@rexeus/typeweaver-types 0.10.4 → 0.11.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/dist/index.cjs +7 -2
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/dist/lib/definitionLookup.js +4 -2
- package/dist/lib/errors/MissingOperationDefinitionError.js +16 -0
- package/dist/lib/errors/MissingResponseDefinitionError.js +14 -0
- package/dist/templates/Request.ejs +2 -2
- package/dist/templates/RequestValidator.ejs +5 -3
- package/dist/templates/Response.ejs +2 -1
- package/dist/templates/ResponseFactory.ejs +2 -1
- package/dist/templates/SharedResponse.ejs +2 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ function writeRequestType(templateFilePath, resourceName, operation, context) {
|
|
|
53
53
|
const content = context.renderTemplate(templateFilePath, {
|
|
54
54
|
pascalCaseOperationId: (0, polycase.pascalCase)(operationId),
|
|
55
55
|
method,
|
|
56
|
+
requestJsDoc: (0, _rexeus_typeweaver_gen.createJSDocComment)(operation.summary),
|
|
56
57
|
headerTsType: header ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(header)) : void 0,
|
|
57
58
|
queryTsType: query ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(query)) : void 0,
|
|
58
59
|
paramTsType: param ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(param)) : void 0,
|
|
@@ -12842,6 +12843,7 @@ function generate$2(context) {
|
|
|
12842
12843
|
function writeRequestValidator(templateFilePath, resourceName, operation, context) {
|
|
12843
12844
|
const { operationId, request } = operation;
|
|
12844
12845
|
const { body, query, param, header } = request ?? {};
|
|
12846
|
+
const hasRequestSchema = body !== void 0 || header !== void 0 || param !== void 0 || query !== void 0;
|
|
12845
12847
|
const outputPaths = context.getOperationOutputPaths({
|
|
12846
12848
|
resourceName,
|
|
12847
12849
|
operationId
|
|
@@ -12858,6 +12860,7 @@ function writeRequestValidator(templateFilePath, resourceName, operation, contex
|
|
|
12858
12860
|
query,
|
|
12859
12861
|
param,
|
|
12860
12862
|
header,
|
|
12863
|
+
hasRequestSchema,
|
|
12861
12864
|
z: external_exports
|
|
12862
12865
|
});
|
|
12863
12866
|
const relativePath = node_path.default.relative(context.outputDir, outputPaths.requestValidationFile);
|
|
@@ -12914,7 +12917,8 @@ function createOwnResponseTemplateData(response, responseFactoryTemplateFile, co
|
|
|
12914
12917
|
typeValue: response.name,
|
|
12915
12918
|
statusCodeKey: _rexeus_typeweaver_core.HttpStatusCode[response.statusCode],
|
|
12916
12919
|
hasHeader,
|
|
12917
|
-
hasBody
|
|
12920
|
+
hasBody,
|
|
12921
|
+
jsDoc: (0, _rexeus_typeweaver_gen.createJSDocComment)(response.description)
|
|
12918
12922
|
};
|
|
12919
12923
|
return {
|
|
12920
12924
|
...factoryData,
|
|
@@ -12933,7 +12937,8 @@ function writeCanonicalResponseType(templateFile, responseFactoryTemplateFile, r
|
|
|
12933
12937
|
typeValue: response.name,
|
|
12934
12938
|
statusCodeKey: _rexeus_typeweaver_core.HttpStatusCode[response.statusCode],
|
|
12935
12939
|
hasHeader: response.header !== void 0,
|
|
12936
|
-
hasBody: response.body !== void 0
|
|
12940
|
+
hasBody: response.body !== void 0,
|
|
12941
|
+
jsDoc: (0, _rexeus_typeweaver_gen.createJSDocComment)(response.description)
|
|
12937
12942
|
};
|
|
12938
12943
|
const content = context.renderTemplate(templateFile, {
|
|
12939
12944
|
coreDir: context.coreDir,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { BasePlugin } from "@rexeus/typeweaver-gen";
|
|
3
|
+
import { BasePlugin, createJSDocComment } from "@rexeus/typeweaver-gen";
|
|
4
4
|
import { fromZod, print } from "@rexeus/typeweaver-zod-to-ts";
|
|
5
5
|
import { camelCase, pascalCase } from "polycase";
|
|
6
6
|
import { HttpStatusCode } from "@rexeus/typeweaver-core";
|
|
@@ -32,6 +32,7 @@ function writeRequestType(templateFilePath, resourceName, operation, context) {
|
|
|
32
32
|
const content = context.renderTemplate(templateFilePath, {
|
|
33
33
|
pascalCaseOperationId: pascalCase(operationId),
|
|
34
34
|
method,
|
|
35
|
+
requestJsDoc: createJSDocComment(operation.summary),
|
|
35
36
|
headerTsType: header ? print(fromZod(header)) : void 0,
|
|
36
37
|
queryTsType: query ? print(fromZod(query)) : void 0,
|
|
37
38
|
paramTsType: param ? print(fromZod(param)) : void 0,
|
|
@@ -12821,6 +12822,7 @@ function generate$2(context) {
|
|
|
12821
12822
|
function writeRequestValidator(templateFilePath, resourceName, operation, context) {
|
|
12822
12823
|
const { operationId, request } = operation;
|
|
12823
12824
|
const { body, query, param, header } = request ?? {};
|
|
12825
|
+
const hasRequestSchema = body !== void 0 || header !== void 0 || param !== void 0 || query !== void 0;
|
|
12824
12826
|
const outputPaths = context.getOperationOutputPaths({
|
|
12825
12827
|
resourceName,
|
|
12826
12828
|
operationId
|
|
@@ -12837,6 +12839,7 @@ function writeRequestValidator(templateFilePath, resourceName, operation, contex
|
|
|
12837
12839
|
query,
|
|
12838
12840
|
param,
|
|
12839
12841
|
header,
|
|
12842
|
+
hasRequestSchema,
|
|
12840
12843
|
z: external_exports
|
|
12841
12844
|
});
|
|
12842
12845
|
const relativePath = path.relative(context.outputDir, outputPaths.requestValidationFile);
|
|
@@ -12893,7 +12896,8 @@ function createOwnResponseTemplateData(response, responseFactoryTemplateFile, co
|
|
|
12893
12896
|
typeValue: response.name,
|
|
12894
12897
|
statusCodeKey: HttpStatusCode[response.statusCode],
|
|
12895
12898
|
hasHeader,
|
|
12896
|
-
hasBody
|
|
12899
|
+
hasBody,
|
|
12900
|
+
jsDoc: createJSDocComment(response.description)
|
|
12897
12901
|
};
|
|
12898
12902
|
return {
|
|
12899
12903
|
...factoryData,
|
|
@@ -12912,7 +12916,8 @@ function writeCanonicalResponseType(templateFile, responseFactoryTemplateFile, r
|
|
|
12912
12916
|
typeValue: response.name,
|
|
12913
12917
|
statusCodeKey: HttpStatusCode[response.statusCode],
|
|
12914
12918
|
hasHeader: response.header !== void 0,
|
|
12915
|
-
hasBody: response.body !== void 0
|
|
12919
|
+
hasBody: response.body !== void 0,
|
|
12920
|
+
jsDoc: createJSDocComment(response.description)
|
|
12916
12921
|
};
|
|
12917
12922
|
const content = context.renderTemplate(templateFile, {
|
|
12918
12923
|
coreDir: context.coreDir,
|