@seam-rpc/server 4.3.4 → 4.3.6
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/bin/generate.js +6 -17
- package/package.json +1 -1
package/dist/bin/generate.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fg from "fast-glob";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
-
import { zodToTs, createAuxiliaryTypeStore } from "zod-to-ts";
|
|
5
|
+
import { zodToTs, createAuxiliaryTypeStore, printNode } from "zod-to-ts";
|
|
6
6
|
import { existsSync, writeFileSync } from "fs";
|
|
7
7
|
export async function generateClient() {
|
|
8
8
|
const config = loadConfig();
|
|
@@ -66,7 +66,9 @@ export function getProcedureMetadata(filePath) {
|
|
|
66
66
|
if (!signature)
|
|
67
67
|
return;
|
|
68
68
|
const returnType = checker.getReturnTypeOfSignature(signature);
|
|
69
|
-
return checker.typeToString(returnType
|
|
69
|
+
return checker.typeToString(returnType, undefined, ts.TypeFormatFlags.NoTruncation |
|
|
70
|
+
ts.TypeFormatFlags.WriteArrayAsGenericType |
|
|
71
|
+
ts.TypeFormatFlags.UseFullyQualifiedType);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
current = prop.expression;
|
|
@@ -111,23 +113,10 @@ function getFullComment(node, sourceText) {
|
|
|
111
113
|
}
|
|
112
114
|
return "";
|
|
113
115
|
}
|
|
114
|
-
// function convert(schema: z.ZodType): string {
|
|
115
|
-
// const store = createAuxiliaryTypeStore();
|
|
116
|
-
// const { node } = zodToTs(schema, { auxiliaryTypeStore: store });
|
|
117
|
-
// return printNode(node);
|
|
118
|
-
// }
|
|
119
116
|
function convert(schema) {
|
|
120
117
|
const store = createAuxiliaryTypeStore();
|
|
121
|
-
const { node } = zodToTs(schema, {
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
const typeAlias = ts.factory.createTypeAliasDeclaration([ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createIdentifier("GeneratedType"), undefined, node);
|
|
125
|
-
const file = ts.createSourceFile("types.ts", "", ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
|
|
126
|
-
const printer = ts.createPrinter({
|
|
127
|
-
newLine: ts.NewLineKind.LineFeed,
|
|
128
|
-
removeComments: false,
|
|
129
|
-
});
|
|
130
|
-
return printer.printNode(ts.EmitHint.Unspecified, typeAlias, file);
|
|
118
|
+
const { node } = zodToTs(schema, { auxiliaryTypeStore: store });
|
|
119
|
+
return printNode(node);
|
|
131
120
|
}
|
|
132
121
|
export async function generateClientFile({ tsPath, jsPath, outputPath, }) {
|
|
133
122
|
const tsFile = path.resolve(process.cwd(), tsPath);
|