@rexeus/typeweaver-types 0.9.2 → 0.10.1
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 +8 -9
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -9
- package/dist/index.mjs.map +1 -1
- package/dist/lib/RequestValidator.js +21 -15
- package/dist/lib/ResponseValidator.js +97 -96
- package/dist/lib/Validator.js +193 -180
- package/dist/lib/definitionLookup.js +16 -10
- package/dist/templates/RequestValidator.ejs +1 -1
- package/dist/templates/ResponseValidator.ejs +1 -1
- package/package.json +7 -9
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -34,8 +35,6 @@ node_path = __toESM(node_path);
|
|
|
34
35
|
let node_url = require("node:url");
|
|
35
36
|
let _rexeus_typeweaver_gen = require("@rexeus/typeweaver-gen");
|
|
36
37
|
let _rexeus_typeweaver_zod_to_ts = require("@rexeus/typeweaver-zod-to-ts");
|
|
37
|
-
let case$1 = require("case");
|
|
38
|
-
case$1 = __toESM(case$1);
|
|
39
38
|
let _rexeus_typeweaver_core = require("@rexeus/typeweaver-core");
|
|
40
39
|
//#region src/requestGenerator.ts
|
|
41
40
|
const moduleDir$4 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
@@ -51,7 +50,7 @@ function writeRequestType(templateFilePath, resourceName, operation, context) {
|
|
|
51
50
|
operationId
|
|
52
51
|
});
|
|
53
52
|
const content = context.renderTemplate(templateFilePath, {
|
|
54
|
-
pascalCaseOperationId:
|
|
53
|
+
pascalCaseOperationId: (0, _rexeus_typeweaver_gen.toPascalCase)(operationId),
|
|
55
54
|
method,
|
|
56
55
|
headerTsType: header ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(header)) : void 0,
|
|
57
56
|
queryTsType: query ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(query)) : void 0,
|
|
@@ -12846,7 +12845,7 @@ function writeRequestValidator(templateFilePath, resourceName, operation, contex
|
|
|
12846
12845
|
resourceName,
|
|
12847
12846
|
operationId
|
|
12848
12847
|
});
|
|
12849
|
-
const pascalCaseOperationId =
|
|
12848
|
+
const pascalCaseOperationId = (0, _rexeus_typeweaver_gen.toPascalCase)(operationId);
|
|
12850
12849
|
const content = context.renderTemplate(templateFilePath, {
|
|
12851
12850
|
pascalCaseOperationId,
|
|
12852
12851
|
operationId,
|
|
@@ -12877,7 +12876,7 @@ function writeResponseType(templateFile, resource, operation, context) {
|
|
|
12877
12876
|
resourceName: resource.name,
|
|
12878
12877
|
operationId: operation.operationId
|
|
12879
12878
|
});
|
|
12880
|
-
const pascalCaseOperationId =
|
|
12879
|
+
const pascalCaseOperationId = (0, _rexeus_typeweaver_gen.toPascalCase)(operation.operationId);
|
|
12881
12880
|
const ownResponses = [];
|
|
12882
12881
|
const canonicalResponses = [];
|
|
12883
12882
|
for (const responseUsage of operation.responses) {
|
|
@@ -12915,7 +12914,7 @@ function createOwnResponseTemplateData(response) {
|
|
|
12915
12914
|
};
|
|
12916
12915
|
}
|
|
12917
12916
|
function writeCanonicalResponseType(templateFile, response, context) {
|
|
12918
|
-
const pascalCaseName =
|
|
12917
|
+
const pascalCaseName = (0, _rexeus_typeweaver_gen.toPascalCase)(response.name);
|
|
12919
12918
|
const headerTsType = response.header ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(response.header)) : void 0;
|
|
12920
12919
|
const bodyTsType = response.body ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(response.body)) : void 0;
|
|
12921
12920
|
const content = context.renderTemplate(templateFile, {
|
|
@@ -12943,7 +12942,7 @@ function writeResponseValidator(templateFilePath, resource, operation, context)
|
|
|
12943
12942
|
resourceName: resource.name,
|
|
12944
12943
|
operationId: operation.operationId
|
|
12945
12944
|
});
|
|
12946
|
-
const pascalCaseOperationId =
|
|
12945
|
+
const pascalCaseOperationId = (0, _rexeus_typeweaver_gen.toPascalCase)(operation.operationId);
|
|
12947
12946
|
const ownResponses = [];
|
|
12948
12947
|
const sharedResponses = [];
|
|
12949
12948
|
const allStatusCodes = /* @__PURE__ */ new Map();
|
|
@@ -12951,7 +12950,7 @@ function writeResponseValidator(templateFilePath, resource, operation, context)
|
|
|
12951
12950
|
const response = responseUsage.source === "canonical" ? context.getCanonicalResponse(responseUsage.responseName) : responseUsage.response;
|
|
12952
12951
|
allStatusCodes.set(response.statusCode, response.statusCodeName);
|
|
12953
12952
|
const templateData = {
|
|
12954
|
-
definitionVariableName: `${
|
|
12953
|
+
definitionVariableName: `${(0, _rexeus_typeweaver_gen.toCamelCase)(response.name)}Definition`,
|
|
12955
12954
|
name: response.name,
|
|
12956
12955
|
hasBody: response.body !== void 0,
|
|
12957
12956
|
hasHeader: response.header !== void 0,
|
|
@@ -12998,4 +12997,4 @@ var TypesPlugin = class extends _rexeus_typeweaver_gen.BasePlugin {
|
|
|
12998
12997
|
}
|
|
12999
12998
|
};
|
|
13000
12999
|
//#endregion
|
|
13001
|
-
|
|
13000
|
+
exports.TypesPlugin = TypesPlugin;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAWa,WAAA,SAAoB,UAAA;EACxB,IAAA;EAES,QAAA,CAAS,OAAA,EAAS,gBAAA;AAAA"}
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAWa,WAAA,SAAoB,UAAA;EACxB,IAAA;EAES,QAAA,CAAS,OAAA,EAAS,gBAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { BasePlugin } from "@rexeus/typeweaver-gen";
|
|
3
|
+
import { BasePlugin, toCamelCase, toPascalCase } from "@rexeus/typeweaver-gen";
|
|
4
4
|
import { fromZod, print } from "@rexeus/typeweaver-zod-to-ts";
|
|
5
|
-
import Case from "case";
|
|
6
5
|
import { HttpStatusCode } from "@rexeus/typeweaver-core";
|
|
7
6
|
//#region \0rolldown/runtime.js
|
|
8
7
|
var __defProp = Object.defineProperty;
|
|
@@ -30,7 +29,7 @@ function writeRequestType(templateFilePath, resourceName, operation, context) {
|
|
|
30
29
|
operationId
|
|
31
30
|
});
|
|
32
31
|
const content = context.renderTemplate(templateFilePath, {
|
|
33
|
-
pascalCaseOperationId:
|
|
32
|
+
pascalCaseOperationId: toPascalCase(operationId),
|
|
34
33
|
method,
|
|
35
34
|
headerTsType: header ? print(fromZod(header)) : void 0,
|
|
36
35
|
queryTsType: query ? print(fromZod(query)) : void 0,
|
|
@@ -12825,7 +12824,7 @@ function writeRequestValidator(templateFilePath, resourceName, operation, contex
|
|
|
12825
12824
|
resourceName,
|
|
12826
12825
|
operationId
|
|
12827
12826
|
});
|
|
12828
|
-
const pascalCaseOperationId =
|
|
12827
|
+
const pascalCaseOperationId = toPascalCase(operationId);
|
|
12829
12828
|
const content = context.renderTemplate(templateFilePath, {
|
|
12830
12829
|
pascalCaseOperationId,
|
|
12831
12830
|
operationId,
|
|
@@ -12856,7 +12855,7 @@ function writeResponseType(templateFile, resource, operation, context) {
|
|
|
12856
12855
|
resourceName: resource.name,
|
|
12857
12856
|
operationId: operation.operationId
|
|
12858
12857
|
});
|
|
12859
|
-
const pascalCaseOperationId =
|
|
12858
|
+
const pascalCaseOperationId = toPascalCase(operation.operationId);
|
|
12860
12859
|
const ownResponses = [];
|
|
12861
12860
|
const canonicalResponses = [];
|
|
12862
12861
|
for (const responseUsage of operation.responses) {
|
|
@@ -12894,7 +12893,7 @@ function createOwnResponseTemplateData(response) {
|
|
|
12894
12893
|
};
|
|
12895
12894
|
}
|
|
12896
12895
|
function writeCanonicalResponseType(templateFile, response, context) {
|
|
12897
|
-
const pascalCaseName =
|
|
12896
|
+
const pascalCaseName = toPascalCase(response.name);
|
|
12898
12897
|
const headerTsType = response.header ? print(fromZod(response.header)) : void 0;
|
|
12899
12898
|
const bodyTsType = response.body ? print(fromZod(response.body)) : void 0;
|
|
12900
12899
|
const content = context.renderTemplate(templateFile, {
|
|
@@ -12922,7 +12921,7 @@ function writeResponseValidator(templateFilePath, resource, operation, context)
|
|
|
12922
12921
|
resourceName: resource.name,
|
|
12923
12922
|
operationId: operation.operationId
|
|
12924
12923
|
});
|
|
12925
|
-
const pascalCaseOperationId =
|
|
12924
|
+
const pascalCaseOperationId = toPascalCase(operation.operationId);
|
|
12926
12925
|
const ownResponses = [];
|
|
12927
12926
|
const sharedResponses = [];
|
|
12928
12927
|
const allStatusCodes = /* @__PURE__ */ new Map();
|
|
@@ -12930,7 +12929,7 @@ function writeResponseValidator(templateFilePath, resource, operation, context)
|
|
|
12930
12929
|
const response = responseUsage.source === "canonical" ? context.getCanonicalResponse(responseUsage.responseName) : responseUsage.response;
|
|
12931
12930
|
allStatusCodes.set(response.statusCode, response.statusCodeName);
|
|
12932
12931
|
const templateData = {
|
|
12933
|
-
definitionVariableName: `${
|
|
12932
|
+
definitionVariableName: `${toCamelCase(response.name)}Definition`,
|
|
12934
12933
|
name: response.name,
|
|
12935
12934
|
hasBody: response.body !== void 0,
|
|
12936
12935
|
hasHeader: response.header !== void 0,
|
|
@@ -12977,6 +12976,6 @@ var TypesPlugin = class extends BasePlugin {
|
|
|
12977
12976
|
}
|
|
12978
12977
|
};
|
|
12979
12978
|
//#endregion
|
|
12980
|
-
export { TypesPlugin
|
|
12979
|
+
export { TypesPlugin };
|
|
12981
12980
|
|
|
12982
12981
|
//# sourceMappingURL=index.mjs.map
|