@likec4/core 1.30.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +407 -5
  2. package/dist/builder/index.d.mts +221 -42
  3. package/dist/builder/index.mjs +118 -65
  4. package/dist/compute-view/index.d.mts +23 -7
  5. package/dist/compute-view/index.mjs +11 -6
  6. package/dist/compute-view/relationships-view/index.d.mts +9 -7
  7. package/dist/compute-view/relationships-view/index.mjs +3 -2
  8. package/dist/index.d.mts +10 -14
  9. package/dist/index.mjs +10 -6
  10. package/dist/model/index.d.mts +173 -19
  11. package/dist/model/index.mjs +6 -1
  12. package/dist/shared/core.BaYE_r29.d.mts +258 -0
  13. package/dist/shared/core.Bk7wEZFG.mjs +276 -0
  14. package/dist/shared/core.BrCnZFTn.mjs +32 -0
  15. package/dist/shared/core.BuO4ncfY.d.mts +146 -0
  16. package/dist/shared/{core.CAcZ6_cP.mjs → core.CBpKAlhj.mjs} +1742 -4128
  17. package/dist/shared/core.CCWXGc6G.d.mts +920 -0
  18. package/dist/shared/core.CUYDgv2-.mjs +214 -0
  19. package/dist/shared/{core.Cu-UdkSl.mjs → core.CpXlRyE5.mjs} +7 -494
  20. package/dist/shared/{core.C-YXI-43.mjs → core.Cy9smucx.mjs} +3 -1
  21. package/dist/shared/core.CywrQs86.d.mts +31 -0
  22. package/dist/shared/core.DoK86JEe.mjs +518 -0
  23. package/dist/shared/core.Dpq3P3YJ.d.mts +1265 -0
  24. package/dist/shared/{core.D2830qgg.d.mts → core.Pf5I9o0e.d.mts} +1 -1
  25. package/dist/shared/core.cbA9VZ02.mjs +2681 -0
  26. package/dist/shared/{core.CQXU9DF7.mjs → core.rmvsy0n3.mjs} +23 -32
  27. package/dist/types/aux.d.mts +3 -0
  28. package/dist/types/aux.mjs +1 -0
  29. package/dist/types/index.d.mts +7 -45
  30. package/dist/types/index.mjs +130 -3
  31. package/dist/utils/index.d.mts +221 -53
  32. package/dist/utils/index.mjs +14 -10
  33. package/package.json +19 -10
  34. package/src/builder/Builder.deploymentModel.ts +82 -18
  35. package/src/builder/Builder.element.ts +40 -20
  36. package/src/builder/Builder.model.ts +66 -17
  37. package/src/builder/Builder.ts +168 -76
  38. package/src/builder/Builder.view-common.ts +35 -17
  39. package/src/builder/Builder.view-deployment.ts +25 -25
  40. package/src/builder/Builder.view-element.ts +13 -12
  41. package/src/builder/Builder.views.ts +12 -7
  42. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +62 -34
  43. package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +319 -0
  44. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +45 -24
  45. package/src/builder/_types.ts +34 -27
  46. package/src/compute-view/compute-view.ts +31 -34
  47. package/src/compute-view/deployment-view/__test__/TestHelper.ts +27 -14
  48. package/src/compute-view/deployment-view/__test__/fixture.ts +15 -13
  49. package/src/compute-view/deployment-view/_types.ts +10 -10
  50. package/src/compute-view/deployment-view/clean-connections.ts +5 -7
  51. package/src/compute-view/deployment-view/compute.ts +16 -13
  52. package/src/compute-view/deployment-view/memory/memory.ts +5 -6
  53. package/src/compute-view/deployment-view/predicates/deploymentRefs.ts +4 -5
  54. package/src/compute-view/deployment-view/predicates/relation-direct.ts +25 -50
  55. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +5 -7
  56. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +7 -11
  57. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +7 -10
  58. package/src/compute-view/deployment-view/predicates/utils.ts +37 -31
  59. package/src/compute-view/deployment-view/predicates/wildcard.ts +3 -2
  60. package/src/compute-view/deployment-view/stages/stage-final.ts +2 -2
  61. package/src/compute-view/deployment-view/stages/stage-include.ts +1 -1
  62. package/src/compute-view/deployment-view/utils.ts +79 -72
  63. package/src/compute-view/dynamic-view/__test__/fixture.ts +20 -11
  64. package/src/compute-view/dynamic-view/compute.ts +60 -53
  65. package/src/compute-view/element-view/__test__/TestHelper.ts +53 -29
  66. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +26 -26
  67. package/src/compute-view/element-view/__test__/fixture.ts +134 -83
  68. package/src/compute-view/element-view/_types.ts +14 -19
  69. package/src/compute-view/element-view/clean-connections.ts +12 -8
  70. package/src/compute-view/element-view/compute.ts +61 -51
  71. package/src/compute-view/element-view/memory/NodeGroup.ts +8 -9
  72. package/src/compute-view/element-view/memory/memory.ts +22 -22
  73. package/src/compute-view/element-view/memory/stage-include.ts +5 -3
  74. package/src/compute-view/element-view/predicates/_utils.ts +18 -14
  75. package/src/compute-view/element-view/predicates/element-expand.ts +4 -5
  76. package/src/compute-view/element-view/predicates/element-kind-tag.ts +3 -4
  77. package/src/compute-view/element-view/predicates/element-ref.ts +3 -4
  78. package/src/compute-view/element-view/predicates/relation-direct.ts +16 -12
  79. package/src/compute-view/element-view/predicates/relation-in-out.ts +7 -8
  80. package/src/compute-view/element-view/predicates/relation-in.ts +19 -26
  81. package/src/compute-view/element-view/predicates/relation-out.ts +20 -21
  82. package/src/compute-view/element-view/predicates/wildcard.ts +3 -3
  83. package/src/compute-view/element-view/utils.ts +25 -23
  84. package/src/compute-view/index.ts +1 -1
  85. package/src/compute-view/memory/AbstractStageExclude.ts +3 -4
  86. package/src/compute-view/memory/AbstractStageInclude.ts +1 -1
  87. package/src/compute-view/memory/_types.ts +3 -2
  88. package/src/compute-view/relationships-view/_types.ts +3 -4
  89. package/src/compute-view/relationships-view/compute.ts +8 -11
  90. package/src/compute-view/relationships-view/layout.ts +6 -6
  91. package/src/compute-view/relationships-view/utils.ts +4 -4
  92. package/src/compute-view/utils/ancestorsOfNode.ts +7 -7
  93. package/src/compute-view/utils/applyCustomElementProperties.ts +16 -8
  94. package/src/compute-view/utils/applyCustomRelationProperties.ts +19 -9
  95. package/src/compute-view/utils/applyViewRuleStyles.ts +18 -10
  96. package/src/compute-view/utils/buildComputedNodes.ts +40 -40
  97. package/src/compute-view/utils/buildElementNotations.ts +14 -14
  98. package/src/compute-view/utils/elementExpressionToPredicate.ts +14 -15
  99. package/src/compute-view/utils/link-nodes-with-edges.ts +6 -4
  100. package/src/compute-view/utils/merge-props-from-relationships.ts +52 -20
  101. package/src/compute-view/utils/relationExpressionToPredicates.ts +19 -19
  102. package/src/compute-view/utils/resolve-extended-views.ts +8 -7
  103. package/src/compute-view/utils/resolve-global-rules.ts +31 -26
  104. package/src/compute-view/utils/topological-sort.ts +14 -14
  105. package/src/compute-view/utils/view-hash.ts +2 -2
  106. package/src/compute-view/utils/with-readable-edges.ts +9 -5
  107. package/src/index.ts +0 -32
  108. package/src/model/DeploymentElementModel.ts +182 -137
  109. package/src/model/DeploymentModel.ts +88 -65
  110. package/src/model/ElementModel.ts +92 -72
  111. package/src/model/LikeC4Model.ts +430 -241
  112. package/src/model/RelationModel.ts +69 -26
  113. package/src/model/__test__/fixture.ts +50 -36
  114. package/src/model/connection/Connection.ts +2 -2
  115. package/src/model/connection/deployment/DeploymentConnectionModel.ts +21 -24
  116. package/src/model/connection/deployment/find.ts +1 -1
  117. package/src/model/connection/model/ConnectionModel.ts +21 -20
  118. package/src/model/connection/model/find.ts +7 -7
  119. package/src/model/connection/ops.ts +6 -6
  120. package/src/model/guards.ts +66 -14
  121. package/src/model/index.ts +20 -7
  122. package/src/model/types.ts +41 -97
  123. package/src/model/view/EdgeModel.ts +47 -41
  124. package/src/model/view/LikeC4ViewModel.ts +130 -80
  125. package/src/model/view/NodeModel.ts +102 -96
  126. package/src/theme/element.ts +1 -1
  127. package/src/theme/index.ts +9 -9
  128. package/src/theme/relationships.ts +1 -1
  129. package/src/types/_common.ts +21 -15
  130. package/src/types/aux.ts +285 -0
  131. package/src/types/const.ts +34 -0
  132. package/src/types/expression-model.ts +292 -0
  133. package/src/types/expression.ts +311 -0
  134. package/src/types/fqnRef.ts +88 -0
  135. package/src/types/geometry.ts +131 -0
  136. package/src/types/global.ts +10 -8
  137. package/src/types/index.ts +39 -201
  138. package/src/types/model-data.ts +52 -84
  139. package/src/types/model-deployment.ts +87 -0
  140. package/src/types/model-dump.ts +72 -0
  141. package/src/types/model-logical.ts +111 -0
  142. package/src/types/model-spec.ts +81 -0
  143. package/src/types/operators.ts +51 -52
  144. package/src/types/scalar.ts +114 -0
  145. package/src/types/styles.ts +123 -0
  146. package/src/types/view-changes.ts +4 -5
  147. package/src/types/view-common.ts +157 -0
  148. package/src/types/view-computed.ts +113 -0
  149. package/src/types/view-layouted.ts +82 -0
  150. package/src/types/view-parsed.deployment.ts +40 -0
  151. package/src/types/view-parsed.dynamic.ts +78 -0
  152. package/src/types/view-parsed.element.ts +65 -0
  153. package/src/types/view.ts +122 -542
  154. package/src/utils/compare-natural.ts +43 -1
  155. package/src/utils/getOrCreate.ts +0 -34
  156. package/src/utils/index.ts +7 -12
  157. package/src/utils/iterable/filter.ts +1 -1
  158. package/src/utils/iterable/find.ts +3 -1
  159. package/src/utils/iterable/head.ts +22 -0
  160. package/src/utils/iterable/index.ts +1 -0
  161. package/src/utils/iterable/map.ts +1 -1
  162. package/src/utils/iterable/reduce.ts +1 -1
  163. package/src/utils/iterable/some.ts +1 -1
  164. package/src/utils/memoize-prop.ts +30 -0
  165. package/src/utils/object-hash.ts +1 -1
  166. package/src/utils/relations.ts +14 -11
  167. package/src/utils/string-hash.ts +1 -1
  168. package/dist/shared/core.CZR9J1Qx.d.mts +0 -146
  169. package/dist/shared/core.CiFKryGW.d.mts +0 -745
  170. package/dist/shared/core.DJvmfnEi.d.mts +0 -1153
  171. package/dist/shared/core.DgfwjBtu.mjs +0 -495
  172. package/dist/shared/core.SjLhMA7a.d.mts +0 -62
  173. package/src/builder/__snapshots__/Builder.spec.ts.snap +0 -374
  174. package/src/compute-view/element-view/predicates.ts +0 -520
  175. package/src/compute-view/utils/uniqueTags.ts +0 -21
  176. package/src/types/deployments.ts +0 -170
  177. package/src/types/element.ts +0 -109
  178. package/src/types/expression-v2-model.ts +0 -314
  179. package/src/types/expression-v2.ts +0 -392
  180. package/src/types/overview-graph.ts +0 -43
  181. package/src/types/relation.ts +0 -61
  182. package/src/types/scalars.ts +0 -39
  183. package/src/types/theme.ts +0 -82
  184. package/src/types/view-notation.ts +0 -9
  185. package/src/utils/graphlib.ts +0 -10
  186. /package/src/{errors/index.ts → utils/invariant.ts} +0 -0
