@likec4/core 1.8.1 → 1.10.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.
- package/dist/index.cjs +4467 -0
- package/dist/index.d.cts +793 -0
- package/dist/index.d.mts +793 -0
- package/dist/index.d.ts +793 -7
- package/dist/index.mjs +4390 -0
- package/dist/shared/core.CpR2fq5B.d.cts +833 -0
- package/dist/shared/core.CpR2fq5B.d.mts +833 -0
- package/dist/shared/core.CpR2fq5B.d.ts +833 -0
- package/dist/shared/core.Db3ntVII.cjs +318 -0
- package/dist/shared/core.DeifT5lC.mjs +263 -0
- package/dist/types/index.cjs +55 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -14
- package/dist/types/index.mjs +1 -0
- package/package.json +43 -33
- package/src/colors/index.ts +27 -1
- package/src/errors/index.ts +3 -95
- package/src/index.ts +6 -6
- package/src/model/LikeC4Model.ts +480 -0
- package/src/model/LikeC4ViewModel.ts +318 -0
- package/src/model/__test__/LikeC4Model.spec.ts +79 -0
- package/src/model/__test__/fixture.ts +333 -0
- package/src/model/index.ts +2 -0
- package/src/model/types.ts +10 -0
- package/src/types/_common.ts +4 -2
- package/src/types/element.ts +11 -8
- package/src/types/expression.ts +7 -3
- package/src/types/index.ts +0 -1
- package/src/types/model.ts +16 -6
- package/src/types/relation.ts +18 -5
- package/src/types/theme.ts +28 -12
- package/src/types/view-notation.ts +3 -4
- package/src/types/view.ts +51 -16
- package/src/utils/compare-natural.spec.ts +37 -0
- package/src/utils/compare-natural.ts +14 -0
- package/src/utils/fqn.spec.ts +99 -2
- package/src/utils/fqn.ts +45 -5
- package/src/utils/index.ts +1 -0
- package/src/utils/relations.spec.ts +2 -4
- package/src/utils/relations.ts +14 -24
- package/dist/colors/element.d.ts +0 -69
- package/dist/colors/element.js +0 -75
- package/dist/colors/index.d.ts +0 -133
- package/dist/colors/index.js +0 -9
- package/dist/colors/relationships.d.ts +0 -58
- package/dist/colors/relationships.js +0 -49
- package/dist/errors/errors.spec.d.ts +0 -2
- package/dist/errors/errors.spec.js +0 -69
- package/dist/errors/index.d.ts +0 -39
- package/dist/errors/index.js +0 -104
- package/dist/index.js +0 -4
- package/dist/types/_common.d.ts +0 -9
- package/dist/types/_common.js +0 -1
- package/dist/types/element.d.ts +0 -55
- package/dist/types/element.js +0 -15
- package/dist/types/expression.d.ts +0 -119
- package/dist/types/expression.js +0 -67
- package/dist/types/index.js +0 -14
- package/dist/types/model.d.ts +0 -14
- package/dist/types/model.js +0 -1
- package/dist/types/opaque.d.ts +0 -103
- package/dist/types/opaque.js +0 -1
- package/dist/types/operators.d.ts +0 -44
- package/dist/types/operators.js +0 -59
- package/dist/types/overview-graph.d.ts +0 -41
- package/dist/types/overview-graph.js +0 -1
- package/dist/types/relation.d.ts +0 -30
- package/dist/types/relation.js +0 -3
- package/dist/types/theme.d.ts +0 -27
- package/dist/types/theme.js +0 -1
- package/dist/types/view-changes.d.ts +0 -26
- package/dist/types/view-changes.js +0 -1
- package/dist/types/view-notation.d.ts +0 -9
- package/dist/types/view-notation.js +0 -1
- package/dist/types/view.d.ts +0 -243
- package/dist/types/view.js +0 -50
- package/dist/utils/fqn.d.ts +0 -39
- package/dist/utils/fqn.js +0 -102
- package/dist/utils/fqn.spec.d.ts +0 -2
- package/dist/utils/fqn.spec.js +0 -82
- package/dist/utils/guards.d.ts +0 -5
- package/dist/utils/guards.js +0 -7
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.js +0 -4
- package/dist/utils/promises.d.ts +0 -2
- package/dist/utils/promises.js +0 -8
- package/dist/utils/relations.d.ts +0 -30
- package/dist/utils/relations.js +0 -79
- package/dist/utils/relations.spec.d.ts +0 -2
- package/dist/utils/relations.spec.js +0 -210
- package/src/errors/errors.spec.ts +0 -88
- package/src/reset.d.ts +0 -2
- package/src/types/opaque.ts +0 -108
package/dist/colors/index.d.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { ElementColors } from './element';
|
|
2
|
-
import { RelationshipColors } from './relationships';
|
|
3
|
-
export declare const defaultTheme: {
|
|
4
|
-
elements: {
|
|
5
|
-
readonly primary: {
|
|
6
|
-
fill: "#3b82f6";
|
|
7
|
-
stroke: "#2563eb";
|
|
8
|
-
hiContrast: "#eff6ff";
|
|
9
|
-
loContrast: "#bfdbfe";
|
|
10
|
-
};
|
|
11
|
-
readonly blue: {
|
|
12
|
-
fill: "#3b82f6";
|
|
13
|
-
stroke: "#2563eb";
|
|
14
|
-
hiContrast: "#eff6ff";
|
|
15
|
-
loContrast: "#bfdbfe";
|
|
16
|
-
};
|
|
17
|
-
readonly secondary: {
|
|
18
|
-
fill: "#0284c7";
|
|
19
|
-
stroke: "#0369a1";
|
|
20
|
-
hiContrast: "#f0f9ff";
|
|
21
|
-
loContrast: "#B6ECF7";
|
|
22
|
-
};
|
|
23
|
-
readonly sky: {
|
|
24
|
-
fill: "#0284c7";
|
|
25
|
-
stroke: "#0369a1";
|
|
26
|
-
hiContrast: "#f0f9ff";
|
|
27
|
-
loContrast: "#B6ECF7";
|
|
28
|
-
};
|
|
29
|
-
readonly muted: {
|
|
30
|
-
fill: "#64748b";
|
|
31
|
-
stroke: "#475569";
|
|
32
|
-
hiContrast: "#f8fafc";
|
|
33
|
-
loContrast: "#cbd5e1";
|
|
34
|
-
};
|
|
35
|
-
readonly slate: {
|
|
36
|
-
fill: "#64748b";
|
|
37
|
-
stroke: "#475569";
|
|
38
|
-
hiContrast: "#f8fafc";
|
|
39
|
-
loContrast: "#cbd5e1";
|
|
40
|
-
};
|
|
41
|
-
readonly gray: {
|
|
42
|
-
readonly fill: "#737373";
|
|
43
|
-
readonly stroke: "#525252";
|
|
44
|
-
readonly hiContrast: "#fafafa";
|
|
45
|
-
readonly loContrast: "#d4d4d4";
|
|
46
|
-
};
|
|
47
|
-
readonly red: {
|
|
48
|
-
readonly fill: "#AC4D39";
|
|
49
|
-
readonly stroke: "#853A2D";
|
|
50
|
-
readonly hiContrast: "#FBD3CB";
|
|
51
|
-
readonly loContrast: "#f5b2a3";
|
|
52
|
-
};
|
|
53
|
-
readonly green: {
|
|
54
|
-
readonly fill: "#428a4f";
|
|
55
|
-
readonly stroke: "#2d5d39";
|
|
56
|
-
readonly hiContrast: "#f8fafc";
|
|
57
|
-
readonly loContrast: "#c2f0c2";
|
|
58
|
-
};
|
|
59
|
-
readonly amber: {
|
|
60
|
-
readonly fill: "#A35829";
|
|
61
|
-
readonly stroke: "#7E451D";
|
|
62
|
-
readonly hiContrast: "#FFE0C2";
|
|
63
|
-
readonly loContrast: "#f9b27c";
|
|
64
|
-
};
|
|
65
|
-
readonly indigo: {
|
|
66
|
-
readonly fill: "#6366f1";
|
|
67
|
-
readonly stroke: "#4f46e5";
|
|
68
|
-
readonly hiContrast: "#eef2ff";
|
|
69
|
-
readonly loContrast: "#c7d2fe";
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
relationships: {
|
|
73
|
-
amber: {
|
|
74
|
-
lineColor: "#b45309";
|
|
75
|
-
labelBgColor: "#78350f";
|
|
76
|
-
labelColor: "#FFE0C2";
|
|
77
|
-
};
|
|
78
|
-
blue: {
|
|
79
|
-
lineColor: "#3b82f6";
|
|
80
|
-
labelBgColor: "#172554";
|
|
81
|
-
labelColor: "#60a5fa";
|
|
82
|
-
};
|
|
83
|
-
gray: {
|
|
84
|
-
lineColor: "#6E6E6E";
|
|
85
|
-
labelBgColor: "#18191b";
|
|
86
|
-
labelColor: "#C6C6C6";
|
|
87
|
-
};
|
|
88
|
-
green: {
|
|
89
|
-
lineColor: "#15803d";
|
|
90
|
-
labelBgColor: "#052e16";
|
|
91
|
-
labelColor: "#22c55e";
|
|
92
|
-
};
|
|
93
|
-
indigo: {
|
|
94
|
-
lineColor: "#6366f1";
|
|
95
|
-
labelBgColor: "#1e1b4b";
|
|
96
|
-
labelColor: "#818cf8";
|
|
97
|
-
};
|
|
98
|
-
muted: {
|
|
99
|
-
lineColor: "#64748b";
|
|
100
|
-
labelBgColor: "#0f172a";
|
|
101
|
-
labelColor: "#cbd5e1";
|
|
102
|
-
};
|
|
103
|
-
primary: {
|
|
104
|
-
lineColor: "#3b82f6";
|
|
105
|
-
labelBgColor: "#172554";
|
|
106
|
-
labelColor: "#60a5fa";
|
|
107
|
-
};
|
|
108
|
-
red: {
|
|
109
|
-
lineColor: "#AC4D39";
|
|
110
|
-
labelBgColor: "#b91c1c";
|
|
111
|
-
labelColor: "#f5b2a3";
|
|
112
|
-
};
|
|
113
|
-
secondary: {
|
|
114
|
-
lineColor: "#0ea5e9";
|
|
115
|
-
labelBgColor: "#082f49";
|
|
116
|
-
labelColor: "#38bdf8";
|
|
117
|
-
};
|
|
118
|
-
sky: {
|
|
119
|
-
lineColor: "#0ea5e9";
|
|
120
|
-
labelBgColor: "#082f49";
|
|
121
|
-
labelColor: "#38bdf8";
|
|
122
|
-
};
|
|
123
|
-
slate: {
|
|
124
|
-
lineColor: "#64748b";
|
|
125
|
-
labelBgColor: "#0f172a";
|
|
126
|
-
labelColor: "#cbd5e1";
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
font: "Arial";
|
|
130
|
-
shadow: "#0a0a0a";
|
|
131
|
-
};
|
|
132
|
-
export { ElementColors, RelationshipColors };
|
|
133
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/colors/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ElementColors } from './element';
|
|
2
|
-
import { RelationshipColors } from './relationships';
|
|
3
|
-
export const defaultTheme = {
|
|
4
|
-
elements: ElementColors,
|
|
5
|
-
relationships: RelationshipColors,
|
|
6
|
-
font: 'Arial',
|
|
7
|
-
shadow: '#0a0a0a'
|
|
8
|
-
};
|
|
9
|
-
export { ElementColors, RelationshipColors };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export declare const RelationshipColors: {
|
|
2
|
-
amber: {
|
|
3
|
-
lineColor: "#b45309";
|
|
4
|
-
labelBgColor: "#78350f";
|
|
5
|
-
labelColor: "#FFE0C2";
|
|
6
|
-
};
|
|
7
|
-
blue: {
|
|
8
|
-
lineColor: "#3b82f6";
|
|
9
|
-
labelBgColor: "#172554";
|
|
10
|
-
labelColor: "#60a5fa";
|
|
11
|
-
};
|
|
12
|
-
gray: {
|
|
13
|
-
lineColor: "#6E6E6E";
|
|
14
|
-
labelBgColor: "#18191b";
|
|
15
|
-
labelColor: "#C6C6C6";
|
|
16
|
-
};
|
|
17
|
-
green: {
|
|
18
|
-
lineColor: "#15803d";
|
|
19
|
-
labelBgColor: "#052e16";
|
|
20
|
-
labelColor: "#22c55e";
|
|
21
|
-
};
|
|
22
|
-
indigo: {
|
|
23
|
-
lineColor: "#6366f1";
|
|
24
|
-
labelBgColor: "#1e1b4b";
|
|
25
|
-
labelColor: "#818cf8";
|
|
26
|
-
};
|
|
27
|
-
muted: {
|
|
28
|
-
lineColor: "#64748b";
|
|
29
|
-
labelBgColor: "#0f172a";
|
|
30
|
-
labelColor: "#cbd5e1";
|
|
31
|
-
};
|
|
32
|
-
primary: {
|
|
33
|
-
lineColor: "#3b82f6";
|
|
34
|
-
labelBgColor: "#172554";
|
|
35
|
-
labelColor: "#60a5fa";
|
|
36
|
-
};
|
|
37
|
-
red: {
|
|
38
|
-
lineColor: "#AC4D39";
|
|
39
|
-
labelBgColor: "#b91c1c";
|
|
40
|
-
labelColor: "#f5b2a3";
|
|
41
|
-
};
|
|
42
|
-
secondary: {
|
|
43
|
-
lineColor: "#0ea5e9";
|
|
44
|
-
labelBgColor: "#082f49";
|
|
45
|
-
labelColor: "#38bdf8";
|
|
46
|
-
};
|
|
47
|
-
sky: {
|
|
48
|
-
lineColor: "#0ea5e9";
|
|
49
|
-
labelBgColor: "#082f49";
|
|
50
|
-
labelColor: "#38bdf8";
|
|
51
|
-
};
|
|
52
|
-
slate: {
|
|
53
|
-
lineColor: "#64748b";
|
|
54
|
-
labelBgColor: "#0f172a";
|
|
55
|
-
labelColor: "#cbd5e1";
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=relationships.d.ts.map
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const gray = {
|
|
2
|
-
lineColor: '#6E6E6E',
|
|
3
|
-
labelBgColor: '#18191b',
|
|
4
|
-
labelColor: '#C6C6C6'
|
|
5
|
-
};
|
|
6
|
-
const slate = {
|
|
7
|
-
lineColor: '#64748b', // 500
|
|
8
|
-
labelBgColor: '#0f172a', // 900
|
|
9
|
-
labelColor: '#cbd5e1' // 300
|
|
10
|
-
};
|
|
11
|
-
const blue = {
|
|
12
|
-
lineColor: '#3b82f6', // 500
|
|
13
|
-
labelBgColor: '#172554', // 950
|
|
14
|
-
labelColor: '#60a5fa' // 400
|
|
15
|
-
};
|
|
16
|
-
const sky = {
|
|
17
|
-
lineColor: '#0ea5e9', // 500
|
|
18
|
-
labelBgColor: '#082f49', // 950
|
|
19
|
-
labelColor: '#38bdf8' // 400
|
|
20
|
-
};
|
|
21
|
-
export const RelationshipColors = {
|
|
22
|
-
amber: {
|
|
23
|
-
lineColor: '#b45309',
|
|
24
|
-
labelBgColor: '#78350f',
|
|
25
|
-
labelColor: '#FFE0C2'
|
|
26
|
-
},
|
|
27
|
-
blue,
|
|
28
|
-
gray,
|
|
29
|
-
green: {
|
|
30
|
-
lineColor: '#15803d', // 700
|
|
31
|
-
labelBgColor: '#052e16', // 950
|
|
32
|
-
labelColor: '#22c55e' // 500
|
|
33
|
-
},
|
|
34
|
-
indigo: {
|
|
35
|
-
lineColor: '#6366f1', // 500
|
|
36
|
-
labelBgColor: '#1e1b4b', // 950
|
|
37
|
-
labelColor: '#818cf8' // 400
|
|
38
|
-
},
|
|
39
|
-
muted: slate,
|
|
40
|
-
primary: blue,
|
|
41
|
-
red: {
|
|
42
|
-
lineColor: '#AC4D39',
|
|
43
|
-
labelBgColor: '#b91c1c',
|
|
44
|
-
labelColor: '#f5b2a3'
|
|
45
|
-
},
|
|
46
|
-
secondary: sky,
|
|
47
|
-
sky,
|
|
48
|
-
slate
|
|
49
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { BaseError, InvalidArgError, InvalidModelError, invariant, InvariantError, NonExhaustiveError, normalizeError, NullableError, RelationRefError, UnknownError } from './index';
|
|
3
|
-
describe('errors', () => {
|
|
4
|
-
describe('normalizeError', () => {
|
|
5
|
-
it.each([
|
|
6
|
-
{ error: new BaseError('BaseError') },
|
|
7
|
-
{ error: new RelationRefError('RelationRefError') },
|
|
8
|
-
{ error: new UnknownError('UnknownError') },
|
|
9
|
-
{ error: new InvariantError('InvariantError') },
|
|
10
|
-
{ error: new NonExhaustiveError('NonExhaustiveError') },
|
|
11
|
-
{ error: new InvalidModelError('InvalidModelError') },
|
|
12
|
-
{ error: new NullableError('NullableError') },
|
|
13
|
-
{ error: new InvalidArgError('InvalidArgError') }
|
|
14
|
-
])('should return $error.name as-is', ({ error }) => {
|
|
15
|
-
expect(normalizeError(error)).toBe(error);
|
|
16
|
-
});
|
|
17
|
-
it.skip('should wrap an error', () => {
|
|
18
|
-
const cause = new Error('original test');
|
|
19
|
-
const error = normalizeError(cause);
|
|
20
|
-
expect(error).toBeInstanceOf(UnknownError);
|
|
21
|
-
expect(error).to.include({
|
|
22
|
-
name: 'UnknownError',
|
|
23
|
-
message: 'original test'
|
|
24
|
-
});
|
|
25
|
-
expect(error).to.have.property('cause').that.eq(cause);
|
|
26
|
-
expect(error)
|
|
27
|
-
.to.have.property('stack')
|
|
28
|
-
.that.is.a('string')
|
|
29
|
-
.and.includes('UnknownError: original test');
|
|
30
|
-
});
|
|
31
|
-
it('should wrap a string', () => {
|
|
32
|
-
const cause = 'error string';
|
|
33
|
-
const error = normalizeError(cause);
|
|
34
|
-
expect(error).toBeInstanceOf(UnknownError);
|
|
35
|
-
expect(error).to.include({
|
|
36
|
-
name: 'UnknownError',
|
|
37
|
-
message: cause
|
|
38
|
-
});
|
|
39
|
-
expect(error).not.to.have.property('cause');
|
|
40
|
-
expect(error).to.have.property('stack').that.is.a('string');
|
|
41
|
-
});
|
|
42
|
-
// Fails on serializiation of AST
|
|
43
|
-
it.skip('should wrap an object', () => {
|
|
44
|
-
const cause = { foo: 'bar' };
|
|
45
|
-
const error = normalizeError(cause);
|
|
46
|
-
expect(error).toBeInstanceOf(UnknownError);
|
|
47
|
-
expect(error).to.include({
|
|
48
|
-
name: 'UnknownError',
|
|
49
|
-
message: '{"foo":"bar"}'
|
|
50
|
-
});
|
|
51
|
-
expect(error).not.to.have.property('cause');
|
|
52
|
-
expect(error).to.have.property('stack').that.is.a('string');
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('invariant', () => {
|
|
57
|
-
it('should throw an error if the condition fails', () => {
|
|
58
|
-
expect(() => invariant(false)).toThrow('Invariant failed');
|
|
59
|
-
});
|
|
60
|
-
it('should throw an error if the condition is null', () => {
|
|
61
|
-
expect(() => invariant(null)).toThrow(InvariantError);
|
|
62
|
-
});
|
|
63
|
-
it('should not throw an error if the condition passes', () => {
|
|
64
|
-
expect(() => invariant(true)).not.toThrow();
|
|
65
|
-
});
|
|
66
|
-
it('should throw an error with the provided message if the condition fails', () => {
|
|
67
|
-
expect(() => invariant(false, 'test')).toThrow('test');
|
|
68
|
-
});
|
|
69
|
-
});
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { CustomError } from 'ts-custom-error';
|
|
2
|
-
export interface BaseErrorOptions {
|
|
3
|
-
cause?: unknown;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Base class for all errors in the LikeC4 library.
|
|
7
|
-
*/
|
|
8
|
-
export declare class BaseError extends CustomError {
|
|
9
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
10
|
-
}
|
|
11
|
-
export declare class InvalidArgError extends BaseError {
|
|
12
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Unknown error, mosly probably a bug, unhandled case or coming from a third-party library.
|
|
16
|
-
*/
|
|
17
|
-
export declare class UnknownError extends BaseError {
|
|
18
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
19
|
-
}
|
|
20
|
-
export declare class NullableError extends BaseError {
|
|
21
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
22
|
-
}
|
|
23
|
-
export declare class InvariantError extends BaseError {
|
|
24
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
25
|
-
}
|
|
26
|
-
export declare function nonNullable<T>(value: T, message?: string): NonNullable<T>;
|
|
27
|
-
export declare class RelationRefError extends BaseError {
|
|
28
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
29
|
-
}
|
|
30
|
-
export declare function normalizeError(e: unknown): Error;
|
|
31
|
-
export declare function invariant(condition: any, message?: string): asserts condition;
|
|
32
|
-
export declare class NonExhaustiveError extends BaseError {
|
|
33
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
34
|
-
}
|
|
35
|
-
export declare function nonexhaustive(value: never): never;
|
|
36
|
-
export declare class InvalidModelError extends BaseError {
|
|
37
|
-
constructor(message: string, options?: BaseErrorOptions);
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/errors/index.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { CustomError } from 'ts-custom-error';
|
|
2
|
-
import { isString } from '../utils/guards';
|
|
3
|
-
/**
|
|
4
|
-
* Base class for all errors in the LikeC4 library.
|
|
5
|
-
*/
|
|
6
|
-
export class BaseError extends CustomError {
|
|
7
|
-
constructor(message, options) {
|
|
8
|
-
super(message, options);
|
|
9
|
-
// Set name explicitly as minification can mangle class names
|
|
10
|
-
Object.defineProperty(this, 'name', { value: 'BaseError' });
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export class InvalidArgError extends BaseError {
|
|
14
|
-
constructor(message, options) {
|
|
15
|
-
super(message, options);
|
|
16
|
-
// Set name explicitly as minification can mangle class names
|
|
17
|
-
Object.defineProperty(this, 'name', { value: 'InvalidArgError' });
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Unknown error, mosly probably a bug, unhandled case or coming from a third-party library.
|
|
22
|
-
*/
|
|
23
|
-
export class UnknownError extends BaseError {
|
|
24
|
-
constructor(message, options) {
|
|
25
|
-
super(message, options);
|
|
26
|
-
// Set name explicitly as minification can mangle class names
|
|
27
|
-
Object.defineProperty(this, 'name', { value: 'UnknownError' });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export class NullableError extends BaseError {
|
|
31
|
-
constructor(message, options) {
|
|
32
|
-
super(message, options);
|
|
33
|
-
// Set name explicitly as minification can mangle class names
|
|
34
|
-
Object.defineProperty(this, 'name', { value: 'NullableError' });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export class InvariantError extends BaseError {
|
|
38
|
-
constructor(message, options) {
|
|
39
|
-
super(message, options);
|
|
40
|
-
// Set name explicitly as minification can mangle class names
|
|
41
|
-
Object.defineProperty(this, 'name', { value: 'InvariantError' });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Ensure that the value is NonNullable
|
|
45
|
-
// Mostly as safer `value!`
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
47
|
-
export function nonNullable(value, message) {
|
|
48
|
-
if (typeof value === 'undefined' || value == null) {
|
|
49
|
-
throw new NullableError(message ?? `Expected defined value, but received ${value}`);
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
export class RelationRefError extends BaseError {
|
|
54
|
-
constructor(message, options) {
|
|
55
|
-
super(message, options);
|
|
56
|
-
// Set name explicitly as minification can mangle class names
|
|
57
|
-
Object.defineProperty(this, 'name', { value: 'RelationRefError' });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export function normalizeError(e) {
|
|
61
|
-
if (e instanceof BaseError || e instanceof Error) {
|
|
62
|
-
return e;
|
|
63
|
-
}
|
|
64
|
-
const message = isString(e) ? e : String(e);
|
|
65
|
-
const error = new UnknownError(message);
|
|
66
|
-
try {
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
Error.captureStackTrace(error, normalizeError);
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
// Ignore
|
|
72
|
-
}
|
|
73
|
-
return error;
|
|
74
|
-
}
|
|
75
|
-
// Throw an error if the condition fails
|
|
76
|
-
// > Not providing an inline default argument for message as the result is smaller
|
|
77
|
-
export function invariant(
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
condition,
|
|
80
|
-
// Can provide a string, or a function that returns a string for cases where
|
|
81
|
-
// the message takes a fair amount of effort to compute
|
|
82
|
-
message) {
|
|
83
|
-
if (condition) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
throw new InvariantError(message ?? 'Invariant failed');
|
|
87
|
-
}
|
|
88
|
-
export class NonExhaustiveError extends BaseError {
|
|
89
|
-
constructor(message, options) {
|
|
90
|
-
super(message, options);
|
|
91
|
-
// Set name explicitly as minification can mangle class names
|
|
92
|
-
Object.defineProperty(this, 'name', { value: 'NonExhaustiveError' });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
export function nonexhaustive(value) {
|
|
96
|
-
throw new NonExhaustiveError(`NonExhaustive value: ${value}`);
|
|
97
|
-
}
|
|
98
|
-
export class InvalidModelError extends BaseError {
|
|
99
|
-
constructor(message, options) {
|
|
100
|
-
super(message, options);
|
|
101
|
-
// Set name explicitly as minification can mangle class names
|
|
102
|
-
Object.defineProperty(this, 'name', { value: 'InvalidModelError' });
|
|
103
|
-
}
|
|
104
|
-
}
|
package/dist/index.js
DELETED
package/dist/types/_common.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Opaque } from './opaque';
|
|
2
|
-
export type NonEmptyArray<T> = [T, ...T[]];
|
|
3
|
-
export type IconUrl = Opaque<string, 'IconUrl'>;
|
|
4
|
-
export type Point = readonly [x: number, y: number];
|
|
5
|
-
export interface XYPoint {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=_common.d.ts.map
|
package/dist/types/_common.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/element.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { IconUrl, NonEmptyArray } from './_common';
|
|
2
|
-
import type { Opaque } from './opaque';
|
|
3
|
-
import type { ThemeColor } from './theme';
|
|
4
|
-
export type Fqn = Opaque<string, 'Fqn'>;
|
|
5
|
-
export declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
|
|
6
|
-
export declare const BorderStyles: readonly ["solid", "dashed", "dotted", "none"];
|
|
7
|
-
export type BorderStyle = typeof BorderStyles[number];
|
|
8
|
-
export type ElementKind = Opaque<string, 'ElementKind'>;
|
|
9
|
-
export declare const ElementShapes: readonly ["rectangle", "person", "browser", "mobile", "cylinder", "storage", "queue"];
|
|
10
|
-
export type ElementShape = typeof ElementShapes[number];
|
|
11
|
-
export declare const DefaultThemeColor = "primary";
|
|
12
|
-
export declare const DefaultElementShape = "rectangle";
|
|
13
|
-
export interface ElementStyle {
|
|
14
|
-
border?: BorderStyle;
|
|
15
|
-
opacity?: number;
|
|
16
|
-
}
|
|
17
|
-
export type Tag = Opaque<string, 'Tag'>;
|
|
18
|
-
export interface TagSpec {
|
|
19
|
-
readonly id: Tag;
|
|
20
|
-
readonly style: ElementStyle;
|
|
21
|
-
}
|
|
22
|
-
export interface Link {
|
|
23
|
-
readonly title?: string;
|
|
24
|
-
readonly url: string;
|
|
25
|
-
}
|
|
26
|
-
export interface Element {
|
|
27
|
-
readonly id: Fqn;
|
|
28
|
-
readonly kind: ElementKind;
|
|
29
|
-
readonly title: string;
|
|
30
|
-
readonly description: string | null;
|
|
31
|
-
readonly technology: string | null;
|
|
32
|
-
readonly tags: NonEmptyArray<Tag> | null;
|
|
33
|
-
readonly links: NonEmptyArray<Link> | null;
|
|
34
|
-
readonly icon?: IconUrl;
|
|
35
|
-
readonly shape?: ElementShape;
|
|
36
|
-
readonly color?: ThemeColor;
|
|
37
|
-
readonly style?: ElementStyle;
|
|
38
|
-
readonly notation?: string;
|
|
39
|
-
readonly metadata?: {
|
|
40
|
-
[key: string]: string;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export interface ElementKindSpecificationStyle {
|
|
44
|
-
shape?: ElementShape;
|
|
45
|
-
icon?: IconUrl;
|
|
46
|
-
color?: ThemeColor;
|
|
47
|
-
border?: BorderStyle;
|
|
48
|
-
opacity?: number;
|
|
49
|
-
}
|
|
50
|
-
export interface ElementKindSpecification {
|
|
51
|
-
readonly technology?: string;
|
|
52
|
-
readonly notation?: string;
|
|
53
|
-
readonly style: ElementKindSpecificationStyle;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=element.d.ts.map
|
package/dist/types/element.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function AsFqn(name, parent) {
|
|
2
|
-
return (parent ? parent + '.' + name : name);
|
|
3
|
-
}
|
|
4
|
-
export const BorderStyles = ['solid', 'dashed', 'dotted', 'none'];
|
|
5
|
-
export const ElementShapes = [
|
|
6
|
-
'rectangle',
|
|
7
|
-
'person',
|
|
8
|
-
'browser',
|
|
9
|
-
'mobile',
|
|
10
|
-
'cylinder',
|
|
11
|
-
'storage',
|
|
12
|
-
'queue'
|
|
13
|
-
];
|
|
14
|
-
export const DefaultThemeColor = 'primary';
|
|
15
|
-
export const DefaultElementShape = 'rectangle';
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import type { IconUrl } from './_common';
|
|
2
|
-
import type { BorderStyle, ElementKind, ElementShape, Fqn, Tag } from './element';
|
|
3
|
-
import type { WhereOperator } from './operators';
|
|
4
|
-
import type { RelationshipArrowType, RelationshipLineType } from './relation';
|
|
5
|
-
import type { ThemeColor } from './theme';
|
|
6
|
-
import type { ViewID } from './view';
|
|
7
|
-
interface BaseExpr {
|
|
8
|
-
where?: never;
|
|
9
|
-
element?: never;
|
|
10
|
-
custom?: never;
|
|
11
|
-
expanded?: never;
|
|
12
|
-
elementKind?: never;
|
|
13
|
-
elementTag?: never;
|
|
14
|
-
isEqual?: never;
|
|
15
|
-
isDescedants?: never;
|
|
16
|
-
wildcard?: never;
|
|
17
|
-
source?: never;
|
|
18
|
-
target?: never;
|
|
19
|
-
inout?: never;
|
|
20
|
-
incoming?: never;
|
|
21
|
-
outgoing?: never;
|
|
22
|
-
customRelation?: never;
|
|
23
|
-
}
|
|
24
|
-
export interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isDescedants'> {
|
|
25
|
-
element: Fqn;
|
|
26
|
-
isDescedants?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export declare function isElementRef(expr: Expression): expr is ElementRefExpr;
|
|
29
|
-
export interface ExpandedElementExpr extends Omit<BaseExpr, 'expanded'> {
|
|
30
|
-
expanded: Fqn;
|
|
31
|
-
}
|
|
32
|
-
export declare function isExpandedElementExpr(expr: Expression): expr is ExpandedElementExpr;
|
|
33
|
-
export interface CustomElementExpr extends Omit<BaseExpr, 'custom'> {
|
|
34
|
-
custom: {
|
|
35
|
-
expr: ElementExpression | ElementWhereExpr;
|
|
36
|
-
title?: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
technology?: string;
|
|
39
|
-
notation?: string;
|
|
40
|
-
shape?: ElementShape;
|
|
41
|
-
color?: ThemeColor;
|
|
42
|
-
icon?: IconUrl;
|
|
43
|
-
border?: BorderStyle;
|
|
44
|
-
opacity?: number;
|
|
45
|
-
navigateTo?: ViewID;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export declare function isCustomElement(expr: Expression): expr is CustomElementExpr;
|
|
49
|
-
export interface WildcardExpr extends Omit<BaseExpr, 'wildcard'> {
|
|
50
|
-
wildcard: true;
|
|
51
|
-
}
|
|
52
|
-
export declare function isWildcard(expr: Expression): expr is WildcardExpr;
|
|
53
|
-
export interface ElementKindExpr extends Omit<BaseExpr, 'elementKind' | 'isEqual'> {
|
|
54
|
-
elementKind: ElementKind;
|
|
55
|
-
isEqual: boolean;
|
|
56
|
-
}
|
|
57
|
-
export declare function isElementKindExpr(expr: Expression): expr is ElementKindExpr;
|
|
58
|
-
export interface ElementTagExpr extends Omit<BaseExpr, 'elementTag' | 'isEqual'> {
|
|
59
|
-
elementTag: Tag;
|
|
60
|
-
isEqual: boolean;
|
|
61
|
-
}
|
|
62
|
-
export declare function isElementTagExpr(expr: Expression): expr is ElementTagExpr;
|
|
63
|
-
export type ElementExpression = ElementRefExpr | WildcardExpr | ElementKindExpr | ElementTagExpr | ExpandedElementExpr;
|
|
64
|
-
export declare function isElement(expr: Expression): expr is ElementExpression;
|
|
65
|
-
export interface ElementWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
66
|
-
where: {
|
|
67
|
-
expr: ElementExpression;
|
|
68
|
-
condition: WhereOperator<string, string>;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
export declare function isElementWhere(expr: Expression): expr is ElementWhereExpr;
|
|
72
|
-
export type ElementPredicateExpression = ElementExpression | ElementWhereExpr | CustomElementExpr;
|
|
73
|
-
export declare function isElementPredicateExpr(expr: Expression): expr is ElementPredicateExpression;
|
|
74
|
-
export interface RelationExpr extends Omit<BaseExpr, 'source' | 'target'> {
|
|
75
|
-
source: ElementExpression;
|
|
76
|
-
target: ElementExpression;
|
|
77
|
-
isBidirectional?: boolean;
|
|
78
|
-
}
|
|
79
|
-
export declare function isRelation(expr: Expression): expr is RelationExpr;
|
|
80
|
-
export interface InOutExpr extends Omit<BaseExpr, 'inout'> {
|
|
81
|
-
inout: ElementExpression;
|
|
82
|
-
}
|
|
83
|
-
export declare function isInOut(expr: Expression): expr is InOutExpr;
|
|
84
|
-
export interface IncomingExpr extends Omit<BaseExpr, 'incoming'> {
|
|
85
|
-
incoming: ElementExpression;
|
|
86
|
-
}
|
|
87
|
-
export declare function isIncoming(expr: Expression): expr is IncomingExpr;
|
|
88
|
-
export interface OutgoingExpr extends Omit<BaseExpr, 'outgoing'> {
|
|
89
|
-
outgoing: ElementExpression;
|
|
90
|
-
}
|
|
91
|
-
export declare function isOutgoing(expr: Expression): expr is OutgoingExpr;
|
|
92
|
-
export type RelationExpression = RelationExpr | InOutExpr | IncomingExpr | OutgoingExpr;
|
|
93
|
-
export declare function isRelationExpression(expr: Expression): expr is RelationExpression;
|
|
94
|
-
export interface RelationWhereExpr extends Omit<BaseExpr, 'where'> {
|
|
95
|
-
where: {
|
|
96
|
-
expr: RelationExpression;
|
|
97
|
-
condition: WhereOperator<string, string>;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
export declare function isRelationWhere(expr: Expression): expr is RelationWhereExpr;
|
|
101
|
-
export interface CustomRelationExpr extends Omit<BaseExpr, 'customRelation'> {
|
|
102
|
-
customRelation: {
|
|
103
|
-
relation: RelationExpression | RelationWhereExpr;
|
|
104
|
-
title?: string;
|
|
105
|
-
description?: string;
|
|
106
|
-
technology?: string;
|
|
107
|
-
notation?: string;
|
|
108
|
-
color?: ThemeColor;
|
|
109
|
-
line?: RelationshipLineType;
|
|
110
|
-
head?: RelationshipArrowType;
|
|
111
|
-
tail?: RelationshipArrowType;
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
export declare function isCustomRelationExpr(expr: Expression): expr is CustomRelationExpr;
|
|
115
|
-
export type RelationPredicateExpression = RelationExpression | RelationWhereExpr | CustomRelationExpr;
|
|
116
|
-
export declare function isRelationPredicateExpr(expr: Expression): expr is RelationPredicateExpression;
|
|
117
|
-
export type Expression = ElementPredicateExpression | RelationPredicateExpression;
|
|
118
|
-
export {};
|
|
119
|
-
//# sourceMappingURL=expression.d.ts.map
|