@likec4/language-server 1.32.2 → 1.33.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/ast.d.ts +6 -5
- package/dist/ast.js +3 -0
- package/dist/bundled.mjs +3342 -2550
- package/dist/generated/ast.d.ts +20 -11
- package/dist/generated/ast.js +17 -5
- package/dist/generated/grammar.js +1 -1
- package/dist/lsp/SemanticTokenProvider.js +1 -1
- package/dist/mcp/LikeC4MCPTools.js +5 -2
- package/dist/model/builder/MergedSpecification.js +8 -4
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/model-parser.d.ts +126 -0
- package/dist/model/parser/Base.d.ts +30 -2
- package/dist/model/parser/Base.js +54 -3
- package/dist/model/parser/DeploymentModelParser.d.ts +14 -0
- package/dist/model/parser/DeploymentModelParser.js +24 -21
- package/dist/model/parser/DeploymentViewParser.d.ts +14 -0
- package/dist/model/parser/DeploymentViewParser.js +15 -6
- package/dist/model/parser/FqnRefParser.d.ts +14 -0
- package/dist/model/parser/FqnRefParser.js +8 -6
- package/dist/model/parser/GlobalsParser.d.ts +14 -0
- package/dist/model/parser/ImportsParser.d.ts +14 -0
- package/dist/model/parser/ModelParser.d.ts +14 -0
- package/dist/model/parser/ModelParser.js +22 -14
- package/dist/model/parser/PredicatesParser.d.ts +14 -0
- package/dist/model/parser/SpecificationParser.d.ts +14 -0
- package/dist/model/parser/SpecificationParser.js +16 -11
- package/dist/model/parser/ValueConverter.d.ts +4 -0
- package/dist/model/parser/ValueConverter.js +12 -0
- package/dist/model/parser/ViewsParser.d.ts +14 -0
- package/dist/model/parser/ViewsParser.js +21 -7
- package/dist/module.d.ts +4 -1
- package/dist/module.js +5 -1
- package/dist/views/configurable-layouter.js +22 -28
- package/dist/views/likec4-views.js +0 -1
- package/package.json +19 -18
|
@@ -272,7 +272,7 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
|
272
272
|
});
|
|
273
273
|
return "prune";
|
|
274
274
|
}
|
|
275
|
-
if ("value" in node && node.value) {
|
|
275
|
+
if ("value" in node && node.value && !ast.isStringProperty(node)) {
|
|
276
276
|
acceptor({
|
|
277
277
|
node,
|
|
278
278
|
property: "value",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _type } from "@likec4/core";
|
|
1
|
+
import { _type, RichText } from "@likec4/core";
|
|
2
2
|
import { loggable } from "@likec4/log";
|
|
3
3
|
import { flatMap } from "remeda";
|
|
4
4
|
import stripIndent from "strip-indent";
|
|
@@ -9,7 +9,10 @@ import { ProjectsManager } from "../workspace/ProjectsManager.js";
|
|
|
9
9
|
import { elementResource, modelViewResource } from "./utils.js";
|
|
10
10
|
const logger = mainLogger.getChild("LikeC4MCPServices");
|
|
11
11
|
function singleLine(str) {
|
|
12
|
-
|
|
12
|
+
if (str === null || str === void 0) {
|
|
13
|
+
return "null";
|
|
14
|
+
}
|
|
15
|
+
const res = toSingleLine(RichText.from(str).text)?.replaceAll('"', "'");
|
|
13
16
|
return res ? `"${res}"` : "null";
|
|
14
17
|
}
|
|
15
18
|
function outputEach(iterator, ifEmpty, output) {
|
|
@@ -102,8 +102,8 @@ export class MergedSpecification {
|
|
|
102
102
|
},
|
|
103
103
|
links: links ?? null,
|
|
104
104
|
tags: tags ?? [],
|
|
105
|
-
technology
|
|
106
|
-
description
|
|
105
|
+
...technology && { technology },
|
|
106
|
+
...description && { description },
|
|
107
107
|
title,
|
|
108
108
|
kind,
|
|
109
109
|
id
|
|
@@ -155,6 +155,7 @@ export class MergedSpecification {
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
if ("element" in parsed) {
|
|
158
|
+
logger.warn`Invalid ParsedAstDeployment ${parsed.id}, has both element and kind properties`;
|
|
158
159
|
return null;
|
|
159
160
|
}
|
|
160
161
|
try {
|
|
@@ -166,10 +167,13 @@ export class MergedSpecification {
|
|
|
166
167
|
let {
|
|
167
168
|
technology = __kind.technology,
|
|
168
169
|
notation = __kind.notation,
|
|
169
|
-
style
|
|
170
|
+
style,
|
|
171
|
+
description,
|
|
172
|
+
...rest
|
|
170
173
|
} = parsed;
|
|
171
174
|
return {
|
|
172
|
-
...
|
|
175
|
+
...rest,
|
|
176
|
+
...description && { description },
|
|
173
177
|
...notation && { notation },
|
|
174
178
|
...technology && { technology },
|
|
175
179
|
style: {
|
package/dist/model/index.d.ts
CHANGED
package/dist/model/index.js
CHANGED
|
@@ -63,6 +63,7 @@ declare const DocumentParserFromMixins: {
|
|
|
63
63
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
64
64
|
[key: string]: string;
|
|
65
65
|
} | undefined;
|
|
66
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
66
67
|
convertTags<E extends {
|
|
67
68
|
tags?: import("../generated/ast").Tags;
|
|
68
69
|
}>(withTags?: E | undefined): any;
|
|
@@ -75,6 +76,19 @@ declare const DocumentParserFromMixins: {
|
|
|
75
76
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
76
77
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
77
78
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
79
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
80
|
+
title?: string | undefined;
|
|
81
|
+
description?: string | undefined;
|
|
82
|
+
technology?: string | undefined;
|
|
83
|
+
}, bodyProps: {
|
|
84
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
85
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
86
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
87
|
+
}): {
|
|
88
|
+
title?: string;
|
|
89
|
+
description?: ProjectId;
|
|
90
|
+
technology?: string;
|
|
91
|
+
};
|
|
78
92
|
parseDeploymentView(astNode: import("../generated/ast").DeploymentView): import("../ast").ParsedAstDeploymentView;
|
|
79
93
|
parseDeploymentViewRule(astRule: import("../generated/ast").DeploymentViewRule): ProjectId;
|
|
80
94
|
parseDeploymentViewRulePredicate(astRule: import("../generated/ast").DeploymentViewRulePredicate): ProjectId;
|
|
@@ -140,6 +154,7 @@ declare const DocumentParserFromMixins: {
|
|
|
140
154
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
141
155
|
[key: string]: string;
|
|
142
156
|
} | undefined;
|
|
157
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
143
158
|
convertTags<E extends {
|
|
144
159
|
tags?: import("../generated/ast").Tags;
|
|
145
160
|
}>(withTags?: E | undefined): any;
|
|
@@ -152,6 +167,19 @@ declare const DocumentParserFromMixins: {
|
|
|
152
167
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
153
168
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
154
169
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
170
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
171
|
+
title?: string | undefined;
|
|
172
|
+
description?: string | undefined;
|
|
173
|
+
technology?: string | undefined;
|
|
174
|
+
}, bodyProps: {
|
|
175
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
176
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
177
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
178
|
+
}): {
|
|
179
|
+
title?: string;
|
|
180
|
+
description?: ProjectId;
|
|
181
|
+
technology?: string;
|
|
182
|
+
};
|
|
155
183
|
parseDeploymentView(astNode: import("../generated/ast").DeploymentView): import("../ast").ParsedAstDeploymentView;
|
|
156
184
|
parseDeploymentViewRule(astRule: import("../generated/ast").DeploymentViewRule): ProjectId;
|
|
157
185
|
parseDeploymentViewRulePredicate(astRule: import("../generated/ast").DeploymentViewRulePredicate): ProjectId;
|
|
@@ -181,6 +209,7 @@ declare const DocumentParserFromMixins: {
|
|
|
181
209
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
182
210
|
[key: string]: string;
|
|
183
211
|
} | undefined;
|
|
212
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
184
213
|
convertTags<E extends {
|
|
185
214
|
tags?: import("../generated/ast").Tags;
|
|
186
215
|
}>(withTags?: E | undefined): any;
|
|
@@ -193,6 +222,19 @@ declare const DocumentParserFromMixins: {
|
|
|
193
222
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
194
223
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
195
224
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
225
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
226
|
+
title?: string | undefined;
|
|
227
|
+
description?: string | undefined;
|
|
228
|
+
technology?: string | undefined;
|
|
229
|
+
}, bodyProps: {
|
|
230
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
231
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
232
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
233
|
+
}): {
|
|
234
|
+
title?: string;
|
|
235
|
+
description?: ProjectId;
|
|
236
|
+
technology?: string;
|
|
237
|
+
};
|
|
196
238
|
};
|
|
197
239
|
} & {
|
|
198
240
|
new (...args: any[]): {
|
|
@@ -234,6 +276,7 @@ declare const DocumentParserFromMixins: {
|
|
|
234
276
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
235
277
|
[key: string]: string;
|
|
236
278
|
} | undefined;
|
|
279
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
237
280
|
convertTags<E extends {
|
|
238
281
|
tags?: import("../generated/ast").Tags;
|
|
239
282
|
}>(withTags?: E | undefined): any;
|
|
@@ -246,6 +289,19 @@ declare const DocumentParserFromMixins: {
|
|
|
246
289
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
247
290
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
248
291
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
292
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
293
|
+
title?: string | undefined;
|
|
294
|
+
description?: string | undefined;
|
|
295
|
+
technology?: string | undefined;
|
|
296
|
+
}, bodyProps: {
|
|
297
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
298
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
299
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
300
|
+
}): {
|
|
301
|
+
title?: string;
|
|
302
|
+
description?: ProjectId;
|
|
303
|
+
technology?: string;
|
|
304
|
+
};
|
|
249
305
|
};
|
|
250
306
|
} & {
|
|
251
307
|
new (...args: any[]): {
|
|
@@ -280,6 +336,7 @@ declare const DocumentParserFromMixins: {
|
|
|
280
336
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
281
337
|
[key: string]: string;
|
|
282
338
|
} | undefined;
|
|
339
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
283
340
|
convertTags<E extends {
|
|
284
341
|
tags?: import("../generated/ast").Tags;
|
|
285
342
|
}>(withTags?: E | undefined): any;
|
|
@@ -292,6 +349,19 @@ declare const DocumentParserFromMixins: {
|
|
|
292
349
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
293
350
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
294
351
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
352
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
353
|
+
title?: string | undefined;
|
|
354
|
+
description?: string | undefined;
|
|
355
|
+
technology?: string | undefined;
|
|
356
|
+
}, bodyProps: {
|
|
357
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
358
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
359
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
360
|
+
}): {
|
|
361
|
+
title?: string;
|
|
362
|
+
description?: ProjectId;
|
|
363
|
+
technology?: string;
|
|
364
|
+
};
|
|
295
365
|
parseDeployment(): void;
|
|
296
366
|
parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
|
|
297
367
|
parseDeployedInstance(astNode: import("../generated/ast").DeployedInstance): import("../ast").ParsedAstDeployment.Instance;
|
|
@@ -334,6 +404,7 @@ declare const DocumentParserFromMixins: {
|
|
|
334
404
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
335
405
|
[key: string]: string;
|
|
336
406
|
} | undefined;
|
|
407
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
337
408
|
convertTags<E extends {
|
|
338
409
|
tags?: import("../generated/ast").Tags;
|
|
339
410
|
}>(withTags?: E | undefined): any;
|
|
@@ -346,6 +417,19 @@ declare const DocumentParserFromMixins: {
|
|
|
346
417
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
347
418
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
348
419
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
420
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
421
|
+
title?: string | undefined;
|
|
422
|
+
description?: string | undefined;
|
|
423
|
+
technology?: string | undefined;
|
|
424
|
+
}, bodyProps: {
|
|
425
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
426
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
427
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
428
|
+
}): {
|
|
429
|
+
title?: string;
|
|
430
|
+
description?: ProjectId;
|
|
431
|
+
technology?: string;
|
|
432
|
+
};
|
|
349
433
|
};
|
|
350
434
|
} & {
|
|
351
435
|
new (...args: any[]): {
|
|
@@ -381,6 +465,7 @@ declare const DocumentParserFromMixins: {
|
|
|
381
465
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
382
466
|
[key: string]: string;
|
|
383
467
|
} | undefined;
|
|
468
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
384
469
|
convertTags<E extends {
|
|
385
470
|
tags?: import("../generated/ast").Tags;
|
|
386
471
|
}>(withTags?: E | undefined): any;
|
|
@@ -393,6 +478,19 @@ declare const DocumentParserFromMixins: {
|
|
|
393
478
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
394
479
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
395
480
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
481
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
482
|
+
title?: string | undefined;
|
|
483
|
+
description?: string | undefined;
|
|
484
|
+
technology?: string | undefined;
|
|
485
|
+
}, bodyProps: {
|
|
486
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
487
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
488
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
489
|
+
}): {
|
|
490
|
+
title?: string;
|
|
491
|
+
description?: ProjectId;
|
|
492
|
+
technology?: string;
|
|
493
|
+
};
|
|
396
494
|
};
|
|
397
495
|
} & {
|
|
398
496
|
new (...args: any[]): {
|
|
@@ -410,6 +508,7 @@ declare const DocumentParserFromMixins: {
|
|
|
410
508
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
411
509
|
[key: string]: string;
|
|
412
510
|
} | undefined;
|
|
511
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
413
512
|
convertTags<E extends {
|
|
414
513
|
tags?: import("../generated/ast").Tags;
|
|
415
514
|
}>(withTags?: E | undefined): any;
|
|
@@ -422,6 +521,19 @@ declare const DocumentParserFromMixins: {
|
|
|
422
521
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
423
522
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
424
523
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
524
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
525
|
+
title?: string | undefined;
|
|
526
|
+
description?: string | undefined;
|
|
527
|
+
technology?: string | undefined;
|
|
528
|
+
}, bodyProps: {
|
|
529
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
530
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
531
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
532
|
+
}): {
|
|
533
|
+
title?: string;
|
|
534
|
+
description?: ProjectId;
|
|
535
|
+
technology?: string;
|
|
536
|
+
};
|
|
425
537
|
};
|
|
426
538
|
} & {
|
|
427
539
|
new (...args: any[]): {
|
|
@@ -452,6 +564,7 @@ declare const DocumentParserFromMixins: {
|
|
|
452
564
|
getMetadata(metadataAstNode: import("../generated/ast").MetadataProperty | undefined): {
|
|
453
565
|
[key: string]: string;
|
|
454
566
|
} | undefined;
|
|
567
|
+
parseMarkdownOrString(markdownOrString: import("../generated/ast").MarkdownOrString | undefined): ProjectId | undefined;
|
|
455
568
|
convertTags<E extends {
|
|
456
569
|
tags?: import("../generated/ast").Tags;
|
|
457
570
|
}>(withTags?: E | undefined): any;
|
|
@@ -464,6 +577,19 @@ declare const DocumentParserFromMixins: {
|
|
|
464
577
|
parseColorLiteral(astNode: import("../generated/ast").ColorLiteral): ProjectId | undefined;
|
|
465
578
|
parseElementStyle(elementProps: Array<import("../generated/ast").ElementProperty> | import("../generated/ast").ElementStyleProperty | undefined): import("../ast").ParsedElementStyle;
|
|
466
579
|
parseStyleProps(styleProps: Array<import("../generated/ast").StyleProperty> | undefined): import("../ast").ParsedElementStyle;
|
|
580
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
581
|
+
title?: string | undefined;
|
|
582
|
+
description?: string | undefined;
|
|
583
|
+
technology?: string | undefined;
|
|
584
|
+
}, bodyProps: {
|
|
585
|
+
title?: import("../generated/ast").MarkdownOrString | undefined;
|
|
586
|
+
description?: import("../generated/ast").MarkdownOrString | undefined;
|
|
587
|
+
technology?: import("../generated/ast").MarkdownOrString | undefined;
|
|
588
|
+
}): {
|
|
589
|
+
title?: string;
|
|
590
|
+
description?: ProjectId;
|
|
591
|
+
technology?: string;
|
|
592
|
+
};
|
|
467
593
|
};
|
|
468
594
|
} & typeof BaseParser;
|
|
469
595
|
export declare class DocumentParser extends DocumentParserFromMixins {
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import type * as c4 from '@likec4/core';
|
|
2
|
+
import { type MarkdownOrString } from '@likec4/core';
|
|
2
3
|
import type { AstNode, URI } from 'langium';
|
|
3
4
|
import { type ParsedElementStyle, type ParsedLikeC4LangiumDocument, ast } from '../../ast';
|
|
4
5
|
import type { ProjectConfig } from '../../config';
|
|
5
6
|
import type { LikeC4Services } from '../../module';
|
|
6
7
|
import { type IsValidFn } from '../../validation';
|
|
7
8
|
export type GConstructor<T = {}> = new (...args: any[]) => T;
|
|
8
|
-
export declare function toSingleLine
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function toSingleLine(str: string): string;
|
|
10
|
+
export declare function toSingleLine(str: string | undefined | null): string | undefined;
|
|
11
|
+
export declare function toSingleLine(str: ast.MarkdownOrString): MarkdownOrString;
|
|
12
|
+
export declare function toSingleLine(str: ast.MarkdownOrString | undefined | null): MarkdownOrString | undefined;
|
|
13
|
+
export declare function toSingleLine(str: ast.MarkdownOrString | string): MarkdownOrString | string;
|
|
14
|
+
export declare function toSingleLine(str: ast.MarkdownOrString | string | undefined | null): MarkdownOrString | string | undefined;
|
|
15
|
+
export declare function removeIndent(str: string): string;
|
|
16
|
+
export declare function removeIndent(str: string | undefined): string | undefined;
|
|
17
|
+
export declare function removeIndent(str: ast.MarkdownOrString): MarkdownOrString;
|
|
18
|
+
export declare function removeIndent(str: ast.MarkdownOrString | undefined): MarkdownOrString | undefined;
|
|
19
|
+
export declare function removeIndent(str: ast.MarkdownOrString | string): MarkdownOrString | string;
|
|
10
20
|
export type Base = GConstructor<BaseParser>;
|
|
11
21
|
export declare class BaseParser {
|
|
12
22
|
readonly services: LikeC4Services;
|
|
@@ -23,6 +33,7 @@ export declare class BaseParser {
|
|
|
23
33
|
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
24
34
|
[key: string]: string;
|
|
25
35
|
} | undefined;
|
|
36
|
+
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
26
37
|
convertTags<E extends {
|
|
27
38
|
tags?: ast.Tags;
|
|
28
39
|
}>(withTags?: E): any;
|
|
@@ -35,4 +46,21 @@ export declare class BaseParser {
|
|
|
35
46
|
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
36
47
|
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): ParsedElementStyle;
|
|
37
48
|
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): ParsedElementStyle;
|
|
49
|
+
/**
|
|
50
|
+
* Parses title, description and technology
|
|
51
|
+
* Inline properties (right on node) have higher priority than body properties (inside '{...}')
|
|
52
|
+
*/
|
|
53
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
54
|
+
title?: string | undefined;
|
|
55
|
+
description?: string | undefined;
|
|
56
|
+
technology?: string | undefined;
|
|
57
|
+
}, bodyProps: {
|
|
58
|
+
title?: ast.MarkdownOrString | undefined;
|
|
59
|
+
description?: ast.MarkdownOrString | undefined;
|
|
60
|
+
technology?: ast.MarkdownOrString | undefined;
|
|
61
|
+
}): {
|
|
62
|
+
title?: string;
|
|
63
|
+
description?: c4.MarkdownOrString;
|
|
64
|
+
technology?: string;
|
|
65
|
+
};
|
|
38
66
|
}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
isArray,
|
|
7
7
|
isBoolean,
|
|
8
8
|
isEmpty,
|
|
9
|
-
isNonNullish,
|
|
10
9
|
isNumber,
|
|
11
10
|
isString,
|
|
12
11
|
isTruthy,
|
|
@@ -21,16 +20,47 @@ import {
|
|
|
21
20
|
parseAstOpacityProperty,
|
|
22
21
|
parseAstPercent,
|
|
23
22
|
parseAstSizeValue,
|
|
23
|
+
parseMarkdownAsString,
|
|
24
24
|
toColor
|
|
25
25
|
} from "../../ast.js";
|
|
26
26
|
import { projectIdFrom } from "../../utils/index.js";
|
|
27
27
|
import { readStrictFqn } from "../../utils/elementRef.js";
|
|
28
28
|
import { checksFromDiagnostics } from "../../validation/index.js";
|
|
29
29
|
export function toSingleLine(str) {
|
|
30
|
-
|
|
30
|
+
if (str === null || str === void 0) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
const without = removeIndent(str);
|
|
34
|
+
if (isString(without)) {
|
|
35
|
+
return without.split("\n").join(" ");
|
|
36
|
+
}
|
|
37
|
+
if ("md" in without) {
|
|
38
|
+
return {
|
|
39
|
+
md: without.md.split("\n").join(" ")
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
txt: without.txt.split("\n").join(" ")
|
|
44
|
+
};
|
|
31
45
|
}
|
|
32
46
|
export function removeIndent(str) {
|
|
33
|
-
|
|
47
|
+
if (str === null || str === void 0) {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
switch (true) {
|
|
51
|
+
case isString(str):
|
|
52
|
+
return stripIndent(str).trim();
|
|
53
|
+
case (ast.isMarkdownOrString(str) && isTruthy(str.markdown)):
|
|
54
|
+
return {
|
|
55
|
+
md: stripIndent(str.markdown).trim()
|
|
56
|
+
};
|
|
57
|
+
case (ast.isMarkdownOrString(str) && isTruthy(str.text)):
|
|
58
|
+
return {
|
|
59
|
+
txt: stripIndent(str.text).trim()
|
|
60
|
+
};
|
|
61
|
+
default:
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
34
64
|
}
|
|
35
65
|
export class BaseParser {
|
|
36
66
|
constructor(services, doc) {
|
|
@@ -72,11 +102,18 @@ export class BaseParser {
|
|
|
72
102
|
const data = pipe(
|
|
73
103
|
metadataAstNode.props,
|
|
74
104
|
map((p) => [p.key, removeIndent(p.value)]),
|
|
105
|
+
map(([key, value]) => [key, value.md || value.txt]),
|
|
75
106
|
filter(([_, value]) => isTruthy(value)),
|
|
76
107
|
fromEntries()
|
|
77
108
|
);
|
|
78
109
|
return isEmpty(data) ? void 0 : data;
|
|
79
110
|
}
|
|
111
|
+
parseMarkdownOrString(markdownOrString) {
|
|
112
|
+
if (ast.isMarkdownOrString(markdownOrString)) {
|
|
113
|
+
return removeIndent(markdownOrString);
|
|
114
|
+
}
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
80
117
|
convertTags(withTags) {
|
|
81
118
|
return this.parseTags(withTags);
|
|
82
119
|
}
|
|
@@ -258,4 +295,18 @@ export class BaseParser {
|
|
|
258
295
|
}
|
|
259
296
|
return result;
|
|
260
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Parses title, description and technology
|
|
300
|
+
* Inline properties (right on node) have higher priority than body properties (inside '{...}')
|
|
301
|
+
*/
|
|
302
|
+
parseTitleDescriptionTechnology(inlineProps, bodyProps) {
|
|
303
|
+
const title = removeIndent(inlineProps.title ?? parseMarkdownAsString(bodyProps.title));
|
|
304
|
+
const description = inlineProps.description ? { txt: removeIndent(inlineProps.description) } : this.parseMarkdownOrString(bodyProps.description);
|
|
305
|
+
const technology = toSingleLine(inlineProps.technology) ?? removeIndent(parseMarkdownAsString(bodyProps.technology));
|
|
306
|
+
return {
|
|
307
|
+
...isTruthy(title) && { title },
|
|
308
|
+
...isTruthy(description) && { description },
|
|
309
|
+
...isTruthy(technology) && { technology }
|
|
310
|
+
};
|
|
311
|
+
}
|
|
261
312
|
}
|
|
@@ -38,6 +38,7 @@ export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B:
|
|
|
38
38
|
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
39
39
|
[key: string]: string;
|
|
40
40
|
} | undefined;
|
|
41
|
+
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
41
42
|
convertTags<E extends {
|
|
42
43
|
tags?: ast.Tags;
|
|
43
44
|
}>(withTags?: E | undefined): any;
|
|
@@ -50,5 +51,18 @@ export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B:
|
|
|
50
51
|
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
51
52
|
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
52
53
|
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
54
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
55
|
+
title?: string | undefined;
|
|
56
|
+
description?: string | undefined;
|
|
57
|
+
technology?: string | undefined;
|
|
58
|
+
}, bodyProps: {
|
|
59
|
+
title?: ast.MarkdownOrString | undefined;
|
|
60
|
+
description?: ast.MarkdownOrString | undefined;
|
|
61
|
+
technology?: ast.MarkdownOrString | undefined;
|
|
62
|
+
}): {
|
|
63
|
+
title?: string;
|
|
64
|
+
description?: c4.MarkdownOrString;
|
|
65
|
+
technology?: string;
|
|
66
|
+
};
|
|
53
67
|
};
|
|
54
68
|
} & TBase;
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
} from "../../ast.js";
|
|
7
7
|
import { logWarnError } from "../../logger.js";
|
|
8
8
|
import { stringHash } from "../../utils/stringHash.js";
|
|
9
|
-
import { removeIndent, toSingleLine } from "./Base.js";
|
|
10
9
|
function* streamDeploymentModel(doc) {
|
|
11
10
|
const traverseStack = LinkedList.from(
|
|
12
11
|
doc.parseResult.value.deployments.flatMap((m) => m.elements)
|
|
@@ -74,11 +73,14 @@ export function DeploymentModelParser(B) {
|
|
|
74
73
|
astNode.body?.props ?? [],
|
|
75
74
|
filter(isValid),
|
|
76
75
|
filter(ast.isElementStringProperty),
|
|
77
|
-
mapToObj((p) => [p.key, p.value
|
|
76
|
+
mapToObj((p) => [p.key, p.value])
|
|
77
|
+
);
|
|
78
|
+
const { title, ...descAndTech } = this.parseTitleDescriptionTechnology(
|
|
79
|
+
{
|
|
80
|
+
title: astNode.title
|
|
81
|
+
},
|
|
82
|
+
bodyProps
|
|
78
83
|
);
|
|
79
|
-
const title = removeIndent(astNode.title ?? bodyProps.title);
|
|
80
|
-
const description = removeIndent(bodyProps.description);
|
|
81
|
-
const technology = toSingleLine(bodyProps.technology);
|
|
82
84
|
const links = this.convertLinks(astNode.body);
|
|
83
85
|
return {
|
|
84
86
|
id,
|
|
@@ -87,8 +89,7 @@ export function DeploymentModelParser(B) {
|
|
|
87
89
|
...metadata && { metadata },
|
|
88
90
|
...tags && { tags },
|
|
89
91
|
...links && isNonEmptyArray(links) && { links },
|
|
90
|
-
...
|
|
91
|
-
...isTruthy(description) && { description },
|
|
92
|
+
...descAndTech,
|
|
92
93
|
style
|
|
93
94
|
};
|
|
94
95
|
}
|
|
@@ -104,21 +105,22 @@ export function DeploymentModelParser(B) {
|
|
|
104
105
|
astNode.body?.props ?? [],
|
|
105
106
|
filter(isValid),
|
|
106
107
|
filter(ast.isElementStringProperty),
|
|
107
|
-
mapToObj((p) => [p.key, p.value
|
|
108
|
+
mapToObj((p) => [p.key, p.value])
|
|
109
|
+
);
|
|
110
|
+
const titleDescAndTech = this.parseTitleDescriptionTechnology(
|
|
111
|
+
{
|
|
112
|
+
title: astNode.title
|
|
113
|
+
},
|
|
114
|
+
bodyProps
|
|
108
115
|
);
|
|
109
|
-
const title = removeIndent(astNode.title ?? bodyProps.title);
|
|
110
|
-
const description = removeIndent(bodyProps.description);
|
|
111
|
-
const technology = toSingleLine(bodyProps.technology);
|
|
112
116
|
const links = this.convertLinks(astNode.body);
|
|
113
117
|
return {
|
|
114
118
|
id,
|
|
115
119
|
element: target,
|
|
116
120
|
...metadata && { metadata },
|
|
117
|
-
...title && { title },
|
|
118
121
|
...tags && { tags },
|
|
119
122
|
...links && isNonEmptyArray(links) && { links },
|
|
120
|
-
...
|
|
121
|
-
...isTruthy(description) && { description },
|
|
123
|
+
...titleDescAndTech,
|
|
122
124
|
style
|
|
123
125
|
};
|
|
124
126
|
}
|
|
@@ -168,7 +170,7 @@ export function DeploymentModelParser(B) {
|
|
|
168
170
|
astNode.body?.props ?? [],
|
|
169
171
|
filter(ast.isRelationStringProperty),
|
|
170
172
|
filter((p) => isTruthy(p.value)),
|
|
171
|
-
mapToObj((p) => [p.key, p.value
|
|
173
|
+
mapToObj((p) => [p.key, p.value])
|
|
172
174
|
);
|
|
173
175
|
const navigateTo = pipe(
|
|
174
176
|
astNode.body?.props ?? [],
|
|
@@ -177,9 +179,12 @@ export function DeploymentModelParser(B) {
|
|
|
177
179
|
filter(isTruthy),
|
|
178
180
|
first()
|
|
179
181
|
);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
const titleDescAndTech = this.parseTitleDescriptionTechnology(
|
|
183
|
+
{
|
|
184
|
+
title: astNode.title
|
|
185
|
+
},
|
|
186
|
+
bodyProps
|
|
187
|
+
);
|
|
183
188
|
const styleProp = astNode.body?.props.find(ast.isRelationStyleProperty);
|
|
184
189
|
const id = stringHash(
|
|
185
190
|
"deployment",
|
|
@@ -191,10 +196,8 @@ export function DeploymentModelParser(B) {
|
|
|
191
196
|
id,
|
|
192
197
|
source,
|
|
193
198
|
target,
|
|
194
|
-
...
|
|
199
|
+
...titleDescAndTech,
|
|
195
200
|
...metadata && { metadata },
|
|
196
|
-
...isTruthy(technology) && { technology },
|
|
197
|
-
...isTruthy(description) && { description },
|
|
198
201
|
...kind && { kind },
|
|
199
202
|
...tags && { tags },
|
|
200
203
|
...isNonEmptyArray(links) && { links },
|
|
@@ -36,6 +36,7 @@ export declare function DeploymentViewParser<TBase extends WithExpressionV2 & Wi
|
|
|
36
36
|
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
37
37
|
[key: string]: string;
|
|
38
38
|
} | undefined;
|
|
39
|
+
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
39
40
|
convertTags<E extends {
|
|
40
41
|
tags?: ast.Tags;
|
|
41
42
|
}>(withTags?: E | undefined): any;
|
|
@@ -48,6 +49,19 @@ export declare function DeploymentViewParser<TBase extends WithExpressionV2 & Wi
|
|
|
48
49
|
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
49
50
|
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
50
51
|
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
52
|
+
parseTitleDescriptionTechnology(inlineProps: {
|
|
53
|
+
title?: string | undefined;
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
technology?: string | undefined;
|
|
56
|
+
}, bodyProps: {
|
|
57
|
+
title?: ast.MarkdownOrString | undefined;
|
|
58
|
+
description?: ast.MarkdownOrString | undefined;
|
|
59
|
+
technology?: ast.MarkdownOrString | undefined;
|
|
60
|
+
}): {
|
|
61
|
+
title?: string;
|
|
62
|
+
description?: c4.MarkdownOrString;
|
|
63
|
+
technology?: string;
|
|
64
|
+
};
|
|
51
65
|
parseDeployment(): void;
|
|
52
66
|
parseDeploymentNode(astNode: ast.DeploymentNode): import("../../ast").ParsedAstDeployment.Node;
|
|
53
67
|
parseDeployedInstance(astNode: ast.DeployedInstance): import("../../ast").ParsedAstDeployment.Instance;
|