sizuku 0.0.4 → 0.0.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/README.md +3 -3
- package/dist/common/config/index.d.ts +12 -12
- package/dist/common/format/index.d.ts +1 -1
- package/dist/common/generator/generate-field-definitions.d.ts +3 -3
- package/dist/common/helper/get-camel-case-schema-name-helper.d.ts +1 -1
- package/dist/common/helper/get-pascal-case-schema-name-helper.d.ts +1 -1
- package/dist/common/helper/get-variable-name-helper.d.ts +2 -2
- package/dist/common/helper/get-variable-schema-name-helper.d.ts +2 -2
- package/dist/common/text/capitalize.d.ts +1 -1
- package/dist/common/text/decapitalize.d.ts +1 -1
- package/dist/common/type/index.d.ts +7 -7
- package/dist/generator/mermaid-er/config/index.d.ts +4 -4
- package/dist/generator/mermaid-er/core/extract-relations.d.ts +2 -2
- package/dist/generator/mermaid-er/generator/generate-er-content.d.ts +2 -2
- package/dist/generator/mermaid-er/generator/generate-relation-line.d.ts +2 -2
- package/dist/generator/mermaid-er/generator/generate-relation-line.js +2 -2
- package/dist/generator/mermaid-er/index.d.ts +4 -6
- package/dist/generator/mermaid-er/index.js +1 -26
- package/dist/generator/mermaid-er/relationship/build-relation-line.d.ts +14 -0
- package/dist/generator/mermaid-er/relationship/build-relation-line.js +37 -0
- package/dist/generator/mermaid-er/type/index.d.ts +18 -37
- package/dist/generator/mermaid-er/validator/is-relationship.d.ts +7 -0
- package/dist/generator/mermaid-er/validator/is-relationship.js +11 -0
- package/dist/generator/mermaid-er/validator/parse-relation-line.d.ts +6 -6
- package/dist/generator/mermaid-er/validator/parse-relation-line.js +0 -5
- package/dist/generator/mermaid-er/validator/parse-table-info.d.ts +2 -2
- package/dist/generator/mermaid-er/validator/remove-duplicate-relations.d.ts +1 -1
- package/dist/generator/valibot/config/index.d.ts +2 -2
- package/dist/generator/valibot/core/extract-schema.d.ts +2 -2
- package/dist/generator/valibot/generator/generate-valibot-code.d.ts +3 -3
- package/dist/generator/valibot/generator/generate-valibot-infer-input.d.ts +3 -3
- package/dist/generator/valibot/generator/generate-valibot-schema.d.ts +3 -3
- package/dist/generator/valibot/index.d.ts +2 -2
- package/dist/generator/zod/config/index.d.ts +2 -2
- package/dist/generator/zod/core/extract-schema.d.ts +2 -2
- package/dist/generator/zod/generator/generate-z-infer.d.ts +3 -3
- package/dist/generator/zod/generator/generate-zod-code.d.ts +3 -3
- package/dist/generator/zod/generator/generate-zod-schema.d.ts +3 -3
- package/dist/generator/zod/index.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -290,9 +290,9 @@ output:
|
|
|
290
290
|
|
|
291
291
|
```mermaid
|
|
292
292
|
erDiagram
|
|
293
|
-
user
|
|
294
|
-
post
|
|
295
|
-
user
|
|
293
|
+
user ||--|{ post : "(id) - (userId)"
|
|
294
|
+
post ||--|{ likes : "(id) - (postId)"
|
|
295
|
+
user ||--|{ likes : "(id) - (userId)"
|
|
296
296
|
user {
|
|
297
297
|
varchar id "(PK) Unique identifier for the user."
|
|
298
298
|
varchar username "Username of the user."
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export type Config = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export declare const DEFAULT_CONFIG: Config
|
|
2
|
+
schema: {
|
|
3
|
+
name: 'PascalCase' | 'camelCase';
|
|
4
|
+
};
|
|
5
|
+
type: {
|
|
6
|
+
name: 'PascalCase' | 'camelCase';
|
|
7
|
+
export: boolean;
|
|
8
|
+
};
|
|
9
|
+
input?: string;
|
|
10
|
+
output?: string;
|
|
11
|
+
comment?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const DEFAULT_CONFIG: Config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function formatCode(code: string): Promise<string
|
|
1
|
+
export declare function formatCode(code: string): Promise<string>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Schema } from '../type'
|
|
2
|
-
import type { Config } from '../config'
|
|
1
|
+
import type { Schema } from '../type';
|
|
2
|
+
import type { Config } from '../config';
|
|
3
3
|
/**
|
|
4
4
|
* @function generateFieldDefinitions
|
|
5
5
|
* @param schema
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare function generateFieldDefinitions(schema: Schema, config: Config): string
|
|
8
|
+
export declare function generateFieldDefinitions(schema: Schema, config: Config): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config } from '../config'
|
|
1
|
+
import type { Config } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Get the variable name helper
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@ import type { Config } from '../config'
|
|
|
6
6
|
* @param config - The config
|
|
7
7
|
* @returns The variable name helper
|
|
8
8
|
*/
|
|
9
|
-
export declare function getVariableNameHelper(name: string, config: Config): string
|
|
9
|
+
export declare function getVariableNameHelper(name: string, config: Config): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config } from '../config'
|
|
1
|
+
import type { Config } from '../config';
|
|
2
2
|
/**
|
|
3
3
|
* Get the variable schema name helper
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@ import type { Config } from '../config'
|
|
|
6
6
|
* @param config - The config
|
|
7
7
|
* @returns The variable schema name helper
|
|
8
8
|
*/
|
|
9
|
-
export declare function getVariableSchemaNameHelper(name: string, config: Config): string
|
|
9
|
+
export declare function getVariableSchemaNameHelper(name: string, config: Config): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type SchemaField = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
name: string;
|
|
3
|
+
definition: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
};
|
|
6
6
|
export type Schema = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
7
|
+
name: string;
|
|
8
|
+
fields: SchemaField[];
|
|
9
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type Config = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
input?: string;
|
|
3
|
+
output?: string;
|
|
4
|
+
};
|
|
5
5
|
/**
|
|
6
6
|
* Loads the configuration from the `sizuku.json` file or returns the default configuration.
|
|
7
7
|
*
|
|
8
8
|
* @returns The configuration object.
|
|
9
9
|
*/
|
|
10
|
-
export declare function getConfig(): Config
|
|
10
|
+
export declare function getConfig(): Config;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Relation } from '../type'
|
|
1
|
+
import type { Relation } from '../type';
|
|
2
2
|
/**
|
|
3
3
|
* Extracts relations from the given code.
|
|
4
4
|
*
|
|
5
5
|
* @param code - The code to extract relations from.
|
|
6
6
|
* @returns The extracted relations.
|
|
7
7
|
*/
|
|
8
|
-
export declare function extractRelations(code: string[]): Relation[]
|
|
8
|
+
export declare function extractRelations(code: string[]): Relation[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Relation, TableInfo } from '../type'
|
|
1
|
+
import type { Relation, TableInfo } from '../type';
|
|
2
2
|
/**
|
|
3
3
|
* Generate ER content
|
|
4
4
|
* @function generateERContent
|
|
@@ -6,4 +6,4 @@ import type { Relation, TableInfo } from '../type'
|
|
|
6
6
|
* @param tables - The tables to generate the ER content from
|
|
7
7
|
* @returns The generated ER content
|
|
8
8
|
*/
|
|
9
|
-
export declare function generateERContent(relations: Relation[], tables: TableInfo[]): string
|
|
9
|
+
export declare function generateERContent(relations: Relation[], tables: TableInfo[]): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Relation } from '../type'
|
|
1
|
+
import type { Relation } from '../type';
|
|
2
2
|
/**
|
|
3
3
|
* Generate a relation line for a relation
|
|
4
4
|
* @param relation - The relation to generate a line for
|
|
5
5
|
* @returns The generated relation line
|
|
6
6
|
*/
|
|
7
|
-
export declare function generateRelationLine(relation: Relation): string
|
|
7
|
+
export declare function generateRelationLine(relation: Relation): string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateRelationLine = generateRelationLine;
|
|
4
|
-
const
|
|
4
|
+
const build_relation_line_1 = require("../relationship/build-relation-line");
|
|
5
5
|
/**
|
|
6
6
|
* Generate a relation line for a relation
|
|
7
7
|
* @param relation - The relation to generate a line for
|
|
8
8
|
* @returns The generated relation line
|
|
9
9
|
*/
|
|
10
10
|
function generateRelationLine(relation) {
|
|
11
|
-
const cardinality =
|
|
11
|
+
const cardinality = (0, build_relation_line_1.buildRelationLine)(relation.type);
|
|
12
12
|
if (!cardinality) {
|
|
13
13
|
throw new Error(`Unknown relation type: ${relation.type}`);
|
|
14
14
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import type { Config } from './config'
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare
|
|
6
|
-
export declare const ER_FOOTER: readonly ['```']
|
|
7
|
-
export declare function main(dev?: boolean, config?: Config): Promise<boolean>
|
|
2
|
+
import type { Config } from './config';
|
|
3
|
+
export declare const ER_HEADER: readonly ["```mermaid", "erDiagram"];
|
|
4
|
+
export declare const ER_FOOTER: readonly ["```"];
|
|
5
|
+
export declare function main(dev?: boolean, config?: Config): Promise<boolean>;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ER_FOOTER = exports.ER_HEADER =
|
|
7
|
+
exports.ER_FOOTER = exports.ER_HEADER = void 0;
|
|
8
8
|
exports.main = main;
|
|
9
9
|
const node_fs_1 = require("node:fs");
|
|
10
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -13,37 +13,12 @@ const parse_table_info_1 = require("./validator/parse-table-info");
|
|
|
13
13
|
const extract_relations_1 = require("./core/extract-relations");
|
|
14
14
|
const config_1 = require("./config");
|
|
15
15
|
const node_process_1 = require("node:process");
|
|
16
|
-
exports.CARDINALITY_MAP = {
|
|
17
|
-
// both required
|
|
18
|
-
'one-to-one': '||--||', // 1--1
|
|
19
|
-
'one-to-many': '||--o{', // 1--*
|
|
20
|
-
'many-to-one': '}o--||', // *--1
|
|
21
|
-
'many-to-many': '}o--o{', // *--*
|
|
22
|
-
// one side optional
|
|
23
|
-
'one-to-zero-one': '||--o|', // 1--0..1
|
|
24
|
-
'zero-one-to-one': 'o|--||', // 0..1--1
|
|
25
|
-
'zero-to-many': 'o|--o{', // 0--*
|
|
26
|
-
'many-to-zero-one': '}o--o|', // *--0..1
|
|
27
|
-
'zero-one-to-many': 'o|--o{', // 0..1--*
|
|
28
|
-
// o o
|
|
29
|
-
'zero-to-one': 'o|--o|', // 0--0..1
|
|
30
|
-
'zero-to-zero-one': 'o|--o|', // 0--0..1
|
|
31
|
-
// ..
|
|
32
|
-
'one-to-many-optional': '||..o{', // 1..*
|
|
33
|
-
'one-to-one-optional': '||..||', // 1..1
|
|
34
|
-
'many-to-many-optional': '}o..o{', // *..*
|
|
35
|
-
'zero-one-to-zero-one': 'o|..o|', // 0..1--0..1
|
|
36
|
-
'many-to-zero-many': '}o..o{', // *--0..*
|
|
37
|
-
'zero-many-to-many': 'o{..}o', // 0..*--*
|
|
38
|
-
'zero-many-to-zero-many': 'o{..o{', // 0..*--0..*
|
|
39
|
-
};
|
|
40
16
|
// ER diagram header
|
|
41
17
|
exports.ER_HEADER = ['```mermaid', 'erDiagram'];
|
|
42
18
|
// ER diagram footer
|
|
43
19
|
exports.ER_FOOTER = ['```'];
|
|
44
20
|
async function main(dev = false, config = (0, config_1.getConfig)()) {
|
|
45
21
|
// 1. argv ['**/bin/node', '**/dist/src/generator/mermaid-er/index.js', 'db/schema.ts', '-o', 'mermaid-er/ER.md']
|
|
46
|
-
console.log(config.output);
|
|
47
22
|
if (config.output === undefined && !node_process_1.argv.includes('-o')) {
|
|
48
23
|
console.error('Error: -o is not found');
|
|
49
24
|
return false;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const RELATIONSHIPS: {
|
|
2
|
+
readonly 'zero-one': "|o";
|
|
3
|
+
readonly one: "||";
|
|
4
|
+
readonly 'zero-many': "}o";
|
|
5
|
+
readonly many: "}|";
|
|
6
|
+
};
|
|
7
|
+
export type Relationship = keyof typeof RELATIONSHIPS;
|
|
8
|
+
/**
|
|
9
|
+
* Builds a relationship line for mermaid from a string.
|
|
10
|
+
* @param { string } input
|
|
11
|
+
* @returns { string }
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildRelationLine(input: string): string;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildRelationLine = buildRelationLine;
|
|
4
|
+
const is_relationship_1 = require("../validator/is-relationship");
|
|
5
|
+
const RELATIONSHIPS = {
|
|
6
|
+
'zero-one': '|o',
|
|
7
|
+
one: '||',
|
|
8
|
+
'zero-many': '}o',
|
|
9
|
+
many: '}|',
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Builds a relationship line for mermaid from a string.
|
|
13
|
+
* @param { string } input
|
|
14
|
+
* @returns { string }
|
|
15
|
+
*/
|
|
16
|
+
function buildRelationLine(input) {
|
|
17
|
+
const parts = input.split('-to-');
|
|
18
|
+
if (parts.length !== 2) {
|
|
19
|
+
throw new Error(`Invalid input format: ${input}`);
|
|
20
|
+
}
|
|
21
|
+
const [toRaw, optionalFlag] = parts[1].includes('-optional')
|
|
22
|
+
? [parts[1].replace('-optional', ''), 'optional']
|
|
23
|
+
: [parts[1], ''];
|
|
24
|
+
const from = parts[0];
|
|
25
|
+
const to = toRaw;
|
|
26
|
+
const isOptional = optionalFlag === 'optional';
|
|
27
|
+
if (!((0, is_relationship_1.isRelationship)(from) && (0, is_relationship_1.isRelationship)(to))) {
|
|
28
|
+
throw new Error(`Invalid relationship string: ${input}`);
|
|
29
|
+
}
|
|
30
|
+
const fromSymbol = RELATIONSHIPS[from];
|
|
31
|
+
const toSymbol = RELATIONSHIPS[to];
|
|
32
|
+
if (!(fromSymbol && toSymbol)) {
|
|
33
|
+
throw new Error(`Invalid relationship string: ${input}`);
|
|
34
|
+
}
|
|
35
|
+
const connector = isOptional ? '..' : '--';
|
|
36
|
+
return `${fromSymbol}${connector}${toSymbol}`;
|
|
37
|
+
}
|
|
@@ -1,40 +1,21 @@
|
|
|
1
|
-
export type RelationType =
|
|
2
|
-
| 'one-to-one'
|
|
3
|
-
| 'one-to-many'
|
|
4
|
-
| 'many-to-one'
|
|
5
|
-
| 'many-to-many'
|
|
6
|
-
| 'one-to-zero-one'
|
|
7
|
-
| 'zero-one-to-one'
|
|
8
|
-
| 'zero-to-many'
|
|
9
|
-
| 'many-to-zero-one'
|
|
10
|
-
| 'zero-one-to-many'
|
|
11
|
-
| 'zero-to-one'
|
|
12
|
-
| 'zero-to-zero-one'
|
|
13
|
-
| 'one-to-many-optional'
|
|
14
|
-
| 'one-to-one-optional'
|
|
15
|
-
| 'many-to-many-optional'
|
|
16
|
-
| 'zero-one-to-zero-one'
|
|
17
|
-
| 'many-to-zero-many'
|
|
18
|
-
| 'zero-many-to-many'
|
|
19
|
-
| 'zero-many-to-zero-many'
|
|
20
1
|
export type Relation = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export type ERContent = readonly string[]
|
|
2
|
+
fromModel: string;
|
|
3
|
+
toModel: string;
|
|
4
|
+
fromField: string;
|
|
5
|
+
toField: string;
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
export type ERContent = readonly string[];
|
|
28
9
|
export type TableInfo = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
10
|
+
name: string;
|
|
11
|
+
fields: {
|
|
12
|
+
type: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string | null;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
36
17
|
export type AccumulatorType = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
18
|
+
tables: TableInfo[];
|
|
19
|
+
currentTable: TableInfo | null;
|
|
20
|
+
currentDescription: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRelationship = isRelationship;
|
|
4
|
+
/**
|
|
5
|
+
* isRelationship
|
|
6
|
+
* @param { string } key
|
|
7
|
+
* @returns { key is Relationship }
|
|
8
|
+
*/
|
|
9
|
+
function isRelationship(key) {
|
|
10
|
+
return ['zero-one', 'one', 'zero-many', 'many'].includes(key);
|
|
11
|
+
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @returns The parsed relation
|
|
5
5
|
*/
|
|
6
6
|
export declare function parseRelationLine(line: string): {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} | null
|
|
7
|
+
fromModel: string;
|
|
8
|
+
fromField: string;
|
|
9
|
+
toModel: string;
|
|
10
|
+
toField: string;
|
|
11
|
+
type: string;
|
|
12
|
+
} | null;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseRelationLine = parseRelationLine;
|
|
4
|
-
const is_relation_1 = require("./is-relation");
|
|
5
4
|
/**
|
|
6
5
|
* Parse a relation line
|
|
7
6
|
* @param line - The line to parse
|
|
@@ -12,10 +11,6 @@ function parseRelationLine(line) {
|
|
|
12
11
|
const relationMatch = line.match(/@relation\s+(\w+)\.(\w+)\s+(\w+)\.(\w+)\s+(\w+-to-\w+)/);
|
|
13
12
|
if (relationMatch) {
|
|
14
13
|
const [_, fromModel, fromField, toModel, toField, type] = relationMatch;
|
|
15
|
-
// Validate the relation type
|
|
16
|
-
if (!(0, is_relation_1.isRelation)(type)) {
|
|
17
|
-
throw new Error(`Unknown relation type: ${type}`);
|
|
18
|
-
}
|
|
19
14
|
return {
|
|
20
15
|
fromModel,
|
|
21
16
|
fromField,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { TableInfo } from '../type'
|
|
1
|
+
import type { TableInfo } from '../type';
|
|
2
2
|
/**
|
|
3
3
|
* Parse table info from code
|
|
4
4
|
* @function parseTableInfo
|
|
5
5
|
* @param code - The code to parse the table info from
|
|
6
6
|
* @returns The parsed table info
|
|
7
7
|
*/
|
|
8
|
-
export declare function parseTableInfo(code: string[]): TableInfo[]
|
|
8
|
+
export declare function parseTableInfo(code: string[]): TableInfo[];
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param relations - The relations to remove duplicates from
|
|
5
5
|
* @returns The relations without duplicates
|
|
6
6
|
*/
|
|
7
|
-
export declare function removeDuplicateRelations(relations: readonly string[]): readonly string[]
|
|
7
|
+
export declare function removeDuplicateRelations(relations: readonly string[]): readonly string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Config } from '../../../common/config';
|
|
2
2
|
/**
|
|
3
3
|
* Loads the configuration from the `sizuku.json` file or returns the default configuration.
|
|
4
4
|
*
|
|
5
5
|
* @returns The configuration object.
|
|
6
6
|
*/
|
|
7
|
-
export declare function getConfig(): Config
|
|
7
|
+
export declare function getConfig(): Config;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
2
|
/**
|
|
3
3
|
* Extract schemas from lines of code
|
|
4
4
|
* @function extractSchemas
|
|
5
5
|
* @param lines - Lines of code
|
|
6
6
|
* @returns Schemas
|
|
7
7
|
*/
|
|
8
|
-
export declare function extractSchemas(lines: string[]): Schema[]
|
|
8
|
+
export declare function extractSchemas(lines: string[]): Schema[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
2
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
|
+
import type { Config } from '../../../common/config';
|
|
3
3
|
/**
|
|
4
4
|
* Generates Valibot code for a given schema and config.
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import type { Config } from '../../../common/config'
|
|
|
8
8
|
* @param config - The configuration for the code generation.
|
|
9
9
|
* @returns The generated Valibot code.
|
|
10
10
|
*/
|
|
11
|
-
export declare function generateValibotCode(schema: Schema, config: Config): string
|
|
11
|
+
export declare function generateValibotCode(schema: Schema, config: Config): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
2
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
|
+
import type { Config } from '../../../common/config';
|
|
3
3
|
/**
|
|
4
4
|
* @function generateValibotInferInput
|
|
5
5
|
* @param schema
|
|
6
6
|
* @param config
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function generateValibotInferInput(schema: Schema, config: Config): string
|
|
9
|
+
export declare function generateValibotInferInput(schema: Schema, config: Config): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
2
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
|
+
import type { Config } from '../../../common/config';
|
|
3
3
|
/**
|
|
4
4
|
* @function generateValibotSchema
|
|
5
5
|
* @param schema
|
|
6
6
|
* @param config
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function generateValibotSchema(schema: Schema, config: Config): string
|
|
9
|
+
export declare function generateValibotSchema(schema: Schema, config: Config): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import type { Config } from '../../common/config'
|
|
3
|
-
export declare function main(dev?: boolean, config?: Config): Promise<boolean
|
|
2
|
+
import type { Config } from '../../common/config';
|
|
3
|
+
export declare function main(dev?: boolean, config?: Config): Promise<boolean>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Config } from '../../../common/config';
|
|
2
2
|
/**
|
|
3
3
|
* Loads the configuration from the `sizuku.json` file or returns the default configuration.
|
|
4
4
|
*
|
|
5
5
|
* @function getConfig
|
|
6
6
|
* @returns The configuration object.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getConfig(): Config
|
|
8
|
+
export declare function getConfig(): Config;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
2
|
/**
|
|
3
3
|
* Extract schemas from lines of code
|
|
4
4
|
* @function extractSchemas
|
|
5
5
|
* @param lines - Lines of code
|
|
6
6
|
* @returns Schemas
|
|
7
7
|
*/
|
|
8
|
-
export declare function extractSchemas(lines: string[]): Schema[]
|
|
8
|
+
export declare function extractSchemas(lines: string[]): Schema[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
2
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
|
+
import type { Config } from '../../../common/config';
|
|
3
3
|
/**
|
|
4
4
|
* Generates a Zod infer type for a given schema and config.
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import type { Config } from '../../../common/config'
|
|
|
8
8
|
* @param config - The configuration for the code generation.
|
|
9
9
|
* @returns The generated Zod infer type.
|
|
10
10
|
*/
|
|
11
|
-
export declare function generateZInfer(schema: Schema, config: Config): string
|
|
11
|
+
export declare function generateZInfer(schema: Schema, config: Config): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
2
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
|
+
import type { Config } from '../../../common/config';
|
|
3
3
|
/**
|
|
4
4
|
* Generates Zod code for a given schema and config.
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import type { Config } from '../../../common/config'
|
|
|
8
8
|
* @param config - The configuration for the code generation.
|
|
9
9
|
* @returns The generated Zod code.
|
|
10
10
|
*/
|
|
11
|
-
export declare function generateZodCode(schema: Schema, config: Config): string
|
|
11
|
+
export declare function generateZodCode(schema: Schema, config: Config): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Schema } from '../../../common/type'
|
|
2
|
-
import type { Config } from '../../../common/config'
|
|
1
|
+
import type { Schema } from '../../../common/type';
|
|
2
|
+
import type { Config } from '../../../common/config';
|
|
3
3
|
/**
|
|
4
4
|
* Generates a Zod schema for a given schema and config.
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import type { Config } from '../../../common/config'
|
|
|
8
8
|
* @param config - The configuration for the code generation.
|
|
9
9
|
* @returns The generated Zod schema.
|
|
10
10
|
*/
|
|
11
|
-
export declare function generateZodSchema(schema: Schema, config: Config): string
|
|
11
|
+
export declare function generateZodSchema(schema: Schema, config: Config): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import type { Config } from '../../common/config'
|
|
3
|
-
export declare function main(dev?: boolean, config?: Config): Promise<boolean
|
|
2
|
+
import type { Config } from '../../common/config';
|
|
3
|
+
export declare function main(dev?: boolean, config?: Config): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sizuku",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Sizuku is a tool that generates validation schemas for Zod and Valibot, as well as ER diagrams, from Drizzle schemas annotated with comments.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dev": "pnpm --filter sizuku-test dev",
|
|
41
41
|
"test": "vitest run",
|
|
42
42
|
"coverage": "vitest run --coverage",
|
|
43
|
-
"release": "npm pkg fix && npm publish"
|
|
43
|
+
"release": "npm pkg fix && pnpm build && npm publish"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^22.13.8",
|