@typespec/emitter-framework 0.6.0-dev.4 → 0.6.0-dev.6

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 (92) hide show
  1. package/dist/src/core/context/name-policy-context.js +1 -2
  2. package/dist/src/core/index.js +1 -2
  3. package/dist/src/core/transport-name-policy.js +1 -2
  4. package/dist/src/core/write-output.js +1 -2
  5. package/dist/src/lib.js +1 -2
  6. package/dist/src/testing/index.js +1 -2
  7. package/dist/src/testing/scenario-test/harness.js +1 -2
  8. package/dist/src/testing/scenario-test/index.js +1 -2
  9. package/dist/src/testing/scenario-test/snippet-extractor.js +1 -2
  10. package/dist/src/testing/scenario-test/test-host.js +1 -2
  11. package/dist/src/typescript/components/array-expression.js +1 -2
  12. package/dist/src/typescript/components/arrow-function.js +2 -5
  13. package/dist/src/typescript/components/class-method.js +2 -4
  14. package/dist/src/typescript/components/enum-declaration.js +2 -4
  15. package/dist/src/typescript/components/function-declaration.js +2 -4
  16. package/dist/src/typescript/components/function-expression.js +2 -5
  17. package/dist/src/typescript/components/function-type.js +2 -5
  18. package/dist/src/typescript/components/index.js +1 -2
  19. package/dist/src/typescript/components/interface-declaration.js +2 -5
  20. package/dist/src/typescript/components/interface-member.js +2 -4
  21. package/dist/src/typescript/components/interface-method.d.ts.map +1 -1
  22. package/dist/src/typescript/components/interface-method.js +5 -8
  23. package/dist/src/typescript/components/record-expression.js +1 -2
  24. package/dist/src/typescript/components/static-serializers.js +1 -2
  25. package/dist/src/typescript/components/type-alias-declaration.js +2 -5
  26. package/dist/src/typescript/components/type-declaration.js +2 -4
  27. package/dist/src/typescript/components/type-expression.js +2 -4
  28. package/dist/src/typescript/components/type-transform.js +2 -4
  29. package/dist/src/typescript/components/union-declaration.js +2 -4
  30. package/dist/src/typescript/components/union-expression.js +2 -4
  31. package/dist/src/typescript/components/value-expression.js +2 -4
  32. package/dist/src/typescript/index.js +1 -2
  33. package/dist/src/typescript/lib.js +1 -2
  34. package/dist/src/typescript/utils/operation.js +1 -2
  35. package/dist/test/testing/snippet-extractor-csharp.test.js +96 -0
  36. package/dist/test/testing/snippet-extractor-java.test.js +104 -0
  37. package/dist/test/testing/snippet-extractor-python.test.js +33 -0
  38. package/dist/test/testing/snippet-extractor-typescript.test.js +161 -0
  39. package/dist/test/typescript/components/arrow-function.test.js +88 -0
  40. package/dist/test/typescript/components/enum-declaration.test.js +118 -0
  41. package/dist/test/typescript/components/function-declaration.test.js +246 -0
  42. package/dist/test/typescript/components/function-expression.test.js +88 -0
  43. package/dist/test/typescript/components/function-type.test.js +85 -0
  44. package/dist/test/typescript/components/interface-declaration.test.js +775 -0
  45. package/dist/test/typescript/components/interface-method.test.js +272 -0
  46. package/dist/test/typescript/components/member-expression.test.js +155 -0
  47. package/dist/test/typescript/components/type-alias-declaration.test.js +155 -0
  48. package/dist/test/typescript/components/type-transform.test.js +682 -0
  49. package/dist/test/typescript/components/union-declaration.test.js +205 -0
  50. package/dist/test/typescript/components/value-expression.test.js +199 -0
  51. package/dist/test/typescript/test-host.js +40 -0
  52. package/dist/test/utils.js +18 -0
  53. package/package.json +5 -10
  54. package/src/typescript/components/interface-method.tsx +2 -4
  55. package/test/typescript/components/interface-method.test.tsx +167 -2
  56. package/vitest.config.ts +2 -9
  57. package/babel.config.js +0 -4
  58. package/dist/src/core/context/index.js.map +0 -1
  59. package/dist/src/core/context/name-policy-context.js.map +0 -1
  60. package/dist/src/core/index.js.map +0 -1
  61. package/dist/src/core/transport-name-policy.js.map +0 -1
  62. package/dist/src/core/write-output.js.map +0 -1
  63. package/dist/src/lib.js.map +0 -1
  64. package/dist/src/testing/index.js.map +0 -1
  65. package/dist/src/testing/scenario-test/harness.js.map +0 -1
  66. package/dist/src/testing/scenario-test/index.js.map +0 -1
  67. package/dist/src/testing/scenario-test/snippet-extractor.js.map +0 -1
  68. package/dist/src/testing/scenario-test/test-host.js.map +0 -1
  69. package/dist/src/typescript/components/array-expression.js.map +0 -1
  70. package/dist/src/typescript/components/arrow-function.js.map +0 -1
  71. package/dist/src/typescript/components/class-method.js.map +0 -1
  72. package/dist/src/typescript/components/enum-declaration.js.map +0 -1
  73. package/dist/src/typescript/components/function-declaration.js.map +0 -1
  74. package/dist/src/typescript/components/function-expression.js.map +0 -1
  75. package/dist/src/typescript/components/function-type.js.map +0 -1
  76. package/dist/src/typescript/components/index.js.map +0 -1
  77. package/dist/src/typescript/components/interface-declaration.js.map +0 -1
  78. package/dist/src/typescript/components/interface-member.js.map +0 -1
  79. package/dist/src/typescript/components/interface-method.js.map +0 -1
  80. package/dist/src/typescript/components/record-expression.js.map +0 -1
  81. package/dist/src/typescript/components/static-serializers.js.map +0 -1
  82. package/dist/src/typescript/components/type-alias-declaration.js.map +0 -1
  83. package/dist/src/typescript/components/type-declaration.js.map +0 -1
  84. package/dist/src/typescript/components/type-expression.js.map +0 -1
  85. package/dist/src/typescript/components/type-transform.js.map +0 -1
  86. package/dist/src/typescript/components/union-declaration.js.map +0 -1
  87. package/dist/src/typescript/components/union-expression.js.map +0 -1
  88. package/dist/src/typescript/components/value-expression.js.map +0 -1
  89. package/dist/src/typescript/index.js.map +0 -1
  90. package/dist/src/typescript/lib.js.map +0 -1
  91. package/dist/src/typescript/utils/index.js.map +0 -1
  92. package/dist/src/typescript/utils/operation.js.map +0 -1
