@typespec/emitter-framework 0.9.0-dev.0 → 0.9.0-dev.10
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.
- package/dist/src/core/components/output.d.ts +4 -4
- package/dist/src/core/components/output.d.ts.map +1 -1
- package/dist/src/core/components/output.js +3 -3
- package/dist/src/core/context/name-policy-context.d.ts +2 -2
- package/dist/src/core/context/name-policy-context.d.ts.map +1 -1
- package/dist/src/core/context/tsp-context.d.ts +2 -2
- package/dist/src/core/context/tsp-context.d.ts.map +1 -1
- package/dist/src/core/transport-name-policy.d.ts +1 -1
- package/dist/src/core/transport-name-policy.d.ts.map +1 -1
- package/dist/src/core/write-output.d.ts +2 -2
- package/dist/src/core/write-output.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.d.ts +13 -0
- package/dist/src/csharp/components/class/declaration.d.ts.map +1 -0
- package/dist/src/csharp/components/class/declaration.js +91 -0
- package/dist/src/csharp/components/class/declaration.test.d.ts +2 -0
- package/dist/src/csharp/components/class/declaration.test.d.ts.map +1 -0
- package/dist/src/csharp/components/class/declaration.test.js +377 -0
- package/dist/src/csharp/components/enum/declaration.d.ts +9 -0
- package/dist/src/csharp/components/enum/declaration.d.ts.map +1 -0
- package/dist/src/csharp/components/enum/declaration.js +55 -0
- package/dist/src/csharp/components/enum/declaration.test.d.ts +2 -0
- package/dist/src/csharp/components/enum/declaration.test.d.ts.map +1 -0
- package/dist/src/csharp/components/enum/declaration.test.js +309 -0
- package/dist/src/csharp/components/index.d.ts +5 -0
- package/dist/src/csharp/components/index.d.ts.map +1 -0
- package/dist/src/csharp/components/index.js +4 -0
- package/dist/src/csharp/components/property/property.d.ts +15 -0
- package/dist/src/csharp/components/property/property.d.ts.map +1 -0
- package/dist/src/csharp/components/property/property.js +85 -0
- package/dist/src/csharp/components/property/property.test.d.ts +2 -0
- package/dist/src/csharp/components/property/property.test.d.ts.map +1 -0
- package/dist/src/csharp/components/property/property.test.js +117 -0
- package/dist/src/csharp/components/type-expression.d.ts +11 -0
- package/dist/src/csharp/components/type-expression.d.ts.map +1 -0
- package/dist/src/csharp/components/type-expression.js +143 -0
- package/dist/src/csharp/components/type-expression.test.d.ts +2 -0
- package/dist/src/csharp/components/type-expression.test.d.ts.map +1 -0
- package/dist/src/csharp/components/type-expression.test.js +128 -0
- package/dist/src/csharp/components/utils/doc-comments.d.ts +14 -0
- package/dist/src/csharp/components/utils/doc-comments.d.ts.map +1 -0
- package/dist/src/csharp/components/utils/doc-comments.js +67 -0
- package/dist/src/csharp/components/utils/refkey.d.ts +23 -0
- package/dist/src/csharp/components/utils/refkey.d.ts.map +1 -0
- package/dist/src/csharp/components/utils/refkey.js +35 -0
- package/dist/src/csharp/index.d.ts +2 -0
- package/dist/src/csharp/index.d.ts.map +1 -0
- package/dist/src/csharp/index.js +1 -0
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/code-block-expectation.d.ts +33 -0
- package/dist/src/testing/scenario-test/code-block-expectation.d.ts.map +1 -0
- package/dist/src/testing/scenario-test/code-block-expectation.js +69 -0
- package/dist/src/testing/scenario-test/code-block-expectation.test.d.ts +2 -0
- package/dist/src/testing/scenario-test/code-block-expectation.test.d.ts.map +1 -0
- package/dist/src/testing/scenario-test/code-block-expectation.test.js +80 -0
- package/dist/src/testing/scenario-test/harness.d.ts +3 -3
- package/dist/src/testing/scenario-test/harness.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/harness.js +69 -158
- package/dist/src/testing/scenario-test/index.d.ts +0 -1
- package/dist/src/testing/scenario-test/index.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/index.js +1 -2
- package/dist/src/testing/scenario-test/snippet-extractor.d.ts +1 -1
- package/dist/src/testing/scenario-test/snippet-extractor.js +1 -1
- package/dist/src/typescript/components/array-expression.d.ts +2 -3
- package/dist/src/typescript/components/array-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/array-expression.js +2 -2
- package/dist/src/typescript/components/arrow-function.d.ts +2 -2
- package/dist/src/typescript/components/arrow-function.d.ts.map +1 -1
- package/dist/src/typescript/components/arrow-function.js +2 -1
- package/dist/src/typescript/components/class-method.d.ts +1 -1
- package/dist/src/typescript/components/class-method.d.ts.map +1 -1
- package/dist/src/typescript/components/enum-declaration.d.ts +6 -6
- package/dist/src/typescript/components/enum-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/enum-declaration.js +2 -2
- package/dist/src/typescript/components/function-declaration.d.ts +1 -1
- package/dist/src/typescript/components/function-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/function-expression.d.ts +2 -2
- package/dist/src/typescript/components/function-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/function-expression.js +2 -1
- package/dist/src/typescript/components/function-type.d.ts +2 -2
- package/dist/src/typescript/components/function-type.d.ts.map +1 -1
- package/dist/src/typescript/components/function-type.js +2 -1
- package/dist/src/typescript/components/interface-declaration.d.ts +4 -4
- package/dist/src/typescript/components/interface-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-declaration.js +3 -4
- package/dist/src/typescript/components/interface-member.d.ts +2 -2
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-method.d.ts +2 -2
- package/dist/src/typescript/components/interface-method.d.ts.map +1 -1
- package/dist/src/typescript/components/record-expression.d.ts +1 -1
- package/dist/src/typescript/components/record-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-alias-declaration.d.ts +1 -1
- package/dist/src/typescript/components/type-alias-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-expression.d.ts +1 -1
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-transform.d.ts +2 -2
- package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
- package/dist/src/typescript/components/union-declaration.d.ts +2 -2
- package/dist/src/typescript/components/union-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/union-expression.d.ts +3 -4
- package/dist/src/typescript/components/union-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/union-expression.js +3 -3
- package/dist/src/typescript/components/value-expression.d.ts +2 -2
- package/dist/src/typescript/components/value-expression.d.ts.map +1 -1
- package/dist/src/typescript/utils/operation.d.ts +2 -2
- package/dist/src/typescript/utils/operation.d.ts.map +1 -1
- package/dist/test/test-host.d.ts +2 -0
- package/dist/test/test-host.d.ts.map +1 -0
- package/dist/test/test-host.js +5 -0
- package/dist/test/testing/snippet-extractor-csharp.test.js +3 -3
- package/dist/test/testing/snippet-extractor-java.test.js +3 -3
- package/dist/test/testing/snippet-extractor-python.test.js +2 -2
- package/dist/test/testing/snippet-extractor-typescript.test.js +3 -3
- package/dist/test/typescript/components/member-expression.test.js +5 -5
- package/dist/test/typescript/test-host.d.ts +1 -1
- package/dist/test/typescript/test-host.d.ts.map +1 -1
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +1 -0
- package/package.json +30 -8
- package/src/core/components/output.tsx +9 -5
- package/src/core/context/name-policy-context.ts +2 -2
- package/src/core/context/tsp-context.ts +2 -2
- package/src/core/transport-name-policy.ts +1 -1
- package/src/core/write-output.ts +2 -2
- package/src/csharp/components/class/declaration.test.tsx +339 -0
- package/src/csharp/components/class/declaration.tsx +86 -0
- package/src/csharp/components/enum/declaration.test.tsx +267 -0
- package/src/csharp/components/enum/declaration.tsx +56 -0
- package/src/csharp/components/index.ts +4 -0
- package/src/csharp/components/property/property.test.tsx +97 -0
- package/src/csharp/components/property/property.tsx +62 -0
- package/src/csharp/components/type-expression.test.tsx +133 -0
- package/src/csharp/components/type-expression.tsx +119 -0
- package/src/csharp/components/utils/doc-comments.tsx +58 -0
- package/src/csharp/components/utils/refkey.ts +36 -0
- package/src/csharp/index.ts +1 -0
- package/src/testing/index.ts +1 -1
- package/src/testing/scenario-test/code-block-expectation.test.ts +95 -0
- package/src/testing/scenario-test/code-block-expectation.ts +115 -0
- package/src/testing/scenario-test/harness.ts +92 -237
- package/src/testing/scenario-test/index.ts +0 -1
- package/src/testing/scenario-test/snippet-extractor.ts +1 -1
- package/src/typescript/components/array-expression.tsx +3 -3
- package/src/typescript/components/arrow-function.tsx +2 -2
- package/src/typescript/components/class-method.tsx +1 -1
- package/src/typescript/components/enum-declaration.tsx +6 -6
- package/src/typescript/components/function-declaration.tsx +1 -1
- package/src/typescript/components/function-expression.tsx +2 -2
- package/src/typescript/components/function-type.tsx +2 -2
- package/src/typescript/components/interface-declaration.tsx +11 -12
- package/src/typescript/components/interface-member.tsx +2 -2
- package/src/typescript/components/interface-method.tsx +2 -2
- package/src/typescript/components/record-expression.tsx +1 -1
- package/src/typescript/components/type-alias-declaration.tsx +1 -1
- package/src/typescript/components/type-declaration.tsx +1 -1
- package/src/typescript/components/type-expression.tsx +2 -2
- package/src/typescript/components/type-transform.tsx +3 -3
- package/src/typescript/components/union-declaration.tsx +2 -2
- package/src/typescript/components/union-expression.tsx +12 -7
- package/src/typescript/components/value-expression.tsx +2 -2
- package/src/typescript/utils/operation.ts +2 -2
- package/test/test-host.ts +4 -0
- package/test/testing/snippet-extractor-csharp.test.ts +4 -4
- package/test/testing/snippet-extractor-java.test.ts +4 -4
- package/test/testing/snippet-extractor-python.test.ts +3 -3
- package/test/testing/snippet-extractor-typescript.test.ts +4 -4
- package/test/typescript/components/arrow-function.test.tsx +2 -2
- package/test/typescript/components/enum-declaration.test.tsx +1 -1
- package/test/typescript/components/function-declaration.test.tsx +1 -1
- package/test/typescript/components/function-expression.test.tsx +2 -2
- package/test/typescript/components/function-type.test.tsx +2 -2
- package/test/typescript/components/interface-declaration.test.tsx +1 -1
- package/test/typescript/components/interface-method.test.tsx +2 -2
- package/test/typescript/components/member-expression.test.tsx +10 -10
- package/test/typescript/components/type-alias-declaration.test.tsx +1 -1
- package/test/typescript/components/type-transform.test.tsx +2 -2
- package/test/typescript/components/union-declaration.test.tsx +2 -2
- package/test/typescript/components/value-expression.test.tsx +6 -6
- package/test/typescript/test-host.ts +1 -1
- package/test/utils.ts +2 -2
- package/test/vitest.setup.ts +1 -0
- package/tsconfig.json +3 -1
- package/vitest.config.ts +2 -1
- package/dist/src/testing/scenario-test/test-host.d.ts +0 -8
- package/dist/src/testing/scenario-test/test-host.d.ts.map +0 -1
- package/dist/src/testing/scenario-test/test-host.js +0 -49
- package/src/testing/scenario-test/test-host.ts +0 -83
|
@@ -1,145 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logDiagnostics, NodeHost } from "@typespec/compiler";
|
|
2
|
+
import { expectDiagnosticEmpty } from "@typespec/compiler/testing";
|
|
2
3
|
import { readdirSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
3
|
-
import
|
|
4
|
-
import path from "path";
|
|
4
|
+
import { join } from "pathe";
|
|
5
5
|
import { format } from "prettier";
|
|
6
|
-
import { afterAll, describe, expect, it } from "vitest";
|
|
7
|
-
import {
|
|
8
|
-
const rawArgs = process.env.TEST_ARGS ? process.env.TEST_ARGS.split(" ") : [];
|
|
9
|
-
|
|
10
|
-
// Parse command-line arguments with minimist
|
|
11
|
-
const args = minimist(rawArgs, {
|
|
12
|
-
alias: {
|
|
13
|
-
filter: "f" // Short alias for `--filter`
|
|
14
|
-
},
|
|
15
|
-
default: {
|
|
16
|
-
filter: undefined // Default to undefined if no filter is provided
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Extract the filter paths from the parsed arguments
|
|
21
|
-
const filterPaths = args.filter ? Array.isArray(args.filter) // Handle single or multiple file paths
|
|
22
|
-
? args.filter : [args.filter] : undefined;
|
|
6
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
7
|
+
import { getExcerptForQuery, parseCodeblockExpectation } from "./code-block-expectation.js";
|
|
23
8
|
const SCENARIOS_UPDATE = process.env["RECORD"] === "true" || process.env["SCENARIOS_UPDATE"] === "true";
|
|
24
|
-
async function
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const warnings = diagnostics.filter(d => d.severity === "warning");
|
|
28
|
-
if (warnings.length > 0) {
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.warn(`Warning compiling code:\n ${warnings.map(x => x.message).join("\n")}`);
|
|
31
|
-
}
|
|
32
|
-
if (errors.length > 0) {
|
|
33
|
-
throw new Error(`Error compiling code:\n ${errors.map(x => x.message).join("\n")}`);
|
|
34
|
-
}
|
|
35
|
-
const normalizedTarget = normalizePath(file);
|
|
36
|
-
const sourceFile = emittedFiles.find(x => normalizePath(x.path) === normalizedTarget);
|
|
37
|
-
if (!sourceFile) {
|
|
38
|
-
throw new Error(`File ${file} not found in emitted files:\n ${emittedFiles.map(f => f.path).join("\n")}`);
|
|
39
|
-
}
|
|
40
|
-
return sourceFile;
|
|
9
|
+
export async function executeScenarios(tester, languageConfiguration, scenariosLocation, snippetExtractor) {
|
|
10
|
+
const scenarioList = discoverAllScenarios(scenariosLocation);
|
|
11
|
+
describeScenarios(scenarioList, tester, languageConfiguration, snippetExtractor);
|
|
41
12
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const snippet = snippetExtractor.getInterface(sourceFile.content, name);
|
|
57
|
-
if (!snippet) {
|
|
58
|
-
throw new Error(`Interface ${name} not found in ${file}`);
|
|
59
|
-
}
|
|
60
|
-
return snippet;
|
|
61
|
-
},
|
|
62
|
-
[`(${languageTags}) {file} type {name}`]: async (code, {
|
|
63
|
-
file,
|
|
64
|
-
name
|
|
65
|
-
}) => {
|
|
66
|
-
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
67
|
-
const snippet = snippetExtractor.getTypeAlias(sourceFile.content, name);
|
|
68
|
-
if (!snippet) {
|
|
69
|
-
throw new Error(`Type alias ${name} not found in ${file}`);
|
|
70
|
-
}
|
|
71
|
-
return snippet;
|
|
72
|
-
},
|
|
73
|
-
// Snapshot of a particular function named {name} in the models file
|
|
74
|
-
[`(${languageTags}) {file} function {name}`]: async (code, {
|
|
75
|
-
file,
|
|
76
|
-
name
|
|
77
|
-
}) => {
|
|
78
|
-
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
79
|
-
const snippet = snippetExtractor.getFunction(sourceFile.content, name);
|
|
80
|
-
if (!snippet) {
|
|
81
|
-
throw new Error(`Function ${name} not found in ${file}`);
|
|
82
|
-
}
|
|
83
|
-
return snippet;
|
|
84
|
-
},
|
|
85
|
-
// Snapshot of a particular class named {name} in the models file
|
|
86
|
-
[`(${languageTags}) {file} class {name}`]: async (code, {
|
|
87
|
-
file,
|
|
88
|
-
name
|
|
89
|
-
}) => {
|
|
90
|
-
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
91
|
-
const snippet = snippetExtractor.getClass(sourceFile.content, name);
|
|
92
|
-
if (!snippet) {
|
|
93
|
-
throw new Error(`Class ${name} not found in ${file}`);
|
|
13
|
+
function discoverAllScenarios(dir) {
|
|
14
|
+
const scenarios = [];
|
|
15
|
+
function recurse(current) {
|
|
16
|
+
const children = readdirSync(join(dir, current));
|
|
17
|
+
for (const child of children) {
|
|
18
|
+
const fullPath = join(dir, current, child);
|
|
19
|
+
const stat = statSync(fullPath);
|
|
20
|
+
if (stat.isDirectory()) {
|
|
21
|
+
recurse(join(current, child));
|
|
22
|
+
} else {
|
|
23
|
+
scenarios.push({
|
|
24
|
+
path: fullPath,
|
|
25
|
+
relativePath: join(current, child)
|
|
26
|
+
});
|
|
94
27
|
}
|
|
95
|
-
return snippet;
|
|
96
|
-
},
|
|
97
|
-
// Snapshot of the entire file
|
|
98
|
-
[`(${languageTags}) {file}`]: async (code, {
|
|
99
|
-
file
|
|
100
|
-
}) => {
|
|
101
|
-
const sourceFile = await assertGetEmittedFile(testLibrary, emitterOutputDir, file, code);
|
|
102
|
-
return sourceFile.content;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
export async function executeScenarios(testLibrary, languageConfiguration, scenariosLocation, emitterOutputDir, snippetExtractor) {
|
|
107
|
-
const scenarioList = filterPaths ?? [];
|
|
108
|
-
// eslint-disable-next-line no-console
|
|
109
|
-
scenarioList.length && console.log("Filtering scenarios: ", scenarioList);
|
|
110
|
-
if (!scenarioList.length) {
|
|
111
|
-
// Add all scenarios.
|
|
112
|
-
discoverAllScenarios(scenariosLocation, scenarioList);
|
|
113
|
-
}
|
|
114
|
-
describeScenarios(scenarioList, testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor);
|
|
115
|
-
}
|
|
116
|
-
function discoverAllScenarios(location, scenarios) {
|
|
117
|
-
const children = readdirSync(location);
|
|
118
|
-
for (const child of children) {
|
|
119
|
-
const fullPath = path.join(location, child);
|
|
120
|
-
const stat = statSync(fullPath);
|
|
121
|
-
if (stat.isDirectory()) {
|
|
122
|
-
discoverAllScenarios(fullPath, scenarios);
|
|
123
|
-
} else {
|
|
124
|
-
scenarios.push(fullPath);
|
|
125
28
|
}
|
|
126
29
|
}
|
|
30
|
+
recurse("");
|
|
127
31
|
return scenarios;
|
|
128
32
|
}
|
|
129
|
-
function parseFile(
|
|
33
|
+
function parseFile(file) {
|
|
130
34
|
// Read the whole file
|
|
131
|
-
const rawContent = readFileSync(path, {
|
|
35
|
+
const rawContent = readFileSync(file.path, {
|
|
132
36
|
encoding: "utf-8"
|
|
133
37
|
});
|
|
134
38
|
|
|
135
39
|
// Split the content by H1
|
|
136
40
|
const sections = splitByH1(rawContent);
|
|
137
41
|
const scenarioFile = {
|
|
138
|
-
|
|
42
|
+
...file,
|
|
139
43
|
scenarios: []
|
|
140
44
|
};
|
|
141
45
|
for (const section of sections) {
|
|
142
|
-
const scenarioContent = parseScenario(section.content
|
|
46
|
+
const scenarioContent = parseScenario(section.content);
|
|
143
47
|
const scenario = {
|
|
144
48
|
title: section.title,
|
|
145
49
|
content: scenarioContent
|
|
@@ -151,47 +55,43 @@ function parseFile(path, testLibrary, languageConfiguration, emitterOutputDir, s
|
|
|
151
55
|
function isTestCodeBlock(codeBlock) {
|
|
152
56
|
return codeBlock.kind === "test";
|
|
153
57
|
}
|
|
154
|
-
function parseScenario(content
|
|
58
|
+
function parseScenario(content) {
|
|
155
59
|
const rawLines = content.split("\n");
|
|
156
60
|
const scenario = {
|
|
157
61
|
lines: [],
|
|
158
62
|
specBlock: {
|
|
159
63
|
kind: "spec",
|
|
160
|
-
content:
|
|
64
|
+
content: ""
|
|
161
65
|
},
|
|
162
66
|
testBlocks: []
|
|
163
67
|
};
|
|
164
68
|
let currentCodeBlock = null;
|
|
165
|
-
|
|
166
|
-
// Precompute output code block types once
|
|
167
|
-
const outputCodeBlockTypes = getCodeBlockTypes(testLibrary, languageConfiguration, emitterOutputDir, snippetExtractor);
|
|
168
69
|
for (const line of rawLines) {
|
|
169
70
|
if (line.startsWith("```") && currentCodeBlock) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
71
|
+
const heading = currentCodeBlock.heading;
|
|
72
|
+
const codeBlockKind = heading.includes("tsp") || heading.includes("typespec") ? "spec" : "test";
|
|
73
|
+
const content = currentCodeBlock.content.join("\n");
|
|
74
|
+
if (codeBlockKind === "spec") {
|
|
75
|
+
const codeblock = {
|
|
76
|
+
kind: "spec",
|
|
77
|
+
content
|
|
78
|
+
};
|
|
79
|
+
scenario.lines.push(codeblock);
|
|
80
|
+
scenario.specBlock.content = content;
|
|
174
81
|
} else {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
};
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
scenario.testBlocks.push(currentCodeBlock);
|
|
82
|
+
const codeblock = {
|
|
83
|
+
kind: "test",
|
|
84
|
+
heading: currentCodeBlock.heading,
|
|
85
|
+
content,
|
|
86
|
+
expectation: parseCodeblockExpectation(currentCodeBlock.heading, content)
|
|
87
|
+
};
|
|
88
|
+
scenario.lines.push(codeblock);
|
|
89
|
+
scenario.testBlocks.push(codeblock);
|
|
188
90
|
}
|
|
189
91
|
currentCodeBlock = null;
|
|
190
92
|
} else if (line.startsWith("```")) {
|
|
191
|
-
const codeBlockKind = line.includes("tsp") || line.includes("typespec") ? "spec" : "test";
|
|
192
93
|
// Start a new code block
|
|
193
94
|
currentCodeBlock = {
|
|
194
|
-
kind: codeBlockKind,
|
|
195
95
|
heading: line.substring(3),
|
|
196
96
|
content: []
|
|
197
97
|
};
|
|
@@ -205,26 +105,37 @@ function parseScenario(content, testLibrary, languageConfiguration, emitterOutpu
|
|
|
205
105
|
}
|
|
206
106
|
return scenario;
|
|
207
107
|
}
|
|
208
|
-
function describeScenarios(scenarioFiles,
|
|
209
|
-
const scenarios = scenarioFiles.map(f => parseFile(f
|
|
108
|
+
function describeScenarios(scenarioFiles, tester, languageConfiguration, snippetExtractor) {
|
|
109
|
+
const scenarios = scenarioFiles.map(f => parseFile(f));
|
|
210
110
|
for (const scenarioFile of scenarios) {
|
|
211
|
-
describe(
|
|
111
|
+
describe(`${scenarioFile.relativePath}`, () => {
|
|
212
112
|
for (const scenario of scenarioFile.scenarios) {
|
|
213
113
|
const isOnly = scenario.title.includes("only:");
|
|
214
114
|
const isSkip = scenario.title.includes("skip:");
|
|
215
115
|
const describeFn = isSkip ? describe.skip : isOnly ? describe.only : describe;
|
|
116
|
+
let outputFiles;
|
|
117
|
+
beforeAll(async () => {
|
|
118
|
+
const code = scenario.content.specBlock.content;
|
|
119
|
+
const [{
|
|
120
|
+
outputs
|
|
121
|
+
}, diagnostics] = await tester.compileAndDiagnose(code);
|
|
122
|
+
const errors = diagnostics.filter(d => d.severity === "error");
|
|
123
|
+
const warnings = diagnostics.filter(d => d.severity === "warning");
|
|
124
|
+
if (warnings.length > 0) {
|
|
125
|
+
// TODO: this should ideally fail the test or be part of the expectation.
|
|
126
|
+
logDiagnostics(warnings, NodeHost.logSink);
|
|
127
|
+
}
|
|
128
|
+
expectDiagnosticEmpty(errors);
|
|
129
|
+
outputFiles = outputs;
|
|
130
|
+
});
|
|
216
131
|
describeFn(`Scenario: ${scenario.title}`, () => {
|
|
217
132
|
for (const testBlock of scenario.content.testBlocks) {
|
|
218
133
|
it(`Test: ${testBlock.heading}`, async () => {
|
|
219
|
-
const
|
|
220
|
-
fn,
|
|
221
|
-
namedArgs
|
|
222
|
-
} = testBlock.matchedTemplate;
|
|
223
|
-
const result = await fn(scenario.content.specBlock.content.join("\n"), namedArgs ?? {});
|
|
134
|
+
const result = getExcerptForQuery(snippetExtractor, testBlock.expectation, outputFiles);
|
|
224
135
|
if (SCENARIOS_UPDATE) {
|
|
225
|
-
testBlock.content =
|
|
136
|
+
testBlock.content = await languageConfiguration.format(result);
|
|
226
137
|
} else {
|
|
227
|
-
const expected = await languageConfiguration.format(testBlock.content
|
|
138
|
+
const expected = await languageConfiguration.format(testBlock.content);
|
|
228
139
|
const actual = await languageConfiguration.format(result);
|
|
229
140
|
expect(actual).toBe(expected);
|
|
230
141
|
}
|
|
@@ -252,7 +163,7 @@ async function updateFile(scenarioFile) {
|
|
|
252
163
|
} else {
|
|
253
164
|
const heading = isTestCodeBlock(line) ? line.heading : "tsp";
|
|
254
165
|
newContent.push("```" + heading);
|
|
255
|
-
newContent.push(
|
|
166
|
+
newContent.push(line.content);
|
|
256
167
|
newContent.push("```");
|
|
257
168
|
}
|
|
258
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/scenario-test/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/scenario-test/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
|
|
@@ -22,5 +22,5 @@ export interface LanguageConfiguration {
|
|
|
22
22
|
enumNodeType?: string;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function createSnippetExtractor(languageConfiguration: LanguageConfiguration): SnippetExtractor;
|
|
26
26
|
//# sourceMappingURL=snippet-extractor.d.ts.map
|
|
@@ -67,7 +67,7 @@ export async function createTypeScriptExtractorConfig() {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
await Parser.init();
|
|
70
|
-
export function
|
|
70
|
+
export function createSnippetExtractor(languageConfiguration) {
|
|
71
71
|
return new SnippetExtractorImpl(languageConfiguration);
|
|
72
72
|
}
|
|
73
73
|
class SnippetExtractorImpl {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Type } from "@typespec/compiler";
|
|
1
|
+
import type { Type } from "@typespec/compiler";
|
|
3
2
|
export interface ArrayExpressionProps {
|
|
4
3
|
elementType: Type;
|
|
5
4
|
}
|
|
6
|
-
export declare function ArrayExpression({ elementType }: ArrayExpressionProps):
|
|
5
|
+
export declare function ArrayExpression({ elementType }: ArrayExpressionProps): import("@alloy-js/core").Children;
|
|
7
6
|
//# sourceMappingURL=array-expression.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/array-expression.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/array-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,IAAI,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,EAAE,oBAAoB,qCAEpE"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
3
|
import { TypeExpression } from "./type-expression.js";
|
|
4
4
|
export function ArrayExpression({
|
|
5
5
|
elementType
|
|
6
6
|
}) {
|
|
7
|
-
return
|
|
7
|
+
return code`Array<${_$createComponent(TypeExpression, {
|
|
8
8
|
type: elementType
|
|
9
9
|
})}>`;
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import { Operation } from "@typespec/compiler";
|
|
2
|
+
import type { Operation } from "@typespec/compiler";
|
|
3
3
|
export interface ArrowFunctionProps extends ts.ArrowFunctionProps {
|
|
4
4
|
type?: Operation;
|
|
5
5
|
/**
|
|
@@ -13,5 +13,5 @@ export interface ArrowFunctionProps extends ts.ArrowFunctionProps {
|
|
|
13
13
|
* function by converting from a TypeSpec Operation. Any other props provided
|
|
14
14
|
* will take precedence.
|
|
15
15
|
*/
|
|
16
|
-
export declare function ArrowFunction(props: Readonly<ArrowFunctionProps>): import("@alloy-js/core
|
|
16
|
+
export declare function ArrowFunction(props: Readonly<ArrowFunctionProps>): import("@alloy-js/core").Children;
|
|
17
17
|
//# sourceMappingURL=arrow-function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-function.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/arrow-function.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"arrow-function.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/arrow-function.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,kBAAkB;IAC/D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC,qCAkBhE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { splitProps } from "@alloy-js/core";
|
|
2
3
|
import * as ts from "@alloy-js/typescript";
|
|
3
4
|
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
4
5
|
import { TypeExpression } from "./type-expression.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import { Operation } from "@typespec/compiler";
|
|
2
|
+
import type { Operation } from "@typespec/compiler";
|
|
3
3
|
export interface ClassMethodPropsWithType extends Omit<ts.ClassMethodProps, "name"> {
|
|
4
4
|
type: Operation;
|
|
5
5
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/class-method.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"class-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/class-method.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACjF,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,gBAAgB,GAAG,wBAAwB,GAAG,EAAE,CAAC,gBAAgB,CAAC;AAE9E,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qCAuBlD"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Children, type Refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
-
import { Enum, EnumMember as TspEnumMember, Union } from "@typespec/compiler";
|
|
3
|
+
import type { Enum, EnumMember as TspEnumMember, Union } from "@typespec/compiler";
|
|
4
4
|
export interface EnumDeclarationProps extends Omit<ts.TypeDeclarationProps, "name"> {
|
|
5
5
|
name?: string;
|
|
6
6
|
type: Union | Enum;
|
|
7
7
|
}
|
|
8
|
-
export declare function EnumDeclaration(props: EnumDeclarationProps):
|
|
8
|
+
export declare function EnumDeclaration(props: EnumDeclarationProps): Children;
|
|
9
9
|
export interface EnumMemberProps {
|
|
10
10
|
type: TspEnumMember;
|
|
11
|
-
doc?:
|
|
12
|
-
refkey?:
|
|
11
|
+
doc?: Children;
|
|
12
|
+
refkey?: Refkey;
|
|
13
13
|
}
|
|
14
|
-
export declare function EnumMember(props: EnumMemberProps):
|
|
14
|
+
export declare function EnumMember(props: EnumMemberProps): Children;
|
|
15
15
|
//# sourceMappingURL=enum-declaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/enum-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"enum-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/enum-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAO,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,IAAI,aAAa,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAKnF,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YA4C1D;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAShD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { For } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { useTsp } from "../../core/context/tsp-context.js";
|
|
5
5
|
import { reportDiagnostic } from "../../lib.js";
|
|
@@ -38,7 +38,7 @@ export function EnumDeclaration(props) {
|
|
|
38
38
|
return props.export;
|
|
39
39
|
},
|
|
40
40
|
get children() {
|
|
41
|
-
return _$createComponent(
|
|
41
|
+
return _$createComponent(For, {
|
|
42
42
|
each: members,
|
|
43
43
|
joiner: ",\n",
|
|
44
44
|
children: ([key, value]) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import { Model, Operation } from "@typespec/compiler";
|
|
2
|
+
import type { Model, Operation } from "@typespec/compiler";
|
|
3
3
|
export interface FunctionDeclarationPropsWithType extends Omit<ts.FunctionDeclarationProps, "name"> {
|
|
4
4
|
type: Operation;
|
|
5
5
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"function-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAM3D,MAAM,WAAW,gCACf,SAAQ,IAAI,CAAC,EAAE,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED,MAAM,MAAM,wBAAwB,GAChC,gCAAgC,GAChC,EAAE,CAAC,wBAAwB,CAAC;AAEhC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qCAsClE;yBAtCe,mBAAmB;4BA+CyB,uBAAuB;;AAPnF,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,EAAE,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC7F,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,GAAG,EAAE,CAAC,uBAAuB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import { Operation } from "@typespec/compiler";
|
|
2
|
+
import type { Operation } from "@typespec/compiler";
|
|
3
3
|
export interface FunctionExpressionProps extends ts.FunctionExpressionProps {
|
|
4
4
|
type?: Operation;
|
|
5
5
|
/**
|
|
@@ -13,5 +13,5 @@ export interface FunctionExpressionProps extends ts.FunctionExpressionProps {
|
|
|
13
13
|
* function expression by converting from a TypeSpec Operation. Any other props
|
|
14
14
|
* provided will take precedence.
|
|
15
15
|
*/
|
|
16
|
-
export declare function FunctionExpression(props: Readonly<FunctionExpressionProps>): import("@alloy-js/core
|
|
16
|
+
export declare function FunctionExpression(props: Readonly<FunctionExpressionProps>): import("@alloy-js/core").Children;
|
|
17
17
|
//# sourceMappingURL=function-expression.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"function-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,uBAAwB,SAAQ,EAAE,CAAC,uBAAuB;IACzE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,qCAoB1E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { splitProps } from "@alloy-js/core";
|
|
2
3
|
import * as ts from "@alloy-js/typescript";
|
|
3
4
|
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
4
5
|
import { TypeExpression } from "./type-expression.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import { Operation } from "@typespec/compiler";
|
|
2
|
+
import type { Operation } from "@typespec/compiler";
|
|
3
3
|
export interface FunctionTypeProps extends ts.FunctionTypeProps {
|
|
4
4
|
type?: Operation;
|
|
5
5
|
/**
|
|
@@ -13,5 +13,5 @@ export interface FunctionTypeProps extends ts.FunctionTypeProps {
|
|
|
13
13
|
* by converting from a TypeSpec Operation. Any other props provided will take
|
|
14
14
|
* precedence.
|
|
15
15
|
*/
|
|
16
|
-
export declare function FunctionType(props: Readonly<FunctionTypeProps>): import("@alloy-js/core
|
|
16
|
+
export declare function FunctionType(props: Readonly<FunctionTypeProps>): import("@alloy-js/core").Children;
|
|
17
17
|
//# sourceMappingURL=function-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-type.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-type.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"function-type.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-type.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,iBAAkB,SAAQ,EAAE,CAAC,iBAAiB;IAC7D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AACD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,qCAkB9D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { splitProps } from "@alloy-js/core";
|
|
2
3
|
import * as ts from "@alloy-js/typescript";
|
|
3
4
|
import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
|
|
4
5
|
import { TypeExpression } from "./type-expression.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
-
import { Interface, Model } from "@typespec/compiler";
|
|
3
|
+
import { type Interface, type Model } from "@typespec/compiler";
|
|
4
4
|
export interface TypedInterfaceDeclarationProps extends Omit<ts.InterfaceDeclarationProps, "name"> {
|
|
5
5
|
type: Model | Interface;
|
|
6
6
|
name?: string;
|
|
7
7
|
}
|
|
8
8
|
export type InterfaceDeclarationProps = TypedInterfaceDeclarationProps | ts.InterfaceDeclarationProps;
|
|
9
|
-
export declare function InterfaceDeclaration(props: InterfaceDeclarationProps):
|
|
9
|
+
export declare function InterfaceDeclaration(props: InterfaceDeclarationProps): Children;
|
|
10
10
|
export interface InterfaceExpressionProps extends ts.InterfaceExpressionProps {
|
|
11
11
|
type: Model | Interface;
|
|
12
12
|
}
|
|
13
|
-
export declare function InterfaceExpression(props: InterfaceExpressionProps):
|
|
13
|
+
export declare function InterfaceExpression(props: InterfaceExpressionProps): Children;
|
|
14
14
|
//# sourceMappingURL=interface-declaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"interface-declaration.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,KAAK,EAIX,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,WAAW,8BAA+B,SAAQ,IAAI,CAAC,EAAE,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAChG,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,yBAAyB,GACjC,8BAA8B,GAC9B,EAAE,CAAC,yBAAyB,CAAC;AAEjC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,YAmCpE;AAQD,MAAM,WAAW,wBAAyB,SAAQ,EAAE,CAAC,wBAAwB;IAC3E,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAMlE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { mapJoin } from "@alloy-js/core";
|
|
2
|
+
import { Block, For, mapJoin } from "@alloy-js/core";
|
|
4
3
|
import * as ts from "@alloy-js/typescript";
|
|
5
4
|
import { isNeverType } from "@typespec/compiler";
|
|
6
5
|
import { createRekeyableMap } from "@typespec/compiler/utils";
|
|
@@ -51,7 +50,7 @@ function isTypedInterfaceDeclarationProps(props) {
|
|
|
51
50
|
return "type" in props;
|
|
52
51
|
}
|
|
53
52
|
export function InterfaceExpression(props) {
|
|
54
|
-
return _$createComponent(
|
|
53
|
+
return _$createComponent(Block, {
|
|
55
54
|
get children() {
|
|
56
55
|
return _$createComponent(InterfaceBody, props);
|
|
57
56
|
}
|
|
@@ -130,7 +129,7 @@ function InterfaceBody(props) {
|
|
|
130
129
|
const enderProp = validTypeMembers.length > 0 ? {
|
|
131
130
|
ender: ";"
|
|
132
131
|
} : {};
|
|
133
|
-
return [_$createComponent(
|
|
132
|
+
return [_$createComponent(For, _$mergeProps({
|
|
134
133
|
each: validTypeMembers,
|
|
135
134
|
semicolon: true,
|
|
136
135
|
line: true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { ModelProperty, Operation } from "@typespec/compiler";
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
import { type ModelProperty, type Operation } from "@typespec/compiler";
|
|
3
3
|
export interface InterfaceMemberProps {
|
|
4
4
|
type: ModelProperty | Operation;
|
|
5
5
|
doc?: Children;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface-member.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-member.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"interface-member.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-member.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAe,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAMrF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YA8B1D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Children } from "@alloy-js/core";
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
-
import { Operation } from "@typespec/compiler";
|
|
3
|
+
import type { Operation } from "@typespec/compiler";
|
|
4
4
|
export interface InterfaceMethodPropsWithType extends Omit<ts.InterfaceMethodProps, "name"> {
|
|
5
5
|
type: Operation;
|
|
6
6
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-method.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"interface-method.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/interface-method.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACzF,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,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,YAgCpE"}
|