@@ -1,9 +1,13 @@
1
- import { a as i, l, d, L as LikeC4Model } from '../shared/core.CAcZ6_cP.mjs';
2
- import { m, l as l$1, i as i$1 } from '../shared/core.Cu-UdkSl.mjs';
3
- import { f as t, n as nameFromFqn, g as isSameHierarchy, p as parentFqn, h as t$1 } from '../shared/core.CQXU9DF7.mjs';
4
- import { o, M as ModelLayer, D as DefaultElementShape, b as DefaultThemeColor, n as n$1, c as DeploymentElement, d as isScopedElementView } from '../shared/core.DgfwjBtu.mjs';
1
+ import { i, l, d, c as computeLikeC4Model } from '../shared/core.CBpKAlhj.mjs';
2
+ import { m, i as i$1 } from '../shared/core.DoK86JEe.mjs';
3
+ import { _ as _type, D as DefaultElementShape, a as DefaultThemeColor, n as n$1, b as _stage, i as isDeployedInstance, F as FqnRef } from '../shared/core.CUYDgv2-.mjs';
4
+ import { n as nameFromFqn, d as isSameHierarchy, p as parentFqn, t as t$2 } from '../shared/core.rmvsy0n3.mjs';
5
+ import { l as l$1 } from '../shared/core.CpXlRyE5.mjs';
5
6
  import { u } from '../shared/core.DbRvwARP.mjs';
6
- import { i as invariant } from '../shared/core.C-YXI-43.mjs';
7
+ import { t as t$1 } from '../shared/core.cbA9VZ02.mjs';
8
+ import { t, i as invariant } from '../shared/core.Cy9smucx.mjs';
9
+ import { o, M as ModelFqnExpr, a as isElementView } from '../shared/core.Bk7wEZFG.mjs';
10
+ import '../shared/core.BrCnZFTn.mjs';
7
11
 
8
12
  function n(...r){return u(Object.fromEntries,r)}
9
13
 
@@ -93,12 +97,16 @@ function parseWhere(where) {
93
97
  };
94
98
  case op.startsWith("source."):
95
99
  return {
96
- operator: parseWhere(op.replace("source.", "")),
100
+ operator: parseWhere(
101
+ op.replace("source.", "")
102
+ ),
97
103
  participant: "source"
98
104
  };
