@polagram/core 0.0.2

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.
Files changed (100) hide show
  1. package/README.md +124 -0
  2. package/dist/index.d.ts +625 -0
  3. package/dist/polagram-core.js +3653 -0
  4. package/dist/polagram-core.umd.cjs +28 -0
  5. package/dist/src/api.d.ts +75 -0
  6. package/dist/src/api.js +160 -0
  7. package/dist/src/ast/ast.test.d.ts +1 -0
  8. package/dist/src/ast/ast.test.js +146 -0
  9. package/dist/src/ast/index.d.ts +119 -0
  10. package/dist/src/ast/index.js +2 -0
  11. package/dist/src/config/index.d.ts +1 -0
  12. package/dist/src/config/index.js +1 -0
  13. package/dist/src/config/schema.d.ts +182 -0
  14. package/dist/src/config/schema.js +78 -0
  15. package/dist/src/config/schema.test.d.ts +1 -0
  16. package/dist/src/config/schema.test.js +94 -0
  17. package/dist/src/generator/base/walker.d.ts +19 -0
  18. package/dist/src/generator/base/walker.js +56 -0
  19. package/dist/src/generator/base/walker.test.d.ts +1 -0
  20. package/dist/src/generator/base/walker.test.js +49 -0
  21. package/dist/src/generator/generators/mermaid.d.ts +24 -0
  22. package/dist/src/generator/generators/mermaid.js +140 -0
  23. package/dist/src/generator/generators/mermaid.test.d.ts +1 -0
  24. package/dist/src/generator/generators/mermaid.test.js +70 -0
  25. package/dist/src/generator/interface.d.ts +17 -0
  26. package/dist/src/generator/interface.js +1 -0
  27. package/dist/src/index.d.ts +9 -0
  28. package/dist/src/index.js +17 -0
  29. package/dist/src/parser/base/lexer.d.ts +18 -0
  30. package/dist/src/parser/base/lexer.js +95 -0
  31. package/dist/src/parser/base/lexer.test.d.ts +1 -0
  32. package/dist/src/parser/base/lexer.test.js +53 -0
  33. package/dist/src/parser/base/parser.d.ts +14 -0
  34. package/dist/src/parser/base/parser.js +43 -0
  35. package/dist/src/parser/base/parser.test.d.ts +1 -0
  36. package/dist/src/parser/base/parser.test.js +90 -0
  37. package/dist/src/parser/index.d.ts +10 -0
  38. package/dist/src/parser/index.js +29 -0
  39. package/dist/src/parser/index.test.d.ts +1 -0
  40. package/dist/src/parser/index.test.js +23 -0
  41. package/dist/src/parser/interface.d.ts +8 -0
  42. package/dist/src/parser/interface.js +1 -0
  43. package/dist/src/parser/languages/mermaid/constants.d.ts +7 -0
  44. package/dist/src/parser/languages/mermaid/constants.js +20 -0
  45. package/dist/src/parser/languages/mermaid/index.d.ts +4 -0
  46. package/dist/src/parser/languages/mermaid/index.js +11 -0
  47. package/dist/src/parser/languages/mermaid/lexer.d.ts +14 -0
  48. package/dist/src/parser/languages/mermaid/lexer.js +152 -0
  49. package/dist/src/parser/languages/mermaid/lexer.test.d.ts +1 -0
  50. package/dist/src/parser/languages/mermaid/lexer.test.js +58 -0
  51. package/dist/src/parser/languages/mermaid/parser.d.ts +21 -0
  52. package/dist/src/parser/languages/mermaid/parser.js +340 -0
  53. package/dist/src/parser/languages/mermaid/parser.test.d.ts +1 -0
  54. package/dist/src/parser/languages/mermaid/parser.test.js +252 -0
  55. package/dist/src/parser/languages/mermaid/tokens.d.ts +9 -0
  56. package/dist/src/parser/languages/mermaid/tokens.js +1 -0
  57. package/dist/src/transformer/cleaners/prune-empty.d.ts +9 -0
  58. package/dist/src/transformer/cleaners/prune-empty.js +27 -0
  59. package/dist/src/transformer/cleaners/prune-empty.test.d.ts +1 -0
  60. package/dist/src/transformer/cleaners/prune-empty.test.js +69 -0
  61. package/dist/src/transformer/cleaners/prune-unused.d.ts +5 -0
  62. package/dist/src/transformer/cleaners/prune-unused.js +48 -0
  63. package/dist/src/transformer/cleaners/prune-unused.test.d.ts +1 -0
  64. package/dist/src/transformer/cleaners/prune-unused.test.js +71 -0
  65. package/dist/src/transformer/filters/focus.d.ts +13 -0
  66. package/dist/src/transformer/filters/focus.js +71 -0
  67. package/dist/src/transformer/filters/focus.test.d.ts +1 -0
  68. package/dist/src/transformer/filters/focus.test.js +50 -0
  69. package/dist/src/transformer/filters/remove.d.ts +12 -0
  70. package/dist/src/transformer/filters/remove.js +82 -0
  71. package/dist/src/transformer/filters/remove.test.d.ts +1 -0
  72. package/dist/src/transformer/filters/remove.test.js +38 -0
  73. package/dist/src/transformer/filters/resolve.d.ts +9 -0
  74. package/dist/src/transformer/filters/resolve.js +32 -0
  75. package/dist/src/transformer/filters/resolve.test.d.ts +1 -0
  76. package/dist/src/transformer/filters/resolve.test.js +48 -0
  77. package/dist/src/transformer/index.d.ts +10 -0
  78. package/dist/src/transformer/index.js +10 -0
  79. package/dist/src/transformer/lens.d.ts +12 -0
  80. package/dist/src/transformer/lens.js +58 -0
  81. package/dist/src/transformer/lens.test.d.ts +1 -0
  82. package/dist/src/transformer/lens.test.js +60 -0
  83. package/dist/src/transformer/orchestration/engine.d.ts +5 -0
  84. package/dist/src/transformer/orchestration/engine.js +24 -0
  85. package/dist/src/transformer/orchestration/engine.test.d.ts +1 -0
  86. package/dist/src/transformer/orchestration/engine.test.js +41 -0
  87. package/dist/src/transformer/orchestration/registry.d.ts +10 -0
  88. package/dist/src/transformer/orchestration/registry.js +27 -0
  89. package/dist/src/transformer/selector/matcher.d.ts +9 -0
  90. package/dist/src/transformer/selector/matcher.js +62 -0
  91. package/dist/src/transformer/selector/matcher.test.d.ts +1 -0
  92. package/dist/src/transformer/selector/matcher.test.js +53 -0
  93. package/dist/src/transformer/traverse/walker.d.ts +14 -0
  94. package/dist/src/transformer/traverse/walker.js +67 -0
  95. package/dist/src/transformer/traverse/walker.test.d.ts +1 -0
  96. package/dist/src/transformer/traverse/walker.test.js +48 -0
  97. package/dist/src/transformer/types.d.ts +47 -0
  98. package/dist/src/transformer/types.js +1 -0
  99. package/dist/tsconfig.tsbuildinfo +1 -0
  100. package/package.json +45 -0
