sizuku 0.3.0 → 0.3.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 CHANGED
@@ -70,7 +70,7 @@ export const postRelations = relations(post, ({ one }) => ({
70
70
  }))
71
71
  ```
72
72
 
73
- Prepare sizuku.json:
73
+ Prepare sizuku.config.ts:
74
74
 
75
75
  ```ts
76
76
  import defineConfig from 'sizuku/config'
@@ -82,11 +82,13 @@ export default defineConfig({
82
82
  comment: true,
83
83
  type: true,
84
84
  zod: 'v4',
85
+ relation: true,
85
86
  },
86
87
  valibot: {
87
88
  output: 'valibot/index.ts',
88
89
  comment: true,
89
90
  type: true,
91
+ relation: true,
90
92
  },
91
93
  mermaid: {
92
94
  output: 'mermaid-er/ER.md',
@@ -1,27 +1,27 @@
1
- export type Config = Readonly<{
2
- input: `${string}.ts`;
3
- zod?: {
4
- output: `${string}.ts`;
5
- comment?: boolean;
6
- type?: boolean;
7
- zod?: 'v4' | 'mini' | '@hono/zod-openapi';
8
- relation?: boolean;
1
+ export type Config = {
2
+ readonly input: `${string}.ts`;
3
+ readonly zod?: {
4
+ readonly output: `${string}.ts`;
5
+ readonly comment?: boolean;
6
+ readonly type?: boolean;
7
+ readonly zod?: 'v4' | 'mini' | '@hono/zod-openapi';
8
+ readonly relation?: boolean;
9
9
  };
10
- valibot?: {
11
- output: `${string}.ts`;
12
- comment?: boolean;
13
- type?: boolean;
14
- relation?: boolean;
10
+ readonly valibot?: {
11
+ readonly output: `${string}.ts`;
12
+ readonly comment?: boolean;
13
+ readonly type?: boolean;
14
+ readonly relation?: boolean;
15
15
  };
16
- mermaid?: {
17
- output: string;
16
+ readonly mermaid?: {
17
+ readonly output: string;
18
18
  };
19
- }>;
19
+ };
20
20
  export declare function config(): Promise<{
21
- ok: true;
22
- value: Config;
21
+ readonly ok: true;
22
+ readonly value: Config;
23
23
  } | {
24
- ok: false;
25
- error: string;
24
+ readonly ok: false;
25
+ readonly error: string;
26
26
  }>;
27
27
  export default function defineConfig(config: Config): Config;
@@ -7,9 +7,9 @@
7
7
  * @param zod - The Zod version to use
8
8
  */
9
9
  export declare function sizukuZod(code: string[], output: `${string}.ts`, comment?: boolean, type?: boolean, zod?: 'v4' | 'mini' | '@hono/zod-openapi', relation?: boolean): Promise<{
10
- ok: true;
11
- value: undefined;
10
+ readonly ok: true;
11
+ readonly value: undefined;
12
12
  } | {
13
- ok: false;
14
- error: string;
13
+ readonly ok: false;
14
+ readonly error: string;
15
15
  }>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export declare function main(): Promise<{
2
- ok: true;
3
- value: string;
2
+ readonly ok: true;
3
+ readonly value: string;
4
4
  } | {
5
- ok: false;
6
- error: string;
5
+ readonly ok: false;
6
+ readonly error: string;
7
7
  }>;
@@ -5,11 +5,9 @@
5
5
  * @returns A `Result` containing the formatted code or an error message.
6
6
  */
7
7
  export declare function fmt(code: string): Promise<{
8
- ok: true;
9
- value: string;
10
- error?: undefined;
8
+ readonly ok: true;
9
+ readonly value: string;
11
10
  } | {
12
- ok: false;
13
- error: string;
14
- value?: undefined;
11
+ readonly ok: false;
12
+ readonly error: string;
15
13
  }>;
@@ -7,13 +7,13 @@ import { format } from 'prettier';
7
7
  */
8
8
  export async function fmt(code) {
9
9
  try {
10
- const formatted = await format(code, {
10
+ const result = await format(code, {
11
11
  parser: 'typescript',
12
12
  printWidth: 100,
13
13
  singleQuote: true,
14
14
  semi: false,
15
15
  });
16
- return { ok: true, value: formatted };
16
+ return { ok: true, value: result };
17
17
  }
18
18
  catch (e) {
19
19
  return {
@@ -1,7 +1,7 @@
1
1
  export declare function readFileSync(path: string): {
2
- ok: true;
3
- value: string;
2
+ readonly ok: true;
3
+ readonly value: string;
4
4
  } | {
5
- ok: false;
6
- error: string;
5
+ readonly ok: false;
6
+ readonly error: string;
7
7
  };
@@ -5,11 +5,11 @@
5
5
  * @returns A `Result` that is `ok` on success, otherwise an error message.
6
6
  */
7
7
  export declare function mkdir(dir: string): Promise<{
8
- ok: false;
9
- error: string;
8
+ readonly ok: false;
9
+ readonly error: string;
10
10
  } | {
11
- ok: true;
12
- value: undefined;
11
+ readonly ok: true;
12
+ readonly value: undefined;
13
13
  }>;
14
14
  /**
15
15
  * Writes UTF-8 text to a file, creating it if necessary.
@@ -48,14 +48,14 @@ export declare function removeAtSign(str: string): string;
48
48
  * @param arr - Array of strings to join.
49
49
  * @returns Joined string with spaces.
50
50
  */
51
- export declare function joinWithSpace(arr: string[]): string;
51
+ export declare function joinWithSpace(arr: readonly string[]): string;
52
52
  /**
53
53
  * Split string by newline character.
54
54
  *
55
55
  * @param str - The input string.
56
56
  * @returns Array of strings split by newline.
57
57
  */
58
- export declare function splitByNewline(str: string): string[];
58
+ export declare function splitByNewline(str: string): readonly string[];
59
59
  /**
60
60
  * Trim whitespace from string.
61
61
  *
@@ -96,14 +96,14 @@ export declare function removeOptionalSuffix(str: string): string;
96
96
  * @param str - The input string.
97
97
  * @returns Array of strings split by whitespace.
98
98
  */
99
- export declare function splitByWhitespace(str: string): string[];
99
+ export declare function splitByWhitespace(str: string): readonly string[];
100
100
  /**
101
101
  * Split string by dot character.
102
102
  *
103
103
  * @param str - The input string.
104
104
  * @returns Array of strings split by dot.
105
105
  */
106
- export declare function splitByDot(str: string): string[];
106
+ export declare function splitByDot(str: string): readonly string[];
107
107
  /**
108
108
  * Parse field comments and extract definition line and description.
109
109
  *
@@ -135,10 +135,10 @@ export declare function inferInput(name: string): string;
135
135
  * @returns
136
136
  */
137
137
  export declare function fieldDefinitions(schema: {
138
- name: string;
139
- fields: {
140
- name: string;
141
- definition: string;
142
- description?: string;
138
+ readonly name: string;
139
+ readonly fields: {
140
+ readonly name: string;
141
+ readonly definition: string;
142
+ readonly description?: string;
143
143
  }[];
144
144
  }, comment: boolean): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sizuku",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "description": "Sizuku is a tool that generates validation schemas for Zod and Valibot, as well as ER diagrams, from Drizzle schemas annotated with comments.",
6
6
  "license": "MIT",
7
7
  "keywords": [