sizuku 0.0.6 → 0.1.0
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 +88 -342
- package/dist/config/index.d.ts +18 -0
- package/dist/config/index.js +13 -0
- package/dist/generator/mermaid-er/config/index.d.ts +4 -4
- package/dist/generator/mermaid-er/config/index.js +4 -10
- package/dist/generator/mermaid-er/core/extract-relations.d.ts +1 -1
- package/dist/generator/mermaid-er/core/extract-relations.js +3 -6
- package/dist/generator/mermaid-er/generator/{generate-er-content.d.ts → er-content.d.ts} +2 -3
- package/dist/generator/mermaid-er/generator/{generate-er-content.js → er-content.js} +3 -7
- package/dist/generator/mermaid-er/generator/index.d.ts +2 -0
- package/dist/generator/mermaid-er/generator/index.js +2 -0
- package/dist/generator/mermaid-er/generator/{generate-relation-line.d.ts → relation-line.d.ts} +2 -2
- package/dist/generator/mermaid-er/generator/{generate-relation-line.js → relation-line.js} +3 -6
- package/dist/generator/mermaid-er/index.d.ts +6 -5
- package/dist/generator/mermaid-er/index.js +15 -76
- package/dist/generator/mermaid-er/relationship/build-relation-line.js +3 -6
- package/dist/generator/mermaid-er/types.js +1 -0
- package/dist/generator/mermaid-er/validator/index.d.ts +4 -0
- package/dist/generator/mermaid-er/validator/index.js +4 -0
- package/dist/generator/mermaid-er/validator/is-relationship.d.ts +1 -1
- package/dist/generator/mermaid-er/validator/is-relationship.js +1 -4
- package/dist/generator/mermaid-er/validator/parse-relation-line.js +1 -4
- package/dist/generator/mermaid-er/validator/parse-table-info.d.ts +1 -7
- package/dist/generator/mermaid-er/validator/parse-table-info.js +69 -89
- package/dist/generator/mermaid-er/validator/remove-duplicate-relations.js +1 -4
- package/dist/generator/valibot/config/index.d.ts +2 -2
- package/dist/generator/valibot/config/index.js +6 -12
- package/dist/generator/valibot/core/extract-schema.d.ts +2 -5
- package/dist/generator/valibot/core/extract-schema.js +162 -81
- package/dist/generator/valibot/generator/infer-input.d.ts +5 -0
- package/dist/generator/valibot/generator/infer-input.js +8 -0
- package/dist/generator/valibot/generator/valibot-code.d.ts +8 -0
- package/dist/generator/valibot/generator/valibot-code.js +16 -0
- package/dist/generator/valibot/generator/valibot.d.ts +7 -0
- package/dist/generator/valibot/generator/valibot.js +11 -0
- package/dist/generator/valibot/index.d.ts +9 -3
- package/dist/generator/valibot/index.js +21 -76
- package/dist/generator/zod/config/index.d.ts +2 -2
- package/dist/generator/zod/config/index.js +6 -12
- package/dist/generator/zod/core/extract-schema.d.ts +1 -2
- package/dist/generator/zod/core/extract-schema.js +228 -81
- package/dist/generator/zod/generator/infer.d.ts +5 -0
- package/dist/generator/zod/generator/infer.js +8 -0
- package/dist/generator/zod/generator/{generate-zod-code.d.ts → zod-code.d.ts} +2 -3
- package/dist/generator/zod/generator/zod-code.js +18 -0
- package/dist/generator/zod/generator/{generate-zod-schema.d.ts → zod.d.ts} +2 -4
- package/dist/generator/zod/generator/zod.js +12 -0
- package/dist/generator/zod/index.d.ts +10 -3
- package/dist/generator/zod/index.js +29 -76
- package/dist/index.d.ts +3 -0
- package/dist/index.js +54 -0
- package/dist/shared/config/index.d.ts +13 -0
- package/dist/{common → shared}/config/index.js +1 -4
- package/dist/shared/format/index.d.ts +2 -0
- package/dist/shared/format/index.js +10 -0
- package/dist/shared/fs/index.d.ts +2 -0
- package/dist/shared/fs/index.js +10 -0
- package/dist/shared/fsp/index.d.ts +3 -0
- package/dist/shared/fsp/index.js +8 -0
- package/dist/shared/generator/field-definitions.d.ts +6 -0
- package/dist/shared/generator/field-definitions.js +12 -0
- package/dist/shared/types.js +1 -0
- package/dist/{common/text → shared/utils}/capitalize.js +1 -4
- package/dist/shared/utils/compose.d.ts +101 -0
- package/dist/shared/utils/compose.js +124 -0
- package/dist/shared/utils/file.d.ts +92 -0
- package/dist/shared/utils/file.js +177 -0
- package/dist/shared/utils/functional.d.ts +118 -0
- package/dist/shared/utils/functional.js +96 -0
- package/package.json +11 -10
- package/dist/common/config/index.d.ts +0 -13
- package/dist/common/format/index.d.ts +0 -1
- package/dist/common/format/index.js +0 -12
- package/dist/common/generator/generate-field-definitions.d.ts +0 -8
- package/dist/common/generator/generate-field-definitions.js +0 -16
- package/dist/common/helper/get-camel-case-schema-name-helper.d.ts +0 -7
- package/dist/common/helper/get-camel-case-schema-name-helper.js +0 -14
- package/dist/common/helper/get-pascal-case-schema-name-helper.d.ts +0 -8
- package/dist/common/helper/get-pascal-case-schema-name-helper.js +0 -15
- package/dist/common/helper/get-variable-name-helper.d.ts +0 -9
- package/dist/common/helper/get-variable-name-helper.js +0 -15
- package/dist/common/helper/get-variable-schema-name-helper.d.ts +0 -9
- package/dist/common/helper/get-variable-schema-name-helper.js +0 -17
- package/dist/common/text/decapitalize.d.ts +0 -17
- package/dist/common/text/decapitalize.js +0 -22
- package/dist/common/type/index.js +0 -2
- package/dist/generator/mermaid-er/type/index.js +0 -2
- package/dist/generator/mermaid-er/validator/is-relation.d.ts +0 -7
- package/dist/generator/mermaid-er/validator/is-relation.js +0 -40
- package/dist/generator/valibot/generator/generate-valibot-code.d.ts +0 -11
- package/dist/generator/valibot/generator/generate-valibot-code.js +0 -21
- package/dist/generator/valibot/generator/generate-valibot-infer-input.d.ts +0 -9
- package/dist/generator/valibot/generator/generate-valibot-infer-input.js +0 -16
- package/dist/generator/valibot/generator/generate-valibot-schema.d.ts +0 -9
- package/dist/generator/valibot/generator/generate-valibot-schema.js +0 -16
- package/dist/generator/zod/generator/generate-z-infer.d.ts +0 -11
- package/dist/generator/zod/generator/generate-z-infer.js +0 -18
- package/dist/generator/zod/generator/generate-zod-code.js +0 -21
- package/dist/generator/zod/generator/generate-zod-schema.js +0 -17
- /package/dist/generator/mermaid-er/{type/index.d.ts → types.d.ts} +0 -0
- /package/dist/{common/type/index.d.ts → shared/types.d.ts} +0 -0
- /package/dist/{common/text → shared/utils}/capitalize.d.ts +0 -0
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateRelationLine = generateRelationLine;
|
|
4
|
-
const build_relation_line_1 = require("../relationship/build-relation-line");
|
|
1
|
+
import { buildRelationLine } from '../relationship/build-relation-line.js';
|
|
5
2
|
/**
|
|
6
3
|
* Generate a relation line for a relation
|
|
7
4
|
* @param relation - The relation to generate a line for
|
|
8
5
|
* @returns The generated relation line
|
|
9
6
|
*/
|
|
10
|
-
function
|
|
11
|
-
const cardinality =
|
|
7
|
+
export function relationLine(relation) {
|
|
8
|
+
const cardinality = buildRelationLine(relation.type);
|
|
12
9
|
if (!cardinality) {
|
|
13
10
|
throw new Error(`Unknown relation type: ${relation.type}`);
|
|
14
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Generate Mermaid ER diagram
|
|
3
|
+
* @param code - The code to generate Mermaid ER diagram from
|
|
4
|
+
* @param output - The output file path
|
|
5
|
+
*/
|
|
6
|
+
export declare function sizukuMermaidER(code: string[], output: string): Promise<import("neverthrow").Result<void, Error>>;
|
|
@@ -1,77 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
// ER diagram header
|
|
17
|
-
exports.ER_HEADER = ['```mermaid', 'erDiagram'];
|
|
18
|
-
// ER diagram footer
|
|
19
|
-
exports.ER_FOOTER = ['```'];
|
|
20
|
-
async function main(dev = false, config = (0, config_1.getConfig)()) {
|
|
21
|
-
// 1. argv ['**/bin/node', '**/dist/src/generator/mermaid-er/index.js', 'db/schema.ts', '-o', 'mermaid-er/ER.md']
|
|
22
|
-
if (config.output === undefined && !node_process_1.argv.includes('-o')) {
|
|
23
|
-
console.error('Error: -o is not found');
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
// 2. slice [ 'db/schema.ts', '-o', 'mermaid-er/ER.md']
|
|
27
|
-
const args = process.argv.slice(2);
|
|
28
|
-
// 3. input = args[0] = 'db/schema.ts'
|
|
29
|
-
const input = config.input ?? args[0];
|
|
30
|
-
config.input = input;
|
|
31
|
-
// 4. output = 'mermaid-er/ER.md'
|
|
32
|
-
const output = config.output ?? args[args.indexOf('-o') + 1];
|
|
33
|
-
config.output = output;
|
|
34
|
-
try {
|
|
35
|
-
// 5. read db/schema.ts
|
|
36
|
-
const content = (0, node_fs_1.readFileSync)(input, 'utf-8');
|
|
37
|
-
// 6. split lines
|
|
38
|
-
const lines = content.split('\n');
|
|
39
|
-
// 7. create output directory
|
|
40
|
-
const outputDir = node_path_1.default.dirname(output);
|
|
41
|
-
if (!(0, node_fs_1.existsSync)(outputDir)) {
|
|
42
|
-
(0, node_fs_1.mkdirSync)(outputDir, { recursive: true });
|
|
43
|
-
}
|
|
44
|
-
// 8. skip import section
|
|
45
|
-
const codeStart = lines.findIndex((line) => !line.trim().startsWith('import') && line.trim() !== '');
|
|
46
|
-
// 9. parse table info
|
|
47
|
-
const tables = (0, parse_table_info_1.parseTableInfo)(lines.slice(codeStart));
|
|
48
|
-
// 10. extract relations
|
|
49
|
-
const relations = (0, extract_relations_1.extractRelations)(lines.slice(codeStart));
|
|
50
|
-
// 11. generate ER content
|
|
51
|
-
const ERContent = (0, generate_er_content_1.generateERContent)(relations, tables);
|
|
52
|
-
// 12. write ER content to output file
|
|
53
|
-
(0, node_fs_1.writeFileSync)(output, ERContent);
|
|
54
|
-
console.log(`Generated ER at: ${output}`);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
if (e instanceof Error) {
|
|
59
|
-
console.error(e.message);
|
|
60
|
-
if (dev) {
|
|
61
|
-
throw e;
|
|
62
|
-
}
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
if (dev) {
|
|
66
|
-
throw new Error('Unknown error occurred');
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (require.main === module) {
|
|
72
|
-
main().then((success) => {
|
|
73
|
-
if (!success) {
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
1
|
+
import { mkdir, writeFile } from '../../shared/fsp/index.js';
|
|
2
|
+
import { extractRelations } from './core/extract-relations.js';
|
|
3
|
+
import { erContent } from './generator/index.js';
|
|
4
|
+
import { parseTableInfo } from './validator/parse-table-info.js';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
/**
|
|
7
|
+
* Generate Mermaid ER diagram
|
|
8
|
+
* @param code - The code to generate Mermaid ER diagram from
|
|
9
|
+
* @param output - The output file path
|
|
10
|
+
*/
|
|
11
|
+
export async function sizukuMermaidER(code, output) {
|
|
12
|
+
const tables = parseTableInfo(code);
|
|
13
|
+
const relations = extractRelations(code);
|
|
14
|
+
const ERContent = erContent(relations, tables);
|
|
15
|
+
return await mkdir(path.dirname(output)).andThen(() => writeFile(output, ERContent));
|
|
77
16
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildRelationLine = buildRelationLine;
|
|
4
|
-
const is_relationship_1 = require("../validator/is-relationship");
|
|
1
|
+
import { isRelationship } from '../validator/is-relationship.js';
|
|
5
2
|
const RELATIONSHIPS = {
|
|
6
3
|
'zero-one': '|o',
|
|
7
4
|
one: '||',
|
|
@@ -13,7 +10,7 @@ const RELATIONSHIPS = {
|
|
|
13
10
|
* @param { string } input
|
|
14
11
|
* @returns { string }
|
|
15
12
|
*/
|
|
16
|
-
function buildRelationLine(input) {
|
|
13
|
+
export function buildRelationLine(input) {
|
|
17
14
|
const parts = input.split('-to-');
|
|
18
15
|
if (parts.length !== 2) {
|
|
19
16
|
throw new Error(`Invalid input format: ${input}`);
|
|
@@ -24,7 +21,7 @@ function buildRelationLine(input) {
|
|
|
24
21
|
const from = parts[0];
|
|
25
22
|
const to = toRaw;
|
|
26
23
|
const isOptional = optionalFlag === 'optional';
|
|
27
|
-
if (!(
|
|
24
|
+
if (!(isRelationship(from) && isRelationship(to))) {
|
|
28
25
|
throw new Error(`Invalid relationship string: ${input}`);
|
|
29
26
|
}
|
|
30
27
|
const fromSymbol = RELATIONSHIPS[from];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRelationship = isRelationship;
|
|
4
1
|
/**
|
|
5
2
|
* isRelationship
|
|
6
3
|
* @param { string } key
|
|
7
4
|
* @returns { key is Relationship }
|
|
8
5
|
*/
|
|
9
|
-
function isRelationship(key) {
|
|
6
|
+
export function isRelationship(key) {
|
|
10
7
|
return ['zero-one', 'one', 'zero-many', 'many'].includes(key);
|
|
11
8
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseRelationLine = parseRelationLine;
|
|
4
1
|
/**
|
|
5
2
|
* Parse a relation line
|
|
6
3
|
* @param line - The line to parse
|
|
7
4
|
* @returns The parsed relation
|
|
8
5
|
*/
|
|
9
|
-
function parseRelationLine(line) {
|
|
6
|
+
export function parseRelationLine(line) {
|
|
10
7
|
// @relation <fromModel>.<fromField> <toModel>.<toField> <relationType>
|
|
11
8
|
const relationMatch = line.match(/@relation\s+(\w+)\.(\w+)\s+(\w+)\.(\w+)\s+(\w+-to-\w+)/);
|
|
12
9
|
if (relationMatch) {
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import type { TableInfo } from '../
|
|
2
|
-
/**
|
|
3
|
-
* Parse table info from code
|
|
4
|
-
* @function parseTableInfo
|
|
5
|
-
* @param code - The code to parse the table info from
|
|
6
|
-
* @returns The parsed table info
|
|
7
|
-
*/
|
|
1
|
+
import type { TableInfo } from '../types.js';
|
|
8
2
|
export declare function parseTableInfo(code: string[]): TableInfo[];
|
|
@@ -1,91 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function parseTableInfo(code) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { Project, Node } from 'ts-morph';
|
|
2
|
+
const baseBuilderName = (expr) => {
|
|
3
|
+
if (Node.isIdentifier(expr))
|
|
4
|
+
return expr.getText();
|
|
5
|
+
if (Node.isCallExpression(expr) || Node.isPropertyAccessExpression(expr))
|
|
6
|
+
return baseBuilderName(expr.getExpression());
|
|
7
|
+
return '';
|
|
8
|
+
};
|
|
9
|
+
const isFieldInfo = (v) => v !== null;
|
|
10
|
+
export function parseTableInfo(code) {
|
|
11
|
+
const source = code.join('\n');
|
|
12
|
+
const file = new Project({ useInMemoryFileSystem: true }).createSourceFile('temp.ts', source);
|
|
13
|
+
return file
|
|
14
|
+
.getVariableStatements()
|
|
15
|
+
.filter((stmt) => stmt.isExported())
|
|
16
|
+
.flatMap((stmt) => {
|
|
17
|
+
const decl = stmt.getDeclarations()[0];
|
|
18
|
+
if (!Node.isVariableDeclaration(decl))
|
|
19
|
+
return [];
|
|
20
|
+
const varName = decl.getName();
|
|
21
|
+
if (varName.toLowerCase().includes('relation'))
|
|
22
|
+
return [];
|
|
23
|
+
const init = decl.getInitializer();
|
|
24
|
+
if (!(init && Node.isCallExpression(init)))
|
|
25
|
+
return [];
|
|
26
|
+
const callee = init.getExpression().getText();
|
|
27
|
+
if (!callee.endsWith('Table') || callee === 'relations')
|
|
28
|
+
return [];
|
|
29
|
+
const objLit = init.getArguments()[1];
|
|
30
|
+
if (!(objLit && Node.isObjectLiteralExpression(objLit)))
|
|
31
|
+
return [];
|
|
32
|
+
const fields = objLit
|
|
33
|
+
.getProperties()
|
|
34
|
+
.filter(Node.isPropertyAssignment)
|
|
35
|
+
.map((prop) => {
|
|
36
|
+
const keyNode = prop.getNameNode();
|
|
37
|
+
if (!Node.isIdentifier(keyNode))
|
|
38
|
+
return null;
|
|
39
|
+
const fieldName = keyNode.getText();
|
|
40
|
+
const initExpr = prop.getInitializer();
|
|
41
|
+
if (!(initExpr && Node.isCallExpression(initExpr)))
|
|
42
|
+
return null;
|
|
43
|
+
const fieldType = baseBuilderName(initExpr);
|
|
44
|
+
const initText = initExpr.getText();
|
|
45
|
+
const lineIdx = prop.getStartLineNumber() - 1;
|
|
46
|
+
const baseDesc = code
|
|
47
|
+
.slice(0, lineIdx)
|
|
48
|
+
.reverse()
|
|
49
|
+
.find((line) => {
|
|
50
|
+
const t = line.trim();
|
|
51
|
+
return (t.startsWith('///') &&
|
|
52
|
+
!t.includes('@z.') &&
|
|
53
|
+
!t.includes('@v.') &&
|
|
54
|
+
!t.includes('@relation'));
|
|
55
|
+
})
|
|
56
|
+
?.replace(/^\s*\/\/\/\s*/, '') ?? '';
|
|
57
|
+
const prefix = initText.includes('.primaryKey()')
|
|
58
|
+
? '(PK) '
|
|
59
|
+
: initText.includes('.references(')
|
|
60
|
+
? '(FK) '
|
|
61
|
+
: '';
|
|
62
|
+
return {
|
|
63
|
+
name: fieldName,
|
|
64
|
+
type: fieldType,
|
|
65
|
+
description: `${prefix}${baseDesc}`.trim(),
|
|
41
66
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// field info extraction
|
|
47
|
-
if (!acc.currentTable) {
|
|
48
|
-
return acc;
|
|
49
|
-
}
|
|
50
|
-
const fieldMatch = line.match(/^\s*([^:]+):\s*([^(]+)\(/);
|
|
51
|
-
if (fieldMatch) {
|
|
52
|
-
const [_, fieldName, fieldType] = fieldMatch;
|
|
53
|
-
const description = line.includes('.primaryKey()')
|
|
54
|
-
? `(PK) ${acc.currentDescription || ''}`
|
|
55
|
-
: acc.currentDescription || '';
|
|
56
|
-
acc.tempFields.push({
|
|
57
|
-
name: fieldName.trim(),
|
|
58
|
-
type: fieldType.trim(),
|
|
59
|
-
description,
|
|
60
|
-
line: index,
|
|
61
|
-
});
|
|
62
|
-
acc.currentDescription = '';
|
|
63
|
-
return acc;
|
|
64
|
-
}
|
|
65
|
-
// detect foreign key constraint
|
|
66
|
-
if (line.includes('.references') || line.includes('relations')) {
|
|
67
|
-
const lastIndex = acc.tempFields.length - 1;
|
|
68
|
-
if (lastIndex >= 0) {
|
|
69
|
-
const lastField = acc.tempFields[lastIndex];
|
|
70
|
-
acc.tempFields[lastIndex] = {
|
|
71
|
-
name: lastField.name,
|
|
72
|
-
type: lastField.type,
|
|
73
|
-
description: `(FK) ${lastField.description}`,
|
|
74
|
-
line: lastField.line,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return acc;
|
|
78
|
-
}
|
|
79
|
-
return acc;
|
|
80
|
-
}, initialAccumulator);
|
|
81
|
-
// process fields of the last table
|
|
82
|
-
if (result.currentTable && result.tempFields.length > 0) {
|
|
83
|
-
result.currentTable.fields = result.tempFields.map((field) => ({
|
|
84
|
-
name: field.name,
|
|
85
|
-
type: field.type,
|
|
86
|
-
description: field.description,
|
|
87
|
-
}));
|
|
88
|
-
result.tables.push(result.currentTable);
|
|
89
|
-
}
|
|
90
|
-
return result.tables;
|
|
67
|
+
})
|
|
68
|
+
.filter(isFieldInfo);
|
|
69
|
+
return [{ name: varName, fields }];
|
|
70
|
+
});
|
|
91
71
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeDuplicateRelations = removeDuplicateRelations;
|
|
4
1
|
/**
|
|
5
2
|
* Remove duplicate relations
|
|
6
3
|
* @function removeDuplicateRelations
|
|
7
4
|
* @param relations - The relations to remove duplicates from
|
|
8
5
|
* @returns The relations without duplicates
|
|
9
6
|
*/
|
|
10
|
-
function removeDuplicateRelations(relations) {
|
|
7
|
+
export function removeDuplicateRelations(relations) {
|
|
11
8
|
return [...new Set(relations)];
|
|
12
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Config } from '../../../
|
|
1
|
+
import type { Config } from '../../../shared/config/index.js'
|
|
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,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getConfig = getConfig;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const config_1 = require("../../../common/config");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { DEFAULT_CONFIG } from '../../../shared/config/index.js';
|
|
9
3
|
/**
|
|
10
4
|
* Loads the configuration from the `sizuku.json` file or returns the default configuration.
|
|
11
5
|
*
|
|
12
6
|
* @returns The configuration object.
|
|
13
7
|
*/
|
|
14
|
-
function getConfig() {
|
|
15
|
-
const config =
|
|
16
|
-
? { ...
|
|
17
|
-
:
|
|
8
|
+
export function getConfig() {
|
|
9
|
+
const config = fs.existsSync('sizuku-valibot.json')
|
|
10
|
+
? { ...DEFAULT_CONFIG, ...JSON.parse(fs.readFileSync('sizuku-valibot.json', 'utf-8')) }
|
|
11
|
+
: DEFAULT_CONFIG;
|
|
18
12
|
return config;
|
|
19
13
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { Schema } from '../../../
|
|
1
|
+
import type { Schema } from '../../../shared/types.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @function extractSchemas
|
|
5
|
-
* @param lines - Lines of code
|
|
6
|
-
* @returns Schemas
|
|
3
|
+
* Public API: extract schemas from code lines
|
|
7
4
|
*/
|
|
8
5
|
export declare function extractSchemas(lines: string[]): Schema[];
|