@@ -9,5 +9,4 @@ export const TransformNamePolicyContext = createNamedContext("TransfromNamePolic
9
9
  });
10
10
  export function useTransformNamePolicy() {
11
11
  return useContext(TransformNamePolicyContext);
12
- }
13
- //# sourceMappingURL=name-policy-context.js.map
12
+ }
@@ -1,4 +1,3 @@
1
1
  export * from "./context/index.js";
2
2
  export * from "./transport-name-policy.js";
3
- export * from "./write-output.js";
4
- //# sourceMappingURL=index.js.map
3
+ export * from "./write-output.js";
@@ -38,5 +38,4 @@ export function createTransformNamePolicy(namer) {
38
38
  return namer.applicationNamer(type);
39
39
  }
40
40
  };
41
- }
42
- //# sourceMappingURL=transport-name-policy.js.map
41
+ }
@@ -16,5 +16,4 @@ async function writeOutputDirectory(dir, emitterOutputDir) {
16
16
  });
17
17
  }
18
18
  }
19
- }
20
- //# sourceMappingURL=write-output.js.map
19
+ }
package/dist/src/lib.js CHANGED
@@ -14,5 +14,4 @@ export const $lib = createTypeSpecLibrary({
14
14
  export const {
15
15
  reportDiagnostic,
16
16
  createDiagnostic
17
- } = $lib;
18
- //# sourceMappingURL=lib.js.map
17
+ } = $lib;
@@ -5,5 +5,4 @@ export const EmitterFrameworkTestLibrary = createTestLibrary({
5
5
  name: "@typespec/emitter-framework",
6
6
  packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../")
7
7
  });
8
- export * from "./scenario-test/index.js";
9
- //# sourceMappingURL=index.js.map
8
+ export * from "./scenario-test/index.js";
@@ -274,5 +274,4 @@ function splitByH1(content) {
274
274
  };
275
275
  });
