@likec4/language-server 1.46.4 → 1.48.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/LICENSE +1 -1
- package/browser/package.json +2 -2
- package/browser-worker/package.json +2 -2
- package/bundled/package.json +4 -0
- package/dist/LikeC4LanguageServices.d.mts +4 -0
- package/dist/LikeC4LanguageServices.mjs +3 -0
- package/dist/_chunks/ConfigurableLayouter.mjs +1956 -0
- package/dist/_chunks/LikeC4LanguageServices.d.mts +1978 -0
- package/dist/_chunks/LikeC4LanguageServices.mjs +725 -0
- package/dist/_chunks/ast.d.mts +1444 -0
- package/dist/_chunks/ast.mjs +2375 -0
- package/dist/_chunks/ast2.mjs +176 -0
- package/dist/_chunks/common-exports.mjs +0 -0
- package/dist/_chunks/filesystem.mjs +58 -0
- package/dist/_chunks/grammar.mjs +8 -0
- package/dist/_chunks/icons.mjs +5211 -0
- package/dist/_chunks/libs/@hono/node-server.mjs +436 -0
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +805 -0
- package/dist/_chunks/libs/eventemitter3.mjs +243 -0
- package/dist/_chunks/libs/fast-equals.mjs +446 -0
- package/dist/_chunks/libs/hono.mjs +1829 -0
- package/dist/_chunks/libs/p-queue.mjs +449 -0
- package/dist/_chunks/libs/parse-ms.mjs +36 -0
- package/dist/_chunks/libs/picomatch.mjs +1673 -0
- package/dist/_chunks/libs/pretty-ms.mjs +80 -0
- package/dist/_chunks/libs/remeda.mjs +482 -0
- package/dist/_chunks/libs/strip-indent.mjs +15 -0
- package/dist/_chunks/libs/ufo.mjs +166 -0
- package/dist/_chunks/likec4lib.mjs +9 -0
- package/dist/_chunks/mcp.mjs +33 -0
- package/dist/_chunks/module.mjs +28 -0
- package/dist/_chunks/module2.mjs +6576 -0
- package/dist/_chunks/protocol.d.mts +311 -0
- package/dist/_chunks/protocol.mjs +78 -0
- package/dist/_chunks/rolldown-runtime.mjs +42 -0
- package/dist/ast.d.mts +4 -0
- package/dist/ast.mjs +4 -0
- package/dist/browser-worker.d.mts +1 -0
- package/dist/browser-worker.mjs +6 -0
- package/dist/browser.d.mts +11 -0
- package/dist/browser.mjs +27 -0
- package/dist/bundled.d.mts +28 -0
- package/dist/bundled.mjs +51 -4681
- package/dist/common-exports.d.mts +4 -0
- package/dist/common-exports.mjs +5 -0
- package/dist/filesystem/index.d.mts +4 -0
- package/dist/filesystem/index.mjs +3 -0
- package/dist/generated/ast.d.mts +2 -0
- package/dist/generated/ast.mjs +3 -0
- package/dist/generated/grammar.d.mts +6 -0
- package/dist/generated/grammar.mjs +3 -0
- package/dist/generated/module.d.mts +14 -0
- package/dist/generated/module.mjs +3 -0
- package/dist/generated-lib/icons.d.mts +4 -0
- package/dist/generated-lib/icons.mjs +3 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +48 -0
- package/dist/likec4lib.d.mts +9 -0
- package/dist/likec4lib.mjs +4 -0
- package/dist/mcp/index.d.mts +4 -0
- package/dist/mcp/index.mjs +3 -0
- package/dist/module.d.mts +4 -0
- package/dist/module.mjs +3 -0
- package/dist/protocol.d.mts +2 -0
- package/dist/protocol.mjs +3 -0
- package/likec4lib/package.json +2 -2
- package/package.json +106 -62
- package/protocol/package.json +2 -2
- package/dist/LikeC4LanguageServices.d.ts +0 -109
- package/dist/LikeC4LanguageServices.js +0 -154
- package/dist/Rpc.d.ts +0 -9
- package/dist/Rpc.js +0 -270
- package/dist/ast.d.ts +0 -226
- package/dist/ast.js +0 -264
- package/dist/browser-worker.d.ts +0 -1
- package/dist/browser-worker.js +0 -4
- package/dist/browser.d.ts +0 -11
- package/dist/browser.js +0 -35
- package/dist/bundled.d.ts +0 -8
- package/dist/bundled.js +0 -44
- package/dist/documentation/documentation-provider.d.ts +0 -8
- package/dist/documentation/documentation-provider.js +0 -51
- package/dist/documentation/index.d.ts +0 -1
- package/dist/documentation/index.js +0 -1
- package/dist/empty.d.ts +0 -2
- package/dist/empty.js +0 -2
- package/dist/filesystem/ChokidarWatcher.d.ts +0 -16
- package/dist/filesystem/ChokidarWatcher.js +0 -108
- package/dist/filesystem/FileSystemWatcher.d.ts +0 -19
- package/dist/filesystem/FileSystemWatcher.js +0 -14
- package/dist/filesystem/LikeC4FileSystem.d.ts +0 -3
- package/dist/filesystem/LikeC4FileSystem.js +0 -130
- package/dist/filesystem/index.d.ts +0 -55
- package/dist/filesystem/index.js +0 -29
- package/dist/formatting/LikeC4Formatter.d.ts +0 -59
- package/dist/formatting/LikeC4Formatter.js +0 -637
- package/dist/formatting/utils.d.ts +0 -6
- package/dist/formatting/utils.js +0 -18
- package/dist/generated/ast.d.ts +0 -1411
- package/dist/generated/ast.js +0 -2207
- package/dist/generated/grammar.d.ts +0 -6
- package/dist/generated/grammar.js +0 -7
- package/dist/generated/module.d.ts +0 -14
- package/dist/generated/module.js +0 -27
- package/dist/generated-lib/icons.d.ts +0 -1
- package/dist/generated-lib/icons.js +0 -18
- package/dist/index.d.ts +0 -38
- package/dist/index.js +0 -55
- package/dist/likec4lib.d.ts +0 -6
- package/dist/likec4lib.js +0 -7
- package/dist/logger.d.ts +0 -17
- package/dist/logger.js +0 -81
- package/dist/lsp/CodeActionProvider.d.ts +0 -14
- package/dist/lsp/CodeActionProvider.js +0 -33
- package/dist/lsp/CodeLensProvider.d.ts +0 -9
- package/dist/lsp/CodeLensProvider.js +0 -44
- package/dist/lsp/CompletionProvider.d.ts +0 -11
- package/dist/lsp/CompletionProvider.js +0 -200
- package/dist/lsp/DocumentHighlightProvider.d.ts +0 -9
- package/dist/lsp/DocumentHighlightProvider.js +0 -10
- package/dist/lsp/DocumentLinkProvider.d.ts +0 -11
- package/dist/lsp/DocumentLinkProvider.js +0 -58
- package/dist/lsp/DocumentSymbolProvider.d.ts +0 -33
- package/dist/lsp/DocumentSymbolProvider.js +0 -317
- package/dist/lsp/HoverProvider.d.ts +0 -10
- package/dist/lsp/HoverProvider.js +0 -106
- package/dist/lsp/RenameProvider.d.ts +0 -5
- package/dist/lsp/RenameProvider.js +0 -6
- package/dist/lsp/SemanticTokenProvider.d.ts +0 -12
- package/dist/lsp/SemanticTokenProvider.js +0 -264
- package/dist/lsp/index.d.ts +0 -8
- package/dist/lsp/index.js +0 -9
- package/dist/mcp/MCPServerFactory.d.ts +0 -8
- package/dist/mcp/MCPServerFactory.js +0 -73
- package/dist/mcp/NoopLikeC4MCPServer.d.ts +0 -9
- package/dist/mcp/NoopLikeC4MCPServer.js +0 -17
- package/dist/mcp/interfaces.d.ts +0 -13
- package/dist/mcp/interfaces.js +0 -5
- package/dist/mcp/server/StdioLikeC4MCPServer.d.ts +0 -16
- package/dist/mcp/server/StdioLikeC4MCPServer.js +0 -51
- package/dist/mcp/server/StreamableLikeC4MCPServer.d.ts +0 -16
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +0 -145
- package/dist/mcp/server/WithMCPServer.d.ts +0 -4
- package/dist/mcp/server/WithMCPServer.js +0 -54
- package/dist/mcp/tools/_common.d.ts +0 -88
- package/dist/mcp/tools/_common.js +0 -49
- package/dist/mcp/tools/find-relationships.d.ts +0 -12
- package/dist/mcp/tools/find-relationships.js +0 -150
- package/dist/mcp/tools/list-projects.d.ts +0 -6
- package/dist/mcp/tools/list-projects.js +0 -62
- package/dist/mcp/tools/open-view.d.ts +0 -10
- package/dist/mcp/tools/open-view.js +0 -52
- package/dist/mcp/tools/read-deployment.d.ts +0 -10
- package/dist/mcp/tools/read-deployment.js +0 -150
- package/dist/mcp/tools/read-element.d.ts +0 -10
- package/dist/mcp/tools/read-element.js +0 -218
- package/dist/mcp/tools/read-project-summary.d.ts +0 -8
- package/dist/mcp/tools/read-project-summary.js +0 -176
- package/dist/mcp/tools/read-view.d.ts +0 -10
- package/dist/mcp/tools/read-view.js +0 -203
- package/dist/mcp/tools/search-element.d.ts +0 -8
- package/dist/mcp/tools/search-element.js +0 -177
- package/dist/mcp/utils.d.ts +0 -18
- package/dist/mcp/utils.js +0 -48
- package/dist/model/builder/MergedExtends.d.ts +0 -13
- package/dist/model/builder/MergedExtends.js +0 -74
- package/dist/model/builder/MergedSpecification.d.ts +0 -32
- package/dist/model/builder/MergedSpecification.js +0 -175
- package/dist/model/builder/buildModel.d.ts +0 -16
- package/dist/model/builder/buildModel.js +0 -245
- package/dist/model/deployments-index.d.ts +0 -10
- package/dist/model/deployments-index.js +0 -102
- package/dist/model/fqn-index.d.ts +0 -61
- package/dist/model/fqn-index.js +0 -253
- package/dist/model/index.d.ts +0 -6
- package/dist/model/index.js +0 -6
- package/dist/model/model-builder.d.ts +0 -52
- package/dist/model/model-builder.js +0 -224
- package/dist/model/model-locator.d.ts +0 -39
- package/dist/model/model-locator.js +0 -240
- package/dist/model/model-parser-where.d.ts +0 -4
- package/dist/model/model-parser-where.js +0 -81
- package/dist/model/model-parser.d.ts +0 -645
- package/dist/model/model-parser.js +0 -133
- package/dist/model/parser/Base.d.ts +0 -69
- package/dist/model/parser/Base.js +0 -372
- package/dist/model/parser/DeploymentModelParser.d.ts +0 -71
- package/dist/model/parser/DeploymentModelParser.js +0 -176
- package/dist/model/parser/DeploymentViewParser.d.ts +0 -75
- package/dist/model/parser/DeploymentViewParser.js +0 -86
- package/dist/model/parser/FqnRefParser.d.ts +0 -66
- package/dist/model/parser/FqnRefParser.js +0 -382
- package/dist/model/parser/GlobalsParser.d.ts +0 -109
- package/dist/model/parser/GlobalsParser.js +0 -84
- package/dist/model/parser/ImportsParser.d.ts +0 -46
- package/dist/model/parser/ImportsParser.js +0 -24
- package/dist/model/parser/ModelParser.d.ts +0 -71
- package/dist/model/parser/ModelParser.js +0 -209
- package/dist/model/parser/PredicatesParser.d.ts +0 -75
- package/dist/model/parser/PredicatesParser.js +0 -45
- package/dist/model/parser/SpecificationParser.d.ts +0 -53
- package/dist/model/parser/SpecificationParser.js +0 -113
- package/dist/model/parser/ValueConverter.d.ts +0 -4
- package/dist/model/parser/ValueConverter.js +0 -12
- package/dist/model/parser/ViewsParser.d.ts +0 -112
- package/dist/model/parser/ViewsParser.js +0 -492
- package/dist/model-change/ModelChanges.d.ts +0 -18
- package/dist/model-change/ModelChanges.js +0 -129
- package/dist/model-change/changeElementStyle.d.ts +0 -16
- package/dist/model-change/changeElementStyle.js +0 -134
- package/dist/model-change/changeViewLayout.d.ts +0 -12
- package/dist/model-change/changeViewLayout.js +0 -28
- package/dist/model-change/removeManualLayoutV1.d.ts +0 -7
- package/dist/model-change/removeManualLayoutV1.js +0 -27
- package/dist/module.d.ts +0 -92
- package/dist/module.js +0 -143
- package/dist/protocol.d.ts +0 -284
- package/dist/protocol.js +0 -123
- package/dist/references/index.d.ts +0 -3
- package/dist/references/index.js +0 -3
- package/dist/references/name-provider.d.ts +0 -9
- package/dist/references/name-provider.js +0 -37
- package/dist/references/scope-computation.d.ts +0 -20
- package/dist/references/scope-computation.js +0 -288
- package/dist/references/scope-provider.d.ts +0 -40
- package/dist/references/scope-provider.js +0 -239
- package/dist/shared/NodeKindProvider.d.ts +0 -15
- package/dist/shared/NodeKindProvider.js +0 -57
- package/dist/shared/WorkspaceSymbolProvider.d.ts +0 -3
- package/dist/shared/WorkspaceSymbolProvider.js +0 -3
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared/index.js +0 -2
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.js +0 -1
- package/dist/test/testServices.d.ts +0 -64
- package/dist/test/testServices.js +0 -210
- package/dist/utils/disposable.d.ts +0 -8
- package/dist/utils/disposable.js +0 -26
- package/dist/utils/elementRef.d.ts +0 -11
- package/dist/utils/elementRef.js +0 -27
- package/dist/utils/fqnRef.d.ts +0 -11
- package/dist/utils/fqnRef.js +0 -63
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -35
- package/dist/utils/printDocs.d.ts +0 -2
- package/dist/utils/printDocs.js +0 -1
- package/dist/utils/projectId.d.ts +0 -4
- package/dist/utils/projectId.js +0 -16
- package/dist/utils/stringHash.d.ts +0 -1
- package/dist/utils/stringHash.js +0 -5
- package/dist/validation/DocumentValidator.d.ts +0 -11
- package/dist/validation/DocumentValidator.js +0 -17
- package/dist/validation/_shared.d.ts +0 -3
- package/dist/validation/_shared.js +0 -26
- package/dist/validation/deployment-checks.d.ts +0 -7
- package/dist/validation/deployment-checks.js +0 -140
- package/dist/validation/dynamic-view.d.ts +0 -6
- package/dist/validation/dynamic-view.js +0 -67
- package/dist/validation/element-ref.d.ts +0 -4
- package/dist/validation/element-ref.js +0 -12
- package/dist/validation/element.d.ts +0 -4
- package/dist/validation/element.js +0 -49
- package/dist/validation/imports.d.ts +0 -4
- package/dist/validation/imports.js +0 -46
- package/dist/validation/index.d.ts +0 -15
- package/dist/validation/index.js +0 -167
- package/dist/validation/property-checks.d.ts +0 -7
- package/dist/validation/property-checks.js +0 -108
- package/dist/validation/relation.d.ts +0 -6
- package/dist/validation/relation.js +0 -141
- package/dist/validation/specification.d.ts +0 -12
- package/dist/validation/specification.js +0 -190
- package/dist/validation/view-checks.d.ts +0 -4
- package/dist/validation/view-checks.js +0 -46
- package/dist/validation/view-predicates/fqn-expr-with.d.ts +0 -4
- package/dist/validation/view-predicates/fqn-expr-with.js +0 -43
- package/dist/validation/view-predicates/fqn-ref-expr.d.ts +0 -4
- package/dist/validation/view-predicates/fqn-ref-expr.js +0 -51
- package/dist/validation/view-predicates/incoming.d.ts +0 -4
- package/dist/validation/view-predicates/incoming.js +0 -16
- package/dist/validation/view-predicates/index.d.ts +0 -6
- package/dist/validation/view-predicates/index.js +0 -6
- package/dist/validation/view-predicates/outgoing.d.ts +0 -4
- package/dist/validation/view-predicates/outgoing.js +0 -20
- package/dist/validation/view-predicates/relation-expr.d.ts +0 -4
- package/dist/validation/view-predicates/relation-expr.js +0 -46
- package/dist/validation/view-predicates/relation-with.d.ts +0 -4
- package/dist/validation/view-predicates/relation-with.js +0 -16
- package/dist/validation/view.d.ts +0 -4
- package/dist/validation/view.js +0 -42
- package/dist/view-utils/assignNavigateTo.d.ts +0 -2
- package/dist/view-utils/assignNavigateTo.js +0 -27
- package/dist/view-utils/index.d.ts +0 -2
- package/dist/view-utils/index.js +0 -2
- package/dist/view-utils/manual-layout.d.ts +0 -13
- package/dist/view-utils/manual-layout.js +0 -149
- package/dist/views/ConfigurableLayouter.d.ts +0 -7
- package/dist/views/ConfigurableLayouter.js +0 -51
- package/dist/views/LikeC4ManualLayouts.d.ts +0 -42
- package/dist/views/LikeC4ManualLayouts.js +0 -209
- package/dist/views/LikeC4Views.d.ts +0 -89
- package/dist/views/LikeC4Views.js +0 -216
- package/dist/views/index.d.ts +0 -4
- package/dist/views/index.js +0 -11
- package/dist/workspace/AstNodeDescriptionProvider.d.ts +0 -7
- package/dist/workspace/AstNodeDescriptionProvider.js +0 -18
- package/dist/workspace/IndexManager.d.ts +0 -10
- package/dist/workspace/IndexManager.js +0 -26
- package/dist/workspace/LangiumDocuments.d.ts +0 -25
- package/dist/workspace/LangiumDocuments.js +0 -98
- package/dist/workspace/ProjectsManager.d.ts +0 -130
- package/dist/workspace/ProjectsManager.js +0 -605
- package/dist/workspace/WorkspaceManager.d.ts +0 -31
- package/dist/workspace/WorkspaceManager.js +0 -132
- package/dist/workspace/index.d.ts +0 -5
- package/dist/workspace/index.js +0 -5
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type * as c4 from '@likec4/core';
|
|
2
|
-
import { FqnRef } from '@likec4/core/types';
|
|
3
|
-
import { type ParsedAstElement, type ParsedAstExtend, type ParsedAstExtendRelation, type ParsedAstRelation, ast } from '../../ast';
|
|
4
|
-
import type { WithExpressionV2 } from './FqnRefParser';
|
|
5
|
-
export type WithModel = ReturnType<typeof ModelParser>;
|
|
6
|
-
export declare function ModelParser<TBase extends WithExpressionV2>(B: TBase): {
|
|
7
|
-
new (...args: any[]): {
|
|
8
|
-
parseModel(): void;
|
|
9
|
-
parseElement(astNode: ast.Element): ParsedAstElement;
|
|
10
|
-
parseExtendElement(astNode: ast.ExtendElement): ParsedAstExtend | null;
|
|
11
|
-
parseExtendRelation(astNode: ast.ExtendRelation): ParsedAstExtendRelation | null;
|
|
12
|
-
_resolveRelationSource(node: ast.Relation): FqnRef.ModelRef | FqnRef.ImportRef;
|
|
13
|
-
parseRelation(astNode: ast.Relation): ParsedAstRelation;
|
|
14
|
-
parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
|
|
15
|
-
parseExpressionV2(astNode: ast.ExpressionV2): c4.Expression;
|
|
16
|
-
parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
|
|
17
|
-
parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
|
|
18
|
-
parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
|
|
19
|
-
parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
|
|
20
|
-
parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
|
|
21
|
-
parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
|
|
22
|
-
parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
|
|
23
|
-
parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
|
|
24
|
-
parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
|
|
25
|
-
parseCustomRelationProperties(custom: ast.CustomRelationProperties | undefined): import("type-fest").Except<c4.RelationExpr.Custom["customRelation"], "expr">;
|
|
26
|
-
parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
|
|
27
|
-
parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
|
|
28
|
-
parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr.OrWhere;
|
|
29
|
-
parseInlineKindCondition(astNode: ast.OutgoingRelationExpr): c4.WhereOperator | null;
|
|
30
|
-
wrapInWhere(expr: c4.RelationExpr, condition: c4.WhereOperator | null): c4.RelationExpr.OrWhere;
|
|
31
|
-
isValid: import("../../validation").IsValidFn;
|
|
32
|
-
readonly services: import("../..").LikeC4Services;
|
|
33
|
-
readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
|
|
34
|
-
get project(): import("../../workspace").Project;
|
|
35
|
-
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
36
|
-
getAstNodePath(node: import("langium").AstNode): string;
|
|
37
|
-
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
38
|
-
[key: string]: string | string[];
|
|
39
|
-
} | undefined;
|
|
40
|
-
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
41
|
-
convertTags<E extends {
|
|
42
|
-
tags?: ast.Tags;
|
|
43
|
-
}>(withTags?: E | undefined): c4.NonEmptyArray<c4.Tag<string>> | null;
|
|
44
|
-
parseTags<E extends {
|
|
45
|
-
tags?: ast.Tags;
|
|
46
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
47
|
-
convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
48
|
-
parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
49
|
-
parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
|
|
50
|
-
parseImageAlias(value: string): string | undefined;
|
|
51
|
-
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
52
|
-
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
53
|
-
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
54
|
-
parseBaseProps(props: {
|
|
55
|
-
title?: ast.MarkdownOrString | undefined;
|
|
56
|
-
summary?: ast.MarkdownOrString | undefined;
|
|
57
|
-
description?: ast.MarkdownOrString | undefined;
|
|
58
|
-
technology?: ast.MarkdownOrString | undefined;
|
|
59
|
-
}, override?: {
|
|
60
|
-
title?: string | undefined;
|
|
61
|
-
summary?: string | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
technology?: string | undefined;
|
|
64
|
-
}): {
|
|
65
|
-
title?: string;
|
|
66
|
-
summary?: c4.MarkdownOrString;
|
|
67
|
-
description?: c4.MarkdownOrString;
|
|
68
|
-
technology?: string;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
} & TBase;
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
//
|
|
3
|
-
// Copyright (c) 2023-2025 Denis Davydkov
|
|
4
|
-
// Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
5
|
-
//
|
|
6
|
-
// Portions of this file have been modified by NVIDIA CORPORATION & AFFILIATES.
|
|
7
|
-
import { invariant, isNonEmptyArray, LinkedList, nonexhaustive, nonNullable } from '@likec4/core';
|
|
8
|
-
import { exact, FqnRef } from '@likec4/core/types';
|
|
9
|
-
import { loggable } from '@likec4/log';
|
|
10
|
-
import { filter, first, isDefined, isEmpty, isTruthy, map, mapToObj, pipe } from 'remeda';
|
|
11
|
-
import { ast, toRelationshipStyle, } from '../../ast';
|
|
12
|
-
import { logger as mainLogger } from '../../logger';
|
|
13
|
-
import { stringHash } from '../../utils/stringHash';
|
|
14
|
-
const logger = mainLogger.getChild('ModelParser');
|
|
15
|
-
function* streamModel(doc) {
|
|
16
|
-
const traverseStack = LinkedList.from(doc.parseResult.value.models.flatMap(m => m.elements));
|
|
17
|
-
const relations = [];
|
|
18
|
-
let el;
|
|
19
|
-
while ((el = traverseStack.shift())) {
|
|
20
|
-
if (ast.isRelation(el)) {
|
|
21
|
-
relations.push(el);
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
// Skip ExtendRelation as it doesn't have child elements
|
|
25
|
-
if (ast.isExtendRelation(el)) {
|
|
26
|
-
yield el;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (el.body && 'elements' in el.body && el.body.elements && el.body.elements.length > 0) {
|
|
30
|
-
for (const child of el.body.elements) {
|
|
31
|
-
traverseStack.push(child);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
yield el;
|
|
35
|
-
}
|
|
36
|
-
yield* relations;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
export function ModelParser(B) {
|
|
40
|
-
return class ModelParser extends B {
|
|
41
|
-
parseModel() {
|
|
42
|
-
const doc = this.doc;
|
|
43
|
-
for (const el of streamModel(doc)) {
|
|
44
|
-
try {
|
|
45
|
-
if (ast.isElement(el)) {
|
|
46
|
-
doc.c4Elements.push(this.parseElement(el));
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (ast.isRelation(el)) {
|
|
50
|
-
if (this.isValid(el)) {
|
|
51
|
-
doc.c4Relations.push(this.parseRelation(el));
|
|
52
|
-
}
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (ast.isExtendElement(el)) {
|
|
56
|
-
const parsed = this.parseExtendElement(el);
|
|
57
|
-
if (parsed) {
|
|
58
|
-
doc.c4ExtendElements.push(parsed);
|
|
59
|
-
}
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (ast.isExtendRelation(el)) {
|
|
63
|
-
const parsed = this.parseExtendRelation(el);
|
|
64
|
-
if (parsed) {
|
|
65
|
-
doc.c4ExtendRelations.push(parsed);
|
|
66
|
-
}
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
nonexhaustive(el);
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
const astPath = this.getAstNodePath(el);
|
|
73
|
-
const error = loggable(e);
|
|
74
|
-
const message = e instanceof Error ? e.message : String(error);
|
|
75
|
-
logger.warn(`Error on {eltype}: ${message}\n document: {path}\n astpath: {astPath}\n${error}`, {
|
|
76
|
-
path: doc.uri.path,
|
|
77
|
-
eltype: el.$type,
|
|
78
|
-
astPath,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
parseElement(astNode) {
|
|
84
|
-
const isValid = this.isValid;
|
|
85
|
-
const id = this.resolveFqn(astNode);
|
|
86
|
-
const kind = nonNullable(astNode.kind.ref, 'Element kind is not resolved').name;
|
|
87
|
-
const tags = this.parseTags(astNode.body);
|
|
88
|
-
const style = this.parseElementStyle(astNode.body?.props);
|
|
89
|
-
const metadata = this.getMetadata(astNode.body?.props.find(ast.isMetadataProperty));
|
|
90
|
-
const astPath = this.getAstNodePath(astNode);
|
|
91
|
-
let [_title, _summary, _technology] = astNode.props ?? [];
|
|
92
|
-
const bodyProps = pipe(astNode.body?.props ?? [], filter(isValid), filter(ast.isElementStringProperty), mapToObj(p => [p.key, p.value]));
|
|
93
|
-
const { title, ...descAndTech } = this.parseBaseProps(bodyProps, {
|
|
94
|
-
title: _title,
|
|
95
|
-
summary: _summary,
|
|
96
|
-
technology: _technology,
|
|
97
|
-
});
|
|
98
|
-
const links = this.parseLinks(astNode.body);
|
|
99
|
-
return exact({
|
|
100
|
-
id,
|
|
101
|
-
kind,
|
|
102
|
-
astPath,
|
|
103
|
-
title: title ?? astNode.name,
|
|
104
|
-
metadata,
|
|
105
|
-
tags: tags ?? undefined,
|
|
106
|
-
...(links && isNonEmptyArray(links) && { links }),
|
|
107
|
-
...descAndTech,
|
|
108
|
-
style,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
parseExtendElement(astNode) {
|
|
112
|
-
const id = this.resolveFqn(astNode);
|
|
113
|
-
const tags = this.parseTags(astNode.body);
|
|
114
|
-
const metadata = this.getMetadata(astNode.body?.props.find(ast.isMetadataProperty));
|
|
115
|
-
const astPath = this.getAstNodePath(astNode);
|
|
116
|
-
const links = this.parseLinks(astNode.body) ?? [];
|
|
117
|
-
if (!tags && isEmpty(metadata ?? {}) && isEmpty(links)) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
return exact({
|
|
121
|
-
id,
|
|
122
|
-
astPath,
|
|
123
|
-
metadata,
|
|
124
|
-
tags,
|
|
125
|
-
links: isNonEmptyArray(links) ? links : null,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
parseExtendRelation(astNode) {
|
|
129
|
-
const source = this.parseFqnRef(astNode.source);
|
|
130
|
-
const target = this.parseFqnRef(astNode.target);
|
|
131
|
-
invariant(FqnRef.isModelRef(source) || FqnRef.isImportRef(source), 'Source must be a model reference');
|
|
132
|
-
invariant(FqnRef.isModelRef(target) || FqnRef.isImportRef(target), 'Target must be a model reference');
|
|
133
|
-
const tags = this.parseTags(astNode.body);
|
|
134
|
-
const metadata = this.getMetadata(astNode.body?.props.find(ast.isMetadataProperty));
|
|
135
|
-
const astPath = this.getAstNodePath(astNode);
|
|
136
|
-
const links = this.parseLinks(astNode.body) ?? [];
|
|
137
|
-
if (!tags && isEmpty(metadata ?? {}) && isEmpty(links)) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
// Generate a stable relation ID based on source, target, kind, and title
|
|
141
|
-
// This allows extends to match specific relations between elements
|
|
142
|
-
const kind = (astNode.kind ?? astNode.dotKind?.kind)?.ref?.name;
|
|
143
|
-
// Normalize title the same way as parseRelation does
|
|
144
|
-
const { title = '' } = this.parseBaseProps({}, { title: astNode.title });
|
|
145
|
-
const id = stringHash('extend-relation', FqnRef.flatten(source), FqnRef.flatten(target), kind ?? 'default', title);
|
|
146
|
-
return exact({
|
|
147
|
-
id,
|
|
148
|
-
astPath,
|
|
149
|
-
metadata,
|
|
150
|
-
tags,
|
|
151
|
-
links: isNonEmptyArray(links) ? links : null,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
_resolveRelationSource(node) {
|
|
155
|
-
if (isDefined(node.source)) {
|
|
156
|
-
const source = this.parseFqnRef(node.source);
|
|
157
|
-
invariant(FqnRef.isModelRef(source) || FqnRef.isImportRef(source), 'Relation source must be a model reference');
|
|
158
|
-
return source;
|
|
159
|
-
}
|
|
160
|
-
if (ast.isElementBody(node.$container)) {
|
|
161
|
-
return {
|
|
162
|
-
model: this.resolveFqn(node.$container.$container),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
if (ast.isExtendElementBody(node.$container)) {
|
|
166
|
-
return {
|
|
167
|
-
model: this.resolveFqn(node.$container.$container),
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
throw new Error('RelationRefError: Invalid container for sourceless relation');
|
|
171
|
-
}
|
|
172
|
-
parseRelation(astNode) {
|
|
173
|
-
const isValid = this.isValid;
|
|
174
|
-
const source = this._resolveRelationSource(astNode);
|
|
175
|
-
const target = this.parseFqnRef(astNode.target);
|
|
176
|
-
invariant(FqnRef.isModelRef(target) || FqnRef.isImportRef(target), 'Target must be a model reference');
|
|
177
|
-
const tags = this.parseTags(astNode) ?? this.parseTags(astNode.body);
|
|
178
|
-
const links = this.parseLinks(astNode.body);
|
|
179
|
-
const kind = (astNode.kind ?? astNode.dotKind?.kind)?.ref?.name;
|
|
180
|
-
const metadata = this.getMetadata(astNode.body?.props.find(ast.isMetadataProperty));
|
|
181
|
-
const astPath = this.getAstNodePath(astNode);
|
|
182
|
-
const bodyProps = pipe(astNode.body?.props ?? [], filter(ast.isRelationStringProperty), filter(p => isTruthy(p.value)), mapToObj(p => [p.key, p.value]));
|
|
183
|
-
const navigateTo = pipe(astNode.body?.props ?? [], filter(ast.isRelationNavigateToProperty), map(p => p.value.view.ref?.name), filter(isTruthy), first());
|
|
184
|
-
const { title = '', description, technology } = this.parseBaseProps(bodyProps, {
|
|
185
|
-
// inline props
|
|
186
|
-
title: astNode.title,
|
|
187
|
-
description: astNode.description,
|
|
188
|
-
technology: astNode.technology,
|
|
189
|
-
});
|
|
190
|
-
const styleProp = astNode.body?.props.find(ast.isRelationStyleProperty);
|
|
191
|
-
const id = stringHash(astPath, source.model, target.model);
|
|
192
|
-
return exact({
|
|
193
|
-
id,
|
|
194
|
-
astPath,
|
|
195
|
-
source,
|
|
196
|
-
target,
|
|
197
|
-
title,
|
|
198
|
-
metadata,
|
|
199
|
-
kind,
|
|
200
|
-
tags: tags ?? undefined,
|
|
201
|
-
links: isNonEmptyArray(links) ? links : undefined,
|
|
202
|
-
navigateTo: navigateTo ? navigateTo : undefined,
|
|
203
|
-
description,
|
|
204
|
-
technology,
|
|
205
|
-
...toRelationshipStyle(styleProp?.props, isValid),
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type * as c4 from '@likec4/core';
|
|
2
|
-
import { ast } from '../../ast';
|
|
3
|
-
import type { WithExpressionV2 } from './FqnRefParser';
|
|
4
|
-
export type WithPredicates = ReturnType<typeof PredicatesParser>;
|
|
5
|
-
export declare function PredicatesParser<TBase extends WithExpressionV2>(B: TBase): {
|
|
6
|
-
new (...args: any[]): {
|
|
7
|
-
parsePredicate(astNode: ast.ExpressionV2): c4.ModelExpression;
|
|
8
|
-
parseElementPredicate(astNode: ast.FqnExprOrWith): c4.ModelFqnExpr.Any;
|
|
9
|
-
parseElementPredicateOrWhere(astNode: ast.FqnExprOrWhere): c4.ModelFqnExpr.OrWhere;
|
|
10
|
-
parseElementExpression(astNode: ast.FqnExpr): c4.ModelFqnExpr;
|
|
11
|
-
parseElementPredicateWhere(astNode: ast.FqnExprWhere): c4.ModelFqnExpr.Where;
|
|
12
|
-
parseElementPredicateWith(astNode: ast.FqnExprWith): c4.ModelFqnExpr.Custom;
|
|
13
|
-
parseRelationPredicate(astNode: ast.RelationExprOrWith): c4.ModelRelationExpr.Any;
|
|
14
|
-
parseRelationPredicateOrWhere(astNode: ast.RelationExprOrWhere): c4.ModelRelationExpr.OrWhere;
|
|
15
|
-
parseRelationPredicateWhere(astNode: ast.RelationExprWhere): c4.ModelRelationExpr.Where;
|
|
16
|
-
parseRelationPredicateWith(astNode: ast.RelationExprWith): c4.ModelRelationExpr.Custom;
|
|
17
|
-
parseRelationExpression(astNode: ast.RelationExpr): c4.ModelRelationExpr;
|
|
18
|
-
parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
|
|
19
|
-
parseExpressionV2(astNode: ast.ExpressionV2): c4.Expression;
|
|
20
|
-
parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
|
|
21
|
-
parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
|
|
22
|
-
parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
|
|
23
|
-
parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
|
|
24
|
-
parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
|
|
25
|
-
parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
|
|
26
|
-
parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
|
|
27
|
-
parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
|
|
28
|
-
parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
|
|
29
|
-
parseCustomRelationProperties(custom: ast.CustomRelationProperties | undefined): import("type-fest").Except<c4.RelationExpr.Custom["customRelation"], "expr">;
|
|
30
|
-
parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
|
|
31
|
-
parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
|
|
32
|
-
parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr.OrWhere;
|
|
33
|
-
parseInlineKindCondition(astNode: ast.OutgoingRelationExpr): c4.WhereOperator | null;
|
|
34
|
-
wrapInWhere(expr: c4.RelationExpr, condition: c4.WhereOperator | null): c4.RelationExpr.OrWhere;
|
|
35
|
-
isValid: import("../../validation").IsValidFn;
|
|
36
|
-
readonly services: import("../..").LikeC4Services;
|
|
37
|
-
readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
|
|
38
|
-
get project(): import("../../workspace").Project;
|
|
39
|
-
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
40
|
-
getAstNodePath(node: import("langium").AstNode): string;
|
|
41
|
-
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
42
|
-
[key: string]: string | string[];
|
|
43
|
-
} | undefined;
|
|
44
|
-
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
45
|
-
convertTags<E extends {
|
|
46
|
-
tags?: ast.Tags;
|
|
47
|
-
}>(withTags?: E | undefined): c4.NonEmptyArray<c4.Tag<string>> | null;
|
|
48
|
-
parseTags<E extends {
|
|
49
|
-
tags?: ast.Tags;
|
|
50
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
51
|
-
convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
52
|
-
parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
53
|
-
parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
|
|
54
|
-
parseImageAlias(value: string): string | undefined;
|
|
55
|
-
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
56
|
-
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
57
|
-
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
58
|
-
parseBaseProps(props: {
|
|
59
|
-
title?: ast.MarkdownOrString | undefined;
|
|
60
|
-
summary?: ast.MarkdownOrString | undefined;
|
|
61
|
-
description?: ast.MarkdownOrString | undefined;
|
|
62
|
-
technology?: ast.MarkdownOrString | undefined;
|
|
63
|
-
}, override?: {
|
|
64
|
-
title?: string | undefined;
|
|
65
|
-
summary?: string | undefined;
|
|
66
|
-
description?: string | undefined;
|
|
67
|
-
technology?: string | undefined;
|
|
68
|
-
}): {
|
|
69
|
-
title?: string;
|
|
70
|
-
summary?: c4.MarkdownOrString;
|
|
71
|
-
description?: c4.MarkdownOrString;
|
|
72
|
-
technology?: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
} & TBase;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { nonexhaustive } from '@likec4/core';
|
|
2
|
-
import { ast } from '../../ast';
|
|
3
|
-
export function PredicatesParser(B) {
|
|
4
|
-
return class PredicatesParser extends B {
|
|
5
|
-
parsePredicate(astNode) {
|
|
6
|
-
return this.parseExpressionV2(astNode);
|
|
7
|
-
}
|
|
8
|
-
parseElementPredicate(astNode) {
|
|
9
|
-
if (ast.isFqnExprWith(astNode)) {
|
|
10
|
-
return this.parseFqnExprWith(astNode);
|
|
11
|
-
}
|
|
12
|
-
if (ast.isFqnExprOrWhere(astNode)) {
|
|
13
|
-
return this.parseFqnExprOrWhere(astNode);
|
|
14
|
-
}
|
|
15
|
-
nonexhaustive(astNode);
|
|
16
|
-
}
|
|
17
|
-
parseElementPredicateOrWhere(astNode) {
|
|
18
|
-
return this.parseFqnExprOrWhere(astNode);
|
|
19
|
-
}
|
|
20
|
-
parseElementExpression(astNode) {
|
|
21
|
-
return this.parseFqnExpr(astNode);
|
|
22
|
-
}
|
|
23
|
-
parseElementPredicateWhere(astNode) {
|
|
24
|
-
return this.parseFqnExprWhere(astNode);
|
|
25
|
-
}
|
|
26
|
-
parseElementPredicateWith(astNode) {
|
|
27
|
-
return this.parseFqnExprWith(astNode);
|
|
28
|
-
}
|
|
29
|
-
parseRelationPredicate(astNode) {
|
|
30
|
-
return this.parseRelationExprOrWith(astNode);
|
|
31
|
-
}
|
|
32
|
-
parseRelationPredicateOrWhere(astNode) {
|
|
33
|
-
return this.parseRelationExprOrWhere(astNode);
|
|
34
|
-
}
|
|
35
|
-
parseRelationPredicateWhere(astNode) {
|
|
36
|
-
return this.parseRelationExprWhere(astNode);
|
|
37
|
-
}
|
|
38
|
-
parseRelationPredicateWith(astNode) {
|
|
39
|
-
return this.parseRelationExprWith(astNode);
|
|
40
|
-
}
|
|
41
|
-
parseRelationExpression(astNode) {
|
|
42
|
-
return this.parseRelationExpr(astNode);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as c4 from '@likec4/core';
|
|
2
|
-
import { ast } from '../../ast';
|
|
3
|
-
import { type Base } from './Base';
|
|
4
|
-
export declare function SpecificationParser<TBase extends Base>(B: TBase): {
|
|
5
|
-
new (...args: any[]): {
|
|
6
|
-
parseSpecification(): void;
|
|
7
|
-
parseElementSpecificationNode(specAst: ast.SpecificationElementKind): {
|
|
8
|
-
[key: c4.ElementKind]: c4.ElementSpecification;
|
|
9
|
-
};
|
|
10
|
-
parseElementSpecificationNode(specAst: ast.SpecificationDeploymentNodeKind): {
|
|
11
|
-
[key: c4.DeploymentKind]: c4.ElementSpecification;
|
|
12
|
-
};
|
|
13
|
-
isValid: import("../../validation").IsValidFn;
|
|
14
|
-
readonly services: import("../..").LikeC4Services;
|
|
15
|
-
readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
|
|
16
|
-
get project(): import("../../workspace").Project;
|
|
17
|
-
resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
|
|
18
|
-
getAstNodePath(node: import("langium").AstNode): string;
|
|
19
|
-
getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
|
|
20
|
-
[key: string]: string | string[];
|
|
21
|
-
} | undefined;
|
|
22
|
-
parseMarkdownOrString(markdownOrString: ast.MarkdownOrString | undefined): c4.MarkdownOrString | undefined;
|
|
23
|
-
convertTags<E extends {
|
|
24
|
-
tags?: ast.Tags;
|
|
25
|
-
}>(withTags?: E | undefined): c4.NonEmptyArray<c4.Tag<string>> | null;
|
|
26
|
-
parseTags<E extends {
|
|
27
|
-
tags?: ast.Tags;
|
|
28
|
-
}>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
|
|
29
|
-
convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
30
|
-
parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
|
|
31
|
-
parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
|
|
32
|
-
parseImageAlias(value: string): string | undefined;
|
|
33
|
-
parseColorLiteral(astNode: ast.ColorLiteral): c4.ColorLiteral | undefined;
|
|
34
|
-
parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
|
|
35
|
-
parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
|
|
36
|
-
parseBaseProps(props: {
|
|
37
|
-
title?: ast.MarkdownOrString | undefined;
|
|
38
|
-
summary?: ast.MarkdownOrString | undefined;
|
|
39
|
-
description?: ast.MarkdownOrString | undefined;
|
|
40
|
-
technology?: ast.MarkdownOrString | undefined;
|
|
41
|
-
}, override?: {
|
|
42
|
-
title?: string | undefined;
|
|
43
|
-
summary?: string | undefined;
|
|
44
|
-
description?: string | undefined;
|
|
45
|
-
technology?: string | undefined;
|
|
46
|
-
}): {
|
|
47
|
-
title?: string;
|
|
48
|
-
summary?: c4.MarkdownOrString;
|
|
49
|
-
description?: c4.MarkdownOrString;
|
|
50
|
-
technology?: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
} & TBase;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import * as c4 from '@likec4/core';
|
|
2
|
-
import { exact } from '@likec4/core';
|
|
3
|
-
import { nonNullable } from '@likec4/core/utils';
|
|
4
|
-
import { loggable } from '@likec4/log';
|
|
5
|
-
import { filter, isNonNullish, isNullish, isTruthy, mapToObj, omitBy, pipe } from 'remeda';
|
|
6
|
-
import { ast, parseMarkdownAsString, toRelationshipStyle } from '../../ast';
|
|
7
|
-
import { serverLogger } from '../../logger';
|
|
8
|
-
import { removeIndent } from './Base';
|
|
9
|
-
const logger = serverLogger.getChild('SpecificationParser');
|
|
10
|
-
export function SpecificationParser(B) {
|
|
11
|
-
return class SpecificationParser extends B {
|
|
12
|
-
parseSpecification() {
|
|
13
|
-
const { parseResult: { value: { specifications, }, }, c4Specification, } = this.doc;
|
|
14
|
-
const isValid = this.isValid;
|
|
15
|
-
for (const elementSpec of specifications.flatMap(s => s.elements.filter(isValid))) {
|
|
16
|
-
try {
|
|
17
|
-
Object.assign(c4Specification.elements, this.parseElementSpecificationNode(elementSpec));
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
logger.warn(loggable(e));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
for (const deploymentNodeSpec of specifications.flatMap(s => s.deploymentNodes.filter(isValid))) {
|
|
24
|
-
try {
|
|
25
|
-
Object.assign(c4Specification.deployments, this.parseElementSpecificationNode(deploymentNodeSpec));
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
logger.warn(loggable(e));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const relations_specs = specifications.flatMap(s => s.relationships.filter(this.isValid));
|
|
32
|
-
for (const { kind, props } of relations_specs) {
|
|
33
|
-
try {
|
|
34
|
-
const kindName = kind.name;
|
|
35
|
-
if (!isTruthy(kindName)) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (kindName in c4Specification.relationships) {
|
|
39
|
-
logger.warn(`Relationship kind "${kindName}" is already defined`);
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const bodyProps = pipe(props.filter(ast.isSpecificationRelationshipStringProperty) ?? [], filter(p => this.isValid(p) && isNonNullish(p.value)), mapToObj(p => [p.key, removeIndent(parseMarkdownAsString(p.value))]), omitBy(isNullish));
|
|
43
|
-
c4Specification.relationships[kindName] = {
|
|
44
|
-
...bodyProps,
|
|
45
|
-
...toRelationshipStyle(props.filter(ast.isRelationshipStyleProperty), this.isValid),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
logger.warn(loggable(e));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const tags_specs = specifications.flatMap(s => s.tags.filter(this.isValid));
|
|
53
|
-
for (const tagSpec of tags_specs) {
|
|
54
|
-
try {
|
|
55
|
-
const tag = tagSpec.tag.name;
|
|
56
|
-
const astPath = this.getAstNodePath(tagSpec.tag);
|
|
57
|
-
const color = tagSpec.color && this.parseColorLiteral(tagSpec.color);
|
|
58
|
-
if (tag in c4Specification.tags) {
|
|
59
|
-
logger.warn(`Tag {tag} is already defined, skipping duplicate`, { tag });
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (isTruthy(tag)) {
|
|
63
|
-
c4Specification.tags[tag] = {
|
|
64
|
-
astPath,
|
|
65
|
-
...(color ? { color } : {}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
logger.warn(loggable(e));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const colors_specs = specifications.flatMap(s => s.colors.filter(isValid));
|
|
74
|
-
for (const { name, color } of colors_specs) {
|
|
75
|
-
try {
|
|
76
|
-
const colorName = name.name;
|
|
77
|
-
if (colorName in c4Specification.colors) {
|
|
78
|
-
logger.warn(`Custom color "${colorName}" is already defined`);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
c4Specification.colors[colorName] = {
|
|
82
|
-
color: nonNullable(this.parseColorLiteral(color), `Color "${colorName}" is not valid`),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
logger.warn(loggable(e));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
parseElementSpecificationNode(specAst) {
|
|
91
|
-
const { kind, props } = specAst;
|
|
92
|
-
const kindName = kind.name;
|
|
93
|
-
if (!isTruthy(kindName)) {
|
|
94
|
-
throw new Error('DeploymentNodeKind name is not resolved');
|
|
95
|
-
}
|
|
96
|
-
const tags = this.parseTags(specAst);
|
|
97
|
-
const style = this.parseElementStyle(props.find(ast.isElementStyleProperty));
|
|
98
|
-
const links = this.parseLinks(specAst);
|
|
99
|
-
const bodyProps = pipe(props.filter(ast.isSpecificationElementStringProperty) ?? [], filter(p => this.isValid(p)), mapToObj(p => [p.key, p.value]));
|
|
100
|
-
const baseProps = this.parseBaseProps(bodyProps);
|
|
101
|
-
const notation = removeIndent(parseMarkdownAsString(bodyProps.notation));
|
|
102
|
-
return {
|
|
103
|
-
[kindName]: exact({
|
|
104
|
-
...baseProps,
|
|
105
|
-
notation,
|
|
106
|
-
tags: tags ?? undefined,
|
|
107
|
-
...(links && c4.isNonEmptyArray(links) && { links }),
|
|
108
|
-
style,
|
|
109
|
-
}),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DefaultValueConverter, ValueConverter } from 'langium';
|
|
2
|
-
export class LikeC4ValueConverter extends DefaultValueConverter {
|
|
3
|
-
runConverter(rule, input, cstNode) {
|
|
4
|
-
if (rule.name === 'MarkdownString') {
|
|
5
|
-
if ((input.startsWith('"""') && input.endsWith('"""')) || (input.startsWith(`'''`) && input.endsWith(`'''`))) {
|
|
6
|
-
input = input.slice(2, -2);
|
|
7
|
-
}
|
|
8
|
-
return ValueConverter.convertString(input);
|
|
9
|
-
}
|
|
10
|
-
return super.runConverter(rule, input, cstNode);
|
|
11
|
-
}
|
|
12
|
-
}
|