@likec4/core 1.26.1 → 1.27.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 (54) hide show
  1. package/dist/builder/index.d.mts +3 -1
  2. package/dist/builder/index.mjs +6 -4
  3. package/dist/compute-view/index.d.mts +1 -2
  4. package/dist/compute-view/index.mjs +19 -7
  5. package/dist/compute-view/relationships-view/index.d.mts +42 -0
  6. package/dist/compute-view/relationships-view/index.mjs +181 -0
  7. package/dist/index.d.mts +3 -5
  8. package/dist/index.mjs +5 -5
  9. package/dist/model/index.d.mts +3 -3
  10. package/dist/model/index.mjs +1 -1
  11. package/dist/shared/{core.yND74qFI.mjs → core.BMep80lJ.mjs} +2 -1
  12. package/dist/shared/{core.DRxv3HIl.mjs → core.C-YXI-43.mjs} +1 -5
  13. package/dist/shared/core.CQXU9DF7.mjs +477 -0
  14. package/dist/shared/{core.Brmu7VBL.d.mts → core.CtloVwbo.d.mts} +3 -1
  15. package/dist/shared/{core.BqezHsjR.mjs → core.Cu-UdkSl.mjs} +16 -477
  16. package/dist/shared/core.DbRvwARP.mjs +5 -0
  17. package/dist/shared/{core.oI7caxVx.d.mts → core.Uz54YXx0.d.mts} +1 -1
  18. package/dist/shared/{core.CcjDE4j7.mjs → core.zj2huD5x.mjs} +17 -30
  19. package/dist/types/index.mjs +1 -1
  20. package/dist/utils/index.d.mts +3 -2
  21. package/dist/utils/index.mjs +5 -3
  22. package/package.json +19 -9
  23. package/src/builder/Builder.model.ts +74 -0
  24. package/src/builder/Builder.with.ts +20 -339
  25. package/src/compute-view/deployment-view/_types.ts +1 -1
  26. package/src/compute-view/deployment-view/predicates/relation-direct.ts +6 -7
  27. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +2 -1
  28. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +1 -1
  29. package/src/compute-view/dynamic-view/compute.ts +22 -43
  30. package/src/compute-view/index.ts +0 -1
  31. package/src/compute-view/relationships-view/_types.ts +7 -6
  32. package/src/compute-view/relationships-view/compute.ts +140 -52
  33. package/src/compute-view/relationships-view/index.ts +3 -0
  34. package/src/compute-view/relationships-view/utils.ts +44 -11
  35. package/src/compute-view/utils/resolve-extended-views.ts +20 -5
  36. package/src/compute-view/utils/view-hash.ts +1 -4
  37. package/src/index.ts +1 -1
  38. package/src/model/ElementModel.ts +2 -0
  39. package/src/model/view/NodeModel.ts +5 -0
  40. package/src/utils/object-hash.ts +13 -2
  41. package/dist/builder/index.d.ts +0 -509
  42. package/dist/compute-view/index.d.ts +0 -23
  43. package/dist/index.d.ts +0 -147
  44. package/dist/model/index.d.ts +0 -118
  45. package/dist/shared/core.-qjOvsEL.d.ts +0 -146
  46. package/dist/shared/core.30yYKXcZ.d.ts +0 -186
  47. package/dist/shared/core.BBJd-FqJ.mjs +0 -37
  48. package/dist/shared/core.BH59D8Ji.d.ts +0 -858
  49. package/dist/shared/core.CIbWBWW3.d.ts +0 -127
  50. package/dist/shared/core.Cpd5mZgF.d.ts +0 -732
  51. package/dist/shared/core.Dd1nCiNx.d.mts +0 -12
  52. package/dist/shared/core.mD0TIdz_.d.ts +0 -12
  53. package/dist/types/index.d.ts +0 -72
  54. package/dist/utils/index.d.ts +0 -458