99
105
  case op.startsWith("target."):
100
106
  return {
101
- operator: parseWhere(op.replace("target.", "")),
107
+ operator: parseWhere(
108
+ op.replace("target.", "")
109
+ ),
102
110
  participant: "target"
103
111
  };
104
112
  default:
@@ -137,7 +145,7 @@ function $include(...args) {
137
145
  }
138
146
  const custom = args[1].with;
139
147
  if (custom) {
140
- const isElement = ModelLayer.FqnExpr.is(expr);
148
+ const isElement = ModelFqnExpr.is(expr);
141
149
  if (isElement) {
142
150
  expr = {
143
151
  custom: {
@@ -335,7 +343,7 @@ function $expr(expr) {
335
343
 
336
344
  function mkViewBuilder(view) {
337
345
  const viewBuilder = {
338
- $expr: view.__ === "deployment" ? $deploymentExpr : $expr,
346
+ $expr: view[_type] === "deployment" ? $deploymentExpr : $expr,
339
347
  autoLayout(autoLayout) {
340
348
  view.rules.push({
341
349
  direction: autoLayout
@@ -370,23 +378,52 @@ function mkViewBuilder(view) {
370
378
  return viewBuilder;
371
379
  }
372
380
 
381
+ function validateSpec(specification) {
382
+ for (const [kind, spec] of t$1(specification.elements)) {
383
+ if (spec.tags) {
384
+ for (const tag of spec.tags) {
385
+ invariant(specification.tags?.[tag], `Invalid specification for element kind "${kind}": tag "${tag}" not found`);
386
+ }
387
+ }
388
+ }
389
+ if (specification.deployments) {
390
+ for (const [kind, spec] of t$1(specification.deployments)) {
391
+ if (spec.tags) {
392
+ for (const tag of spec.tags) {
393
+ invariant(
394
+ specification.tags?.[tag],
395
+ `Invalid specification for deployment kind "${kind}": tag "${tag}" not found`
396
+ );
397
+ }
398
+ }
399
+ }
400
+ }
401
+ }
373
402
  function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _views = /* @__PURE__ */ new Map(), _globals = {
374
403
  predicates: {},
375
404
  dynamicPredicates: {},
376
405
  styles: {}
377
406
  }, _deployments = /* @__PURE__ */ new Map(), _deploymentRelations = []) {
378
- const toLikeC4Specification = () => ({
379
- elements: {
380
- ...structuredClone(spec.elements)
381
- },
382
- deployments: {
383
- ...structuredClone(spec.deployments)
384
- },
385
- relationships: {
386
- ...structuredClone(spec.relationships)
387
- },
388
- tags: spec.tags ?? []
389
- });
407
+ const toLikeC4Specification = () => {
408
+ validateSpec(spec);
409
+ return {
410
+ elements: {
411
+ ...structuredClone(spec.elements)
412
+ },
413
+ deployments: {
414
+ ...structuredClone(spec.deployments)
415
+ },
416
+ relationships: {
417
+ ...structuredClone(spec.relationships)
418
+ },
419
+ tags: i(spec.tags ?? {}, (tagSpec) => ({
420
+ color: DefaultThemeColor,
421
+ ...tagSpec
422
+ })),
423
+ ...!!spec.metadataKeys ? { metadataKeys: spec.metadataKeys } : {},
424
+ customColors: {}
425
+ };
426
+ };
390
427
  const mapLinks = (links) => {
391
428
  if (!links || !i$1(links, 1)) {
392
429
  return null;
@@ -394,7 +431,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
394
431
  return m(links, (l) => typeof l === "string" ? { url: l } : l);
395
432
  };
396
433
  const createGenericView = (id, _props, builder2) => {
397
- if (t$1(_props)) {
434
+ if (t$2(_props)) {
398
435
  builder2 = _props;
399
436
  _props = {};
400
437
  }
@@ -403,7 +440,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
403
440
  links: _links = [],
404
441
  title = null,
405
442
  description = null,
406
- tags = null,
443
+ tags = [],
407
444
  ...props
408
445
  } = typeof _props === "string" ? { title: _props } : { ..._props };
409
446
  const links = mapLinks(_links);
@@ -413,7 +450,8 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
413
450
  description,
414
451
  tags,
415
452
  links,
416
- customColorDefinitions: {},
453
+ _stage: "parsed",
454
+ // customColorDefinitions: {},
417
455
  ...props
418
456
  }, builder2];
419
457
  };
@@ -447,9 +485,9 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
447
485
  return self;
448
486
  },
449
487
  __addRelation(relation) {
450
- const sourceEl = _elements.get(relation.source);
488
+ const sourceEl = _elements.get(FqnRef.flatten(relation.source));
451
489
  invariant(sourceEl, `Element with id "${relation.source}" not found`);
452
- const targetEl = _elements.get(relation.target);
490
+ const targetEl = _elements.get(FqnRef.flatten(relation.target));
453
491
  invariant(targetEl, `Element with id "${relation.target}" not found`);
454
492
  invariant(
455
493
  !isSameHierarchy(sourceEl, targetEl),
@@ -461,13 +499,14 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
461
499
  });
462
500
  return self;
463
501
  },
464
- /**
465
- * Fully qualified name for nested elements
466
- */
467
502
  __fqn(id) {
468
503
  invariant(id.trim() !== "", "Id must be non-empty");
469
504
  return id;
470
505
  },
506
+ __deploymentFqn(id) {
507
+ invariant(id.trim() !== "", "Id must be non-empty");
508
+ return id;
509
+ },
471
510
  __addSourcelessRelation() {
472
511
  throw new Error("Can be called only in nested model");
473
512
  },
@@ -475,7 +514,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
475
514
  if (_views.has(view.id)) {
476
515
  throw new Error(`View with id "${view.id}" already exists`);
477
516
  }
478
- if (isScopedElementView(view)) {
517
+ if (isElementView(view) && "viewOf" in view) {
479
518
  invariant(
480
519
  _elements.get(view.viewOf),
481
520
  `Invalid scoped view ${view.id}, wlement with id "${view.viewOf}" not found`
@@ -495,7 +534,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
495
534
  `Parent element with id "${parent}" not found for node with id "${node.id}"`
496
535
  );
497
536
  }
498
- if (DeploymentElement.isInstance(node)) {
537
+ if (isDeployedInstance(node)) {
499
538
  invariant(parent, `Instance ${node.id} of ${node.element} must be deployed under a parent node`);
500
539
  invariant(
501
540
  _elements.get(node.element),
@@ -507,16 +546,16 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
507
546
  },
508
547
  __addDeploymentRelation: (relation) => {
509
548
  invariant(
510
- !isSameHierarchy(relation.source.id, relation.target.id),
549
+ !isSameHierarchy(relation.source.deployment, relation.target.deployment),
511
550
  "Cannot create relationship between elements in the same hierarchy"
512
551
  );
513
552
  invariant(
514
- _deployments.has(relation.source.id),
515
- `Relation "${relation.source.id} -> ${relation.target.id}" references non-existing source`
553
+ _deployments.has(relation.source.deployment),
554
+ `Relation "${relation.source.deployment} -> ${relation.target.deployment}" references non-existing source`
516
555
  );
517
556
  invariant(
518
- _deployments.has(relation.target.id),
519
- `Relation "${relation.source.id} -> ${relation.target.id}" references non-existing target`
557
+ _deployments.has(relation.target.deployment),
558
+ `Relation "${relation.source.deployment} -> ${relation.target.deployment}" references non-existing target`
520
559
  );
521
560
  _deploymentRelations.push({
522
561
  id: `deploy_rel${_deploymentRelations.length + 1}`,
@@ -525,6 +564,8 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
525
564
  return self;
526
565
  },
527
566
  build: () => ({
567
+ [_stage]: "parsed",
568
+ projectId: "from-builder",
528
569
  specification: toLikeC4Specification(),
529
570
  elements: n(
530
571
  structuredClone(
@@ -550,7 +591,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
550
591
  }),
551
592
  toLikeC4Model: () => {
552
593
  const parsed = self.build();
553
- return LikeC4Model.compute(parsed);
594
+ return computeLikeC4Model(parsed);
554
595
  },
555
596
  helpers: () => ({
556
597
  model: {
@@ -571,8 +612,12 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
571
612
  );
572
613
  const links = mapLinks(_links);
573
614
  b.__addRelation({
574
- source,
575
- target,
615
+ source: {
616
+ model: source
617
+ },
618
+ target: {
619
+ model: target
620
+ },
576
621
  title,
577
622
  ...links && { links },
578
623
  ...props
@@ -592,7 +637,9 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
592
637
  );
593
638
  const links = mapLinks(_links);
594
639
  b.__addSourcelessRelation({
595
- target,
640
+ target: {
641
+ model: target
642
+ },
596
643
  title,
597
644
  ...links && { links },
598
645
  ...props
@@ -620,7 +667,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
620
667
  title: title ?? nameFromFqn(_id),
621
668
  description: null,
622
669
  technology: null,
623
- tags: null,
670
+ tags: [],
624
671
  color: specStyle?.color ?? DefaultThemeColor,
625
672
  shape: specStyle?.shape ?? DefaultElementShape,
626
673
  style: d({
@@ -646,7 +693,9 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
646
693
  b.__addSourcelessRelation = (relation) => {
647
694
  return b.__addRelation({
648
695
  ...relation,
649
- source: __fqn(id)
696
+ source: {
697
+ model: __fqn(id)
698
+ }
650
699
  });
651
700
  };
652
701
  ops.reduce((b2, op) => op(b2), b);
@@ -670,7 +719,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
670
719
  const [generic, builder2] = createGenericView(id, _props, _builder);
671
720
  const view = {
672
721
  ...generic,
673
- __: "element",
722
+ [_type]: "element",
674
723
  rules: []
675
724
  };
676
725
  const add = (b) => {
@@ -695,7 +744,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
695
744
  const view = {
696
745
  ...generic,
697
746
  viewOf,
698
- __: "element",
747
+ [_type]: "element",
699
748
  rules: []
700
749
  };
701
750
  const add = (b) => {
@@ -719,7 +768,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
719
768
  const [generic, builder2] = createGenericView(id, _props, _builder);
720
769
  const view = {
721
770
  ...generic,
722
- __: "deployment",
771
+ [_type]: "deployment",
723
772
  rules: []
724
773
  };
725
774
  const add = (b) => {
@@ -768,7 +817,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
768
817
  title,
769
818
  ...props
770
819
  } = typeof _props === "string" ? { title: _props } : { ..._props };
771
- const _id = b.__fqn(id);
820
+ const _id = b.__deploymentFqn(id);
772
821
  invariant(_elements.has(target), `Target element with id "${target}" not found`);
773
822
  b.__addDeployment({
774
823
  id: _id,
@@ -783,18 +832,18 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
783
832
  rel: (source, target, _props) => {
784
833
  return (b) => {
785
834
  const {
786
- title,
835
+ title = null,
787
836
  links,
788
837
  ...props
789
838
  } = typeof _props === "string" ? { title: _props } : { ..._props };
790
839
  b.__addDeploymentRelation({
791
840
  source: {
792
- id: source
841
+ deployment: source
793
842
  },
794
843
  target: {
795
- id: target
844
+ deployment: target
796
845
  },
797
- ...title && { title },
846
+ title,
798
847
  ...links && { links: mapLinks(links) },
799
848
  ...props
800
849
  });
@@ -813,7 +862,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
813
862
  ...props
814
863
  } = typeof _props === "string" ? { title: _props } : { ..._props };
815
864
  const icon = _icon ?? specStyle?.icon;
816
- const _id = b.__fqn(id);
865
+ const _id = b.__deploymentFqn(id);
817
866
  b.__addDeployment({
818
867
  id: _id,
819
868
  kind,
@@ -821,18 +870,20 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
821
870
  description: null,
822
871
  technology: null,
823
872
  tags: null,
824
- color: specStyle?.color ?? DefaultThemeColor,
825
- shape: specStyle?.shape ?? DefaultElementShape,
826
- style: d({
827
- border: specStyle?.border,
828
- opacity: specStyle?.opacity,
829
- size: specStyle?.size,
830
- padding: specStyle?.padding,
831
- textSize: specStyle?.textSize,
832
- ...style
833
- }, l$1),
873
+ style: {
874
+ ...icon && { icon },
875
+ color: specStyle?.color ?? DefaultThemeColor,
876
+ shape: specStyle?.shape ?? DefaultElementShape,
877
+ ...d({
878
+ border: specStyle?.border,
879
+ opacity: specStyle?.opacity,
880
+ size: specStyle?.size,
881
+ padding: specStyle?.padding,
882
+ textSize: specStyle?.textSize,
883
+ ...style
884
+ }, l$1)
885
+ },
834
886
  ...links && { links: mapLinks(links) },
835
- ...icon && { icon },
836
887
  ...spec2,
837
888
  ...props
838
889
  });
@@ -840,12 +891,12 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
840
891
  };
841
892
  add.with = (...ops) => (b) => {
842
893
  add(b);
843
- const { __fqn } = b;
894
+ const { __deploymentFqn } = b;
844
895
  try {
845
- b.__fqn = (child) => `${__fqn(id)}.${child}`;
896
+ b.__deploymentFqn = (child) => `${__deploymentFqn(id)}.${child}`;
846
897
  ops.reduce((b2, op) => op(b2), b);
847
898
  } finally {
848
- b.__fqn = __fqn;
899
+ b.__deploymentFqn = __deploymentFqn;
849
900
  }
850
901
  return b;
851
902
  };
@@ -883,6 +934,7 @@ function builder(spec, _elements = /* @__PURE__ */ new Map(), _relations = [], _
883
934
  var Builder;
884
935
  ((Builder2) => {
885
936
  function forSpecification(spec) {
937
+ validateSpec(spec);
886
938
  const b = builder(spec);
887
939
  return {
888
940
  ...b.helpers(),
@@ -891,6 +943,7 @@ var Builder;
891
943
  }
892
944
  Builder2.forSpecification = forSpecification;
893
945
  function specification(spec) {
946
+ validateSpec(spec);
894
947
  return builder(spec);
895
948
  }
896
949
  Builder2.specification = specification;
@@ -1,22 +1,38 @@
1
- export { C as ComputeViewResult, c as computeView, a as computeViews, u as unsafeComputeView } from '../shared/core.CiFKryGW.mjs';
2
- import { L as LikeC4View, C as ComputedLikeC4ModelData, a as ComputedView } from '../shared/core.DJvmfnEi.mjs';
1
+ import { A as Any } from '../shared/core.BaYE_r29.mjs';
2
+ import { L as LikeC4Model } from '../shared/core.CCWXGc6G.mjs';
3
+ import { k as ParsedLikeC4ModelData, l as ComputedLikeC4ModelData, aF as ParsedView, aI as ComputedView } from '../shared/core.Dpq3P3YJ.mjs';
3
4
  import 'type-fest';
4
- import '../shared/core.SjLhMA7a.mjs';
5
+ import '../shared/core.BuO4ncfY.mjs';
6
+ import '../shared/core.CywrQs86.mjs';
7
+
8
+ type ComputeViewResult<V> = {
9
+ isSuccess: true;
10
+ error?: undefined;
11
+ view: V;
12
+ } | {
13
+ isSuccess: false;
14
+ error: Error;
15
+ view: undefined;
16
+ };
17
+ declare function unsafeComputeView<A extends Any>(viewsource: ParsedView<A>, likec4model: LikeC4Model<any>): ComputedView<A>;
18
+ declare function computeView<A extends Any>(viewsource: ParsedView<A>, likec4model: LikeC4Model<A>): ComputeViewResult<ComputedView<A>>;
19
+ declare function computeParsedModelData<A extends Any>(parsed: ParsedLikeC4ModelData<A>): ComputedLikeC4ModelData<A>;
20
+ declare function computeLikeC4Model<A extends Any>(parsed: ParsedLikeC4ModelData<A>): LikeC4Model.Computed<A>;
5
21
 
6
22
  /**
7
23
  * Resolve rules of extended views
8
24
  * (Removes invalid views)
9
25
  */
10
- declare function resolveRulesExtendedViews<V extends Record<any, LikeC4View>>(unresolvedViews: V): V;
26
+ declare function resolveRulesExtendedViews<A extends Any, V extends Record<any, ParsedView<A>>>(unresolvedViews: V): V;
11
27
 
12
28
  /**
13
29
  * Convert hashed edge ids to human-readable
14
30
  * Mostly for testing purposes
15
31
  */
16
- declare function withReadableEdges<T extends ComputedView>({ edges, nodes, ...view }: T, separator?: string): T & {
32
+ declare function withReadableEdges<V extends ComputedView<any>>({ edges, nodes, ...view }: V, separator?: string): V & {
17
33
  nodeIds: string[];
18
34
  edgeIds: string[];
19
35
  };
20
- declare function viewsWithReadableEdges<M extends ComputedLikeC4ModelData>({ views, ...model }: M): M;
36
+ declare function viewsWithReadableEdges<A extends Any>({ views, ...model }: ComputedLikeC4ModelData<A>): ComputedLikeC4ModelData<A>;
21
37
 
22
- export { resolveRulesExtendedViews, viewsWithReadableEdges, withReadableEdges };
38
+ export { type ComputeViewResult, computeLikeC4Model, computeParsedModelData, computeView, resolveRulesExtendedViews, unsafeComputeView, viewsWithReadableEdges, withReadableEdges };
@@ -1,9 +1,14 @@
1
- import { G as Graph, r, w as willCreateCycle, t as topologicalSortExports, i as i$1, a as i$2, l } from '../shared/core.CAcZ6_cP.mjs';
2
- export { c as computeView, b as computeViews, u as unsafeComputeView } from '../shared/core.CAcZ6_cP.mjs';
3
- import { i as isExtendsElementView, a as isElementView } from '../shared/core.DgfwjBtu.mjs';
4
- import { e as isNonEmptyArray } from '../shared/core.CQXU9DF7.mjs';
5
- import { i, m } from '../shared/core.Cu-UdkSl.mjs';
1
+ import { G as Graph, w as willCreateCycle, t as topologicalSortExports, i as i$2, l } from '../shared/core.CBpKAlhj.mjs';
2
+ export { c as computeLikeC4Model, a as computeParsedModelData, b as computeView, u as unsafeComputeView } from '../shared/core.CBpKAlhj.mjs';
3
+ import { r, i as i$1 } from '../shared/core.cbA9VZ02.mjs';
4
+ import { i as isExtendsElementView, a as isElementView } from '../shared/core.Bk7wEZFG.mjs';
5
+ import { c as isNonEmptyArray } from '../shared/core.rmvsy0n3.mjs';
6
+ import { i, m } from '../shared/core.DoK86JEe.mjs';
6
7
  import { u } from '../shared/core.DbRvwARP.mjs';
8
+ import '../shared/core.CpXlRyE5.mjs';
9
+ import '../shared/core.Cy9smucx.mjs';
10
+ import '../shared/core.CUYDgv2-.mjs';
11
+ import '../shared/core.BrCnZFTn.mjs';
7
12
 
8
13
  function y(...t){return u(f,t)}function f(t,e){if(!i(e,1))return {...t};if(!i(e,2)){let{[e[0]]:r,...m}=t;return m}let o={...t};for(let r of e)delete o[r];return o}
9
14
 
@@ -56,7 +61,7 @@ function resolveRulesExtendedViews(unresolvedViews) {
56
61
  ...view,
57
62
  title: view.title ?? extendsFrom.title ?? null,
58
63
  description: view.description ?? extendsFrom.description ?? null,
59
- tags: isNonEmptyArray(tags) ? tags : null,
64
+ tags,
60
65
  links: isNonEmptyArray(links) ? links : null,
61
66
  rules: [...extendsFrom.rules, ...view.rules]
62
67
  };
@@ -1,9 +1,11 @@
1
- import { A as AnyAux, E as ElementModel, R as RelationshipModel, L as LikeC4Model } from '../../shared/core.CiFKryGW.mjs';
1
+ import { A as Any, U as Unknown, g as ElementId, V as ViewId } from '../../shared/core.BaYE_r29.mjs';
2
+ import { E as ElementModel, R as RelationshipModel, L as LikeC4Model } from '../../shared/core.CCWXGc6G.mjs';
2
3
  import 'type-fest';
3
- import '../../shared/core.SjLhMA7a.mjs';
4
- import '../../shared/core.DJvmfnEi.mjs';
4
+ import '../../shared/core.BuO4ncfY.mjs';
5
+ import '../../shared/core.CywrQs86.mjs';
6
+ import '../../shared/core.Dpq3P3YJ.mjs';
5
7
 
6
- type RelationshipsViewData<M extends AnyAux = AnyAux> = {
8
+ type RelationshipsViewData<M extends Any = Unknown> = {
7
9
  incomers: ReadonlySet<ElementModel<M>>;
8
10
  incoming: ReadonlySet<RelationshipModel<M>>;
9
11
  subjects: ReadonlySet<ElementModel<M>>;
@@ -11,11 +13,11 @@ type RelationshipsViewData<M extends AnyAux = AnyAux> = {
11
13
  outgoers: ReadonlySet<ElementModel<M>>;
12
14
  };
13
15
 
14
- declare function computeRelationshipsView<const M extends AnyAux>(subjectId: NoInfer<M['Element']>, likec4model: LikeC4Model<M>, scopeViewId: NoInfer<M['View']> | null, scope?: 'global' | 'view'): RelationshipsViewData<M>;
16
+ declare function computeRelationshipsView<M extends Any>(subjectId: ElementId<M>, likec4model: LikeC4Model<M>, scopeViewId: ViewId<M> | null, scope?: 'global' | 'view'): RelationshipsViewData<M>;
15
17
 
16
- declare function treeFromElements<const M extends AnyAux>(elements: Iterable<ElementModel<M>>): {
18
+ declare function treeFromElements<M extends Any>(elements: Iterable<ElementModel<M>>): {
17
19
  sorted: readonly ElementModel<M>[];
18
- byId: (id: M["Element"]) => ElementModel<M>;
20
+ byId: (id: ElementId<M>) => ElementModel<M>;
19
21
  root: ReadonlySet<ElementModel<M>>;
20
22
  parent: (el: ElementModel<M>) => ElementModel<M> | null;
21
23
  children: (el: ElementModel<M>) => ReadonlyArray<ElementModel<M>>;
@@ -1,5 +1,6 @@
1
- import { s as sortParentsFirst, D as DefaultMap, i as isDescendantOf, a as isAncestor, t as toSet, b as toArray, c as ifilter, C, d as imap } from '../../shared/core.CQXU9DF7.mjs';
2
- import { n as nonNullable, i as invariant } from '../../shared/core.C-YXI-43.mjs';
1
+ import { s as sortParentsFirst, D as DefaultMap, i as isDescendantOf, a as isAncestor, b as ifilter, C } from '../../shared/core.rmvsy0n3.mjs';
2
+ import { n as nonNullable, i as invariant } from '../../shared/core.Cy9smucx.mjs';
3
+ import { t as toSet, a as toArray, i as imap } from '../../shared/core.BrCnZFTn.mjs';
3
4
 
4
5
  function treeFromElements(elements) {
5
6
  const sorted = sortParentsFirst([...elements]);
package/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- import { H as HexColorLiteral, T as ThemeColorValues, b as LikeC4Theme } from './shared/core.DJvmfnEi.mjs';
2
- export { ag as AbstractRelation, a1 as AllNever, a2 as AndOperator, O as AnyParsedLikeC4ModelData, aT as AutoLayoutDirection, aW as BBox, aU as BasicElementView, aV as BasicView, p as BorderStyle, B as BorderStyles, ap as Color, aq as ColorLiteral, aX as ComputedDeploymentView, aY as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, C as ComputedLikeC4ModelData, az as ComputedNode, a as ComputedView, a$ as CustomColorDefinitions, ad as DefaultArrowType, j as DefaultElementShape, ae as DefaultLineStyle, k as DefaultPaddingSize, af as DefaultRelationshipColor, l as DefaultShapeSize, m as DefaultTextSize, n as DefaultThemeColor, c as DeployedInstance, D as DeploymentElement, d as DeploymentElementStyle, e as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b0 as DeploymentView, b1 as DeploymentViewRule, b2 as DeploymentViewRulePredicate, b3 as DeploymentViewRuleStyle, b4 as DiagramEdge, aA as DiagramNode, b5 as DiagramView, b6 as DynamicView, b7 as DynamicViewIncludeRule, b8 as DynamicViewParallelSteps, b9 as DynamicViewRule, ba as DynamicViewStep, bb as DynamicViewStepOrParallel, bc as EdgeId, q as Element, E as ElementKind, r as ElementKindSpecification, s as ElementKindSpecificationStyle, bw as ElementNotation, t as ElementShape, o as ElementShapes, u as ElementStyle, as as ElementThemeColorValues, ar as ElementThemeColors, bd as ElementView, a3 as EqualOperator, y as ExpressionV2, be as ExtendsElementView, a4 as Filterable, F as FqnExpr, z as FqnRef, Q as GenericLikeC4ModelData, G as GlobalDynamicPredicates, A as GlobalPredicateId, I as GlobalPredicates, J as GlobalStyleID, K as GlobalStyles, a5 as KindEqual, S as LayoutedLikeC4ModelData, U as LikeC4ModelDump, L as LikeC4View, v as Link, N as ModelGlobals, M as ModelLayer, ah as ModelRelation, bf as NodeId, a6 as NotOperator, a7 as OperatorPredicate, a8 as OrOperator, V as ParsedLikeC4ModelData, a9 as Participant, aa as ParticipantOperator, P as PredicateSelector, R as RelationExpr, ai as RelationId, aj as RelationshipArrowType, ak as RelationshipKind, al as RelationshipKindSpecification, am as RelationshipLineType, au as RelationshipThemeColorValues, at as RelationshipThemeColors, bg as ScopedElementView, av as ShapeSize, aw as SpacingSize, bh as StepEdgeId, bi as StepEdgeIdLiteral, ab as TagEqual, w as TagSpec, ax as TextSize, ay as ThemeColor, ao as ThemeColors, x as TypedElement, bj as ViewAutoLayout, bk as ViewId, bl as ViewManualLayout, bm as ViewRule, bn as ViewRuleAutoLayout, bo as ViewRuleGlobalPredicateRef, bp as ViewRuleGlobalStyle, bq as ViewRuleGroup, br as ViewRulePredicate, bs as ViewRuleStyle, bt as ViewRuleStyleOrGlobalRef, bu as ViewWithHash, bv as ViewWithNotation, ac as WhereOperator, aB as extractStep, aC as getBBoxCenter, aD as getParallelStepsPrefix, W as isAndOperator, aE as isAutoLayoutDirection, aF as isDeploymentView, aG as isDynamicView, aH as isDynamicViewParallelSteps, aI as isElementView, aJ as isExtendsElementView, X as isKindEqual, Y as isNotOperator, Z as isOrOperator, _ as isParticipantOperator, aK as isScopedElementView, aL as isStepEdgeId, $ as isTagEqual, an as isThemeColor, aM as isViewRuleAutoLayout, aN as isViewRuleGlobalPredicateRef, aO as isViewRuleGlobalStyle, aP as isViewRuleGroup, aQ as isViewRulePredicate, aR as isViewRuleStyle, aS as stepEdgeId, a0 as whereOperatorAsPredicate } from './shared/core.DJvmfnEi.mjs';
3
- export { BiMap, DefaultMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareRelations, delay, difference, equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, imap, intersection, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, objectHash, stringHash, symmetricDifference, toArray, toSet, union } from './utils/index.mjs';
4
- export { A as AnyAux, b as Aux, C as ComputeViewResult, D as DeployedInstanceModel, d as DeploymentElementModel, e as DeploymentNodeModel, f as DeploymentRelationModel, g as EdgeModel, E as ElementModel, h as LikeC4DeploymentModel, L as LikeC4Model, i as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, c as computeView, a as computeViews, u as unsafeComputeView } from './shared/core.CiFKryGW.mjs';
5
- export { C as Connection, a as ConnectionModel, D as DeploymentConnectionModel } from './shared/core.CZR9J1Qx.mjs';
6
- export { A as AsFqn, C as CustomColor, E as ExclusiveUnion, F as Fqn, G as GlobalFqn, d as IconUrl, I as IteratorLike, K as KeysOf, b as NTuple, N as NonEmptyArray, a as NonEmptyReadonlyArray, P as Point, c as Predicate, e as ProjectId, T as Tag, X as XYPoint, i as isGlobalFqn, s as splitGlobalFqn } from './shared/core.SjLhMA7a.mjs';
7
- export { OverviewGraph, ViewChange } from './types/index.mjs';
8
- export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from './shared/core.D2830qgg.mjs';
1
+ import { C as ColorLiteral, T as ThemeColorValues, L as LikeC4Theme } from './shared/core.Dpq3P3YJ.mjs';
2
+ export { W as AbstractRelationship, ad as AndOperator, aY as AnyExcludePredicate, aX as AnyIncludePredicate, aK as AnyView, aZ as AnyViewRuleStyle, b2 as AutoLayoutDirection, y as AuxFromDump, A as AuxFromLikeC4ModelData, B as BBox, ba as BaseParsedViewProperties, b9 as BaseViewProperties, ap as BorderStyle, ao as BorderStyles, az as Color, bh as ComputedDeploymentView, bi as ComputedDynamicView, bf as ComputedEdge, bg as ComputedElementView, l as ComputedLikeC4ModelData, be as ComputedNode, aI as ComputedView, at as CustomColor, au as CustomColorDefinitions, U as DefaultArrowType, H as DefaultElementShape, Q as DefaultLineStyle, J as DefaultPaddingSize, V as DefaultRelationshipColor, I as DefaultShapeSize, K as DefaultTextSize, z as DefaultThemeColor, p as DeployedInstance, q as DeploymentElement, r as DeploymentElementRef, D as DeploymentElementStyle, o as DeploymentNode, v as DeploymentRelation, u as DeploymentRelationship, bp as DeploymentViewExcludePredicate, bo as DeploymentViewIncludePredicate, bq as DeploymentViewPredicate, bs as DeploymentViewRule, br as DeploymentViewRuleStyle, bk as DiagramEdge, bj as DiagramNode, aG as DiagramView, by as DynamicViewIncludeRule, bv as DynamicViewParallelSteps, bz as DynamicViewRule, bu as DynamicViewStep, bx as DynamicViewStepOrParallel, O as Element, ar as ElementShape, aq as ElementShapes, _ as ElementSpecification, N as ElementStyle, aB as ElementThemeColorValues, aC as ElementThemeColors, bD as ElementViewExcludePredicate, bC as ElementViewIncludePredicate, bE as ElementViewPredicate, bI as ElementViewRule, bF as ElementViewRuleGroup, bH as ElementViewRuleStyle, a3 as EqualOperator, E as Expression, ai as Filterable, F as FqnExpr, c as FqnRef, g as GlobalDynamicPredicates, G as GlobalPredicateId, f as GlobalPredicates, h as GlobalStyleID, i as GlobalStyles, as as HexColor, a6 as KindEqual, bm as LayoutedDeploymentView, bn as LayoutedDynamicView, bl as LayoutedElementView, m as LayoutedLikeC4ModelData, aG as LayoutedView, n as LikeC4ModelData, x as LikeC4ModelDump, aF as LikeC4View, b as ModelExpression, M as ModelFqnExpr, j as ModelGlobals, Z as ModelRelation, a as ModelRelationExpr, bb as NodeNotation, ab as NotOperator, aj as OperatorPredicate, af as OrOperator, bt as ParsedDeploymentView, bA as ParsedDynamicView, bJ as ParsedElementView, k as ParsedLikeC4ModelData, aF as ParsedView, a8 as Participant, a9 as ParticipantOperator, d as Point, P as PredicateSelector, aJ as ProcessedView, e as RectBox, R as RelationExpr, Y as Relationship, aw as RelationshipArrowType, av as RelationshipLineType, a1 as RelationshipSpecification, aD as RelationshipThemeColorValues, aE as RelationshipThemeColors, an as ShapeSize, al as SpacingSize, w as SpecTypesFromDump, a2 as Specification, S as SpecificationDump, a4 as TagEqual, $ as TagSpecification, am as TextSize, ay as ThemeColor, ax as ThemeColors, b6 as ViewAutoLayout, b7 as ViewManualLayout, aL as ViewOnStage, aN as ViewRule, b4 as ViewRuleAutoLayout, b0 as ViewRuleGlobalPredicateRef, a_ as ViewRuleGlobalStyle, aO as ViewRulePredicate, b8 as ViewType, bd as ViewWithHash, bc as ViewWithNotation, aM as ViewWithType, ah as WhereOperator, X as XYPoint, bw as getParallelStepsPrefix, ae as isAndOperator, b3 as isAutoLayoutDirection, aR as isComputedView, t as isDeployedInstance, s as isDeploymentNode, aV as isDeploymentView, aH as isDiagramView, aW as isDynamicView, bB as isDynamicViewParallelSteps, aS as isElementView, aU as isExtendsElementView, a7 as isKindEqual, aH as isLayoutedView, ac as isNotOperator, ag as isOrOperator, aa as isParticipantOperator, aT as isScopedElementView, a0 as isTagColorSpecified, a5 as isTagEqual, aA as isThemeColor, b5 as isViewRuleAutoLayout, b1 as isViewRuleGlobalPredicateRef, a$ as isViewRuleGlobalStyle, bG as isViewRuleGroup, aP as isViewRulePredicate, aQ as isViewRuleStyle, ak as whereOperatorAsPredicate } from './shared/core.Dpq3P3YJ.mjs';
3
+ export { BiMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareNaturalHierarchically, compareRelations, delay, difference, equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, ihead, imap, intersection, invariant, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, memoizeProp, nonNullable, nonexhaustive, objectHash, stringHash, symmetricDifference, toArray, toSet, union } from './utils/index.mjs';
4
+ export { D as DefaultMap } from './shared/core.CywrQs86.mjs';
5
+ export { A as Any, A as AnyAux, b as Aux, E as ExtractOnStage, M as ModelStage, S as SpecAux, U as Unknown, c as UnknownComputed, d as UnknownLayouted, e as UnknownParsed, _ as _stage, f as _type, a as aux, i as isOnStage } from './shared/core.BaYE_r29.mjs';
6
+ export { A as AnyFqn, B as BuiltInIcon, C as Coalesce, D as DeploymentFqn, b as DeploymentKind, E as EdgeId, a as ElementKind, f as ExclusiveUnion, F as Fqn, m as GlobalFqn, G as GroupElementKind, i as Icon, j as IconUrl, I as IteratorLike, K as KeysOf, L as Link, g as NTuple, N as NodeId, d as NonEmptyArray, e as NonEmptyReadonlyArray, h as Predicate, P as ProjectId, R as RelationId, l as RelationKind, c as RelationshipKind, p as StepEdgeId, S as StepEdgeIdLiteral, r as StepEdgeKind, T as Tag, V as ViewId, u as extractStep, n as isGlobalFqn, k as isGroupElementKind, t as isStepEdgeId, s as scalar, o as splitGlobalFqn, q as stepEdgeId } from './shared/core.BuO4ncfY.mjs';
7
+ export { ViewChange } from './types/index.mjs';
8
+ export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from './shared/core.Pf5I9o0e.mjs';
9
9
  import 'type-fest';
10
10
 
11
11
  declare const ElementColors: {
@@ -136,10 +136,6 @@ declare const RelationshipColors: {
136
136
  };
137
137
 
138
138
  declare const defaultTheme: LikeC4Theme;
139
- declare function computeColorValues(color: HexColorLiteral): ThemeColorValues;
139
+ declare function computeColorValues(color: ColorLiteral): ThemeColorValues;
140
140
 
141
- declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
142
- declare function invariant(condition: any, message?: string): asserts condition;
143
- declare function nonexhaustive(value: never): never;
144
-
145
- export { ElementColors, HexColorLiteral, LikeC4Theme, RelationshipColors, ThemeColorValues, computeColorValues, defaultTheme, invariant, nonNullable, nonexhaustive };
141
+ export { ColorLiteral, ElementColors, LikeC4Theme, RelationshipColors, ThemeColorValues, computeColorValues, defaultTheme };
package/dist/index.mjs CHANGED
@@ -1,10 +1,13 @@
1
- export { i as invariant, n as nonNullable, a as nonexhaustive } from './shared/core.C-YXI-43.mjs';
2
- export { C as Connection, e as ConnectionModel, D as DeployedInstanceModel, f as DeploymentConnectionModel, g as DeploymentNodeModel, h as DeploymentRelationModel, E as EdgeModel, j as ElementModel, k as LikeC4DeploymentModel, L as LikeC4Model, m as LikeC4ViewModel, N as NodeModel, R as RelationshipModel, c as computeView, b as computeViews, u as unsafeComputeView } from './shared/core.CAcZ6_cP.mjs';
3
- export { A as AsFqn, B as BorderStyles, C as ComputedNode, z as ComputedView, v as DefaultArrowType, D as DefaultElementShape, x as DefaultLineStyle, f as DefaultPaddingSize, y as DefaultRelationshipColor, g as DefaultShapeSize, h as DefaultTextSize, b as DefaultThemeColor, c as DeploymentElement, H as DiagramNode, E as ElementKind, j as ElementShapes, k as ExpressionV2, F as FqnExpr, l as FqnRef, G as GlobalFqn, M as ModelLayer, R as RelationExpr, I as extractStep, J as getBBoxCenter, K as getParallelStepsPrefix, m as isAndOperator, L as isAutoLayoutDirection, N as isDeploymentView, O as isDynamicView, P as isDynamicViewParallelSteps, a as isElementView, i as isExtendsElementView, e as isGlobalFqn, p as isKindEqual, q as isNotOperator, r as isOrOperator, t as isParticipantOperator, d as isScopedElementView, Q as isStepEdgeId, u as isTagEqual, S as isViewRuleAutoLayout, T as isViewRuleGlobalPredicateRef, U as isViewRuleGlobalStyle, V as isViewRuleGroup, W as isViewRulePredicate, X as isViewRuleStyle, s as splitGlobalFqn, Y as stepEdgeId, w as whereOperatorAsPredicate } from './shared/core.DgfwjBtu.mjs';
4
- export { ThemeColors, isThemeColor } from './types/index.mjs';
1
+ export { f as DefaultArrowType, D as DefaultElementShape, g as DefaultLineStyle, m as DefaultPaddingSize, h as DefaultRelationshipColor, l as DefaultShapeSize, p as DefaultTextSize, a as DefaultThemeColor, A as DeploymentFqn, H as EdgeId, z as Fqn, F as FqnRef, B as GlobalFqn, G as GroupElementKind, N as NodeId, R as RelationId, S as StepEdgeKind, V as ViewId, b as _stage, _ as _type, I as extractStep, v as isAndOperator, i as isDeployedInstance, k as isDeploymentNode, C as isGlobalFqn, e as isGroupElementKind, r as isKindEqual, u as isNotOperator, j as isOnStage, x as isOrOperator, t as isParticipantOperator, d as isStepEdgeId, q as isTagEqual, E as splitGlobalFqn, s as stepEdgeId, w as whereOperatorAsPredicate } from './shared/core.CUYDgv2-.mjs';
2
+ export { E as Expression, F as FqnExpr, k as ModelExpression, M as ModelFqnExpr, j as ModelRelationExpr, R as RelationExpr, s as getParallelStepsPrefix, r as isAutoLayoutDirection, n as isComputedView, m as isDeploymentView, p as isDiagramView, l as isDynamicView, h as isDynamicViewParallelSteps, a as isElementView, i as isExtendsElementView, p as isLayoutedView, q as isScopedElementView, d as isViewRuleAutoLayout, f as isViewRuleGlobalPredicateRef, g as isViewRuleGlobalStyle, e as isViewRuleGroup, c as isViewRulePredicate, b as isViewRuleStyle } from './shared/core.Bk7wEZFG.mjs';
3
+ export { BBox, BorderStyles, ElementShapes, RectBox, ThemeColors, isTagColorSpecified, isThemeColor } from './types/index.mjs';
5
4
  export { BiMap, DefaultWeakMap, LinkedList, MultiMap, Queue, compareRelations, delay, ireduce } from './utils/index.mjs';
6
- export { D as DefaultMap, l as ancestorsFqn, m as commonAncestor, o as compareByFqnHierarchically, q as compareFqnHierarchically, k as compareNatural, r as hierarchyDistance, u as hierarchyLevel, c as ifilter, d as imap, a as isAncestor, i as isDescendantOf, e as isNonEmptyArray, g as isSameHierarchy, x as isString, n as nameFromFqn, p as parentFqn, v as sortByFqnHierarchically, w as sortNaturalByFqn, s as sortParentsFirst, b as toArray, t as toSet } from './shared/core.CQXU9DF7.mjs';
7
- export { S as Stack, c as commonHead, h as difference, j as equalsSet, g as getOrCreate, i as hasAtLeast, a as ifind, b as iflat, k as intersection, d as isIterable, e as isome, f as iunique, o as objectHash, n as stringHash, s as symmetricDifference, u as union } from './shared/core.Cu-UdkSl.mjs';
5
+ export { D as DefaultMap, l as ancestorsFqn, k as commonAncestor, h as compareByFqnHierarchically, q as compareFqnHierarchically, m as compareNatural, o as compareNaturalHierarchically, r as hierarchyDistance, u as hierarchyLevel, b as ifilter, a as isAncestor, i as isDescendantOf, c as isNonEmptyArray, d as isSameHierarchy, w as isString, n as nameFromFqn, p as parentFqn, j as sortByFqnHierarchically, v as sortNaturalByFqn, s as sortParentsFirst } from './shared/core.rmvsy0n3.mjs';
6
+ export { S as Stack, c as commonHead, e as iflat, i as isIterable, b as iunique, o as objectHash } from './shared/core.CpXlRyE5.mjs';
7
+ export { i as invariant, n as nonNullable, a as nonexhaustive } from './shared/core.Cy9smucx.mjs';
8
+ export { d as difference, j as equalsSet, g as getOrCreate, i as hasAtLeast, c as ifind, e as ihead, a as intersection, b as isome, f as memoizeProp, k as stringHash, s as symmetricDifference, u as union } from './shared/core.DoK86JEe.mjs';
9
+ export { i as imap, a as toArray, t as toSet } from './shared/core.BrCnZFTn.mjs';
10
+ import './shared/core.DbRvwARP.mjs';
8
11
 
9
12
  const { min: min$4, max: max$4 } = Math;
10
13
 
@@ -3488,6 +3491,7 @@ function generateColorsMap(color) {
3488
3491
  const saturationDelta = SATURATION_MAP[i] - SATURATION_MAP[baseColorIndex];
3489
3492
  return saturationDelta >= 0 ? c.saturate(saturationDelta) : c.desaturate(saturationDelta * -1);
3490
3493
  });
3494
+ colors[baseColorIndex] = chroma(color);
3491
3495
  return { baseColorIndex, colors };
3492
3496
  }
3493
3497
  function generateColors(color) {