@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,11 +1,9 @@
1
- import { i as invariant } from './core.C-YXI-43.mjs';
1
+ import { t as t$1, i as invariant } from './core.Cy9smucx.mjs';
2
2
 
3
3
  var e={done:true,hasNext:false},s={done:false,hasNext:false},a=()=>e;
4
4
 
5
5
  function C(t,...o){let n=t,u=o.map(e=>"lazy"in e?y(e):void 0),p=0;for(;p<o.length;){if(u[p]===void 0||!B(n)){let i=o[p];n=i(n),p+=1;continue}let r=[];for(let i=p;i<o.length;i++){let l=u[i];if(l===void 0||(r.push(l),l.isSingle))break}let a=[];for(let i of n)if(f(i,a,r))break;let{isSingle:s}=r.at(-1);n=s?a[0]:a,p+=r.length;}return n}function f(t,o,n){if(n.length===0)return o.push(t),false;let u=t,p=s,e=false;for(let[r,a]of n.entries()){let{index:s,items:i}=a;if(i.push(u),p=a(u,s,i),a.index+=1,p.hasNext){if(p.hasMany??false){for(let l of p.next)if(f(l,o,n.slice(r+1)))return true;return e}u=p.next;}if(!p.hasNext)break;p.done&&(e=true);}return p.hasNext&&o.push(u),e}function y(t){let{lazy:o,lazyArgs:n}=t,u=o(...n);return Object.assign(u,{isSingle:o.single??false,index:0,items:[]})}function B(t){return typeof t=="string"||typeof t=="object"&&t!==null&&Symbol.iterator in t}
6
6
 
7
- function t$1(r){return typeof r=="string"}
8
-
9
7
  function t(n){return typeof n=="function"}
10
8
 
11
9
  function getDefaultExportFromCjs (x) {
@@ -263,6 +261,27 @@ function compareNatural(a, b) {
263
261
  }
264
262
  return t$1(b) ? -1 : 0;
265
263
  }
264
+ function compareNaturalHierarchically(separator = ".") {
265
+ return (a, b) => {
266
+ if (a === b) return 0;
267
+ if (!a) return -1;
268
+ if (!b) return 1;
269
+ const aParts = a.split(separator);
270
+ const bParts = b.split(separator);
271
+ if (aParts.length !== bParts.length) {
272
+ return aParts.length - bParts.length;
273
+ }
274
+ for (let i = 0; i < aParts.length; i++) {
275
+ const aPart = aParts[i];
276
+ const bPart = bParts[i];
277
+ const comparison = compare(aPart, bPart);
278
+ if (comparison !== 0) {
279
+ return comparison;
280
+ }
281
+ }
282
+ return 0;
283
+ };
284
+ }
266
285
 
