@rexeus/typeweaver-types 0.10.1 → 0.10.3
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/index.cjs +43 -20
- package/dist/index.mjs +44 -21
- package/dist/index.mjs.map +1 -1
- package/dist/lib/RequestValidator.d.ts +1 -1
- package/dist/lib/RequestValidator.js +1 -1
- package/dist/lib/ResponseValidator.d.ts +1 -1
- package/dist/lib/ResponseValidator.js +1 -1
- package/dist/lib/index.ts +4 -4
- package/dist/templates/RequestValidator.ejs +1 -1
- package/dist/templates/Response.ejs +14 -25
- package/dist/templates/ResponseFactory.ejs +12 -0
- package/dist/templates/ResponseValidator.ejs +1 -1
- package/dist/templates/SharedResponse.ejs +8 -19
- package/package.json +7 -6
package/dist/lib/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @generated by @rexeus/typeweaver
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export * from "./definitionLookup";
|
|
9
|
-
export * from "./RequestValidator";
|
|
10
|
-
export * from "./ResponseValidator";
|
|
11
|
-
export * from "./Validator";
|
|
8
|
+
export * from "./definitionLookup.js";
|
|
9
|
+
export * from "./RequestValidator.js";
|
|
10
|
+
export * from "./ResponseValidator.js";
|
|
11
|
+
export * from "./Validator.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
type SafeRequestValidationResult,
|
|
13
13
|
RequestValidationError
|
|
14
14
|
} from "@rexeus/typeweaver-core";
|
|
15
|
-
import { getOperationDefinition, RequestValidator } from "../lib/types";
|
|
15
|
+
import { getOperationDefinition, RequestValidator } from "../lib/types/index.js";
|
|
16
16
|
import type { I<%= pascalCaseOperationId %>Request } from "<%= requestFile %>";
|
|
17
17
|
|
|
18
18
|
const definition = getOperationDefinition(spec, "<%= resourceName %>", "<%= operationId %>");
|
|
@@ -11,49 +11,38 @@ import { HttpStatusCode } from "<%= coreDir %>";
|
|
|
11
11
|
import type { ITypedHttpResponse } from "<%= coreDir %>";
|
|
12
12
|
<% } %>
|
|
13
13
|
<% for (const shared of sharedResponses) { %>
|
|
14
|
-
import type { I<%= shared.
|
|
14
|
+
import type { I<%= shared.identifierName %>Response } from "<%= shared.path %>";
|
|
15
15
|
<% } %>
|
|
16
16
|
<% for(const entityResponse of entityResponses) { %>
|
|
17
|
-
import type { I<%= entityResponse.
|
|
17
|
+
import type { I<%= entityResponse.identifierName %>Response } from "<%= entityResponse.path %>";
|
|
18
18
|
<% } %>
|
|
19
19
|
|
|
20
20
|
<% for (const ownResponse of ownResponses) { %>
|
|
21
|
-
<% if (ownResponse.
|
|
22
|
-
export type I<%= ownResponse.
|
|
21
|
+
<% if (ownResponse.hasHeader) { %>
|
|
22
|
+
export type I<%= ownResponse.identifierName %>ResponseHeader = <%- ownResponse.header %>;
|
|
23
23
|
<% } %>
|
|
24
24
|
|
|
25
|
-
<% if (ownResponse.
|
|
26
|
-
export type I<%= ownResponse.
|
|
25
|
+
<% if (ownResponse.hasBody) { %>
|
|
26
|
+
export type I<%= ownResponse.identifierName %>ResponseBody = <%- ownResponse.body %>;
|
|
27
27
|
<% } %>
|
|
28
28
|
|
|
29
|
-
export type I<%= ownResponse.
|
|
30
|
-
"<%= ownResponse.
|
|
29
|
+
export type I<%= ownResponse.identifierName %>Response = ITypedHttpResponse<
|
|
30
|
+
"<%= ownResponse.typeValue %>",
|
|
31
31
|
HttpStatusCode.<%= ownResponse.statusCodeKey %>,
|
|
32
|
-
<%= ownResponse.
|
|
33
|
-
<%= ownResponse.
|
|
32
|
+
<%= ownResponse.hasHeader ? `I${ownResponse.identifierName}ResponseHeader` : 'undefined' %>,
|
|
33
|
+
<%= ownResponse.hasBody ? `I${ownResponse.identifierName}ResponseBody` : 'undefined' %>
|
|
34
34
|
>;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
export const create<%= ownResponse.name %>Response = (input: Omit<I<%= ownResponse.name %>Response, "type" | "statusCode">): I<%= ownResponse.name %>Response => ({
|
|
38
|
-
...input,
|
|
39
|
-
type: "<%= ownResponse.name %>",
|
|
40
|
-
statusCode: HttpStatusCode.<%= ownResponse.statusCodeKey %>,
|
|
41
|
-
});
|
|
42
|
-
<% } else { %>
|
|
43
|
-
export const create<%= ownResponse.name %>Response = (): I<%= ownResponse.name %>Response => ({
|
|
44
|
-
type: "<%= ownResponse.name %>",
|
|
45
|
-
statusCode: HttpStatusCode.<%= ownResponse.statusCodeKey %>,
|
|
46
|
-
});
|
|
47
|
-
<% } %>
|
|
36
|
+
<%- ownResponse.factory %>
|
|
48
37
|
<% } %>
|
|
49
38
|
|
|
50
39
|
export type <%= pascalCaseOperationId %>Response =
|
|
51
40
|
<% for (const ownResponse of ownResponses) { %>
|
|
52
|
-
| I<%= ownResponse.
|
|
41
|
+
| I<%= ownResponse.identifierName %>Response
|
|
53
42
|
<% } %>
|
|
54
43
|
<% for (const shared of sharedResponses) { %>
|
|
55
|
-
| I<%= shared.
|
|
44
|
+
| I<%= shared.identifierName %>Response
|
|
56
45
|
<% } %>
|
|
57
46
|
<% for (const entityResponse of entityResponses) { %>
|
|
58
|
-
| I<%= entityResponse.
|
|
47
|
+
| I<%= entityResponse.identifierName %>Response
|
|
59
48
|
<% } %>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%= indentation %>export const create<%= identifierName %>Response = <% if (hasHeader || hasBody) { %>(
|
|
2
|
+
<%= indentation %>input: {
|
|
3
|
+
<% if (hasHeader) { %><%= indentation %> header: I<%= identifierName %>ResponseHeader;
|
|
4
|
+
<% } %><% if (hasBody) { %><%= indentation %> body: I<%= identifierName %>ResponseBody;
|
|
5
|
+
<% } %>
|
|
6
|
+
<%= indentation %>}
|
|
7
|
+
<%= indentation %>): I<%= identifierName %>Response<% } else { %>(): I<%= identifierName %>Response<% } %> => ({
|
|
8
|
+
<%= indentation %> type: "<%= typeValue %>",
|
|
9
|
+
<%= indentation %> statusCode: HttpStatusCode.<%= statusCodeKey %>,
|
|
10
|
+
<%= indentation %> header: <%= hasHeader ? 'input.header' : 'undefined' %>,
|
|
11
|
+
<%= indentation %> body: <%= hasBody ? 'input.body' : 'undefined' %>,
|
|
12
|
+
<%= indentation %>});
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getResponseDefinition,
|
|
13
13
|
type ResponseEntry,
|
|
14
14
|
ResponseValidator,
|
|
15
|
-
} from "../lib/types";
|
|
15
|
+
} from "../lib/types/index.js";
|
|
16
16
|
import type { <%= pascalCaseOperationId %>Response } from "<%= responseFile %>";
|
|
17
17
|
|
|
18
18
|
const definition = getOperationDefinition(spec, "<%= resourceName %>", "<%= operationId %>");
|
|
@@ -10,29 +10,18 @@ import { HttpStatusCode } from "<%= coreDir %>";
|
|
|
10
10
|
import type { ITypedHttpResponse } from "<%= coreDir %>";
|
|
11
11
|
|
|
12
12
|
<% if (headerTsType) { %>
|
|
13
|
-
export type I<%=
|
|
13
|
+
export type I<%= identifierName %>ResponseHeader = <%- headerTsType %>;
|
|
14
14
|
<% } %>
|
|
15
15
|
|
|
16
16
|
<% if (bodyTsType) { %>
|
|
17
|
-
export type I<%=
|
|
17
|
+
export type I<%= identifierName %>ResponseBody = <%- bodyTsType %>;
|
|
18
18
|
<% } %>
|
|
19
19
|
|
|
20
|
-
export type I<%=
|
|
21
|
-
"<%=
|
|
22
|
-
HttpStatusCode.<%=
|
|
23
|
-
<%=
|
|
24
|
-
<%=
|
|
20
|
+
export type I<%= identifierName %>Response = ITypedHttpResponse<
|
|
21
|
+
"<%= typeValue %>",
|
|
22
|
+
HttpStatusCode.<%= statusCodeKey %>,
|
|
23
|
+
<%= hasHeader ? `I${identifierName}ResponseHeader` : 'undefined' %>,
|
|
24
|
+
<%= hasBody ? `I${identifierName}ResponseBody` : 'undefined' %>
|
|
25
25
|
>;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
export const create<%= pascalCaseName %>Response = (input: Omit<I<%= pascalCaseName %>Response, "type" | "statusCode">): I<%= pascalCaseName %>Response => ({
|
|
29
|
-
...input,
|
|
30
|
-
type: "<%= pascalCaseName %>",
|
|
31
|
-
statusCode: HttpStatusCode.<%= httpStatusCode[sharedResponse.statusCode] %>,
|
|
32
|
-
});
|
|
33
|
-
<% } else { %>
|
|
34
|
-
export const create<%= pascalCaseName %>Response = (): I<%= pascalCaseName %>Response => ({
|
|
35
|
-
type: "<%= pascalCaseName %>",
|
|
36
|
-
statusCode: HttpStatusCode.<%= httpStatusCode[sharedResponse.statusCode] %>,
|
|
37
|
-
});
|
|
38
|
-
<% } %>
|
|
27
|
+
<%- factory %>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-types",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "Generates request and response types plus validators aligned with your API contract. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,16 +47,17 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@rexeus/typeweaver-core": "^0.10.
|
|
51
|
-
"@rexeus/typeweaver-gen": "^0.10.
|
|
50
|
+
"@rexeus/typeweaver-core": "^0.10.3",
|
|
51
|
+
"@rexeus/typeweaver-gen": "^0.10.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"test-utils": "file:../test-utils",
|
|
55
|
-
"@rexeus/typeweaver-
|
|
56
|
-
"@rexeus/typeweaver-
|
|
55
|
+
"@rexeus/typeweaver-core": "^0.10.3",
|
|
56
|
+
"@rexeus/typeweaver-gen": "^0.10.3"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"
|
|
59
|
+
"polycase": "^1.1.0",
|
|
60
|
+
"@rexeus/typeweaver-zod-to-ts": "^0.10.3"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|