@typespec/emitter-framework 0.8.0-dev.3 → 0.8.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.
- package/CHANGELOG.md +15 -0
- package/dist/src/typescript/components/type-alias-declaration.js +1 -1
- package/dist/src/typescript/components/type-declaration.js +1 -1
- package/dist/src/typescript/utils/operation.d.ts +3 -1
- package/dist/src/typescript/utils/operation.d.ts.map +1 -1
- package/dist/src/typescript/utils/operation.js +5 -3
- package/package.json +13 -14
- package/src/typescript/components/type-alias-declaration.tsx +1 -1
- package/src/typescript/components/type-declaration.tsx +1 -1
- package/src/typescript/utils/operation.ts +11 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog - @typespec/emitter-framework
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#7409](https://github.com/microsoft/typespec/pull/7409) Emit TypeSpec comments as JSDoc in TypeScript components
|
|
8
|
+
|
|
9
|
+
### Bump dependencies
|
|
10
|
+
|
|
11
|
+
- [#7605](https://github.com/microsoft/typespec/pull/7605) Updates alloy to 0.17
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- [#7369](https://github.com/microsoft/typespec/pull/7369) Render discriminated unions correctly
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## 0.7.1
|
|
4
19
|
|
|
5
20
|
### Bump dependencies
|
|
@@ -27,7 +27,7 @@ export function TypeAliasDeclaration(props) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
const doc = props.doc ?? $.type.getDoc(props.type);
|
|
30
|
-
const refkeys = declarationRefkeys(props.refkey, props.
|
|
30
|
+
const refkeys = declarationRefkeys(props.refkey, props.type);
|
|
31
31
|
const name = ts.useTSNamePolicy().getName(originalName, "type");
|
|
32
32
|
return _$createComponent(ts.TypeDeclaration, _$mergeProps({
|
|
33
33
|
doc: doc
|
|
@@ -11,7 +11,7 @@ export function TypeDeclaration(props) {
|
|
|
11
11
|
$
|
|
12
12
|
} = useTsp();
|
|
13
13
|
if (!props.type) {
|
|
14
|
-
const refkeys = declarationRefkeys(props.refkey, props.
|
|
14
|
+
const refkeys = declarationRefkeys(props.refkey, props.type);
|
|
15
15
|
return _$createComponent(ts.TypeDeclaration, _$mergeProps(props, {
|
|
16
16
|
refkey: refkeys
|
|
17
17
|
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Refkey } from "@alloy-js/core";
|
|
1
2
|
import * as ts from "@alloy-js/typescript";
|
|
2
3
|
import { Model, ModelProperty, Operation, Type } from "@typespec/compiler";
|
|
3
4
|
export declare function getReturnType(type: Operation, options?: {
|
|
@@ -6,7 +7,8 @@ export declare function getReturnType(type: Operation, options?: {
|
|
|
6
7
|
export interface BuildParameterDescriptorsOptions {
|
|
7
8
|
params?: ts.ParameterDescriptor[] | string[] | undefined;
|
|
8
9
|
mode?: "prepend" | "append" | "replace";
|
|
10
|
+
suffixRefkey?: Refkey;
|
|
9
11
|
}
|
|
10
12
|
export declare function buildParameterDescriptors(type: Model, options?: BuildParameterDescriptorsOptions): ts.ParameterDescriptor[] | undefined;
|
|
11
|
-
export declare function buildParameterDescriptor(modelProperty: ModelProperty): ts.ParameterDescriptor;
|
|
13
|
+
export declare function buildParameterDescriptor(modelProperty: ModelProperty, suffixRefkey: Refkey): ts.ParameterDescriptor;
|
|
12
14
|
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/typescript/utils/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAK3E,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAkC,GACvE,IAAI,CASN;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,CAAC,EAAE,EAAE,CAAC,mBAAmB,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACzD,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/typescript/utils/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAK3E,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAkC,GACvE,IAAI,CASN;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,CAAC,EAAE,EAAE,CAAC,mBAAmB,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACzD,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,gCAAqC,GAC7C,EAAE,CAAC,mBAAmB,EAAE,GAAG,SAAS,CAqBtC;AAED,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,GACnB,EAAE,CAAC,mBAAmB,CAaxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refkey } from "@alloy-js/core";
|
|
1
2
|
import * as ts from "@alloy-js/typescript";
|
|
2
3
|
import { useTsp } from "../../core/index.js";
|
|
3
4
|
import { TypeExpression } from "../components/type-expression.js";
|
|
@@ -18,18 +19,19 @@ export function buildParameterDescriptors(type, options = {}) {
|
|
|
18
19
|
const {
|
|
19
20
|
$
|
|
20
21
|
} = useTsp();
|
|
22
|
+
const suffixRefkey = options.suffixRefkey ?? refkey();
|
|
21
23
|
const optionsParams = normalizeParameters(options.params);
|
|
22
24
|
if (options.mode === "replace") {
|
|
23
25
|
return optionsParams;
|
|
24
26
|
}
|
|
25
27
|
const modelProperties = $.model.getProperties(type);
|
|
26
|
-
const operationParams = [...modelProperties.values()].map(buildParameterDescriptor);
|
|
28
|
+
const operationParams = [...modelProperties.values()].map(m => buildParameterDescriptor(m, suffixRefkey));
|
|
27
29
|
|
|
28
30
|
// Merge parameters based on location
|
|
29
31
|
const allParams = options.mode === "append" ? operationParams.concat(optionsParams) : optionsParams.concat(operationParams);
|
|
30
32
|
return allParams;
|
|
31
33
|
}
|
|
32
|
-
export function buildParameterDescriptor(modelProperty) {
|
|
34
|
+
export function buildParameterDescriptor(modelProperty, suffixRefkey) {
|
|
33
35
|
const {
|
|
34
36
|
$
|
|
35
37
|
} = useTsp();
|
|
@@ -40,7 +42,7 @@ export function buildParameterDescriptor(modelProperty) {
|
|
|
40
42
|
return {
|
|
41
43
|
doc,
|
|
42
44
|
name: paramName,
|
|
43
|
-
refkey: efRefkey(modelProperty),
|
|
45
|
+
refkey: efRefkey(modelProperty, suffixRefkey),
|
|
44
46
|
optional: isOptional,
|
|
45
47
|
type: TypeExpression({
|
|
46
48
|
type: modelProperty.type
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/emitter-framework",
|
|
3
|
-
"version": "0.8.0
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -19,21 +19,18 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"description": "",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@alloy-js/core": "^0.
|
|
23
|
-
"@alloy-js/typescript": "^0.
|
|
24
|
-
"@typespec/compiler": "^1.
|
|
25
|
-
"@typespec/http": "^1.0
|
|
26
|
-
"@typespec/rest": "^0.
|
|
22
|
+
"@alloy-js/core": "^0.17.0",
|
|
23
|
+
"@alloy-js/typescript": "^0.17.0",
|
|
24
|
+
"@typespec/compiler": "^1.1.0",
|
|
25
|
+
"@typespec/http": "^1.1.0",
|
|
26
|
+
"@typespec/rest": "^0.71.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@alloy-js/cli": "^0.
|
|
29
|
+
"@alloy-js/cli": "^0.17.0",
|
|
30
30
|
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
31
|
-
"@alloy-js/core": "^0.
|
|
32
|
-
"@alloy-js/typescript": "^0.
|
|
31
|
+
"@alloy-js/core": "^0.17.0",
|
|
32
|
+
"@alloy-js/typescript": "^0.17.0",
|
|
33
33
|
"@types/minimist": "^1.2.5",
|
|
34
|
-
"@typespec/compiler": "^1.0.0",
|
|
35
|
-
"@typespec/http": "^1.0.1",
|
|
36
|
-
"@typespec/rest": "^0.70.0 || >=0.71.0-dev <0.71.0",
|
|
37
34
|
"concurrently": "^9.1.2",
|
|
38
35
|
"minimist": "^1.2.8",
|
|
39
36
|
"prettier": "~3.5.3",
|
|
@@ -44,9 +41,11 @@
|
|
|
44
41
|
"tree-sitter-python": "^0.23.2",
|
|
45
42
|
"tree-sitter-typescript": "^0.23.0",
|
|
46
43
|
"typescript": "~5.8.2",
|
|
47
|
-
"vitest": "^3.1.2"
|
|
44
|
+
"vitest": "^3.1.2",
|
|
45
|
+
"@typespec/compiler": "^1.1.0",
|
|
46
|
+
"@typespec/http": "^1.1.0",
|
|
47
|
+
"@typespec/rest": "^0.71.0"
|
|
48
48
|
},
|
|
49
|
-
"dependencies": {},
|
|
50
49
|
"scripts": {
|
|
51
50
|
"build": "alloy build",
|
|
52
51
|
"clean": "rimraf ./dist",
|
|
@@ -31,7 +31,7 @@ export function TypeAliasDeclaration(props: TypeAliasDeclarationProps) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const doc = props.doc ?? $.type.getDoc(props.type);
|
|
34
|
-
const refkeys = declarationRefkeys(props.refkey, props.
|
|
34
|
+
const refkeys = declarationRefkeys(props.refkey, props.type);
|
|
35
35
|
|
|
36
36
|
const name = ts.useTSNamePolicy().getName(originalName, "type");
|
|
37
37
|
return (
|
|
@@ -17,7 +17,7 @@ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
|
17
17
|
export function TypeDeclaration(props: TypeDeclarationProps) {
|
|
18
18
|
const { $ } = useTsp();
|
|
19
19
|
if (!props.type) {
|
|
20
|
-
const refkeys = declarationRefkeys(props.refkey, props.
|
|
20
|
+
const refkeys = declarationRefkeys(props.refkey, props.type);
|
|
21
21
|
return (
|
|
22
22
|
<ts.TypeDeclaration
|
|
23
23
|
{...(props as WithRequired<ts.TypeDeclarationProps, "name">)}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refkey, Refkey } from "@alloy-js/core";
|
|
1
2
|
import * as ts from "@alloy-js/typescript";
|
|
2
3
|
import { Model, ModelProperty, Operation, Type } from "@typespec/compiler";
|
|
3
4
|
import { useTsp } from "../../core/index.js";
|
|
@@ -21,6 +22,7 @@ export function getReturnType(
|
|
|
21
22
|
export interface BuildParameterDescriptorsOptions {
|
|
22
23
|
params?: ts.ParameterDescriptor[] | string[] | undefined;
|
|
23
24
|
mode?: "prepend" | "append" | "replace";
|
|
25
|
+
suffixRefkey?: Refkey;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export function buildParameterDescriptors(
|
|
@@ -28,6 +30,7 @@ export function buildParameterDescriptors(
|
|
|
28
30
|
options: BuildParameterDescriptorsOptions = {},
|
|
29
31
|
): ts.ParameterDescriptor[] | undefined {
|
|
30
32
|
const { $ } = useTsp();
|
|
33
|
+
const suffixRefkey = options.suffixRefkey ?? refkey();
|
|
31
34
|
const optionsParams = normalizeParameters(options.params);
|
|
32
35
|
|
|
33
36
|
if (options.mode === "replace") {
|
|
@@ -35,7 +38,9 @@ export function buildParameterDescriptors(
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
const modelProperties = $.model.getProperties(type);
|
|
38
|
-
const operationParams = [...modelProperties.values()].map(
|
|
41
|
+
const operationParams = [...modelProperties.values()].map((m) =>
|
|
42
|
+
buildParameterDescriptor(m, suffixRefkey),
|
|
43
|
+
);
|
|
39
44
|
|
|
40
45
|
// Merge parameters based on location
|
|
41
46
|
const allParams =
|
|
@@ -46,7 +51,10 @@ export function buildParameterDescriptors(
|
|
|
46
51
|
return allParams;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
export function buildParameterDescriptor(
|
|
54
|
+
export function buildParameterDescriptor(
|
|
55
|
+
modelProperty: ModelProperty,
|
|
56
|
+
suffixRefkey: Refkey,
|
|
57
|
+
): ts.ParameterDescriptor {
|
|
50
58
|
const { $ } = useTsp();
|
|
51
59
|
const namePolicy = ts.useTSNamePolicy();
|
|
52
60
|
const paramName = namePolicy.getName(modelProperty.name, "parameter");
|
|
@@ -55,7 +63,7 @@ export function buildParameterDescriptor(modelProperty: ModelProperty): ts.Param
|
|
|
55
63
|
return {
|
|
56
64
|
doc,
|
|
57
65
|
name: paramName,
|
|
58
|
-
refkey: efRefkey(modelProperty),
|
|
66
|
+
refkey: efRefkey(modelProperty, suffixRefkey),
|
|
59
67
|
optional: isOptional,
|
|
60
68
|
type: TypeExpression({ type: modelProperty.type }),
|
|
61
69
|
};
|