typespec-fastify 0.1.0 → 0.3.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/LICENSE +21 -0
- package/dist/src/components/ModelsDirectory.js +8 -2
- package/dist/src/components/ModelsDirectory.js.map +1 -1
- package/dist/src/components/ModelsDirectory.jsx +4 -0
- package/dist/src/components/ModelsDirectory.jsx.map +1 -1
- package/dist/src/components/OperationInterface.js +45 -30
- package/dist/src/components/OperationInterface.js.map +1 -1
- package/dist/src/components/OperationInterface.jsx +30 -23
- package/dist/src/components/OperationInterface.jsx.map +1 -1
- package/dist/src/components/OperationsDirectory.js +12 -4
- package/dist/src/components/OperationsDirectory.js.map +1 -1
- package/dist/src/components/OperationsDirectory.jsx +14 -1
- package/dist/src/components/OperationsDirectory.jsx.map +1 -1
- package/dist/src/components/ResponseTypes.d.ts +4 -0
- package/dist/src/components/ResponseTypes.js +21 -0
- package/dist/src/components/ResponseTypes.js.map +1 -0
- package/dist/src/components/ResponseTypes.jsx +27 -0
- package/dist/src/components/ResponseTypes.jsx.map +1 -0
- package/dist/src/components/RouteRegistration.d.ts +2 -2
- package/dist/src/components/RouteRegistration.js +142 -71
- package/dist/src/components/RouteRegistration.js.map +1 -1
- package/dist/src/components/RouteRegistration.jsx +148 -49
- package/dist/src/components/RouteRegistration.jsx.map +1 -1
- package/dist/src/components/RouterFile.js +19 -15
- package/dist/src/components/RouterFile.js.map +1 -1
- package/dist/src/components/RouterFile.jsx +11 -9
- package/dist/src/components/RouterFile.jsx.map +1 -1
- package/dist/src/components/RoutesDirectory.js +27 -26
- package/dist/src/components/RoutesDirectory.js.map +1 -1
- package/dist/src/components/RoutesDirectory.jsx +12 -15
- package/dist/src/components/RoutesDirectory.jsx.map +1 -1
- package/dist/src/components/ZodSchemasDirectory.d.ts +9 -0
- package/dist/src/components/ZodSchemasDirectory.js +37 -0
- package/dist/src/components/ZodSchemasDirectory.js.map +1 -0
- package/dist/src/components/ZodSchemasDirectory.jsx +25 -0
- package/dist/src/components/ZodSchemasDirectory.jsx.map +1 -0
- package/dist/src/emitter.js +13 -1
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/emitter.jsx +6 -1
- package/dist/src/emitter.jsx.map +1 -1
- package/dist/src/external-packages/fastify-type-provider-zod.d.ts +5 -0
- package/dist/src/external-packages/fastify-type-provider-zod.js +11 -0
- package/dist/src/external-packages/fastify-type-provider-zod.js.map +1 -0
- package/dist/src/lib.d.ts +8 -1
- package/dist/src/lib.js +8 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/utils/http-helpers.d.ts +0 -13
- package/dist/src/utils/http-helpers.js +0 -22
- package/dist/src/utils/http-helpers.js.map +1 -1
- package/package.json +55 -24
- package/dist/test/hello.test.d.ts +0 -1
- package/dist/test/hello.test.js +0 -187
- package/dist/test/hello.test.js.map +0 -1
- package/dist/test/test-host.d.ts +0 -5
- package/dist/test/test-host.js +0 -52
- package/dist/test/test-host.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jordan Hood
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -2,6 +2,7 @@ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime
|
|
|
2
2
|
import { SourceDirectory } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { TsTypes } from "./TsTypes.js";
|
|
5
|
+
import { ResponseTypes } from "./ResponseTypes.js";
|
|
5
6
|
/**
|
|
6
7
|
* Generates the models directory with TypeSpec type declarations.
|
|
7
8
|
*/
|
|
@@ -9,7 +10,12 @@ export function ModelsDirectory(props) {
|
|
|
9
10
|
return _$createComponent(SourceDirectory, {
|
|
10
11
|
path: "models",
|
|
11
12
|
get children() {
|
|
12
|
-
return _$createComponent(ts.SourceFile, {
|
|
13
|
+
return [_$createComponent(ts.SourceFile, {
|
|
14
|
+
path: "response-types.ts",
|
|
15
|
+
get children() {
|
|
16
|
+
return _$createComponent(ResponseTypes, {});
|
|
17
|
+
}
|
|
18
|
+
}), _$createComponent(ts.SourceFile, {
|
|
13
19
|
get path() {
|
|
14
20
|
return `${props.namespace.toLowerCase()}.ts`;
|
|
15
21
|
},
|
|
@@ -20,7 +26,7 @@ export function ModelsDirectory(props) {
|
|
|
20
26
|
}
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
|
-
});
|
|
29
|
+
})];
|
|
24
30
|
}
|
|
25
31
|
});
|
|
26
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SourceDirectory","ts","TsTypes","ModelsDirectory","props","_$createComponent","path","children","SourceFile","namespace","toLowerCase","types"],"sources":["../../../src/components/ModelsDirectory.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,OAAO,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["SourceDirectory","ts","TsTypes","ResponseTypes","ModelsDirectory","props","_$createComponent","path","children","SourceFile","namespace","toLowerCase","types"],"sources":["../../../src/components/ModelsDirectory.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,aAAa,QAAQ,oBAAoB;AAOlD;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAA2B,EAAE;EAC3D,OAAAC,iBAAA,CACGN,eAAe;IAACO,IAAI;IAAA,IAAAC,SAAA;MAAA,QAAAF,iBAAA,CAClBL,EAAE,CAACQ,UAAU;QAACF,IAAI;QAAA,IAAAC,SAAA;UAAA,OAAAF,iBAAA,CAChBH,aAAa;QAAA;MAAA,IAAAG,iBAAA,CAEfL,EAAE,CAACQ,UAAU;QAAA,IAACF,IAAIA,CAAA;UAAA,OAAE,GAAGF,KAAK,CAACK,SAAS,CAACC,WAAW,CAAC,CAAC,KAAK;QAAA;QAAA,IAAAH,SAAA;UAAA,OAAAF,iBAAA,CACvDJ,OAAO;YAAA,IAACU,KAAKA,CAAA;cAAA,OAAEP,KAAK,CAACO,KAAK;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAInC","ignoreList":[]}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { SourceDirectory } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { TsTypes } from "./TsTypes.js";
|
|
4
|
+
import { ResponseTypes } from "./ResponseTypes.js";
|
|
4
5
|
/**
|
|
5
6
|
* Generates the models directory with TypeSpec type declarations.
|
|
6
7
|
*/
|
|
7
8
|
export function ModelsDirectory(props) {
|
|
8
9
|
return (<SourceDirectory path="models">
|
|
10
|
+
<ts.SourceFile path="response-types.ts">
|
|
11
|
+
<ResponseTypes />
|
|
12
|
+
</ts.SourceFile>
|
|
9
13
|
<ts.SourceFile path={`${props.namespace.toLowerCase()}.ts`}>
|
|
10
14
|
<TsTypes types={props.types}/>
|
|
11
15
|
</ts.SourceFile>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelsDirectory.jsx","sourceRoot":"","sources":["../../../src/components/ModelsDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ModelsDirectory.jsx","sourceRoot":"","sources":["../../../src/components/ModelsDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,OAAO,CACL,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAC5B;MAAA,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,CACrC;QAAA,CAAC,aAAa,CAAC,AAAD,EAChB;MAAA,EAAE,EAAE,CAAC,UAAU,CACf;MAAA,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CACzD;QAAA,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAC9B;MAAA,EAAE,EAAE,CAAC,UAAU,CACjB;IAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { createComponent as _$createComponent
|
|
2
|
-
import { For, List, refkey } from "@alloy-js/core";
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { For, List, refkey, code } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
|
+
import { useTSNamePolicy } from "@alloy-js/typescript";
|
|
5
|
+
import { isVoidType } from "@typespec/compiler";
|
|
4
6
|
import { TypeExpression } from "@typespec/emitter-framework/typescript";
|
|
5
|
-
import {
|
|
7
|
+
import { getNoContentResponseRef } from "./ResponseTypes.js";
|
|
6
8
|
/**
|
|
7
9
|
* Creates a refkey for an operation interface.
|
|
8
10
|
* This allows other components to reference this interface and
|
|
@@ -23,6 +25,7 @@ export function OperationInterface(props) {
|
|
|
23
25
|
operations
|
|
24
26
|
} = props;
|
|
25
27
|
const interfaceRef = getOperationInterfaceRef(containerName);
|
|
28
|
+
const namePolicy = useTSNamePolicy();
|
|
26
29
|
return _$createComponent(ts.InterfaceDeclaration, {
|
|
27
30
|
name: containerName,
|
|
28
31
|
"export": true,
|
|
@@ -34,35 +37,38 @@ export function OperationInterface(props) {
|
|
|
34
37
|
each: operations,
|
|
35
38
|
hardline: true,
|
|
36
39
|
semicolon: true,
|
|
37
|
-
children:
|
|
38
|
-
const opName =
|
|
40
|
+
children: operation => {
|
|
41
|
+
const opName = namePolicy.getName(operation.operation.name, "function");
|
|
39
42
|
const parameters = [];
|
|
40
43
|
for (const param of operation.parameters.parameters) {
|
|
41
44
|
if (param.type === "path") {
|
|
42
|
-
const paramName =
|
|
45
|
+
const paramName = namePolicy.getName(param.param.name, "parameter");
|
|
43
46
|
parameters.push({
|
|
44
47
|
name: paramName,
|
|
45
48
|
type: _$createComponent(TypeExpression, {
|
|
46
49
|
get type() {
|
|
47
50
|
return param.param.type;
|
|
48
51
|
}
|
|
49
|
-
})
|
|
52
|
+
}),
|
|
53
|
+
optional: param.param.optional
|
|
50
54
|
});
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
if (operation.parameters.body) {
|
|
58
|
+
const bodyParam = operation.parameters.body;
|
|
54
59
|
parameters.push({
|
|
55
60
|
name: "body",
|
|
56
61
|
type: _$createComponent(TypeExpression, {
|
|
57
62
|
get type() {
|
|
58
|
-
return
|
|
63
|
+
return bodyParam.type;
|
|
59
64
|
}
|
|
60
|
-
})
|
|
65
|
+
}),
|
|
66
|
+
optional: bodyParam.property?.optional ?? false
|
|
61
67
|
});
|
|
62
68
|
}
|
|
63
69
|
for (const param of operation.parameters.parameters) {
|
|
64
70
|
if (param.type === "header") {
|
|
65
|
-
const paramName =
|
|
71
|
+
const paramName = namePolicy.getName(param.param.name, "parameter");
|
|
66
72
|
parameters.push({
|
|
67
73
|
name: paramName,
|
|
68
74
|
type: _$createComponent(TypeExpression, {
|
|
@@ -74,27 +80,30 @@ export function OperationInterface(props) {
|
|
|
74
80
|
});
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
|
-
const queryParams = operation.parameters.parameters.filter(
|
|
78
|
-
return p.type === "query";
|
|
79
|
-
});
|
|
83
|
+
const queryParams = operation.parameters.parameters.filter(p => p.type === "query");
|
|
80
84
|
if (queryParams.length > 0) {
|
|
81
85
|
const optionsType = _$createComponent(ts.InterfaceExpression, {
|
|
82
86
|
get children() {
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
return _$createComponent(For, {
|
|
88
|
+
each: queryParams,
|
|
89
|
+
semicolon: true,
|
|
90
|
+
hardline: true,
|
|
91
|
+
children: param => {
|
|
92
|
+
const paramName = namePolicy.getName(param.param.name, "interface-member");
|
|
93
|
+
return _$createComponent(ts.InterfaceMember, {
|
|
94
|
+
name: paramName,
|
|
95
|
+
get optional() {
|
|
96
|
+
return param.param.optional;
|
|
97
|
+
},
|
|
98
|
+
get children() {
|
|
99
|
+
return _$createComponent(TypeExpression, {
|
|
100
|
+
get type() {
|
|
101
|
+
return param.param.type;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
98
107
|
});
|
|
99
108
|
}
|
|
100
109
|
});
|
|
@@ -104,11 +113,17 @@ export function OperationInterface(props) {
|
|
|
104
113
|
optional: true
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
|
-
const
|
|
116
|
+
const isVoid = isVoidType(operation.operation.returnType);
|
|
117
|
+
const is204Response = operation.responses.some(function (r) {
|
|
118
|
+
return r.statusCodes === 204;
|
|
119
|
+
});
|
|
120
|
+
const shouldEmitVoid = isVoid || is204Response;
|
|
121
|
+
const noContentRef = getNoContentResponseRef();
|
|
122
|
+
const returnType = shouldEmitVoid ? code`Promise<${noContentRef}>` : code`Promise<ResponseWithBody<${_$createComponent(TypeExpression, {
|
|
108
123
|
get type() {
|
|
109
124
|
return operation.operation.returnType;
|
|
110
125
|
}
|
|
111
|
-
})
|
|
126
|
+
})}>>`;
|
|
112
127
|
return _$createComponent(ts.InterfaceMethod, {
|
|
113
128
|
name: opName,
|
|
114
129
|
parameters: parameters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["For","List","refkey","ts","TypeExpression","
|
|
1
|
+
{"version":3,"names":["For","List","refkey","code","ts","useTSNamePolicy","isVoidType","TypeExpression","getNoContentResponseRef","getOperationInterfaceRef","containerName","OperationInterface","props","operations","interfaceRef","namePolicy","_$createComponent","InterfaceDeclaration","name","children","each","hardline","semicolon","operation","opName","getName","parameters","param","type","paramName","push","optional","body","bodyParam","property","queryParams","filter","p","length","optionsType","InterfaceExpression","InterfaceMember","isVoid","returnType","is204Response","responses","some","r","statusCodes","shouldEmitVoid","noContentRef","InterfaceMethod"],"sources":["../../../src/components/OperationInterface.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,GAAG,EACHC,IAAI,EACJC,MAAM,EAGNC,IAAI,QACC,gBAAgB;AACvB,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1C,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,cAAc,QAAQ,wCAAwC;AACvE,SAASC,uBAAuB,QAAQ,oBAAoB;AAM5D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAACC,aAAqB,EAAU;EACtE,OAAOR,MAAM,CAACQ,aAAa,EAAE,qBAAqB,CAAC;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAA8B,EAAE;EACjE,MAAM;IAAEF,aAAa;IAAEG;EAAW,CAAC,GAAGD,KAAK;EAC3C,MAAME,YAAY,GAAGL,wBAAwB,CAACC,aAAa,CAAC;EAC5D,MAAMK,UAAU,GAAGV,eAAe,CAAC,CAAC;EACpC,OAAAW,iBAAA,CACGZ,EAAE,CAACa,oBAAoB;IAACC,IAAI,EAAER,aAAa;IAAA;IAASR,MAAM,EAAEY,YAAY;IAAA,IAAAK,SAAA;MAAA,OAAAH,iBAAA,CACtEf,IAAI;QAAA,IAAAkB,SAAA;UAAA,OAAAH,iBAAA,CACFhB,GAAG;YAACoB,IAAI,EAAEP,UAAU;YAAEQ,QAAQ;YAACC,SAAS;YAAAH,QAAA,EACrCI,SAAS,IAAK;cACd,MAAMC,MAAM,GAAGT,UAAU,CAACU,OAAO,CAC/BF,SAAS,CAACA,SAAS,CAACL,IAAI,EACxB,UACF,CAAC;cACD,MAAMQ,UAIH,GAAG,EAAE;cAER,KAAK,MAAMC,KAAK,IAAIJ,SAAS,CAACG,UAA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OA,CAAC,CAACC,WAAW,KAAK,GAAG;cAC9B,CAAC,CAAC;cACF,MAAMC,cAAc,GAAGP,MAAM,IAAIE,aAAa;cAC9C,MAAMM,YAAY,GAAG1C,uBAAuB,CAAC,CAAC;cAC9C,MAAMmC,UAAU,GAAGM,cAAc,GAC7B9C,IAAI,WAAW+C,YAAY,GAAG,GAC9B/C,IAAI,4BAAAa,iBAAA,CAA8BT,cAAc;gBAAA,IAACqB,IAAIA,CAAA;kBAAA,OAAEL,SAAS,CAACA,SAAS,CAACoB,UAAU;gBAAA;cAAA,MAAS;cAClG,OAAA3B,iBAAA,CACGZ,EAAE,CAAC+C,eAAe;gBACjBjC,IAAI,EAAEM,MAAM;gBACZE,UAAU,EAAEA,UAAU;gBACtBiB,UAAU,EAAEA;cAAU;YAG5B;UAAC;QAAA;MAAA;IAAA;EAAA;AAKX","ignoreList":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { For, List, refkey } from "@alloy-js/core";
|
|
1
|
+
import { For, List, refkey, code, } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
+
import { useTSNamePolicy } from "@alloy-js/typescript";
|
|
4
|
+
import { isVoidType } from "@typespec/compiler";
|
|
3
5
|
import { TypeExpression } from "@typespec/emitter-framework/typescript";
|
|
4
|
-
import {
|
|
6
|
+
import { getNoContentResponseRef } from "./ResponseTypes.js";
|
|
5
7
|
/**
|
|
6
8
|
* Creates a refkey for an operation interface.
|
|
7
9
|
* This allows other components to reference this interface and
|
|
@@ -18,30 +20,34 @@ export function getOperationInterfaceRef(containerName) {
|
|
|
18
20
|
export function OperationInterface(props) {
|
|
19
21
|
const { containerName, operations } = props;
|
|
20
22
|
const interfaceRef = getOperationInterfaceRef(containerName);
|
|
23
|
+
const namePolicy = useTSNamePolicy();
|
|
21
24
|
return (<ts.InterfaceDeclaration name={containerName} export refkey={interfaceRef}>
|
|
22
25
|
<List>
|
|
23
26
|
<For each={operations} hardline semicolon>
|
|
24
|
-
{
|
|
25
|
-
const opName =
|
|
27
|
+
{(operation) => {
|
|
28
|
+
const opName = namePolicy.getName(operation.operation.name, "function");
|
|
26
29
|
const parameters = [];
|
|
27
30
|
for (const param of operation.parameters.parameters) {
|
|
28
31
|
if (param.type === "path") {
|
|
29
|
-
const paramName =
|
|
32
|
+
const paramName = namePolicy.getName(param.param.name, "parameter");
|
|
30
33
|
parameters.push({
|
|
31
34
|
name: paramName,
|
|
32
35
|
type: <TypeExpression type={param.param.type}/>,
|
|
36
|
+
optional: param.param.optional,
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
if (operation.parameters.body) {
|
|
41
|
+
const bodyParam = operation.parameters.body;
|
|
37
42
|
parameters.push({
|
|
38
43
|
name: "body",
|
|
39
|
-
type: <TypeExpression type={
|
|
44
|
+
type: <TypeExpression type={bodyParam.type}/>,
|
|
45
|
+
optional: bodyParam.property?.optional ?? false,
|
|
40
46
|
});
|
|
41
47
|
}
|
|
42
48
|
for (const param of operation.parameters.parameters) {
|
|
43
49
|
if (param.type === "header") {
|
|
44
|
-
const paramName =
|
|
50
|
+
const paramName = namePolicy.getName(param.param.name, "parameter");
|
|
45
51
|
parameters.push({
|
|
46
52
|
name: paramName,
|
|
47
53
|
type: <TypeExpression type={param.param.type}/>,
|
|
@@ -49,20 +55,17 @@ export function OperationInterface(props) {
|
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
|
-
const queryParams = operation.parameters.parameters.filter(
|
|
53
|
-
return p.type === "query";
|
|
54
|
-
});
|
|
58
|
+
const queryParams = operation.parameters.parameters.filter((p) => p.type === "query");
|
|
55
59
|
if (queryParams.length > 0) {
|
|
56
60
|
const optionsType = (<ts.InterfaceExpression>
|
|
57
|
-
{queryParams
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<ts.InterfaceMember name={paramName} optional={param.param.optional}>
|
|
61
|
+
<For each={queryParams} semicolon hardline>
|
|
62
|
+
{(param) => {
|
|
63
|
+
const paramName = namePolicy.getName(param.param.name, "interface-member");
|
|
64
|
+
return (<ts.InterfaceMember name={paramName} optional={param.param.optional}>
|
|
61
65
|
<TypeExpression type={param.param.type}/>
|
|
62
|
-
</ts.InterfaceMember>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})}
|
|
66
|
+
</ts.InterfaceMember>);
|
|
67
|
+
}}
|
|
68
|
+
</For>
|
|
66
69
|
</ts.InterfaceExpression>);
|
|
67
70
|
parameters.push({
|
|
68
71
|
name: "options",
|
|
@@ -70,11 +73,15 @@ export function OperationInterface(props) {
|
|
|
70
73
|
optional: true,
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const isVoid = isVoidType(operation.operation.returnType);
|
|
77
|
+
const is204Response = operation.responses.some(function (r) {
|
|
78
|
+
return r.statusCodes === 204;
|
|
79
|
+
});
|
|
80
|
+
const shouldEmitVoid = isVoid || is204Response;
|
|
81
|
+
const noContentRef = getNoContentResponseRef();
|
|
82
|
+
const returnType = shouldEmitVoid
|
|
83
|
+
? code `Promise<${noContentRef}>`
|
|
84
|
+
: code `Promise<ResponseWithBody<${(<TypeExpression type={operation.operation.returnType}/>)}>>`;
|
|
78
85
|
return (<ts.InterfaceMethod name={opName} parameters={parameters} returnType={returnType}/>);
|
|
79
86
|
}}
|
|
80
87
|
</For>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationInterface.jsx","sourceRoot":"","sources":["../../../src/components/OperationInterface.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"OperationInterface.jsx","sourceRoot":"","sources":["../../../src/components/OperationInterface.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,MAAM,EAGN,IAAI,GACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,sBAAsB,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IAAI,CAAA,4BAA4B,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,EAAG,CAAC,IAAI,CAAC;YACnG,OAAO,CACL,CAAC,EAAE,CAAC,eAAe,CACjB,IAAI,CAAC,CAAC,MAAM,CAAC,CACb,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,UAAU,CAAC,CAAC,UAAU,CAAC,EACvB,CACH,CAAC;QACJ,CAAC,CACH;QAAA,EAAE,GAAG,CACP;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { For, SourceDirectory } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
|
+
import { isVoidType } from "@typespec/compiler";
|
|
4
5
|
import { OperationInterface } from "./OperationInterface.js";
|
|
5
6
|
/**
|
|
6
7
|
* Generates the operations directory with operation interface files.
|
|
@@ -13,16 +14,23 @@ export function OperationsDirectory(props) {
|
|
|
13
14
|
get each() {
|
|
14
15
|
return Array.from(props.groupedOperations.entries());
|
|
15
16
|
},
|
|
16
|
-
children:
|
|
17
|
+
children: ([containerName, operations]) => {
|
|
18
|
+
const hasResponseWithBody = operations.some(function (op) {
|
|
19
|
+
const isVoid = isVoidType(op.operation.returnType);
|
|
20
|
+
const is204 = op.responses.some(function (r) {
|
|
21
|
+
return r.statusCodes === 204;
|
|
22
|
+
});
|
|
23
|
+
return !isVoid && !is204;
|
|
24
|
+
});
|
|
17
25
|
return _$createComponent(ts.SourceFile, {
|
|
18
26
|
get path() {
|
|
19
27
|
return `${containerName.toLowerCase()}.ts`;
|
|
20
28
|
},
|
|
21
29
|
get children() {
|
|
22
|
-
return _$createComponent(OperationInterface, {
|
|
30
|
+
return [_$memo(() => hasResponseWithBody && ["import type ", "{", " ResponseWithBody ", "}", " from \"../models/response-types.js\";", "\n\n"]), _$createComponent(OperationInterface, {
|
|
23
31
|
containerName: containerName,
|
|
24
32
|
operations: operations
|
|
25
|
-
});
|
|
33
|
+
})];
|
|
26
34
|
}
|
|
27
35
|
});
|
|
28
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["For","SourceDirectory","ts","OperationInterface","OperationsDirectory","props","_$createComponent","path","children","each","Array","from","groupedOperations","entries","
|
|
1
|
+
{"version":3,"names":["For","SourceDirectory","ts","isVoidType","OperationInterface","OperationsDirectory","props","_$createComponent","path","children","each","Array","from","groupedOperations","entries","containerName","operations","hasResponseWithBody","some","op","isVoid","operation","returnType","is204","responses","r","statusCodes","SourceFile","toLowerCase","_$memo"],"sources":["../../../src/components/OperationsDirectory.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,EAAEC,eAAe,QAAQ,gBAAgB;AACrD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,kBAAkB,QAAQ,yBAAyB;AAM5D;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,OAAAC,iBAAA,CACGN,eAAe;IAACO,IAAI;IAAA,IAAAC,SAAA;MAAA,OAAAF,iBAAA,CAClBP,GAAG;QAAA,IAACU,IAAIA,CAAA;UAAA,OAAEC,KAAK,CAACC,IAAI,CAACN,KAAK,CAACO,iBAAiB,CAACC,OAAO,CAAC,CAAC,CAAC;QAAA;QAAAL,QAAA,EACrDA,CAAC,CAACM,aAAa,EAAEC,UAAU,CAAC,KAAK;UAChC,MAAMC,mBAAmB,GAAGD,UAAU,CAACE,IAAI,CAAC,UAAUC,EAAE,EAAE;YACxD,MAAMC,MAAM,GAAGjB,UAAU,CAACgB,EAAE,CAACE,SAAS,CAACC,UAAU,CAAC;YAClD,MAAMC,KAAK,GAAGJ,EAAE,CAACK,SAAS,CAACN,IAAI,CAAC,UAAUO,CAAC,EAAE;cAC3C,OAAOA,CAAC,CAACC,WAAW,KAAK,GAAG;YAC9B,CAAC,CAAC;YACF,OAAO,CAACN,MAAM,IAAI,CAACG,KAAK;UAC1B,CAAC,CAAC;UAEF,OAAAhB,iBAAA,CACGL,EAAE,CAACyB,UAAU;YAAA,IAACnB,IAAIA,CAAA;cAAA,OAAE,GAAGO,aAAa,CAACa,WAAW,CAAC,CAAC,KAAK;YAAA;YAAA,IAAAnB,SAAA;cAAA,QAAAoB,MAAA,OACrDZ,mBAAmB,qBAEH,GAAG,wBAAoB,GAAG,4CAEtC,MAAM,CAEV,GAAAV,iBAAA,CACAH,kBAAkB;gBACjBW,aAAa,EAAEA,aAAa;gBAC5BC,UAAU,EAAEA;cAAU;YAAA;UAAA;QAI9B;MAAC;IAAA;EAAA;AAIT","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { For, SourceDirectory } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
+
import { isVoidType } from "@typespec/compiler";
|
|
3
4
|
import { OperationInterface } from "./OperationInterface.js";
|
|
4
5
|
/**
|
|
5
6
|
* Generates the operations directory with operation interface files.
|
|
@@ -7,8 +8,20 @@ import { OperationInterface } from "./OperationInterface.js";
|
|
|
7
8
|
export function OperationsDirectory(props) {
|
|
8
9
|
return (<SourceDirectory path="operations">
|
|
9
10
|
<For each={Array.from(props.groupedOperations.entries())}>
|
|
10
|
-
{
|
|
11
|
+
{([containerName, operations]) => {
|
|
12
|
+
const hasResponseWithBody = operations.some(function (op) {
|
|
13
|
+
const isVoid = isVoidType(op.operation.returnType);
|
|
14
|
+
const is204 = op.responses.some(function (r) {
|
|
15
|
+
return r.statusCodes === 204;
|
|
16
|
+
});
|
|
17
|
+
return !isVoid && !is204;
|
|
18
|
+
});
|
|
11
19
|
return (<ts.SourceFile path={`${containerName.toLowerCase()}.ts`}>
|
|
20
|
+
{hasResponseWithBody && (<>
|
|
21
|
+
import type {"{"} ResponseWithBody {"}"} from
|
|
22
|
+
"../models/response-types.js";
|
|
23
|
+
{"\n\n"}
|
|
24
|
+
</>)}
|
|
12
25
|
<OperationInterface containerName={containerName} operations={operations}/>
|
|
13
26
|
</ts.SourceFile>);
|
|
14
27
|
}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationsDirectory.jsx","sourceRoot":"","sources":["../../../src/components/OperationsDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAM7D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,OAAO,CACL,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAChC;MAAA,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC,CACvD;QAAA,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"OperationsDirectory.jsx","sourceRoot":"","sources":["../../../src/components/OperationsDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAM7D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,OAAO,CACL,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAChC;MAAA,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC,CACvD;QAAA,CAAC,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,EAAE,EAAE;YAC/B,MAAM,mBAAmB,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE;gBACtD,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACnD,MAAM,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC;oBACzC,OAAO,CAAC,CAAC,WAAW,KAAK,GAAG,CAAC;gBAC/B,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,OAAO,CACL,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CACvD;cAAA,CAAC,mBAAmB,IAAI,CACtB,EACE;8BAAY,CAAC,GAAG,CAAE,kBAAiB,CAAC,GAAG,CAAE;;kBAEzC,CAAC,MAAM,CACT;gBAAA,GAAG,CACJ,CACD;cAAA,CAAC,kBAAkB,CACjB,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,UAAU,CAAC,CAAC,UAAU,CAAC,EAE3B;YAAA,EAAE,EAAE,CAAC,UAAU,CAAC,CACjB,CAAC;QACJ,CAAC,CACH;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { refkey } from "@alloy-js/core";
|
|
3
|
+
import * as ts from "@alloy-js/typescript";
|
|
4
|
+
export function getNoContentResponseRef() {
|
|
5
|
+
return refkey("NoContentResponse", "response-types");
|
|
6
|
+
}
|
|
7
|
+
export function getResponseWithBodyRef() {
|
|
8
|
+
return refkey("ResponseWithBody", "response-types");
|
|
9
|
+
}
|
|
10
|
+
export function ResponseTypes() {
|
|
11
|
+
const noContentRef = getNoContentResponseRef();
|
|
12
|
+
return [_$createComponent(ts.InterfaceDeclaration, {
|
|
13
|
+
name: "NoContentResponse",
|
|
14
|
+
"export": true,
|
|
15
|
+
refkey: noContentRef,
|
|
16
|
+
get children() {
|
|
17
|
+
return ["statusCode: number"];
|
|
18
|
+
}
|
|
19
|
+
}), "\n\n", ["export interface ResponseWithBody", "<", "TBody", ">", " ", "{", "\n", " ", "statusCode: number;", "\n", " ", "body: TBody;", "\n", "}"]];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ResponseTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["refkey","ts","getNoContentResponseRef","getResponseWithBodyRef","ResponseTypes","noContentRef","_$createComponent","InterfaceDeclaration","name","children"],"sources":["../../../src/components/ResponseTypes.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAqB,gBAAgB;AACpD,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,OAAO,SAASC,uBAAuBA,CAAA,EAAW;EAChD,OAAOF,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC;AACtD;AAEA,OAAO,SAASG,sBAAsBA,CAAA,EAAW;EAC/C,OAAOH,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;AACrD;AAEA,OAAO,SAASI,aAAaA,CAAA,EAAG;EAC9B,MAAMC,YAAY,GAAGH,uBAAuB,CAAC,CAAC;EAE9C,QAAAI,iBAAA,CAEKL,EAAE,CAACM,oBAAoB;IACtBC,IAAI;IAAA;IAEJR,MAAM,EAAEK,YAAY;IAAA,IAAAI,SAAA;MAAA;IAAA;EAAA,IAIrB,MAAM,wCAE6B,GAAG,WAAO,GAAG,OAAG,GAAG,EACpD,IAAI,EACJ,IAAI,yBACJ,IAAI,EACJ,IAAI,kBACJ,IAAI,EACJ,GAAG;AAIZ","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { refkey } from "@alloy-js/core";
|
|
2
|
+
import * as ts from "@alloy-js/typescript";
|
|
3
|
+
export function getNoContentResponseRef() {
|
|
4
|
+
return refkey("NoContentResponse", "response-types");
|
|
5
|
+
}
|
|
6
|
+
export function getResponseWithBodyRef() {
|
|
7
|
+
return refkey("ResponseWithBody", "response-types");
|
|
8
|
+
}
|
|
9
|
+
export function ResponseTypes() {
|
|
10
|
+
const noContentRef = getNoContentResponseRef();
|
|
11
|
+
return (<>
|
|
12
|
+
<ts.InterfaceDeclaration name="NoContentResponse" export refkey={noContentRef}>
|
|
13
|
+
<>statusCode: number</>
|
|
14
|
+
</ts.InterfaceDeclaration>
|
|
15
|
+
{"\n\n"}
|
|
16
|
+
<>
|
|
17
|
+
export interface ResponseWithBody{"<"}TBody{">"} {"{"}
|
|
18
|
+
{"\n"}
|
|
19
|
+
{" "}statusCode: number;
|
|
20
|
+
{"\n"}
|
|
21
|
+
{" "}body: TBody;
|
|
22
|
+
{"\n"}
|
|
23
|
+
{"}"}
|
|
24
|
+
</>
|
|
25
|
+
</>);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ResponseTypes.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseTypes.jsx","sourceRoot":"","sources":["../../../src/components/ResponseTypes.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3C,MAAM,UAAU,uBAAuB;IACrC,OAAO,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,MAAM,YAAY,GAAG,uBAAuB,EAAE,CAAC;IAE/C,OAAO,CACL,EACE;MAAA,CAAC,EAAE,CAAC,oBAAoB,CACtB,IAAI,CAAC,mBAAmB,CACxB,MAAM,CACN,MAAM,CAAC,CAAC,YAAY,CAAC,CAErB;QAAA,EAAE,kBAAkB,GACtB;MAAA,EAAE,EAAE,CAAC,oBAAoB,CACzB;MAAA,CAAC,MAAM,CACP;MAAA,EACE;yCAAiC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAE,CAAA,CAAC,GAAG,CACrD;QAAA,CAAC,IAAI,CACL;QAAA,CAAC,IAAI,CAAC;QACN,CAAC,IAAI,CACL;QAAA,CAAC,IAAI,CAAC;QACN,CAAC,IAAI,CACL;QAAA,CAAC,GAAG,CACN;MAAA,GACF;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -10,7 +10,7 @@ export interface RouteRegistrationProps {
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function getRouteRegistrationRef(containerName: string): Refkey;
|
|
12
12
|
/**
|
|
13
|
-
* Generates Fastify route registration functions.
|
|
14
|
-
*
|
|
13
|
+
* Generates Fastify route registration functions with Zod schema validation.
|
|
14
|
+
* Uses fastify-type-provider-zod for automatic type inference and runtime validation.
|
|
15
15
|
*/
|
|
16
16
|
export declare function RouteRegistration(props: RouteRegistrationProps): Children;
|