@polagram/core 0.0.4 → 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/dist/index.d.ts +102 -113
- package/dist/polagram-core.js +1532 -1404
- package/dist/polagram-core.umd.cjs +22 -22
- package/package.json +3 -2
- package/dist/src/api.d.ts +0 -84
- package/dist/src/api.js +0 -183
- package/dist/src/ast/ast.test.d.ts +0 -1
- package/dist/src/ast/ast.test.js +0 -146
- package/dist/src/ast/index.d.ts +0 -119
- package/dist/src/ast/index.js +0 -2
- package/dist/src/config/index.d.ts +0 -1
- package/dist/src/config/index.js +0 -1
- package/dist/src/config/schema.d.ts +0 -198
- package/dist/src/config/schema.js +0 -82
- package/dist/src/config/schema.test.d.ts +0 -1
- package/dist/src/config/schema.test.js +0 -94
- package/dist/src/generator/base/walker.d.ts +0 -19
- package/dist/src/generator/base/walker.js +0 -56
- package/dist/src/generator/base/walker.test.d.ts +0 -1
- package/dist/src/generator/base/walker.test.js +0 -49
- package/dist/src/generator/generators/mermaid.d.ts +0 -24
- package/dist/src/generator/generators/mermaid.js +0 -140
- package/dist/src/generator/generators/mermaid.test.d.ts +0 -1
- package/dist/src/generator/generators/mermaid.test.js +0 -70
- package/dist/src/generator/generators/plantuml.d.ts +0 -17
- package/dist/src/generator/generators/plantuml.js +0 -131
- package/dist/src/generator/generators/plantuml.test.d.ts +0 -1
- package/dist/src/generator/generators/plantuml.test.js +0 -143
- package/dist/src/generator/interface.d.ts +0 -17
- package/dist/src/generator/interface.js +0 -1
- package/dist/src/index.d.ts +0 -13
- package/dist/src/index.js +0 -21
- package/dist/src/parser/base/lexer.d.ts +0 -18
- package/dist/src/parser/base/lexer.js +0 -95
- package/dist/src/parser/base/lexer.test.d.ts +0 -1
- package/dist/src/parser/base/lexer.test.js +0 -53
- package/dist/src/parser/base/parser.d.ts +0 -14
- package/dist/src/parser/base/parser.js +0 -43
- package/dist/src/parser/base/parser.test.d.ts +0 -1
- package/dist/src/parser/base/parser.test.js +0 -90
- package/dist/src/parser/base/token.d.ts +0 -18
- package/dist/src/parser/base/token.js +0 -1
- package/dist/src/parser/base/tokens.d.ts +0 -8
- package/dist/src/parser/base/tokens.js +0 -1
- package/dist/src/parser/format-detector.d.ts +0 -55
- package/dist/src/parser/format-detector.js +0 -98
- package/dist/src/parser/index.d.ts +0 -11
- package/dist/src/parser/index.js +0 -33
- package/dist/src/parser/index.test.d.ts +0 -1
- package/dist/src/parser/index.test.js +0 -23
- package/dist/src/parser/interface.d.ts +0 -8
- package/dist/src/parser/interface.js +0 -1
- package/dist/src/parser/languages/mermaid/constants.d.ts +0 -7
- package/dist/src/parser/languages/mermaid/constants.js +0 -20
- package/dist/src/parser/languages/mermaid/index.d.ts +0 -4
- package/dist/src/parser/languages/mermaid/index.js +0 -11
- package/dist/src/parser/languages/mermaid/lexer.d.ts +0 -14
- package/dist/src/parser/languages/mermaid/lexer.js +0 -152
- package/dist/src/parser/languages/mermaid/lexer.test.d.ts +0 -1
- package/dist/src/parser/languages/mermaid/lexer.test.js +0 -58
- package/dist/src/parser/languages/mermaid/parser.d.ts +0 -22
- package/dist/src/parser/languages/mermaid/parser.js +0 -340
- package/dist/src/parser/languages/mermaid/parser.test.d.ts +0 -1
- package/dist/src/parser/languages/mermaid/parser.test.js +0 -252
- package/dist/src/parser/languages/mermaid/tokens.d.ts +0 -9
- package/dist/src/parser/languages/mermaid/tokens.js +0 -1
- package/dist/src/parser/languages/plantuml/index.d.ts +0 -4
- package/dist/src/parser/languages/plantuml/index.js +0 -11
- package/dist/src/parser/languages/plantuml/lexer.d.ts +0 -15
- package/dist/src/parser/languages/plantuml/lexer.js +0 -143
- package/dist/src/parser/languages/plantuml/parser.d.ts +0 -23
- package/dist/src/parser/languages/plantuml/parser.js +0 -481
- package/dist/src/parser/languages/plantuml/parser.test.d.ts +0 -1
- package/dist/src/parser/languages/plantuml/parser.test.js +0 -236
- package/dist/src/parser/languages/plantuml/tokens.d.ts +0 -9
- package/dist/src/parser/languages/plantuml/tokens.js +0 -1
- package/dist/src/transformer/cleaners/prune-empty.d.ts +0 -9
- package/dist/src/transformer/cleaners/prune-empty.js +0 -27
- package/dist/src/transformer/cleaners/prune-empty.test.d.ts +0 -1
- package/dist/src/transformer/cleaners/prune-empty.test.js +0 -69
- package/dist/src/transformer/cleaners/prune-unused.d.ts +0 -5
- package/dist/src/transformer/cleaners/prune-unused.js +0 -48
- package/dist/src/transformer/cleaners/prune-unused.test.d.ts +0 -1
- package/dist/src/transformer/cleaners/prune-unused.test.js +0 -71
- package/dist/src/transformer/filters/focus.d.ts +0 -13
- package/dist/src/transformer/filters/focus.js +0 -71
- package/dist/src/transformer/filters/focus.test.d.ts +0 -1
- package/dist/src/transformer/filters/focus.test.js +0 -50
- package/dist/src/transformer/filters/remove.d.ts +0 -12
- package/dist/src/transformer/filters/remove.js +0 -82
- package/dist/src/transformer/filters/remove.test.d.ts +0 -1
- package/dist/src/transformer/filters/remove.test.js +0 -38
- package/dist/src/transformer/filters/resolve.d.ts +0 -9
- package/dist/src/transformer/filters/resolve.js +0 -32
- package/dist/src/transformer/filters/resolve.test.d.ts +0 -1
- package/dist/src/transformer/filters/resolve.test.js +0 -48
- package/dist/src/transformer/index.d.ts +0 -10
- package/dist/src/transformer/index.js +0 -10
- package/dist/src/transformer/lens.d.ts +0 -12
- package/dist/src/transformer/lens.js +0 -58
- package/dist/src/transformer/lens.test.d.ts +0 -1
- package/dist/src/transformer/lens.test.js +0 -60
- package/dist/src/transformer/orchestration/engine.d.ts +0 -5
- package/dist/src/transformer/orchestration/engine.js +0 -24
- package/dist/src/transformer/orchestration/engine.test.d.ts +0 -1
- package/dist/src/transformer/orchestration/engine.test.js +0 -52
- package/dist/src/transformer/orchestration/registry.d.ts +0 -10
- package/dist/src/transformer/orchestration/registry.js +0 -27
- package/dist/src/transformer/selector/matcher.d.ts +0 -9
- package/dist/src/transformer/selector/matcher.js +0 -62
- package/dist/src/transformer/selector/matcher.test.d.ts +0 -1
- package/dist/src/transformer/selector/matcher.test.js +0 -70
- package/dist/src/transformer/traverse/walker.d.ts +0 -14
- package/dist/src/transformer/traverse/walker.js +0 -67
- package/dist/src/transformer/traverse/walker.test.d.ts +0 -1
- package/dist/src/transformer/traverse/walker.test.js +0 -111
- package/dist/src/transformer/types.d.ts +0 -47
- package/dist/src/transformer/types.js +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polagram/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"build": "tsc && vite build",
|
|
35
35
|
"test": "vitest run",
|
|
36
36
|
"test:watch": "vitest",
|
|
37
|
-
"
|
|
37
|
+
"lint": "biome lint .",
|
|
38
|
+
"gen:docs": "node ../cli/dist/index.js generate -c docs/sequence/polagram.yml"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/js-yaml": "^4.0.9",
|
package/dist/src/api.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { PolagramRoot } from './ast';
|
|
2
|
-
import { FragmentSelector, GroupSelector, Lens, MessageSelector, ParticipantSelector, TextMatcher } from './transformer/types';
|
|
3
|
-
/**
|
|
4
|
-
* Polagram Fluent API
|
|
5
|
-
*
|
|
6
|
-
* Provides a high-level, chainable interface for transformations.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const result = Polagram.init(mermaidCode)
|
|
10
|
-
* .focusParticipant('PaymentService')
|
|
11
|
-
* .removeParticipant('DebugLogger')
|
|
12
|
-
* .toMermaid();
|
|
13
|
-
*/
|
|
14
|
-
export declare class Polagram {
|
|
15
|
-
private constructor();
|
|
16
|
-
/**
|
|
17
|
-
* Initialize a new Polagram transformation pipeline.
|
|
18
|
-
* @param code Source diagram code
|
|
19
|
-
* @param format Input format ('mermaid' or 'plantuml')
|
|
20
|
-
*/
|
|
21
|
-
static init(code: string, format?: 'mermaid' | 'plantuml'): PolagramBuilder;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Builder class for chaining transformations.
|
|
25
|
-
*/
|
|
26
|
-
export declare class PolagramBuilder {
|
|
27
|
-
private ast;
|
|
28
|
-
private layers;
|
|
29
|
-
private sourceFormat;
|
|
30
|
-
constructor(ast: PolagramRoot, sourceFormat?: 'mermaid' | 'plantuml');
|
|
31
|
-
/**
|
|
32
|
-
* Focus on specific participants.
|
|
33
|
-
* Keeps only interactions involving the matched participants.
|
|
34
|
-
* @param selector Name (string/RegExp) or detailed ParticipantSelector
|
|
35
|
-
*/
|
|
36
|
-
focusParticipant(selector: TextMatcher | Partial<ParticipantSelector>): this;
|
|
37
|
-
/**
|
|
38
|
-
* Remove specific participants and their interactions.
|
|
39
|
-
* @param selector Name (string/RegExp) or detailed ParticipantSelector
|
|
40
|
-
*/
|
|
41
|
-
removeParticipant(selector: TextMatcher | Partial<ParticipantSelector>): this;
|
|
42
|
-
/**
|
|
43
|
-
* Remove specific messages.
|
|
44
|
-
* @param selector Message text (string/RegExp) or detailed MessageSelector
|
|
45
|
-
*/
|
|
46
|
-
removeMessage(selector: TextMatcher | Partial<MessageSelector>): this;
|
|
47
|
-
/**
|
|
48
|
-
* Remove specific groups (visual boxes).
|
|
49
|
-
* @param selector Group name (string/RegExp) or detailed GroupSelector
|
|
50
|
-
*/
|
|
51
|
-
removeGroup(selector: TextMatcher | Partial<GroupSelector>): this;
|
|
52
|
-
/**
|
|
53
|
-
* Resolve (unwrap) specific fragments like 'alt', 'opt', 'loop'.
|
|
54
|
-
* Promotes the content of the matched branch and removes the wrapper.
|
|
55
|
-
* @param selector Condition text (string/RegExp) or detailed FragmentSelector
|
|
56
|
-
*/
|
|
57
|
-
resolveFragment(selector: TextMatcher | Partial<FragmentSelector>): this;
|
|
58
|
-
/**
|
|
59
|
-
* Apply a Lens (a named set of transformation layers).
|
|
60
|
-
* @param lens Lens object containing layers
|
|
61
|
-
*/
|
|
62
|
-
applyLens(lens: Lens): this;
|
|
63
|
-
/**
|
|
64
|
-
* Generate Mermaid code from the transformed AST.
|
|
65
|
-
*/
|
|
66
|
-
toMermaid(): string;
|
|
67
|
-
/**
|
|
68
|
-
* Generate PlantUML code from the transformed AST.
|
|
69
|
-
*/
|
|
70
|
-
toPlantUML(): string;
|
|
71
|
-
/**
|
|
72
|
-
* Get the transformed AST (for advanced use cases).
|
|
73
|
-
*/
|
|
74
|
-
toAST(): PolagramRoot;
|
|
75
|
-
/**
|
|
76
|
-
* Get the source format detected/specified during init.
|
|
77
|
-
*/
|
|
78
|
-
getSourceFormat(): 'mermaid' | 'plantuml';
|
|
79
|
-
private normalizeParticipantSelector;
|
|
80
|
-
private normalizeMessageSelector;
|
|
81
|
-
private normalizeGroupSelector;
|
|
82
|
-
private normalizeFragmentSelector;
|
|
83
|
-
private isTextMatcher;
|
|
84
|
-
}
|
package/dist/src/api.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { MermaidGeneratorVisitor } from './generator/generators/mermaid';
|
|
2
|
-
import { PlantUMLGeneratorVisitor } from './generator/generators/plantuml';
|
|
3
|
-
import { ParserFactory } from './parser';
|
|
4
|
-
import { TransformationEngine } from './transformer/orchestration/engine';
|
|
5
|
-
/**
|
|
6
|
-
* Polagram Fluent API
|
|
7
|
-
*
|
|
8
|
-
* Provides a high-level, chainable interface for transformations.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const result = Polagram.init(mermaidCode)
|
|
12
|
-
* .focusParticipant('PaymentService')
|
|
13
|
-
* .removeParticipant('DebugLogger')
|
|
14
|
-
* .toMermaid();
|
|
15
|
-
*/
|
|
16
|
-
export class Polagram {
|
|
17
|
-
constructor() { }
|
|
18
|
-
/**
|
|
19
|
-
* Initialize a new Polagram transformation pipeline.
|
|
20
|
-
* @param code Source diagram code
|
|
21
|
-
* @param format Input format ('mermaid' or 'plantuml')
|
|
22
|
-
*/
|
|
23
|
-
static init(code, format = 'mermaid') {
|
|
24
|
-
const parser = ParserFactory.getParser(format);
|
|
25
|
-
const ast = parser.parse(code);
|
|
26
|
-
return new PolagramBuilder(ast, format);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Builder class for chaining transformations.
|
|
31
|
-
*/
|
|
32
|
-
export class PolagramBuilder {
|
|
33
|
-
constructor(ast, sourceFormat = 'mermaid') {
|
|
34
|
-
Object.defineProperty(this, "ast", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: void 0
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(this, "layers", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true,
|
|
44
|
-
value: []
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(this, "sourceFormat", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: void 0
|
|
51
|
-
});
|
|
52
|
-
this.ast = ast;
|
|
53
|
-
this.sourceFormat = sourceFormat;
|
|
54
|
-
}
|
|
55
|
-
// -- Entity Filtering --
|
|
56
|
-
/**
|
|
57
|
-
* Focus on specific participants.
|
|
58
|
-
* Keeps only interactions involving the matched participants.
|
|
59
|
-
* @param selector Name (string/RegExp) or detailed ParticipantSelector
|
|
60
|
-
*/
|
|
61
|
-
focusParticipant(selector) {
|
|
62
|
-
this.layers.push({
|
|
63
|
-
action: 'focus',
|
|
64
|
-
selector: this.normalizeParticipantSelector(selector)
|
|
65
|
-
});
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Remove specific participants and their interactions.
|
|
70
|
-
* @param selector Name (string/RegExp) or detailed ParticipantSelector
|
|
71
|
-
*/
|
|
72
|
-
removeParticipant(selector) {
|
|
73
|
-
this.layers.push({
|
|
74
|
-
action: 'remove',
|
|
75
|
-
selector: this.normalizeParticipantSelector(selector)
|
|
76
|
-
});
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
// -- Message Filtering --
|
|
80
|
-
/**
|
|
81
|
-
* Remove specific messages.
|
|
82
|
-
* @param selector Message text (string/RegExp) or detailed MessageSelector
|
|
83
|
-
*/
|
|
84
|
-
removeMessage(selector) {
|
|
85
|
-
this.layers.push({
|
|
86
|
-
action: 'remove',
|
|
87
|
-
selector: this.normalizeMessageSelector(selector)
|
|
88
|
-
});
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
// -- Group Filtering --
|
|
92
|
-
/**
|
|
93
|
-
* Remove specific groups (visual boxes).
|
|
94
|
-
* @param selector Group name (string/RegExp) or detailed GroupSelector
|
|
95
|
-
*/
|
|
96
|
-
removeGroup(selector) {
|
|
97
|
-
this.layers.push({
|
|
98
|
-
action: 'remove',
|
|
99
|
-
selector: this.normalizeGroupSelector(selector)
|
|
100
|
-
});
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
// -- Structural Resolution --
|
|
104
|
-
/**
|
|
105
|
-
* Resolve (unwrap) specific fragments like 'alt', 'opt', 'loop'.
|
|
106
|
-
* Promotes the content of the matched branch and removes the wrapper.
|
|
107
|
-
* @param selector Condition text (string/RegExp) or detailed FragmentSelector
|
|
108
|
-
*/
|
|
109
|
-
resolveFragment(selector) {
|
|
110
|
-
this.layers.push({
|
|
111
|
-
action: 'resolve',
|
|
112
|
-
selector: this.normalizeFragmentSelector(selector)
|
|
113
|
-
});
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Apply a Lens (a named set of transformation layers).
|
|
118
|
-
* @param lens Lens object containing layers
|
|
119
|
-
*/
|
|
120
|
-
applyLens(lens) {
|
|
121
|
-
this.layers.push(...lens.layers);
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Generate Mermaid code from the transformed AST.
|
|
126
|
-
*/
|
|
127
|
-
toMermaid() {
|
|
128
|
-
const engine = new TransformationEngine();
|
|
129
|
-
const transformedAst = engine.transform(this.ast, this.layers);
|
|
130
|
-
const generator = new MermaidGeneratorVisitor();
|
|
131
|
-
return generator.generate(transformedAst);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Generate PlantUML code from the transformed AST.
|
|
135
|
-
*/
|
|
136
|
-
toPlantUML() {
|
|
137
|
-
const engine = new TransformationEngine();
|
|
138
|
-
const transformedAst = engine.transform(this.ast, this.layers);
|
|
139
|
-
const generator = new PlantUMLGeneratorVisitor();
|
|
140
|
-
return generator.generate(transformedAst);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get the transformed AST (for advanced use cases).
|
|
144
|
-
*/
|
|
145
|
-
toAST() {
|
|
146
|
-
const engine = new TransformationEngine();
|
|
147
|
-
return engine.transform(this.ast, this.layers);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get the source format detected/specified during init.
|
|
151
|
-
*/
|
|
152
|
-
getSourceFormat() {
|
|
153
|
-
return this.sourceFormat;
|
|
154
|
-
}
|
|
155
|
-
// -- Helper Methods --
|
|
156
|
-
normalizeParticipantSelector(selector) {
|
|
157
|
-
if (this.isTextMatcher(selector)) {
|
|
158
|
-
return { kind: 'participant', name: selector };
|
|
159
|
-
}
|
|
160
|
-
return { kind: 'participant', ...selector };
|
|
161
|
-
}
|
|
162
|
-
normalizeMessageSelector(selector) {
|
|
163
|
-
if (this.isTextMatcher(selector)) {
|
|
164
|
-
return { kind: 'message', text: selector };
|
|
165
|
-
}
|
|
166
|
-
return { kind: 'message', ...selector };
|
|
167
|
-
}
|
|
168
|
-
normalizeGroupSelector(selector) {
|
|
169
|
-
if (this.isTextMatcher(selector)) {
|
|
170
|
-
return { kind: 'group', name: selector };
|
|
171
|
-
}
|
|
172
|
-
return { kind: 'group', ...selector };
|
|
173
|
-
}
|
|
174
|
-
normalizeFragmentSelector(selector) {
|
|
175
|
-
if (this.isTextMatcher(selector)) {
|
|
176
|
-
return { kind: 'fragment', condition: selector };
|
|
177
|
-
}
|
|
178
|
-
return { kind: 'fragment', ...selector };
|
|
179
|
-
}
|
|
180
|
-
isTextMatcher(val) {
|
|
181
|
-
return typeof val === 'string' || val instanceof RegExp || (typeof val === 'object' && val !== null && 'pattern' in val && !('kind' in val));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/ast/ast.test.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// packages/core/test/complex_ast_example.test.ts
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
describe('Polagram AST Definition', () => {
|
|
4
|
-
it('should support a complex lossless scenario', () => {
|
|
5
|
-
// This "Rosetta Stone" object attempts to use ALL new features
|
|
6
|
-
// to prove they are correctly typed and coexist.
|
|
7
|
-
const complexAst = {
|
|
8
|
-
kind: 'root',
|
|
9
|
-
meta: {
|
|
10
|
-
version: '1.0.0',
|
|
11
|
-
source: 'plantuml',
|
|
12
|
-
title: 'Complex Order System',
|
|
13
|
-
theme: {
|
|
14
|
-
participantPadding: '10'
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
groups: [
|
|
18
|
-
{
|
|
19
|
-
kind: 'group',
|
|
20
|
-
id: 'g_1',
|
|
21
|
-
name: 'AWS Cloud',
|
|
22
|
-
type: 'box',
|
|
23
|
-
participantIds: ['p_db', 'p_sqs'],
|
|
24
|
-
style: { backgroundColor: '#f0f0f0' }
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
participants: [
|
|
28
|
-
{
|
|
29
|
-
id: 'p_user',
|
|
30
|
-
name: 'User',
|
|
31
|
-
type: 'actor'
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: 'p_api',
|
|
35
|
-
name: 'API Gateway',
|
|
36
|
-
type: 'control'
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'p_sqs',
|
|
40
|
-
name: 'Order Queue',
|
|
41
|
-
type: 'queue'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: 'p_db',
|
|
45
|
-
name: 'DynamoDB',
|
|
46
|
-
type: 'database'
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
events: [
|
|
50
|
-
// 1. Found message (from unknown)
|
|
51
|
-
{
|
|
52
|
-
kind: 'message',
|
|
53
|
-
id: 'm_1',
|
|
54
|
-
from: null,
|
|
55
|
-
to: 'p_user',
|
|
56
|
-
text: 'User lands on page',
|
|
57
|
-
type: 'sync',
|
|
58
|
-
style: { line: 'solid', head: 'arrow' }
|
|
59
|
-
},
|
|
60
|
-
// 2. Activation independent of message
|
|
61
|
-
{
|
|
62
|
-
kind: 'activation',
|
|
63
|
-
participantId: 'p_user',
|
|
64
|
-
action: 'activate'
|
|
65
|
-
},
|
|
66
|
-
// 3. Message with lifecycle
|
|
67
|
-
{
|
|
68
|
-
kind: 'message',
|
|
69
|
-
id: 'm_2',
|
|
70
|
-
from: 'p_user',
|
|
71
|
-
to: 'p_api',
|
|
72
|
-
text: 'POST /order',
|
|
73
|
-
type: 'sync',
|
|
74
|
-
style: { line: 'solid', head: 'arrow' },
|
|
75
|
-
lifecycle: { activateTarget: true }
|
|
76
|
-
},
|
|
77
|
-
// 4. Create message (Lifecycle)
|
|
78
|
-
{
|
|
79
|
-
kind: 'message',
|
|
80
|
-
id: 'm_3',
|
|
81
|
-
from: 'p_api',
|
|
82
|
-
to: 'p_sqs',
|
|
83
|
-
text: 'new OrderMessage()',
|
|
84
|
-
type: 'create', // Explicit create
|
|
85
|
-
style: { line: 'dotted', head: 'arrow' }
|
|
86
|
-
},
|
|
87
|
-
// 5. Visual Divider
|
|
88
|
-
{
|
|
89
|
-
kind: 'divider',
|
|
90
|
-
id: 'd_1',
|
|
91
|
-
text: 'Async Processing'
|
|
92
|
-
},
|
|
93
|
-
// 6. Visual Spacer (Delay)
|
|
94
|
-
{
|
|
95
|
-
kind: 'spacer',
|
|
96
|
-
id: 's_1',
|
|
97
|
-
text: '... 5 seconds later ...'
|
|
98
|
-
},
|
|
99
|
-
// 7. Grouping/Fragment (Loop)
|
|
100
|
-
{
|
|
101
|
-
kind: 'fragment',
|
|
102
|
-
id: 'f_1',
|
|
103
|
-
operator: 'loop',
|
|
104
|
-
branches: [
|
|
105
|
-
{
|
|
106
|
-
id: 'b_1',
|
|
107
|
-
condition: 'Every 1s',
|
|
108
|
-
events: [
|
|
109
|
-
{
|
|
110
|
-
kind: 'message',
|
|
111
|
-
id: 'm_poll',
|
|
112
|
-
from: 'p_db',
|
|
113
|
-
to: 'p_sqs',
|
|
114
|
-
text: 'Check items',
|
|
115
|
-
type: 'sync',
|
|
116
|
-
style: { line: 'solid', head: 'arrow' }
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
// 8. Reference (Ref)
|
|
123
|
-
{
|
|
124
|
-
kind: 'ref',
|
|
125
|
-
id: 'r_1',
|
|
126
|
-
text: 'Payment Processing',
|
|
127
|
-
link: 'payment.mermaid',
|
|
128
|
-
participantIds: ['p_api', 'p_db']
|
|
129
|
-
},
|
|
130
|
-
// 9. Destroy (Lifecycle)
|
|
131
|
-
{
|
|
132
|
-
kind: 'message',
|
|
133
|
-
id: 'm_del',
|
|
134
|
-
from: 'p_api',
|
|
135
|
-
to: 'p_sqs',
|
|
136
|
-
text: 'delete',
|
|
137
|
-
type: 'destroy',
|
|
138
|
-
style: { line: 'solid', head: 'cross' } // X marker
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
};
|
|
142
|
-
expect(complexAst).toBeTruthy();
|
|
143
|
-
expect(complexAst.participants.length).toBe(4);
|
|
144
|
-
expect(complexAst.events.length).toBe(9);
|
|
145
|
-
});
|
|
146
|
-
});
|
package/dist/src/ast/index.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Polagram Abstract Syntax Tree (AST) Definitions
|
|
3
|
-
*
|
|
4
|
-
* Designed to be a lossless representation of Sequence Diagrams from:
|
|
5
|
-
* - Mermaid
|
|
6
|
-
* - PlantUML
|
|
7
|
-
*
|
|
8
|
-
* It captures structure, semantics (lifecycle, grouping), and necessary visual hints.
|
|
9
|
-
*/
|
|
10
|
-
export interface PolagramRoot {
|
|
11
|
-
kind: 'root';
|
|
12
|
-
meta: MetaData;
|
|
13
|
-
participants: Participant[];
|
|
14
|
-
groups: ParticipantGroup[];
|
|
15
|
-
events: EventNode[];
|
|
16
|
-
}
|
|
17
|
-
export interface MetaData {
|
|
18
|
-
version: string;
|
|
19
|
-
source: 'mermaid' | 'plantuml' | 'unknown';
|
|
20
|
-
title?: string;
|
|
21
|
-
theme?: Record<string, string>;
|
|
22
|
-
}
|
|
23
|
-
export interface Participant {
|
|
24
|
-
id: string;
|
|
25
|
-
name: string;
|
|
26
|
-
alias?: string;
|
|
27
|
-
type: ParticipantType;
|
|
28
|
-
stereotype?: string;
|
|
29
|
-
style?: StyleProps;
|
|
30
|
-
}
|
|
31
|
-
export type ParticipantType = 'participant' | 'actor' | 'boundary' | 'control' | 'entity' | 'database' | 'collections' | 'queue';
|
|
32
|
-
export interface ParticipantGroup {
|
|
33
|
-
kind: 'group';
|
|
34
|
-
id: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
type?: string;
|
|
37
|
-
participantIds: string[];
|
|
38
|
-
style?: StyleProps;
|
|
39
|
-
}
|
|
40
|
-
export type EventNode = MessageNode | FragmentNode | NoteNode | DividerNode | ActivationNode | ReferenceNode | SpacerNode;
|
|
41
|
-
export type MessageEndpoint = string | null;
|
|
42
|
-
/**
|
|
43
|
-
* Represents a directional interaction.
|
|
44
|
-
* Includes standard sync/async calls, returns, and object creation/deletion.
|
|
45
|
-
*/
|
|
46
|
-
export interface MessageNode {
|
|
47
|
-
kind: 'message';
|
|
48
|
-
id: string;
|
|
49
|
-
from: MessageEndpoint;
|
|
50
|
-
to: MessageEndpoint;
|
|
51
|
-
text: string;
|
|
52
|
-
type: 'sync' | 'async' | 'reply' | 'create' | 'destroy';
|
|
53
|
-
style: {
|
|
54
|
-
line: 'solid' | 'dotted';
|
|
55
|
-
head: 'arrow' | 'async' | 'open' | 'cross';
|
|
56
|
-
color?: string;
|
|
57
|
-
};
|
|
58
|
-
lifecycle?: {
|
|
59
|
-
activateTarget?: boolean;
|
|
60
|
-
deactivateSource?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export interface FragmentNode {
|
|
64
|
-
kind: 'fragment';
|
|
65
|
-
id: string;
|
|
66
|
-
operator: FragmentOperator;
|
|
67
|
-
branches: FragmentBranch[];
|
|
68
|
-
}
|
|
69
|
-
export type FragmentOperator = 'alt' | 'opt' | 'loop' | 'par' | 'break' | 'critical' | 'rect' | 'group';
|
|
70
|
-
export interface FragmentBranch {
|
|
71
|
-
id: string;
|
|
72
|
-
condition?: string;
|
|
73
|
-
events: EventNode[];
|
|
74
|
-
}
|
|
75
|
-
export interface NoteNode {
|
|
76
|
-
kind: 'note';
|
|
77
|
-
id: string;
|
|
78
|
-
text: string;
|
|
79
|
-
position: 'left' | 'right' | 'over';
|
|
80
|
-
participantIds: string[];
|
|
81
|
-
style?: StyleProps;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Independent activation/deactivation not tied to a specific message line.
|
|
85
|
-
* e.g., Mermaid "activate A", PlantUML "activate A"
|
|
86
|
-
*/
|
|
87
|
-
export interface ActivationNode {
|
|
88
|
-
kind: 'activation';
|
|
89
|
-
participantId: string;
|
|
90
|
-
action: 'activate' | 'deactivate';
|
|
91
|
-
style?: StyleProps;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Refers to another sequence diagram or a frame covering participants.
|
|
95
|
-
* e.g., PlantUML "ref over A, B : Init"
|
|
96
|
-
*/
|
|
97
|
-
export interface ReferenceNode {
|
|
98
|
-
kind: 'ref';
|
|
99
|
-
id: string;
|
|
100
|
-
text: string;
|
|
101
|
-
participantIds: string[];
|
|
102
|
-
link?: string;
|
|
103
|
-
}
|
|
104
|
-
export interface DividerNode {
|
|
105
|
-
kind: 'divider';
|
|
106
|
-
id: string;
|
|
107
|
-
text?: string;
|
|
108
|
-
}
|
|
109
|
-
export interface SpacerNode {
|
|
110
|
-
kind: 'spacer';
|
|
111
|
-
id: string;
|
|
112
|
-
height?: number;
|
|
113
|
-
text?: string;
|
|
114
|
-
}
|
|
115
|
-
export interface StyleProps {
|
|
116
|
-
color?: string;
|
|
117
|
-
backgroundColor?: string;
|
|
118
|
-
shape?: string;
|
|
119
|
-
}
|
package/dist/src/ast/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './schema';
|
package/dist/src/config/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './schema';
|