276
276
  return sections;
277
- }
278
- //# sourceMappingURL=harness.js.map
277
+ }
@@ -1,4 +1,3 @@
1
1
  export * from "./harness.js";
2
2
  export * from "./snippet-extractor.js";
3
- export * from "./test-host.js";
4
- //# sourceMappingURL=index.js.map
3
+ export * from "./test-host.js";
@@ -149,5 +149,4 @@ class SnippetExtractorImpl {
149
149
  };
150
150
  return traverse(rootNode); // Start traversal from the root node
151
151
  }
152
- }
153
- //# sourceMappingURL=snippet-extractor.js.map
152
+ }
@@ -46,5 +46,4 @@ async function readFilesRecursively(currentDir, emitterOutputDir, runner) {
46
46
  }
47
47
  }
48
48
  return result;
49
- }
50
- //# sourceMappingURL=test-host.js.map
49
+ }
@@ -7,5 +7,4 @@ export function ArrayExpression({
7
7
  return ay.code`Array<${_$createComponent(TypeExpression, {
8
8
  type: elementType
9
9
  })}>`;
10
- }
11
- //# sourceMappingURL=array-expression.js.map
10
+ }
@@ -1,6 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { splitProps } from "@alloy-js/core/jsx-runtime";
1
+ import { splitProps, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
4
2
  import * as ts from "@alloy-js/typescript";
5
3
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
6
4
  import { TypeExpression } from "./type-expression.js";
@@ -27,5 +25,4 @@ export function ArrowFunction(props) {
27
25
  returnType: returnType,
28
26
  parameters: allParameters
29
27
  }));
30
- }
31
- //# sourceMappingURL=arrow-function.js.map
28
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import { refkey as getRefkey } from "@alloy-js/core";
4
3
  import * as ts from "@alloy-js/typescript";
5
4
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
@@ -35,5 +34,4 @@ export function ClassMethod(props) {
35
34
  }
36
35
  function isTypedMethodDeclarationProps(props) {
37
36
  return props.type !== undefined;
38
- }
39
- //# sourceMappingURL=class-method.js.map
37
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import * as ay from "@alloy-js/core";
4
3
  import * as ts from "@alloy-js/typescript";
5
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -61,5 +60,4 @@ export function EnumMember(props) {
61
60
  return ay.refkey(props.refkey ?? props.type);
62
61
  }
63
62
  });
64
- }
65
- //# sourceMappingURL=enum-declaration.js.map
63
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import { refkey as getRefkey } from "@alloy-js/core";
4
3
  import * as ts from "@alloy-js/typescript";