@@ -1,127 +0,0 @@
1
- import { F as Fqn } from './core.30yYKXcZ.js';
2
-
3
- declare function parentFqn<E extends string>(fqn: E): E | null;
4
- declare function nameFromFqn<E extends string>(fqn: E): string;
5
- /**
6
- * Check if one element is an ancestor of another
7
- * Composable version
8
- * @signature
9
- * isAncestor(another)(ancestor)
10
- */
11
- declare function isAncestor<A extends string | {
12
- id: string;
13
- }>(another: NoInfer<A>): (ancestor: A) => boolean;
14
- /**
15
- * Check if one element is an ancestor of another
16
- * @signature
17
- * isAncestor(ancestor, another)
18
- */
19
- declare function isAncestor<A extends string | {
20
- id: string;
21
- }>(ancestor: A, another: A): boolean;
22
- declare function isSameHierarchy<T extends string>(one: NoInfer<T> | WithId<NoInfer<T>>): (another: T | WithId<T>) => boolean;
23
- declare function isSameHierarchy<T extends string>(one: T | WithId<T>, another: T | WithId<T>): boolean;
24
- type WithId<T> = {
25
- id: T;
26
- };
27
- declare function isDescendantOf<T extends string>(ancestor: WithId<T>): (descedant: WithId<T>) => boolean;
28
- declare function isDescendantOf<T extends string>(descedant: WithId<T>, ancestor: WithId<T>): boolean;
29
- /**
30
- * How deep in the hierarchy the element is.
31
- * Root element has depth 1
32
- */
33
- declare function hierarchyLevel<E extends string | {
34
- id: Fqn;
35
- }>(elementOfFqn: E): number;
36
- /**
37
- * Calculate the distance as number of steps from one element to another, i.e.
38
- * going up to the common ancestor, then going down to the other element.
39
- * Sibling distance is always 1
40
- *
41
- * Can be used for hierarchical clustering
42
- */
43
- declare function hierarchyDistance<E extends string | {
44
- id: Fqn;
45
- }>(one: E, another: E): number;
46
- declare function commonAncestor<E extends string>(first: E, second: E): E | null;
47
- /**
48
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
49
- * going up from parent to the root
50
- */
51
- declare function ancestorsFqn<Id extends string>(fqn: Id): Id[];
52
- /**
53
- * Compares two fully qualified names (fqns) hierarchically based on their depth.
54
- * From parent nodes to leaves
55
- *
56
- * @param {string} a - The first fqn to compare.
57
- * @param {string} b - The second fqn to compare.
58
- * @returns {number} - 0 if the fqns have the same depth.
59
- * - Positive number if a is deeper than b.
60
- * - Negative number if b is deeper than a.
61
- */
62
- declare function compareFqnHierarchically<T extends string = string>(a: T, b: T): -1 | 0 | 1;
63
- declare function compareByFqnHierarchically<T extends {
64
- id: string;
65
- }>(a: T, b: T): -1 | 0 | 1;
66
- type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
67
- type ReorderedArray<T extends IterableContainer> = {
68
- -readonly [P in keyof T]: T[number];
69
- };
70
- /**
71
- * Sorts an array of objects hierarchically based on their fully qualified names (FQN).
72
- * Objects are sorted by the number of segments in their FQN (defined by dot-separated ID).
73
- *
74
- * @typeParam T - Object type that contains an 'id' string property
75
- * @typeParam A - Type extending IterableContainer of T
76
- *
77
- * @param array - Array of objects to be sorted
78
- * @returns A new array with items sorted by their FQN hierarchy depth (number of segments)
79
- *
80
- * @example
81
- * ```ts
82
- * const items = [
83
- * { id: "a.b.c" },
84
- * { id: "a" },
85
- * { id: "a.b" }
86
- * ];
87
- * sortByFqnHierarchically(items);
88
- * // Result: [
89
- * // { id: "a" },
90
- * // { id: "a.b" },
91
- * // { id: "a.b.c" }
92
- * // ]
93
- * ```
94
- */
95
- declare function sortByFqnHierarchically<T extends {
96
- id: string;
97
- }, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
98
- /**
99
- * Keeps initial order of the elements, but ensures that parents are before children
100
- */
101
- declare function sortParentsFirst<T extends {
102
- id: string;
103
- }, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
104
- /**
105
- * Sorts an array of objects naturally by their fully qualified name (FQN) identifier.
106
- *
107
- * @template T - Type of objects containing an 'id' string property
108
- * @template A - Type extending IterableContainer of T
109
- *
110
- * @param first - Optional. Either the array to sort or the sort direction ('asc'|'desc')
111
- * @param sort - Optional. The sort direction ('asc'|'desc'). Defaults to 'asc' if not specified
112
- *
113
- * @example
114
- * // As a function that returns a sorting function
115
- * const sorted = sortNaturalByFqn('desc')(myArray);
116
- *
117
- * // Direct array sorting
118
- * const sorted = sortNaturalByFqn(myArray, 'desc');
119
- */
120
- declare function sortNaturalByFqn(sort?: 'asc' | 'desc'): <T extends {
121
- id: string;
122
- }, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>;
123
- declare function sortNaturalByFqn<T extends {
124
- id: string;
125
- }, A extends IterableContainer<T>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
126
-
127
- export { type IterableContainer as I, type ReorderedArray as R, ancestorsFqn as a, compareByFqnHierarchically as b, commonAncestor as c, compareFqnHierarchically as d, hierarchyLevel as e, isDescendantOf as f, isSameHierarchy as g, hierarchyDistance as h, isAncestor as i, sortNaturalByFqn as j, sortParentsFirst as k, nameFromFqn as n, parentFqn as p, sortByFqnHierarchically as s };