@@ -0,0 +1,625 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Independent activation/deactivation not tied to a specific message line.
5
+ * e.g., Mermaid "activate A", PlantUML "activate A"
6
+ */
7
+ export declare interface ActivationNode {
8
+ kind: 'activation';
9
+ participantId: string;
10
+ action: 'activate' | 'deactivate';
11
+ style?: StyleProps;
12
+ }
13
+
14
+ /**
15
+ * Apply a lens object to the AST.
16
+ * Facade for the TransformationEngine.
17
+ */
18
+ export declare function applyLens(root: PolagramRoot, lens: Lens): PolagramRoot;
19
+
20
+ /**
21
+ * Strategy Interface for Diagram Parsing.
22
+ * Implements the Strategy Pattern: different formats implement this interface.
23
+ */
24
+ export declare interface DiagramParser {
25
+ parse(code: string): PolagramRoot;
26
+ }
27
+
28
+ export declare interface DividerNode {
29
+ kind: 'divider';
30
+ id: string;
31
+ text?: string;
32
+ }
33
+
34
+ export declare type EventNode = MessageNode | FragmentNode | NoteNode | DividerNode | ActivationNode | ReferenceNode | SpacerNode;
35
+
36
+ export declare class FocusFilter extends Walker {
37
+ private layer;
38
+ private matcher;
39
+ private targetParticipantIds;
40
+ constructor(layer: FocusLayer);
41
+ transform(root: PolagramRoot): PolagramRoot;
42
+ private resolveTargetParticipants;
43
+ protected visitEvent(node: EventNode): EventNode[];
44
+ private isRelatedToParticipant;
45
+ }
46
+
47
+ export declare interface FocusLayer {
48
+ action: 'focus';
49
+ selector: ParticipantSelector;
50
+ }
51
+
52
+ export declare interface FragmentBranch {
53
+ id: string;
54
+ condition?: string;
55
+ events: EventNode[];
56
+ }
57
+
58
+ export declare interface FragmentNode {
59
+ kind: 'fragment';
60
+ id: string;
61
+ operator: FragmentOperator;
62
+ branches: FragmentBranch[];
63
+ }
64
+
65
+ export declare type FragmentOperator = 'alt' | 'opt' | 'loop' | 'par' | 'break' | 'critical' | 'rect' | 'group';
66
+
67
+ export declare interface FragmentSelector {
68
+ kind?: 'fragment';
69
+ condition?: TextMatcher;
70
+ operator?: FragmentOperator | FragmentOperator[];
71
+ }
72
+
73
+ export declare interface GroupSelector {
74
+ kind?: 'group';
75
+ name?: TextMatcher;
76
+ }
77
+
78
+ export declare type Layer = ResolveLayer | FocusLayer | RemoveLayer;
79
+
80
+ export declare interface Lens {
81
+ name?: string;
82
+ description?: string;
83
+ layers: Layer[];
84
+ }
85
+
86
+ export declare type LensConfig = z.infer<typeof LensSchema>;
87
+
88
+ declare const LensSchema: z.ZodObject<{
89
+ name: z.ZodString;
90
+ suffix: z.ZodOptional<z.ZodString>;
91
+ layers: z.ZodArray<z.ZodObject<{
92
+ action: z.ZodEnum<{
93
+ resolve: "resolve";
94
+ focus: "focus";
95
+ remove: "remove";
96
+ }>;
97
+ selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
98
+ kind: z.ZodLiteral<"fragment">;
99
+ condition: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
100
+ pattern: z.ZodString;
101
+ flags: z.ZodOptional<z.ZodString>;
102
+ }, z.core.$strip>]>>;
103
+ operator: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
104
+ }, z.core.$strip>, z.ZodObject<{
105
+ kind: z.ZodLiteral<"participant">;
106
+ name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
107
+ pattern: z.ZodString;
108
+ flags: z.ZodOptional<z.ZodString>;
109
+ }, z.core.$strip>]>>;
110
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
111
+ pattern: z.ZodString;
112
+ flags: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strip>]>>;
114
+ stereotype: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
115
+ pattern: z.ZodString;
116
+ flags: z.ZodOptional<z.ZodString>;
117
+ }, z.core.$strip>]>>;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ kind: z.ZodLiteral<"message">;
120
+ text: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
121
+ pattern: z.ZodString;
122
+ flags: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$strip>]>>;
124
+ from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
125
+ pattern: z.ZodString;
126
+ flags: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strip>]>>;
128
+ to: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
129
+ pattern: z.ZodString;
130
+ flags: z.ZodOptional<z.ZodString>;
131
+ }, z.core.$strip>]>>;
132
+ }, z.core.$strip>, z.ZodObject<{
133
+ kind: z.ZodLiteral<"group">;
134
+ name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
135
+ pattern: z.ZodString;
136
+ flags: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$strip>]>>;
138
+ }, z.core.$strip>], "kind">;
139
+ }, z.core.$strip>>;
140
+ }, z.core.$strip>;
141
+
142
+ export declare class Matcher {
143
+ matchBranch(branch: FragmentBranch, selector: FragmentSelector, parentOperator: FragmentOperator): boolean;
144
+ matchParticipant(node: Participant, selector: ParticipantSelector): boolean;
145
+ matchMessage(node: MessageNode, selector: MessageSelector): boolean;
146
+ matchGroup(node: ParticipantGroup, selector: GroupSelector): boolean;
147
+ private matchText;
148
+ }
149
+
150
+ /**
151
+ * Visitor implementation that generates Mermaid code.
152
+ */
153
+ export declare class MermaidGeneratorVisitor implements PolagramVisitor {
154
+ private lines;
155
+ private indentLevel;
156
+ private traverser;
157
+ constructor();
158
+ generate(ast: PolagramRoot): string;
159
+ visitRoot(node: PolagramRoot): void;
160
+ visitParticipant(node: Participant): void;
161
+ visitParticipantGroup(node: ParticipantGroup): void;
162
+ visitMessage(node: MessageNode): void;
163
+ visitFragment(node: FragmentNode): void;
164
+ visitNote(node: NoteNode): void;
165
+ visitActivation(node: ActivationNode): void;
166
+ visitDivider(node: DividerNode): void;
167
+ visitSpacer(node: SpacerNode): void;
168
+ visitReference(node: ReferenceNode): void;
169
+ private add;
170
+ private indent;
171
+ }
172
+
173
+ export declare type MessageEndpoint = string | null;
174
+
175
+ /**
176
+ * Represents a directional interaction.
177
+ * Includes standard sync/async calls, returns, and object creation/deletion.
178
+ */
179
+ export declare interface MessageNode {
180
+ kind: 'message';
181
+ id: string;
182
+ from: MessageEndpoint;
183
+ to: MessageEndpoint;
184
+ text: string;
185
+ type: 'sync' | 'async' | 'reply' | 'create' | 'destroy';
186
+ style: {
187
+ line: 'solid' | 'dotted';
188
+ head: 'arrow' | 'async' | 'open' | 'cross';
189
+ color?: string;
190
+ };
191
+ lifecycle?: {
192
+ activateTarget?: boolean;
193
+ deactivateSource?: boolean;
194
+ };
195
+ }
196
+
197
+ export declare interface MessageSelector {
198
+ kind?: 'message';
199
+ text?: TextMatcher;
200
+ from?: TextMatcher;
201
+ to?: TextMatcher;
202
+ }
203
+
204
+ export declare interface MetaData {
205
+ version: string;
206
+ source: 'mermaid' | 'plantuml' | 'unknown';
207
+ title?: string;
208
+ theme?: Record<string, string>;
209
+ }
210
+
211
+ export declare interface NoteNode {
212
+ kind: 'note';
213
+ id: string;
214
+ text: string;
215
+ position: 'left' | 'right' | 'over';
216
+ participantIds: string[];
217
+ style?: StyleProps;
218
+ }
219
+
220
+ /**
221
+ * Parser Factory
222
+ * Centralizes retrieval of parser strategies.
223
+ */
224
+ export declare class ParserFactory {
225
+ private static parsers;
226
+ static register(language: string, parser: DiagramParser): void;
227
+ static getParser(language: string): DiagramParser;
228
+ }
229
+
230
+ export declare interface Participant {
231
+ id: string;
232
+ name: string;
233
+ alias?: string;
234
+ type: ParticipantType;
235
+ stereotype?: string;
236
+ style?: StyleProps;
237
+ }
238
+
239
+ export declare interface ParticipantGroup {
240
+ kind: 'group';
241
+ id: string;
242
+ name?: string;
243
+ type?: string;
244
+ participantIds: string[];
245
+ style?: StyleProps;
246
+ }
247
+
248
+ export declare interface ParticipantSelector {
249
+ kind?: 'participant';
250
+ name?: TextMatcher;
251
+ id?: TextMatcher;
252
+ stereotype?: TextMatcher;
253
+ }
254
+
255
+ export declare type ParticipantType = 'participant' | 'actor' | 'boundary' | 'control' | 'entity' | 'database' | 'collections' | 'queue';
256
+
257
+ /**
258
+ * Polagram Fluent API
259
+ *
260
+ * Provides a high-level, chainable interface for transformations.
261
+ *
262
+ * @example
263
+ * const result = Polagram.init(mermaidCode)
264
+ * .focusParticipant('PaymentService')
265
+ * .removeParticipant('DebugLogger')
266
+ * .toMermaid();
267
+ */
268
+ export declare class Polagram {
269
+ private constructor();
270
+ /**
271
+ * Initialize a new Polagram transformation pipeline.
272
+ * @param code Source diagram code
273
+ * @param format Input format (currently only 'mermaid' is supported)
274
+ */
275
+ static init(code: string, format?: 'mermaid'): PolagramBuilder;
276
+ }
277
+
278
+ /**
279
+ * Builder class for chaining transformations.
280
+ */
281
+ export declare class PolagramBuilder {
282
+ private ast;
283
+ private layers;
284
+ constructor(ast: PolagramRoot);
285
+ /**
286
+ * Focus on specific participants.
287
+ * Keeps only interactions involving the matched participants.
288
+ * @param selector Name (string/RegExp) or detailed ParticipantSelector
289
+ */
290
+ focusParticipant(selector: TextMatcher | Partial<ParticipantSelector>): this;
291
+ /**
292
+ * Remove specific participants and their interactions.
293
+ * @param selector Name (string/RegExp) or detailed ParticipantSelector
294
+ */
295
+ removeParticipant(selector: TextMatcher | Partial<ParticipantSelector>): this;
296
+ /**
297
+ * Remove specific messages.
298
+ * @param selector Message text (string/RegExp) or detailed MessageSelector
299
+ */
300
+ removeMessage(selector: TextMatcher | Partial<MessageSelector>): this;
301
+ /**
302
+ * Remove specific groups (visual boxes).
303
+ * @param selector Group name (string/RegExp) or detailed GroupSelector
304
+ */
305
+ removeGroup(selector: TextMatcher | Partial<GroupSelector>): this;
306
+ /**
307
+ * Resolve (unwrap) specific fragments like 'alt', 'opt', 'loop'.
308
+ * Promotes the content of the matched branch and removes the wrapper.
309
+ * @param selector Condition text (string/RegExp) or detailed FragmentSelector
310
+ */
311
+ resolveFragment(selector: TextMatcher | Partial<FragmentSelector>): this;
312
+ /**
313
+ * Apply a Lens (a named set of transformation layers).
314
+ * @param lens Lens object containing layers
315
+ */
316
+ applyLens(lens: Lens): this;
317
+ /**
318
+ * Generate Mermaid code from the transformed AST.
319
+ */
320
+ toMermaid(): string;
321
+ /**
322
+ * Get the transformed AST (for advanced use cases).
323
+ */
324
+ toAST(): PolagramRoot;
325
+ private normalizeParticipantSelector;
326
+ private normalizeMessageSelector;
327
+ private normalizeGroupSelector;
328
+ private normalizeFragmentSelector;
329
+ private isTextMatcher;
330
+ }
331
+
332
+ export declare type PolagramConfig = z.infer<typeof PolagramConfigSchema>;
333
+
334
+ export declare const PolagramConfigSchema: z.ZodObject<{
335
+ version: z.ZodNumber;
336
+ targets: z.ZodArray<z.ZodObject<{
337
+ input: z.ZodArray<z.ZodString>;
338
+ outputDir: z.ZodString;
339
+ ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
340
+ lenses: z.ZodArray<z.ZodObject<{
341
+ name: z.ZodString;
342
+ suffix: z.ZodOptional<z.ZodString>;
343
+ layers: z.ZodArray<z.ZodObject<{
344
+ action: z.ZodEnum<{
345
+ resolve: "resolve";
346
+ focus: "focus";
347
+ remove: "remove";
348
+ }>;
349
+ selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
350
+ kind: z.ZodLiteral<"fragment">;
351
+ condition: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
352
+ pattern: z.ZodString;
353
+ flags: z.ZodOptional<z.ZodString>;
354
+ }, z.core.$strip>]>>;
355
+ operator: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
356
+ }, z.core.$strip>, z.ZodObject<{
357
+ kind: z.ZodLiteral<"participant">;
358
+ name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
359
+ pattern: z.ZodString;
360
+ flags: z.ZodOptional<z.ZodString>;
361
+ }, z.core.$strip>]>>;
362
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
363
+ pattern: z.ZodString;
364
+ flags: z.ZodOptional<z.ZodString>;
365
+ }, z.core.$strip>]>>;
366
+ stereotype: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
367
+ pattern: z.ZodString;
368
+ flags: z.ZodOptional<z.ZodString>;
369
+ }, z.core.$strip>]>>;
370
+ }, z.core.$strip>, z.ZodObject<{
371
+ kind: z.ZodLiteral<"message">;
372
+ text: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
373
+ pattern: z.ZodString;
374
+ flags: z.ZodOptional<z.ZodString>;
375
+ }, z.core.$strip>]>>;
376
+ from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
377
+ pattern: z.ZodString;
378
+ flags: z.ZodOptional<z.ZodString>;
379
+ }, z.core.$strip>]>>;
380
+ to: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
381
+ pattern: z.ZodString;
382
+ flags: z.ZodOptional<z.ZodString>;
383
+ }, z.core.$strip>]>>;
384
+ }, z.core.$strip>, z.ZodObject<{
385
+ kind: z.ZodLiteral<"group">;
386
+ name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
387
+ pattern: z.ZodString;
388
+ flags: z.ZodOptional<z.ZodString>;
389
+ }, z.core.$strip>]>>;
390
+ }, z.core.$strip>], "kind">;
391
+ }, z.core.$strip>>;
392
+ }, z.core.$strip>>;
393
+ }, z.core.$strip>>;
394
+ }, z.core.$strip>;
395
+
396
+ /**
397
+ * Polagram Abstract Syntax Tree (AST) Definitions
398
+ *
399
+ * Designed to be a lossless representation of Sequence Diagrams from:
400
+ * - Mermaid
401
+ * - PlantUML
402
+ *
403
+ * It captures structure, semantics (lifecycle, grouping), and necessary visual hints.
404
+ */
405
+ export declare interface PolagramRoot {
406
+ kind: 'root';
407
+ meta: MetaData;
408
+ participants: Participant[];
409
+ groups: ParticipantGroup[];
410
+ events: EventNode[];
411
+ }
412
+
413
+ /**
414
+ * Visitor interface for traversing the Polagram AST.
415
+ * Implement this interface to create code generators, validators, etc.
416
+ */
417
+ export declare interface PolagramVisitor {
418
+ visitRoot(node: PolagramRoot): void;
419
+ visitParticipant(node: Participant): void;
420
+ visitParticipantGroup(node: ParticipantGroup): void;
421
+ visitMessage(node: MessageNode): void;
422
+ visitFragment(node: FragmentNode): void;
423
+ visitNote(node: NoteNode): void;
424
+ visitActivation(node: ActivationNode): void;
425
+ visitDivider(node: DividerNode): void;
426
+ visitSpacer(node: SpacerNode): void;
427
+ visitReference(node: ReferenceNode): void;
428
+ }
429
+
430
+ /**
431
+ * Refers to another sequence diagram or a frame covering participants.
432
+ * e.g., PlantUML "ref over A, B : Init"
433
+ */
434
+ export declare interface ReferenceNode {
435
+ kind: 'ref';
436
+ id: string;
437
+ text: string;
438
+ participantIds: string[];
439
+ link?: string;
440
+ }
441
+
442
+ export declare class RemoveFilter extends Walker {
443
+ private layer;
444
+ private matcher;
445
+ private removedParticipantIds;
446
+ constructor(layer: RemoveLayer);
447
+ transform(root: PolagramRoot): PolagramRoot;
448
+ protected visitEvent(node: EventNode): EventNode[];
449
+ private isRelatedToRemovedParticipant;
450
+ }
451
+
452
+ export declare interface RemoveLayer {
453
+ action: 'remove';
454
+ selector: ParticipantSelector | MessageSelector | GroupSelector;
455
+ }
456
+
457
+ export declare class ResolveFilter extends Walker {
458
+ private layer;
459
+ private matcher;
460
+ constructor(layer: ResolveLayer);
461
+ protected visitFragment(node: FragmentNode): EventNode[];
462
+ }
463
+
464
+ export declare interface ResolveLayer {
465
+ action: 'resolve';
466
+ selector: FragmentSelector;
467
+ }
468
+
469
+ export declare interface SpacerNode {
470
+ kind: 'spacer';
471
+ id: string;
472
+ height?: number;
473
+ text?: string;
474
+ }
475
+
476
+ /**
477
+ * Cleaner that removes empty fragments and branches from the AST.
478
+ * This runs after filters to ensure the AST structure remains valid/clean.
479
+ */
480
+ export declare class StructureCleaner extends Walker {
481
+ protected visitFragment(node: FragmentNode): EventNode[];
482
+ }
483
+
484
+ export declare interface StyleProps {
485
+ color?: string;
486
+ backgroundColor?: string;
487
+ shape?: string;
488
+ }
489
+
490
+ export declare type TargetConfig = z.infer<typeof TargetConfigSchema>;
491
+
492
+ declare const TargetConfigSchema: z.ZodObject<{
493
+ input: z.ZodArray<z.ZodString>;
494
+ outputDir: z.ZodString;
495
+ ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
496
+ lenses: z.ZodArray<z.ZodObject<{
497
+ name: z.ZodString;
498
+ suffix: z.ZodOptional<z.ZodString>;
499
+ layers: z.ZodArray<z.ZodObject<{
500
+ action: z.ZodEnum<{
501
+ resolve: "resolve";
502
+ focus: "focus";
503
+ remove: "remove";
504
+ }>;
505
+ selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
506
+ kind: z.ZodLiteral<"fragment">;
507
+ condition: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
508
+ pattern: z.ZodString;
509
+ flags: z.ZodOptional<z.ZodString>;
510
+ }, z.core.$strip>]>>;
511
+ operator: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
512
+ }, z.core.$strip>, z.ZodObject<{
513
+ kind: z.ZodLiteral<"participant">;
514
+ name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
515
+ pattern: z.ZodString;
516
+ flags: z.ZodOptional<z.ZodString>;
517
+ }, z.core.$strip>]>>;
518
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
519
+ pattern: z.ZodString;
520
+ flags: z.ZodOptional<z.ZodString>;
521
+ }, z.core.$strip>]>>;
522
+ stereotype: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
523
+ pattern: z.ZodString;
524
+ flags: z.ZodOptional<z.ZodString>;
525
+ }, z.core.$strip>]>>;
526
+ }, z.core.$strip>, z.ZodObject<{
527
+ kind: z.ZodLiteral<"message">;
528
+ text: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
529
+ pattern: z.ZodString;
530
+ flags: z.ZodOptional<z.ZodString>;
531
+ }, z.core.$strip>]>>;
532
+ from: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
533
+ pattern: z.ZodString;
534
+ flags: z.ZodOptional<z.ZodString>;
535
+ }, z.core.$strip>]>>;
536
+ to: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
537
+ pattern: z.ZodString;
538
+ flags: z.ZodOptional<z.ZodString>;
539
+ }, z.core.$strip>]>>;
540
+ }, z.core.$strip>, z.ZodObject<{
541
+ kind: z.ZodLiteral<"group">;
542
+ name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
543
+ pattern: z.ZodString;
544
+ flags: z.ZodOptional<z.ZodString>;
545
+ }, z.core.$strip>]>>;
546
+ }, z.core.$strip>], "kind">;
547
+ }, z.core.$strip>>;
548
+ }, z.core.$strip>>;
549
+ }, z.core.$strip>;
550
+
551
+ export declare type TextMatcher = string | RegExp | {
552
+ pattern: string;
553
+ flags?: string;
554
+ };
555
+
556
+ export declare class TransformationEngine {
557
+ transform(root: PolagramRoot, layers: Layer[]): PolagramRoot;
558
+ }
559
+
560
+ declare interface Transformer_2 {
561
+ transform(root: PolagramRoot): PolagramRoot;
562
+ }
563
+ export { Transformer_2 as Transformer }
564
+
565
+ declare type TransformerFactory = (layer: Layer) => Transformer_2;
566
+
567
+ declare class TransformerRegistry {
568
+ private factories;
569
+ constructor();
570
+ register(action: string, factory: TransformerFactory): void;
571
+ get(layer: Layer): Transformer_2 | null;
572
+ }
573
+
574
+ export declare const transformerRegistry: TransformerRegistry;
575
+
576
+ /**
577
+ * Helper class to traverse AST nodes and dispatch to the visitor.
578
+ */
579
+ export declare class Traverser {
580
+ private visitor;
581
+ constructor(visitor: PolagramVisitor);
582
+ traverse(root: PolagramRoot): void;
583
+ /**
584
+ * Dispatches a single event node to the appropriate visitor method.
585
+ * This is public so Visitors can call it recursively (e.g. inside Fragments/Groups).
586
+ */
587
+ dispatchEvent(node: EventNode): void;
588
+ /**
589
+ * Helper to iterate over a list of events.
590
+ */
591
+ dispatchEvents(events: EventNode[]): void;
592
+ }
593
+
594
+ export declare class UnusedCleaner {
595
+ transform(root: PolagramRoot): PolagramRoot;
596
+ private collectUsedParticipants;
597
+ }
598
+
599
+ /**
600
+ * Validates the input object against the Polagram Config Schema.
601
+ * Throws a formatted error message if validation fails.
602
+ */
603
+ export declare function validateConfig(input: unknown): PolagramConfig;
604
+
605
+ /**
606
+ * Type Guard to validate if an object is a valid Lens.
607
+ * Acts as an Anti-Corruption Layer.
608
+ */
609
+ export declare function validateLens(lens: unknown): lens is Lens;
610
+
611
+ /**
612
+ * Abstract base class for tree transformations.
613
+ * Implements the "Updating Visitor" pattern with Copy-on-Write immutability.
614
+ *
615
+ * Subclasses should override `visitEvent` to apply specific logic.
616
+ */
617
+ declare abstract class Walker {
618
+ transform(root: PolagramRoot): PolagramRoot;
619
+ protected mapEvents(events: EventNode[]): EventNode[];
620
+ protected visitEvent(node: EventNode): EventNode[];
621
+ protected visitFragment(node: FragmentNode): EventNode[];
622
+ protected visitBranch(branch: FragmentBranch): FragmentBranch;
623
+ }
624
+
625
+ export { }