5
4
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
@@ -71,5 +70,4 @@ function isTypedFunctionDeclarationProps(props) {
71
70
  function isTypedFunctionParametersProps(props) {
72
71
  return "type" in props;
73
72
  }
74
- const reservedFunctionKeywords = new Set(["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "return", "super", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "yield", "let", "static", "implements", "interface", "package", "private", "protected", "public", "await"]);
75
- //# sourceMappingURL=function-declaration.js.map
73
+ const reservedFunctionKeywords = new Set(["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "return", "super", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "yield", "let", "static", "implements", "interface", "package", "private", "protected", "public", "await"]);
@@ -1,6 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { splitProps } from "@alloy-js/core/jsx-runtime";
1
+ import { splitProps, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
4
2
  import * as ts from "@alloy-js/typescript";
5
3
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
6
4
  import { TypeExpression } from "./type-expression.js";
@@ -27,5 +25,4 @@ export function FunctionExpression(props) {
27
25
  returnType: returnType,
28
26
  parameters: allParameters
29
27
  }));
30
- }
31
- //# sourceMappingURL=function-expression.js.map
28
+ }
@@ -1,6 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { splitProps } from "@alloy-js/core/jsx-runtime";
1
+ import { splitProps, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
4
2
  import * as ts from "@alloy-js/typescript";
5
3
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
6
4
  import { TypeExpression } from "./type-expression.js";
@@ -27,5 +25,4 @@ export function FunctionType(props) {
27
25
  returnType: returnType,
28
26
  parameters: allParameters
29
27
  }));
30
- }
31
- //# sourceMappingURL=function-type.js.map
28
+ }
@@ -13,5 +13,4 @@ export * from "./type-expression.js";
13
13
  export * from "./type-transform.js";
14
14
  export * from "./union-declaration.js";
15
15
  export * from "./union-expression.js";
16
- export * from "./value-expression.js";
17
- //# sourceMappingURL=index.js.map
16
+ export * from "./value-expression.js";
@@ -1,6 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
4
2
  import * as ay from "@alloy-js/core";
5
3
  import { refkey as getRefkey, mapJoin } from "@alloy-js/core";
6
4
  import * as ts from "@alloy-js/typescript";
@@ -133,5 +131,4 @@ function InterfaceBody(props) {
133
131
  });
134
132
  }
135
133
  })), _$memo(() => props.children)];
136
- }
137
- //# sourceMappingURL=interface-declaration.js.map
134
+ }
@@ -1,5 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
2
  import * as ts from "@alloy-js/typescript";
4
3
  import { isNeverType } from "@typespec/compiler";
5
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -37,5 +36,4 @@ export function InterfaceMember(props) {
37
36
  }
38
37
  });
39
38
  }
40
- }
41
- //# sourceMappingURL=interface-member.js.map
39
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"interface-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-method.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACzF,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,oBAAoB,GAAG,4BAA4B,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAE1F;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,iDA8BpE"}
1
+ {"version":3,"file":"interface-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-method.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACzF,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,oBAAoB,GAAG,4BAA4B,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAE1F;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,iDA4BpE"}
@@ -1,6 +1,4 @@
1
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
- import { splitProps } from "@alloy-js/core/jsx-runtime";
1
+ import { splitProps, createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
4
2
  import * as ts from "@alloy-js/typescript";
5
3
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
6
4
  import { TypeExpression } from "./type-expression.js";
@@ -15,7 +13,7 @@ export function InterfaceMethod(props) {
15
13
  return _$createComponent(ts.InterfaceMethod, props);
16
14
  }
17
15
  const [efProps, updateProps, forwardProps] = splitProps(props, ["type"], ["returnType", "parameters"]);
18
- const name = props.name ? props.name : ts.useTSNamePolicy().getName(efProps.type.name, "function");
16
+ const name = props.name ?? ts.useTSNamePolicy().getName(efProps.type.name, "function");
19
17
  const returnType = props.returnType ?? _$createComponent(TypeExpression, {
20
18
  get type() {
21
19
  return getReturnType(efProps.type);
@@ -25,10 +23,9 @@ export function InterfaceMethod(props) {
25
23
  params: props.parameters,
26
24
  mode: props.parametersMode
27
25
  });
28
- return _$createComponent(ts.InterfaceMethod, _$mergeProps(forwardProps, {
26
+ return _$createComponent(ts.InterfaceMethod, _$mergeProps(forwardProps, updateProps, {
29
27
  name: name,
30
28
  returnType: returnType,
31
29
  parameters: allParameters
32
- }, updateProps));
33
- }
34
- //# sourceMappingURL=interface-method.js.map
30
+ }));
31
+ }
@@ -9,5 +9,4 @@ export function RecordExpression({
9
9
  type: elementType
10
10
  })}>
