@cloudbase/cals 1.2.17 → 1.2.18-alpha.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/lib/cjs/utils/mermaid-datasource/build.d.ts +2 -0
- package/lib/cjs/utils/mermaid-datasource/build.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/build.js +82 -0
- package/lib/cjs/utils/mermaid-datasource/classDb.d.ts +116 -0
- package/lib/cjs/utils/mermaid-datasource/classDb.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/classDb.js +333 -0
- package/lib/cjs/utils/mermaid-datasource/classDiagram.d.ts +4 -0
- package/lib/cjs/utils/mermaid-datasource/classDiagram.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/classDiagram.js +1115 -0
- package/lib/cjs/utils/mermaid-datasource/jison-builder.d.ts +2 -0
- package/lib/cjs/utils/mermaid-datasource/jison-builder.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/jison-builder.js +22 -0
- package/lib/cjs/utils/mermaid-datasource/mermaid-json-transform.d.ts +70 -0
- package/lib/cjs/utils/mermaid-datasource/mermaid-json-transform.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/mermaid-json-transform.js +624 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/activity_reservation.d.ts +11 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/activity_reservation.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/activity_reservation.js +9 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/index.d.ts +6 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/index.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/index.js +18 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/students_course_selection.d.ts +11 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/students_course_selection.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/cases/students_course_selection.js +9 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/system.d.ts +7 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/system.d.ts.map +1 -0
- package/lib/cjs/utils/mermaid-datasource/prompts/system.js +9 -0
- package/lib/esm/utils/mermaid-datasource/build.d.ts +2 -0
- package/lib/esm/utils/mermaid-datasource/build.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/build.js +77 -0
- package/lib/esm/utils/mermaid-datasource/classDb.d.ts +116 -0
- package/lib/esm/utils/mermaid-datasource/classDb.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/classDb.js +331 -0
- package/lib/esm/utils/mermaid-datasource/classDiagram.d.ts +4 -0
- package/lib/esm/utils/mermaid-datasource/classDiagram.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/classDiagram.js +1112 -0
- package/lib/esm/utils/mermaid-datasource/jison-builder.d.ts +2 -0
- package/lib/esm/utils/mermaid-datasource/jison-builder.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/jison-builder.js +15 -0
- package/lib/esm/utils/mermaid-datasource/mermaid-json-transform.d.ts +70 -0
- package/lib/esm/utils/mermaid-datasource/mermaid-json-transform.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/mermaid-json-transform.js +615 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/activity_reservation.d.ts +11 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/activity_reservation.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/activity_reservation.js +7 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/index.d.ts +6 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/index.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/index.js +12 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/students_course_selection.d.ts +11 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/students_course_selection.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/prompts/cases/students_course_selection.js +7 -0
- package/lib/esm/utils/mermaid-datasource/prompts/system.d.ts +7 -0
- package/lib/esm/utils/mermaid-datasource/prompts/system.d.ts.map +1 -0
- package/lib/esm/utils/mermaid-datasource/prompts/system.js +7 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../../src/utils/mermaid-datasource/build.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_extra_1 = require("fs-extra");
|
|
16
|
+
const jison_builder_1 = require("./jison-builder");
|
|
17
|
+
const promises_1 = require("node:fs/promises");
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
|
+
const banner = `/* eslint-disable */\n//\n\n/**\n * 本文件由 build.ts 自动生成,请勿手动修改\n * }\n */\n\n`;
|
|
20
|
+
function buildJison() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const classDiagramJison = yield (0, promises_1.readFile)('./classDiagram.jison', 'utf-8');
|
|
23
|
+
let result = (0, jison_builder_1.transformJison)(classDiagramJison);
|
|
24
|
+
result = `//@ts-nocheck\n// DO NOT EDIT THIS FILE, IT IS AUTO GENERATED BY build.ts\n\n
|
|
25
|
+
${result}`;
|
|
26
|
+
// console.log(result);
|
|
27
|
+
yield (0, promises_1.writeFile)('./classDiagram.ts', result);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function exportStringCodeGenerator(path) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const code = yield (0, promises_1.readFile)(path, { encoding: 'utf-8' });
|
|
33
|
+
return {
|
|
34
|
+
code: `${banner}\nexport default ${JSON.stringify(code)};`,
|
|
35
|
+
targetPath: path.replace('.md', '.ts').replace('prompts-src', 'prompts'),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function buildPrompts() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const casesDir = node_path_1.default.join(__dirname, 'prompts-src/cases');
|
|
42
|
+
const cases = yield (0, promises_1.readdir)(casesDir);
|
|
43
|
+
const casesResults = yield Promise.all(cases.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const singleCaseDir = node_path_1.default.join(casesDir, file);
|
|
45
|
+
const userPrompt = yield (0, promises_1.readFile)(node_path_1.default.join(singleCaseDir, 'user.txt'), { encoding: 'utf-8' });
|
|
46
|
+
const answer = yield (0, promises_1.readFile)(node_path_1.default.join(singleCaseDir, 'answer.txt'), { encoding: 'utf-8' });
|
|
47
|
+
return {
|
|
48
|
+
code: `${banner}\nexport default ${JSON.stringify({
|
|
49
|
+
user: userPrompt.trim(),
|
|
50
|
+
assistant: answer.trim(),
|
|
51
|
+
name: file,
|
|
52
|
+
})};`,
|
|
53
|
+
name: file,
|
|
54
|
+
targetPath: node_path_1.default.join(__dirname, 'prompts', 'cases', `${file}.ts`),
|
|
55
|
+
};
|
|
56
|
+
})));
|
|
57
|
+
let caseIndexCode = banner;
|
|
58
|
+
casesResults.forEach((result) => {
|
|
59
|
+
caseIndexCode += `import ${result.name} from './${result.name}';\n`;
|
|
60
|
+
});
|
|
61
|
+
caseIndexCode += `\nexport const cases = [\n${casesResults.map((result) => ` ${result.name},`).join('\n')}\n];`;
|
|
62
|
+
const systemPrompt = yield exportStringCodeGenerator(node_path_1.default.join(__dirname, 'prompts-src', 'system.md'));
|
|
63
|
+
(0, fs_extra_1.ensureDirSync)(node_path_1.default.join(__dirname, 'prompts', 'cases'));
|
|
64
|
+
const prompts = [
|
|
65
|
+
systemPrompt,
|
|
66
|
+
...casesResults,
|
|
67
|
+
{
|
|
68
|
+
code: caseIndexCode,
|
|
69
|
+
targetPath: node_path_1.default.join(__dirname, 'prompts', 'cases', 'index.ts'),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
yield Promise.all(prompts.map((prompt) => __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
yield (0, promises_1.writeFile)(prompt.targetPath, prompt.code);
|
|
74
|
+
})));
|
|
75
|
+
yield (0, promises_1.writeFile)(node_path_1.default.join(__dirname, 'prompts', 'README.md'), `这个目录应该全是自动生成的,请勿手动修改, 如果需要修改,请修改 prompts-src 目录下的文件`);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function build() {
|
|
79
|
+
buildPrompts();
|
|
80
|
+
buildJison();
|
|
81
|
+
}
|
|
82
|
+
build();
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
interface ClassMember {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
visibility?: string;
|
|
6
|
+
annotations?: string[];
|
|
7
|
+
}
|
|
8
|
+
interface ClassInfo {
|
|
9
|
+
id: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
members: ClassMember[];
|
|
12
|
+
annotations: string[];
|
|
13
|
+
cssClasses: string;
|
|
14
|
+
styles: string[];
|
|
15
|
+
methods: ClassMember[];
|
|
16
|
+
text?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
shape?: string;
|
|
19
|
+
domId?: string;
|
|
20
|
+
parent?: string;
|
|
21
|
+
tooltip?: string;
|
|
22
|
+
link?: string;
|
|
23
|
+
linkTarget?: string;
|
|
24
|
+
haveCallback?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ClassRelation {
|
|
27
|
+
id1: string;
|
|
28
|
+
id2: string;
|
|
29
|
+
relation: {
|
|
30
|
+
type1: ClassDatabase['relationType'][keyof ClassDatabase['relationType']] | 'none';
|
|
31
|
+
type2: ClassDatabase['relationType'][keyof ClassDatabase['relationType']] | 'none';
|
|
32
|
+
lineType: number;
|
|
33
|
+
};
|
|
34
|
+
relationTitle1?: string;
|
|
35
|
+
relationTitle2?: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
style?: string;
|
|
38
|
+
}
|
|
39
|
+
interface Note {
|
|
40
|
+
id?: string;
|
|
41
|
+
text: string;
|
|
42
|
+
class?: string;
|
|
43
|
+
}
|
|
44
|
+
interface NamespaceNode {
|
|
45
|
+
id: string;
|
|
46
|
+
classes: Map<string, ClassInfo>;
|
|
47
|
+
children: any;
|
|
48
|
+
domId: string;
|
|
49
|
+
}
|
|
50
|
+
declare class ClassDatabase {
|
|
51
|
+
private classes;
|
|
52
|
+
private relations;
|
|
53
|
+
private notes;
|
|
54
|
+
private namespaces;
|
|
55
|
+
private accTitle;
|
|
56
|
+
private accDescription;
|
|
57
|
+
private direction;
|
|
58
|
+
private classDefs;
|
|
59
|
+
private callbacks;
|
|
60
|
+
private links;
|
|
61
|
+
private tooltips;
|
|
62
|
+
private interfaces;
|
|
63
|
+
private functions;
|
|
64
|
+
private styleClasses;
|
|
65
|
+
private namespaceCounter;
|
|
66
|
+
readonly relationType: {
|
|
67
|
+
readonly AGGREGATION: 0;
|
|
68
|
+
readonly EXTENSION: 1;
|
|
69
|
+
readonly COMPOSITION: 2;
|
|
70
|
+
readonly DEPENDENCY: 3;
|
|
71
|
+
readonly LOLLIPOP: 4;
|
|
72
|
+
};
|
|
73
|
+
readonly lineType: {
|
|
74
|
+
LINE: number;
|
|
75
|
+
DOTTED_LINE: number;
|
|
76
|
+
};
|
|
77
|
+
constructor();
|
|
78
|
+
private splitClassNameAndType;
|
|
79
|
+
addClass(_id: string): void;
|
|
80
|
+
setClassLabel(_id: string, label: string): void;
|
|
81
|
+
addMember(className: string, member: string): void;
|
|
82
|
+
addMembers(className: string, members: string[]): void;
|
|
83
|
+
addAnnotation(className: string, annotation: string): void;
|
|
84
|
+
addRelation(relation: ClassRelation): void;
|
|
85
|
+
addNamespace(id: string): void;
|
|
86
|
+
addClassesToNamespace(id: string, classNames: string[]): void;
|
|
87
|
+
addNote(text: string, className?: string): void;
|
|
88
|
+
setCssClass(ids: string, className: string): void;
|
|
89
|
+
setCssStyle(id: string, styles: string | string[]): void;
|
|
90
|
+
defineClass(ids: string | string[], styles: string[]): void;
|
|
91
|
+
setClickEvent(ids: string, functionName: string, functionArgs?: string): void;
|
|
92
|
+
setLink(ids: string, link: string, target?: string): void;
|
|
93
|
+
setTooltip(ids: string, tooltip?: string): void;
|
|
94
|
+
setAccTitle(title: string): void;
|
|
95
|
+
setAccDescription(description: string): void;
|
|
96
|
+
setDirection(dir: string): void;
|
|
97
|
+
cleanupLabel(label: string): string;
|
|
98
|
+
getClasses(): Map<string, ClassInfo>;
|
|
99
|
+
getRelations(): ClassRelation[];
|
|
100
|
+
getNotes(): Note[];
|
|
101
|
+
getNamespaces(): Map<string, NamespaceNode>;
|
|
102
|
+
getDirection(): string;
|
|
103
|
+
clear(): void;
|
|
104
|
+
exportData(): {
|
|
105
|
+
classes: any;
|
|
106
|
+
relations: ClassRelation[];
|
|
107
|
+
notes: Note[];
|
|
108
|
+
namespaces: any;
|
|
109
|
+
accTitle: string;
|
|
110
|
+
accDescription: string;
|
|
111
|
+
direction: string;
|
|
112
|
+
classDefs: any;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export default ClassDatabase;
|
|
116
|
+
//# sourceMappingURL=classDb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classDb.d.ts","sourceRoot":"","sources":["../../../../src/utils/mermaid-datasource/classDb.ts"],"names":[],"mappings":"AAUA,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE;QACR,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC,MAAM,aAAa,CAAC,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC;QACnF,KAAK,EAAE,aAAa,C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YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAQnC,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;IAIpC,YAAY,IAAI,aAAa,EAAE;IAI/B,QAAQ,IAAI,IAAI,EAAE;IAIlB,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;IAI3C,YAAY,IAAI,MAAM;IAKtB,KAAK,IAAI,IAAI;IAmBb,UAAU;;;;;;;;;;CAYlB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Class Diagram Database Implementation
|
|
3
|
+
// Based on Mermaid.js classDb structure
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
function fromEntries(iterable) {
|
|
6
|
+
return [...iterable].reduce((obj, [key, val]) => {
|
|
7
|
+
obj[key] = val;
|
|
8
|
+
return obj;
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
class ClassDatabase {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.classes = new Map();
|
|
14
|
+
this.relations = [];
|
|
15
|
+
this.notes = [];
|
|
16
|
+
this.namespaces = new Map();
|
|
17
|
+
this.accTitle = '';
|
|
18
|
+
this.accDescription = '';
|
|
19
|
+
this.direction = 'TB';
|
|
20
|
+
this.classDefs = new Map();
|
|
21
|
+
this.callbacks = new Map();
|
|
22
|
+
this.links = new Map();
|
|
23
|
+
this.tooltips = new Map();
|
|
24
|
+
this.interfaces = [];
|
|
25
|
+
this.functions = [];
|
|
26
|
+
this.styleClasses = new Map();
|
|
27
|
+
this.namespaceCounter = 0;
|
|
28
|
+
// Constants for relation and line types (matching Mermaid.js)
|
|
29
|
+
this.relationType = {
|
|
30
|
+
AGGREGATION: 0,
|
|
31
|
+
EXTENSION: 1,
|
|
32
|
+
COMPOSITION: 2,
|
|
33
|
+
DEPENDENCY: 3,
|
|
34
|
+
LOLLIPOP: 4,
|
|
35
|
+
};
|
|
36
|
+
this.lineType = {
|
|
37
|
+
LINE: 0,
|
|
38
|
+
DOTTED_LINE: 1,
|
|
39
|
+
};
|
|
40
|
+
// Bind methods for JISON compatibility
|
|
41
|
+
this.addRelation = this.addRelation.bind(this);
|
|
42
|
+
this.addClassesToNamespace = this.addClassesToNamespace.bind(this);
|
|
43
|
+
this.addNamespace = this.addNamespace.bind(this);
|
|
44
|
+
this.setCssClass = this.setCssClass.bind(this);
|
|
45
|
+
this.addMembers = this.addMembers.bind(this);
|
|
46
|
+
this.addClass = this.addClass.bind(this);
|
|
47
|
+
this.setClassLabel = this.setClassLabel.bind(this);
|
|
48
|
+
this.addAnnotation = this.addAnnotation.bind(this);
|
|
49
|
+
this.addMember = this.addMember.bind(this);
|
|
50
|
+
this.cleanupLabel = this.cleanupLabel.bind(this);
|
|
51
|
+
this.addNote = this.addNote.bind(this);
|
|
52
|
+
this.defineClass = this.defineClass.bind(this);
|
|
53
|
+
this.setDirection = this.setDirection.bind(this);
|
|
54
|
+
this.setLink = this.setLink.bind(this);
|
|
55
|
+
this.setTooltip = this.setTooltip.bind(this);
|
|
56
|
+
this.setClickEvent = this.setClickEvent.bind(this);
|
|
57
|
+
this.setCssStyle = this.setCssStyle.bind(this);
|
|
58
|
+
this.setAccTitle = this.setAccTitle.bind(this);
|
|
59
|
+
this.setAccDescription = this.setAccDescription.bind(this);
|
|
60
|
+
}
|
|
61
|
+
splitClassNameAndType(_id) {
|
|
62
|
+
let genericType = '';
|
|
63
|
+
let className = _id;
|
|
64
|
+
if (_id.indexOf('~') > 0) {
|
|
65
|
+
const split = _id.split('~');
|
|
66
|
+
className = split[0];
|
|
67
|
+
genericType = split[1];
|
|
68
|
+
}
|
|
69
|
+
return { className: className, type: genericType };
|
|
70
|
+
}
|
|
71
|
+
// Core class methods
|
|
72
|
+
addClass(_id) {
|
|
73
|
+
// console.log(`Adding class: ${_id}`);
|
|
74
|
+
const { className, type } = this.splitClassNameAndType(_id);
|
|
75
|
+
if (!this.classes.has(className)) {
|
|
76
|
+
this.classes.set(className, {
|
|
77
|
+
id: className,
|
|
78
|
+
type: type,
|
|
79
|
+
label: className,
|
|
80
|
+
text: `${className}${type ? `<${type}>` : ''}`,
|
|
81
|
+
shape: 'classBox',
|
|
82
|
+
cssClasses: 'default',
|
|
83
|
+
methods: [],
|
|
84
|
+
members: [],
|
|
85
|
+
annotations: [],
|
|
86
|
+
styles: [],
|
|
87
|
+
domId: `classId-${className}-${Date.now()}`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
setClassLabel(_id, label) {
|
|
92
|
+
const { className } = this.splitClassNameAndType(_id);
|
|
93
|
+
const classInfo = this.classes.get(className);
|
|
94
|
+
if (classInfo) {
|
|
95
|
+
classInfo.label = label;
|
|
96
|
+
classInfo.text = `${label}${classInfo.type ? `<${classInfo.type}>` : ''}`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
addMember(className, member) {
|
|
100
|
+
// console.log(`Adding member to ${className}: ${member}`);
|
|
101
|
+
this.addClass(className);
|
|
102
|
+
const { className: validatedClassName } = this.splitClassNameAndType(className);
|
|
103
|
+
const classInfo = this.classes.get(validatedClassName);
|
|
104
|
+
if (classInfo && typeof member === 'string') {
|
|
105
|
+
const memberString = member.trim();
|
|
106
|
+
if (memberString.startsWith('<<') && memberString.endsWith('>>')) {
|
|
107
|
+
// It's an annotation
|
|
108
|
+
classInfo.annotations.push(memberString.substring(2, memberString.length - 2));
|
|
109
|
+
}
|
|
110
|
+
else if (memberString.indexOf(')') > 0) {
|
|
111
|
+
// It's a method
|
|
112
|
+
classInfo.methods.push({
|
|
113
|
+
id: `${validatedClassName}_method_${classInfo.methods.length}`,
|
|
114
|
+
name: memberString,
|
|
115
|
+
type: 'method',
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else if (memberString) {
|
|
119
|
+
// It's an attribute
|
|
120
|
+
classInfo.members.push({
|
|
121
|
+
id: `${validatedClassName}_member_${classInfo.members.length}`,
|
|
122
|
+
name: memberString,
|
|
123
|
+
type: 'attribute',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
addMembers(className, members) {
|
|
129
|
+
// console.log(`Adding members to ${className}:`, members);
|
|
130
|
+
if (Array.isArray(members)) {
|
|
131
|
+
members.reverse();
|
|
132
|
+
members.forEach((member) => this.addMember(className, member));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Annotation methods
|
|
136
|
+
addAnnotation(className, annotation) {
|
|
137
|
+
// console.log(`Adding annotation to ${className}: ${annotation}`);
|
|
138
|
+
const { className: validatedClassName } = this.splitClassNameAndType(className);
|
|
139
|
+
const classInfo = this.classes.get(validatedClassName);
|
|
140
|
+
if (classInfo) {
|
|
141
|
+
classInfo.annotations.push(annotation);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Relation methods
|
|
145
|
+
addRelation(relation) {
|
|
146
|
+
// console.log('Adding relation:', relation);
|
|
147
|
+
// Add classes if they don't exist
|
|
148
|
+
this.addClass(relation.id1);
|
|
149
|
+
this.addClass(relation.id2);
|
|
150
|
+
// Clean up class names
|
|
151
|
+
relation.id1 = this.splitClassNameAndType(relation.id1).className;
|
|
152
|
+
relation.id2 = this.splitClassNameAndType(relation.id2).className;
|
|
153
|
+
// Clean up relation titles
|
|
154
|
+
if (relation.relationTitle1) {
|
|
155
|
+
relation.relationTitle1 = relation.relationTitle1.trim();
|
|
156
|
+
}
|
|
157
|
+
if (relation.relationTitle2) {
|
|
158
|
+
relation.relationTitle2 = relation.relationTitle2.trim();
|
|
159
|
+
}
|
|
160
|
+
this.relations.push(relation);
|
|
161
|
+
}
|
|
162
|
+
// Namespace methods
|
|
163
|
+
addNamespace(id) {
|
|
164
|
+
// console.log(`Adding namespace: ${id}`);
|
|
165
|
+
if (!this.namespaces.has(id)) {
|
|
166
|
+
this.namespaces.set(id, {
|
|
167
|
+
id: id,
|
|
168
|
+
classes: new Map(),
|
|
169
|
+
children: {},
|
|
170
|
+
// eslint-disable-next-line no-plusplus
|
|
171
|
+
domId: `classId-${id}-${this.namespaceCounter++}`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
addClassesToNamespace(id, classNames) {
|
|
176
|
+
// console.log(`Adding classes to namespace ${id}:`, classNames);
|
|
177
|
+
if (!this.namespaces.has(id)) {
|
|
178
|
+
this.addNamespace(id);
|
|
179
|
+
}
|
|
180
|
+
const namespace = this.namespaces.get(id);
|
|
181
|
+
for (const name of classNames) {
|
|
182
|
+
const { className } = this.splitClassNameAndType(name);
|
|
183
|
+
const classInfo = this.classes.get(className);
|
|
184
|
+
if (classInfo) {
|
|
185
|
+
classInfo.parent = id;
|
|
186
|
+
namespace.classes.set(className, classInfo);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Note methods
|
|
191
|
+
addNote(text, className) {
|
|
192
|
+
this.notes.push({
|
|
193
|
+
text,
|
|
194
|
+
class: className,
|
|
195
|
+
id: `note${this.notes.length}`,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// Style and CSS methods
|
|
199
|
+
setCssClass(ids, className) {
|
|
200
|
+
// console.log(`Setting CSS class for ${ids}: ${className}`);
|
|
201
|
+
ids.split(',').forEach((_id) => {
|
|
202
|
+
const classInfo = this.classes.get(_id.trim());
|
|
203
|
+
if (classInfo) {
|
|
204
|
+
classInfo.cssClasses += ` ${className}`;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
setCssStyle(id, styles) {
|
|
209
|
+
// console.log(`Setting CSS style for ${id}:`, styles);
|
|
210
|
+
const classInfo = this.classes.get(id);
|
|
211
|
+
if (classInfo && styles) {
|
|
212
|
+
const styleArray = Array.isArray(styles) ? styles : [styles];
|
|
213
|
+
for (const s of styleArray) {
|
|
214
|
+
if (s.includes(',')) {
|
|
215
|
+
classInfo.styles.push(...s.split(','));
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
classInfo.styles.push(s);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
defineClass(ids, styles) {
|
|
224
|
+
// console.log(`Defining class styles for`, ids, ':', styles);
|
|
225
|
+
const idArray = Array.isArray(ids) ? ids : [ids];
|
|
226
|
+
for (const id of idArray) {
|
|
227
|
+
this.classDefs.set(id, styles.join(';'));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Interaction methods
|
|
231
|
+
setClickEvent(ids, functionName, functionArgs) {
|
|
232
|
+
// console.log(`Setting click event for ${ids}: ${functionName}${functionArgs ? ` with args: ${functionArgs}` : ''}`);
|
|
233
|
+
ids.split(',').forEach((id) => {
|
|
234
|
+
this.callbacks.set(id.trim(), { functionName, functionArgs });
|
|
235
|
+
const classInfo = this.classes.get(id.trim());
|
|
236
|
+
if (classInfo) {
|
|
237
|
+
classInfo.haveCallback = true;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
setLink(ids, link, target) {
|
|
242
|
+
// console.log(`Setting link for ${ids}: ${link}${target ? ` target: ${target}` : ''}`);
|
|
243
|
+
ids.split(',').forEach((id) => {
|
|
244
|
+
this.links.set(id.trim(), { link, target });
|
|
245
|
+
const classInfo = this.classes.get(id.trim());
|
|
246
|
+
if (classInfo) {
|
|
247
|
+
classInfo.link = link;
|
|
248
|
+
classInfo.linkTarget = target || '_blank';
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
setTooltip(ids, tooltip) {
|
|
253
|
+
// console.log(`Setting tooltip for ${ids}: ${tooltip}`);
|
|
254
|
+
ids.split(',').forEach((id) => {
|
|
255
|
+
if (tooltip !== undefined) {
|
|
256
|
+
this.tooltips.set(id.trim(), tooltip);
|
|
257
|
+
const classInfo = this.classes.get(id.trim());
|
|
258
|
+
if (classInfo) {
|
|
259
|
+
classInfo.tooltip = tooltip;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
// Accessibility methods
|
|
265
|
+
setAccTitle(title) {
|
|
266
|
+
// console.log(`Setting accessibility title: ${title}`);
|
|
267
|
+
this.accTitle = title;
|
|
268
|
+
}
|
|
269
|
+
setAccDescription(description) {
|
|
270
|
+
// console.log(`Setting accessibility description: ${description}`);
|
|
271
|
+
this.accDescription = description;
|
|
272
|
+
}
|
|
273
|
+
// Direction method
|
|
274
|
+
setDirection(dir) {
|
|
275
|
+
// console.log(`Setting direction: ${dir}`);
|
|
276
|
+
this.direction = dir;
|
|
277
|
+
}
|
|
278
|
+
// Utility methods
|
|
279
|
+
cleanupLabel(label) {
|
|
280
|
+
if (label.startsWith(':')) {
|
|
281
|
+
label = label.substring(1);
|
|
282
|
+
}
|
|
283
|
+
return label.replace(/^["']|["']$/g, '').trim();
|
|
284
|
+
}
|
|
285
|
+
// Get data methods
|
|
286
|
+
getClasses() {
|
|
287
|
+
return this.classes;
|
|
288
|
+
}
|
|
289
|
+
getRelations() {
|
|
290
|
+
return this.relations;
|
|
291
|
+
}
|
|
292
|
+
getNotes() {
|
|
293
|
+
return this.notes;
|
|
294
|
+
}
|
|
295
|
+
getNamespaces() {
|
|
296
|
+
return this.namespaces;
|
|
297
|
+
}
|
|
298
|
+
getDirection() {
|
|
299
|
+
return this.direction;
|
|
300
|
+
}
|
|
301
|
+
// Reset method
|
|
302
|
+
clear() {
|
|
303
|
+
this.classes.clear();
|
|
304
|
+
this.relations = [];
|
|
305
|
+
this.notes = [];
|
|
306
|
+
this.namespaces.clear();
|
|
307
|
+
this.accTitle = '';
|
|
308
|
+
this.accDescription = '';
|
|
309
|
+
this.direction = 'TB';
|
|
310
|
+
this.classDefs.clear();
|
|
311
|
+
this.callbacks.clear();
|
|
312
|
+
this.links.clear();
|
|
313
|
+
this.tooltips.clear();
|
|
314
|
+
this.interfaces = [];
|
|
315
|
+
this.functions = [];
|
|
316
|
+
this.styleClasses.clear();
|
|
317
|
+
this.namespaceCounter = 0;
|
|
318
|
+
}
|
|
319
|
+
// Export parsed data
|
|
320
|
+
exportData() {
|
|
321
|
+
return {
|
|
322
|
+
classes: fromEntries(this.classes),
|
|
323
|
+
relations: this.relations,
|
|
324
|
+
notes: this.notes,
|
|
325
|
+
namespaces: fromEntries(this.namespaces),
|
|
326
|
+
accTitle: this.accTitle,
|
|
327
|
+
accDescription: this.accDescription,
|
|
328
|
+
direction: this.direction,
|
|
329
|
+
classDefs: fromEntries(this.classDefs),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
exports.default = ClassDatabase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classDiagram.d.ts","sourceRoot":"","sources":["../../../../src/utils/mermaid-datasource/classDiagram.ts"],"names":[],"mappings":"AA6EA,QAAA,IAAI,MAAM,KAu4BN,CAAC;AAEJ,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,eAAe,MAAM,CAAC"}
|