267
286
  function isString(value) {
268
287
  return value != null && typeof value === "string";
@@ -446,32 +465,4 @@ function ifilter(arg1, arg2) {
446
465
  return _filter(arg1);
447
466
  }
448
467
 
449
- function imap(arg1, arg2) {
450
- const mapper = arg2 ?? arg1;
451
- invariant(t(mapper));
452
- function* _map(iter) {
453
- for (const value of iter) {
454
- yield mapper(value);
455
- }
456
- return;
457
- }
458
- if (!arg2) {
459
- return _map;
460
- }
461
- return _map(arg1);
462
- }
463
-
464
- function toArray(iterable) {
465
- if (iterable) {
466
- return Array.from(iterable);
467
- }
468
- return (it) => Array.from(it);
469
- }
470
- function toSet(iterable) {
471
- if (iterable) {
472
- return new Set(iterable);
473
- }
474
- return (it) => new Set(it);
475
- }
476
-
477
- export { C, DefaultMap as D, isAncestor as a, toArray as b, ifilter as c, imap as d, isNonEmptyArray as e, t$1 as f, isSameHierarchy as g, t as h, isDescendantOf as i, getDefaultExportFromCjs as j, compareNatural as k, ancestorsFqn as l, commonAncestor as m, nameFromFqn as n, compareByFqnHierarchically as o, parentFqn as p, compareFqnHierarchically as q, hierarchyDistance as r, sortParentsFirst as s, toSet as t, hierarchyLevel as u, sortByFqnHierarchically as v, sortNaturalByFqn as w, isString as x, s as y, a as z };
468
+ export { C, DefaultMap as D, isAncestor as a, ifilter as b, isNonEmptyArray as c, isSameHierarchy as d, a as e, s as f, getDefaultExportFromCjs as g, compareByFqnHierarchically as h, isDescendantOf as i, sortByFqnHierarchically as j, commonAncestor as k, ancestorsFqn as l, compareNatural as m, nameFromFqn as n, compareNaturalHierarchically as o, parentFqn as p, compareFqnHierarchically as q, hierarchyDistance as r, sortParentsFirst as s, t, hierarchyLevel as u, sortNaturalByFqn as v, isString as w };
@@ -0,0 +1,3 @@
1
+ import 'type-fest';
2
+ import '../shared/core.BuO4ncfY.mjs';
3
+ export { y as AllKinds, A as Any, A as AnyAux, C as AnySpec, b as Aux, q as DeploymentFqn, u as DeploymentId, D as DeploymentKind, h as EdgeId, g as ElementId, l as ElementKind, F as Fqn, p as LooseDeploymentId, a3 as LooseDeploymentKind, o as LooseElementId, a2 as LooseElementKind, a4 as LooseRelationKind, L as LooseTag, a1 as LooseTags, x as LooseViewId, j as Metadata, k as MetadataKey, N as Never, I as NodeId, a0 as OrString, G as PickByStage, P as ProjectId, m as RelationId, R as RelationKind, J as Spec, S as SpecAux, s as Stage, q as StrictDeploymentFqn, X as StrictDeploymentKind, Q as StrictElementKind, F as StrictFqn, K as StrictProjectId, Y as StrictRelationKind, O as StrictTag, n as StrictViewId, v as Tag, T as Tags, U as Unknown, c as UnknownComputed, d as UnknownLayouted, e as UnknownParsed, V as ViewId, $ as WithLinks, B as WithMetadata, z as WithOptionalLinks, W as WithOptionalTags, Z as WithTags, H as setStage, t as toComputed, r as toLayouted, w as toParsed } from '../shared/core.BaYE_r29.mjs';
@@ -0,0 +1 @@
1
+
@@ -1,48 +1,10 @@
1
- import { X as XYPoint, N as NonEmptyArray, P as Point, F as Fqn } from '../shared/core.SjLhMA7a.mjs';
2
- export { A as AsFqn, C as CustomColor, E as ExclusiveUnion, G as GlobalFqn, d as IconUrl, I as IteratorLike, K as KeysOf, b as NTuple, a as NonEmptyReadonlyArray, c as Predicate, e as ProjectId, T as Tag, i as isGlobalFqn, s as splitGlobalFqn } from '../shared/core.SjLhMA7a.mjs';
3
- import { bk as ViewId, aW as BBox, p as BorderStyle, t as ElementShape, ay as ThemeColor, bl as ViewManualLayout, aT as AutoLayoutDirection } from '../shared/core.DJvmfnEi.mjs';
4
- export { ag as AbstractRelation, a1 as AllNever, a2 as AndOperator, O as AnyParsedLikeC4ModelData, aU as BasicElementView, aV as BasicView, 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, 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, H as HexColorLiteral, a5 as KindEqual, S as LayoutedLikeC4ModelData, U as LikeC4ModelDump, b as LikeC4Theme, 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, T as ThemeColorValues, ao as ThemeColors, x as TypedElement, bj as ViewAutoLayout, 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';
1
+ import { d as NonEmptyArray, F as Fqn, D as DeploymentFqn } from '../shared/core.BuO4ncfY.mjs';
2
+ export { A as AnyFqn, B as BuiltInIcon, C as Coalesce, b as DeploymentKind, E as EdgeId, a as ElementKind, f as ExclusiveUnion, 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, 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';
3
+ 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';
4
+ import { ap as BorderStyle, ar as ElementShape, ay as ThemeColor, b7 as ViewManualLayout, b2 as AutoLayoutDirection } from '../shared/core.Dpq3P3YJ.mjs';
5
+ export { W as AbstractRelationship, ad as AndOperator, aY as AnyExcludePredicate, aX as AnyIncludePredicate, aK as AnyView, aZ as AnyViewRuleStyle, y as AuxFromDump, A as AuxFromLikeC4ModelData, B as BBox, ba as BaseParsedViewProperties, b9 as BaseViewProperties, ao as BorderStyles, az as Color, C as ColorLiteral, 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, 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, L as LikeC4Theme, 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, T as ThemeColorValues, ax as ThemeColors, b6 as ViewAutoLayout, 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';
5
6
  import 'type-fest';
6
7
 
7
- /**
8
- * OverviewGraph is a graph representation of all views in a model
9
- */
10
- declare namespace OverviewGraph {
11
- type Node = {
12
- id: string;
13
- type: 'folder' | 'file';
14
- path: string;
15
- label: string;
16
- parentId: string | null;
17
- position: XYPoint;
18
- width: number;
19
- height: number;
20
- } | {
21
- id: string;
22
- type: 'view';
23
- viewId: ViewId;
24
- label: string;
25
- parentId: string | null;
26
- position: XYPoint;
27
- width: number;
28
- height: number;
29
- };
30
- /**
31
- * Edge represents a navigational link from one view to another
32
- */
33
- type Edge = {
34
- id: string;
35
- source: string;
36
- target: string;
37
- points: NonEmptyArray<Point>;
38
- };
39
- }
40
- interface OverviewGraph {
41
- nodes: OverviewGraph.Node[];
42
- edges: OverviewGraph.Edge[];
43
- bounds: BBox;
44
- }
45
-
46
8
  declare namespace ViewChange {
47
9
  interface ChangeElementStyle {
48
10
  op: 'change-element-style';
@@ -52,7 +14,7 @@ declare namespace ViewChange {
52
14
  shape?: ElementShape;
53
15
  color?: ThemeColor;
54
16
  };
55
- targets: NonEmptyArray<Fqn>;
17
+ targets: NonEmptyArray<Fqn | DeploymentFqn>;
56
18
  }
57
19
  interface SaveManualLayout {
58
20
  op: 'save-manual-layout';
@@ -69,4 +31,4 @@ declare namespace ViewChange {
69
31
  }
70
32
  type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
71
33
 
72
- export { AutoLayoutDirection, BBox, BorderStyle, ElementShape, Fqn, NonEmptyArray, OverviewGraph, Point, ThemeColor, ViewChange, ViewId, ViewManualLayout, XYPoint };
34
+ export { AutoLayoutDirection, BorderStyle, DeploymentFqn, ElementShape, Fqn, NonEmptyArray, ThemeColor, ViewChange, ViewManualLayout };
@@ -1,5 +1,132 @@
1
- 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';
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
+ import { i as invariant } from '../shared/core.Cy9smucx.mjs';
4
+ import '../shared/core.DbRvwARP.mjs';
2
5
 
6
+ var BBox;
7
+ ((BBox2) => {
8
+ function center({ x, y, width, height }) {
9
+ return {
10
+ x: x + width / 2,
11
+ y: y + height / 2
12
+ };
13
+ }
14
+ BBox2.center = center;
15
+ function fromPoints(points) {
16
+ const { x1, y1, x2, y2 } = RectBox.fromPoints(points);
17
+ return {
18
+ x: x1,
19
+ y: y1,
20
+ width: x2 - x1,
21
+ height: y2 - y1
22
+ };
23
+ }
24
+ BBox2.fromPoints = fromPoints;
25
+ function merge(...boxes) {
26
+ invariant(boxes.length > 0, "No boxes provided");
27
+ let minX = Infinity;
28
+ let minY = Infinity;
29
+ let maxX = -Infinity;
30
+ let maxY = -Infinity;
31
+ for (const box of boxes) {
32
+ minX = Math.min(minX, box.x);
33
+ minY = Math.min(minY, box.y);
34
+ maxX = Math.max(maxX, box.x + box.width);
35
+ maxY = Math.max(maxY, box.y + box.height);
36
+ }
37
+ return {
38
+ x: minX,
39
+ y: minY,
40
+ width: maxX - minX,
41
+ height: maxY - minY
42
+ };
43
+ }
44
+ BBox2.merge = merge;
45
+ function toRectBox(box) {
46
+ return {
47
+ x1: box.x,
48
+ y1: box.y,
49
+ x2: box.x + box.width,
50
+ y2: box.y + box.height
51
+ };
52
+ }
53
+ BBox2.toRectBox = toRectBox;
54
+ })(BBox || (BBox = {}));
55
+ var RectBox;
56
+ ((RectBox2) => {
57
+ function center({ x1, y1, x2, y2 }) {
58
+ return {
59
+ x: (x1 + x2) / 2,
60
+ y: (y1 + y2) / 2
61
+ };
62
+ }
63
+ RectBox2.center = center;
64
+ function fromPoints(points) {
65
+ invariant(points.length > 0, "At least one point is required");
66
+ let minX = Infinity;
67
+ let minY = Infinity;
68
+ let maxX = -Infinity;
69
+ let maxY = -Infinity;
70
+ for (const [x, y] of points) {
71
+ minX = Math.min(minX, x);
72
+ minY = Math.min(minY, y);
73
+ maxX = Math.max(maxX, x);
74
+ maxY = Math.max(maxY, y);
75
+ }
76
+ return {
77
+ x1: minX,
78
+ y1: minY,
79
+ x2: maxX,
80
+ y2: maxY
81
+ };
82
+ }
83
+ RectBox2.fromPoints = fromPoints;
84
+ function merge(...boxes) {
85
+ invariant(boxes.length > 0, "No boxes provided");
86
+ let minX = Infinity;
87
+ let minY = Infinity;
88
+ let maxX = -Infinity;
89
+ let maxY = -Infinity;
90
+ for (const box of boxes) {
91
+ minX = Math.min(minX, box.x1);
92
+ minY = Math.min(minY, box.y1);
93
+ maxX = Math.max(maxX, box.x2);
94
+ maxY = Math.max(maxY, box.y2);
95
+ }
96
+ return {
97
+ x1: minX,
98
+ y1: minY,
99
+ x2: maxX,
100
+ y2: maxY
101
+ };
102
+ }
103
+ RectBox2.merge = merge;
104
+ function toBBox(box) {
105
+ return {
106
+ x: box.x1,
107
+ y: box.y1,
108
+ width: box.x2 - box.x1,
109
+ height: box.y2 - box.y1
110
+ };
111
+ }
112
+ RectBox2.toBBox = toBBox;
113
+ })(RectBox || (RectBox = {}));
114
+
115
+ function isTagColorSpecified(spec) {
116
+ const color = typeof spec === "string" ? spec : spec.color;
117
+ return color.startsWith("#") || color.startsWith("rgb");
118
+ }
119
+
120
+ const BorderStyles = ["solid", "dashed", "dotted", "none"];
121
+ const ElementShapes = [
122
+ "rectangle",
123
+ "person",
124
+ "browser",
125
+ "mobile",
126
+ "cylinder",
127
+ "storage",
128
+ "queue"
129
+ ];
3
130
  const ThemeColors = [
4
131
  "amber",
5
132
  "blue",
@@ -14,7 +141,7 @@ const ThemeColors = [
14
141
  "sky"
15
142
  ];
16
143
  function isThemeColor(color) {
17
- return color in ThemeColors;
144
+ return ThemeColors.includes(color);
18
145
  }
19
146
 
20
- export { ThemeColors, isThemeColor };
147
+ export { BBox, BorderStyles, ElementShapes, RectBox, ThemeColors, isTagColorSpecified, isThemeColor };
@@ -1,36 +1,7 @@
1
- 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';
2
- import { N as NonEmptyArray, I as IteratorLike } from '../shared/core.SjLhMA7a.mjs';
3
- import { IsNumericLiteral } from 'type-fest';
4
-
5
- /**
6
- * Mnemonist DefaultMap Typings
7
- * =============================
8
- */
9
- declare class DefaultMap<K, V> implements Iterable<[K, V]> {
10
-
11
- // Members
12
- size: number;
13
-
14
- // Constructor
15
- constructor(factory: (key: K, index: number) => V);
16
-
17
- // Methods
18
- clear(): void;
19
- set(key: K, value: V): this;
20
- delete(key: K): boolean;
21
- has(key: K): boolean;
22
- get(key: K): V;
23
- peek(key: K): V | undefined;
24
- forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void;
25
- keys(): IterableIterator<K>;
26
- values(): IterableIterator<V>;
27
- entries(): IterableIterator<[K, V]>;
28
- [Symbol.iterator](): IterableIterator<[K, V]>;
29
- inspect(): any;
30
-
31
- // Statics
32
- static autoIncrement(): number;
33
- }
1
+ export { D as DefaultMap } from '../shared/core.CywrQs86.mjs';
2
+ 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';
3
+ import { d as NonEmptyArray, I as IteratorLike } from '../shared/core.BuO4ncfY.mjs';
4
+ import { Tagged, Simplify, Or, IfNever, IsLiteral, And, GreaterThan, IsNever, IsEqual, ReadonlyTuple, IsNumericLiteral } from 'type-fest';
34
5
 
35
6
  /**
36
7
  * Mnemonist DefaultWeakMap Typings
@@ -245,6 +216,10 @@ declare class BiMap<K, V> implements Iterable<[K, V]> {
245
216
  static from<I, J>(iterable: Iterable<[I, J]> | {[key: string]: J}): BiMap<I, J>;
246
217
  }
247
218
 
219
+ declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
220
+ declare function invariant(condition: any, message?: string): asserts condition;
221
+ declare function nonexhaustive(value: never): never;
222
+
248
223
  /**
249
224
  * Common head of two arrays
250
225
  *
@@ -253,6 +228,26 @@ declare class BiMap<K, V> implements Iterable<[K, V]> {
253
228
  declare function commonHead<T>(sources: ReadonlyArray<T>, targets: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): T[];
254
229
 
255
230
  declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
231
+ /**
232
+ * Compares two strings hierarchically based on their depth.
233
+ * From parent nodes to leaves
234
+ *
235
+ * @example
236
+ * const lines = [
237
+ * 'a.b.c',
238
+ * 'a',
239
+ * 'a.b',
240
+ * 'a.c.c',
241
+ * ]
242
+ * lines.sort(compareNaturalHierarchically('.'))
243
+ * // [
244
+ * // 'a',
245
+ * // 'a.b',
246
+ * // 'a.b.c',
247
+ * // 'a.c.c',
248
+ * // ]
249
+ */
250
+ declare function compareNaturalHierarchically(separator?: string): (a: string | undefined, b: string | undefined) => number;
256
251
 
257
252
  declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V): V;
258
253
 
@@ -270,19 +265,155 @@ declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V
270
265
  */
271
266
  type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
272
267
 
273
- type ArraySetRequired<T extends IterableContainer, Min extends number, Iteration extends ReadonlyArray<unknown> = []> = number extends Min ? never : Iteration["length"] extends Min ? T : T extends readonly [] ? never : T extends [infer Head, ...infer Rest] ? [
274
- Head,
275
- ...ArraySetRequired<Rest, Min, [unknown, ...Iteration]>
276
- ] : T extends readonly [infer Head, ...infer Rest] ? readonly [
277
- Head,
278
- ...ArraySetRequired<Rest, Min, [unknown, ...Iteration]>
279
- ] : T extends Array<infer Item> ? [
280
- Item,
281
- ...ArraySetRequired<T, Min, [unknown, ...Iteration]>
282
- ] : T extends ReadonlyArray<infer Item> ? readonly [
283
- Item,
284
- ...ArraySetRequired<T, Min, [unknown, ...Iteration]>
285
- ] : never;
268
+ declare const RemedaErrorSymbol: unique symbol;
269
+ type RemedaTypeErrorOptions = {
270
+ type?: unknown;
271
+ metadata?: unknown;
272
+ };
273
+ /**
274
+ * Used for reporting type errors in a more useful way than `never`.
275
+ */
276
+ type RemedaTypeError<Name extends string, Message extends string, Options extends RemedaTypeErrorOptions = {}> = Tagged<Options extends {
277
+ type: infer T;
278
+ } ? T : typeof RemedaErrorSymbol, `RemedaTypeError(${Name}): ${Message}.`, Options extends {
279
+ metadata: infer Metadata;
280
+ } ? Metadata : never>;
281
+
282
+ /**
283
+ * Takes a tuple and returns the types that make up its parts. These parts
284
+ * follow TypeScript's only supported format for arrays/tuples:
285
+ * [<required>, <optional>, ...<rest>[], <suffix>].
286
+ *
287
+ * There are some limitations to what shapes TypeScript supports:
288
+ * tuples can only have a suffix if they also have a non-never rest element,
289
+ * **and** tuples cannot have both an optional part and a suffix; this means
290
+ * there are only 10 possible shapes for tuples:
291
+ * 1. Empty Tuples: `[]`.
292
+ * 2. Fixed Tuples: `[string, number]`.
293
+ * 3. Optional Tuples: `[string?, number?]`.
294
+ * 4. Mixed Tuples: `[string, number?]`.
295
+ * 5. Arrays: `Array<string>`.
296
+ * 6. Fixed-Prefix Arrays: `[string, ...Array<string>]`.
297
+ * 7. Optional-Prefix Arrays: `[number?, ...Array<boolean>]`.
298
+ * 8. Mixed-Prefix Arrays: `[string, number?, ...Array<boolean>]`.
299
+ * 9. Fixed-Suffix Arrays: `[...Array<string>, string]`.
300
+ * 10. Fixed-Elements Arrays: `[string, ...Array<string>, string]`.
301
+ *
302
+ * @example [
303
+ * ...TupleParts<T>["required"],
304
+ * ...Partial<TupleParts<T>["optional"]>,
305
+ * ...CoercedArray<TupleParts<T>["item"]>,
306
+ * ...TupleParts<T>["suffix"],
307
+ * ].
308
+ */
309
+ type TupleParts<T extends IterableContainer, Prefix extends Array<unknown> = []> = T extends readonly [infer Head, ...infer Tail] ? TupleParts<Tail, [...Prefix, Head]> : Simplify<{
310
+ /**
311
+ * A fixed tuple that defines the part of the tuple where all its
312
+ * elements are required. This will always be the first part of the
313
+ * tuple and will never contain any optional or rest elements. When the
314
+ * array doesn't have a required part this will be an empty tuple
315
+ * (`[]`).
316
+ */
317
+ required: Prefix;
318
+ } & TuplePartsWithoutRequired<T>>;
319
+ type TuplePartsWithoutRequired<T extends IterableContainer, Suffix extends Array<unknown> = []> = T extends readonly [...infer Head, infer Tail] ? TuplePartsWithoutRequired<Head, [Tail, ...Suffix]> : (Suffix extends readonly [] ? TuplePartsWithoutFixed<T> : // When the suffix is not empty we can skip the optional part and go
320
+ {
321
+ optional: [];
322
+ } & TuplePartsRest<T>) & {
323
+ /**
324
+ * A *fixed* tuple that defines the part of a tuple **after** a non-never
325
+ * rest parameter. These could never be optional elements, and could
326
+ * never contain another rest element. When the array doesn't have a
327
+ * required part this will be an empty tuple (`[]`).
328
+ */
329
+ suffix: Suffix;
330
+ };
331
+ type TuplePartsWithoutFixed<T extends IterableContainer, Optional extends Array<unknown> = []> = T extends readonly [(infer Head)?, ...infer Tail] ? Or<T extends readonly [] ? true : false, Array<T[number]> extends Tail ? true : false> extends true ? {
332
+ /**
333
+ * A *fixed* tuple that defines the part of a tuple where all its
334
+ * elements are suffixed with the optional operator (`?`); but with
335
+ * the optional operator removed (e.g. `[string?]` would be
336
+ * represented as `[string]`). These elements can only follow the
337
+ * `required` part (which could be empty).
338
+ * To add optional operator back wrap the result with the built-in
339
+ * `Partial` type.
340
+ * When the array doesn't have a required part this will be an empty
341
+ * tuple (`[]`).
342
+ *
343
+ * @example Partial<TupleParts<T>["optional"]>
344
+ */
345
+ optional: Optional;
346
+ } & TuplePartsRest<T> : TuplePartsWithoutFixed<Tail, [...Optional, Head | undefined]> : RemedaTypeError<"TupleParts", "Unexpected tuple shape", {
347
+ type: never;
348
+ metadata: T;
349
+ }>;
350
+ type TuplePartsRest<T extends IterableContainer> = {
351
+ /**
352
+ * The type for the rest parameter of the tuple, if any. Unlike the
353
+ * other parts of the tuple, this is a single type and not
354
+ * represented as an array/tuple. When a tuple doesn't have a rest
355
+ * element, this will be `never`. To convert this to a matching array
356
+ * type that could be spread into a new type use the `CoercedArray`
357
+ * type which handles the `never` case correctly.
358
+ *
359
+ * @example CoercedArray<TupleParts<T>["item"]>
360
+ */
361
+ item: T extends readonly [] ? never : T[number];
362
+ };
363
+
364
+ /**
365
+ * We built our own version of Subtract instead of using type-fest's one
366
+ * because we needed a simpler implementation that isn't as prone to excessive
367
+ * recursion issues and that is clamped at 0 so that we don't need to handle
368
+ * negative values using even more utilities.
369
+ */
370
+ type ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag extends Array<unknown> = [], ResultBag extends Array<unknown> = []> = [...SubtrahendBag, ...ResultBag]["length"] extends Minuend ? ResultBag["length"] : SubtrahendBag["length"] extends Subtrahend ? ClampedIntegerSubtract<Minuend, Subtrahend, SubtrahendBag, [
371
+ ...ResultBag,
372
+ unknown
373
+ ]> : ClampedIntegerSubtract<Minuend, Subtrahend, [
374
+ ...SubtrahendBag,
375
+ unknown
376
+ ], ResultBag>;
377
+
378
+ /**
379
+ * `never[]` and `[]` are not the same type, and in some cases they aren't
380
+ * interchangeable.
381
+ *
382
+ * This type makes it easier to use the result of TupleParts when the input is a
383
+ * fixed-length tuple but we still want to spread the rest of the array. e.g.
384
+ * `[...CoercedArray<TupleParts<T>["item"]>, ...TupleParts<T>["suffix"]]`.
385
+ *
386
+ */
387
+ type CoercedArray<T> = IfNever<T, [], Array<T>>;
388
+
389
+ type ArrayRequiredPrefix<T extends IterableContainer, N extends number> = IsLiteral<N> extends true ? T extends unknown ? ClampedIntegerSubtract<N, [
390
+ ...TupleParts<T>["required"],
391
+ ...TupleParts<T>["suffix"]
392
+ ]["length"]> extends infer Remainder extends number ? Remainder extends 0 ? T : And<GreaterThan<Remainder, TupleParts<T>["optional"]["length"]>, IsNever<TupleParts<T>["item"]>> extends true ? RemedaTypeError<"ArrayRequiredPrefix", "The input tuple cannot satisfy the minimum", {
393
+ type: never;
394
+ metadata: [T, N];
395
+ }> : WithSameReadonly<T, [
396
+ ...TupleParts<T>["required"],
397
+ ...OptionalTupleRequiredPrefix<TupleParts<T>["optional"], Remainder>,
398
+ ...ReadonlyTuple<TupleParts<T>["item"], ClampedIntegerSubtract<Remainder, TupleParts<T>["optional"]["length"]>>,
399
+ ...CoercedArray<TupleParts<T>["item"]>,
400
+ ...TupleParts<T>["suffix"]
401
+ ]> : RemedaTypeError<"ArrayRequiredPrefix", "Remainder didn't compute to a number?!", {
402
+ type: never;
403
+ metadata: [T, N];
404
+ }> : RemedaTypeError<"ArrayRequiredPrefix", "Failed to distribute union?!", {
405
+ type: never;
406
+ metadata: T;
407
+ }> : RemedaTypeError<"ArrayRequiredPrefix", "Only literal minimums are supported!", {
408
+ type: never;
409
+ metadata: N;
410
+ }>;
411
+ type WithSameReadonly<Source, Destination> = IsEqual<Source, Readonly<Source>> extends true ? Readonly<Destination> : Destination;
412
+ type OptionalTupleRequiredPrefix<T extends Array<unknown>, N, Prefix extends Array<unknown> = []> = Prefix["length"] extends N ? [
413
+ ...Prefix,
414
+ ...Partial<T>
415
+ ] : T extends readonly [infer Head, ...infer Rest] ? OptionalTupleRequiredPrefix<Rest, N, [...Prefix, Head]> : Prefix;
416
+
286
417
  /**
287
418
  * Checks if the given array has at least the defined number of elements. When
288
419
  * the minimum used is a literal (e.g. `3`) the output is refined accordingly so
@@ -305,7 +436,7 @@ type ArraySetRequired<T extends IterableContainer, Min extends number, Iteration
305
436
  * @dataFirst
306
437
  * @category Array
307
438
  */
308
- declare function hasAtLeast<T extends IterableContainer, N extends number>(data: IterableContainer | T, minimum: IsNumericLiteral<N> extends true ? N : never): data is ArraySetRequired<T, N>;
439
+ declare function hasAtLeast<T extends IterableContainer, N extends number>(data: IterableContainer | T, minimum: IsNumericLiteral<N> extends true ? N : never): data is ArrayRequiredPrefix<T, N>;
309
440
  declare function hasAtLeast(data: IterableContainer, minimum: number): boolean;
310
441
  /**
311
442
  * Checks if the given array has at least the defined number of elements. When
@@ -331,7 +462,7 @@ declare function hasAtLeast(data: IterableContainer, minimum: number): boolean;
331
462
  * @dataLast
332
463
  * @category Array
333
464
  */
334
- declare function hasAtLeast<N extends number>(minimum: IsNumericLiteral<N> extends true ? N : never): <T extends IterableContainer>(data: IterableContainer | T) => data is ArraySetRequired<T, N>;
465
+ declare function hasAtLeast<N extends number>(minimum: IsNumericLiteral<N> extends true ? N : never): <T extends IterableContainer>(data: IterableContainer | T) => data is ArrayRequiredPrefix<T, N>;
335
466
  declare function hasAtLeast(minimum: number): (data: IterableContainer) => boolean;
336
467
 
337
468
  declare function isString(value: unknown): value is string;
@@ -364,6 +495,7 @@ declare function ifilter<T>(iterable: Iterable<T>, predicate: (v: T) => boolean)
364
495
  * @signature
365
496
  * ifind(predicate)(data)
366
497
  */
498
+ declare function ifind<T, S extends T>(predicate: (item: T) => item is S): (iterable: Iterable<T>) => S | undefined;
367
499
  declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => T | undefined;
368
500
  /**
369
501
  * Finds the first element in the iterable that satisfies the predicate.
@@ -371,11 +503,21 @@ declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<
371
503
  * @signature
372
504
  * ifind(data, predicate)
373
505
  */
506
+ declare function ifind<T, S extends T>(iterable: Iterable<T>, predicate: (item: T) => item is S): S | undefined;
374
507
  declare function ifind<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): T | undefined;
375
508
 
376
509
  declare function iflat(): <T>(iterable: Iterable<IteratorLike<T>>) => IteratorLike<T>;
377
510
  declare function iflat<T>(iterable: Iterable<IteratorLike<T>>): IteratorLike<T>;
378
511
 
512
+ declare function ihead<T>(): (iterable: Iterable<T>) => T | undefined;
513
+ /**
514
+ * Finds the first element in the iterable that satisfies the predicate.
515
+ * Data first version of `find`.
516
+ * @signature
517
+ * ifind(data, predicate)
518
+ */
519
+ declare function ihead<T>(iterable: Iterable<T>): T | undefined;
520
+
379
521
  type MapFunction<T, S> = (item: T) => S;
380
522
  /**
381
523
  * Maps an iterable using a mapper function.
@@ -422,18 +564,44 @@ declare function toSet<T>(iterable: Iterable<T>): Set<T>;
422
564
  declare function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>;
423
565
  declare function iunique<T>(iterable: Iterable<T>): IteratorLike<T>;
424
566
 
567
+ /**
568
+ * Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
569
+ * that value will be returned, and fn won't be called.
570
+ *
571
+ * @example
572
+ * ```ts
573
+ * class Model {
574
+ * // using same Symbol
575
+ * get computed1() {
576
+ * return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
577
+ * }
578
+ * // using string
579
+ * get computed2() {
580
+ * return memoizeProp(this, 'computed2', () => doOnce())
581
+ * }
582
+ *
583
+ * }
584
+ * ```
585
+ */
586
+ declare function memoizeProp<Tag extends symbol | string, Res>(obj: object, tag: Tag, fn: () => Res): Res;
587
+
425
588
  declare function delay(): Promise<string>;
426
589
  declare function delay(ms: number): Promise<string>;
427
590
  declare function delay(randomFrom: number, randomTo: number): Promise<string>;
428
591
 
592
+ type RelationshipLike = {
593
+ source: {
594
+ model: string;
595
+ };
596
+ target: {
597
+ model: string;
598
+ };
599
+ };
429
600
  /**
430
601
  * Compares two relations hierarchically.
431
602
  * From the most general (implicit) to the most specific.
432
603
  */
433
- declare const compareRelations: <T extends {
434
- source: string;
435
- target: string;
436
- }>(a: T, b: T) => number;
604
+ declare const compareRelations: <T extends RelationshipLike>(a: T, b: T) => number;
437
605
 
438
606
  /**
439
607
  * Returns new set as a union of given sets
@@ -456,4 +624,4 @@ declare function stringHash(str: string): string;
456
624
 
457
625
  declare function objectHash(value: any): string;
458
626
 
459
- export { BiMap, DefaultMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareRelations, delay, difference, equals as equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, imap, intersection, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, objectHash, stringHash, symmetricDifference, toArray, toSet, union };
627
+ export { BiMap, DefaultWeakMap, LinkedList, MultiMap, Queue, Stack, commonHead, compareNatural, compareNaturalHierarchically, compareRelations, delay, difference, equals as 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 };