@sneat/core 0.1.3 → 0.1.4
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/esm2022/index.js +2 -0
- package/esm2022/index.js.map +1 -0
- package/esm2022/lib/analytics.interface.js +3 -0
- package/esm2022/lib/analytics.interface.js.map +1 -0
- package/esm2022/lib/animations/form-animations.js +8 -0
- package/esm2022/lib/animations/form-animations.js.map +1 -0
- package/esm2022/lib/animations/index.js +3 -0
- package/esm2022/lib/animations/index.js.map +1 -0
- package/esm2022/lib/animations/list-animations.js +29 -0
- package/esm2022/lib/animations/list-animations.js.map +1 -0
- package/esm2022/lib/app.service.js +3 -0
- package/esm2022/lib/app.service.js.map +1 -0
- package/esm2022/lib/core-models.js +2 -0
- package/esm2022/lib/core-models.js.map +1 -0
- package/esm2022/lib/directives/index.js +2 -0
- package/esm2022/lib/directives/index.js.map +1 -0
- package/esm2022/lib/directives/sneat-select-all-on-focus.directive.js +42 -0
- package/esm2022/lib/directives/sneat-select-all-on-focus.directive.js.map +1 -0
- package/esm2022/lib/environment-config.js +4 -0
- package/esm2022/lib/environment-config.js.map +1 -0
- package/esm2022/lib/eq.js +2 -0
- package/esm2022/lib/eq.js.map +1 -0
- package/esm2022/lib/exclude-undefined.js +43 -0
- package/esm2022/lib/exclude-undefined.js.map +1 -0
- package/esm2022/lib/form-field.js +2 -0
- package/esm2022/lib/form-field.js.map +1 -0
- package/esm2022/lib/index.js +22 -0
- package/esm2022/lib/index.js.map +1 -0
- package/esm2022/lib/interfaces.js +11 -0
- package/esm2022/lib/interfaces.js.map +1 -0
- package/esm2022/lib/location-href.js +6 -0
- package/esm2022/lib/location-href.js.map +1 -0
- package/esm2022/lib/logging/interfaces.js +3 -0
- package/esm2022/lib/logging/interfaces.js.map +1 -0
- package/esm2022/lib/logging.js +16 -0
- package/esm2022/lib/logging.js.map +1 -0
- package/esm2022/lib/nav/index.js +3 -0
- package/esm2022/lib/nav/index.js.map +1 -0
- package/esm2022/lib/nav/nav-context.js +7 -0
- package/esm2022/lib/nav/nav-context.js.map +1 -0
- package/esm2022/lib/nav/routing-state.js +29 -0
- package/esm2022/lib/nav/routing-state.js.map +1 -0
- package/esm2022/lib/services/index.js +4 -0
- package/esm2022/lib/services/index.js.map +1 -0
- package/esm2022/lib/services/ng-module-preloader.service.js +108 -0
- package/esm2022/lib/services/ng-module-preloader.service.js.map +1 -0
- package/esm2022/lib/services/sneat-nav.service.js +41 -0
- package/esm2022/lib/services/sneat-nav.service.js.map +1 -0
- package/esm2022/lib/services/top-menu.service.js +25 -0
- package/esm2022/lib/services/top-menu.service.js.map +1 -0
- package/esm2022/lib/sneat-enum-keys.js +2 -0
- package/esm2022/lib/sneat-enum-keys.js.map +1 -0
- package/esm2022/lib/sneat-extensions.js +38 -0
- package/esm2022/lib/sneat-extensions.js.map +1 -0
- package/esm2022/lib/store.js +42 -0
- package/esm2022/lib/store.js.map +1 -0
- package/esm2022/lib/team-type.js +2 -0
- package/esm2022/lib/team-type.js.map +1 -0
- package/esm2022/lib/types/age-group.js +2 -0
- package/esm2022/lib/types/age-group.js.map +1 -0
- package/{src/lib/types/gender.ts → esm2022/lib/types/gender.js} +1 -7
- package/esm2022/lib/types/gender.js.map +1 -0
- package/esm2022/lib/types/index.js +3 -0
- package/esm2022/lib/types/index.js.map +1 -0
- package/esm2022/lib/utils/datetimes.js +39 -0
- package/esm2022/lib/utils/datetimes.js.map +1 -0
- package/esm2022/lib/utils/index.js +2 -0
- package/esm2022/lib/utils/index.js.map +1 -0
- package/esm2022/sneat-core.js +5 -0
- package/esm2022/sneat-core.js.map +1 -0
- package/lib/analytics.interface.d.ts +12 -0
- package/lib/animations/form-animations.d.ts +1 -0
- package/lib/animations/list-animations.d.ts +3 -0
- package/lib/app.service.d.ts +9 -0
- package/{src/lib/core-models.ts → lib/core-models.d.ts} +4 -6
- package/lib/directives/sneat-select-all-on-focus.directive.d.ts +7 -0
- package/lib/environment-config.d.ts +37 -0
- package/lib/eq.d.ts +1 -0
- package/lib/exclude-undefined.d.ts +6 -0
- package/lib/form-field.d.ts +4 -0
- package/lib/interfaces.d.ts +53 -0
- package/lib/location-href.d.ts +1 -0
- package/lib/logging/interfaces.d.ts +12 -0
- package/lib/logging.d.ts +12 -0
- package/lib/nav/nav-context.d.ts +4 -0
- package/lib/nav/routing-state.d.ts +8 -0
- package/lib/services/ng-module-preloader.service.d.ts +18 -0
- package/lib/services/sneat-nav.service.d.ts +12 -0
- package/lib/services/top-menu.service.d.ts +10 -0
- package/lib/sneat-enum-keys.d.ts +1 -0
- package/lib/sneat-extensions.d.ts +7 -0
- package/lib/store.d.ts +14 -0
- package/lib/team-type.d.ts +2 -0
- package/lib/types/gender.d.ts +6 -0
- package/lib/utils/datetimes.d.ts +7 -0
- package/package.json +14 -2
- package/sneat-core.d.ts +5 -0
- package/eslint.config.js +0 -7
- package/ng-package.json +0 -7
- package/project.json +0 -38
- package/src/lib/analytics.interface.ts +0 -34
- package/src/lib/animations/form-animations.spec.ts +0 -26
- package/src/lib/animations/form-animations.ts +0 -11
- package/src/lib/animations/list-animations.spec.ts +0 -50
- package/src/lib/animations/list-animations.ts +0 -44
- package/src/lib/app.service.ts +0 -33
- package/src/lib/constants.spec.ts +0 -20
- package/src/lib/constants.ts +0 -1
- package/src/lib/directives/sneat-select-all-on-focus.directive.spec.ts +0 -142
- package/src/lib/directives/sneat-select-all-on-focus.directive.ts +0 -36
- package/src/lib/environment-config.ts +0 -54
- package/src/lib/eq.spec.ts +0 -24
- package/src/lib/eq.ts +0 -1
- package/src/lib/exclude-undefined.spec.ts +0 -165
- package/src/lib/exclude-undefined.ts +0 -47
- package/src/lib/form-field.ts +0 -5
- package/src/lib/interfaces.spec.ts +0 -116
- package/src/lib/interfaces.ts +0 -85
- package/src/lib/location-href.spec.ts +0 -53
- package/src/lib/location-href.ts +0 -9
- package/src/lib/logging/interfaces.ts +0 -19
- package/src/lib/logging.spec.ts +0 -132
- package/src/lib/logging.ts +0 -33
- package/src/lib/nav/nav-context.ts +0 -16
- package/src/lib/nav/routing-state.spec.ts +0 -65
- package/src/lib/nav/routing-state.ts +0 -26
- package/src/lib/services/ng-module-preloader.service.spec.ts +0 -72
- package/src/lib/services/ng-module-preloader.service.ts +0 -125
- package/src/lib/services/sneat-nav.service.spec.ts +0 -95
- package/src/lib/services/sneat-nav.service.ts +0 -46
- package/src/lib/services/top-menu.service.spec.ts +0 -42
- package/src/lib/services/top-menu.service.ts +0 -19
- package/src/lib/sneat-enum-keys.ts +0 -2
- package/src/lib/sneat-extensions.spec.ts +0 -127
- package/src/lib/sneat-extensions.ts +0 -49
- package/src/lib/store.spec.ts +0 -156
- package/src/lib/store.ts +0 -54
- package/src/lib/team-type.spec.ts +0 -8
- package/src/lib/team-type.ts +0 -13
- package/src/lib/testing/base-test-setup.ts +0 -247
- package/src/lib/testing/test-setup-light.ts +0 -1
- package/src/lib/testing/test-setup.ts +0 -70
- package/src/lib/types/gender.spec.ts +0 -42
- package/src/lib/utils/datetimes.spec.ts +0 -144
- package/src/lib/utils/datetimes.ts +0 -51
- package/src/test-setup.ts +0 -3
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -19
- package/tsconfig.lib.prod.json +0 -7
- package/tsconfig.spec.json +0 -31
- package/vite.config.mts +0 -10
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/lib/animations/index.ts → lib/animations/index.d.ts} +0 -0
- /package/{src/lib/directives/index.ts → lib/directives/index.d.ts} +0 -0
- /package/{src/lib/index.ts → lib/index.d.ts} +0 -0
- /package/{src/lib/nav/index.ts → lib/nav/index.d.ts} +0 -0
- /package/{src/lib/services/index.ts → lib/services/index.d.ts} +0 -0
- /package/{src/lib/types/age-group.ts → lib/types/age-group.d.ts} +0 -0
- /package/{src/lib/types/index.ts → lib/types/index.d.ts} +0 -0
- /package/{src/lib/utils/index.ts → lib/utils/index.d.ts} +0 -0
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
excludeUndefined,
|
|
4
|
-
excludeEmpty,
|
|
5
|
-
undefinedIfEmpty,
|
|
6
|
-
excludeZeroValues,
|
|
7
|
-
} from './exclude-undefined';
|
|
8
|
-
|
|
9
|
-
describe('excludeUndefined', () => {
|
|
10
|
-
it('should return the same value if input is null', () => {
|
|
11
|
-
expect(excludeUndefined(null)).toBe(null);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should return the same value if input is undefined', () => {
|
|
15
|
-
expect(excludeUndefined(undefined)).toBe(undefined);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should remove undefined values from object', () => {
|
|
19
|
-
const input = { a: 1, b: undefined, c: 'test' };
|
|
20
|
-
const result = excludeUndefined(input);
|
|
21
|
-
expect(result).toEqual({ a: 1, c: 'test' });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should keep null values in object', () => {
|
|
25
|
-
const input = { a: 1, b: null, c: 'test' };
|
|
26
|
-
const result = excludeUndefined(input);
|
|
27
|
-
expect(result).toEqual({ a: 1, b: null, c: 'test' });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should keep empty string values in object', () => {
|
|
31
|
-
const input = { a: 1, b: '', c: 'test' };
|
|
32
|
-
const result = excludeUndefined(input);
|
|
33
|
-
expect(result).toEqual({ a: 1, b: '', c: 'test' });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should keep zero values in object', () => {
|
|
37
|
-
const input = { a: 0, b: 'test' };
|
|
38
|
-
const result = excludeUndefined(input);
|
|
39
|
-
expect(result).toEqual({ a: 0, b: 'test' });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should handle empty object', () => {
|
|
43
|
-
const input = {};
|
|
44
|
-
const result = excludeUndefined(input);
|
|
45
|
-
expect(result).toEqual({});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('excludeEmpty', () => {
|
|
50
|
-
it('should return the same value if input is null', () => {
|
|
51
|
-
expect(excludeEmpty(null)).toBe(null);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should return the same value if input is undefined', () => {
|
|
55
|
-
expect(excludeEmpty(undefined)).toBe(undefined);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should remove undefined values from object', () => {
|
|
59
|
-
const input = { a: 1, b: undefined, c: 'test' };
|
|
60
|
-
const result = excludeEmpty(input);
|
|
61
|
-
expect(result).toEqual({ a: 1, c: 'test' });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should remove empty string values from object', () => {
|
|
65
|
-
const input = { a: 1, b: '', c: 'test' };
|
|
66
|
-
const result = excludeEmpty(input);
|
|
67
|
-
expect(result).toEqual({ a: 1, c: 'test' });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should keep null values in object', () => {
|
|
71
|
-
const input = { a: 1, b: null, c: 'test' };
|
|
72
|
-
const result = excludeEmpty(input);
|
|
73
|
-
expect(result).toEqual({ a: 1, b: null, c: 'test' });
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should keep zero values in object', () => {
|
|
77
|
-
const input = { a: 0, b: 'test' };
|
|
78
|
-
const result = excludeEmpty(input);
|
|
79
|
-
expect(result).toEqual({ a: 0, b: 'test' });
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('should handle empty object', () => {
|
|
83
|
-
const input = {};
|
|
84
|
-
const result = excludeEmpty(input);
|
|
85
|
-
expect(result).toEqual({});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('undefinedIfEmpty', () => {
|
|
90
|
-
it('should return the same value if input is null', () => {
|
|
91
|
-
expect(undefinedIfEmpty(null as unknown as Record<string, unknown>)).toBe(
|
|
92
|
-
null,
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should return the same value if input is undefined', () => {
|
|
97
|
-
expect(
|
|
98
|
-
undefinedIfEmpty(undefined as unknown as Record<string, unknown>),
|
|
99
|
-
).toBe(undefined);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should return undefined for empty object', () => {
|
|
103
|
-
const input = {};
|
|
104
|
-
const result = undefinedIfEmpty(input);
|
|
105
|
-
expect(result).toBe(undefined);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should return the object if not empty', () => {
|
|
109
|
-
const input = { a: 1, b: 'test' };
|
|
110
|
-
const result = undefinedIfEmpty(input);
|
|
111
|
-
expect(result).toEqual({ a: 1, b: 'test' });
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should return the object with undefined values', () => {
|
|
115
|
-
const input = { a: undefined, b: undefined };
|
|
116
|
-
const result = undefinedIfEmpty(input);
|
|
117
|
-
expect(result).toEqual({ a: undefined, b: undefined });
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe('excludeZeroValues', () => {
|
|
122
|
-
it('should return the same value if input is null', () => {
|
|
123
|
-
expect(excludeZeroValues(null)).toBe(null);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('should return the same value if input is undefined', () => {
|
|
127
|
-
expect(excludeZeroValues(undefined)).toBe(undefined);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('should remove zero values from object', () => {
|
|
131
|
-
const input = { a: 0, b: 1, c: 'test' };
|
|
132
|
-
const result = excludeZeroValues(input);
|
|
133
|
-
expect(result).toEqual({ b: 1, c: 'test' });
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('should remove undefined values from object', () => {
|
|
137
|
-
const input = { a: 1, b: undefined, c: 'test' };
|
|
138
|
-
const result = excludeZeroValues(input);
|
|
139
|
-
expect(result).toEqual({ a: 1, c: 'test' });
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should keep empty string values in object', () => {
|
|
143
|
-
const input = { a: 1, b: '', c: 'test' };
|
|
144
|
-
const result = excludeZeroValues(input);
|
|
145
|
-
expect(result).toEqual({ a: 1, b: '', c: 'test' });
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should keep null values in object', () => {
|
|
149
|
-
const input = { a: 1, b: null, c: 'test' };
|
|
150
|
-
const result = excludeZeroValues(input);
|
|
151
|
-
expect(result).toEqual({ a: 1, b: null, c: 'test' });
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('should handle empty object', () => {
|
|
155
|
-
const input = {};
|
|
156
|
-
const result = excludeZeroValues(input);
|
|
157
|
-
expect(result).toEqual({});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should handle multiple zero values', () => {
|
|
161
|
-
const input = { a: 0, b: 0, c: 1 };
|
|
162
|
-
const result = excludeZeroValues(input);
|
|
163
|
-
expect(result).toEqual({ c: 1 });
|
|
164
|
-
});
|
|
165
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
type O = Record<string, unknown>;
|
|
2
|
-
|
|
3
|
-
export function excludeUndefined<T>(o: T): T {
|
|
4
|
-
if (!o) {
|
|
5
|
-
return o;
|
|
6
|
-
}
|
|
7
|
-
return Object.keys(o).reduce((r, k) => {
|
|
8
|
-
const v = (o as unknown as O)[k];
|
|
9
|
-
if (v !== undefined) {
|
|
10
|
-
r[k] = v;
|
|
11
|
-
}
|
|
12
|
-
return r;
|
|
13
|
-
}, {} as O) as unknown as T;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function excludeEmpty<T>(o: T): T {
|
|
17
|
-
if (!o) {
|
|
18
|
-
return o;
|
|
19
|
-
}
|
|
20
|
-
return Object.keys(o).reduce((r, k) => {
|
|
21
|
-
const v = (o as unknown as O)[k];
|
|
22
|
-
if (v !== undefined && v !== '') {
|
|
23
|
-
r[k] = v;
|
|
24
|
-
}
|
|
25
|
-
return r;
|
|
26
|
-
}, {} as O) as unknown as T;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function undefinedIfEmpty<T extends O>(o: T): T | undefined {
|
|
30
|
-
if (!o) {
|
|
31
|
-
return o;
|
|
32
|
-
}
|
|
33
|
-
return Object.keys(o).length === 0 ? undefined : o;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function excludeZeroValues<T>(o: T): T {
|
|
37
|
-
if (!o) {
|
|
38
|
-
return o;
|
|
39
|
-
}
|
|
40
|
-
return Object.keys(o).reduce((r, k) => {
|
|
41
|
-
const v = (o as unknown as O)[k];
|
|
42
|
-
if (v !== undefined && v !== 0) {
|
|
43
|
-
r[k] = v;
|
|
44
|
-
}
|
|
45
|
-
return r;
|
|
46
|
-
}, {} as O) as unknown as T;
|
|
47
|
-
}
|
package/src/lib/form-field.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
equalSpaceRefs,
|
|
4
|
-
emptySpaceRef,
|
|
5
|
-
spaceItemBriefWithSpaceRefFromBrief,
|
|
6
|
-
type ISpaceRef,
|
|
7
|
-
} from './interfaces';
|
|
8
|
-
|
|
9
|
-
describe('interfaces', () => {
|
|
10
|
-
describe('emptySpaceRef', () => {
|
|
11
|
-
it('should have empty id', () => {
|
|
12
|
-
expect(emptySpaceRef.id).toBe('');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should not have type', () => {
|
|
16
|
-
expect(emptySpaceRef.type).toBeUndefined();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('equalSpaceRefs', () => {
|
|
21
|
-
it('should return true for identical objects', () => {
|
|
22
|
-
const ref: ISpaceRef = { id: 'space1', type: 'family' };
|
|
23
|
-
expect(equalSpaceRefs(ref, ref)).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should return true for null compared to null', () => {
|
|
27
|
-
expect(equalSpaceRefs(null, null)).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('should return true for undefined compared to undefined', () => {
|
|
31
|
-
expect(equalSpaceRefs(undefined, undefined)).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should return true for same id and type', () => {
|
|
35
|
-
const ref1: ISpaceRef = { id: 'space1', type: 'family' };
|
|
36
|
-
const ref2: ISpaceRef = { id: 'space1', type: 'family' };
|
|
37
|
-
expect(equalSpaceRefs(ref1, ref2)).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should return true for same id without type', () => {
|
|
41
|
-
const ref1: ISpaceRef = { id: 'space1' };
|
|
42
|
-
const ref2: ISpaceRef = { id: 'space1' };
|
|
43
|
-
expect(equalSpaceRefs(ref1, ref2)).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should return false for different ids', () => {
|
|
47
|
-
const ref1: ISpaceRef = { id: 'space1', type: 'family' };
|
|
48
|
-
const ref2: ISpaceRef = { id: 'space2', type: 'family' };
|
|
49
|
-
expect(equalSpaceRefs(ref1, ref2)).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should return false for different types', () => {
|
|
53
|
-
const ref1: ISpaceRef = { id: 'space1', type: 'family' };
|
|
54
|
-
const ref2: ISpaceRef = { id: 'space1', type: 'team' };
|
|
55
|
-
expect(equalSpaceRefs(ref1, ref2)).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should return false when comparing null to non-null', () => {
|
|
59
|
-
const ref: ISpaceRef = { id: 'space1' };
|
|
60
|
-
expect(equalSpaceRefs(null, ref)).toBe(false);
|
|
61
|
-
expect(equalSpaceRefs(ref, null)).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should return false when comparing undefined to defined', () => {
|
|
65
|
-
const ref: ISpaceRef = { id: 'space1' };
|
|
66
|
-
expect(equalSpaceRefs(undefined, ref)).toBe(false);
|
|
67
|
-
expect(equalSpaceRefs(ref, undefined)).toBe(false);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should return false for one with type and one without', () => {
|
|
71
|
-
const ref1: ISpaceRef = { id: 'space1', type: 'family' };
|
|
72
|
-
const ref2: ISpaceRef = { id: 'space1' };
|
|
73
|
-
expect(equalSpaceRefs(ref1, ref2)).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('spaceItemBriefWithSpaceRefFromBrief', () => {
|
|
78
|
-
it('should create space item with brief', () => {
|
|
79
|
-
const space: ISpaceRef = { id: 'space1', type: 'family' };
|
|
80
|
-
const brief = { name: 'Test Item' };
|
|
81
|
-
const result = spaceItemBriefWithSpaceRefFromBrief(space, 'item1', brief);
|
|
82
|
-
|
|
83
|
-
expect(result.id).toBe('item1');
|
|
84
|
-
expect(result.space).toBe(space);
|
|
85
|
-
expect(result.brief).toBe(brief);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('should preserve space reference', () => {
|
|
89
|
-
const space: ISpaceRef = { id: 'space2', type: 'team' };
|
|
90
|
-
const brief = { title: 'Project' };
|
|
91
|
-
const result = spaceItemBriefWithSpaceRefFromBrief(space, 'proj1', brief);
|
|
92
|
-
|
|
93
|
-
expect(result.space.id).toBe('space2');
|
|
94
|
-
expect(result.space.type).toBe('team');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should work with any brief type', () => {
|
|
98
|
-
const space: ISpaceRef = { id: 'space3' };
|
|
99
|
-
const brief = { count: 42, active: true };
|
|
100
|
-
const result = spaceItemBriefWithSpaceRefFromBrief(space, 'id123', brief);
|
|
101
|
-
|
|
102
|
-
expect(result.id).toBe('id123');
|
|
103
|
-
expect(result.brief.count).toBe(42);
|
|
104
|
-
expect(result.brief.active).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should work with empty brief', () => {
|
|
108
|
-
const space: ISpaceRef = { id: 'space4' };
|
|
109
|
-
const brief = {};
|
|
110
|
-
const result = spaceItemBriefWithSpaceRefFromBrief(space, 'empty', brief);
|
|
111
|
-
|
|
112
|
-
expect(result.id).toBe('empty');
|
|
113
|
-
expect(result.brief).toEqual({});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
package/src/lib/interfaces.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { SpaceType } from './team-type';
|
|
2
|
-
|
|
3
|
-
export interface ISpaceRef {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
readonly type?: SpaceType;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function equalSpaceRefs(
|
|
9
|
-
v1?: ISpaceRef | null,
|
|
10
|
-
v2?: ISpaceRef | null,
|
|
11
|
-
): boolean {
|
|
12
|
-
if (v1 === v2) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return v1?.id === v2?.id && v1?.type === v2?.type;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const emptySpaceRef: ISpaceRef = { id: '' };
|
|
19
|
-
|
|
20
|
-
export interface IIdAndBrief<Brief> {
|
|
21
|
-
readonly id: string;
|
|
22
|
-
readonly brief: Brief;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface IIdAndBriefWithSpaceRef<Brief> {
|
|
26
|
-
readonly id: string;
|
|
27
|
-
readonly brief: Brief;
|
|
28
|
-
readonly space: ISpaceRef;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface IIdAndOptionalBrief<Brief> {
|
|
32
|
-
readonly id: string;
|
|
33
|
-
readonly brief?: Brief | null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface IIdAndOptionalDbo<Dbo> {
|
|
37
|
-
readonly id: string;
|
|
38
|
-
readonly dbo?: Dbo | null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface IIdAndDbo<Dbo> {
|
|
42
|
-
readonly id: string;
|
|
43
|
-
readonly dbo: Dbo;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface IIdAndOptionalBriefAndOptionalDbo<Brief, Dbo extends Brief> {
|
|
47
|
-
readonly id: string;
|
|
48
|
-
readonly brief?: Brief | null;
|
|
49
|
-
readonly dbo?: Dbo | null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface IIdAndBriefAndOptionalDbo<Brief, Dbo extends Brief> {
|
|
53
|
-
readonly id: string;
|
|
54
|
-
readonly brief: Brief;
|
|
55
|
-
readonly dbo?: Dbo | null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface IIdAndBriefAndDbo<Brief, Dbo extends Brief> {
|
|
59
|
-
readonly id: string;
|
|
60
|
-
readonly brief: Brief;
|
|
61
|
-
readonly dbo: Dbo;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface ISpaceItemWithBriefAndDbo<
|
|
65
|
-
Brief,
|
|
66
|
-
Dbo extends Brief,
|
|
67
|
-
> extends IIdAndBriefAndDbo<Brief, Dbo> {
|
|
68
|
-
readonly space: ISpaceRef;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface ISpaceItemBriefWithSpace<Brief> extends IIdAndBrief<Brief> {
|
|
72
|
-
readonly space: ISpaceRef;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function spaceItemBriefWithSpaceRefFromBrief<Brief>(
|
|
76
|
-
space: ISpaceRef,
|
|
77
|
-
id: string,
|
|
78
|
-
brief: Brief,
|
|
79
|
-
): ISpaceItemBriefWithSpace<Brief> {
|
|
80
|
-
return { id, brief, space };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface IIdAndDboWithSpaceRef<Dbo> extends IIdAndDbo<Dbo> {
|
|
84
|
-
space: ISpaceRef;
|
|
85
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { setHrefQueryParam } from './location-href';
|
|
3
|
-
|
|
4
|
-
describe('setHrefQueryParam', () => {
|
|
5
|
-
it('should add query param to URL without existing params', () => {
|
|
6
|
-
const href = 'https://example.com/path';
|
|
7
|
-
const result = setHrefQueryParam('foo', 'bar', href);
|
|
8
|
-
expect(result).toBe('https://example.com/path?foo=bar');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('should add query param to URL with existing params', () => {
|
|
12
|
-
const href = 'https://example.com/path?existing=value';
|
|
13
|
-
const result = setHrefQueryParam('foo', 'bar', href);
|
|
14
|
-
expect(result).toBe('https://example.com/path?existing=value&foo=bar');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should update existing query param', () => {
|
|
18
|
-
const href = 'https://example.com/path?foo=old';
|
|
19
|
-
const result = setHrefQueryParam('foo', 'new', href);
|
|
20
|
-
expect(result).toBe('https://example.com/path?foo=new');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should handle special characters in param value', () => {
|
|
24
|
-
const href = 'https://example.com/path';
|
|
25
|
-
const result = setHrefQueryParam('foo', 'hello world', href);
|
|
26
|
-
expect(result).toBe('https://example.com/path?foo=hello+world');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should handle empty string value', () => {
|
|
30
|
-
const href = 'https://example.com/path';
|
|
31
|
-
const result = setHrefQueryParam('foo', '', href);
|
|
32
|
-
expect(result).toBe('https://example.com/path?foo=');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should preserve hash in URL', () => {
|
|
36
|
-
const href = 'https://example.com/path#section';
|
|
37
|
-
const result = setHrefQueryParam('foo', 'bar', href);
|
|
38
|
-
expect(result).toBe('https://example.com/path?foo=bar#section');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should work with localhost', () => {
|
|
42
|
-
const href = 'http://localhost:4200/path';
|
|
43
|
-
const result = setHrefQueryParam('test', 'value', href);
|
|
44
|
-
expect(result).toBe('http://localhost:4200/path?test=value');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should handle multiple updates to same URL', () => {
|
|
48
|
-
const href = 'https://example.com/path';
|
|
49
|
-
const result1 = setHrefQueryParam('foo', 'bar', href);
|
|
50
|
-
const result2 = setHrefQueryParam('baz', 'qux', result1);
|
|
51
|
-
expect(result2).toBe('https://example.com/path?foo=bar&baz=qux');
|
|
52
|
-
});
|
|
53
|
-
});
|
package/src/lib/location-href.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export interface ILogErrorOptions {
|
|
4
|
-
readonly report?: boolean;
|
|
5
|
-
readonly feedback?: boolean;
|
|
6
|
-
readonly show?: boolean;
|
|
7
|
-
readonly showDuration?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface IErrorLogger {
|
|
11
|
-
logError(e: unknown, message?: string, options?: ILogErrorOptions): void;
|
|
12
|
-
|
|
13
|
-
logErrorHandler(
|
|
14
|
-
message?: string,
|
|
15
|
-
options?: ILogErrorOptions,
|
|
16
|
-
): (error: unknown) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const ErrorLogger = new InjectionToken<IErrorLogger>('IErrorLogger');
|
package/src/lib/logging.spec.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { loggerFactory } from './logging';
|
|
3
|
-
|
|
4
|
-
describe('loggerFactory', () => {
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
// Clear all mocks before each test
|
|
7
|
-
vi.clearAllMocks();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should throw error when logger name is empty string', () => {
|
|
11
|
-
expect(() => loggerFactory.getLogger('')).toThrow(
|
|
12
|
-
'Logger name is required',
|
|
13
|
-
);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should throw error when logger name is null', () => {
|
|
17
|
-
expect(() => loggerFactory.getLogger(null as unknown as string)).toThrow(
|
|
18
|
-
'Logger name is required',
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should throw error when logger name is undefined', () => {
|
|
23
|
-
expect(() =>
|
|
24
|
-
loggerFactory.getLogger(undefined as unknown as string),
|
|
25
|
-
).toThrow('Logger name is required');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should return logger with valid name', () => {
|
|
29
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
30
|
-
expect(logger).toBeDefined();
|
|
31
|
-
expect(logger.debug).toBeDefined();
|
|
32
|
-
expect(logger.info).toBeDefined();
|
|
33
|
-
expect(logger.warn).toBeDefined();
|
|
34
|
-
expect(logger.error).toBeDefined();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should have debug method that calls console.log', () => {
|
|
38
|
-
const consoleSpy = vi
|
|
39
|
-
.spyOn(console, 'log')
|
|
40
|
-
.mockImplementation(() => undefined);
|
|
41
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
42
|
-
|
|
43
|
-
logger.debug('test message');
|
|
44
|
-
|
|
45
|
-
expect(consoleSpy).toHaveBeenCalledWith('test message');
|
|
46
|
-
consoleSpy.mockRestore();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should have info method that calls console.log', () => {
|
|
50
|
-
const consoleSpy = vi
|
|
51
|
-
.spyOn(console, 'log')
|
|
52
|
-
.mockImplementation(() => undefined);
|
|
53
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
54
|
-
|
|
55
|
-
logger.info('info message');
|
|
56
|
-
|
|
57
|
-
expect(consoleSpy).toHaveBeenCalledWith('info message');
|
|
58
|
-
consoleSpy.mockRestore();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should have warn method that calls console.warn', () => {
|
|
62
|
-
const consoleSpy = vi
|
|
63
|
-
.spyOn(console, 'warn')
|
|
64
|
-
.mockImplementation(() => undefined);
|
|
65
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
66
|
-
|
|
67
|
-
logger.warn('warn message');
|
|
68
|
-
|
|
69
|
-
expect(consoleSpy).toHaveBeenCalledWith('warn message');
|
|
70
|
-
consoleSpy.mockRestore();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should have error method that calls console.error', () => {
|
|
74
|
-
const consoleSpy = vi
|
|
75
|
-
.spyOn(console, 'error')
|
|
76
|
-
.mockImplementation(() => undefined);
|
|
77
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
78
|
-
|
|
79
|
-
logger.error('error message');
|
|
80
|
-
|
|
81
|
-
expect(consoleSpy).toHaveBeenCalledWith('error message');
|
|
82
|
-
consoleSpy.mockRestore();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should handle multiple arguments in debug', () => {
|
|
86
|
-
const consoleSpy = vi
|
|
87
|
-
.spyOn(console, 'log')
|
|
88
|
-
.mockImplementation(() => undefined);
|
|
89
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
90
|
-
|
|
91
|
-
logger.debug('message', { data: 'test' }, 123);
|
|
92
|
-
|
|
93
|
-
expect(consoleSpy).toHaveBeenCalledWith('message', { data: 'test' }, 123);
|
|
94
|
-
consoleSpy.mockRestore();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should handle multiple arguments in info', () => {
|
|
98
|
-
const consoleSpy = vi
|
|
99
|
-
.spyOn(console, 'log')
|
|
100
|
-
.mockImplementation(() => undefined);
|
|
101
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
102
|
-
|
|
103
|
-
logger.info('message', { data: 'test' }, 123);
|
|
104
|
-
|
|
105
|
-
expect(consoleSpy).toHaveBeenCalledWith('message', { data: 'test' }, 123);
|
|
106
|
-
consoleSpy.mockRestore();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should handle multiple arguments in warn', () => {
|
|
110
|
-
const consoleSpy = vi
|
|
111
|
-
.spyOn(console, 'warn')
|
|
112
|
-
.mockImplementation(() => undefined);
|
|
113
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
114
|
-
|
|
115
|
-
logger.warn('message', { data: 'test' }, 123);
|
|
116
|
-
|
|
117
|
-
expect(consoleSpy).toHaveBeenCalledWith('message', { data: 'test' }, 123);
|
|
118
|
-
consoleSpy.mockRestore();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should handle multiple arguments in error', () => {
|
|
122
|
-
const consoleSpy = vi
|
|
123
|
-
.spyOn(console, 'error')
|
|
124
|
-
.mockImplementation(() => undefined);
|
|
125
|
-
const logger = loggerFactory.getLogger('test-logger');
|
|
126
|
-
|
|
127
|
-
logger.error('message', { data: 'test' }, 123);
|
|
128
|
-
|
|
129
|
-
expect(consoleSpy).toHaveBeenCalledWith('message', { data: 'test' }, 123);
|
|
130
|
-
consoleSpy.mockRestore();
|
|
131
|
-
});
|
|
132
|
-
});
|
package/src/lib/logging.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export interface ILogger {
|
|
4
|
-
debug(...v: unknown[]): void;
|
|
5
|
-
|
|
6
|
-
info(...v: unknown[]): void;
|
|
7
|
-
|
|
8
|
-
warn(...v: unknown[]): void;
|
|
9
|
-
|
|
10
|
-
error(...v: unknown[]): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ILoggerFactory {
|
|
14
|
-
getLogger(name: string): ILogger;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const LOGGER_FACTORY = new InjectionToken<ILoggerFactory>(
|
|
18
|
-
'loggerFactory',
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export const loggerFactory: ILoggerFactory = {
|
|
22
|
-
getLogger(name: string): ILogger {
|
|
23
|
-
if (!name) {
|
|
24
|
-
throw new Error('Logger name is required');
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
debug: console.log,
|
|
28
|
-
info: console.log,
|
|
29
|
-
error: console.error,
|
|
30
|
-
warn: console.warn,
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IIdAndOptionalBriefAndOptionalDbo } from '../interfaces';
|
|
2
|
-
|
|
3
|
-
export type SpaceItem = 'happening' | 'contact' | 'document' | 'asset' | 'list';
|
|
4
|
-
|
|
5
|
-
export type DeleteOperationState = 'deleting' | 'deleted' | undefined;
|
|
6
|
-
|
|
7
|
-
export type INavContext<
|
|
8
|
-
Brief,
|
|
9
|
-
Dbo extends Brief,
|
|
10
|
-
> = IIdAndOptionalBriefAndOptionalDbo<Brief, Dbo>;
|
|
11
|
-
|
|
12
|
-
// export interface INavContext<Brief, Dto> {
|
|
13
|
-
// readonly id: string;
|
|
14
|
-
// readonly brief?: Brief | null;
|
|
15
|
-
// readonly dto?: Dto | null;
|
|
16
|
-
// }
|