import { n as __exportAll, r as __name } from "./rolldown-runtime.mjs"; import { c as XYPoint, i as BBox, s as Point } from "./index2.mjs"; import { IfNever, IsAny, IsEqual, IsLiteral, IsNever, IsUnknown, KeysOfUnion, Or, PartialDeep, SetNonNullable, SetRequired, Simplify, Tagged, TupleToUnion, UnionToIntersection, WritableDeep } from "type-fest"; //#region src/types/_common.d.ts type NonEmptyArray = [T, ...T[]]; type NonEmptyReadonlyArray = readonly [T, ...T[]]; type IterableContainer = ReadonlyArray | readonly []; type ReorderedArray = { -readonly [P in keyof T]: T[number]; }; type KeysOf = keyof T extends (infer K extends string) ? K : never; type AllNever$1 = UnionToIntersection<{ [Name in keyof Expressions]: { -readonly [Key in keyof Expressions[Name]]?: never; }; }[keyof Expressions]>; /** * @example * ```ts * type Variant1 = { * a: string * } * type Variant2 = { * b: number * } * * type Variants = ExclusiveUnion<{ * Variant1: Variant1, * Variant2: Variant2 * }> * * // Fail here * const variant1: Variants = { * a: 'one', * b: 1 * } * ``` */ type ExclusiveUnion> = Expressions extends object ? { [Name in keyof Expressions]: Simplify & Expressions[Name]>; }[keyof Expressions] : never; /** * Copy from https://github.com/remeda/remeda/blob/main/packages/remeda/src/internal/types/NTuple.ts * An array with *exactly* N elements in it. * * Only literal N values are supported. For very large N the type might result * in a recurse depth error. For negative N the type would result in an infinite * recursion. None of these have protections because this is an internal type! */ type NTuple = []> = Result['length'] extends N ? Result : NTuple; type IteratorLike = IteratorObject; type Predicate = (x: T) => boolean; interface Link { title?: string; url: string; relative?: string; } /** * @see {@link LiteralUnion} from type-fest (https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts) */ type OrString = string & Record; /** * Coalesce `V` to a string if it is `any` */ type Coalesce = IsAny extends true ? OrIfAny : V; type ExactObject = { [KeyType in keyof T]: undefined extends T[KeyType] ? T[KeyType] | undefined : T[KeyType]; } & Record>, never>; /** * Allows only exact properties of `U` to be present in `T` and omits undefined values * * See {@link Exact} for more details (this version is non-deep) */ declare function exact>(a: T): Expected; type IsAnyOrNever = Or, IsNever>; //#endregion //#region src/types/const.d.ts /** * Determines the stage of the model: * 1. `parsed` - parsed from DSL or returned from Builder * 2. `computed` - views are computed * 3. `layouted` - views are layouted * * @internal */ type ModelStage = 'parsed' | 'computed' | 'layouted'; type ExtractOnStage = Extract; declare function isOnStage(value: T, stage: S): value is ExtractOnStage; /** * Property name to store the stage of the model * * @internal */ declare const _stage = "_stage"; type _stage = typeof _stage; type inferStage = A extends { ['_stage']: infer S extends ModelStage; } ? IsAnyOrNever extends true ? never : S : never; /** * Property name to store type information, used to identify the type * (of the view or view element) * * @internal */ declare const _type = "_type"; type _type = typeof _type; type inferType = A extends { ['_type']: infer T; } ? IsAnyOrNever extends true ? never : T : never; /** * Property name to store layout type information, used to identify the type of the layout* * @internal */ declare const _layout = "_layout"; type _layout = typeof _layout; /** * Property name to store version information (for migration purposes) * @internal */ declare const _v = "_v"; type _v = typeof _v; declare namespace scalar_d_exports { export { AnyFqn, BuiltInIcon, DeploymentFqn$1 as DeploymentFqn, DeploymentKind$1 as DeploymentKind, EdgeId$1 as EdgeId, ElementKind$1 as ElementKind, Fqn$1 as Fqn, GlobalFqn, GroupElementKind, Icon, IconUrl, MarkdownOrString, NodeId$1 as NodeId, NoneIcon, ProjectId$1 as ProjectId, RelationId$1 as RelationId, RelationKind$1 as RelationKind, RelationshipKind, StepEdgeKind, StepPath, Tag$1 as Tag, ViewId$1 as ViewId, flattenMarkdownOrString, isGlobalFqn, isGroupElementKind, isStepPath, splitGlobalFqn }; } type ProjectId$1 = Tagged; declare function ProjectId$1(name: string): ProjectId$1; type MarkdownOrString = { txt: string; md?: never; } | { md: string; txt?: never; }; declare function MarkdownOrString(value: { txt: string; md?: never; } | { md: string; txt?: never; } | string): MarkdownOrString; /** * Converts a MarkdownOrString object or a plain string into a simple string representation. * This utility function handles different types of text content and normalizes them to a string format. * * @param value - The content to be flattened. * Can be one of: * - A plain string * - A MarkdownOrString object with either txt or md property * - undefined or null * * @returns The string content contained within the input value. * - Returns the input directly if it's already a string * - Returns the txt property if available in a MarkdownOrString object * - Falls back to the md property if txt is not available * - Returns null if: * - The input is null or undefined * - The resulting string value is empty, whitespace, or null * * @example * // String input * flattenMarkdownOrString("Hello world") // Returns: "Hello world" * flattenMarkdownOrString(" ") // Returns: null * * // MarkdownOrString with txt property * flattenMarkdownOrString({ txt: "Plain text" }) // Returns: "Plain text" * flattenMarkdownOrString({ txt: " " }) // Returns: null * * // MarkdownOrString with md property * flattenMarkdownOrString({ md: "**Bold markdown**" }) // Returns: "**Bold markdown**" * * // Null input * flattenMarkdownOrString(null) // Returns: null */ declare function flattenMarkdownOrString(value: MarkdownOrString | string): string; declare function flattenMarkdownOrString(value: MarkdownOrString | string | undefined | null): string | null; type BuiltInIcon = 'none' | `${'aws' | 'azure' | 'gcp' | 'tech' | 'bootstrap'}:${string}`; type Icon = Tagged | BuiltInIcon; declare const NoneIcon: Icon; type IconUrl = Icon; /** * Full-qualified-name for model elements */ type Fqn$1 = Tagged; declare function Fqn$1(name: string, parent?: Fqn$1 | null): Fqn$1; type ElementKind$1 = Tagged; declare const GroupElementKind: ElementKind$1<"@group">; type GroupElementKind = typeof GroupElementKind; declare function isGroupElementKind(v: V): v is V & { kind: GroupElementKind; }; /** * Full-qualified-name for deployment elements */ type DeploymentFqn$1 = Tagged; declare function DeploymentFqn$1(name: string, parent?: DeploymentFqn$1 | null): DeploymentFqn$1; type DeploymentKind$1 = Tagged; type ViewId$1 = Tagged; declare function ViewId$1(id: string): ViewId$1; type AnyFqn = DeploymentFqn$1 | Fqn$1; /** * @deprecated Use {@link RelationshipKind} instead */ type RelationKind$1 = RelationshipKind; type RelationshipKind = Tagged; type RelationId$1 = Tagged; declare function RelationId$1(id: string): RelationId$1; type Tag$1 = Tagged; type GlobalFqn = Tagged, 'GlobalFqn'>; declare function GlobalFqn(projectId: A | ProjectId$1, name: string): GlobalFqn; declare function isGlobalFqn(fqn: A): fqn is GlobalFqn; declare function splitGlobalFqn(fqn: Fqn$1 | GlobalFqn): [ProjectId$1 | null, Fqn$1]; type NodeId$1 = Tagged; declare function NodeId$1(id: string): NodeId$1; type EdgeId$1 = Tagged; declare function EdgeId$1(id: string): EdgeId$1; declare const StepEdgeKind = "@step"; type StepPath = Tagged, 'StepPath'>; declare function isStepPath(id: unknown): id is StepPath; /** * Path to a step, also acting as EdgeId * * Format: step-{segment1}.{segment2}...{segmentN} * Where segment can be: * - {index} (index in array, 1-based, represents A -> B) * - {index}:{kind} (subflow of a kind, 1-based, i.e. "03:loop" - 3rd step starts a loop) * * @example * ``` * dynamic view { * A -> B // step-01 * alt { // step-02:alt - step 2 is alt subflow * when { // step-02:alt.01:when - step 1 in alt is when subflow * try { // step-02:alt.01:when.01:try - step 1 in when is try subflow * B -> C // step-02:alt.01:when.01:try.01:block.01 - step 1 in try block * } catch { * B -> D // step-02:alt.01:when.01:try.02:catch.01 * } * } * } * } * ``` * * @param segments - Array of segments, where each segment can be: * - string: literal segment * - number: index segment (will be padded to 2 digits) * - [number, string]: index:kind segment (will be padded to 2 digits) * - undefined: will be filtered out */ declare function StepPath(...segments: Array): StepPath; declare namespace _aux_d_exports { export { AllKinds, Any, Any as AnyAux, AnyComputed, AnyLayouted, AnyOnStage, AnyParsed, AnySpec, Aux, DeploymentFqn, DeploymentId, DeploymentKind, EdgeId, ElementId, ElementKind, Fqn, LooseDeploymentId, LooseDeploymentKind, LooseElementId, LooseElementKind, LooseLiteral, LooseRelationKind, LooseTag, LooseTags, LooseViewId, Metadata, MetadataKey, Never, NodeId, PickByStage, ProjectId, RelationId, RelationKind, Spec, SpecAux, Stage, DeploymentFqn as StrictDeploymentFqn, StrictDeploymentKind, StrictElementKind, Fqn as StrictFqn, StrictProjectId, StrictRelationKind, StrictTag, StrictViewId, Tag, Tags, Unknown, UnknownComputed, UnknownLayouted, UnknownParsed, ViewId, WithDescriptionAndTech, WithLinks, WithMetadata, WithNotation, WithOptionalLinks, WithOptionalTags, WithTags, preferDescription, preferSummary, setProject, setStage, toComputed, toLayouted, toParsed }; } /** * Specification types (kinds, tags, metadata keys) * * @param ElementKind - Literal union of element kinds * @param DeploymentKind - Literal union of deployment kinds * @param RelationKind - Literal union of relationship kinds * @param Tag - Literal union of tags * @param MetadataKey - Literal union of metadata keys */ interface SpecAux { ElementKind: ElementKind; DeploymentKind: DeploymentKind; RelationKind: RelationKind; Tag: Tag; MetadataKey: MetadataKey; } type AnySpec = SpecAux; /** * Auxilary interface to keep inferred types * * @typeParam Stage - View stage * @typeParam Element - Literal union of FQNs of model elements * @typeParam Deployment - Literal union of FQNs of deployment elements * @typeParam View - Literal union of view identifiers * @typeParam Project - Project identifier type * @typeParam Spec - Specification types (kinds, tags, metadata keys) */ interface Aux { Stage: Stage; ProjectId: Project; ElementId: Element; DeploymentId: Deployment; ViewId: View; ElementKind: Spec['ElementKind']; DeploymentKind: Spec['DeploymentKind']; RelationKind: Spec['RelationKind']; Tag: Spec['Tag']; MetadataKey: Spec['MetadataKey']; } type AnyOnStage = Aux; type AnyParsed = AnyOnStage<'parsed'>; type AnyComputed = AnyOnStage<'computed'>; type AnyLayouted = AnyOnStage<'layouted'>; type Any = Aux; type Never = Aux>; /** * Fallback when {@link Aux} can't be inferred. * By default assumes non parsed model */ type Unknown = UnknownComputed | UnknownLayouted; type UnknownParsed = Aux<'parsed', string, string, string, string, SpecAux>; type UnknownComputed = Aux<'computed', string, string, string, string, SpecAux>; type UnknownLayouted = Aux<'layouted', string, string, string, string, SpecAux>; /** * Reads stage from Aux */ type Stage = A extends Aux ? IfNever> : never; /** * Picks type based on stage from Aux */ type PickByStage = { parsed: OnParsed; computed: OnComputed; layouted: OnLayouted; }[A['Stage']]; type setStage = A extends Aux ? Aux : never; type toParsed = A extends Aux ? Aux<'parsed', E, D, V, P, Spec> : never; type toComputed = A extends Aux ? Aux<'computed', E, D, V, P, Spec> : never; type toLayouted = A extends Aux ? Aux<'layouted', E, D, V, P, Spec> : never; /** * Project identifier from Aux */ type ProjectId = A extends Aux ? Coalesce

