import { r as __name } from "./rolldown-runtime.mjs"; import { Bi as NodeId, Bt as DeploymentRelationship, C as ComputedView, Ct as ViewManualLayoutSnapshot, Di as toComputed, Er as RelationshipArrowType, Ft as DeployedInstance, Gr as Any, Gt as ElementStyle, Hi as ProjectId, Ii as GroupElementKind, It as DeploymentElement, Jr as AnyParsed, Kr as AnyComputed, M as ViewWithType, Mi as EdgeId, Mt as Specification, O as ProcessedView, Qr as DeploymentKind, Ri as IconUrl, Rt as DeploymentNode, Si as ViewId, T as LayoutedView, Ui as RelationId, Wt as Element, Xr as DeploymentFqn, Yi as ViewId$1, Yr as Aux, Zr as DeploymentId, _ as AuxFromLikeC4ModelData, _a as Link, _i as Tags, aa as _stage, b as LikeC4ModelData, bi as UnknownLayouted, ci as Metadata, di as RelationId$1, ei as ElementId, en as ModelGlobals, et as ComputedNodeStyle, f as AuxFromDump, fi as RelationKind, fr as FqnRef, gi as Tag, ha as IteratorLike, hi as StrictViewId, ii as LooseElementId, kr as RelationshipLineType, li as MetadataKey, mi as Stage, mr as Color, ni as Fqn, nn as DynamicViewDisplayVariant, oa as _type, oi as LooseTag, p as LikeC4ModelDump, qr as AnyLayouted, qt as Relationship, ri as LooseDeploymentId, rr as WhereOperator, si as LooseViewId, ti as ElementKind, u as RichTextOrEmpty, ui as ProjectId$1, v as ComputedLikeC4ModelData, vi as Unknown, wt as LikeC4Project, x as ParsedLikeC4ModelData, xi as UnknownParsed, y as LayoutedLikeC4ModelData, ya as NonEmptyArray, yi as UnknownComputed, yr as ElementShape } from "./index.mjs"; import { i as BBox } from "./index2.mjs"; import { o as LikeC4Styles } from "./index3.mjs"; import { t as DefaultMap } from "./default-map.mjs"; import { IsAny, SetRequired, Tagged } from "type-fest"; //#region src/model/RelationModel.d.ts type RelationshipsIterator = IteratorLike>; /** * A relationship between two elements (in logical or deployment model) * use {@link isDeploymentRelationModel} guard to check if the relationship is a deployment relationship */ interface AnyRelationshipModel extends WithTags, WithMetadata { readonly id: RelationId; readonly expression: string; readonly title: string | null; readonly technology: string | null; readonly hasSummary: boolean; readonly summary: RichTextOrEmpty; readonly description: RichTextOrEmpty; readonly navigateTo: LikeC4ViewModel | null; readonly kind: RelationKind | null; readonly links: ReadonlyArray; readonly color: Color; readonly line: RelationshipLineType; readonly head: RelationshipArrowType; readonly tail: RelationshipArrowType | undefined; isDeploymentRelation(): this is DeploymentRelationModel; isModelRelation(): this is RelationshipModel; views(): ViewsIterator; } declare class RelationshipModel implements AnyRelationshipModel { readonly model: LikeC4Model; readonly $relationship: Relationship; readonly source: ElementModel; readonly target: ElementModel; /** * Common ancestor of the source and target elements. * Represents the boundary of the Relation. */ readonly boundary: ElementModel | null; constructor(model: LikeC4Model, $relationship: Relationship); get id(): RelationId; get expression(): string; get title(): string | null; get technology(): string | null; /** * Returns true if the relationship has a summary and a description * (if one is missing - it falls back to another) */ get hasSummary(): boolean; /** * Short description of the relationship. * Falls back to description if summary is not provided. */ get summary(): RichTextOrEmpty; /** * Long description of the relationship. * Falls back to summary if description is not provided. */ get description(): RichTextOrEmpty; get navigateTo(): LikeC4ViewModel | null; get tags(): Tags; get kind(): RelationKind | null; get metadata(): Metadata; get links(): ReadonlyArray; get color(): Color; get line(): RelationshipLineType; get head(): RelationshipArrowType; get tail(): RelationshipArrowType | undefined; /** * Iterate over all views that include this relationship. */ views(): ViewsIterator; isDeploymentRelation(): this is DeploymentRelationModel; isModelRelation(): this is RelationshipModel; hasMetadata(): boolean; getMetadata(): Metadata; getMetadata(field: MetadataKey): string | string[] | undefined; /** * Checks if the relationship has the given tag. */ isTagged(tag: LooseTag): boolean; } //#endregion //#region src/model/ElementModel.d.ts type ElementsIterator = IteratorLike>; declare class ElementModel implements WithTags, WithMetadata { readonly $model: LikeC4Model; readonly $element: Element; /** * Don't use in runtime, only for type inference */ readonly Aux: A; readonly id: Fqn; readonly _literalId: ElementId; readonly hierarchyLevel: number; readonly imported: null | { readonly from: ProjectId; readonly fqn: Fqn; }; constructor($model: LikeC4Model, $element: Element); get name(): string; get parent(): ElementModel | null; get kind(): ElementKind; get shape(): ElementShape; get color(): Color; get icon(): IconUrl | null; /** * Returns all tags of the element. * It includes tags from the element and its kind. */ get tags(): Tags; get metadata(): Metadata; get title(): string; /** * Returns true if the element has a summary and a description * (if one is missing - it falls back to another) */ get hasSummary(): boolean; /** * Short description of the element. * Falls back to description if summary is not provided. */ get summary(): RichTextOrEmpty; /** * Long description of the element. * Falls back to summary if description is not provided. */ get description(): RichTextOrEmpty; get technology(): string | null; get links(): ReadonlyArray; get defaultView(): LikeC4ViewModel.ScopedElementView | null; get isRoot(): boolean; get style(): SetRequired; get projectId(): ProjectId$1; isAncestorOf(another: ElementModel): boolean; isDescendantOf(another: ElementModel): boolean; /** * Get all ancestor elements (i.e. parent, parent’s parent, etc.) * (from closest to root) */ ancestors(): ElementsIterator; /** * Returns the common ancestor of this element and another element. */ commonAncestor(another: ElementModel): ElementModel | null; children(): ReadonlySet>; /** * Get all descendant elements (i.e. children, children’s children, etc.) */ descendants(sort?: 'asc' | 'desc'): ElementsIterator; /** * Get all sibling (i.e. same parent) */ siblings(): ElementsIterator; /** * Resolve siblings of the element and its ancestors * (from closest parent to root) */ ascendingSiblings(): ElementsIterator; /** * Resolve siblings of the element and its ancestors * (from root to closest) */ descendingSiblings(): ElementsIterator; incoming(filter?: IncomingFilter): RelationshipsIterator; incomers(filter?: IncomingFilter): ElementsIterator; outgoing(filter?: OutgoingFilter): RelationshipsIterator; outgoers(filter?: OutgoingFilter): ElementsIterator; get allOutgoing(): ReadonlySet>; get allIncoming(): ReadonlySet>; /** * Iterate over all views that include this element. */ views(): ReadonlySet>; /** * Iterate over all views that scope this element. * It is possible that element is not included in the view. */ scopedViews(): ReadonlySet>; /** * @returns true if the element is deployed */ isDeployed(): boolean; deployments(): DeployedInstancesIterator; hasMetadata(): boolean; getMetadata(): Metadata; getMetadata(field: MetadataKey): string | string[] | undefined; /** * Checks if the element has the given tag. */ isTagged(tag: LooseTag): boolean; } //#endregion //#region src/model/view/NodeModel.d.ts type NodesIterator = $View> = IteratorLike>; declare class NodeModel = $View> implements WithTags { readonly Aux: A; readonly $viewModel: LikeC4ViewModel; readonly $view: V; readonly $node: V['nodes'][number]; constructor($viewModel: LikeC4ViewModel, $node: V['nodes'][number]); get id(): NodeId; get title(): string; get kind(): ElementKind | DeploymentKind | typeof GroupElementKind | 'instance'; get description(): RichTextOrEmpty; get technology(): string | null; get notes(): RichTextOrEmpty; get parent(): NodeModel | null; get element(): ElementModel | null; get deployment(): DeploymentElementModel | null; get shape(): ElementShape; get color(): Color; get icon(): IconUrl | null; get tags(): Tags; get links(): ReadonlyArray; get navigateTo(): LikeC4ViewModel | null; get style(): ComputedNodeStyle; get x(): number | undefined; get y(): number | undefined; get width(): number | undefined; get height(): number | undefined; children(): ReadonlySet>; /** * Get all ancestor elements (i.e. parent, parent’s parent, etc.) * (from closest to root) */ ancestors(): NodesIterator; siblings(): NodesIterator; incoming(filter?: IncomingFilter): EdgesIterator; incomers(filter?: IncomingFilter): NodesIterator; outgoing(filter?: OutgoingFilter): EdgesIterator; outgoers(filter?: OutgoingFilter): NodesIterator; isLayouted(): this is NodeModel.Layouted; hasChildren(): boolean; hasParent(): this is NodeModel.WithParent; /** * Check if this node references to logical model element. */ hasElement(): this is NodeModel.WithElement; /** * Check if this node references to deployment element (Node or Instance). */ hasDeployment(): this is NodeModel.WithDeploymentElement; /** * Check if this node references to deployed instance * Deployed instance always references to element and deployment element. */ hasDeployedInstance(): this is NodeModel.WithDeployedInstance; isGroup(): this is NodeModel.IsGroup; /** * Checks if the node has the given tag. */ isTagged(tag: LooseTag): boolean; } declare namespace NodeModel { type Layouted = A extends AnyLayouted ? NodeModel> & { x: number; y: number; width: number; height: number; } : never; interface WithParent = $View> extends NodeModel { readonly parent: NodeModel; } interface WithElement = $View> extends NodeModel { readonly kind: ElementKind; readonly element: ElementModel; } interface WithDeploymentElement = $View> extends NodeModel { readonly kind: DeploymentKind; readonly deployment: DeploymentElementModel; } interface WithDeployedInstance = $View> extends NodeModel { readonly kind: 'instance'; readonly element: ElementModel; readonly deployment: DeployedInstanceModel; } interface IsGroup = $View> extends NodeModel { readonly kind: typeof GroupElementKind; readonly element: null; readonly deployment: null; } } //#endregion //#region src/model/view/EdgeModel.d.ts type EdgesIterator = $View> = IteratorLike>; declare class EdgeModel = $View> implements WithTags { readonly source: NodeModel; readonly target: NodeModel; readonly Aux: A; readonly $viewModel: LikeC4ViewModel; readonly $view: V; readonly $edge: V['edges'][number]; constructor($viewModel: LikeC4ViewModel, $edge: V['edges'][number], source: NodeModel, target: NodeModel); get id(): EdgeId; get parent(): NodeModel | null; get label(): string | null; get description(): RichTextOrEmpty; get technology(): string | null; hasParent(): this is EdgeModel.WithParent; get tags(): Tags; get navigateTo(): LikeC4ViewModel | null; get color(): Color; get line(): RelationshipLineType; get head(): RelationshipArrowType; get tail(): RelationshipArrowType | undefined; isStep(): boolean; relationships(type: 'model'): IteratorLike>; relationships(type: 'deployment'): IteratorLike>; relationships(type?: 'model' | 'deployment'): IteratorLike | DeploymentRelationModel>; includesRelation(rel: RelationId$1 | { id: RelationId$1; }): boolean; isTagged(tag: LooseTag): boolean; } declare namespace EdgeModel { interface WithParent> extends EdgeModel { readonly parent: NodeModel; } } //#endregion //#region src/model/view/LikeC4ViewsFolder.d.ts declare class LikeC4ViewsFolder { readonly $model: LikeC4Model; /** * Path to this view folder, processed by {@link normalizeViewPath} * * @example * "Folder 1/Folder 2/Folder 3" */ readonly path: string; /** * Title of this view folder. * * @example * // title is the last segment of the path * path = "Folder 1/Folder 2/Folder 3" * title = "Folder 3" */ readonly title: string; /** * Whether this is the root view folder. * * !NOTE * Root folder is special folder with an empty path and used only for internal purposes. \ * It is not visible to the user and should not be used in the code. */ readonly isRoot: boolean; protected readonly parentPath: string | undefined; protected readonly defaultViewId: StrictViewId | undefined; constructor($model: LikeC4Model, path: NonEmptyArray, defaultViewId: StrictViewId | undefined); /** * Default view of this view folder.\ * It is for the case when there is a view at the same path as this folder.\ * (if there are multiple views at the same path, the first one is chosen) * * @example * ``` * // Assume the following views exist: * const views = [ * "Folder 1/ Folder 2 / View", * "Folder 1/ Folder 2 / View / Subview", * ] * ``` * Group with path `Folder 1/ Folder 2 / View`\ * will have default view `Folder 1/ Folder 2 / View` */ get defaultView(): LikeC4ViewModel | null; /** * Returns path to this view folder as an array of ancestors (excluding root) and this view folder as the last element * * @throws Error if this is the root folder. */ get breadcrumbs(): [...LikeC4ViewsFolder[], this]; /** * Returns parent folder * * @throws Error if this is the root folder. */ get parent(): LikeC4ViewsFolder | null; /** * Returns sorted set of children * - First folders * - Then views */ get children(): ReadonlySet | LikeC4ViewModel>; /** * Returns sorted array of children folders */ get folders(): ReadonlyArray>; /** * Returns all views in this view folder. */ get views(): ReadonlyArray>; } //#endregion //#region src/model/view/LikeC4ViewModel.d.ts type ViewsIterator = $View> = IteratorLike>; declare class LikeC4ViewModel = $View> implements WithTags { #private; /** * Don't use in runtime, only for type inference */ readonly Aux: A; readonly id: StrictViewId; /** * The model this view belongs to */ readonly $model: LikeC4Model; /** * The title of the view */ readonly title: string | null; /** * View folder this view belongs to. * If view is top-level, this is the root folder. */ readonly folder: LikeC4ViewsFolder; /** * Path to this view, processed by {@link normalizeViewPath} * * @example * "Group 1/Group 2/View" */ readonly viewPath: string; constructor(model: LikeC4Model, folder: LikeC4ViewsFolder, view: V, manualLayoutSnapshot?: ViewManualLayoutSnapshot | undefined); /** * Returns the styles configuration for the project. */ get $styles(): LikeC4Styles; get _type(): V[_type]; get stage(): V[_stage]; get bounds(): Readonly; /** * Returns title if defined, otherwise returns title of the element it is based on, otherwise returns its {@link id} */ get titleOrId(): string; /** * Returns title if defined, otherwise returns `Untitled`. */ get titleOrUntitled(): string; /** * Returns path to this view as an array of groups and this view as the last element * If view is top-level, returns only this view. * * @example * viewPath = "Group 1/Group 2/View" * * breadcrumbs = [ * "Group 1", // folder * "Group 1/Group 2", // folder * "Group 1/Group 2/View" // view * ] */ get breadcrumbs(): [...LikeC4ViewsFolder[], this]; get description(): RichTextOrEmpty; get tags(): Tags; get links(): ReadonlyArray; get viewOf(): ElementModel | null; /** * Available for dynamic views only * throws error if view is not dynamic */ get mode(): DynamicViewDisplayVariant | null; /** * All tags from nodes and edges. */ get includedTags(): Tags; /** * The original view from the model. * In case of layouted model, this is the latest auto-layouted view without manual changes applied * @see {@link $layouted} should be used for rendering in the UI */ get $view(): V; /** * Returns the view with manual layout applied if it exists, otherwise returns the original view * This should be used for rendering in the UI */ get $layouted(): V; get hasManualLayout(): boolean; get hasLayoutDrifts(): boolean; /** * If view has manual layout, returns it with manual layout applied */ get $manual(): V | null; get projectId(): ProjectId$1; roots(): NodesIterator; /** * Iterate over all nodes that have children. */ compounds(): NodesIterator; /** * Get node by id. * @throws Error if node is not found. */ node(node: NodeOrId): NodeModel; /** * Find node by id. */ findNode(node: NodeOrId): NodeModel | null; findNodeWithElement(element: LooseElementId | { id: Fqn; }): NodeModel.WithElement | null; /** * Iterate over all nodes. */ nodes(): NodesIterator; /** * Get edge by id, throws error if edge is not found. * Use {@link findEdge} if you are not sure if the edge exists. * * @param edge Edge or id * @returns {@link EdgeModel} */ edge(edge: EdgeOrId): EdgeModel; /** * Find edge by id. * @param edge Edge or id * @returns {@link EdgeModel} or null if edge is not found */ findEdge(edge: EdgeOrId): EdgeModel | null; /** * Iterate over all edges. */ edges(): EdgesIterator; /** * Iterate over all edges. */ edgesWithRelation(relation: RelationId$1): EdgesIterator; /** * Nodes that have references to elements from logical model. */ elements(): IteratorLike>; /** * Checks if the view has the given tag. */ isTagged(tag: LooseTag): boolean; includesElement(element: LooseElementId | { id: Fqn; }): boolean; includesDeployment(deployment: LooseDeploymentId | { id: DeploymentFqn; }): boolean; includesRelation(relation: RelationId | { id: RelationId; }): boolean; /** * Below are type guards. */ isComputed(this: LikeC4ViewModel): this is LikeC4ViewModel.Computed>; isLayouted(): this is LikeC4ViewModel.Layouted; /** * @deprecated Use {@link isLayouted} instead */ isDiagram(): this is LikeC4ViewModel.Layouted; isElementView(this: LikeC4ViewModel): this is LikeC4ViewModel.ElementView; isScopedElementView(this: LikeC4ViewModel): this is LikeC4ViewModel.ScopedElementView; isDeploymentView(this: LikeC4ViewModel): this is LikeC4ViewModel.DeploymentView; isDynamicView(this: LikeC4ViewModel): this is LikeC4ViewModel.DynamicView; } declare namespace LikeC4ViewModel { type Computed = A extends AnyComputed ? LikeC4ViewModel> : never; type Layouted = A extends AnyLayouted ? LikeC4ViewModel> : never; interface ElementView = $View> extends LikeC4ViewModel> { readonly mode: never; } interface ScopedElementView extends LikeC4ViewModel, 'element'> & { viewOf: Fqn; }> { readonly mode: never; readonly viewOf: ElementModel; } interface DeploymentView = $View> extends LikeC4ViewModel> { readonly mode: never; } interface DynamicView = $View> extends LikeC4ViewModel> { readonly mode: DynamicViewDisplayVariant; readonly viewOf: never; } } //#endregion //#region src/model/types.d.ts type IncomingFilter = 'all' | 'direct' | 'to-descendants'; type OutgoingFilter = 'all' | 'direct' | 'from-descendants'; type ElementOrFqn = ElementId | { id: Fqn; }; type DeploymentOrFqn = DeploymentId | { id: DeploymentFqn; }; type NodeOrId = string | { id: NodeId; }; type EdgeOrId = string | { id: EdgeId; }; type RelationOrId = string | { id: RelationId; }; type $View = { parsed: never; computed: ComputedView; layouted: LayoutedView; }[Stage]; type $ViewModel = { parsed: never; computed: LikeC4ViewModel>; layouted: LikeC4ViewModel>; }[Stage]; type $ModelData = { parsed: ParsedLikeC4ModelData; computed: ComputedLikeC4ModelData; layouted: LayoutedLikeC4ModelData; }[Stage]; interface WithTags { get tags(): Tags; isTagged(tag: LooseTag): boolean; } interface WithMetadata { hasMetadata(): boolean; getMetadata(): Metadata; getMetadata(field: MetadataKey): string | string[] | undefined; } //#endregion //#region src/model/DeploymentModel.d.ts declare class LikeC4DeploymentModel { #private; readonly $model: LikeC4Model; readonly $deployments: $ModelData['deployments']; constructor($model: LikeC4Model); /** * Returns the styles configuration for the project. */ get $styles(): LikeC4Styles; /** * Returns the Project ID associated with the model. * If the project ID is not defined in the model, it returns "default". */ get projectId(): ProjectId$1; /** * Returns the project associated with the model. * If the project is not defined in the model, it returns a default project with the ID "default". */ get project(): LikeC4Project; get specification(): Specification; element(el: DeploymentOrFqn): DeploymentElementModel; findElement(el: LooseDeploymentId): DeploymentElementModel | null; node(el: DeploymentOrFqn): DeploymentNodeModel; findNode(el: LooseDeploymentId): DeploymentNodeModel | null; instance(el: DeploymentOrFqn): DeployedInstanceModel; findInstance(el: LooseDeploymentId): DeployedInstanceModel | null; /** * Returns the root elements of the model. */ roots(): DeploymentNodesIterator; /** * Returns all elements in the model. */ elements(): DeploymentElementsIterator; /** * Returns all elements in the model. */ nodes(): DeploymentNodesIterator; nodesOfKind(kind: DeploymentKind): DeploymentNodesIterator; instances(): DeployedInstancesIterator; /** * Iterate over all instances of the given logical element. */ instancesOf(element: ElementOrFqn): DeployedInstancesIterator; deploymentRef(ref: FqnRef.DeploymentRef): DeploymentElementModel | NestedElementOfDeployedInstanceModel; /** * Returns all relationships in the model. */ relationships(): IteratorLike>; /** * Returns a specific relationship by its ID. */ relationship(id: RelationOrId): DeploymentRelationModel; findRelationship(id: string): DeploymentRelationModel | null; /** * Returns all deployment views in the model. */ views(): IteratorLike>; /** * Returns the parent element of given element. * @see ancestors */ parent(element: DeploymentOrFqn): DeploymentNodeModel | null; /** * Get all children of the element (only direct children), * @see descendants */ children(element: DeploymentOrFqn): ReadonlySet>; /** * Get all sibling (i.e. same parent) */ siblings(element: DeploymentOrFqn): DeploymentElementsIterator; /** * Get all ancestor elements (i.e. parent, parent’s parent, etc.) * (from closest to root) */ ancestors(element: DeploymentOrFqn): DeploymentNodesIterator; /** * Get all descendant elements (i.e. children, children’s children, etc.) */ descendants(element: DeploymentOrFqn, sort?: 'asc' | 'desc'): DeploymentElementsIterator; /** * Incoming relationships to the element and its descendants * @see incomers */ incoming(element: DeploymentOrFqn, filter?: IncomingFilter): IteratorLike>; /** * Outgoing relationships from the element and its descendants * @see outgoers */ outgoing(element: DeploymentOrFqn, filter?: OutgoingFilter): IteratorLike>; private addElement; private addRelation; } //#endregion //#region src/model/DeploymentElementModel.d.ts type DeploymentElementsIterator = IteratorLike>; type DeployedInstancesIterator = IteratorLike>; type DeploymentNodesIterator = IteratorLike>; type DeploymentElementModel = DeploymentNodeModel | DeployedInstanceModel; declare abstract class AbstractDeploymentElementModel implements WithTags, WithMetadata { /** * Don't use in runtime, only for type inference */ readonly Aux: A; abstract readonly id: DeploymentFqn; abstract readonly _literalId: DeploymentId; abstract readonly parent: DeploymentNodeModel | null; abstract readonly title: string; abstract readonly hierarchyLevel: number; abstract readonly $model: LikeC4DeploymentModel; abstract readonly $node: DeploymentElement; abstract readonly tags: Tags; get style(): SetRequired; get name(): string; get shape(): ElementShape; get color(): Color; get icon(): IconUrl | null; /** * Short description of the element. * Falls back to description if summary is not provided. */ get summary(): RichTextOrEmpty; /** * Long description of the element. * Falls back to summary if description is not provided. */ get description(): RichTextOrEmpty; get technology(): string | null; get links(): ReadonlyArray; /** * Get all ancestor elements (i.e. parent, parent’s parent, etc.) * (from closest to root) */ ancestors(): DeploymentNodesIterator; /** * Returns the common ancestor of this element and another element. */ commonAncestor(another: DeploymentElementModel): DeploymentNodeModel | null; /** * Get all sibling (i.e. same parent) */ siblings(): DeploymentElementsIterator; /** * Check if the element is a sibling of another element */ isSibling(other: DeploymentElementModel): boolean; /** * Resolve siblings of the element and its ancestors * (from closest to root) */ ascendingSiblings(): DeploymentElementsIterator; /** * Resolve siblings of the element and its ancestors * (from root to closest) */ descendingSiblings(): DeploymentElementsIterator; incoming(filter?: IncomingFilter): IteratorLike>; outgoing(filter?: OutgoingFilter): IteratorLike>; incomers(filter?: IncomingFilter): IteratorLike>; outgoers(filter?: OutgoingFilter): IteratorLike>; /** * Iterate over all views that include this deployment element. */ views(): IteratorLike>; isDeploymentNode(): this is DeploymentNodeModel; isInstance(): this is DeployedInstanceModel; abstract outgoingModelRelationships(): RelationshipsIterator; abstract incomingModelRelationships(): RelationshipsIterator; get allOutgoing(): RelationshipsAccum; get allIncoming(): RelationshipsAccum; hasMetadata(): boolean; getMetadata(): Metadata; getMetadata(field: MetadataKey): string | string[] | undefined; /** * Checks if the deployment element has the given tag. */ isTagged(tag: LooseTag): boolean; } declare class DeploymentNodeModel extends AbstractDeploymentElementModel { readonly $model: LikeC4DeploymentModel; readonly $node: DeploymentNode; id: DeploymentFqn; _literalId: DeploymentId; title: string; hierarchyLevel: number; constructor($model: LikeC4DeploymentModel, $node: DeploymentNode); get parent(): DeploymentNodeModel | null; get kind(): DeploymentKind; get metadata(): Metadata; get tags(): Tags; children(): ReadonlySet>; descendants(sort?: 'asc' | 'desc'): DeploymentElementsIterator; isDeploymentNode(): this is DeploymentNodeModel; /** * Iterate over all instances nested in this deployment node. */ instances(): DeployedInstancesIterator; /** * Returns deployed instance inside this deployment node * if only there are no more instances */ onlyOneInstance(): DeployedInstanceModel | null; /** * Cached result of relationships from instances */ private _relationshipsFromInstances; private relationshipsFromInstances; /** * We return only relationships that are not already present in nested instances */ outgoingModelRelationships(): RelationshipsIterator; /** * We return only relationships that are not already present in nested instances */ incomingModelRelationships(): RelationshipsIterator; /** * Returns an iterator of relationships between nested instances */ internalModelRelationships(): ReadonlySet>; } declare class DeployedInstanceModel extends AbstractDeploymentElementModel { readonly $model: LikeC4DeploymentModel; readonly $instance: DeployedInstance; readonly element: ElementModel; readonly id: DeploymentFqn; readonly _literalId: DeploymentId; readonly title: string; readonly hierarchyLevel: number; constructor($model: LikeC4DeploymentModel, $instance: DeployedInstance, element: ElementModel); get $node(): DeployedInstance; get parent(): DeploymentNodeModel; get style(): SetRequired; get tags(): Tags; get kind(): ElementKind; /** * Instance metadata overrides element metadata entirely (replacement, not merge). * This differs from tags which are merged from instance + element. */ get metadata(): Metadata; get summary(): RichTextOrEmpty; get description(): RichTextOrEmpty; get technology(): string | null; get links(): ReadonlyArray; isInstance(): this is DeployedInstanceModel; outgoingModelRelationships(): RelationshipsIterator; incomingModelRelationships(): RelationshipsIterator; /** * Iterate over all views that include this instance. * (Some views may include the parent deployment node instead of the instance.) */ views(): IteratorLike>; } declare class NestedElementOfDeployedInstanceModel { readonly instance: DeployedInstanceModel; readonly element: ElementModel; constructor(instance: DeployedInstanceModel, element: ElementModel); get id(): DeploymentFqn; get _literalId(): DeploymentId; get style(): SetRequired; get shape(): ElementShape; get color(): Color; get title(): string; get summary(): RichTextOrEmpty; get description(): RichTextOrEmpty; get technology(): string | null; isDeploymentNode(): this is DeploymentNodeModel; isInstance(): this is DeployedInstanceModel; } type DeploymentRelationEndpoint = DeploymentElementModel | NestedElementOfDeployedInstanceModel; declare class DeploymentRelationModel implements AnyRelationshipModel { readonly $model: LikeC4DeploymentModel; readonly $relationship: DeploymentRelationship; boundary: DeploymentNodeModel | null; source: DeploymentRelationEndpoint; target: DeploymentRelationEndpoint; constructor($model: LikeC4DeploymentModel, $relationship: DeploymentRelationship); get id(): RelationId; get expression(): string; get title(): string | null; get technology(): string | null; /** * Returns true if the relationship has a summary and a description * (if one is missing - it falls back to another) */ get hasSummary(): boolean; /** * Short description of the relationship. * Falls back to description if summary is not provided. */ get summary(): RichTextOrEmpty; /** * Long description of the relationship. * Falls back to summary if description is not provided. */ get description(): RichTextOrEmpty; get tags(): Tags; get kind(): RelationKind | null; get metadata(): Metadata; get navigateTo(): LikeC4ViewModel | null; get links(): ReadonlyArray; get color(): Color; get line(): RelationshipLineType; get head(): RelationshipArrowType; get tail(): RelationshipArrowType | undefined; views(): IteratorLike>; isDeploymentRelation(): this is DeploymentRelationModel; isModelRelation(): this is RelationshipModel; hasMetadata(): boolean; getMetadata(): Metadata; getMetadata(field: MetadataKey): string | string[] | undefined; /** * Checks if the relationship has the given tag. */ isTagged(tag: LooseTag): boolean; } declare class RelationshipsAccum { readonly model: ReadonlySet>; readonly deployment: ReadonlySet>; static empty(): RelationshipsAccum; static from(model: Iterable> | undefined, deployment?: Iterable>): RelationshipsAccum; /** * @param model relationships from logical model * @param deployment relationships from deployment model */ constructor(model?: ReadonlySet>, deployment?: ReadonlySet>); get isEmpty(): boolean; get nonEmpty(): boolean; get size(): number; /** * Returns new Accum containing all the elements which are both in this and otherAccum */ intersect(otherAccum: RelationshipsAccum): RelationshipsAccum; /** * Returns new Accum containing all the elements which are both in this and otherAccum */ difference(otherAccum: RelationshipsAccum): RelationshipsAccum; /** * Returns new Accum containing all the elements from both */ union(otherAccum: RelationshipsAccum): RelationshipsAccum; } //#endregion //#region src/model/LikeC4Model.d.ts declare class LikeC4Model { /** * Don't use in runtime, only for type inference */ readonly Aux: A; protected readonly _elements: Map, ElementModel>; protected readonly _parents: Map, ElementModel>; protected readonly _children: DefaultMap, Set>>; protected readonly _rootElements: Set>; protected readonly _relations: Map, RelationshipModel>; protected readonly _incoming: DefaultMap, Set>>; protected readonly _outgoing: DefaultMap, Set>>; protected readonly _internal: DefaultMap, Set>>; protected readonly _views: Map, LikeC4ViewModel>>; protected readonly _rootViewFolder: LikeC4ViewsFolder; protected readonly _viewFolders: Map>; protected readonly _viewFolderItems: DefaultMap> | LikeC4ViewsFolder>>; protected readonly _allTags: DefaultMap, Set | RelationshipModel | LikeC4ViewModel>>>; static fromParsed(model: ParsedLikeC4ModelData): LikeC4Model; /** * Creates a new LikeC4Model instance from the provided model data. * Model with parsed data will not have views, as they must be computed * (this model is used for computing views) * * @typeParam M - Type parameter constrained to AnyLikeC4Model * @param model - The model data to create a LikeC4Model from * @returns A new LikeC4Model instance with the type derived from the input model */ static create(model: ParsedLikeC4ModelData): LikeC4Model; static create(model: ComputedLikeC4ModelData): LikeC4Model; static create(model: LayoutedLikeC4ModelData): LikeC4Model; static create(model: ParsedLikeC4ModelData): LikeC4Model.Parsed; static create(model: ComputedLikeC4ModelData): LikeC4Model.Computed; static create(model: LayoutedLikeC4ModelData): LikeC4Model.Layouted; static create>(model: M): LikeC4Model>; static create(model: $ModelData): LikeC4Model; /** * Creates a new LikeC4Model instance and infers types from a model dump.\ * Model dump expected to be computed or layouted. * * @typeParam D - A constant type parameter extending LikeC4ModelDump * @param dump - The model dump to create the instance from * @returns A new LikeC4Model instance with types inferred from the dump */ static fromDump(dump: D): LikeC4Model>; readonly deployment: LikeC4DeploymentModel; readonly $data: $ModelData; constructor($data: $ModelData); /** * Type narrows the model to the parsed stage. * This is useful for tests */ get asParsed(): LikeC4Model.Parsed; /** * Type narrows the model to the layouted stage. * This is useful for tests */ get asComputed(): LikeC4Model.Computed; /** * Type narrows the model to the layouted stage. * This is useful for tests */ get asLayouted(): LikeC4Model.Layouted; /** * Returns the styles configuration for the project. */ get $styles(): LikeC4Styles; /** * Type guard the model to the parsed stage. */ isParsed(this: LikeC4Model): this is LikeC4Model.Parsed; /** * Type guard the model to the layouted stage. */ isLayouted(this: LikeC4Model): this is LikeC4Model.Layouted; /** * Type guard the model to the computed stage. */ isComputed(this: LikeC4Model): this is LikeC4Model.Computed; /** * Keeping here for backward compatibility * @deprecated use {@link $data} */ get $model(): $ModelData; get stage(): Stage; /** * Returns the Project ID associated with the model. * If the project ID is not defined in the model, it returns "default". */ get projectId(): ProjectId$1; /** * Returns the project associated with the model. * If the project is not defined in the model, it returns a default project with the ID "default". */ get project(): LikeC4Project; get specification(): Specification; get globals(): ModelGlobals; /** * Returns the element with the given FQN. * * @throws Error if element is not found\ * Use {@link findElement} if you don't want to throw an error * * @note Method is type-safe for typed model * @example * model.element('cloud.frontend') * // or object with id property of scalar.Fqn * model.element({ * id: 'dashboard', * }) */ element(el: ElementId | { id: Fqn; }): ElementModel; /** * Returns the element with the given FQN. * * @returns Element if found, null otherwise * @note Method is not type-safe as {@link element} * * @example * model.findElement('cloud.frontend') */ findElement(el: LooseElementId): ElementModel | null; /** * Returns the root elements of the model. */ roots(): ElementsIterator; /** * Returns all elements in the model. */ elements(): ElementsIterator; /** * Returns all relationships in the model. */ relationships(): RelationshipsIterator; /** * Returns a specific relationship by its ID. * If the relationship is not found in the model, it will be searched in the deployment model. * Search can be limited to the model or deployment model only. */ relationship(rel: RelationOrId, type: 'model'): RelationshipModel; relationship(rel: RelationOrId, type: 'deployment'): DeploymentRelationModel; relationship(rel: RelationId, type?: 'model' | 'deployment'): RelationshipModel | DeploymentRelationModel; findRelationship(id: string, type: 'model'): RelationshipModel | null; findRelationship(id: string, type: 'deployment'): DeploymentRelationModel | null; findRelationship(id: string, type?: 'model' | 'deployment'): RelationshipModel | DeploymentRelationModel | null; /** * Returns all views in the model. */ views(): IteratorLike>>; /** * Returns a specific view by its ID. * @note Method is type-safe for typed model * @throws Error if view is not found\ * Use {@link findView} if you don't want to throw an error * * @example * model.view('index') * // or object with id property of scalar.ViewId * model.view({ * id: 'index', * }) */ view(viewId: ViewId | { id: ViewId$1>; }): $ViewModel; /** * Returns a specific view by its ID. * @note Method is not type-safe as {@link view} * * @example * model.findView('index') */ findView(viewId: LooseViewId): $ViewModel | null; /** * Returns manual layout snapshot for given view ID, if any. */ findManualLayout(viewId: LooseViewId): ViewManualLayoutSnapshot | null; /** * Returns a view folder by its path. * Path is extracted from the view title, e.g. "Group 1/Group 2/View" -> "Group 1/Group 2" * @throws Error if view folder is not found. */ viewFolder(path: string): LikeC4ViewsFolder; /** * Root folder is a special one with an empty path and used only for internal purposes. * It is not visible to the user and should be used only to get top-level folders and views. */ get rootViewFolder(): LikeC4ViewsFolder; /** * Whether the model has any view folders. */ get hasViewFolders(): boolean; /** * Returns all children of a view folder. * Path is extracted from the view title, e.g. "Group 1/Group 2/View" -> "Group 1/Group 2" * * @throws Error if view folder is not found. */ viewFolderItems(path: string): ReadonlySet | LikeC4ViewModel>; /** * Returns the parent element of given element. * @see ancestors */ parent(element: ElementOrFqn): ElementModel | null; /** * Get all children of the element (only direct children), * @see descendants */ children(element: ElementOrFqn): ReadonlySet>; /** * Get all sibling (i.e. same parent) */ siblings(element: ElementOrFqn): ElementsIterator; /** * Get all ancestor elements (i.e. parent, parent’s parent, etc.) * (from closest to root) */ ancestors(element: ElementOrFqn): ElementsIterator; /** * Get all descendant elements (i.e. children, children’s children, etc.) */ descendants(element: ElementOrFqn): ElementsIterator; /** * Incoming relationships to the element and its descendants * @see incomers */ incoming(element: ElementOrFqn, filter?: IncomingFilter): RelationshipsIterator; /** * Outgoing relationships from the element and its descendants * @see outgoers */ outgoing(element: ElementOrFqn, filter?: OutgoingFilter): RelationshipsIterator; /** * Returns array of all tags used in the model, sorted naturally.\ * Use {@link specification.tags} to get all defined tags */ get tags(): Tags; /** * Returns all tags used in the model, sorted by usage count (descending). */ get tagsSortedByUsage(): ReadonlyArray<{ tag: Tag; count: number; tagged: ReadonlySet | RelationshipModel | LikeC4ViewModel>; }>; /** * Returns all elements, relationships and views marked with the given tag. */ findByTag(tag: Tag): IteratorLike | RelationshipModel | LikeC4ViewModel>; findByTag(tag: Tag, type: 'elements'): IteratorLike>; findByTag(tag: Tag, type: 'views'): IteratorLike>; findByTag(tag: Tag, type: 'relationships'): IteratorLike>; /** * Returns all elements of the given kind. */ elementsOfKind(kind: ElementKind): IteratorLike>; /** * Returns all elements that match the given where operator. * * @example * ```ts * model.where({ * and: [ * { kind: 'component' }, * { * or: [ * { tag: 'old' }, * { tag: { neq: 'new' } }, * ], * }, * ], * }) * ``` */ elementsWhere(where: WhereOperator): IteratorLike>; /** * Returns all **model** relationships that match the given where operator. * * @example * ```ts * model.relationshipsWhere({ * and: [ * { kind: 'uses' }, * { * or: [ * { tag: 'old' }, * { tag: { neq: 'new' } }, * ], * }, * ], * }) * ``` */ relationshipsWhere(where: WhereOperator): IteratorLike>; private addElement; private addImportedElement; private addRelation; } /** * When you do not need types in the model */ type AnyLikeC4Model = LikeC4Model; declare namespace LikeC4Model { const EMPTY: LikeC4Model; type Parsed = IsAny extends true ? LikeC4Model : A extends Aux ? LikeC4Model> : LikeC4Model; type Computed = IsAny extends true ? LikeC4Model : A extends Aux ? LikeC4Model> : LikeC4Model; type Layouted = IsAny extends true ? LikeC4Model : A extends Aux ? LikeC4Model> : LikeC4Model; type Node = A extends Any ? NodeModel : never; type Element = A extends Any ? ElementModel : never; type Relationship = A extends Any ? RelationshipModel : never; type View = A extends Any ? $ViewModel : never; type DeploymentNode = A extends Any ? DeploymentNodeModel : never; type DeploymentRelation = A extends Any ? DeploymentRelationModel : never; type DeployedInstance = A extends Any ? DeployedInstanceModel : never; type AnyRelation = M extends Any ? RelationshipModel | DeploymentRelationModel : never; } //#endregion export { ElementModel as C, NodeModel as S, RelationshipModel as T, WithMetadata as _, DeploymentNodeModel as a, LikeC4ViewsFolder as b, NestedElementOfDeployedInstanceModel as c, DeploymentOrFqn as d, EdgeOrId as f, OutgoingFilter as g, NodeOrId as h, DeploymentElementModel as i, RelationshipsAccum as l, IncomingFilter as m, LikeC4Model as n, DeploymentRelationEndpoint as o, ElementOrFqn as p, DeployedInstanceModel as r, DeploymentRelationModel as s, AnyLikeC4Model as t, LikeC4DeploymentModel as u, WithTags as v, AnyRelationshipModel as w, EdgeModel as x, LikeC4ViewModel as y };