@likec4/core 1.58.0 → 1.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder/index.d.mts +2 -2
- package/dist/builder/index.mjs +2 -1
- package/dist/chunks/Builder.view-element.mjs +2 -0
- package/dist/{_chunks → chunks}/LikeC4Model.d.mts +24 -26
- package/dist/{_chunks → chunks}/_types.d.mts +302 -57
- package/dist/{_chunks → chunks}/_types2.d.mts +2 -2
- package/dist/chunks/assignTagColors.mjs +1 -0
- package/dist/chunks/calcDriftsFromSnapshot.mjs +1 -0
- package/dist/chunks/default-map.d.mts +29 -0
- package/dist/{_chunks → chunks}/index.d.mts +933 -194
- package/dist/{_chunks → chunks}/index2.d.mts +21 -19
- package/dist/{_chunks → chunks}/index3.d.mts +2 -2
- package/dist/{_chunks/index5.d.mts → chunks/index4.d.mts} +153 -4
- package/dist/{_chunks/index4.d.mts → chunks/index5.d.mts} +2 -2
- package/dist/chunks/libs/chroma-js.mjs +15 -0
- package/dist/chunks/libs/graphology-dag.mjs +1 -0
- package/dist/chunks/libs/graphology.mjs +1 -0
- package/dist/chunks/libs/hast-util-sanitize.mjs +1 -0
- package/dist/chunks/libs/hast-util-to-html.mjs +9 -0
- package/dist/chunks/libs/mdast.mjs +29 -0
- package/dist/chunks/libs/mnemonist.mjs +1 -0
- package/dist/chunks/libs/ohash.mjs +1 -0
- package/dist/chunks/libs/remark.mjs +3 -0
- package/dist/chunks/libs/remeda.mjs +1 -0
- package/dist/chunks/libs/unified.mjs +1 -0
- package/dist/chunks/model.mjs +4 -0
- package/dist/chunks/rolldown-runtime.mjs +1 -0
- package/dist/chunks/types.mjs +9 -0
- package/dist/compute-view/index.d.mts +56 -18
- package/dist/compute-view/index.mjs +2 -2
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +3 -3
- package/dist/model/index.mjs +1 -1
- package/dist/styles/index.d.mts +3 -3
- package/dist/styles/index.mjs +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.mjs +1 -1
- package/dist/utils/graphology/index.d.mts +618 -1
- package/dist/utils/graphology/index.mjs +1 -1
- package/dist/utils/index.d.mts +4 -4
- package/dist/utils/index.mjs +1 -1
- package/package.json +13 -14
- package/dist/THIRD-PARTY-LICENSES.md +0 -1034
- package/dist/_chunks/Builder.view-element.mjs +0 -2
- package/dist/_chunks/assignTagColors.mjs +0 -1
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +0 -1
- package/dist/_chunks/libs/bail.mjs +0 -1
- package/dist/_chunks/libs/ccount.mjs +0 -1
- package/dist/_chunks/libs/character-entities-html4.mjs +0 -1
- package/dist/_chunks/libs/character-entities-legacy.mjs +0 -1
- package/dist/_chunks/libs/character-entities.mjs +0 -2
- package/dist/_chunks/libs/chroma-js.mjs +0 -15
- package/dist/_chunks/libs/comma-separated-tokens.mjs +0 -1
- package/dist/_chunks/libs/decode-named-character-reference.mjs +0 -1
- package/dist/_chunks/libs/defu.mjs +0 -1
- package/dist/_chunks/libs/devlop.mjs +0 -1
- package/dist/_chunks/libs/escape-string-regexp.mjs +0 -1
- package/dist/_chunks/libs/extend.mjs +0 -1
- package/dist/_chunks/libs/graphology-dag.d.mts +0 -607
- package/dist/_chunks/libs/graphology-dag.mjs +0 -1
- package/dist/_chunks/libs/graphology.mjs +0 -1
- package/dist/_chunks/libs/hast-util-sanitize.mjs +0 -1
- package/dist/_chunks/libs/hast-util-to-html.mjs +0 -9
- package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
- package/dist/_chunks/libs/longest-streak.mjs +0 -1
- package/dist/_chunks/libs/markdown-table.mjs +0 -2
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +0 -1
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +0 -3
- package/dist/_chunks/libs/mdast-util-gfm.mjs +0 -15
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +0 -11
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +0 -1
- package/dist/_chunks/libs/mnemonist.d.mts +0 -164
- package/dist/_chunks/libs/mnemonist.mjs +0 -1
- package/dist/_chunks/libs/natural-compare-lite.mjs +0 -9
- package/dist/_chunks/libs/ohash.mjs +0 -1
- package/dist/_chunks/libs/rehype-sanitize.mjs +0 -1
- package/dist/_chunks/libs/rehype-stringify.mjs +0 -1
- package/dist/_chunks/libs/remark-gfm.mjs +0 -1
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +0 -3
- package/dist/_chunks/libs/remark-parse.mjs +0 -1
- package/dist/_chunks/libs/remark-rehype.mjs +0 -1
- package/dist/_chunks/libs/remeda.mjs +0 -2
- package/dist/_chunks/libs/trough.mjs +0 -1
- package/dist/_chunks/libs/unified.mjs +0 -1
- package/dist/_chunks/manual-layout.mjs +0 -1
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/model.mjs +0 -4
- package/dist/_chunks/rolldown-runtime.mjs +0 -1
- package/dist/_chunks/types.mjs +0 -1
- /package/dist/{_chunks → chunks}/libs/@radix-ui/colors.mjs +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { Ai as DeploymentFqn, At as ElementSpecification$1, Bn as ModelFqnExpr, Bt as DeploymentRelationship, Dt as LikeC4ProjectStylesConfig, E as ParsedView, Ei as setProject, Er as RelationshipArrowType, Fr as ThemeColor, Gr as Any, Hn as Expression, It as DeploymentElement, Kt as ModelRelation, Nr as SpacingSize, Nt as TagSpecification, Pi as Fqn, Pr as TextSize, Sn as AutoLayoutDirection, Vn as ModelRelationExpr, Wt as Element$1, Yr as Aux, an as ParsedDynamicView, er as Participant, ga as KeysOf, gn as ParsedElementView, jr as ShapeSize, jt as RelationshipSpecification, kr as RelationshipLineType, on as Step, pi as SpecAux, pr as BorderStyle, q as ParsedDeploymentView, x as ParsedLikeC4ModelData, xn as AnyViewRuleStyle, xr as IconPosition, ya as NonEmptyArray, yr as ElementShape, zi as MarkdownOrString } from "./index.mjs";
|
|
2
3
|
import { n as LikeC4Model } from "./LikeC4Model.mjs";
|
|
3
4
|
import { IfNever, IsLiteral, IsNever, LastArrayElement, PartialDeep, Simplify, Split, Tagged, TupleToUnion, Writable } from "type-fest";
|
|
4
|
-
|
|
5
5
|
//#region src/builder/Builder.deployment.d.ts
|
|
6
6
|
type ToNested$1<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, infer F> ? TypesNested<`${P}.${Id}`, T['ElementKind'], T['Fqn'], T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], `${P}.${Id}` | F> : T extends AnyTypes ? TypesNested<Id, T['ElementKind'], T['Fqn'], T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], Id | T['DeploymentFqn']> : never;
|
|
7
7
|
type FromNested$1<T extends AnyTypes, N> = N extends TypesNested<any, any, any, any, any, any, any, any, infer F> ? T extends TypesNested<infer P, any, any, any, any, any, any, any, any> ? TypesNested<P, T['ElementKind'], T['Fqn'], T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], F> : T extends AnyTypes ? Types<T['ElementKind'], T['Fqn'], T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], F> : never : never;
|
|
@@ -110,7 +110,7 @@ type AddDeploymentNodeHelper<T = unknown> =
|
|
|
110
110
|
* )
|
|
111
111
|
*/
|
|
112
112
|
<const Id extends string>(id: ValidId<Id>, titleOrProps?: string | T) => AddDeploymentNode<Id>;
|
|
113
|
-
type AddDeploymentNodeHelpers<T extends AnyTypes> = T extends Types<any, any, any, any, any, any, infer Kinds extends string, any> ? { [Kind in Kinds]: AddDeploymentNodeHelper<T['NewDeploymentNodeProps']
|
|
113
|
+
type AddDeploymentNodeHelpers<T extends AnyTypes> = T extends Types<any, any, any, any, any, any, infer Kinds extends string, any> ? { [Kind in Kinds]: AddDeploymentNodeHelper<T['NewDeploymentNodeProps']>; } : Invalid<'No Deployment Kinds'>;
|
|
114
114
|
type AddDeploymentRelation<Props = unknown> =
|
|
115
115
|
/**
|
|
116
116
|
* @example
|
|
@@ -174,7 +174,7 @@ interface AddElement<Id extends string> {
|
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/builder/Builder.model.d.ts
|
|
176
176
|
interface ModelBuilder<T extends AnyTypes> extends Builder<T> {
|
|
177
|
-
__addElement(this: void, element: Element): Builder<T>;
|
|
177
|
+
__addElement(this: void, element: Element$1): Builder<T>;
|
|
178
178
|
__addRelation(this: void, relation: Omit<ModelRelation, 'id'>): Builder<T>;
|
|
179
179
|
/**
|
|
180
180
|
* Create a fully qualified name from an id (for nested models)
|
|
@@ -252,7 +252,7 @@ type AddElementHelper<T = unknown> =
|
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
254
|
<const Id extends string>(id: ValidId<Id>, titleOrProps?: string | T) => AddElement<Id>;
|
|
255
|
-
type AddElementHelpers<T extends AnyTypes> = T extends Types<infer Kinds extends string, any, any, any, any, any, any, any> ? { [Kind in Kinds]: AddElementHelper<T['NewElementProps']
|
|
255
|
+
type AddElementHelpers<T extends AnyTypes> = T extends Types<infer Kinds extends string, any, any, any, any, any, any, any> ? { [Kind in Kinds]: AddElementHelper<T['NewElementProps']>; } : Invalid<'No Element Kinds'>;
|
|
256
256
|
type ModelHelpers<T extends AnyTypes> = AddElementHelpers<T> & {
|
|
257
257
|
model: typeof model;
|
|
258
258
|
rel: RelationshipHelper<T['NewRelationshipProps']>;
|
|
@@ -264,6 +264,7 @@ type ModelBuilderFunction<A extends AnyTypes, B extends AnyTypes> = (helpers: Mo
|
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/builder/Builder.view-common.d.ts
|
|
266
266
|
interface LikeC4ViewBuilder<Types extends AnyTypes, Fqn extends string, TypedExpr, ElementExpr extends string = ViewPredicate.ElementExpr<Fqn>, Expr extends string = ViewPredicate.AllExpression<ElementExpr>> {
|
|
267
|
+
Fqn: Fqn;
|
|
267
268
|
Types: Types;
|
|
268
269
|
ElementExpr: ElementExpr;
|
|
269
270
|
Expr: Expr;
|
|
@@ -272,6 +273,7 @@ interface LikeC4ViewBuilder<Types extends AnyTypes, Fqn extends string, TypedExp
|
|
|
272
273
|
include(...exprs: TypedExpr[]): this;
|
|
273
274
|
exclude(...exprs: TypedExpr[]): this;
|
|
274
275
|
style(rule: AnyViewRuleStyle<any>): this;
|
|
276
|
+
step(step: Omit<Step.Any, 'id'>): this;
|
|
275
277
|
autoLayout(layout: AutoLayoutDirection, margins: {
|
|
276
278
|
rank: number;
|
|
277
279
|
node: number;
|
|
@@ -304,12 +306,15 @@ declare namespace ViewPredicate {
|
|
|
304
306
|
type Custom<Types extends AnyTypes> = {
|
|
305
307
|
where?: ViewPredicate.WhereOperator<Types>;
|
|
306
308
|
with?: Simplify<Omit<ModelFqnExpr.Custom['custom'] & ModelRelationExpr.Custom['customRelation'], 'expr' | 'relation' | 'navigateTo'> & {
|
|
309
|
+
kind?: Types['RelationshipKind'];
|
|
307
310
|
navigateTo?: Types['ViewId'];
|
|
308
311
|
}>;
|
|
309
312
|
};
|
|
310
313
|
}
|
|
311
|
-
|
|
312
|
-
declare function $
|
|
314
|
+
type $IncludeArgs<B extends LikeC4ViewBuilder<any, any, any>> = [B['Expr']] | [B['TypedExpr']] | [B['Expr'], ViewPredicate.Custom<B['Types']>] | [B['Expr'], B['Expr'], ...B['Expr'][]];
|
|
315
|
+
declare function $include<B extends LikeC4ViewBuilder<any, any, any>>(...args: $IncludeArgs<NoInfer<B>>): (b: B) => B;
|
|
316
|
+
type $ExcludeArgs<B extends LikeC4ViewBuilder<any, any, any>> = [B['Expr']] | [B['TypedExpr']] | [B['Expr'], ViewPredicate.Custom<B['Types']>] | [B['TypedExpr'], ViewPredicate.Custom<B['Types']>];
|
|
317
|
+
declare function $exclude<B extends LikeC4ViewBuilder<any, any, any>>(...args: $ExcludeArgs<NoInfer<B>>): (b: B) => B;
|
|
313
318
|
/**
|
|
314
319
|
* @example
|
|
315
320
|
* builder.views(({ view, $style }, _) =>
|
|
@@ -325,18 +330,14 @@ declare function $exclude<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...ar
|
|
|
325
330
|
* )
|
|
326
331
|
* )
|
|
327
332
|
*/
|
|
328
|
-
declare function $style<B extends LikeC4ViewBuilder<
|
|
329
|
-
notation,
|
|
330
|
-
...style
|
|
331
|
-
}: AnyViewRuleStyle<any>['style'] & {
|
|
333
|
+
declare function $style<B extends LikeC4ViewBuilder<any, any, any>>(element: B['ElementExpr'] | B['TypedExpr'] | NonEmptyArray<B['ElementExpr']>, { notation, ...style }: AnyViewRuleStyle<any>['style'] & {
|
|
332
334
|
notation?: string;
|
|
333
335
|
}): (b: B) => B;
|
|
334
|
-
declare function $autoLayout<B extends LikeC4ViewBuilder<
|
|
336
|
+
declare function $autoLayout<B extends LikeC4ViewBuilder<any, any, any>>(layout: AutoLayoutDirection, margins?: {
|
|
335
337
|
rank: number;
|
|
336
338
|
node: number;
|
|
337
339
|
}): (b: B) => B;
|
|
338
|
-
|
|
339
|
-
declare function $rules<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...rules: Op<B>[]): (b: B) => B;
|
|
340
|
+
declare function $rules<B extends LikeC4ViewBuilder<any, any, any>>(...rules: Array<(b: B) => B>): (b: B) => B;
|
|
340
341
|
//#endregion
|
|
341
342
|
//#region src/builder/Builder.view-deployment.d.ts
|
|
342
343
|
interface DeploymentViewBuilder<T extends AnyTypes> extends LikeC4ViewBuilder<T, T['DeploymentFqn'], Types.ToExpression<T>> {
|
|
@@ -362,40 +363,115 @@ interface AddDeploymentViewHelper {
|
|
|
362
363
|
declare function $deploymentExpr<T extends AnyTypes>(expr: ViewPredicate.DeploymentExpression<T> | Expression): Types.ToExpression<T>;
|
|
363
364
|
declare function $includeAncestors<B extends DeploymentViewBuilder<AnyTypes>>(value: boolean): (b: B) => B;
|
|
364
365
|
//#endregion
|
|
366
|
+
//#region src/builder/Builder.view-dynamic.d.ts
|
|
367
|
+
interface DynamicViewBuilder<T extends AnyTypes> extends LikeC4ViewBuilder<T, T['Fqn'], Expression<Types.ToAux<T>>> {}
|
|
368
|
+
type DynamicViewRulesBuilder<T extends AnyTypes> = (b: DynamicViewBuilder<T>) => any;
|
|
369
|
+
interface AltBranchBuilder<T extends AnyTypes> {
|
|
370
|
+
readonly Types: T;
|
|
371
|
+
addBranch(alias: Step.Alt['branches'][number]): this;
|
|
372
|
+
}
|
|
373
|
+
interface AddDynamicViewRules<Id extends string> {
|
|
374
|
+
with<S extends AnyTypes>(...rules: Array<(b: DynamicViewBuilder<NoInfer<S>>) => any>): (builder: ViewsBuilder<S>) => ViewsBuilder<Types.AddView<S, Id>>;
|
|
375
|
+
}
|
|
376
|
+
interface AddDynamicViewHelper {
|
|
377
|
+
<const Id extends string, T extends AnyTypes>(id: Id): AddDynamicViewRules<Id> & {
|
|
378
|
+
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
379
|
+
};
|
|
380
|
+
<const Id extends string, T extends AnyTypes>(id: Id, builder: DynamicViewRulesBuilder<NoInfer<T>>): {
|
|
381
|
+
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
382
|
+
};
|
|
383
|
+
<const Id extends string, T extends AnyTypes>(id: Id, propsOrTitle: NoInfer<T>['NewViewProps'] | string): AddDynamicViewRules<Id> & {
|
|
384
|
+
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
385
|
+
};
|
|
386
|
+
<const Id extends string, T extends AnyTypes>(id: Id, propsOrTitle: NoInfer<T>['NewViewProps'] | string | undefined, builder: DynamicViewRulesBuilder<NoInfer<T>>): {
|
|
387
|
+
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
type $StepArg<T extends AnyTypes> = `${T['Fqn']} -> ${T['Fqn']}`;
|
|
391
|
+
type $StepArgs<B extends {
|
|
392
|
+
Types: AnyTypes;
|
|
393
|
+
}> = [step: $StepArg<B['Types']>] | [step: $StepArg<B['Types']>, props: {
|
|
394
|
+
title?: string;
|
|
395
|
+
} & ViewPredicate.Custom<B['Types']>] | [source: B['Types']['Fqn'], target: B['Types']['Fqn']] | [source: B['Types']['Fqn'], target: B['Types']['Fqn'], props: string] | [source: B['Types']['Fqn'], target: B['Types']['Fqn'], props: {
|
|
396
|
+
title?: string;
|
|
397
|
+
} & ViewPredicate.Custom<B['Types']>];
|
|
398
|
+
/**
|
|
399
|
+
* Adds a step to a dynamic view
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* $step('alice -> bob')
|
|
403
|
+
* $step('alice -> bob', { title: 'Alice calls Bob' })
|
|
404
|
+
* $step('alice', 'bob')
|
|
405
|
+
* $step('alice', 'bob', 'Alice calls Bob')
|
|
406
|
+
* $step('alice', 'bob', { title: 'Alice calls Bob' })
|
|
407
|
+
* ```
|
|
408
|
+
* @see $step.series - Sequential steps
|
|
409
|
+
* @see $step.parallel - Parallel steps
|
|
410
|
+
* @see $step.try - Try-catch block
|
|
411
|
+
* @see $step.alt - Alternative steps
|
|
412
|
+
*/
|
|
413
|
+
declare function $step<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...args: $StepArgs<NoInfer<B>>): (b: B) => B;
|
|
414
|
+
declare namespace $step {
|
|
415
|
+
export var series: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(series_0: NoInfer<B>["Types"]["Fqn"], series_1: `-> ${NoInfer<B>["Types"]["Fqn"]}`, ...series: `-> ${NoInfer<B>["Types"]["Fqn"]}`[]) => (b: B) => B;
|
|
416
|
+
var _a: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(opts: $StepTry<$StepOps<NoInfer<B>>>) => (b: B) => B;
|
|
417
|
+
export var parallel: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => any;
|
|
418
|
+
export var loop: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => any;
|
|
419
|
+
export var opt: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => any;
|
|
420
|
+
var _b: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => any;
|
|
421
|
+
export var alt: <B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...stepOps: Array<(b: AltBranchBuilder<NoInfer<B>["Types"]>) => any>) => (b: B) => B;
|
|
422
|
+
export var when: <B extends AltBranchBuilder<AnyTypes>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => B;
|
|
423
|
+
var _c: <B extends AltBranchBuilder<AnyTypes>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => B;
|
|
424
|
+
var _d: <B extends AltBranchBuilder<AnyTypes>>(...stepOps: $StepOps<NoInfer<B>>) => (b: B) => B;
|
|
425
|
+
export { _a as try, _b as break, _c as if, _d as else };
|
|
426
|
+
}
|
|
427
|
+
type $StepOp<T extends AnyTypes> = ((b: LikeC4ViewBuilder<T, any, any>) => any) | `${T['Fqn']} -> ${T['Fqn']}`;
|
|
428
|
+
type $StepOps<B extends {
|
|
429
|
+
Types: AnyTypes;
|
|
430
|
+
}> = Array<$StepOp<B['Types']>>;
|
|
431
|
+
type $StepTry<OPS> = {
|
|
432
|
+
try: OPS;
|
|
433
|
+
catch?: OPS;
|
|
434
|
+
finally?: OPS;
|
|
435
|
+
};
|
|
436
|
+
//#endregion
|
|
365
437
|
//#region src/builder/Builder.view-element.d.ts
|
|
366
438
|
interface ElementViewBuilder<T extends AnyTypes> extends LikeC4ViewBuilder<T, T['Fqn'], Expression<Types.ToAux<T>>> {}
|
|
367
439
|
type ElementViewRulesBuilder<T extends AnyTypes> = (b: ElementViewBuilder<T>) => ElementViewBuilder<T>;
|
|
368
440
|
interface AddViewRules<Id extends string> {
|
|
369
|
-
with<
|
|
441
|
+
with<B extends ViewsBuilder<any>>(...rules: Array<((b: ElementViewBuilder<NoInfer<B>['Types']>) => any)>): (builder: B) => ViewsBuilder<Types.AddView<B['Types'], Id>>;
|
|
370
442
|
}
|
|
371
443
|
interface AddViewHelper {
|
|
372
444
|
<const Id extends string, T extends AnyTypes>(id: Id): AddViewRules<Id> & {
|
|
373
445
|
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
374
446
|
};
|
|
375
|
-
<const Id extends string,
|
|
376
|
-
(builder:
|
|
447
|
+
<const Id extends string, B extends ViewsBuilder<any>>(id: Id, builder: (b: ElementViewBuilder<NoInfer<B>['Types']>) => any): {
|
|
448
|
+
(builder: B): ViewsBuilder<Types.AddView<B['Types'], Id>>;
|
|
377
449
|
};
|
|
378
|
-
<const Id extends string, T extends AnyTypes>(id: Id, propsOrTitle: NoInfer<T['NewViewProps']
|
|
450
|
+
<const Id extends string, T extends AnyTypes>(id: Id, propsOrTitle: NoInfer<T>['NewViewProps'] | string): AddViewRules<Id> & {
|
|
379
451
|
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
380
452
|
};
|
|
381
|
-
<const Id extends string,
|
|
382
|
-
(builder:
|
|
453
|
+
<const Id extends string, B extends ViewsBuilder<any>>(id: Id, propsOrTitle: NoInfer<B>['Types']['NewViewProps'] | string | undefined, builder: (b: ElementViewBuilder<NoInfer<B>['Types']>) => any): {
|
|
454
|
+
(builder: B): ViewsBuilder<Types.AddView<B['Types'], Id>>;
|
|
383
455
|
};
|
|
384
456
|
}
|
|
385
457
|
type ValidFqn<T extends AnyTypes> = IsLiteral<T['Fqn']> extends true ? T['Fqn'] : Invalid<'Fqn must be a literal'>;
|
|
386
458
|
interface AddViewOfHelper {
|
|
387
|
-
<const Id extends string, T extends AnyTypes>(id: Id, of:
|
|
388
|
-
<const Id extends string, T extends AnyTypes>(id: Id, of:
|
|
389
|
-
<const Id extends string, T extends AnyTypes>(id: Id, of:
|
|
459
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: NoInfer<T>['Fqn']): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>;
|
|
460
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: NoInfer<T['Fqn']>, rules: ElementViewRulesBuilder<NoInfer<T>>): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>;
|
|
461
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: NoInfer<T>['Fqn'], propsOrTitle: NoInfer<T>['NewViewProps'] | string): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>;
|
|
462
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: NoInfer<T>['Fqn'], propsOrTitle: NoInfer<T>['NewViewProps'] | string, rules: ElementViewRulesBuilder<NoInfer<T>>): (builder: ViewsBuilder<T>) => ViewsBuilder<Types.AddView<T, Id>>;
|
|
390
463
|
}
|
|
391
464
|
interface TypedAddViewOfHelper<A extends AnyTypes> {
|
|
392
465
|
<const Id extends string, T extends AnyTypes>(id: Id, of: ValidFqn<A>): AddViewRules<Id> & {
|
|
393
466
|
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
394
467
|
};
|
|
395
|
-
<const Id extends string, T extends AnyTypes>(id: Id, of: ValidFqn<A>,
|
|
468
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: ValidFqn<A>, rules: ElementViewRulesBuilder<A>): {
|
|
396
469
|
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
397
470
|
};
|
|
398
|
-
<const Id extends string, T extends AnyTypes>(id: Id, of: ValidFqn<A>, propsOrTitle: A['NewViewProps'] | string
|
|
471
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: ValidFqn<A>, propsOrTitle: A['NewViewProps'] | string): {
|
|
472
|
+
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
473
|
+
};
|
|
474
|
+
<const Id extends string, T extends AnyTypes>(id: Id, of: ValidFqn<A>, propsOrTitle: A['NewViewProps'] | string, rules: ElementViewRulesBuilder<A>): {
|
|
399
475
|
(builder: ViewsBuilder<T>): ViewsBuilder<Types.AddView<T, Id>>;
|
|
400
476
|
};
|
|
401
477
|
}
|
|
@@ -426,10 +502,12 @@ type ViewsHelpers = {
|
|
|
426
502
|
view: AddViewHelper;
|
|
427
503
|
viewOf: AddViewOfHelper;
|
|
428
504
|
deploymentView: AddDeploymentViewHelper;
|
|
505
|
+
dynamicView: AddDynamicViewHelper;
|
|
429
506
|
$include: typeof $include;
|
|
430
507
|
$exclude: typeof $exclude;
|
|
431
508
|
$style: typeof $style;
|
|
432
509
|
$rules: typeof $rules;
|
|
510
|
+
$step: typeof $step;
|
|
433
511
|
$autoLayout: typeof $autoLayout;
|
|
434
512
|
$includeAncestors: typeof $includeAncestors;
|
|
435
513
|
};
|
|
@@ -439,6 +517,7 @@ type ViewsBuilderFunction<A extends AnyTypes, B extends AnyTypes> = (helpers: Si
|
|
|
439
517
|
}>, add: ViewsHelpers['views']) => ((builder: ViewsBuilder<A>) => ViewsBuilder<B>) | ((builder: Builder<A>) => Builder<B>);
|
|
440
518
|
declare function mkViewBuilder(view: Writable<ParsedDeploymentView<any>>): DeploymentViewBuilder<AnyTypes>;
|
|
441
519
|
declare function mkViewBuilder(view: Writable<ParsedElementView<any>>): ElementViewBuilder<AnyTypes>;
|
|
520
|
+
declare function mkViewBuilder(view: Writable<ParsedDynamicView<any>>): DynamicViewBuilder<AnyTypes>;
|
|
442
521
|
//#endregion
|
|
443
522
|
//#region src/builder/Builder.with.d.ts
|
|
444
523
|
interface BuilderMethods<T extends AnyTypes> {
|
|
@@ -462,6 +541,26 @@ interface Builder<T extends AnyTypes> extends BuilderMethods<T> {
|
|
|
462
541
|
*/
|
|
463
542
|
readonly Types: T;
|
|
464
543
|
clone(): Builder<T>;
|
|
544
|
+
/**
|
|
545
|
+
* Extends the builder with additional specification — new element kinds,
|
|
546
|
+
* deployment kinds, relationship kinds, tags or metadata keys. Existing kinds
|
|
547
|
+
* with the same name are overridden by the new spec.
|
|
548
|
+
*
|
|
549
|
+
* The returned builder's `Types` are the *union* of the current types and the
|
|
550
|
+
* ones derived from `spec` (see {@link Types.Merge}), so element-kind helpers,
|
|
551
|
+
* tags, etc. accumulate rather than narrowing.
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```ts
|
|
555
|
+
* Builder.fromParsed(data)
|
|
556
|
+
* .specification({
|
|
557
|
+
* elements: { database: { style: { shape: 'storage' } } },
|
|
558
|
+
* tags: { experimental: { color: '#f00' } },
|
|
559
|
+
* })
|
|
560
|
+
* .model(({ database }, _) => _(database('warehouse', { tags: ['experimental'] })))
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
specification<const Spec extends BuilderSpecification>(spec: Spec): Builder<Types.Merge<T, Types.FromSpecification<Spec>>>;
|
|
465
564
|
/**
|
|
466
565
|
* Builders for each element kind
|
|
467
566
|
*/
|
|
@@ -521,36 +620,85 @@ interface Builder<T extends AnyTypes> extends BuilderMethods<T> {
|
|
|
521
620
|
* Adds views
|
|
522
621
|
*
|
|
523
622
|
* @example
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
623
|
+
* ```ts
|
|
624
|
+
* // Element views
|
|
625
|
+
* builder.views(({ view, viewOf, $include, $style, $rules }, _) =>
|
|
626
|
+
* _(
|
|
627
|
+
* view('view1').with(
|
|
628
|
+
* $include('a -> b'),
|
|
629
|
+
* ),
|
|
630
|
+
* view('view2', {
|
|
631
|
+
* title: 'View 2',
|
|
632
|
+
* }).with(
|
|
633
|
+
* $include('*')
|
|
634
|
+
* ),
|
|
635
|
+
* view(
|
|
636
|
+
* 'view3',
|
|
637
|
+
* {
|
|
638
|
+
* title: 'View 3',
|
|
639
|
+
* },
|
|
640
|
+
* $rules(
|
|
641
|
+
* $include('*'),
|
|
642
|
+
* $style(['*', 'alice'], {
|
|
643
|
+
* color: 'red',
|
|
644
|
+
* }),
|
|
645
|
+
* ),
|
|
646
|
+
* ),
|
|
647
|
+
* viewOf('viewOfA', 'a', $rules(
|
|
648
|
+
* $include('*')
|
|
649
|
+
* )),
|
|
650
|
+
* )
|
|
651
|
+
* )
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```ts
|
|
656
|
+
* // Deployment views
|
|
657
|
+
* builder.views(({ deploymentView, $include, $style, $rules }, _) =>
|
|
658
|
+
* _(
|
|
659
|
+
* deploymentView('deploymentView1').with(
|
|
660
|
+
* $include('a -> b')
|
|
661
|
+
* ),
|
|
662
|
+
* deploymentView(
|
|
663
|
+
* 'deploymentView2'
|
|
664
|
+
* { title: 'View 2' },
|
|
665
|
+
* $rules(
|
|
666
|
+
* $include('*'),
|
|
667
|
+
* $style(['*', 'alice'], {
|
|
668
|
+
* color: 'red',
|
|
669
|
+
* }),
|
|
670
|
+
* ),
|
|
671
|
+
* ),
|
|
672
|
+
* )
|
|
673
|
+
* )
|
|
674
|
+
* ```
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```ts
|
|
678
|
+
* // Dynamic views
|
|
679
|
+
* builder.views(({ dynamicView, $step, $rules }, _) =>
|
|
680
|
+
* _(
|
|
681
|
+
* dynamicView('dynamicView1').with(
|
|
682
|
+
* $step('a -> b'),
|
|
683
|
+
* $step.alt(
|
|
684
|
+
* $step.when('b -> c'),
|
|
685
|
+
* $step.else('b -> e'),
|
|
686
|
+
* ),
|
|
687
|
+
* ),
|
|
688
|
+
* dynamicView(
|
|
689
|
+
* 'dynamic-b',
|
|
690
|
+
* $rules(
|
|
691
|
+
* $step('a', 'b'),
|
|
692
|
+
* $step('a -> b'),
|
|
693
|
+
* $step.loop(
|
|
694
|
+
* 'a -> b',
|
|
695
|
+
* $step.opt('a -> b'),
|
|
696
|
+
* ),
|
|
697
|
+
* ),
|
|
551
698
|
* ),
|
|
552
|
-
*
|
|
553
|
-
*
|
|
699
|
+
* )
|
|
700
|
+
* )
|
|
701
|
+
* ```
|
|
554
702
|
*/
|
|
555
703
|
views<Out extends AnyTypes>(callback: ViewsBuilderFunction<T, Out>): Builder<Out>;
|
|
556
704
|
/**
|
|
@@ -568,6 +716,34 @@ interface Builder<T extends AnyTypes> extends BuilderMethods<T> {
|
|
|
568
716
|
toLikeC4Model<const Project extends BuilderProjectSpecification>(project: Project): LikeC4Model.Computed<setProject<Types.ToAux<T>, Project['id']>>;
|
|
569
717
|
toLikeC4Model(): LikeC4Model.Computed<Types.ToAux<T>>;
|
|
570
718
|
}
|
|
719
|
+
/**
|
|
720
|
+
* The shape of a {@link Specification} this module reads when checking
|
|
721
|
+
* compatibility — only the name-bearing slots that affect {@link Types.FromSpecification}.
|
|
722
|
+
*/
|
|
723
|
+
interface SpecificationShape {
|
|
724
|
+
elements?: string[] | Record<string, unknown>;
|
|
725
|
+
deployments?: string[] | Record<string, unknown>;
|
|
726
|
+
relationships?: string[] | Record<string, unknown>;
|
|
727
|
+
tags?: string[] | Record<string, unknown>;
|
|
728
|
+
metadataKeys?: readonly string[];
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Asserts that `declared` is a subset of `loaded`: every element / deployment /
|
|
732
|
+
* relationship kind, tag and metadata key declared must be present in the loaded
|
|
733
|
+
* specification. The reverse is allowed — the loaded specification may contain
|
|
734
|
+
* extra kinds/tags that are not declared (you simply won't get typed helpers for
|
|
735
|
+
* them).
|
|
736
|
+
*
|
|
737
|
+
* Styles and other per-kind props are intentionally ignored — only the *names*
|
|
738
|
+
* that feed {@link Types.FromSpecification} are compared.
|
|
739
|
+
*
|
|
740
|
+
* Used by `LikeC4.toTypedBuilder` to back its typed cast with a runtime check:
|
|
741
|
+
* if a declared kind is missing from the loaded model, the produced types would
|
|
742
|
+
* lie, so we throw instead.
|
|
743
|
+
*
|
|
744
|
+
* @throws Error listing every declared-but-missing entry.
|
|
745
|
+
*/
|
|
746
|
+
declare function assertSpecificationCompatible(declared: BuilderSpecification, loaded: SpecificationShape): void;
|
|
571
747
|
declare const Builder: {
|
|
572
748
|
/**
|
|
573
749
|
* Creates a builder with compositional methods
|
|
@@ -632,17 +808,69 @@ declare const Builder: {
|
|
|
632
808
|
* ```
|
|
633
809
|
*/
|
|
634
810
|
specification<const Spec extends BuilderSpecification>(spec: Spec): Builder<Types.FromSpecification<Spec>>;
|
|
811
|
+
/**
|
|
812
|
+
* Creates a builder seeded from an existing {@link ParsedLikeC4ModelData}.
|
|
813
|
+
*
|
|
814
|
+
* Use this to enrich a model that was loaded from disk (e.g. via
|
|
815
|
+
* `LikeC4.fromWorkspace(...).toBuilder()`) — the returned builder already
|
|
816
|
+
* contains the model's elements, relations, views, deployments, globals and
|
|
817
|
+
* imports, so calls to `.model(...)`, `.deployment(...)` and `.views(...)` will
|
|
818
|
+
* extend it.
|
|
819
|
+
*
|
|
820
|
+
* Type-safety:
|
|
821
|
+
* - When the data carries a typed {@link Aux} (e.g. the output of
|
|
822
|
+
* `builder.build()`), the returned builder preserves those types — element
|
|
823
|
+
* kinds, FQNs, view ids and tags are statically known.
|
|
824
|
+
* - When the data has an `Unknown` Aux (e.g. loaded from a workspace via
|
|
825
|
+
* `LikeC4.toBuilder()`), the returned builder is `Builder<AnyTypes>` —
|
|
826
|
+
* kinds and FQNs are only known at runtime.
|
|
827
|
+
* - You can also override the type explicitly via the generic parameter
|
|
828
|
+
* (`Builder.fromParsed<typeof mySpec.Types>(data)`) — this is an unchecked
|
|
829
|
+
* promise: the caller takes responsibility for the cast.
|
|
830
|
+
*
|
|
831
|
+
* The optional `mode` controls duplicate handling (see {@link BuilderMode}):
|
|
832
|
+
* - `editable` (default): re-declaring an existing FQN with the same kind
|
|
833
|
+
* replaces it, so loaded elements can be edited in place.
|
|
834
|
+
* - `strict`: re-declaring an existing FQN throws.
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* ```ts
|
|
838
|
+
* const likec4 = await LikeC4.fromWorkspace('/path/to/workspace')
|
|
839
|
+
* const builder = Builder.fromParsed((await likec4.parsedModel()).$data)
|
|
840
|
+
* const enriched = builder
|
|
841
|
+
* .model(({ system, component, relTo }, _) =>
|
|
842
|
+
* _(system('monitoring').with(component('grafana'))),
|
|
843
|
+
* )
|
|
844
|
+
* .toLikeC4Model()
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
847
|
+
fromParsed: {
|
|
848
|
+
<A extends Any>(data: ParsedLikeC4ModelData<A>, mode?: BuilderMode): Builder<Types.FromAux<A>>;
|
|
849
|
+
<T extends AnyTypes>(data: ParsedLikeC4ModelData<Any>, mode?: BuilderMode): Builder<T>;
|
|
850
|
+
};
|
|
635
851
|
};
|
|
636
852
|
declare namespace Builder {
|
|
637
853
|
type Any = Builder<AnyTypes>;
|
|
638
854
|
}
|
|
639
855
|
//#endregion
|
|
640
856
|
//#region src/builder/_types.d.ts
|
|
857
|
+
/**
|
|
858
|
+
* Duplicate-handling mode for a {@link Builder}.
|
|
859
|
+
*
|
|
860
|
+
* - `editable` (default): re-declaring an existing FQN with the **same kind** replaces the
|
|
861
|
+
* existing entry (so `.with(...)` can both edit and descend). Different-kind
|
|
862
|
+
* redeclaration still throws.
|
|
863
|
+
* - `strict`: re-declaring an FQN that already exists throws.
|
|
864
|
+
*
|
|
865
|
+
* Pass `'strict'` when duplicates should be treated as programmer errors — see
|
|
866
|
+
* {@link Builder.fromParsed} and `LikeC4.toBuilder`.
|
|
867
|
+
*/
|
|
868
|
+
type BuilderMode = 'strict' | 'editable';
|
|
641
869
|
type ElementSpecification = Omit<ElementSpecification$1, 'tags'> & {
|
|
642
870
|
tags?: string[];
|
|
643
871
|
};
|
|
644
872
|
type BuilderSpecification = {
|
|
645
|
-
elements
|
|
873
|
+
elements?: string[] | {
|
|
646
874
|
[kind: string]: Partial<ElementSpecification>;
|
|
647
875
|
};
|
|
648
876
|
relationships?: string[] | {
|
|
@@ -666,7 +894,7 @@ type BuilderProjectSpecification = {
|
|
|
666
894
|
title?: string;
|
|
667
895
|
styles?: PartialDeep<LikeC4ProjectStylesConfig>;
|
|
668
896
|
};
|
|
669
|
-
type Metadata<MetadataKey extends string> = IsNever<MetadataKey> extends true ? never : IsLiteral<MetadataKey> extends true ? { [key in MetadataKey]?: string | NonEmptyArray<string
|
|
897
|
+
type Metadata<MetadataKey extends string> = IsNever<MetadataKey> extends true ? never : IsLiteral<MetadataKey> extends true ? { [key in MetadataKey]?: string | NonEmptyArray<string>; } : Record<string, string | NonEmptyArray<string>>;
|
|
670
898
|
type NewElementProps<Tag, Metadata> = {
|
|
671
899
|
title?: string;
|
|
672
900
|
summary?: MarkdownOrString | string;
|
|
@@ -781,9 +1009,26 @@ declare namespace Types {
|
|
|
781
1009
|
type AddDeploymentFqn<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any> ? TypesNested<P, T['ElementKind'], T['Fqn'], T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], `${P}.${Id}` | T['DeploymentFqn']> : T extends AnyTypes ? Types<T['ElementKind'], T['Fqn'], T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], Id | T['DeploymentFqn']> : never;
|
|
782
1010
|
type AddView<T, Id extends string> = T extends TypesNested<infer P, any, any, any, any, any, any, any, any> ? TypesNested<P, T['ElementKind'], T['Fqn'], Id | T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], T['DeploymentFqn']> : T extends AnyTypes ? Types<T['ElementKind'], T['Fqn'], Id | T['ViewId'], T['RelationshipKind'], T['Tag'], T['MetadataKey'], T['DeploymentKind'], T['DeploymentFqn']> : never;
|
|
783
1011
|
type ToAux<T> = T extends AnyTypes ? Aux<'parsed', T['Fqn'], T['DeploymentFqn'], T['ViewId'], 'from-builder', SpecAux<T['ElementKind'], T['DeploymentKind'], T['RelationshipKind'], T['Tag'], T['MetadataKey']>> : Any;
|
|
1012
|
+
/**
|
|
1013
|
+
* Merges two {@link Types} by unioning every slot (element kinds, FQNs,
|
|
1014
|
+
* relationship kinds, tags, metadata keys, deployment kinds and FQNs).
|
|
1015
|
+
*
|
|
1016
|
+
* Used by `Builder.specification(...)` to combine the existing builder's
|
|
1017
|
+
* types with a newly-declared specification. A plain `A & B` intersection
|
|
1018
|
+
* would *narrow* the unions (e.g. `'a' | 'b' & 'c' | 'd'` = `never`), which
|
|
1019
|
+
* is the opposite of what we want when adding new kinds.
|
|
1020
|
+
*/
|
|
1021
|
+
type Merge<A, B> = A extends Types<infer AK extends string, infer AF extends string, infer AV extends string, infer AR extends string, infer AT extends string, infer AM extends string, infer ADK extends string, infer ADF extends string> ? B extends Types<infer BK extends string, infer BF extends string, infer BV extends string, infer BR extends string, infer BT extends string, infer BM extends string, infer BDK extends string, infer BDF extends string> ? Types<AK | BK, AF | BF, AV | BV, AR | BR, AT | BT, AM | BM, ADK | BDK, ADF | BDF> : A : B;
|
|
1022
|
+
/**
|
|
1023
|
+
* Inverse of {@link ToAux} — derives builder {@link Types} from an {@link Aux}.
|
|
1024
|
+
*
|
|
1025
|
+
* Useful when a `Builder` needs to be reconstructed from a runtime value whose
|
|
1026
|
+
* Aux is already known statically (e.g. the result of `builder.build()`).
|
|
1027
|
+
*/
|
|
1028
|
+
type FromAux<A> = A extends Aux<any, infer Element extends string, infer Deployment extends string, infer View extends string, any, SpecAux<infer ElementKind extends string, infer DeploymentKind extends string, infer RelationshipKind extends string, infer Tag extends string, infer MetadataKey extends string>> ? Types<ElementKind, Element, View, RelationshipKind, Tag, MetadataKey, DeploymentKind, Deployment> : AnyTypes;
|
|
784
1029
|
type ToExpression<T> = T extends AnyTypes ? Expression<ToAux<T>> : never;
|
|
785
1030
|
type From<B> = B extends Builder<infer T> ? B['Types'] extends AnyTypes ? T : AnyTypes : never;
|
|
786
1031
|
type DeploymentRules<B> = DeploymentRulesBuilderOp<From<B>>;
|
|
787
1032
|
}
|
|
788
1033
|
//#endregion
|
|
789
|
-
export {
|
|
1034
|
+
export { AddDeploymentNodeHelpers as $, TypedAddViewOfHelper as A, $rules as B, views as C, AddViewRules as D, AddViewOfHelper as E, DeploymentRulesBuilderOp as F, ModelBuilder as G, LikeC4ViewBuilder as H, DeploymentViewBuilder as I, NestedRelationshipHelper as J, ModelBuilderFunction as K, $autoLayout as L, $includeAncestors as M, AddDeploymentViewHelper as N, ElementViewBuilder as O, AddDeploymentViewRules as P, AddDeployedInstance as Q, $exclude as R, mkViewBuilder as S, AddViewHelper as T, ViewPredicate as U, $style as V, AddElementHelpers as W, model as X, RelationshipHelper as Y, AddElement as Z, assertSpecificationCompatible as _, BuilderSpecification as a, AddDeploymentNode as at, ViewsBuilderFunction as b, NewDeploymentNodeProps as c, NewViewProps as d, AddDeploymentRelation as et, Types as f, Builder as g, Warn as h, BuilderProjectSpecification as i, deployment as it, $deploymentExpr as j, ElementViewRulesBuilder as k, NewElementProps as l, ValidId as m, AnyTypesNested as n, DeloymentModelHelpers as nt, Invalid as o, TypesNested as p, ModelHelpers as q, BuilderMode as r, DeploymentModelBuilder as rt, Metadata as s, AnyTypes as t, DeloymentModelBuildFunction as tt, NewRelationProps as u, BuilderMethods as v, $expr as w, ViewsHelpers as x, ViewsBuilder as y, $include as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { $ as ComputedNode, Dn as ViewAutoLayout, Hi as ProjectId, Z as ComputedEdge, aa as _stage, ht as DiagramNode, mt as DiagramEdge, oa as _type, wn as BaseViewProperties } from "./index.mjs";
|
|
2
3
|
import { i as BBox } from "./index2.mjs";
|
|
3
|
-
|
|
4
4
|
//#region src/compute-view/projects-view/_types.d.ts
|
|
5
5
|
interface ComputedProjectNode extends ComputedNode {
|
|
6
6
|
readonly projectId: ProjectId;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime.mjs";import{U as e,jn as t,wn as n}from"./types.mjs";import{E as r,Q as i,Y as a,l as o,m as s,nt as c,p as l,w as u}from"./libs/remeda.mjs";function assignTagColors(d){let f=[],p=[];for(let[e,t]of a(d))r(t.color)?f.push({tag:e,spec:{color:t.color}}):p.push(e);return i(p,o(n),u((n,r)=>({tag:n,spec:{color:t(e[r%e.length])}})),c(f),o((e,t)=>n(e.tag,t.tag)),l(s(`tag`),s(`spec`)))}export{assignTagColors as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime.mjs";import{An as e,Rt as t,St as n,Zt as r,b as i,nn as a,x as o}from"./types.mjs";import{A as s,B as c,E as l,J as u,Q as d,S as f,U as p,V as m,Y as h,Z as g,_,c as v,h as y,i as b,k as x,m as S,w as C}from"./libs/remeda.mjs";import{castDraft as w,produce as T}from"immer";function buildElementNotations(e){return d(e,u(e=>!!e.notation),m(S(`notation`)),f(y(m(S(`shape`)),f(y(m(S(`color`)),f(y(C(S(`kind`)),b())),h(),C(([e,t])=>({kinds:t,color:e})))),h(),p(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),h(),p(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),v(S(`shape`),S(`title`),[e=>e.kinds.length,`desc`]))}const changed=(e,t)=>e===t||s(e)&&s(t)?!1:!c(e,t);function autoApplyMetaAndStyles(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],s(t.style.border)?delete e.style.border:e.style.border=t.style.border,x(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,s(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function autoApplyIcon(e,t,n){if(changed(t.icon??`none`,e.icon??`none`)){let r=l(e.icon)&&e.icon!==`none`;switch(!0){case r&&l(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case r&&(s(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!r&&l(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function autoApplyIconStyles(e,t,n){let r=!0;return changed(e.style.iconColor,t.style.iconColor)&&(s(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),changed(e.style.iconSize,t.style.iconSize)&&(n?s(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:r=!1),changed(e.style.iconPosition,t.style.iconPosition)&&(n?s(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:r=!1),r}function patchMarkdownOrString(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function autoApplyLabelsToLeaf(e,t,n){let r=!0;return changed(e.title,t.title)&&(n?e.title=t.title:r=!1),changed(e.description,t.description)&&(s(t.description)?delete e.description:n?e.description=patchMarkdownOrString(e.description,t.description):r=!1),changed(e.technology,t.technology)&&(s(t.technology)?delete e.technology:n?e.technology=t.technology:r=!1),r}function autoApplyLabelsToCompound(e,t,n){return e.title=t.title,s(t.description)?delete e.description:e.description=patchMarkdownOrString(e.description,t.description),s(t.technology)?delete e.technology:e.technology=t.technology,!0}function applyManualLayout(t,r){e(t.id===r.id,`applyManualLayout: view ids do not match`),e(t._stage===`layouted`,`applyManualLayout: expected layouted view`),e(r._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),e(t._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let a=new Set;t._type!==r._type&&a.add(`type-changed`);let s=applyNodesManualLayout(r.nodes,t.nodes,a),c=applyEdgesManualLayout(r.edges,t.edges,a),l=buildElementNotations(s);return T(r,e=>{e.title=t.title??r.title,e.description=t.description??r.description,e.tags=t.tags?[...t.tags]:null,e.links=t.links?[...t.links]:null,e.sourcePath=t.sourcePath,e[n]=`manual`,l&&l.length>0?e.notation={nodes:l}:delete e.notation,e.nodes=w(s),e.edges=w(c),i(t)&&e._type===`dynamic`&&(e.variant=t.variant),o(t)&&e._type===`element`&&(t.viewOf?e.viewOf=t.viewOf:delete e.viewOf,t.extends?e.extends=t.extends:delete e.extends);let u=[...a];g(u,1)?e.drifts=u:(e.hash=t.hash,delete e.drifts)})}function applyNodesManualLayout(e,n,r){let i=new Map(n.map(e=>[e.id,e])),a=e.map(e=>{let n=i.get(e.id);return n?(i.delete(n.id),T(e,i=>{autoApplyMetaAndStyles(i,n);let a=new Set,o=e.children.length>0,c=n.children.length>0;(changed(i.modelRef,n.modelRef)||changed(i.deploymentRef,n.deploymentRef))&&a.add(`modelRef-changed`),c&&!o&&a.add(`became-compound`),!c&&o&&a.add(`became-leaf`),changed(i.parent,n.parent)&&a.add(`parent-changed`);let l=i.width+5>=n.width&&i.height+5>=n.height;changed(i.shape,n.shape)&&(l?i.shape=n.shape:a.add(`shape-changed`)),autoApplyIconStyles(i,n,l)||a.add(`label-changed`),autoApplyIcon(i,n,l&&c===o)||a.add(`label-changed`),(o?autoApplyLabelsToCompound:autoApplyLabelsToLeaf)(i,n,l)||a.add(`label-changed`),changed(i.notes,n.notes)&&(s(n.notes)?delete i.notes:i.notes=patchMarkdownOrString(i.notes,n.notes)),changed(e.notation,n.notation)&&(i.notation=n.notation??null),o&&c&&t(new Set(e.children),new Set(n.children)).size>0&&a.add(`children-changed`);let u=[...a];g(u,1)?(r.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(r.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&r.add(`nodes-added`),a}function applyEdgesManualLayout(t,n,i){let o=new Map(n.map(e=>[e.id,e])),c=t.map(t=>{let n=o.get(t.id)??d(o.values(),a(e=>e.source===t.source&&e.target===t.target),r());return n&&o.delete(n.id),T(t,r=>{if(!n){r.drifts=[`removed`],i.add(`edges-removed`);return}let a=new Set,o=t.id===n.id;switch(!0){case o&&t.source==n.source&&t.target==n.target:changed(r.dir??`forward`,n.dir??`forward`)&&a.add(`direction-changed`);break;case o&&t.source==n.target&&t.target==n.source:t.source!==t.target&&a.add(`direction-changed`);break;case o:t.source!=n.source&&a.add(`source-changed`),t.target!=n.target&&a.add(`target-changed`);break;default:e(t.id!=n.id,`Unexpected case in edge drift detection, ids should not match`),e(t.source==n.source,`Unexpected case in edge drift detection, sources should match`),e(t.target==n.target,`Unexpected case in edge drift detection, targets should match`),changed(r.dir??`forward`,n.dir??`forward`)&&a.add(`direction-changed`);break}r.color=n.color,r.line=n.line,r.navigateTo=n.navigateTo??null,r.tags=n.tags?[...n.tags]:null,changed(t.notes,n.notes)&&(s(t.notes)!==s(n.notes)&&a.add(`notes-changed`),r.notes=n.notes??t.notes),n.astPath?r.astPath=n.astPath:delete r.astPath;let c=_(t,[`label`,`description`,`technology`,`labelBBox`]),l=_(n,[`label`,`description`,`technology`,`labelBBox`]);if(changed(c,l))switch(!0){case n.labelBBox&&!t.labelBBox:a.add(`label-added`);break;case t.labelBBox&&!n.labelBBox:a.add(`label-removed`);break;case!!t.labelBBox&&!!n.labelBBox:n.labelBBox.width*n.labelBBox.height>(t.labelBBox.width+5)*(t.labelBBox.height+5)&&(r.labelBBox.width=Math.round(n.labelBBox.width),r.labelBBox.height=Math.round(n.labelBBox.height)),changed(t.label,n.label)&&(s(n.label)!==s(t.label)&&a.add(`label-changed`),r.label=n.label??t.label),changed(t.description,n.description)&&(s(n.description)!==s(t.description)&&a.add(`label-changed`),n.description&&(r.description=patchMarkdownOrString(t.description,n.description))),changed(t.technology,n.technology)&&(s(n.technology)!==s(t.technology)&&a.add(`label-changed`),r.technology=n.technology??t.technology??null);break;default:e(!t.labelBBox,`Unexpected case in edge labelBBox drift detection`),e(!n.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let u=[...a];g(u,1)?(i.add(`edges-drift`),r.drifts=u):delete r.drifts})});return o.size>0&&i.add(`edges-added`),c}function calcDriftsFromSnapshot(e,t){let{drifts:i,...o}=applyManualLayout(e,t);if(!i||i.length===0)return T(e,e=>{delete e.drifts,e[n]=`auto`});let s=new Set;i.includes(`type-changed`)&&s.add(`type-changed`);let c=new Map(o.nodes.map(e=>[e.id,e])),l=new Map(o.edges.map(e=>[e.id,e])),u=e.nodes.map(e=>{let t=c.get(e.id);return t&&c.delete(t.id),T(e,e=>{if(!t){s.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(s.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});c.size>0&&s.add(`nodes-removed`);let f=e.edges.map(e=>{let t=l.get(e.id)??d(l.values(),a(t=>t.source===e.source&&t.target===e.target),r());return t&&l.delete(t.id),T(e,e=>{if(!t){s.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(s.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});l.size>0&&s.add(`edges-removed`);let p=[...s];return T(e,e=>{g(p,1)?e.drifts=p:delete e.drifts,e.nodes=w(u),e.edges=w(f),e[n]=`auto`})}export{applyManualLayout as n,buildElementNotations as r,calcDriftsFromSnapshot as t};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/default-map.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Mnemonist DefaultMap Typings
|
|
5
|
+
* =============================
|
|
6
|
+
*/
|
|
7
|
+
declare class DefaultMap<K, V> implements Iterable<[K, V]> {
|
|
8
|
+
// Members
|
|
9
|
+
size: number;
|
|
10
|
+
// Constructor
|
|
11
|
+
constructor(factory: (key: K, index: number) => V);
|
|
12
|
+
// Methods
|
|
13
|
+
clear(): void;
|
|
14
|
+
set(key: K, value: V): this;
|
|
15
|
+
delete(key: K): boolean;
|
|
16
|
+
has(key: K): boolean;
|
|
17
|
+
get(key: K): V;
|
|
18
|
+
peek(key: K): V | undefined;
|
|
19
|
+
forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void;
|
|
20
|
+
keys(): IterableIterator<K>;
|
|
21
|
+
values(): IterableIterator<V>;
|
|
22
|
+
entries(): IterableIterator<[K, V]>;
|
|
23
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
24
|
+
inspect(): any;
|
|
25
|
+
// Statics
|
|
26
|
+
static autoIncrement(): number;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { DefaultMap as t };
|