@rexeus/typeweaver 0.6.0 → 0.6.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/README.md +10 -35
- package/bin/typeweaver.mjs +18 -0
- package/dist/{cli-Cs-6XYwL.mjs → cli-gJQliCVf.mjs} +30 -30
- package/dist/cli.cjs +30 -30
- package/dist/cli.mjs +30 -30
- package/dist/cli.mjs.map +1 -1
- package/dist/entry.mjs +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -213,11 +213,7 @@ export const userSchema = z.object({
|
|
|
213
213
|
|
|
214
214
|
```typescript
|
|
215
215
|
// api/definition/user/GetUserDefinition.ts
|
|
216
|
-
import {
|
|
217
|
-
HttpOperationDefinition,
|
|
218
|
-
HttpMethod,
|
|
219
|
-
HttpStatusCode,
|
|
220
|
-
} from "@rexeus/typeweaver-core";
|
|
216
|
+
import { HttpOperationDefinition, HttpMethod, HttpStatusCode } from "@rexeus/typeweaver-core";
|
|
221
217
|
import { z } from "zod";
|
|
222
218
|
import { sharedResponses } from "../shared/sharedResponses";
|
|
223
219
|
import { userSchema } from "./userSchema";
|
|
@@ -253,11 +249,7 @@ export default new HttpOperationDefinition({
|
|
|
253
249
|
|
|
254
250
|
```typescript
|
|
255
251
|
// api/definition/user/UpdateUserDefinition.ts
|
|
256
|
-
import {
|
|
257
|
-
HttpOperationDefinition,
|
|
258
|
-
HttpMethod,
|
|
259
|
-
HttpStatusCode,
|
|
260
|
-
} from "@rexeus/typeweaver-core";
|
|
252
|
+
import { HttpOperationDefinition, HttpMethod, HttpStatusCode } from "@rexeus/typeweaver-core";
|
|
261
253
|
import { z } from "zod";
|
|
262
254
|
import { sharedResponses } from "../shared/sharedResponses";
|
|
263
255
|
import { userSchema } from "./userSchema";
|
|
@@ -320,10 +312,7 @@ export default NotFoundErrorDefinition.extend({
|
|
|
320
312
|
|
|
321
313
|
```typescript
|
|
322
314
|
// api/definition/user/errors/UserStatusTransitionInvalidErrorDefinition.ts
|
|
323
|
-
import {
|
|
324
|
-
HttpResponseDefinition,
|
|
325
|
-
HttpStatusCode,
|
|
326
|
-
} from "@rexeus/typeweaver-core";
|
|
315
|
+
import { HttpResponseDefinition, HttpStatusCode } from "@rexeus/typeweaver-core";
|
|
327
316
|
import { z } from "zod";
|
|
328
317
|
import { userStatusSchema } from "../userSchema";
|
|
329
318
|
|
|
@@ -335,9 +324,7 @@ export default new HttpResponseDefinition({
|
|
|
335
324
|
name: "UserStatusTransitionInvalidError",
|
|
336
325
|
description: "User status transition is conflicting with current status",
|
|
337
326
|
body: z.object({
|
|
338
|
-
message: z.literal(
|
|
339
|
-
"User status transition is conflicting with current status",
|
|
340
|
-
),
|
|
327
|
+
message: z.literal("User status transition is conflicting with current status"),
|
|
341
328
|
code: z.literal("USER_STATUS_TRANSITION_INVALID_ERROR"),
|
|
342
329
|
context: z.object({
|
|
343
330
|
userId: z.uuid(),
|
|
@@ -404,9 +391,7 @@ import {
|
|
|
404
391
|
export class UserHandlers implements HonoUserApiHandler {
|
|
405
392
|
public constructor() {}
|
|
406
393
|
|
|
407
|
-
public async handleGetUserRequest(
|
|
408
|
-
request: IGetUserRequest,
|
|
409
|
-
): Promise<GetUserResponse> {
|
|
394
|
+
public async handleGetUserRequest(request: IGetUserRequest): Promise<GetUserResponse> {
|
|
410
395
|
// Simulate fetching user data
|
|
411
396
|
const fetchedUser = {
|
|
412
397
|
id: request.param.userId,
|
|
@@ -426,21 +411,15 @@ export class UserHandlers implements HonoUserApiHandler {
|
|
|
426
411
|
});
|
|
427
412
|
}
|
|
428
413
|
|
|
429
|
-
public handleCreateUserRequest(
|
|
430
|
-
request: ICreateUserRequest,
|
|
431
|
-
): Promise<CreateUserResponse> {
|
|
414
|
+
public handleCreateUserRequest(request: ICreateUserRequest): Promise<CreateUserResponse> {
|
|
432
415
|
throw new Error("Not implemented");
|
|
433
416
|
}
|
|
434
417
|
|
|
435
|
-
public handleUpdateUserRequest(
|
|
436
|
-
request: IUpdateUserRequest,
|
|
437
|
-
): Promise<UpdateUserResponse> {
|
|
418
|
+
public handleUpdateUserRequest(request: IUpdateUserRequest): Promise<UpdateUserResponse> {
|
|
438
419
|
throw new Error("Not implemented");
|
|
439
420
|
}
|
|
440
421
|
|
|
441
|
-
public handleListUserRequest(
|
|
442
|
-
request: IListUserRequest,
|
|
443
|
-
): Promise<ListUserResponse> {
|
|
422
|
+
public handleListUserRequest(request: IListUserRequest): Promise<ListUserResponse> {
|
|
444
423
|
throw new Error("Not implemented");
|
|
445
424
|
}
|
|
446
425
|
}
|
|
@@ -480,7 +459,7 @@ serve(
|
|
|
480
459
|
},
|
|
481
460
|
() => {
|
|
482
461
|
console.log("Server is running on http://localhost:3000");
|
|
483
|
-
}
|
|
462
|
+
}
|
|
484
463
|
);
|
|
485
464
|
```
|
|
486
465
|
|
|
@@ -493,11 +472,7 @@ tsx api/server.ts
|
|
|
493
472
|
|
|
494
473
|
```typescript
|
|
495
474
|
// api/client-test.ts
|
|
496
|
-
import {
|
|
497
|
-
UserClient,
|
|
498
|
-
GetUserRequestCommand,
|
|
499
|
-
UserNotFoundErrorResponse,
|
|
500
|
-
} from "./generated";
|
|
475
|
+
import { UserClient, GetUserRequestCommand, UserNotFoundErrorResponse } from "./generated";
|
|
501
476
|
|
|
502
477
|
const client = new UserClient({ baseUrl: "http://localhost:3000" });
|
|
503
478
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const entry = resolve(__dirname, "../dist/entry.mjs");
|
|
9
|
+
|
|
10
|
+
if (!existsSync(entry)) {
|
|
11
|
+
console.error(
|
|
12
|
+
"TypeWeaver CLI has not been built yet.\n" +
|
|
13
|
+
"Run 'pnpm build' in the project root first."
|
|
14
|
+
);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await import(entry);
|
|
@@ -8,6 +8,36 @@ import TypesPlugin from "@rexeus/typeweaver-types";
|
|
|
8
8
|
import { render } from "ejs";
|
|
9
9
|
import { HttpMethod, HttpOperationDefinition, HttpResponseDefinition, HttpStatusCode, HttpStatusCodeNameMap } from "@rexeus/typeweaver-core";
|
|
10
10
|
|
|
11
|
+
//#region src/generators/Formatter.ts
|
|
12
|
+
var Formatter = class {
|
|
13
|
+
constructor(outputDir) {
|
|
14
|
+
this.outputDir = outputDir;
|
|
15
|
+
}
|
|
16
|
+
async formatCode(startDir) {
|
|
17
|
+
const format = await this.loadFormatter();
|
|
18
|
+
if (!format) return;
|
|
19
|
+
const targetDir = startDir ?? this.outputDir;
|
|
20
|
+
await this.formatDirectory(targetDir, format);
|
|
21
|
+
}
|
|
22
|
+
async loadFormatter() {
|
|
23
|
+
try {
|
|
24
|
+
return (await import("oxfmt")).format;
|
|
25
|
+
} catch {
|
|
26
|
+
console.warn("oxfmt not installed - skipping formatting. Install with: npm install -D oxfmt");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async formatDirectory(targetDir, format) {
|
|
31
|
+
const contents = fs.readdirSync(targetDir, { withFileTypes: true });
|
|
32
|
+
for (const content of contents) if (content.isFile()) {
|
|
33
|
+
const filePath = path.join(targetDir, content.name);
|
|
34
|
+
const { code } = await format(filePath, fs.readFileSync(filePath, "utf8"));
|
|
35
|
+
fs.writeFileSync(filePath, code);
|
|
36
|
+
} else if (content.isDirectory()) await this.formatDirectory(path.join(targetDir, content.name), format);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
11
41
|
//#region src/generators/IndexFileGenerator.ts
|
|
12
42
|
var IndexFileGenerator = class {
|
|
13
43
|
constructor(templateDir) {
|
|
@@ -122,36 +152,6 @@ var PluginLoader = class {
|
|
|
122
152
|
}
|
|
123
153
|
};
|
|
124
154
|
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/generators/Formatter.ts
|
|
127
|
-
var Formatter = class {
|
|
128
|
-
constructor(outputDir) {
|
|
129
|
-
this.outputDir = outputDir;
|
|
130
|
-
}
|
|
131
|
-
async formatCode(startDir) {
|
|
132
|
-
const format = await this.loadFormatter();
|
|
133
|
-
if (!format) return;
|
|
134
|
-
const targetDir = startDir ?? this.outputDir;
|
|
135
|
-
await this.formatDirectory(targetDir, format);
|
|
136
|
-
}
|
|
137
|
-
async loadFormatter() {
|
|
138
|
-
try {
|
|
139
|
-
return (await import("oxfmt")).format;
|
|
140
|
-
} catch {
|
|
141
|
-
console.warn("oxfmt not installed - skipping formatting. Install with: npm install -D oxfmt");
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async formatDirectory(targetDir, format) {
|
|
146
|
-
const contents = fs.readdirSync(targetDir, { withFileTypes: true });
|
|
147
|
-
for (const content of contents) if (content.isFile()) {
|
|
148
|
-
const filePath = path.join(targetDir, content.name);
|
|
149
|
-
const { code } = await format(filePath, fs.readFileSync(filePath, "utf8"));
|
|
150
|
-
fs.writeFileSync(filePath, code);
|
|
151
|
-
} else if (content.isDirectory()) await this.formatDirectory(path.join(targetDir, content.name), format);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
155
|
//#endregion
|
|
156
156
|
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
157
157
|
/** A special constant with type `never` */
|
package/dist/cli.cjs
CHANGED
|
@@ -37,6 +37,36 @@ _rexeus_typeweaver_types = __toESM(_rexeus_typeweaver_types);
|
|
|
37
37
|
let ejs = require("ejs");
|
|
38
38
|
let _rexeus_typeweaver_core = require("@rexeus/typeweaver-core");
|
|
39
39
|
|
|
40
|
+
//#region src/generators/Formatter.ts
|
|
41
|
+
var Formatter = class {
|
|
42
|
+
constructor(outputDir) {
|
|
43
|
+
this.outputDir = outputDir;
|
|
44
|
+
}
|
|
45
|
+
async formatCode(startDir) {
|
|
46
|
+
const format = await this.loadFormatter();
|
|
47
|
+
if (!format) return;
|
|
48
|
+
const targetDir = startDir ?? this.outputDir;
|
|
49
|
+
await this.formatDirectory(targetDir, format);
|
|
50
|
+
}
|
|
51
|
+
async loadFormatter() {
|
|
52
|
+
try {
|
|
53
|
+
return (await import("oxfmt")).format;
|
|
54
|
+
} catch {
|
|
55
|
+
console.warn("oxfmt not installed - skipping formatting. Install with: npm install -D oxfmt");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async formatDirectory(targetDir, format) {
|
|
60
|
+
const contents = node_fs.default.readdirSync(targetDir, { withFileTypes: true });
|
|
61
|
+
for (const content of contents) if (content.isFile()) {
|
|
62
|
+
const filePath = node_path.default.join(targetDir, content.name);
|
|
63
|
+
const { code } = await format(filePath, node_fs.default.readFileSync(filePath, "utf8"));
|
|
64
|
+
node_fs.default.writeFileSync(filePath, code);
|
|
65
|
+
} else if (content.isDirectory()) await this.formatDirectory(node_path.default.join(targetDir, content.name), format);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
40
70
|
//#region src/generators/IndexFileGenerator.ts
|
|
41
71
|
var IndexFileGenerator = class {
|
|
42
72
|
constructor(templateDir) {
|
|
@@ -151,36 +181,6 @@ var PluginLoader = class {
|
|
|
151
181
|
}
|
|
152
182
|
};
|
|
153
183
|
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/generators/Formatter.ts
|
|
156
|
-
var Formatter = class {
|
|
157
|
-
constructor(outputDir) {
|
|
158
|
-
this.outputDir = outputDir;
|
|
159
|
-
}
|
|
160
|
-
async formatCode(startDir) {
|
|
161
|
-
const format = await this.loadFormatter();
|
|
162
|
-
if (!format) return;
|
|
163
|
-
const targetDir = startDir ?? this.outputDir;
|
|
164
|
-
await this.formatDirectory(targetDir, format);
|
|
165
|
-
}
|
|
166
|
-
async loadFormatter() {
|
|
167
|
-
try {
|
|
168
|
-
return (await import("oxfmt")).format;
|
|
169
|
-
} catch {
|
|
170
|
-
console.warn("oxfmt not installed - skipping formatting. Install with: npm install -D oxfmt");
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
async formatDirectory(targetDir, format) {
|
|
175
|
-
const contents = node_fs.default.readdirSync(targetDir, { withFileTypes: true });
|
|
176
|
-
for (const content of contents) if (content.isFile()) {
|
|
177
|
-
const filePath = node_path.default.join(targetDir, content.name);
|
|
178
|
-
const { code } = await format(filePath, node_fs.default.readFileSync(filePath, "utf8"));
|
|
179
|
-
node_fs.default.writeFileSync(filePath, code);
|
|
180
|
-
} else if (content.isDirectory()) await this.formatDirectory(node_path.default.join(targetDir, content.name), format);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
184
|
//#endregion
|
|
185
185
|
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
186
186
|
/** A special constant with type `never` */
|
package/dist/cli.mjs
CHANGED
|
@@ -7,6 +7,36 @@ import TypesPlugin from "@rexeus/typeweaver-types";
|
|
|
7
7
|
import { render } from "ejs";
|
|
8
8
|
import { HttpMethod, HttpOperationDefinition, HttpResponseDefinition, HttpStatusCode, HttpStatusCodeNameMap } from "@rexeus/typeweaver-core";
|
|
9
9
|
|
|
10
|
+
//#region src/generators/Formatter.ts
|
|
11
|
+
var Formatter = class {
|
|
12
|
+
constructor(outputDir) {
|
|
13
|
+
this.outputDir = outputDir;
|
|
14
|
+
}
|
|
15
|
+
async formatCode(startDir) {
|
|
16
|
+
const format = await this.loadFormatter();
|
|
17
|
+
if (!format) return;
|
|
18
|
+
const targetDir = startDir ?? this.outputDir;
|
|
19
|
+
await this.formatDirectory(targetDir, format);
|
|
20
|
+
}
|
|
21
|
+
async loadFormatter() {
|
|
22
|
+
try {
|
|
23
|
+
return (await import("oxfmt")).format;
|
|
24
|
+
} catch {
|
|
25
|
+
console.warn("oxfmt not installed - skipping formatting. Install with: npm install -D oxfmt");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async formatDirectory(targetDir, format) {
|
|
30
|
+
const contents = fs.readdirSync(targetDir, { withFileTypes: true });
|
|
31
|
+
for (const content of contents) if (content.isFile()) {
|
|
32
|
+
const filePath = path.join(targetDir, content.name);
|
|
33
|
+
const { code } = await format(filePath, fs.readFileSync(filePath, "utf8"));
|
|
34
|
+
fs.writeFileSync(filePath, code);
|
|
35
|
+
} else if (content.isDirectory()) await this.formatDirectory(path.join(targetDir, content.name), format);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
10
40
|
//#region src/generators/IndexFileGenerator.ts
|
|
11
41
|
var IndexFileGenerator = class {
|
|
12
42
|
constructor(templateDir) {
|
|
@@ -121,36 +151,6 @@ var PluginLoader = class {
|
|
|
121
151
|
}
|
|
122
152
|
};
|
|
123
153
|
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/generators/Formatter.ts
|
|
126
|
-
var Formatter = class {
|
|
127
|
-
constructor(outputDir) {
|
|
128
|
-
this.outputDir = outputDir;
|
|
129
|
-
}
|
|
130
|
-
async formatCode(startDir) {
|
|
131
|
-
const format = await this.loadFormatter();
|
|
132
|
-
if (!format) return;
|
|
133
|
-
const targetDir = startDir ?? this.outputDir;
|
|
134
|
-
await this.formatDirectory(targetDir, format);
|
|
135
|
-
}
|
|
136
|
-
async loadFormatter() {
|
|
137
|
-
try {
|
|
138
|
-
return (await import("oxfmt")).format;
|
|
139
|
-
} catch {
|
|
140
|
-
console.warn("oxfmt not installed - skipping formatting. Install with: npm install -D oxfmt");
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async formatDirectory(targetDir, format) {
|
|
145
|
-
const contents = fs.readdirSync(targetDir, { withFileTypes: true });
|
|
146
|
-
for (const content of contents) if (content.isFile()) {
|
|
147
|
-
const filePath = path.join(targetDir, content.name);
|
|
148
|
-
const { code } = await format(filePath, fs.readFileSync(filePath, "utf8"));
|
|
149
|
-
fs.writeFileSync(filePath, code);
|
|
150
|
-
} else if (content.isDirectory()) await this.formatDirectory(path.join(targetDir, content.name), format);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
154
|
//#endregion
|
|
155
155
|
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
156
156
|
/** A special constant with type `never` */
|