: never; type setProject = A extends Aux ? Aux : never; /** * Element FQN from Aux as branded type */ type Fqn = A extends Any ? Fqn$1> : never; /** * Element FQN from Aux as a literal union */ type ElementId = A extends Any ? Coalesce : never; /** * Deployment FQN from Aux as branded type */ type DeploymentFqn = A extends Any ? DeploymentFqn$1> : never; /** * Deployment FQN from Aux as a literal union * @alias {@link DeploymentFqn} */ type DeploymentId = A extends Any ? Coalesce : never; /** * View identifier from Aux as a literal union */ type ViewId = A extends Any ? Coalesce : never; type RelationId = RelationId$1; type NodeId = NodeId$1; type EdgeId = EdgeId$1; /** * ElementKind from Aux as a literal union */ type ElementKind = A extends Any ? Coalesce : never; /** * DeploymentKind from Aux as a literal union */ type DeploymentKind = A extends Any ? Coalesce : never; /** * RelationKind from Aux as a literal union */ type RelationKind = A extends Any ? Coalesce : never; /** * Tags from Aux as a literal union */ type Tag = A extends Any ? Coalesce : never; /** * Array of tags from Aux */ type Tags = readonly Tag[]; /** * Metadata key from Aux */ type MetadataKey = A extends Any ? Coalesce : never; /** * Metadata object from Aux */ type Metadata = IsNever extends true ? never : IsLiteral extends true ? { [key in A['MetadataKey']]?: string | string[]; } : Record; /** * All known kinds from Aux as a literal union. */ type AllKinds = ElementKind | DeploymentKind | RelationKind; /** * Specification from Aux */ type Spec = A extends Aux> ? SpecAux : never; type StrictProjectId = A extends (infer T extends Any) ? ProjectId$1> : never; type StrictViewId = A extends (infer T extends Any) ? ViewId$1> : never; type StrictTag = A extends (infer T extends Any) ? Tag$1> : never; type StrictElementKind = A extends (infer T extends Any) ? ElementKind$1> : never; type StrictDeploymentKind = A extends (infer T extends Any) ? DeploymentKind$1> : never; type StrictRelationKind = A extends (infer T extends Any) ? RelationshipKind> : never; type WithDescriptionAndTech = { readonly summary?: MarkdownOrString | null; readonly description?: MarkdownOrString | null; readonly technology?: string | null; }; /** * Returns summary if it is not null, otherwise returns description */ declare function preferSummary(a: WithDescriptionAndTech): MarkdownOrString | null | undefined; /** * Returns description if it is not null, otherwise returns summary */ declare function preferDescription(a: WithDescriptionAndTech): MarkdownOrString | null | undefined; type WithTags = { readonly tags: Tags; }; type WithOptionalTags = { readonly tags?: Tags | null; }; type WithLinks = { readonly links: readonly Link[]; }; type WithOptionalLinks = { readonly links?: readonly Link[] | null; }; type WithMetadata = { readonly metadata?: Metadata; }; type WithNotation = { readonly notation?: string | null; }; /** * Allows any string value, but still auto-completes to the possible values in IDE */ type LooseLiteral = Coalesce | OrString; type LooseElementId = A extends Any ? LooseLiteral : string; type LooseDeploymentId = A extends Any ? LooseLiteral : string; type LooseViewId = A extends Any ? LooseLiteral : string; type LooseTag = A extends Any ? LooseLiteral : string; type LooseTags = A extends Any ? readonly (LooseLiteral)[] : string[]; type LooseElementKind = A extends Any ? LooseLiteral : string; type LooseDeploymentKind = A extends Any ? LooseLiteral : string; type LooseRelationKind = A extends Any ? LooseLiteral : string; //#endregion //#region ../../styled-system/preset/dist/defaults/types.d.mts //#region src/defaults/types.d.ts declare const Sizes: readonly ["xs", "sm", "md", "lg", "xl"]; declare const IconPositions: readonly ["left", "right", "top", "bottom"]; declare const BorderStyles: readonly ["solid", "dashed", "dotted", "none"]; declare const ElementShapes: readonly ["rectangle", "person", "browser", "mobile", "cylinder", "storage", "queue", "bucket", "document", "component"]; declare const ThemeColors: readonly ["amber", "blue", "gray", "slate", "green", "indigo", "muted", "primary", "red", "secondary", "sky"]; declare const DefaultTagColors: readonly ["tomato", "grass", "blue", "ruby", "orange", "indigo", "pink", "teal", "purple", "amber", "crimson", "red", "lime", "yellow", "violet"]; type DefaultTagColors = typeof DefaultTagColors[number]; //#endregion //#region src/styles/types.d.ts /** * For padding, margin, etc. */ type Size = typeof Sizes[number]; type TextSize = Size; type ShapeSize = Size; type SpacingSize = Size; type IconSize = Size; type IconPosition = typeof IconPositions[number]; type BorderStyle = typeof BorderStyles[number]; type ElementShape = typeof ElementShapes[number]; type HexColor = `#${string}`; type ColorLiteral = HexColor | `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number})`; declare const RelationshipLineTypes: readonly ["dashed", "solid", "dotted"]; type RelationshipLineType = TupleToUnion; declare const RelationshipArrowTypes: readonly ["none", "normal", "onormal", "dot", "odot", "diamond", "odiamond", "crow", "open", "vee"]; type RelationshipArrowType = TupleToUnion; type ThemeColor = typeof ThemeColors[number]; declare function isThemeColor(color: string): color is ThemeColor; type CustomColorDefinitions = { [key: string]: ThemeColorValues; }; type CustomColor = Tagged; declare function isCustomColor(color: string): color is CustomColor; type Color = ThemeColor | CustomColor; interface ElementColorValues { readonly fill: ColorLiteral; readonly stroke: ColorLiteral; readonly hiContrast: ColorLiteral; readonly loContrast: ColorLiteral; } interface RelationshipColorValues { readonly line: ColorLiteral; readonly labelBg: ColorLiteral; readonly label: ColorLiteral; } interface ThemeColorValues { readonly elements: ElementColorValues; readonly relationships: RelationshipColorValues; } /** * Default style values for elements, groups and relationships */ interface LikeC4StyleDefaults { readonly color: ThemeColor; readonly size: ShapeSize; readonly shape: ElementShape; readonly opacity?: number; readonly border?: BorderStyle; readonly padding?: SpacingSize; readonly text?: TextSize; readonly iconPosition?: IconPosition; /** * Default style values for groups * If not specified, the default values for elements are used */ readonly group: { readonly color?: ThemeColor; readonly opacity: number; readonly border: BorderStyle; }; readonly relationship: { readonly color: ThemeColor; readonly line: RelationshipLineType; readonly arrow: RelationshipArrowType; }; } interface LikeC4Theme { readonly colors: Readonly>; readonly sizes: Readonly>; readonly spacing: Readonly>; readonly textSizes: Readonly>; readonly iconSizes: Readonly>; } interface LikeC4StylesConfig { readonly theme: LikeC4Theme; readonly defaults: LikeC4StyleDefaults; } //#endregion //#region src/types/fqnRef.d.ts type AnyAux$2 = Any; declare namespace FqnRef { /** * Reference to logical model element */ interface ElementRef { project?: never; model: ElementId; } function isElementRef(ref: FqnRef): ref is ElementRef; /** * Reference to imported logical model element */ interface ImportRef { project: ProjectId; model: ElementId; } function isImportRef(ref: FqnRef): ref is ImportRef; function flatten(ref: FqnRef): Fqn; type ModelRef = ImportRef | ElementRef; function isModelRef(ref: FqnRef): ref is ModelRef; /** * Represents a reference to an instance within a deployment. * * @template D - The type representing the deployment fqn. Defaults to `Fqn`. * @template M - The type representing the model fqn. Defaults to `Fqn`. * * @property {D} deployment - TThe fully qualified name (FQN) of the deployed instance. * @property {M} element - The element reference within the deployment. */ interface InsideInstanceRef { deployment: DeploymentId; element: ElementId; } function isInsideInstanceRef(ref: FqnRef): ref is InsideInstanceRef; /** * Represents a reference to a deployment element. * * @template F - The type of the fully qualified name (FQN) of the deployment element. Defaults to `Fqn`. * @property {F} deployment - The fully qualified name (FQN) of the deployment element. */ interface DeploymentElementRef { deployment: DeploymentId; element?: never; } function isDeploymentElementRef(ref: FqnRef): ref is DeploymentElementRef; type DeploymentRef = DeploymentElementRef | InsideInstanceRef; function isDeploymentRef(ref: FqnRef): ref is DeploymentRef; } type FqnRef = ExclusiveUnion<{ DeploymentRef: FqnRef.DeploymentRef; ModelRef: FqnRef.ModelRef; }>; //#endregion //#region src/types/operators.d.ts type EqualOperator = { eq: V; neq?: never; } | { eq?: never; neq: V; }; type AllNever = { not?: never; and?: never; or?: never; tag?: never; kind?: never; metadata?: never; participant?: never; operator?: never; }; type TagEqual = Omit & { tag: EqualOperator> | Tag; }; declare function isTagEqual(operator: WhereOperator): operator is TagEqual; type KindEqual = Omit & { kind: EqualOperator> | AllKinds; }; declare function isKindEqual(operator: WhereOperator): operator is KindEqual; type MetadataEqual = Omit & { metadata: { key: MetadataKey; value?: EqualOperator | string; }; }; declare function isMetadataEqual(operator: WhereOperator): operator is MetadataEqual; type Participant = 'source' | 'target'; type ParticipantOperator = Omit & { participant: Participant; operator: KindEqual | TagEqual | MetadataEqual; }; declare function isParticipantOperator(operator: WhereOperator): operator is ParticipantOperator; type NotOperator = Omit & { not: WhereOperator; }; declare function isNotOperator(operator: WhereOperator): operator is NotOperator; type AndOperator = Omit & { and: NonEmptyArray>; }; declare function isAndOperator(operator: WhereOperator): operator is AndOperator; type OrOperator = Omit & { or: NonEmptyArray>; }; declare function isOrOperator(operator: WhereOperator): operator is OrOperator; type WhereOperator = TagEqual | KindEqual | MetadataEqual | ParticipantOperator | NotOperator | AndOperator | OrOperator; type Filterable = { tags?: Tags | null | undefined; kind?: AllKinds | null | undefined; metadata?: Record | null | undefined; source?: Filterable; target?: Filterable; }; type OperatorPredicate = (value: Filterable) => boolean; declare function whereOperatorAsPredicate(operator: WhereOperator): OperatorPredicate; //#endregion //#region src/types/expression.d.ts type AnyAux$1 = Any; type PredicateSelector = 'children' | 'expanded' | 'descendants'; declare namespace FqnExpr { type Wildcard = { wildcard: true; }; function isWildcard(expr: Expression): expr is FqnExpr.Wildcard; interface ModelRef { ref: FqnRef.ModelRef; selector?: PredicateSelector; } function isModelRef(ref: Expression): ref is FqnExpr.ModelRef; interface DeploymentRef { ref: FqnRef.DeploymentRef; selector?: PredicateSelector; } function isDeploymentRef(expr: Expression): expr is FqnExpr.DeploymentRef; interface ElementKindExpr { elementKind: ElementKind; isEqual: boolean; } function isElementKindExpr(expr: Expression): expr is ElementKindExpr; interface ElementTagExpr { elementTag: Tag; isEqual: boolean; } function isElementTagExpr(expr: Expression): expr is ElementTagExpr; type NonWildcard = ExclusiveUnion<{ ModelRef: ModelRef; DeploymentRef: DeploymentRef; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; }>; interface Where { where: { expr: ExclusiveUnion<{ Wildcard: Wildcard; ModelRef: ModelRef; DeploymentRef: DeploymentRef; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; }>; condition: WhereOperator; }; } function isWhere(expr: Expression): expr is FqnExpr.Where; interface Custom { custom: { expr: OrWhere; title?: string; description?: MarkdownOrString; technology?: string; notation?: string; notes?: MarkdownOrString; shape?: ElementShape; color?: Color; icon?: Icon; iconColor?: Color; iconSize?: ShapeSize; iconPosition?: IconPosition; border?: BorderStyle; opacity?: number; navigateTo?: StrictViewId; /** * If true, each matching element is rendered as multiple shapes. * @default false */ multiple?: boolean; size?: ShapeSize; padding?: ShapeSize; textSize?: ShapeSize; }; } function isCustom(expr: Expression): expr is Custom; function is(expr: Expression): expr is FqnExpr; type OrWhere = ExclusiveUnion<{ Wildcard: FqnExpr.Wildcard; ModelRef: FqnExpr.ModelRef; DeploymentRef: FqnExpr.DeploymentRef; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; Where: FqnExpr.Where; }>; type Any = ExclusiveUnion<{ Wildcard: Wildcard; ModelRef: ModelRef; DeploymentRef: DeploymentRef; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; Where: Where; Custom: Custom; }>; function unwrap(expr: FqnExpr.Any): Wildcard | ModelRef | DeploymentRef | ElementKindExpr | ElementTagExpr; } type FqnExpr = ExclusiveUnion<{ Wildcard: FqnExpr.Wildcard; ModelRef: FqnExpr.ModelRef; DeploymentRef: FqnExpr.DeploymentRef; ElementKind: FqnExpr.ElementKindExpr; ElementTag: FqnExpr.ElementTagExpr; }>; declare namespace RelationExpr { type Endpoint = FqnExpr.Where['where']['expr']; interface Direct { source: Endpoint; target: Endpoint; isBidirectional?: boolean; } function isDirect(expr: Expression): expr is RelationExpr.Direct; interface Incoming { incoming: Endpoint; } function isIncoming(expr: Expression): expr is RelationExpr.Incoming; interface Outgoing { outgoing: Endpoint; } function isOutgoing(expr: Expression): expr is RelationExpr.Outgoing; interface InOut { inout: Endpoint; } function isInOut(expr: Expression): expr is RelationExpr.InOut; interface Where { where: { expr: ExclusiveUnion<{ Direct: RelationExpr.Direct; Incoming: RelationExpr.Incoming; Outgoing: RelationExpr.Outgoing; InOut: RelationExpr.InOut; }>; condition: WhereOperator; }; } function isWhere(expr: Expression): expr is RelationExpr.Where; interface Custom { customRelation: { expr: OrWhere; title?: string; description?: MarkdownOrString; technology?: string; notation?: string; navigateTo?: StrictViewId; notes?: MarkdownOrString; color?: Color; line?: RelationshipLineType; head?: RelationshipArrowType; tail?: RelationshipArrowType; /** * If true, each matching relationship is rendered as a separate edge. * @default false */ multiple?: boolean; }; } function isCustom(expr: Expression): expr is Custom; function is(expr: Expression): expr is RelationExpr; type OrWhere = ExclusiveUnion<{ Direct: Direct; Incoming: Incoming; Outgoing: Outgoing; InOut: InOut; Where: Where; }>; type Any = ExclusiveUnion<{ Direct: Direct; Incoming: Incoming; Outgoing: Outgoing; InOut: InOut; Where: Where; Custom: Custom; }>; function unwrap(expr: RelationExpr.Any): Direct | Incoming | Outgoing | InOut; } type RelationExpr = ExclusiveUnion<{ Direct: RelationExpr.Direct; Incoming: RelationExpr.Incoming; Outgoing: RelationExpr.Outgoing; InOut: RelationExpr.InOut; }>; /** * Represents a version 2 expression which can be one of several types. * * @template D - The type for the deployment FQN, defaults to `Fqn`. * @template M - The type for the model FQN, defaults to `Fqn`. */ type Expression = ExclusiveUnion<{ Wildcard: FqnExpr.Wildcard; ModelRef: FqnExpr.ModelRef; DeploymentRef: FqnExpr.DeploymentRef; ElementKind: FqnExpr.ElementKindExpr; ElementTag: FqnExpr.ElementTagExpr; Custom: FqnExpr.Custom; Direct: RelationExpr.Direct; Incoming: RelationExpr.Incoming; Outgoing: RelationExpr.Outgoing; InOut: RelationExpr.InOut; Where: Expression.Where; CustomRelation: RelationExpr.Custom; }>; declare namespace Expression { type Where = FqnExpr.Where | RelationExpr.Where; function isWhere(expr: Expression): expr is Expression.Where; function isRelationWhere(expr: Expression): expr is RelationExpr.Where; function isFqnExprWhere(expr: Expression): expr is FqnExpr.Where; function isFqnExpr(expr: Expression): expr is FqnExpr.Any; function isRelation(expr: Expression): expr is RelationExpr.Any; } //#endregion //#region src/types/expression-model.d.ts type AnyAux = Any; declare namespace ModelFqnExpr { type Wildcard = { wildcard: true; }; function isWildcard(expr: ModelExpression): expr is ModelFqnExpr.Wildcard; interface Ref { ref: FqnRef.ModelRef; selector?: PredicateSelector; } function isModelRef(ref: ModelExpression): ref is ModelFqnExpr.Ref; interface ElementKindExpr { elementKind: ElementKind; isEqual: boolean; } function isElementKindExpr(expr: ModelExpression): expr is ElementKindExpr; interface ElementTagExpr { elementTag: Tag; isEqual: boolean; } function isElementTagExpr(expr: ModelExpression): expr is ElementTagExpr; type NonWildcard = ExclusiveUnion<{ Ref: Ref; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; }>; interface Where { where: { expr: ExclusiveUnion<{ Wildcard: Wildcard; Ref: Ref; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; }>; condition: WhereOperator; }; } function isWhere(expr: ModelExpression): expr is ModelFqnExpr.Where; interface Custom { custom: { expr: OrWhere; title?: string; description?: MarkdownOrString; technology?: string; notation?: string; notes?: MarkdownOrString; shape?: ElementShape; color?: Color; icon?: Icon; iconColor?: Color; iconSize?: ShapeSize; iconPosition?: IconPosition; border?: BorderStyle; opacity?: number; navigateTo?: StrictViewId; /** * If true, each matching element is rendered as multiple shapes. * @default false */ multiple?: boolean; size?: ShapeSize; padding?: ShapeSize; textSize?: ShapeSize; }; } function isCustom(expr: ModelExpression): expr is Custom; function is(expr: ModelExpression): expr is ModelFqnExpr; type OrWhere = ExclusiveUnion<{ Wildcard: ModelFqnExpr.Wildcard; Ref: ModelFqnExpr.Ref; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; Where: ModelFqnExpr.Where; }>; type Any = ExclusiveUnion<{ Wildcard: Wildcard; Ref: Ref; ElementKind: ElementKindExpr; ElementTag: ElementTagExpr; Where: Where; Custom: Custom; }>; function unwrap(expr: ModelFqnExpr.Any): Wildcard | Ref | ElementKindExpr | ElementTagExpr; } type ModelFqnExpr = ExclusiveUnion<{ Wildcard: ModelFqnExpr.Wildcard; Ref: ModelFqnExpr.Ref; ElementKind: ModelFqnExpr.ElementKindExpr; ElementTag: ModelFqnExpr.ElementTagExpr; }>; declare namespace ModelRelationExpr { type Endpoint = ModelFqnExpr.Where['where']['expr']; interface Direct { source: Endpoint; target: Endpoint; isBidirectional?: boolean; } function isDirect(expr: ModelExpression): expr is ModelRelationExpr.Direct; interface Incoming { incoming: Endpoint; } function isIncoming(expr: ModelExpression): expr is ModelRelationExpr.Incoming; interface Outgoing { outgoing: Endpoint; } function isOutgoing(expr: ModelExpression): expr is ModelRelationExpr.Outgoing; interface InOut { inout: Endpoint; } function isInOut(expr: ModelExpression): expr is ModelRelationExpr.InOut; interface Where { where: { expr: ExclusiveUnion<{ Direct: ModelRelationExpr.Direct; Incoming: ModelRelationExpr.Incoming; Outgoing: ModelRelationExpr.Outgoing; InOut: ModelRelationExpr.InOut; }>; condition: WhereOperator; }; } function isWhere(expr: ModelExpression): expr is ModelRelationExpr.Where; interface Custom { customRelation: { expr: OrWhere; title?: string; description?: MarkdownOrString; technology?: string; notation?: string; navigateTo?: StrictViewId; notes?: MarkdownOrString; color?: Color; line?: RelationshipLineType; head?: RelationshipArrowType; tail?: RelationshipArrowType; /** * If true, each matching relationship is rendered as a separate edge. * @default false */ multiple?: boolean; }; } function isCustom(expr: ModelExpression): expr is Custom; function is(expr: ModelExpression): expr is ModelRelationExpr; type OrWhere = ExclusiveUnion<{ Direct: Direct; Incoming: Incoming; Outgoing: Outgoing; InOut: InOut; Where: Where; }>; type Any = ExclusiveUnion<{ Direct: Direct; Incoming: Incoming; Outgoing: Outgoing; InOut: InOut; Where: Where; Custom: Custom; }>; function unwrap(expr: ModelRelationExpr.Any): Direct | Incoming | Outgoing | InOut; } type ModelRelationExpr = ExclusiveUnion<{ Direct: ModelRelationExpr.Direct; Incoming: ModelRelationExpr.Incoming; Outgoing: ModelRelationExpr.Outgoing; InOut: ModelRelationExpr.InOut; }>; /** * Represents a version 2 expression which can be one of several types. * * @template D - The type for the deployment FQN, defaults to `Fqn`. * @template M - The type for the model FQN, defaults to `Fqn`. */ type ModelExpression = ExclusiveUnion<{ Wildcard: ModelFqnExpr.Wildcard; Ref: ModelFqnExpr.Ref; ElementKind: ModelFqnExpr.ElementKindExpr; ElementTag: ModelFqnExpr.ElementTagExpr; Custom: ModelFqnExpr.Custom; Direct: ModelRelationExpr.Direct; Incoming: ModelRelationExpr.Incoming; Outgoing: ModelRelationExpr.Outgoing; InOut: ModelRelationExpr.InOut; Where: ModelExpression.Where; CustomRelation: ModelRelationExpr.Custom; }>; declare namespace ModelExpression { type Where = ModelFqnExpr.Where | ModelRelationExpr.Where; function isWhere(expr: ModelExpression): expr is ModelExpression.Where; function isRelationWhere(expr: ModelExpression): expr is ModelRelationExpr.Where; function isFqnExprWhere(expr: ModelExpression): expr is ModelFqnExpr.Where; function isFqnExpr(expr: ModelExpression): expr is ModelFqnExpr.Any; function isRelationExpr(expr: ModelExpression): expr is ModelRelationExpr.Any; } //#endregion //#region src/types/view-common.d.ts interface AnyIncludePredicate { include: Expr[]; exclude?: never; } interface AnyExcludePredicate { include?: never; exclude: Expr[]; } interface AnyViewRuleStyle { targets: Expr[]; notation?: string; style: { border?: BorderStyle; opacity?: number; /** * If true, the element is rendered as multiple shapes. * @default false */ multiple?: boolean; size?: ShapeSize; padding?: SpacingSize; textSize?: TextSize; color?: Color; shape?: ElementShape; icon?: Icon; iconColor?: Color; iconSize?: IconSize; iconPosition?: IconPosition; }; } interface ViewRuleGlobalStyle { styleId: GlobalStyleID; } declare function isViewRuleGlobalStyle(rule: object): rule is ViewRuleGlobalStyle; interface ViewRuleGlobalPredicateRef { predicateId: GlobalPredicateId; } declare function isViewRuleGlobalPredicateRef(rule: object): rule is ViewRuleGlobalPredicateRef; type RankValue = 'max' | 'min' | 'same' | 'sink' | 'source'; interface ViewRuleRank { targets: Expr[]; rank: RankValue; } type AutoLayoutDirection = 'TB' | 'BT' | 'LR' | 'RL'; declare function isAutoLayoutDirection(autoLayout: unknown): autoLayout is AutoLayoutDirection; interface ViewRuleAutoLayout { direction: AutoLayoutDirection; nodeSep?: number; rankSep?: number; } declare function isViewRuleAutoLayout(rule: object): rule is ViewRuleAutoLayout; interface ViewAutoLayout { direction: ViewRuleAutoLayout['direction']; rankSep?: number; nodeSep?: number; } type ViewType = 'element' | 'dynamic' | 'deployment'; interface BaseViewProperties extends WithOptionalTags, WithOptionalLinks { readonly id: StrictViewId; readonly title: string | null; readonly description: MarkdownOrString | null; /** * Source file containing this view, relative to the project root. * Undefined if the view is auto-generated. */ readonly sourcePath?: string | undefined; } interface BaseParsedViewProperties extends BaseViewProperties { /** * Internal field to identify the stage of the view. * This is used to create the correct type of the view. */ readonly [_stage]: 'parsed'; /** * URI to the source file of this view. * Undefined if the view is auto-generated. */ readonly docUri?: string | undefined; } type NodeNotation = { kinds: string[]; shape: ElementShape; color: Color; title: string; }; interface ViewWithNotation { notation?: { nodes: NodeNotation[]; }; } interface ViewWithHash { /** * Hash of the view object. * This is used to detect changes in layout */ hash: string; } //#endregion //#region src/types/view-parsed.element.d.ts /** * Predicates scoped to logical model */ interface ElementViewIncludePredicate extends AnyIncludePredicate> {} interface ElementViewExcludePredicate extends AnyExcludePredicate> {} type ElementViewPredicate = ElementViewIncludePredicate | ElementViewExcludePredicate; interface ElementViewRuleGroup { groupRules: Array | ElementViewRuleGroup>; title: string | null; color?: Color; border?: BorderStyle; opacity?: number; /** * If true, each matching element in the group is rendered as multiple shapes. * @default false */ multiple?: boolean; size?: ShapeSize; padding?: SpacingSize; textSize?: TextSize; } declare function isViewRuleGroup(rule: ElementViewRule): rule is ElementViewRuleGroup; interface ElementViewRuleStyle extends AnyViewRuleStyle> {} interface ElementViewRuleRank extends ViewRuleRank> {} declare function isViewRuleRank(rule: ElementViewRule): rule is ElementViewRuleRank; type ElementViewRule = ExclusiveUnion<{ IncludePredicate: ElementViewIncludePredicate; ExcludePredicate: ElementViewExcludePredicate; Group: ElementViewRuleGroup; Style: ElementViewRuleStyle; GlobalStyle: ViewRuleGlobalStyle; GlobalPredicateRef: ViewRuleGlobalPredicateRef; AutoLayout: ViewRuleAutoLayout; Rank: ElementViewRuleRank; }>; interface ParsedElementView extends BaseParsedViewProperties { [_type]: 'element'; readonly rules: ElementViewRule[]; readonly viewOf?: Fqn; readonly extends?: StrictViewId; } //#endregion //#region src/types/view-parsed.dynamic.d.ts interface Step$1 { readonly source: Fqn; readonly target: Fqn; readonly title?: string | null; readonly kind?: RelationKind; readonly description?: MarkdownOrString; readonly technology?: string; readonly notation?: string; readonly notes?: MarkdownOrString; readonly color?: Color; readonly line?: RelationshipLineType; readonly head?: RelationshipArrowType; readonly tail?: RelationshipArrowType; readonly isBackward?: boolean; readonly navigateTo?: StrictViewId; /** * Path to the AST node relative to the view body ast * Used to locate the step in the source code */ readonly astPath: string; } type AnyStep = ExclusiveUnion<{ Step: Step$1; Series: Step$1.Series; Parallel: Step$1.Parallel; Opt: Step$1.Opt; Loop: Step$1.Loop; Try: Step$1.Try; Alt: Step$1.Alt; Break: Step$1.Break; }>; declare const stepGuards: { isStep: (step: AnyStep | undefined | null) => step is Step$1; isSeries: (step: AnyStep | undefined | null) => step is Step$1.Series; isParallel: (step: AnyStep | undefined | null) => step is Step$1.Parallel; isOpt: (step: AnyStep | undefined | null) => step is Step$1.Opt; isLoop: (step: AnyStep | undefined | null) => step is Step$1.Loop; isTry: (step: AnyStep | undefined | null) => step is Step$1.Try; isAlt: (step: AnyStep | undefined | null) => step is Step$1.Alt; isBreak: (step: AnyStep | undefined | null) => step is Step$1.Break; }; interface WithSteps { readonly steps: NonEmptyReadonlyArray>; } declare namespace Step$1 { type Any = AnyStep; /** * Chain of steps (used for sequential execution) */ interface Series { readonly [_type]: 'series'; readonly steps: NonEmptyReadonlyArray>; } /** * Block of parallel steps */ interface Parallel extends WithSteps { readonly [_type]: 'par'; readonly title?: string; } /** * Try-catch-finally block */ interface Try { readonly [_type]: 'try'; /** * Try section */ readonly try: WithSteps & { readonly title?: string; }; /** * Catch section (optional) */ readonly catch?: WithSteps & { readonly title?: string; }; /** * Finally section (optional) */ readonly finally?: WithSteps & { readonly title?: string; }; } /** * Opt block (opt) */ interface Opt extends WithSteps { readonly [_type]: 'opt'; readonly title?: string; } /** * Break block */ interface Break extends WithSteps { readonly [_type]: 'break'; readonly title?: string; } /** * Loop block (loop) */ interface Loop extends WithSteps { readonly [_type]: 'loop'; readonly title?: string; } /** * Group of alternative branches (alt) */ interface Alt { readonly [_type]: 'alt'; readonly title?: string; readonly branches: NonEmptyReadonlyArray>; } /** * Branch block (if/else/if, when, opt) */ interface AltBranch extends WithSteps { readonly [_type]: 'when' | 'if' | 'else'; readonly title?: string; } } interface DynamicViewIncludeRule { include: ModelFqnExpr.Any[]; } type DynamicViewRule = ExclusiveUnion<{ Include: DynamicViewIncludeRule; GlobalPredicateRef: ViewRuleGlobalPredicateRef; ElementViewRuleStyle: ElementViewRuleStyle; GlobalStyle: ViewRuleGlobalStyle; AutoLayout: ViewRuleAutoLayout; }>; type DynamicViewDisplayVariant = 'diagram' | 'sequence'; interface ParsedDynamicView extends BaseParsedViewProperties { [_type]: 'dynamic'; /** * How to display the dynamic view * - `diagram`: display as a regular likec4 view * - `sequence`: display as a sequence diagram * * @default 'diagram' */ readonly variant?: DynamicViewDisplayVariant; readonly steps: Step$1.Any[]; readonly rules: DynamicViewRule[]; } //#endregion //#region src/types/global.d.ts type GlobalPredicateId = Tagged; type GlobalPredicates = NonEmptyArray>; type GlobalDynamicPredicates = NonEmptyArray>; type GlobalStyleID = Tagged; type GlobalStyles = NonEmptyArray>; interface ModelGlobals { readonly predicates: Record>; readonly dynamicPredicates: Record>; readonly styles: Record>; } //#endregion //#region src/types/model-logical.d.ts interface ElementStyle { readonly icon?: Icon; readonly iconColor?: Color; readonly iconSize?: IconSize; readonly iconPosition?: IconPosition; readonly shape?: ElementShape; readonly color?: Color; readonly border?: BorderStyle; /** * In percentage 0-100, 0 is fully transparent * * @default 100 */ readonly opacity?: number; /** * If true, the element is rendered as multiple shapes * @default false */ readonly multiple?: boolean; /** * Shape size * * @default 'md' */ readonly size?: ShapeSize; readonly padding?: SpacingSize; readonly textSize?: TextSize; } type WithSizes = Pick; /** * Ensures that the sizes are set to default values if they are not set */ declare function ensureSizes({ size, padding, textSize, iconSize, ...rest }: S, defaultSize?: "xs" | "sm" | "md" | "lg" | "xl"): Omit & Required; interface Element extends WithDescriptionAndTech, WithOptionalTags, WithOptionalLinks, WithMetadata, WithNotation { readonly id: Fqn; readonly kind: ElementKind; readonly title: string; readonly style: ElementStyle; } interface AbstractRelationship extends WithDescriptionAndTech, WithOptionalTags, WithOptionalLinks, WithMetadata { readonly id: RelationId$1; readonly title?: string | null; readonly kind?: RelationKind; readonly color?: Color; readonly line?: RelationshipLineType; readonly head?: RelationshipArrowType; readonly tail?: RelationshipArrowType; readonly navigateTo?: StrictViewId; } /** * Relationship between two model elements */ interface Relationship extends AbstractRelationship { readonly source: FqnRef.ModelRef; readonly target: FqnRef.ModelRef; } /** * Backward compatibility alias * @deprecated Use {@link Relationship} instead */ type ModelRelation = Relationship; //#endregion //#region src/types/model-deployment.d.ts interface DeploymentNode extends WithDescriptionAndTech, WithOptionalTags, WithOptionalLinks, WithMetadata, WithNotation { element?: never; readonly id: DeploymentFqn; readonly kind: DeploymentKind; readonly title: string; readonly style: ElementStyle; } interface DeployedInstance extends WithDescriptionAndTech, WithOptionalTags, WithOptionalLinks, WithMetadata, WithNotation { kind?: never; /** * Format: `.` * i.e parent fqn is deployment target */ readonly id: DeploymentFqn; readonly element: Fqn; readonly title?: string; readonly style: ElementStyle; } type DeploymentElement = DeploymentNode | DeployedInstance; type DeploymentElementRef$1 = { readonly id: DeploymentFqn; readonly element?: Fqn; }; declare function isDeploymentNode(el: DeploymentElement): el is DeploymentNode; declare function isDeployedInstance(el: DeploymentElement): el is DeployedInstance; /** * Relationship in deployment model */ interface DeploymentRelationship extends AbstractRelationship { readonly source: FqnRef.DeploymentRef; readonly target: FqnRef.DeploymentRef; } /** * Backward compatibility alias * @deprecated Use {@link DeploymentRelationship} instead */ type DeploymentRelation = DeploymentRelationship; //#endregion //#region src/types/model-spec.d.ts /** * Element and deployment kind specification */ interface ElementSpecification { tags?: Tag$1[]; title?: string; summary?: MarkdownOrString; description?: MarkdownOrString; technology?: string; notation?: string; links?: NonEmptyArray; style: { shape?: ElementShape; icon?: Icon; iconColor?: Color; iconSize?: ShapeSize; iconPosition?: IconPosition; color?: Color; border?: BorderStyle; opacity?: number; size?: ShapeSize; padding?: SpacingSize; textSize?: TextSize; /** * If true, the element is rendered as multiple shapes. * @default false */ multiple?: boolean; }; } interface TagSpecification { color: ThemeColor | ColorLiteral; } /** * Checks if tag color is defined in the specification * Expects HEX, `rgb(...)` or `rgba(...)` color */ declare function isTagColorSpecified(spec: string | TagSpecification): spec is { color: ColorLiteral; }; interface RelationshipSpecification { tags?: Tag$1[]; title?: string; description?: MarkdownOrString; technology?: string; notation?: string; links?: NonEmptyArray; color?: Color; line?: RelationshipLineType; head?: RelationshipArrowType; tail?: RelationshipArrowType; /** * If true, matching relationships are rendered as separate edges instead of * being merged into a single connection. * @default false */ multiple?: boolean; } type Specification = A extends Any ? { tags: { [key in Tag]: TagSpecification; }; elements: { [key in ElementKind]: Partial; }; deployments: { [key in DeploymentKind]: Partial; }; relationships: { [key in RelationKind]: Partial; }; metadataKeys?: IsNever> extends true ? never : MetadataKey[]; customColors?: CustomColorDefinitions; } : never; //#endregion //#region src/types/project.d.ts type LikeC4ProjectTheme = PartialDeep, { recurseIntoArrays: false; allowUndefinedInNonTupleArrays: false; }>; type LikeC4ProjectStyleDefaults = PartialDeep, { recurseIntoArrays: false; allowUndefinedInNonTupleArrays: false; }>; interface LikeC4ProjectStylesCustomStylesheets { /** * List of paths to CSS files, relative to the project root * (available in LSP, but not in dumped JSON) */ paths?: string[]; /** * Merged CSS */ content: string; } interface LikeC4ProjectStylesConfig { theme?: LikeC4ProjectTheme; defaults?: LikeC4ProjectStyleDefaults; customCss?: LikeC4ProjectStylesCustomStylesheets; } interface LikeC4ProjectManualLayoutsConfig { outDir: string; } /** * Configuration of the project, as read from the config file. * LikeC4 projects encapsulate models, and can import from each other */ interface LikeC4Project { /** * ID of the project, casted to {@link ProjectId} */ readonly id: ProjectId$1; /** * Title of the project */ title?: string; /** * Custom styles */ styles?: LikeC4ProjectStylesConfig | undefined; /** * Configuration for manual layouts snapshots */ manualLayouts?: LikeC4ProjectManualLayoutsConfig | undefined; /** * Automatically derive element technology from icon name * when technology is not explicitly set. * Applies to aws:, azure:, gcp:, and tech: icons. * Defaults to true. */ inferTechnologyFromIcon?: boolean | undefined; } //#endregion //#region src/types/view-manual-layout.d.ts type LayoutedViewDriftReason = 'not-exists' | 'type-changed' | 'nodes-added' | 'nodes-removed' | 'nodes-drift' | 'edges-added' | 'edges-removed' | 'edges-drift'; type DiagramNodeDriftReason = 'removed' | 'added' | 'label-changed' | 'modelRef-changed' | 'parent-changed' | 'children-changed' | 'became-compound' | 'became-leaf' | 'shape-changed'; type DiagramEdgeDriftReason = 'removed' | 'added' | 'label-added' | 'label-removed' | 'label-changed' | 'notes-changed' | 'direction-changed' | 'source-changed' | 'target-changed'; type ViewManualLayoutSnapshotPerType = Simplify<{ readonly id: ViewId$1; readonly title: string | null; readonly description: MarkdownOrString | null; readonly [_stage]: 'layouted'; readonly hash: string; readonly nodes: ReadonlyArray; readonly edges: ReadonlyArray; readonly bounds: BBox; readonly autoLayout: ViewAutoLayout; } & ViewWithNotation & ({ readonly [_type]: 'element'; readonly viewOf?: Fqn$1; readonly extends?: ViewId$1; } | { readonly [_type]: 'deployment'; } | { readonly [_type]: 'dynamic'; readonly flow?: DynamicViewFlowData; readonly sequenceLayout: LayoutedDynamicView.Sequence.Layout; })>; /** * Snapshot of a view's manual layout. * * When Type is `any`, returns the union of all possible snapshot types. * When Type is a specific view type, returns the corresponding snapshot type. */ type ViewManualLayoutSnapshot = IsAnyOrNever extends true ? never : Type extends (infer T extends string) ? Extract : ViewManualLayoutSnapshotPerType; //#endregion //#region src/types/view-layouted.d.ts interface DiagramNode extends ComputedNode, BBox { /** * Absolute X coordinate */ x: number; /** * Absolute Y coordinate */ y: number; width: number; height: number; /** * Bounding box of label * (Absolute coordinates) */ labelBBox: BBox; /** * List of reasons causing node drift */ drifts?: NonEmptyReadonlyArray | null; } interface DiagramEdge extends ComputedEdge { /** * Bezier points * (Absolute coordinates) */ points: NonEmptyArray; /** * Control points to adjust the edge * (Absolute coordinates) */ controlPoints?: NonEmptyArray | null; /** * Bounding box of label * (Absolute coordinates) */ labelBBox?: BBox | null; /** * Whether the label position was manually set by the user. * When set, the label keeps its position and is not auto-centered on the edge. */ isLabelCustomized?: boolean; /** * List of reasons causing edge drift */ drifts?: NonEmptyReadonlyArray | null; } /** * Type of the layout * - `auto`: auto-layouted from the current sources * - `manual`: read from the manually layouted snapshot */ type LayoutType = 'auto' | 'manual'; interface BaseLayoutedViewProperties extends BaseViewProperties, ViewWithHash, ViewWithNotation { readonly [_stage]: 'layouted'; /** * If undefined, view does not have any manual layouts, and is auto-layouted */ readonly [_layout]?: LayoutType; readonly autoLayout: ViewAutoLayout; readonly nodes: ReadonlyArray>; readonly edges: ReadonlyArray>; readonly bounds: BBox; /** * If diagram has manual layout * But was changed and layout should be recalculated * @deprecated manual layout v2 uses {@link drifts} */ readonly hasLayoutDrift?: boolean; /** * List of reasons causing layout drift * If undefined or null, there is no layout drift or view is auto-layouted */ readonly drifts?: NonEmptyReadonlyArray | null; } interface LayoutedElementView extends BaseLayoutedViewProperties { readonly [_type]: 'element'; readonly viewOf?: Fqn; readonly extends?: StrictViewId; } interface LayoutedDeploymentView extends BaseLayoutedViewProperties { readonly [_type]: 'deployment'; } interface LayoutedDynamicView extends BaseLayoutedViewProperties { readonly [_type]: 'dynamic'; /** * Default variant of this dynamic view * - `diagram`: display as a regular likec4 view (default if not specified) * - `sequence`: display as a sequence diagram */ readonly variant: DynamicViewDisplayVariant; /** * Represents the complete flow structure for dynamic views, as a sequence of steps. * Can include nested flows, branches, loops, and conditional statements. * * (this can be undefined if read from manual snapshot) */ readonly flow?: DynamicViewFlowSteps; /** * Sequence layout of this dynamic view */ readonly sequenceLayout: LayoutedDynamicView.Sequence.Layout; } declare namespace LayoutedDynamicView { namespace Sequence { interface ActorPort { readonly id: string; readonly cx: number; readonly cy: number; readonly height: number; readonly type: 'target' | 'source'; readonly position: 'left' | 'right' | 'top' | 'bottom'; } interface Actor { readonly id: NodeId$1; readonly x: number; readonly y: number; readonly width: number; readonly height: number; readonly ports: ReadonlyArray; } interface Compound { readonly id: NodeId$1; /** * Original node id, since multiple compound nodes can be built from one node */ readonly origin: NodeId$1; readonly x: number; readonly y: number; readonly width: number; readonly height: number; readonly depth: number; } /** * @deprecated Use SubflowArea instead */ interface ParallelArea { readonly parallelPrefix: string; readonly x: number; readonly y: number; readonly width: number; readonly height: number; } /** * Represents an area around some flow control block * (the rest my be read from `view.flow`) */ interface SubflowArea { readonly id: StepPath; readonly x: number; readonly y: number; readonly width: number; readonly height: number; } interface Step { readonly id: StepPath; readonly labelBBox?: { width: number; height: number; } | undefined; readonly sourceHandle: string; readonly targetHandle: string; /** * Step is hidden if it is inside a collapsed subflow */ readonly hidden?: boolean; } interface Layout { readonly actors: ReadonlyArray; /** * Steps in the sequence diagram (filtered edges with compound nodes) */ readonly steps: ReadonlyArray; readonly compounds: ReadonlyArray; /** * @deprecated Use subflows instead */ readonly parallelAreas: ReadonlyArray; readonly subflows: ReadonlyArray; readonly bounds: BBox; } } } //#endregion //#region src/types/view-dynamic-flow.d.ts type WithFlowBase = { [T in keyof Dict]: Simplify<{ readonly '_type': T; /** * Prefix for step IDs in this flow (undefined for top-level flow) */ readonly id: StepPath; readonly title?: string | undefined; } & Dict[T]>; }; /** * All possible sub-flow types */ type SubFlows = WithFlowBase<{ [T in 'loop' | 'opt' | 'par' | 'break']: { readonly flow: DynamicViewFlowSteps; }; } & { [B in `try-${'block' | 'catch' | 'finally'}` | `alt-${'when' | 'else' | 'if'}`]: { readonly flow: DynamicViewFlowSteps; }; } & { 'try': { /** * Allowed flows: * try, try-catch, try-finally, try-catch-finally, */ readonly flow: readonly [Subflow<'try-block'>] | readonly [Subflow<'try-block'>, Subflow<'try-catch' | 'try-finally'>] | readonly [Subflow<'try-block'>, Subflow<'try-catch'>, Subflow<'try-finally'>]; }; 'alt': { /** * Allowed branch flows: * when, else, if */ readonly flow: readonly Subflow<'alt-when' | 'alt-else' | 'alt-if'>[]; }; }>; type SubflowType = keyof SubFlows; type Subflow = SubFlows[T]; type AnySubflow = SubFlows[SubflowType]; type NestedOf = SubFlows[T] extends { flow: IterableContainer; } ? F : never; type ParentOf = IsAnyOrNever extends true ? never : IsEqual extends true ? SubflowType : T extends `try-${string}` ? 'try' : T extends `alt-${string}` ? 'alt' : Exclude; /** * Sub-flows that can be used in dynamic view flows: `alt`, `try`, `loop`, `opt`, `par`, `break` * * (excluding branch flows like `try-block`, `alt-when`, etc. - as they exist only within their parent) */ type DynamicViewSubFlow = Subflow<'alt' | 'try' | 'loop' | 'opt' | 'par' | 'break'>; /** * Generic step in a dynamic view flow * Either a String, meaning it is relation `A -> B`, lookup in edges) or a sub-flow * * @see DynamicViewSubFlow */ type DynamicViewFlowStep = StepPath | DynamicViewSubFlow; /** * Generic steps in a dynamic view flow * @see DynamicViewFlowStep */ type DynamicViewFlowSteps = ReadonlyArray; /** * Represents the complete flow structure for dynamic views, as a sequence of steps. * Can include nested flows, branches, loops, and conditional statements. */ type DynamicViewFlowData = DynamicViewFlowSteps; declare namespace DynamicViewFlow { type SubFlowType = SubflowType; /** * Sub-flow types that can be used in dynamic view flows (excluding nested blocks like try-block, alt-when, etc.) * alt, try, loop, opt, par */ type SubFlow = DynamicViewSubFlow; type Step = DynamicViewFlowStep; type Steps = DynamicViewFlowSteps; type AnyStep = StepPath | AnySubflow; namespace SubFlow { /** * Any subflow type, including nested branches (alt-when, alt-else, alt-if, try-catch, try-finally) */ type Any = AnySubflow; /** * Generic subflow type for a given subflow type * @example * ```ts * type AltOrTry = DynamicViewFlow.SubFlow.Of<'alt' | 'try'> * ``` */ type Of = Subflow; type Alt = Subflow<'alt'>; namespace Alt { type Branch = Subflow<'alt-when' | 'alt-else' | 'alt-if'>; } type Try = Subflow<'try'>; namespace Try { type Block = Subflow<'try-block'>; type Catch = Subflow<'try-catch'>; type Finally = Subflow<'try-finally'>; type Any = Block | Catch | Finally; } type Loop = Subflow<'loop'>; type Opt = Subflow<'opt'>; type Par = Subflow<'par'>; type Break = Subflow<'break'>; } } type StepPathOrFlow = StepPath | { readonly id: StepPath; }; declare function isSubFlow(step: T): step is Exclude; declare function isSubFlow(step: unknown): step is AnySubflow; declare const flowGuards: { isStepPath: typeof isStepPath; isSubFlow: typeof isSubFlow; isTry: (step: unknown) => step is DynamicViewFlow.SubFlow.Try; isTryBlock: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Block; isAlt: (step: unknown) => step is DynamicViewFlow.SubFlow.Alt; isAltBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Alt.Branch; isTryBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Any; isAltOrTry: (step: unknown) => step is DynamicViewFlow.SubFlow.Try | DynamicViewFlow.SubFlow.Alt; isAltOrTryBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Any | DynamicViewFlow.SubFlow.Alt.Branch; type: { isAltOrTry: (value: unknown) => value is "alt" | "try"; isAltBranch: (value: unknown) => value is DynamicViewFlow.SubFlow.Alt.Branch["_type"]; isTryBlock: (value: unknown) => value is "try-block"; isTryBranch: (value: unknown) => value is DynamicViewFlow.SubFlow.Try.Any["_type"]; isAltOrTryBranch: (value: V) => value is Extract; }; }; /** * Returns a function that checks if flow has a step (either directly or as a subflow) */ declare function includes(step: StepPathOrFlow): (flow: StepPathOrFlow) => boolean; /** * Checks if flow has a step (either directly or as a subflow) * @example * ```ts * includes(flow, 'step-path') * includes(flow, anotherFlow) * ``` */ declare function includes(flow: StepPathOrFlow, step: StepPathOrFlow): boolean; /** * Returns a function that checks if a step is before other step, */ declare function isBefore(other: StepPathOrFlow): (step: StepPathOrFlow) => boolean; /** * Checks if a step is before another step */ declare function isBefore(step: StepPathOrFlow, other: StepPathOrFlow): boolean; declare const flowHelpers: { unwindTry: (step: { flow: DynamicViewFlow.SubFlow.Try["flow"]; }) => { tryBlock: DynamicViewFlow.SubFlow.Try.Block; catchBlock: DynamicViewFlow.SubFlow.Try.Catch | null; finallyBlock: DynamicViewFlow.SubFlow.Try.Finally | null; }; /** * Returns first step in flow */ firstStep: (anystepOrFlow: DynamicViewFlow.AnyStep | readonly DynamicViewFlow.AnyStep[]) => StepPath | null; hasSteps: (subflow: F) => boolean; /** * Returns steps of the subflow (excluding nested subflows) (non-recursive) */ steps: (subflow: { flow: IterableContainer; }) => StepPath[]; /** * Returns nested subflows (excluding steps) (non-recursive) */ subflows: (subflow: { flow: IterableContainer; }) => N[]; /** * Returns true if the subflow has nested subflows */ hasSubflows: (subflow: { flow: IterableContainer; }) => boolean; isBefore: typeof isBefore; includes: typeof includes; }; /** * Returns the ids of all ancestor subflows that enclose the given step path, * ordered from the outermost flow to the innermost (closest) one. * * A {@link scalar.StepPath} is a `.`-joined chain of segments where every * subflow segment carries a `NN:type` suffix (e.g. `02:opt`, `03:try`, * `01:block`), while a plain step segment is just its number (`NN`). Every * prefix that ends in such a `:`-bearing segment is therefore an ancestor flow. * * The path itself is never included — a flow is not its own ancestor — so * passing a flow id returns only the flows above it. * * @example * flowAncestors('step-01.02:opt.03:try.04' as StepPath) * // => ['step-01.02:opt', 'step-01.02:opt.03:try'] */ declare function flowAncestors(path: EdgeId$1 | StepPath): StepPath[]; /** * Returns the id of the immediate parent flow that directly encloses the given * step path, or `null` when the path lives at the top level. * * The parent is the innermost of {@link flowAncestors} — the longest prefix that * ends in a `:`-bearing subflow segment, excluding the path itself. * * @example * parentFlow('step-02:opt.03:try.04' as StepPath) // => 'step-02:opt.03:try' * parentFlow('step-02:opt.03:try' as StepPath) // => 'step-02:opt' * parentFlow('step-04' as StepPath) // => null */ declare function parentFlow(path: EdgeId$1 | StepPath | undefined | null): StepPath | null; type StepCtx, R = DynamicViewFlow.AnyStep> = { readonly step: StepPath; readonly edge: V['edges'][number]; readonly source: V['nodes'][number]; readonly target: V['nodes'][number]; readonly stepnum: { /** * Step number within current flow (1-based) */ readonly index: number; /** * Global step number across all flows (1-based) */ readonly global: number; }; readonly level: number; readonly parent: SubflowHookCtx | null; readonly stopAndReturn: (step?: R | undefined) => never; }; type SubflowHookCtx = { readonly id: StepPath; readonly type: T; readonly subflow: Subflow; readonly previous: SubFlows[ParentOf]['flow'][number] | null; readonly parent: SubflowHookCtx> | null; readonly level: number; readonly stopAndReturn: (step?: R | undefined) => never; }; type OnLeave = (onleave: { visited: Array>; lastVisited: NestedOf | null; }) => void; type SubflowHookResult = { /** * Next subflow(s) to visit, or undefined to continue with the default behavior * * @example * { next: 'step-02:opt.03:try' } // Single subflow * { next: ['step-02:opt.03:try', 'step-02:opt.04:catch'] } // Multiple subflows * { next: undefined } // Continue with default behavior */ next?: undefined | NestedOf | ArrayLike | undefined>; /** * Callback function that is called when leaving the subflow */ onLeave?: OnLeave; }; interface SubflowHook { /** * Callback function that is called on entry to each subflow. * * @param ctx - The context of the subflow * @returns {true} - Continue walking * @returns {void} - Continue walking * @returns {false} - Stop walking * @returns {OnLeave} - Continue walking with onLeave callback * @returns {SubflowHookResult} - Continue walking with custom configuration */ (ctx: SubflowHookCtx): boolean | void | OnLeave | SubflowHookResult; } type SubflowHookPerType = Partial | boolean; } & { default: SubflowHook; }>>; type WalkCallback, R = DynamicViewFlow.AnyStep> = { step?: (ctx: StepCtx) => void; subflow?: SubflowHook | SubflowHookPerType; }; /** * Walks through the dynamic view flow and calls the callback for each step and subflow. * (Tree walker) * * @param view - The dynamic view to walk through * @param callback - The callback to call for each step and subflow * * @example * ```ts * walkthroughFlow(view, { * step: ({step, stepnum}) => { * console.log(`Step ${stepnum.global}: ${step}`) * }, * subflow: ({subflow}) => { * console.log(`Subflow ${subflow._type}: ${subflow.id}`) * return { * next: subflow.flow, * onLeave: () => { * console.log(`Left subflow ${subflow._type}`) * } * } * } * }) * ``` */ declare function walkthroughFlow(callback: WalkCallback, R>): (view: ProcessedDynamicView) => R | undefined; declare function walkthroughFlow = ProcessedDynamicView, R extends DynamicViewFlow.AnyStep = DynamicViewFlow.AnyStep>(view: V, callback: WalkCallback): R | undefined; declare namespace walkthroughFlow { var onSubflows: { (types: T, callback: SubflowHook, NoInfer>): { [K in T]: SubflowHook; }; (types: T, callback: SubflowHook[number], NoInfer>): { [K in T[number]]: SubflowHook; }; }; } /** * Creates a map of hooks for the given subflow types. * Each hook will be called when the corresponding subflow is entered. * @example * ```ts * walkthrough({ * view, * subflow: { * ...walkthrough.onSubflows(['try', 'alt'], ({subflow}) => { * // ... * // subflow is typed * }), * }, * }) * ``` */ declare function onSubflows(types: T, callback: SubflowHook, NoInfer>): { [K in T]: SubflowHook; }; declare function onSubflows(types: T, callback: SubflowHook[number], NoInfer>): { [K in T[number]]: SubflowHook; }; /** * Creates a DynamicViewFlow instance from a dynamic view. * This is a convenience function that wraps DynamicViewFlowOps.from(). */ declare function dynamicViewFlow>(view: V): DynamicViewFlow; declare class DynamicViewFlow = LayoutedDynamicView> { private static cache; static from>(view: V): DynamicViewFlow; static readonly guards: { isStepPath: typeof isStepPath; isSubFlow: typeof isSubFlow; isTry: (step: unknown) => step is DynamicViewFlow.SubFlow.Try; isTryBlock: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Block; isAlt: (step: unknown) => step is DynamicViewFlow.SubFlow.Alt; isAltBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Alt.Branch; isTryBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Any; isAltOrTry: (step: unknown) => step is DynamicViewFlow.SubFlow.Try | DynamicViewFlow.SubFlow.Alt; isAltOrTryBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Any | DynamicViewFlow.SubFlow.Alt.Branch; type: { isAltOrTry: (value: unknown) => value is "alt" | "try"; isAltBranch: (value: unknown) => value is DynamicViewFlow.SubFlow.Alt.Branch["_type"]; isTryBlock: (value: unknown) => value is "try-block"; isTryBranch: (value: unknown) => value is DynamicViewFlow.SubFlow.Try.Any["_type"]; isAltOrTryBranch: (value: V_1) => value is Extract; }; }; static readonly helpers: { unwindTry: (step: { flow: DynamicViewFlow.SubFlow.Try["flow"]; }) => { tryBlock: DynamicViewFlow.SubFlow.Try.Block; catchBlock: DynamicViewFlow.SubFlow.Try.Catch | null; finallyBlock: DynamicViewFlow.SubFlow.Try.Finally | null; }; /** * Returns first step in flow */ firstStep: (anystepOrFlow: DynamicViewFlow.AnyStep | readonly DynamicViewFlow.AnyStep[]) => StepPath | null; hasSteps: (subflow: F) => boolean; /** * Returns steps of the subflow (excluding nested subflows) (non-recursive) */ steps: (subflow: { flow: IterableContainer; }) => StepPath[]; /** * Returns nested subflows (excluding steps) (non-recursive) */ subflows: (subflow: { flow: IterableContainer; }) => N[]; /** * Returns true if the subflow has nested subflows */ hasSubflows: (subflow: { flow: IterableContainer; }) => boolean; isBefore: typeof isBefore; includes: typeof includes; }; readonly unwindTry: (step: { flow: DynamicViewFlow.SubFlow.Try["flow"]; }) => { tryBlock: DynamicViewFlow.SubFlow.Try.Block; catchBlock: DynamicViewFlow.SubFlow.Try.Catch | null; finallyBlock: DynamicViewFlow.SubFlow.Try.Finally | null; }; readonly isBefore: typeof isBefore; readonly includes: typeof includes; readonly onSubflows: typeof onSubflows; readonly guards: { isStepPath: typeof isStepPath; isSubFlow: typeof isSubFlow; isTry: (step: unknown) => step is DynamicViewFlow.SubFlow.Try; isTryBlock: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Block; isAlt: (step: unknown) => step is DynamicViewFlow.SubFlow.Alt; isAltBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Alt.Branch; isTryBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Any; isAltOrTry: (step: unknown) => step is DynamicViewFlow.SubFlow.Try | DynamicViewFlow.SubFlow.Alt; isAltOrTryBranch: (step: unknown) => step is DynamicViewFlow.SubFlow.Try.Any | DynamicViewFlow.SubFlow.Alt.Branch; type: { isAltOrTry: (value: unknown) => value is "alt" | "try"; isAltBranch: (value: unknown) => value is DynamicViewFlow.SubFlow.Alt.Branch["_type"]; isTryBlock: (value: unknown) => value is "try-block"; isTryBranch: (value: unknown) => value is DynamicViewFlow.SubFlow.Try.Any["_type"]; isAltOrTryBranch: (value: V_1) => value is Extract; }; }; readonly helpers: { unwindTry: (step: { flow: DynamicViewFlow.SubFlow.Try["flow"]; }) => { tryBlock: DynamicViewFlow.SubFlow.Try.Block; catchBlock: DynamicViewFlow.SubFlow.Try.Catch | null; finallyBlock: DynamicViewFlow.SubFlow.Try.Finally | null; }; /** * Returns first step in flow */ firstStep: (anystepOrFlow: DynamicViewFlow.AnyStep | readonly DynamicViewFlow.AnyStep[]) => StepPath | null; hasSteps: (subflow: F) => boolean; /** * Returns steps of the subflow (excluding nested subflows) (non-recursive) */ steps: (subflow: { flow: IterableContainer; }) => StepPath[]; /** * Returns nested subflows (excluding steps) (non-recursive) */ subflows: (subflow: { flow: IterableContainer; }) => N[]; /** * Returns true if the subflow has nested subflows */ hasSubflows: (subflow: { flow: IterableContainer; }) => boolean; isBefore: typeof isBefore; includes: typeof includes; }; /** * View (flow is defined) */ readonly view: V & { flow: DynamicViewFlowData; }; private levelById; private byId; readonly stepsCount: number; private constructor(); /** * Returns all known step paths in the flow */ get paths(): readonly StepPath[]; /** * Returns level in hierarchy (for z-indexes) */ level(step: StepPath | { id: StepPath; }): number; /** * Returns the parent subflow of the given step path, or undefined if the step is not nested. * @param step The step path to find the parent for. * @returns The parent subflow, or undefined if the step is not nested. */ parent(subflow: N): Subflow> | undefined; parent(step: StepPath | EdgeId$1 | { id: StepPath; }): DynamicViewFlow.SubFlow.Any | undefined; /** * Returns very first step in dynamic view */ firstStep(): StepPath; /** * Returns very first step in subflow */ firstStep(subflow: StepPath | { id: StepPath; }): StepPath | null; /** * Checks if the given path is a step (i.e `A -> B>) */ isStep(path: StepPath): boolean; /** * Checks if the given path is a flow */ isSubflow(path: StepPath): boolean; /** * Returns top level steps */ steps(): readonly StepPath[]; /** * Returns steps in subflow */ steps(subflow: StepPath | { id: StepPath; }): readonly StepPath[]; /** * Returns previous and next steps for the given step * (only steps are considered, subflows are excluded) */ prevAndNext(targetStep: StepPath, skipFlow?: (flowId: StepPath) => boolean): { prev: StepPath | null; next: StepPath | null; }; /** * Lookup a subflow by its path. * @param id The path of the subflow to lookup. * @param assertType Optional type to assert the subflow type. If provided, throws if the subflow is not of the given type. * @returns The subflow with the given path, or throws if not found. */ lookup(id: StepPath, assertType?: T): DynamicViewFlow.SubFlow.Of; /** * Returns top level subflows in the view */ subflows(): DynamicViewFlow.SubFlow[]; /** * Returns nested subflows of a given subflow. * @param id The path of the subflow to lookup. * @returns The subflow with the given path, or throws if not found. */ subflows(subflow: N): NestedOf[]; subflows(id: StepPath): DynamicViewFlow.SubFlow.Any[]; /** * Checks if has nested subflows */ hasSubflows(check: AnySubflow | StepPath): boolean; /** * @see Sequence Layout */ walk(callback: WalkCallback): R | undefined; /** * Returns all steps that come before the given step in the flow. * @param step The step to find predecessors for. * @returns An array of step paths that come before the given step. */ stepsBefore(step: StepPath): DynamicViewFlow.AnyStep[]; /** * Returns all step paths that come before the given step in the flow. * @param step The step to find predecessors for. * @returns An array of step paths that come before the given step. */ stepPathsBefore(step: StepPath): StepPath[]; } /** * Returns all steps that come before the given step in the flow. */ declare function stepsBefore(view: ProcessedDynamicView, _step: StepPath): DynamicViewFlow.AnyStep[]; //#endregion //#region src/types/view-computed.d.ts type ComputedNodeStyle = Simplify; interface ComputedNode extends WithTags, WithOptionalLinks { /** * Element metadata, propagated from the model. * Uses a loose record type (instead of aux.WithMetadata) to avoid * exactOptionalPropertyTypes conflicts when MetadataKey is a literal union. */ readonly metadata?: Readonly> | null; id: NodeId$1; kind: ElementKind | DeploymentKind | '@group'; parent: NodeId$1 | null; /** * Reference to model element */ modelRef?: Fqn; /** * Reference to deployment element */ deploymentRef?: DeploymentFqn; title: string; /** * Description of the node * either summary or description */ description?: MarkdownOrString | null; technology?: string | null; children: NodeId$1[]; inEdges: EdgeId$1[]; outEdges: EdgeId$1[]; shape: ElementShape; color: Color; icon?: Icon | null; style: ComputedNodeStyle; navigateTo?: StrictViewId | null; level: number; depth?: number | null; /** * If this node was customized in the view */ isCustomized?: boolean; notation?: string | null; notes?: MarkdownOrString | undefined; } interface ComputedEdge extends WithOptionalTags { id: EdgeId$1; parent: NodeId$1 | null; source: NodeId$1; target: NodeId$1; label: string | null; description?: MarkdownOrString | null; technology?: string | null; relations: RelationId$1[]; kind?: RelationKind | typeof StepEdgeKind; notation?: string; notes?: MarkdownOrString; color: Color; line: RelationshipLineType; head?: RelationshipArrowType; tail?: RelationshipArrowType; navigateTo?: StrictViewId | null; /** * If this edge is derived from custom relationship predicate */ isCustomized?: boolean; /** * Path to the AST node relative to the view body ast * Available only in dynamic views * @internal */ astPath?: string; /** * For layouting purposes * @default 'forward' */ dir?: 'forward' | 'back' | 'both'; } interface ComputedRankConstraint { type: RankValue; nodes: NodeId$1[]; } interface BaseComputedViewProperties extends BaseViewProperties, ViewWithHash, ViewWithNotation { readonly [_stage]: 'computed'; readonly autoLayout: ViewAutoLayout; readonly nodes: ReadonlyArray>; readonly edges: ReadonlyArray>; /** * If the view has manual layout (v2) */ readonly hasManualLayout?: boolean; } interface ComputedElementView extends BaseComputedViewProperties { readonly [_type]: 'element'; readonly viewOf?: Fqn; readonly extends?: StrictViewId; readonly ranks?: ComputedRankConstraint[]; } interface ComputedDeploymentView extends BaseComputedViewProperties { readonly [_type]: 'deployment'; } interface ComputedDynamicView extends BaseComputedViewProperties { readonly [_type]: 'dynamic'; /** * How to display the dynamic view * - `diagram`: display as a regular likec4 view * - `sequence`: display as a sequence diagram */ readonly variant: DynamicViewDisplayVariant; /** * Represents the complete flow structure for dynamic views, as a sequence of steps. * Can include nested flows, branches, loops, and conditional statements. */ readonly flow: DynamicViewFlowSteps; } //#endregion //#region src/types/view-parsed.deployment.d.ts /** * Predicates scoped to deployment model */ interface DeploymentViewIncludePredicate extends AnyIncludePredicate> {} interface DeploymentViewExcludePredicate extends AnyExcludePredicate> {} type DeploymentViewPredicate = DeploymentViewIncludePredicate | DeploymentViewExcludePredicate; interface DeploymentViewRuleStyle extends AnyViewRuleStyle> {} type DeploymentViewRule = ExclusiveUnion<{ Include: DeploymentViewIncludePredicate; Exclude: DeploymentViewExcludePredicate; Style: DeploymentViewRuleStyle; AutoLayout: ViewRuleAutoLayout; IncludeAncestors: ParsedViewRuleAncestors; }>; interface ParsedViewRuleAncestors { /** * When true, ancestor elements of included deployment nodes are also included in the view. * @default false (ancestors are not included) */ includeAncestors: boolean; } interface ParsedDeploymentView extends BaseParsedViewProperties { [_type]: 'deployment'; readonly rules: DeploymentViewRule[]; } //#endregion //#region src/types/view.d.ts type ParsedView = ParsedElementView | ParsedDeploymentView | ParsedDynamicView; type ComputedView = ComputedElementView | ComputedDeploymentView | ComputedDynamicView; type LayoutedView = LayoutedElementView | LayoutedDeploymentView | LayoutedDynamicView; type ProcessedView = ComputedView | LayoutedView; type ProcessedDynamicView = ComputedDynamicView | LayoutedDynamicView; type AnyView = ParsedElementView | ParsedDeploymentView | ParsedDynamicView | ComputedElementView | ComputedDeploymentView | ComputedDynamicView | LayoutedElementView | LayoutedDeploymentView | LayoutedDynamicView; type ViewOnStage, T extends ModelStage> = Extract; type ViewWithType, T extends ViewType> = Extract; type InferViewAux = V extends AnyView ? Or, IsNever> extends true ? never : A : never; type ViewRule = ParsedView['rules'][number]; type ViewRulePredicate = Extract, { include: any[]; } | { exclude: any[]; }>; declare function isViewRulePredicate>(rule: V): rule is Extract; declare function isViewRuleStyle>(rule: V): rule is Extract; declare function isComputedView>(view: V): view is ExtractOnStage; declare function isDiagramView>(view: V): view is ExtractOnStage; declare function isElementView>(view: V): view is ViewWithType; declare function isScopedElementView>(view: V): view is ViewWithType & { viewOf: Fqn; }; declare function isExtendsElementView>(view: V): view is ViewWithType & { extends: StrictViewId; }; declare function isDeploymentView>(view: V): view is ViewWithType; declare function isDynamicView>(view: V): view is ViewWithType; //#endregion //#region src/types/model-data.d.ts /** * Represents a LikeC4 model data, in different stages of processing * - {@link ParsedLikeC4ModelData} - parsed from DSL or result from Builder * - {@link ComputedLikeC4ModelData} - computed from parsed model * - {@link LayoutedLikeC4ModelData} - layouted from computed model * * !IMPORTANT: This is a low-level type, use `LikeC4Model` instead. */ interface BaseLikeC4ModelData { [_stage]: A['Stage']; projectId: ProjectId; project: LikeC4Project; specification: Specification; elements: Record, Element>; deployments: { elements: Record, DeploymentElement>; relations: Record>; }; relations: Record>; globals: ModelGlobals; imports: Record>>; } type AuxFromLikeC4ModelData = D extends BaseLikeC4ModelData ? IsAnyOrNever extends true ? never : A : never; interface ParsedLikeC4ModelData extends BaseLikeC4ModelData { [_stage]: 'parsed'; views: Record, ParsedView>; } interface ComputedLikeC4ModelData extends BaseLikeC4ModelData { [_stage]: 'computed'; views: Record, ComputedView>; /** * If project contains saved manual layouts */ manualLayouts?: Record; } interface LayoutedLikeC4ModelData extends BaseLikeC4ModelData { [_stage]: 'layouted'; views: Record, LayoutedView>; /** * If this model contains saved manual layouts */ manualLayouts?: Record; } type LikeC4ModelData = ParsedLikeC4ModelData | ComputedLikeC4ModelData | LayoutedLikeC4ModelData; //#endregion //#region src/types/model-dump.d.ts /** * JSON representation of {@link Specification} */ interface SpecificationDump { elements: { [kind: string]: object; }; tags?: { [tag: string]: object; }; deployments?: { [kind: string]: object; }; relationships?: { [kind: string]: object; }; metadataKeys?: string[]; customColors?: { [kind: string]: object; }; } type SpecTypesFromDump = J extends SpecificationDump ? SpecAux, KeysOf, KeysOf, KeysOf, J['metadataKeys'] extends readonly [string, ...string[]] ? J['metadataKeys'][number] : never> : SpecAux; /** * Dump differs from {@link ParsedLikeC4ModelData} by the fact that it is computed or layouted */ type LikeC4ModelDump = { [_stage]?: 'computed' | 'layouted'; projectId?: string; project?: ProjectDump; specification: SpecificationDump; elements?: { [kind: string]: object; }; deployments: { elements?: { [kind: string]: object; }; relations?: {}; }; views?: { [kind: string]: object; }; relations?: {}; globals?: { predicates?: {}; dynamicPredicates?: {}; styles?: {}; }; imports?: {}; }; type ProjectDump = { id: string; name?: string; title?: string | undefined; }; type AuxFromDump = D extends LikeC4ModelDump ? Aux, KeysOf, KeysOf, D['projectId'] extends (infer PID extends string) ? PID : never, SpecTypesFromDump> : Never; //#endregion //#region src/types/view-changes.d.ts declare namespace ViewChange { interface ChangeElementStyle { op: 'change-element-style'; style: { border?: BorderStyle; opacity?: number; shape?: ElementShape; color?: ThemeColor; }; targets: NonEmptyArray; } interface SaveViewSnapshot { op: 'save-view-snapshot'; layout: LayoutedView; } interface ResetManualLayout { op: 'reset-manual-layout'; } interface ChangeAutoLayout { op: 'change-autolayout'; layout: { direction: AutoLayoutDirection; nodeSep?: number | null; rankSep?: number | null; }; } interface ChangeProperty { op: 'change-property'; /** * Change title */ title?: string; /** * Change description */ description?: MarkdownOrString; /** * Add or remove tags */ tag?: { add?: Tag$1 | Tag$1[]; remove?: Tag$1 | Tag$1[]; }; } } type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveViewSnapshot | ViewChange.ResetManualLayout | ViewChange.ChangeAutoLayout | ViewChange.ChangeProperty; //#endregion //#region src/types/RichText.d.ts interface RichTextEmpty { readonly isEmpty: true; readonly isMarkdown: false; readonly nonEmpty: false; readonly $source: null; readonly text: null; readonly md: null; readonly html: null; equals(other: unknown): boolean; } interface RichTextNonEmpty { readonly isEmpty: false; readonly nonEmpty: true; readonly isMarkdown: boolean; readonly $source: MarkdownOrString; readonly text: string; readonly md: string; readonly html: string; equals(other: unknown): boolean; } type RichTextOrEmpty = RichTextNonEmpty | RichTextEmpty; /** * RichText is a class that represents a potentially markdown string. * It can be either a plain text or a markdown. * It is used to represent the content of a node or a link. */ declare class RichText { private static mdcache; private static txtcache; private static getOrCreateFromText; private static getOrCreateFromMarkdown; /** * Creates and memoizes a RichText instance. * @see ElementModel.description * @example * * get description(): RichTextOrEmpty { * return RichText.memoize(this, 'description', this.$element.description) * } */ static memoize(obj: object, tag: symbol | string, source: MarkdownOrString | null | undefined): RichTextOrEmpty; /** * Creates a RichText instance from a source. */ static from(source: RichTextOrEmpty | MarkdownOrString | string | null | undefined): RichTextOrEmpty; /** * This is a workaround for the fact that we need instance of RichText for `instanceof` checks * It is invalid inheritance (returning `null` from getters), and we cast to @see RichTextEmpty */ static EMPTY: RichTextEmpty; readonly $source: Readonly | null; readonly isEmpty: boolean; readonly nonEmpty: boolean; readonly isMarkdown: boolean; /** * Private constructor to prevent direct instantiation. * Use {@link RichText.from} or {@link RichText.memoize} instead. */ private constructor(); /** * Returns the text content of the rich text. * If the source is a string, it returns the string. * If the source is a markdown, it returns the markdown. */ get text(): string; /** * Returns the markdown content of the rich text. * If the source is a string, it returns the string. * If the source is a markdown, it returns the markdown. */ get md(): string; /** * Returns the html content of the rich text. * If the source is a string, it returns the string. * If the source is a markdown, it returns the HTML. */ get html(): string; equals(other: unknown): boolean; } //#endregion //#region src/types/guards.d.ts declare function isString(value: unknown): value is string; declare function isNonEmptyArray(arr: ArrayLike | undefined): arr is NonEmptyArray; declare function hasProp(value: T, path: P): value is SetRequired, P>; declare function hasProp(path: P): (value: T) => value is SetRequired, P>; type Guard = (value: any) => value is To; /** * Extracts the guarded type from a Guard type. * * @template G - A Guard type or union of Guard types * @returns The type that the guard narrows to * * @example * ```typescript * const isString = (n): n is string => typeof n === 'string'; * GuardedBy; // string * ``` */ type GuardedBy = G extends Guard ? Or, IsUnknown> extends true ? never : To : never; /** * Creates a type guard that checks if a value matches any of the provided predicates. * * @template Predicates - A non-empty array of guard functions * @param predicates - The guard functions to test against * @returns A type guard function that returns true if the value matches any of the predicates * * @example * ```typescript * const isStringOrNumber = isAnyOf(isString, isNumber); * * if (isStringOrNumber(value)) { * // value is now typed as string | number * console.log(value); * } * ``` */ declare function isAnyOf>>(...predicates: Predicates): (value: T) => value is T & GuardedBy; declare function hasChildren(value: A): value is A & { children: NonEmptyArray; }; //#endregion export { ComputedNode as $, isStepPath as $i, OrOperator as $n, EdgeId as $r, GlobalStyles as $t, ViewRule as A, DeploymentFqn$1 as Ai, ViewRuleGlobalStyle as An, RelationshipLineTypes as Ar, ElementSpecification as At, isViewRulePredicate as B, NodeId$1 as Bi, ModelFqnExpr as Bn, DefaultTagColors as Br, DeploymentRelationship as Bt, ComputedView as C, ReorderedArray as Ca, _aux_d_exports as Ci, BaseParsedViewProperties as Cn, LikeC4StyleDefaults as Cr, ViewManualLayoutSnapshot as Ct, ProcessedDynamicView as D, toComputed as Di, ViewAutoLayout as Dn, RelationshipArrowTypes as Dr, LikeC4ProjectStylesConfig as Dt, ParsedView as E, setProject as Ei, RankValue as En, RelationshipArrowType as Er, LikeC4ProjectStyleDefaults as Et, isDiagramView as F, GlobalFqn as Fi, isAutoLayoutDirection as Fn, ThemeColor as Fr, DeployedInstance as Ft, DeploymentViewRule as G, RelationshipKind as Gi, RelationExpr as Gn, Any as Gr, ElementStyle as Gt, DeploymentViewExcludePredicate as H, ProjectId$1 as Hi, Expression as Hn, IconPositions as Hr, isDeploymentNode as Ht, isDynamicView as I, GroupElementKind as Ii, isViewRuleAutoLayout as In, ThemeColorValues as Ir, DeploymentElement as It, ParsedViewRuleAncestors as J, Tag$1 as Ji, Filterable as Jn, AnyParsed as Jr, ensureSizes as Jt, DeploymentViewRuleStyle as K, StepEdgeKind as Ki, AndOperator as Kn, AnyComputed as Kr, ModelRelation as Kt, isElementView as L, Icon as Li, isViewRuleGlobalPredicateRef as Ln, isCustomColor as Lr, DeploymentElementRef$1 as Lt, ViewWithType as M, EdgeId$1 as Mi, ViewType as Mn, Size as Mr, Specification as Mt, isComputedView as N, ElementKind$1 as Ni, ViewWithHash as Nn, SpacingSize as Nr, TagSpecification as Nt, ProcessedView as O, AnyFqn as Oi, ViewRuleAutoLayout as On, RelationshipColorValues as Or, LikeC4ProjectStylesCustomStylesheets as Ot, isDeploymentView as P, Fqn$1 as Pi, ViewWithNotation as Pn, TextSize as Pr, isTagColorSpecified as Pt, ComputedElementView as Q, isGroupElementKind as Qi, OperatorPredicate as Qn, DeploymentKind as Qr, GlobalStyleID as Qt, isExtendsElementView as R, IconUrl as Ri, isViewRuleGlobalStyle as Rn, isThemeColor as Rr, DeploymentNode as Rt, AnyView as S, Predicate as Sa, ViewId as Si, AutoLayoutDirection as Sn, IconSize as Sr, LayoutedViewDriftReason as St, LayoutedView as T, preferSummary as Ti, NodeNotation as Tn, LikeC4Theme as Tr, LikeC4ProjectManualLayoutsConfig as Tt, DeploymentViewIncludePredicate as U, RelationId$1 as Ui, FqnExpr as Un, Sizes as Ur, AbstractRelationship as Ut, isViewRuleStyle as V, NoneIcon as Vi, ModelRelationExpr as Vn, ElementShapes as Vr, isDeployedInstance as Vt, DeploymentViewPredicate as W, RelationKind$1 as Wi, PredicateSelector as Wn, ThemeColors as Wr, Element as Wt, ComputedDynamicView as X, flattenMarkdownOrString as Xi, MetadataEqual as Xn, DeploymentFqn as Xr, GlobalPredicateId as Xt, ComputedDeploymentView as Y, ViewId$1 as Yi, KindEqual as Yn, Aux as Yr, GlobalDynamicPredicates as Yt, ComputedEdge as Z, isGlobalFqn as Zi, NotOperator as Zn, DeploymentId as Zr, GlobalPredicates as Zt, AuxFromLikeC4ModelData as _, Link as _a, Tags as _i, isViewRuleGroup as _n, CustomColorDefinitions as _r, LayoutedDeploymentView as _t, isAnyOf as a, _stage as aa, LooseLiteral as ai, ParsedDynamicView as an, isKindEqual as ar, DynamicViewFlowSteps as at, LikeC4ModelData as b, NonEmptyReadonlyArray as ba, UnknownLayouted as bi, AnyIncludePredicate as bn, HexColor as br, DiagramEdgeDriftReason as bt, RichText as c, inferStage as ca, Metadata as ci, stepGuards as cn, isOrOperator as cr, flowAncestors as ct, ViewChange as d, Coalesce as da, RelationId as di, ElementViewPredicate as dn, whereOperatorAsPredicate as dr, parentFlow as dt, scalar_d_exports as ea, ElementId as ei, ModelGlobals as en, Participant as er, ComputedNodeStyle as et, AuxFromDump as f, ExclusiveUnion as fa, RelationKind as fi, ElementViewRule as fn, FqnRef as fr, stepsBefore as ft, SpecificationDump as g, KeysOf as ga, Tag as gi, ParsedElementView as gn, CustomColor as gr, LayoutType as gt, SpecTypesFromDump as h, IteratorLike as ha, StrictViewId as hi, ElementViewRuleStyle as hn, ColorLiteral as hr, DiagramNode as ht, hasProp as i, _layout as ia, LooseElementId as ii, DynamicViewRule as in, isAndOperator as ir, DynamicViewFlowStep as it, ViewRulePredicate as j, DeploymentKind$1 as ji, ViewRuleRank as jn, ShapeSize as jr, RelationshipSpecification as jt, ViewOnStage as k, BuiltInIcon as ki, ViewRuleGlobalPredicateRef as kn, RelationshipLineType as kr, LikeC4ProjectTheme as kt, RichTextEmpty as l, inferType as la, MetadataKey as li, ElementViewExcludePredicate as ln, isParticipantOperator as lr, flowGuards as lt, ProjectDump as m, IterableContainer as ma, Stage as mi, ElementViewRuleRank as mn, Color as mr, DiagramEdge as mt, GuardedBy as n, ExtractOnStage as na, Fqn as ni, DynamicViewDisplayVariant as nn, TagEqual as nr, DynamicViewFlow as nt, isNonEmptyArray as o, _type as oa, LooseTag as oi, Step$1 as on, isMetadataEqual as or, DynamicViewSubFlow as ot, LikeC4ModelDump as p, IsAnyOrNever as pa, SpecAux as pi, ElementViewRuleGroup as pn, BorderStyle as pr, walkthroughFlow as pt, ParsedDeploymentView as q, StepPath as qi, EqualOperator as qn, AnyLayouted as qr, Relationship as qt, hasChildren as r, ModelStage as ra, LooseDeploymentId as ri, DynamicViewIncludeRule as rn, WhereOperator as rr, DynamicViewFlowData as rt, isString as s, _v as sa, LooseViewId as si, WithSteps as sn, isNotOperator as sr, dynamicViewFlow as st, Guard as t, splitGlobalFqn as ta, ElementKind as ti, AnyStep as tn, ParticipantOperator as tr, ComputedRankConstraint as tt, RichTextOrEmpty as u, isOnStage as ua, ProjectId as ui, ElementViewIncludePredicate as un, isTagEqual as ur, flowHelpers as ut, ComputedLikeC4ModelData as v, NTuple as va, Unknown as vi, isViewRuleRank as vn, ElementColorValues as vr, LayoutedDynamicView as vt, InferViewAux as w, exact as wa, preferDescription as wi, BaseViewProperties as wn, LikeC4StylesConfig as wr, LikeC4Project as wt, ParsedLikeC4ModelData as x, OrString as xa, UnknownParsed as xi, AnyViewRuleStyle as xn, IconPosition as xr, DiagramNodeDriftReason as xt, LayoutedLikeC4ModelData as y, NonEmptyArray as ya, UnknownComputed as yi, AnyExcludePredicate as yn, ElementShape as yr, LayoutedElementView as yt, isScopedElementView as z, MarkdownOrString as zi, ModelExpression as zn, BorderStyles as zr, DeploymentRelation as zt };