@based/schema 5.0.0-alpha.13 → 5.0.0-alpha.14
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/lang.d.ts +3 -1
- package/dist/lang.js +2 -0
- package/dist/mermaid.d.ts +1 -0
- package/dist/mermaid.js +70 -13
- package/package.json +1 -1
package/dist/lang.d.ts
CHANGED
|
@@ -144,8 +144,10 @@ declare const langCodes: {
|
|
|
144
144
|
readonly yi: 142;
|
|
145
145
|
readonly yo: 143;
|
|
146
146
|
readonly zu: 144;
|
|
147
|
+
readonly ka: 145;
|
|
148
|
+
readonly cnr: 146;
|
|
147
149
|
};
|
|
148
|
-
export declare const langCodesMap: Map<string, 0 |
|
|
150
|
+
export declare const langCodesMap: Map<string, 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146>;
|
|
149
151
|
export declare const inverseLangMap: Map<any, any>;
|
|
150
152
|
export type LangName = keyof typeof langCodes;
|
|
151
153
|
export type LangCode = (typeof langCodes)[LangName];
|
package/dist/lang.js
CHANGED
package/dist/mermaid.d.ts
CHANGED
package/dist/mermaid.js
CHANGED
|
@@ -1,23 +1,80 @@
|
|
|
1
1
|
import { getPropType } from './parse/utils.js';
|
|
2
|
-
import { isPropType } from './types.js';
|
|
3
|
-
export const
|
|
4
|
-
let mermaid = '
|
|
2
|
+
import { isPropType, } from './types.js';
|
|
3
|
+
export const mermaid2 = (schema) => {
|
|
4
|
+
let mermaid = 'erDiagram';
|
|
5
|
+
let relations = '';
|
|
6
|
+
const parse = (type, props, indent = '') => {
|
|
7
|
+
let entity = indent ? '' : `\n${type} {`;
|
|
8
|
+
for (const key in props) {
|
|
9
|
+
const prop = props[key];
|
|
10
|
+
if (isPropType('reference', prop)) {
|
|
11
|
+
entity += `\n${prop.ref} ${indent}${key}`;
|
|
12
|
+
relations += `\n${type} ||--o| ${prop.ref} : ${key}`;
|
|
13
|
+
}
|
|
14
|
+
else if (isPropType('references', prop)) {
|
|
15
|
+
entity += `\n${prop.items.ref} ${indent}${key}`;
|
|
16
|
+
relations += `\n${type} ||--o{ ${prop.items.ref} : ${key}`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
entity += `\n${getPropType(prop)} ${indent}${key}`;
|
|
20
|
+
if (isPropType('object', prop)) {
|
|
21
|
+
entity += parse(type, prop.props, `${indent}_`);
|
|
22
|
+
}
|
|
23
|
+
else if (isPropType('enum', prop)) {
|
|
24
|
+
entity += '"';
|
|
25
|
+
if (prop.enum.length > 3) {
|
|
26
|
+
const [a, b, c] = prop.enum;
|
|
27
|
+
entity += [a, b, c, `+${prop.enum.length - 3}`].join(', ');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
entity += prop.enum.join(', ');
|
|
31
|
+
}
|
|
32
|
+
entity += '"';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!indent) {
|
|
37
|
+
entity += '\n}';
|
|
38
|
+
}
|
|
39
|
+
return entity;
|
|
40
|
+
};
|
|
41
|
+
if (schema.props) {
|
|
42
|
+
mermaid += parse('_root', schema.props);
|
|
43
|
+
}
|
|
5
44
|
if (schema.types) {
|
|
6
45
|
for (const type in schema.types) {
|
|
7
|
-
|
|
8
|
-
|
|
46
|
+
mermaid += parse(type, schema.types[type].props);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return mermaid + relations;
|
|
50
|
+
};
|
|
51
|
+
export const mermaid = (schema) => {
|
|
52
|
+
let mermaid = 'classDiagram';
|
|
53
|
+
const parse = (type, props, indent = '') => {
|
|
54
|
+
for (const key in props) {
|
|
55
|
+
const prop = props[key];
|
|
56
|
+
if (isPropType('reference', prop)) {
|
|
57
|
+
mermaid += `\n${type} --> ${prop.ref} : ${key}`;
|
|
58
|
+
}
|
|
59
|
+
else if (isPropType('references', prop)) {
|
|
60
|
+
mermaid += `\n${type} --> ${prop.items.ref} : ${key}[]`;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
9
63
|
const propType = getPropType(prop);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
else if (isPropType('references', prop)) {
|
|
14
|
-
mermaid += `\n${type} --> ${prop.items.ref} : ${key}[]`;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
mermaid += `\n${type} : ${propType} ${key}`;
|
|
64
|
+
mermaid += `\n${type} : ${indent}${key} __${propType}__`;
|
|
65
|
+
if (isPropType('object', prop)) {
|
|
66
|
+
parse(type, prop.props, `${indent}.`);
|
|
18
67
|
}
|
|
19
68
|
}
|
|
20
69
|
}
|
|
70
|
+
};
|
|
71
|
+
if (schema.props) {
|
|
72
|
+
parse('_root', schema.props);
|
|
73
|
+
}
|
|
74
|
+
if (schema.types) {
|
|
75
|
+
for (const type in schema.types) {
|
|
76
|
+
parse(type, schema.types[type].props);
|
|
77
|
+
}
|
|
21
78
|
}
|
|
22
79
|
return mermaid;
|
|
23
80
|
};
|