@seam-rpc/server 4.3.3 → 4.3.4

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.
@@ -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, printNode } from "zod-to-ts";
5
+ import { zodToTs, createAuxiliaryTypeStore } from "zod-to-ts";
6
6
  import { existsSync, writeFileSync } from "fs";
7
7
  export async function generateClient() {
8
8
  const config = loadConfig();
@@ -111,10 +111,23 @@ function getFullComment(node, sourceText) {
111
111
  }
112
112
  return "";
113
113
  }
114
+ // function convert(schema: z.ZodType): string {
115
+ // const store = createAuxiliaryTypeStore();
116
+ // const { node } = zodToTs(schema, { auxiliaryTypeStore: store });
117
+ // return printNode(node);
118
+ // }
114
119
  function convert(schema) {
115
120
  const store = createAuxiliaryTypeStore();
116
- const { node } = zodToTs(schema, { auxiliaryTypeStore: store });
117
- return printNode(node);
121
+ const { node } = zodToTs(schema, {
122
+ auxiliaryTypeStore: store,
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
131
  }
119
132
  export async function generateClientFile({ tsPath, jsPath, outputPath, }) {
120
133
  const tsFile = path.resolve(process.cwd(), tsPath);
package/dist/test.js CHANGED
@@ -1,4 +1,4 @@
1
- import { zodToTs, createAuxiliaryTypeStore } from "zod-to-ts";
1
+ import { zodToTs, createAuxiliaryTypeStore, printNode } from "zod-to-ts";
2
2
  import * as z from "zod";
3
3
  import ts from "typescript";
4
4
  export function convert(schema) {
@@ -14,25 +14,43 @@ export function convert(schema) {
14
14
  });
15
15
  return printer.printNode(ts.EmitHint.Unspecified, typeAlias, file);
16
16
  }
17
- console.log(convert(z.object({
18
- test: z.object({
19
- a: z.string(),
20
- b: z.string(),
21
- c: z.string(),
22
- d: z.string(),
23
- e: z.string(),
24
- f: z.string(),
25
- ga: z.string(),
26
- wea: z.string(),
27
- waa: z.string(),
28
- wga: z.string(),
29
- weega: z.string(),
30
- wwa: z.string(),
31
- af: z.string(),
32
- wha: z.string(),
33
- ag: z.string(),
34
- wwea: z.string(),
35
- we3a: z.string(),
36
- wada: z.string(),
17
+ function convert2(schema) {
18
+ const store = createAuxiliaryTypeStore();
19
+ const { node } = zodToTs(schema, { auxiliaryTypeStore: store });
20
+ return printNode(node);
21
+ }
22
+ console.log(convert2(z.object({
23
+ user: z.object({
24
+ email: z.string(),
25
+ id: z.string(),
26
+ createdAt: z.date(),
27
+ firstName: z.string(),
28
+ lastName: z.string(),
29
+ trackingStartDate: z.string(),
30
+ trackingWorkItemId: z.string(),
31
+ }),
32
+ roles: z.object({
33
+ id: z.string(),
34
+ name: z.string(),
35
+ createdAt: z.date(),
36
+ permissions: z.number().array(),
37
+ projectId: z.string(),
38
+ }),
39
+ workItems: z.object({
40
+ id: z.string(),
41
+ createdAt: z.date(),
42
+ date: z.date(),
43
+ link: z.string(),
44
+ title: z.string(),
45
+ description: z.string(),
46
+ projectId: z.string(),
47
+ authorId: z.string(),
48
+ durationMethod: z.string(),
49
+ startTime: z.number(),
50
+ endTime: z.number(),
51
+ duration: z.number(),
52
+ labels: z.string(),
53
+ updatedAt: z.string(),
54
+ projectMemberId: z.string(),
37
55
  })
38
56
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seam-rpc/server",
3
- "version": "4.3.3",
3
+ "version": "4.3.4",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {