@rexeus/typeweaver-clients 0.9.1 → 0.10.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 +5 -6
- 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 +5 -6
- package/dist/index.mjs.map +1 -1
- package/dist/templates/RequestCommand.ejs +1 -1
- package/package.json +6 -7
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;
|
|
@@ -25,8 +26,6 @@ node_path = __toESM(node_path);
|
|
|
25
26
|
let node_url = require("node:url");
|
|
26
27
|
let _rexeus_typeweaver_gen = require("@rexeus/typeweaver-gen");
|
|
27
28
|
let _rexeus_typeweaver_zod_to_ts = require("@rexeus/typeweaver-zod-to-ts");
|
|
28
|
-
let case$1 = require("case");
|
|
29
|
-
case$1 = __toESM(case$1);
|
|
30
29
|
//#region src/clientGenerator.ts
|
|
31
30
|
const moduleDir$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
32
31
|
function generate(context) {
|
|
@@ -38,7 +37,7 @@ function generate(context) {
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
function writeClient(templateFilePath, resource, context) {
|
|
41
|
-
const pascalCaseEntityName =
|
|
40
|
+
const pascalCaseEntityName = (0, _rexeus_typeweaver_gen.toPascalCase)(resource.name);
|
|
42
41
|
const outputDir = context.getResourceOutputDir(resource.name);
|
|
43
42
|
const operations = resource.operations.map((operation) => {
|
|
44
43
|
const outputPaths = context.getOperationOutputPaths({
|
|
@@ -47,7 +46,7 @@ function writeClient(templateFilePath, resource, context) {
|
|
|
47
46
|
});
|
|
48
47
|
return {
|
|
49
48
|
operationId: operation.operationId,
|
|
50
|
-
pascalCaseOperationId:
|
|
49
|
+
pascalCaseOperationId: (0, _rexeus_typeweaver_gen.toPascalCase)(operation.operationId),
|
|
51
50
|
requestFile: `./${node_path.default.basename(outputPaths.requestFileName, ".ts")}`,
|
|
52
51
|
responseValidatorFile: `./${node_path.default.basename(outputPaths.responseValidationFileName, ".ts")}`,
|
|
53
52
|
responseFile: `./${node_path.default.basename(outputPaths.responseFileName, ".ts")}`
|
|
@@ -73,7 +72,7 @@ function writeRequestCommand(templateFilePath, resourceName, operation, context)
|
|
|
73
72
|
operationId: operation.operationId
|
|
74
73
|
});
|
|
75
74
|
const request = operation.request ?? {};
|
|
76
|
-
const pascalCaseOperationId =
|
|
75
|
+
const pascalCaseOperationId = (0, _rexeus_typeweaver_gen.toPascalCase)(operation.operationId);
|
|
77
76
|
const headerTsType = request.header ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(request.header)) : void 0;
|
|
78
77
|
const paramTsType = request.param ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(request.param)) : void 0;
|
|
79
78
|
const queryTsType = request.query ? (0, _rexeus_typeweaver_zod_to_ts.print)((0, _rexeus_typeweaver_zod_to_ts.fromZod)(request.query)) : void 0;
|
|
@@ -108,4 +107,4 @@ var ClientsPlugin = class extends _rexeus_typeweaver_gen.BasePlugin {
|
|
|
108
107
|
}
|
|
109
108
|
};
|
|
110
109
|
//#endregion
|
|
111
|
-
|
|
110
|
+
exports.ClientsPlugin = ClientsPlugin;
|
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":";;;cAQa,aAAA,SAAsB,UAAA;EAC1B,IAAA;EACS,QAAA,CAAS,OAAA,EAAS,gBAAA,GAAmB,OAAA;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":";;;cAQa,aAAA,SAAsB,UAAA;EAC1B,IAAA;EACS,QAAA,CAAS,OAAA,EAAS,gBAAA,GAAmB,OAAA;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, toPascalCase } from "@rexeus/typeweaver-gen";
|
|
4
4
|
import { fromZod, print } from "@rexeus/typeweaver-zod-to-ts";
|
|
5
|
-
import Case from "case";
|
|
6
5
|
//#region src/clientGenerator.ts
|
|
7
6
|
const moduleDir$1 = path.dirname(fileURLToPath(import.meta.url));
|
|
8
7
|
function generate(context) {
|
|
@@ -14,7 +13,7 @@ function generate(context) {
|
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
function writeClient(templateFilePath, resource, context) {
|
|
17
|
-
const pascalCaseEntityName =
|
|
16
|
+
const pascalCaseEntityName = toPascalCase(resource.name);
|
|
18
17
|
const outputDir = context.getResourceOutputDir(resource.name);
|
|
19
18
|
const operations = resource.operations.map((operation) => {
|
|
20
19
|
const outputPaths = context.getOperationOutputPaths({
|
|
@@ -23,7 +22,7 @@ function writeClient(templateFilePath, resource, context) {
|
|
|
23
22
|
});
|
|
24
23
|
return {
|
|
25
24
|
operationId: operation.operationId,
|
|
26
|
-
pascalCaseOperationId:
|
|
25
|
+
pascalCaseOperationId: toPascalCase(operation.operationId),
|
|
27
26
|
requestFile: `./${path.basename(outputPaths.requestFileName, ".ts")}`,
|
|
28
27
|
responseValidatorFile: `./${path.basename(outputPaths.responseValidationFileName, ".ts")}`,
|
|
29
28
|
responseFile: `./${path.basename(outputPaths.responseFileName, ".ts")}`
|
|
@@ -49,7 +48,7 @@ function writeRequestCommand(templateFilePath, resourceName, operation, context)
|
|
|
49
48
|
operationId: operation.operationId
|
|
50
49
|
});
|
|
51
50
|
const request = operation.request ?? {};
|
|
52
|
-
const pascalCaseOperationId =
|
|
51
|
+
const pascalCaseOperationId = toPascalCase(operation.operationId);
|
|
53
52
|
const headerTsType = request.header ? print(fromZod(request.header)) : void 0;
|
|
54
53
|
const paramTsType = request.param ? print(fromZod(request.param)) : void 0;
|
|
55
54
|
const queryTsType = request.query ? print(fromZod(request.query)) : void 0;
|
|
@@ -84,6 +83,6 @@ var ClientsPlugin = class extends BasePlugin {
|
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
85
|
//#endregion
|
|
87
|
-
export { ClientsPlugin
|
|
86
|
+
export { ClientsPlugin };
|
|
88
87
|
|
|
89
88
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["moduleDir"],"sources":["../src/clientGenerator.ts","../src/index.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n GeneratorContext,\n NormalizedOperation,\n NormalizedResource,\n} from \"@rexeus/typeweaver-gen\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["moduleDir"],"sources":["../src/clientGenerator.ts","../src/index.ts"],"sourcesContent":["import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n GeneratorContext,\n NormalizedOperation,\n NormalizedResource,\n} from \"@rexeus/typeweaver-gen\";\nimport { toPascalCase } from \"@rexeus/typeweaver-gen\";\nimport { fromZod, print } from \"@rexeus/typeweaver-zod-to-ts\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport function generate(context: GeneratorContext): void {\n const clientTemplatePath = path.join(moduleDir, \"templates\", \"Client.ejs\");\n const commandTemplatePath = path.join(\n moduleDir,\n \"templates\",\n \"RequestCommand.ejs\"\n );\n\n for (const resource of context.normalizedSpec.resources) {\n writeClient(clientTemplatePath, resource, context);\n writeRequestCommands(commandTemplatePath, resource, context);\n }\n}\n\nfunction writeClient(\n templateFilePath: string,\n resource: NormalizedResource,\n context: GeneratorContext\n): void {\n const pascalCaseEntityName = toPascalCase(resource.name);\n const outputDir = context.getResourceOutputDir(resource.name);\n\n const operations = resource.operations.map(operation => {\n const outputPaths = context.getOperationOutputPaths({\n resourceName: resource.name,\n operationId: operation.operationId,\n });\n\n return {\n operationId: operation.operationId,\n pascalCaseOperationId: toPascalCase(operation.operationId),\n requestFile: `./${path.basename(outputPaths.requestFileName, \".ts\")}`,\n responseValidatorFile: `./${path.basename(outputPaths.responseValidationFileName, \".ts\")}`,\n responseFile: `./${path.basename(outputPaths.responseFileName, \".ts\")}`,\n };\n });\n\n const content = context.renderTemplate(templateFilePath, {\n coreDir: context.coreDir,\n pascalCaseEntityName,\n operations,\n });\n\n const outputClientFile = path.join(\n outputDir,\n `${pascalCaseEntityName}Client.ts`\n );\n const relativePath = path.relative(context.outputDir, outputClientFile);\n context.writeFile(relativePath, content);\n}\n\nfunction writeRequestCommands(\n templateFilePath: string,\n resource: NormalizedResource,\n context: GeneratorContext\n): void {\n resource.operations.forEach(operation => {\n writeRequestCommand(templateFilePath, resource.name, operation, context);\n });\n}\n\nfunction writeRequestCommand(\n templateFilePath: string,\n resourceName: string,\n operation: NormalizedOperation,\n context: GeneratorContext\n): void {\n const outputPaths = context.getOperationOutputPaths({\n resourceName,\n operationId: operation.operationId,\n });\n const request = operation.request ?? {};\n const pascalCaseOperationId = toPascalCase(operation.operationId);\n\n const headerTsType = request.header\n ? print(fromZod(request.header))\n : undefined;\n const paramTsType = request.param ? print(fromZod(request.param)) : undefined;\n const queryTsType = request.query ? print(fromZod(request.query)) : undefined;\n const bodyTsType = request.body ? print(fromZod(request.body)) : undefined;\n\n const content = context.renderTemplate(templateFilePath, {\n resourceName,\n specPath: context.getSpecImportPath({\n importerDir: outputPaths.outputDir,\n }),\n operationId: operation.operationId,\n pascalCaseOperationId,\n method: operation.method,\n headerTsType,\n paramTsType,\n queryTsType,\n bodyTsType,\n requestFile: `./${path.basename(outputPaths.requestFileName, \".ts\")}`,\n responseValidatorFile: `./${path.basename(outputPaths.responseValidationFileName, \".ts\")}`,\n responseFile: `./${path.basename(outputPaths.responseFileName, \".ts\")}`,\n });\n\n const outputCommandFile = path.join(\n outputPaths.outputDir,\n `${pascalCaseOperationId}RequestCommand.ts`\n );\n const relativePath = path.relative(context.outputDir, outputCommandFile);\n context.writeFile(relativePath, content);\n}\n","import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { BasePlugin } from \"@rexeus/typeweaver-gen\";\nimport type { GeneratorContext } from \"@rexeus/typeweaver-gen\";\nimport { generate as generateClients } from \"./clientGenerator\";\n\nconst moduleDir = path.dirname(fileURLToPath(import.meta.url));\n\nexport class ClientsPlugin extends BasePlugin {\n public name = \"clients\";\n public override generate(context: GeneratorContext): Promise<void> | void {\n // Copy lib files to lib/clients/ from dist folder\n const libDir = path.join(moduleDir, \"lib\");\n this.copyLibFiles(context, libDir, \"clients\");\n\n generateClients(context);\n }\n}\n"],"mappings":";;;;;AAUA,MAAMA,cAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,SAAgB,SAAS,SAAiC;CACxD,MAAM,qBAAqB,KAAK,KAAKA,aAAW,aAAa,aAAa;CAC1E,MAAM,sBAAsB,KAAK,KAC/BA,aACA,aACA,qBACD;AAED,MAAK,MAAM,YAAY,QAAQ,eAAe,WAAW;AACvD,cAAY,oBAAoB,UAAU,QAAQ;AAClD,uBAAqB,qBAAqB,UAAU,QAAQ;;;AAIhE,SAAS,YACP,kBACA,UACA,SACM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AAQ,QAAQ,KAAK,CAAC,GAAG,KAAA;CAEjE,MAAM,UAAU,QAAQ,eAAe,kBAAkB;EACvD;EACA,UAAU,QAAQ,kBAAkB,EAClC,aAAa,YAAY,WAC1B,CAAC;EACF,aAAa,UAAU;EACvB;EACA,QAAQ,UAAU;EAClB;EACA;EACA;EACA;EACA,aAAa,KAAK,KAAK,SAAS,YAAY,iBAAiB,MAAM;EACnE,uBAAuB,KAAK,KAAK,SAAS,YAAY,4BAA4B,MAAM;EACxF,cAAc,KAAK,KAAK,SAAS,YAAY,kBAAkB,MAAM;EACtE,CAAC;CAEF,MAAM,oBAAoB,KAAK,KAC7B,YAAY,WACZ,GAAG,sBAAsB,mBAC1B;CACD,MAAM,eAAe,KAAK,SAAS,QAAQ,WAAW,kBAAkB;AACxE,SAAQ,UAAU,cAAc,QAAQ;;;;AC7G1C,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,IAAa,gBAAb,cAAmC,WAAW;CAC5C,OAAc;CACd,SAAyB,SAAiD;EAExE,MAAM,SAAS,KAAK,KAAK,WAAW,MAAM;AAC1C,OAAK,aAAa,SAAS,QAAQ,UAAU;AAE7C,WAAgB,QAAQ"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @generated by @rexeus/typeweaver
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import spec from "<%= specPath %>";
|
|
9
|
+
import { spec } from "<%= specPath %>";
|
|
10
10
|
import { HttpMethod, type IHttpResponse, ResponseValidationError, UnknownResponseError } from "@rexeus/typeweaver-core";
|
|
11
11
|
import { RequestCommand } from "../lib/clients";
|
|
12
12
|
import { getOperationDefinition } from "../lib/types";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-clients",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Generates HTTP clients directly from your API definitions. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,19 +48,18 @@
|
|
|
48
48
|
"homepage": "https://github.com/rexeus/typeweaver#readme",
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"zod": "^4.3.0",
|
|
51
|
-
"@rexeus/typeweaver-
|
|
52
|
-
"@rexeus/typeweaver-
|
|
51
|
+
"@rexeus/typeweaver-core": "^0.10.0",
|
|
52
|
+
"@rexeus/typeweaver-gen": "^0.10.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@hono/node-server": "^1.19.11",
|
|
56
56
|
"test-utils": "file:../test-utils",
|
|
57
57
|
"zod": "^4.3.6",
|
|
58
|
-
"@rexeus/typeweaver-core": "^0.
|
|
59
|
-
"@rexeus/typeweaver-gen": "^0.
|
|
58
|
+
"@rexeus/typeweaver-core": "^0.10.0",
|
|
59
|
+
"@rexeus/typeweaver-gen": "^0.10.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"
|
|
63
|
-
"@rexeus/typeweaver-zod-to-ts": "^0.9.1"
|
|
62
|
+
"@rexeus/typeweaver-zod-to-ts": "^0.10.0"
|
|
64
63
|
},
|
|
65
64
|
"scripts": {
|
|
66
65
|
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|