@likec4/core 0.30.0 → 0.31.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.
@@ -12,7 +12,7 @@ import { invariant } from '../errors';
12
12
  function transformToNodes(elementsIterator) {
13
13
  return Array.from(elementsIterator)
14
14
  .sort(compareByFqnHierarchically)
15
- .reduce((map, { id, color, shape, tags, ...el }) => {
15
+ .reduce((map, { id, color, shape, ...el }) => {
16
16
  let parent = parentFqn(id);
17
17
  while (parent) {
18
18
  if (map.has(parent)) {
@@ -31,8 +31,7 @@ function transformToNodes(elementsIterator) {
31
31
  parent,
32
32
  color: color ?? DefaultThemeColor,
33
33
  shape: shape ?? DefaultElementShape,
34
- children: [],
35
- tags: [...tags]
34
+ children: []
36
35
  };
37
36
  map.set(id, node);
38
37
  return map;
@@ -0,0 +1,2 @@
1
+ export type NonEmptyArray<T> = [T, ...T[]];
2
+ //# sourceMappingURL=_common.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=_common.js.map
@@ -2,6 +2,7 @@ import type { Opaque } from './opaque';
2
2
  import type { ElementKind, ElementShape, Fqn, Tag, ThemeColor } from './element';
3
3
  import type { RelationID } from './relation';
4
4
  import type { ElementView, ViewID, ViewRuleAutoLayout } from './view';
5
+ import type { NonEmptyArray } from './_common';
5
6
  export type NodeId = Fqn;
6
7
  export type EdgeId = Opaque<string, 'EdgeId'>;
7
8
  export interface ComputedNode {
@@ -11,7 +12,8 @@ export interface ComputedNode {
11
12
  title: string;
12
13
  description: string | null;
13
14
  technology: string | null;
14
- tags: Tag[];
15
+ tags: NonEmptyArray<Tag> | null;
16
+ links: NonEmptyArray<string> | null;
15
17
  children: NodeId[];
16
18
  shape: ElementShape;
17
19
  color: ThemeColor;
@@ -1,3 +1,4 @@
1
+ import type { NonEmptyArray } from '.';
1
2
  import type { Opaque } from './opaque';
2
3
  export type Fqn = Opaque<string, 'Fqn'>;
3
4
  export declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
@@ -23,7 +24,8 @@ export interface Element {
23
24
  readonly title: string;
24
25
  readonly description: string | null;
25
26
  readonly technology: string | null;
26
- readonly tags: ReadonlyArray<Tag>;
27
+ readonly tags: NonEmptyArray<Tag> | null;
28
+ readonly links: NonEmptyArray<string> | null;
27
29
  readonly shape?: ElementShape;
28
30
  readonly color?: ThemeColor;
29
31
  }
@@ -1,6 +1,7 @@
1
1
  export { AsFqn, DefaultThemeColor, DefaultElementShape } from './element';
2
2
  export { isViewRuleExpression, isViewRuleAutoLayout, isViewRuleStyle } from './view';
3
3
  export * as Expr from './expression';
4
+ export type * from './_common';
4
5
  export type * from './opaque';
5
6
  export type * from './element';
6
7
  export type * from './relation';
@@ -1,6 +1,7 @@
1
1
  import type { Opaque } from './opaque';
2
- import type { ElementShape, Fqn, ThemeColor } from './element';
2
+ import type { ElementShape, Fqn, Tag, ThemeColor } from './element';
3
3
  import type { ElementExpression, Expression } from './expression';
4
+ import type { NonEmptyArray } from './_common';
4
5
  export type ViewID = Opaque<string, 'ViewID'>;
5
6
  export interface ViewRuleExpression {
6
7
  isInclude: boolean;
@@ -23,8 +24,10 @@ export type ViewRule = ViewRuleExpression | ViewRuleStyle | ViewRuleAutoLayout;
23
24
  export interface ElementView {
24
25
  readonly id: ViewID;
25
26
  readonly viewOf?: Fqn;
26
- readonly title?: string;
27
- readonly description?: string;
27
+ readonly title: string | null;
28
+ readonly description: string | null;
29
+ readonly tags: NonEmptyArray<Tag> | null;
30
+ readonly links: NonEmptyArray<string> | null;
28
31
  readonly rules: ViewRule[];
29
32
  }
30
33
  //# sourceMappingURL=view.d.ts.map
@@ -1,4 +1,6 @@
1
+ import type { NonEmptyArray } from "../types";
1
2
  export declare function isString(value: unknown): value is string;
2
3
  export declare function failExpectedNever(arg: never): never;
3
4
  export declare function ignoreNeverInRuntime(arg: never): void;
5
+ export declare function isNonEmptyArray<A>(arr: ArrayLike<A>): arr is NonEmptyArray<A>;
4
6
  //# sourceMappingURL=guards.d.ts.map
@@ -8,4 +8,7 @@ export function ignoreNeverInRuntime(arg) {
8
8
  console.warn(`Unexpected and ignored value: ${JSON.stringify(arg)}`);
9
9
  // throw new Error(`Unexpected value: ${arg}`);
10
10
  }
11
+ export function isNonEmptyArray(arr) {
12
+ return arr.length > 0;
13
+ }
11
14
  //# sourceMappingURL=guards.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -93,7 +93,7 @@
93
93
  "@dagrejs/graphlib": "^2.1.13",
94
94
  "modern-errors": "^6.0.0",
95
95
  "rambdax": "^9.1.1",
96
- "remeda": "^1.23.0"
96
+ "remeda": "^1.24.0"
97
97
  },
98
98
  "devDependencies": {
99
99
  "typescript": "^5.1.6"