11
11
  `;
12
- }
13
- //# sourceMappingURL=record-expression.js.map
12
+ }
@@ -186,5 +186,4 @@ export function ArraySerializer() {
186
186
  `];
187
187
  }
188
188
  });
189
- }
190
- //# sourceMappingURL=static-serializers.js.map
189
+ }
@@ -1,6 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
4
2
  import { refkey as getRefkey } from "@alloy-js/core";
5
3
  import * as ts from "@alloy-js/typescript";
6
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -43,5 +41,4 @@ export function TypeAliasDeclaration(props) {
43
41
  }
44
42
  function isTypedAliasDeclarationProps(props) {
45
43
  return "type" in props;
46
- }
47
- //# sourceMappingURL=type-alias-declaration.js.map
44
+ }
@@ -1,5 +1,4 @@
1
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
3
2
  import * as ts from "@alloy-js/typescript";
4
3
  import { EnumDeclaration } from "./enum-declaration.js";
5
4
  import { InterfaceDeclaration } from "./interface-declaration.js";
@@ -35,5 +34,4 @@ export function TypeDeclaration(props) {
35
34
  type: type
36
35
  }, restProps));
37
36
  }
38
- }
39
- //# sourceMappingURL=type-declaration.js.map
37
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import { For, refkey } from "@alloy-js/core";
4
3
  import { Reference, ValueExpression } from "@alloy-js/typescript";
5
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -213,5 +212,4 @@ function isDeclaration(type) {
213
212
  default:
214
213
  return false;
215
214
  }
216
- }
217
- //# sourceMappingURL=type-expression.js.map
215
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import { code, For, mapJoin, refkey } from "@alloy-js/core";
4
3
  import * as ts from "@alloy-js/typescript";
5
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -389,5 +388,4 @@ function getCollapsedProperty(model, collapse) {
389
388
  return Array.from(modelProperties.values())[0];
390
389
  }
391
390
  return undefined;
392
- }
393
- //# sourceMappingURL=type-transform.js.map
391
+ }
@@ -1,5 +1,4 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
2
  import { refkey as getRefkey } from "@alloy-js/core";
4
3
  import * as ts from "@alloy-js/typescript";
5
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -41,5 +40,4 @@ export function UnionDeclaration(props) {
41
40
  }
42
41
  function isTypedUnionDeclarationProps(props) {
43
42
  return "type" in props;
44
- }
45
- //# sourceMappingURL=union-declaration.js.map
43
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import * as ay from "@alloy-js/core";
4
3
  import * as ts from "@alloy-js/typescript";
5
4
  import { $ } from "@typespec/compiler/experimental/typekit";
@@ -32,5 +31,4 @@ export function UnionExpression({
32
31
  return [variants, " ", ` | ${children}`];
33
32
  }
34
33
  return variants;
35
- }
36
- //# sourceMappingURL=union-expression.js.map
34
+ }
@@ -1,5 +1,4 @@
1
- import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
2
  import * as ts from "@alloy-js/typescript";
4
3
  import { compilerAssert } from "@typespec/compiler";
5
4
 
@@ -68,5 +67,4 @@ export function ValueExpression(props) {
68
67
  }
69
68
  });
70
69
  }
71
- }
72
- //# sourceMappingURL=value-expression.js.map
70
+ }
@@ -1,3 +1,2 @@
1
1
  export * from "./components/index.js";
2
- export * from "./utils/index.js";
3
- //# sourceMappingURL=index.js.map
2
+ export * from "./utils/index.js";
@@ -61,5 +61,4 @@ export const $typescriptLib = createTypeSpecLibrary({
61
61
  export const {
62
62
  reportDiagnostic: reportTypescriptDiagnostic,
63
63
  createDiagnostic: CreateTypescriptDiagnostic
64
- } = $typescriptLib;
65
- //# sourceMappingURL=lib.js.map
64
+ } = $typescriptLib;
@@ -51,5 +51,4 @@ function normalizeParameters(params) {
51
51
  }
52
52
  return param;
53
53
  });
