@polagram/core 0.0.3 → 0.0.4
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 +104 -6
- package/dist/polagram-core.js +2689 -2157
- package/dist/polagram-core.umd.cjs +20 -14
- package/dist/src/api.d.ts +12 -3
- package/dist/src/api.js +26 -3
- package/dist/src/config/schema.d.ts +16 -0
- package/dist/src/config/schema.js +5 -1
- package/dist/src/generator/generators/plantuml.d.ts +17 -0
- package/dist/src/generator/generators/plantuml.js +131 -0
- package/dist/src/generator/generators/plantuml.test.d.ts +1 -0
- package/dist/src/generator/generators/plantuml.test.js +143 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +4 -0
- package/dist/src/parser/base/lexer.d.ts +3 -3
- package/dist/src/parser/base/parser.d.ts +9 -9
- package/dist/src/parser/base/token.d.ts +18 -0
- package/dist/src/parser/base/token.js +1 -0
- package/dist/src/parser/base/tokens.d.ts +8 -0
- package/dist/src/parser/base/tokens.js +1 -0
- package/dist/src/parser/format-detector.d.ts +55 -0
- package/dist/src/parser/format-detector.js +98 -0
- package/dist/src/parser/index.d.ts +1 -0
- package/dist/src/parser/index.js +4 -0
- package/dist/src/parser/languages/mermaid/lexer.d.ts +1 -1
- package/dist/src/parser/languages/mermaid/parser.d.ts +2 -1
- package/dist/src/parser/languages/plantuml/index.d.ts +4 -0
- package/dist/src/parser/languages/plantuml/index.js +11 -0
- package/dist/src/parser/languages/plantuml/lexer.d.ts +15 -0
- package/dist/src/parser/languages/plantuml/lexer.js +143 -0
- package/dist/src/parser/languages/plantuml/parser.d.ts +23 -0
- package/dist/src/parser/languages/plantuml/parser.js +481 -0
- package/dist/src/parser/languages/plantuml/parser.test.d.ts +1 -0
- package/dist/src/parser/languages/plantuml/parser.test.js +236 -0
- package/dist/src/parser/languages/plantuml/tokens.d.ts +9 -0
- package/dist/src/parser/languages/plantuml/tokens.js +1 -0
- package/dist/src/transformer/orchestration/engine.test.js +12 -1
- package/dist/src/transformer/selector/matcher.test.js +17 -0
- package/dist/src/transformer/traverse/walker.test.js +67 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare interface ActivationNode {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function applyLens(root: PolagramRoot, lens: Lens): PolagramRoot;
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Supported diagram formats
|
|
22
|
+
*/
|
|
23
|
+
export declare type DiagramFormat = 'mermaid' | 'plantuml';
|
|
24
|
+
|
|
20
25
|
/**
|
|
21
26
|
* Strategy Interface for Diagram Parsing.
|
|
22
27
|
* Implements the Strategy Pattern: different formats implement this interface.
|
|
@@ -49,6 +54,58 @@ export declare interface FocusLayer {
|
|
|
49
54
|
selector: ParticipantSelector;
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Format detection utilities for diagram source code.
|
|
59
|
+
* Detects diagram format based on file extension and content analysis.
|
|
60
|
+
*/
|
|
61
|
+
export declare class FormatDetector {
|
|
62
|
+
/**
|
|
63
|
+
* File extensions mapped to their diagram formats
|
|
64
|
+
*/
|
|
65
|
+
private static readonly EXTENSION_MAP;
|
|
66
|
+
/**
|
|
67
|
+
* Content patterns for format detection
|
|
68
|
+
*/
|
|
69
|
+
private static readonly CONTENT_PATTERNS;
|
|
70
|
+
/**
|
|
71
|
+
* Detect diagram format from file path and content.
|
|
72
|
+
*
|
|
73
|
+
* @param filePath - Path to the diagram file
|
|
74
|
+
* @param content - Content of the diagram file
|
|
75
|
+
* @returns Detected format, or null if format cannot be determined
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const format = FormatDetector.detect('diagram.puml', content);
|
|
80
|
+
* if (format === 'plantuml') {
|
|
81
|
+
* // Process as PlantUML
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
static detect(filePath: string, content: string): DiagramFormat | null;
|
|
86
|
+
/**
|
|
87
|
+
* Detect format based on file extension.
|
|
88
|
+
*
|
|
89
|
+
* @param filePath - Path to the diagram file
|
|
90
|
+
* @returns Detected format, or null if extension is not recognized
|
|
91
|
+
*/
|
|
92
|
+
static detectByExtension(filePath: string): DiagramFormat | null;
|
|
93
|
+
/**
|
|
94
|
+
* Detect format based on content patterns.
|
|
95
|
+
*
|
|
96
|
+
* @param content - Content of the diagram file
|
|
97
|
+
* @returns Detected format, or null if no pattern matches
|
|
98
|
+
*/
|
|
99
|
+
static detectByContent(content: string): DiagramFormat | null;
|
|
100
|
+
/**
|
|
101
|
+
* Get file extension for a given format.
|
|
102
|
+
*
|
|
103
|
+
* @param format - Diagram format
|
|
104
|
+
* @returns Default file extension for the format
|
|
105
|
+
*/
|
|
106
|
+
static getDefaultExtension(format: DiagramFormat): string;
|
|
107
|
+
}
|
|
108
|
+
|
|
52
109
|
export declare interface FragmentBranch {
|
|
53
110
|
id: string;
|
|
54
111
|
condition?: string;
|
|
@@ -90,9 +147,9 @@ declare const LensSchema: z.ZodObject<{
|
|
|
90
147
|
suffix: z.ZodOptional<z.ZodString>;
|
|
91
148
|
layers: z.ZodArray<z.ZodObject<{
|
|
92
149
|
action: z.ZodEnum<{
|
|
93
|
-
resolve: "resolve";
|
|
94
150
|
focus: "focus";
|
|
95
151
|
remove: "remove";
|
|
152
|
+
resolve: "resolve";
|
|
96
153
|
}>;
|
|
97
154
|
selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
98
155
|
kind: z.ZodLiteral<"fragment">;
|
|
@@ -254,6 +311,22 @@ export declare interface ParticipantSelector {
|
|
|
254
311
|
|
|
255
312
|
export declare type ParticipantType = 'participant' | 'actor' | 'boundary' | 'control' | 'entity' | 'database' | 'collections' | 'queue';
|
|
256
313
|
|
|
314
|
+
export declare class PlantUMLGeneratorVisitor implements PolagramVisitor {
|
|
315
|
+
generate(root: PolagramRoot): string;
|
|
316
|
+
visitRoot(node: PolagramRoot): string;
|
|
317
|
+
visitParticipant(node: Participant): string;
|
|
318
|
+
visitGroup(node: ParticipantGroup, context?: Map<string, Participant>): string;
|
|
319
|
+
visitMessage(node: MessageNode): string;
|
|
320
|
+
visitFragment(node: FragmentNode): string;
|
|
321
|
+
private visitEvent;
|
|
322
|
+
visitNote(node: NoteNode): string;
|
|
323
|
+
visitActivation(node: ActivationNode): string;
|
|
324
|
+
visitParticipantGroup(_node: ParticipantGroup): string;
|
|
325
|
+
visitDivider(_node: DividerNode): string;
|
|
326
|
+
visitSpacer(_node: SpacerNode): string;
|
|
327
|
+
visitReference(_node: ReferenceNode): string;
|
|
328
|
+
}
|
|
329
|
+
|
|
257
330
|
/**
|
|
258
331
|
* Polagram Fluent API
|
|
259
332
|
*
|
|
@@ -270,9 +343,9 @@ export declare class Polagram {
|
|
|
270
343
|
/**
|
|
271
344
|
* Initialize a new Polagram transformation pipeline.
|
|
272
345
|
* @param code Source diagram code
|
|
273
|
-
* @param format Input format (
|
|
346
|
+
* @param format Input format ('mermaid' or 'plantuml')
|
|
274
347
|
*/
|
|
275
|
-
static init(code: string, format?: 'mermaid'): PolagramBuilder;
|
|
348
|
+
static init(code: string, format?: 'mermaid' | 'plantuml'): PolagramBuilder;
|
|
276
349
|
}
|
|
277
350
|
|
|
278
351
|
/**
|
|
@@ -281,7 +354,8 @@ export declare class Polagram {
|
|
|
281
354
|
export declare class PolagramBuilder {
|
|
282
355
|
private ast;
|
|
283
356
|
private layers;
|
|
284
|
-
|
|
357
|
+
private sourceFormat;
|
|
358
|
+
constructor(ast: PolagramRoot, sourceFormat?: 'mermaid' | 'plantuml');
|
|
285
359
|
/**
|
|
286
360
|
* Focus on specific participants.
|
|
287
361
|
* Keeps only interactions involving the matched participants.
|
|
@@ -318,10 +392,18 @@ export declare class PolagramBuilder {
|
|
|
318
392
|
* Generate Mermaid code from the transformed AST.
|
|
319
393
|
*/
|
|
320
394
|
toMermaid(): string;
|
|
395
|
+
/**
|
|
396
|
+
* Generate PlantUML code from the transformed AST.
|
|
397
|
+
*/
|
|
398
|
+
toPlantUML(): string;
|
|
321
399
|
/**
|
|
322
400
|
* Get the transformed AST (for advanced use cases).
|
|
323
401
|
*/
|
|
324
402
|
toAST(): PolagramRoot;
|
|
403
|
+
/**
|
|
404
|
+
* Get the source format detected/specified during init.
|
|
405
|
+
*/
|
|
406
|
+
getSourceFormat(): 'mermaid' | 'plantuml';
|
|
325
407
|
private normalizeParticipantSelector;
|
|
326
408
|
private normalizeMessageSelector;
|
|
327
409
|
private normalizeGroupSelector;
|
|
@@ -342,9 +424,9 @@ export declare const PolagramConfigSchema: z.ZodObject<{
|
|
|
342
424
|
suffix: z.ZodOptional<z.ZodString>;
|
|
343
425
|
layers: z.ZodArray<z.ZodObject<{
|
|
344
426
|
action: z.ZodEnum<{
|
|
345
|
-
resolve: "resolve";
|
|
346
427
|
focus: "focus";
|
|
347
428
|
remove: "remove";
|
|
429
|
+
resolve: "resolve";
|
|
348
430
|
}>;
|
|
349
431
|
selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
350
432
|
kind: z.ZodLiteral<"fragment">;
|
|
@@ -390,6 +472,14 @@ export declare const PolagramConfigSchema: z.ZodObject<{
|
|
|
390
472
|
}, z.core.$strip>], "kind">;
|
|
391
473
|
}, z.core.$strip>>;
|
|
392
474
|
}, z.core.$strip>>;
|
|
475
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
476
|
+
mermaid: "mermaid";
|
|
477
|
+
plantuml: "plantuml";
|
|
478
|
+
}>>;
|
|
479
|
+
outputFormat: z.ZodOptional<z.ZodEnum<{
|
|
480
|
+
mermaid: "mermaid";
|
|
481
|
+
plantuml: "plantuml";
|
|
482
|
+
}>>;
|
|
393
483
|
}, z.core.$strip>>;
|
|
394
484
|
}, z.core.$strip>;
|
|
395
485
|
|
|
@@ -498,9 +588,9 @@ declare const TargetConfigSchema: z.ZodObject<{
|
|
|
498
588
|
suffix: z.ZodOptional<z.ZodString>;
|
|
499
589
|
layers: z.ZodArray<z.ZodObject<{
|
|
500
590
|
action: z.ZodEnum<{
|
|
501
|
-
resolve: "resolve";
|
|
502
591
|
focus: "focus";
|
|
503
592
|
remove: "remove";
|
|
593
|
+
resolve: "resolve";
|
|
504
594
|
}>;
|
|
505
595
|
selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
506
596
|
kind: z.ZodLiteral<"fragment">;
|
|
@@ -546,6 +636,14 @@ declare const TargetConfigSchema: z.ZodObject<{
|
|
|
546
636
|
}, z.core.$strip>], "kind">;
|
|
547
637
|
}, z.core.$strip>>;
|
|
548
638
|
}, z.core.$strip>>;
|
|
639
|
+
format: z.ZodOptional<z.ZodEnum<{
|
|
640
|
+
mermaid: "mermaid";
|
|
641
|
+
plantuml: "plantuml";
|
|
642
|
+
}>>;
|
|
643
|
+
outputFormat: z.ZodOptional<z.ZodEnum<{
|
|
644
|
+
mermaid: "mermaid";
|
|
645
|
+
plantuml: "plantuml";
|
|
646
|
+
}>>;
|
|
549
647
|
}, z.core.$strip>;
|
|
550
648
|
|
|
551
649
|
export declare type TextMatcher = string | RegExp | {
|