54
- }
55
- //# sourceMappingURL=operation.js.map
54
+ }
@@ -0,0 +1,96 @@
1
+ import { d } from "@alloy-js/core/testing";
2
+ import { beforeEach, describe, expect, it } from "vitest";
3
+ import { createCSharpExtractorConfig, createSnipperExtractor } from "../../src/testing/index.js";
4
+ describe("C# Snippet Extractor", () => {
5
+ let extractor;
6
+ beforeEach(() => {
7
+ extractor = createSnipperExtractor(createCSharpExtractorConfig());
8
+ });
9
+ it("should extract a class", () => {
10
+ const content = d`
11
+ public class Foo {
12
+ public Foo() {
13
+ Console.WriteLine("Hello");
14
+ }
15
+ }
16
+ `;
17
+ const snippet = extractor.getClass(content, "Foo");
18
+ expect(snippet).toBe(d`
19
+ public class Foo {
20
+ public Foo() {
21
+ Console.WriteLine("Hello");
22
+ }
23
+ }
24
+ `);
25
+ });
26
+ it("should extract an interface", () => {
27
+ const content = d`
28
+ public interface IMyInterface {
29
+ string Foo();
30
+ }
31
+ `;
32
+ const snippet = extractor.getInterface(content, "IMyInterface");
33
+ expect(snippet).toBe(d`
34
+ public interface IMyInterface {
35
+ string Foo();
36
+ }
37
+ `);
38
+ });
39
+ it("should extract a function", () => {
40
+ const content = d`
41
+ public string Greet(string name) {
42
+ return "Hello " + name;
43
+ }
44
+ `;
45
+ const snippet = extractor.getFunction(content, "Greet");
46
+ expect(snippet).toBe(d`
47
+ public string Greet(string name) {
48
+ return "Hello " + name;
49
+ }
50
+ `);
51
+ });
52
+ });
53
+ describe("C# Snippet Extractor - Enums", () => {
54
+ let extractor;
55
+ beforeEach(() => {
56
+ extractor = createSnipperExtractor(createCSharpExtractorConfig());
57
+ });
58
+ it("should extract a basic enum", async () => {
59
+ const content = d`
60
+ public enum Direction
61
+ {
62
+ Up,
63
+ Down,
64
+ Left,
65
+ Right
66
+ }
67
+ `;
68
+ const snippet = extractor.getEnum(content, "Direction");
69
+ expect(snippet).toBe(d`
70
+ public enum Direction
71
+ {
72
+ Up,
73
+ Down,
74
+ Left,
75
+ Right
76
+ }
77
+ `);
78
+ });
79
+ it("should extract an enum with values", async () => {
80
+ const content = d`
81
+ public enum Status
82
+ {
83
+ Active = 1,
84
+ Inactive = 2
85
+ }
86
+ `;
87
+ const snippet = extractor.getEnum(content, "Status");
88
+ expect(snippet).toBe(d`
89
+ public enum Status
90
+ {
91
+ Active = 1,
92
+ Inactive = 2
93
+ }
94
+ `);
95
+ });
96
+ });
@@ -0,0 +1,104 @@
1
+ import { d } from "@alloy-js/core/testing";
2
+ import { beforeEach, describe, expect, it } from "vitest";
3
+ import { createJavaExtractorConfig, createSnipperExtractor } from "../../src/testing/index.js";
4
+ describe("Java Snippet Extractor", () => {
5
+ let extractor;
6
+ beforeEach(() => {
7
+ extractor = createSnipperExtractor(createJavaExtractorConfig());
8
+ });
9
+ it("should extract a class", () => {
10
+ const content = d`
11
+ public class Foo {
12
+ public Foo() {
13
+ System.out.println("Hello");
14
+ }
15
+ }
16
+ `;
17
+ const snippet = extractor.getClass(content, "Foo");
18
+ expect(snippet).toBe(d`
19
+ public class Foo {
20
+ public Foo() {
21
+ System.out.println("Hello");
22
+ }
23
+ }
24
+ `);
25
+ });
26
+ it("should extract an interface", () => {
27
+ const content = d`
28
+ public interface MyInterface {
29
+ String foo();
30
+ }
31
+ `;
32
+ const snippet = extractor.getInterface(content, "MyInterface");
33
+ expect(snippet).toBe(d`
34
+ public interface MyInterface {
35
+ String foo();
36
+ }
37
+ `);
38
+ });
39
+ it("should extract a function", () => {
40
+ const content = d`
41
+ public String greet(String name) {
42
+ return "Hello " + name;
43
+ }
44
+ `;
45
+ const snippet = extractor.getFunction(content, "greet");
46
+ expect(snippet).toBe(d`
47
+ public String greet(String name) {
48
+ return "Hello " + name;
49
+ }
50
+ `);
51
+ });
52
+ });
53
+ describe("Java Snippet Extractor - Enums", () => {
54
+ let extractor;
55
+ beforeEach(() => {
56
+ extractor = createSnipperExtractor(createJavaExtractorConfig());
57
+ });
58
+ it("should extract a basic enum", async () => {
59
+ const content = d`
60
+ public enum Direction {
61
+ UP,
62
+ DOWN,
63
+ LEFT,
64
+ RIGHT
65
+ }
66
+ `;
67
+ const snippet = extractor.getEnum(content, "Direction");
68
+ expect(snippet).toBe(d`
69
+ public enum Direction {
70
+ UP,
71
+ DOWN,
72
+ LEFT,
73
+ RIGHT
74
+ }
75
+ `);
76
+ });
77
+ it("should extract an enum with constructor values", async () => {
78
+ const content = d`
79
+ public enum Status {
80
+ ACTIVE(1),
81
+ INACTIVE(2);
82
+
83
+ private final int value;
84
+
85
+ Status(int value) {
86
+ this.value = value;
87
+ }
88
+ }
89
+ `;
90
+ const snippet = extractor.getEnum(content, "Status");
91
+ expect(snippet).toBe(d`
92
+ public enum Status {
93
+ ACTIVE(1),
94
+ INACTIVE(2);
95
+
96
+ private final int value;
97
+
98
+ Status(int value) {
99
+ this.value = value;
100
+ }
101
+ }
102
+ `);
103
+ });
104
+ });
@@ -0,0 +1,33 @@
1
+ import { d } from "@alloy-js/core/testing";
2
+ import { beforeEach, describe, expect, it } from "vitest";
3
+ import { createPythonExtractorConfig, createSnipperExtractor } from "../../src/testing/index.js";
4
+ describe("Python Snippet Extractor", () => {
5
+ let extractor;
6
+ beforeEach(() => {
7
+ extractor = createSnipperExtractor(createPythonExtractorConfig());
8
+ });
9
+ it("should extract a class", () => {
10
+ const content = d`
11
+ class Foo:
12
+ def __init__(self):
13
+ print("Hello")
14
+ `;
15
+ const snippet = extractor.getClass(content, "Foo");
16
+ expect(snippet).toBe(d`
17
+ class Foo:
18
+ def __init__(self):
19
+ print("Hello")
20
+ `);
21
+ });
22
+ it("should extract a function", () => {
23
+ const content = d`
24
+ def greet(name: str) -> str:
25
+ return f"Hello {name}"
26
+ `;
27
+ const snippet = extractor.getFunction(content, "greet");
28
+ expect(snippet).toBe(d`
29
+ def greet(name: str) -> str:
30
+ return f"Hello {name}"
31
+ `);
32
+ });
33
+ });