@linagora/linid-im-front-corelib 0.0.6 → 0.0.8

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 (52) hide show
  1. package/README.md +3 -3
  2. package/dist/core-lib.es.js +3 -2
  3. package/dist/core-lib.umd.js +3 -3
  4. package/dist/package.json +13 -9
  5. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  6. package/dist/types/src/index.d.ts +2 -1
  7. package/package.json +13 -9
  8. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -83
  9. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -90
  10. package/.github/ISSUE_TEMPLATE/question.yml +0 -31
  11. package/.github/ISSUE_TEMPLATE/security.yml +0 -69
  12. package/.github/actions/setup-node-pnpm/action.yml +0 -29
  13. package/.github/workflows/pull-request.yml +0 -147
  14. package/.github/workflows/release.yml +0 -90
  15. package/.prettierignore +0 -7
  16. package/.prettierrc.json +0 -5
  17. package/.vscode/extensions.json +0 -3
  18. package/.vscode/settings.json +0 -9
  19. package/CHANGELOG.md +0 -51
  20. package/CONTRIBUTING.md +0 -269
  21. package/COPYRIGHT +0 -23
  22. package/docs/components-plugin-zones.md +0 -168
  23. package/docs/helpers.md +0 -188
  24. package/docs/module-lifecycle.md +0 -717
  25. package/docs/services.md +0 -39
  26. package/docs/types-and-interfaces.md +0 -139
  27. package/eslint.config.js +0 -136
  28. package/src/components/LinidZoneRenderer.vue +0 -77
  29. package/src/index.ts +0 -62
  30. package/src/lifecycle/skeleton.ts +0 -147
  31. package/src/services/federationService.ts +0 -44
  32. package/src/services/httpClientService.ts +0 -61
  33. package/src/services/linIdConfigurationService.ts +0 -73
  34. package/src/stores/linIdConfigurationStore.ts +0 -116
  35. package/src/stores/linidZoneStore.ts +0 -62
  36. package/src/types/linidConfiguration.ts +0 -70
  37. package/src/types/linidZone.ts +0 -48
  38. package/src/types/module.ts +0 -96
  39. package/src/types/moduleLifecycle.ts +0 -154
  40. package/tests/unit/components/LinidZoneRenderer.spec.js +0 -135
  41. package/tests/unit/lifecycle/skeleton.spec.js +0 -138
  42. package/tests/unit/services/federationService.spec.js +0 -146
  43. package/tests/unit/services/httpClientService.spec.js +0 -49
  44. package/tests/unit/services/linIdConfigurationService.spec.js +0 -113
  45. package/tests/unit/stores/linIdConfigurationStore.spec.js +0 -171
  46. package/tests/unit/stores/linidZoneStore.spec.js +0 -94
  47. package/tsconfig.json +0 -14
  48. package/tsconfig.lib.json +0 -20
  49. package/tsconfig.node.json +0 -9
  50. package/tsconfig.spec.json +0 -16
  51. package/vite.config.ts +0 -37
  52. package/vitest.config.ts +0 -19
@@ -1,113 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from 'vitest';
2
- import {
3
- getEntitiesConfiguration,
4
- getEntityConfiguration,
5
- getRoutesConfiguration,
6
- } from 'src/services/linIdConfigurationService';
7
- import * as httpClientService from 'src/services/httpClientService';
8
-
9
- vi.mock('src/services/httpClientService', () => ({
10
- getHttpClient: vi.fn(),
11
- }));
12
-
13
- describe('Test service: linIdConfigurationService', () => {
14
- let mockHttpClient;
15
-
16
- beforeEach(() => {
17
- mockHttpClient = {
18
- get: vi.fn(),
19
- };
20
- vi.mocked(httpClientService.getHttpClient).mockReturnValue(mockHttpClient);
21
- vi.clearAllMocks();
22
- });
23
-
24
- describe('Test function: getEntitiesConfiguration', () => {
25
- it('should fetch all entities from /metadata/entities', async () => {
26
- const mockEntities = [
27
- { name: 'user', attributes: [] },
28
- { name: 'group', attributes: [] },
29
- ];
30
- mockHttpClient.get.mockResolvedValue({ data: mockEntities });
31
-
32
- const result = await getEntitiesConfiguration();
33
-
34
- expect(httpClientService.getHttpClient).toHaveBeenCalled();
35
- expect(mockHttpClient.get).toHaveBeenCalledWith('/metadata/entities');
36
- expect(result).toEqual(mockEntities);
37
- });
38
-
39
- it('should propagate errors from HTTP client', async () => {
40
- const error = new Error('Network error');
41
- mockHttpClient.get.mockRejectedValue(error);
42
-
43
- await expect(getEntitiesConfiguration()).rejects.toThrow('Network error');
44
- });
45
- });
46
-
47
- describe('Test function: getEntityConfiguration', () => {
48
- it('should fetch a specific entity from /metadata/entities/:entity', async () => {
49
- const mockEntity = {
50
- name: 'user',
51
- attributes: [
52
- {
53
- name: 'email',
54
- type: 'string',
55
- required: true,
56
- hasValidations: false,
57
- input: 'text',
58
- inputSettings: {},
59
- },
60
- ],
61
- };
62
- mockHttpClient.get.mockResolvedValue({ data: mockEntity });
63
-
64
- const result = await getEntityConfiguration('user');
65
-
66
- expect(mockHttpClient.get).toHaveBeenCalledWith(
67
- '/metadata/entities/user'
68
- );
69
- expect(result).toEqual(mockEntity);
70
- });
71
-
72
- it('should handle special characters in entity ID', async () => {
73
- const mockEntity = { name: 'my-entity', attributes: [] };
74
- mockHttpClient.get.mockResolvedValue({ data: mockEntity });
75
-
76
- const result = await getEntityConfiguration('my-entity');
77
-
78
- expect(mockHttpClient.get).toHaveBeenCalledWith(
79
- '/metadata/entities/my-entity'
80
- );
81
- expect(result).toEqual(mockEntity);
82
- });
83
-
84
- it('should propagate errors from HTTP client', async () => {
85
- mockHttpClient.get.mockRejectedValue(new Error('Not found'));
86
-
87
- await expect(getEntityConfiguration('unknown')).rejects.toThrow(
88
- 'Not found'
89
- );
90
- });
91
- });
92
-
93
- describe('Test function: getRoutesConfiguration', () => {
94
- it('should fetch all routes from /metadata/routes', async () => {
95
- const mockRoutes = [
96
- { method: 'GET', path: '/users', entity: 'user', variables: [] },
97
- { method: 'POST', path: '/users', entity: 'user', variables: [] },
98
- ];
99
- mockHttpClient.get.mockResolvedValue({ data: mockRoutes });
100
-
101
- const result = await getRoutesConfiguration();
102
-
103
- expect(mockHttpClient.get).toHaveBeenCalledWith('/metadata/routes');
104
- expect(result).toEqual(mockRoutes);
105
- });
106
-
107
- it('should propagate errors from HTTP client', async () => {
108
- mockHttpClient.get.mockRejectedValue(new Error('Server error'));
109
-
110
- await expect(getRoutesConfiguration()).rejects.toThrow('Server error');
111
- });
112
- });
113
- });
@@ -1,171 +0,0 @@
1
- import { createPinia, setActivePinia } from 'pinia';
2
- import { useLinIdConfigurationStore } from 'src/stores/linIdConfigurationStore';
3
- import * as linIdConfigurationService from 'src/services/linIdConfigurationService';
4
- import { beforeEach, describe, expect, it, vi } from 'vitest';
5
-
6
- vi.mock('src/services/linIdConfigurationService', () => ({
7
- getEntitiesConfiguration: vi.fn(),
8
- getRoutesConfiguration: vi.fn(),
9
- }));
10
-
11
- describe('Test store: linIdConfigurationStore', () => {
12
- let store;
13
-
14
- beforeEach(() => {
15
- setActivePinia(createPinia());
16
- store = useLinIdConfigurationStore();
17
- vi.clearAllMocks();
18
- });
19
-
20
- describe('Test initial state', () => {
21
- it('should have empty initial state', () => {
22
- expect(store.entities).toEqual([]);
23
- expect(store.routes).toEqual([]);
24
- expect(store.loading).toBe(false);
25
- expect(store.error).toBeNull();
26
- });
27
- });
28
-
29
- describe('Test getter: getEntityByName', () => {
30
- it('should return undefined when entity is not found', () => {
31
- store.entities = [{ name: 'user', attributes: [] }];
32
-
33
- const result = store.getEntityByName('unknown');
34
-
35
- expect(result).toBeUndefined();
36
- });
37
-
38
- it('should return the entity when found', () => {
39
- const userEntity = { name: 'user', attributes: [{ name: 'email' }] };
40
- store.entities = [userEntity, { name: 'group', attributes: [] }];
41
-
42
- const result = store.getEntityByName('user');
43
-
44
- expect(result).toEqual(userEntity);
45
- });
46
- });
47
-
48
- describe('Test getter: getRoutesByEntity', () => {
49
- it('should return empty array when no routes match', () => {
50
- store.routes = [
51
- { method: 'GET', path: '/groups', entity: 'group', variables: [] },
52
- ];
53
-
54
- const result = store.getRoutesByEntity('user');
55
-
56
- expect(result).toEqual([]);
57
- });
58
-
59
- it('should return all routes for the specified entity', () => {
60
- const userRoutes = [
61
- { method: 'GET', path: '/users', entity: 'user', variables: [] },
62
- { method: 'POST', path: '/users', entity: 'user', variables: [] },
63
- ];
64
- store.routes = [
65
- ...userRoutes,
66
- { method: 'GET', path: '/groups', entity: 'group', variables: [] },
67
- ];
68
-
69
- const result = store.getRoutesByEntity('user');
70
-
71
- expect(result).toEqual(userRoutes);
72
- });
73
- });
74
-
75
- describe('Test action: fetchConfiguration', () => {
76
- it('should fetch entities and routes successfully', async () => {
77
- const mockEntities = [{ name: 'user', attributes: [] }];
78
- const mockRoutes = [
79
- { method: 'GET', path: '/users', entity: 'user', variables: [] },
80
- ];
81
-
82
- vi.mocked(
83
- linIdConfigurationService.getEntitiesConfiguration
84
- ).mockResolvedValue(mockEntities);
85
- vi.mocked(
86
- linIdConfigurationService.getRoutesConfiguration
87
- ).mockResolvedValue(mockRoutes);
88
-
89
- await store.fetchConfiguration();
90
-
91
- expect(store.entities).toEqual(mockEntities);
92
- expect(store.routes).toEqual(mockRoutes);
93
- expect(store.loading).toBe(false);
94
- expect(store.error).toBeNull();
95
- });
96
-
97
- it('should set loading to true during fetch', async () => {
98
- let loadingDuringFetch = false;
99
-
100
- vi.mocked(
101
- linIdConfigurationService.getEntitiesConfiguration
102
- ).mockImplementation(async () => {
103
- loadingDuringFetch = store.loading;
104
- return [];
105
- });
106
- vi.mocked(
107
- linIdConfigurationService.getRoutesConfiguration
108
- ).mockResolvedValue([]);
109
-
110
- await store.fetchConfiguration();
111
-
112
- expect(loadingDuringFetch).toBe(true);
113
- expect(store.loading).toBe(false);
114
- });
115
-
116
- it('should handle errors and set error message', async () => {
117
- const consoleErrorSpy = vi
118
- .spyOn(globalThis.console, 'error')
119
- .mockImplementation(() => {});
120
- const error = new Error('Network failure');
121
-
122
- vi.mocked(
123
- linIdConfigurationService.getEntitiesConfiguration
124
- ).mockRejectedValue(error);
125
-
126
- await store.fetchConfiguration();
127
-
128
- expect(store.error).toBe('Network failure');
129
- expect(store.loading).toBe(false);
130
- expect(store.entities).toEqual([]);
131
- expect(store.routes).toEqual([]);
132
- expect(consoleErrorSpy).toHaveBeenCalledWith(
133
- '[LinID CoreLib] Failed to fetch configuration:',
134
- error
135
- );
136
-
137
- consoleErrorSpy.mockRestore();
138
- });
139
-
140
- it('should handle non-Error exceptions', async () => {
141
- const consoleErrorSpy = vi
142
- .spyOn(globalThis.console, 'error')
143
- .mockImplementation(() => {});
144
-
145
- vi.mocked(
146
- linIdConfigurationService.getEntitiesConfiguration
147
- ).mockRejectedValue('String error');
148
-
149
- await store.fetchConfiguration();
150
-
151
- expect(store.error).toBe('Failed to fetch configuration');
152
-
153
- consoleErrorSpy.mockRestore();
154
- });
155
-
156
- it('should reset error on new fetch', async () => {
157
- store.error = 'Previous error';
158
-
159
- vi.mocked(
160
- linIdConfigurationService.getEntitiesConfiguration
161
- ).mockResolvedValue([]);
162
- vi.mocked(
163
- linIdConfigurationService.getRoutesConfiguration
164
- ).mockResolvedValue([]);
165
-
166
- await store.fetchConfiguration();
167
-
168
- expect(store.error).toBeNull();
169
- });
170
- });
171
- });
@@ -1,94 +0,0 @@
1
- import { createPinia, setActivePinia } from 'pinia';
2
- import { useLinidZoneStore } from 'src/stores/linidZoneStore';
3
- import { beforeEach, describe, expect, it } from 'vitest';
4
-
5
- describe('Test store: linidZoneStore', () => {
6
- beforeEach(() => {
7
- setActivePinia(createPinia());
8
- });
9
-
10
- describe('Test initial state', () => {
11
- it('should initialize with empty zones', () => {
12
- const store = useLinidZoneStore();
13
-
14
- expect(store.zones).toEqual({});
15
- });
16
- });
17
-
18
- describe('Test function: register', () => {
19
- it('should register an entry in a new zone', () => {
20
- const store = useLinidZoneStore();
21
- const entry = {
22
- plugin: 'test-plugin/TestComponent',
23
- props: {},
24
- };
25
-
26
- store.register('list-page.sidebar', entry);
27
-
28
- expect(store.zones['list-page.sidebar']).toBeDefined();
29
- expect(store.zones['list-page.sidebar']).toHaveLength(1);
30
- expect(store.zones['list-page.sidebar'][0]).toEqual(entry);
31
- });
32
-
33
- it('should register multiple entries in the same zone', () => {
34
- const store = useLinidZoneStore();
35
- const entry1 = {
36
- plugin: 'plugin-1/Component1',
37
- props: {},
38
- };
39
- const entry2 = {
40
- plugin: 'plugin-2/Component2',
41
- props: { value: 42 },
42
- };
43
-
44
- store.register('list-page.sidebar', entry1);
45
- store.register('list-page.sidebar', entry2);
46
-
47
- expect(store.zones['list-page.sidebar']).toHaveLength(2);
48
- expect(store.zones['list-page.sidebar'][0]).toEqual(entry1);
49
- expect(store.zones['list-page.sidebar'][1]).toEqual(entry2);
50
- });
51
-
52
- it('should register entries in different zones independently', () => {
53
- const store = useLinidZoneStore();
54
- const headerEntry = {
55
- plugin: 'header-plugin/HeaderComponent',
56
- props: {},
57
- };
58
- const footerEntry = {
59
- plugin: 'footer-plugin/FooterComponent',
60
- props: {},
61
- };
62
-
63
- store.register('list-page.header', headerEntry);
64
- store.register('list-page.footer', footerEntry);
65
-
66
- expect(store.zones['list-page.header']).toHaveLength(1);
67
- expect(store.zones['list-page.footer']).toHaveLength(1);
68
- expect(store.zones['list-page.header'][0]).toEqual(headerEntry);
69
- expect(store.zones['list-page.footer'][0]).toEqual(footerEntry);
70
- });
71
-
72
- it('should handle entries with complex props', () => {
73
- const store = useLinidZoneStore();
74
- const entry = {
75
- plugin: 'complex-plugin/ComplexComponent',
76
- props: {
77
- title: 'Test Title',
78
- count: 123,
79
- enabled: true,
80
- config: {
81
- nested: {
82
- value: 'deep',
83
- },
84
- },
85
- items: ['a', 'b', 'c'],
86
- },
87
- };
88
-
89
- store.register('list-page.body', entry);
90
-
91
- expect(store.zones['list-page.body'][0].props).toEqual(entry.props);
92
- });
93
- });
94
- });
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- {
5
- "path": "./tsconfig.node.json"
6
- },
7
- {
8
- "path": "./tsconfig.lib.json"
9
- },
10
- {
11
- "path": "./tsconfig.spec.json"
12
- }
13
- ]
14
- }
package/tsconfig.lib.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "target": "ESNext",
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "lib": ["ESNext", "DOM"],
8
- "esModuleInterop": true,
9
- "strict": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "types": ["node", "vite/client", "vue"],
14
- "declaration": true,
15
- "declarationDir": "dist/types",
16
- "outDir": "dist"
17
- },
18
- "include": ["src"],
19
- "exclude": ["vite.config.ts", "tests", "vitest.config.ts"]
20
- }
@@ -1,9 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "module": "nodenext",
5
- "strict": true,
6
- "types": ["node"]
7
- },
8
- "include": ["vite.config.ts", "vitest.config.ts"]
9
- }
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "baseUrl": ".",
5
- "outDir": "./out-tsc/vitest",
6
- "allowJs": true,
7
- "module": "esnext",
8
- "moduleResolution": "bundler"
9
- },
10
- "include": ["tests", "src"],
11
- "references": [
12
- {
13
- "path": "./tsconfig.lib.json"
14
- }
15
- ]
16
- }
package/vite.config.ts DELETED
@@ -1,37 +0,0 @@
1
- import vue from '@vitejs/plugin-vue';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import { defineConfig } from 'vite';
5
-
6
- export default defineConfig({
7
- plugins: [
8
- vue(),
9
-
10
- {
11
- name: 'copy-package-json',
12
- closeBundle() {
13
- const src = path.resolve(__dirname, 'package.json');
14
- const dest = path.resolve(__dirname, 'dist', 'package.json');
15
- if (fs.existsSync(src)) {
16
- fs.copyFileSync(src, dest);
17
- }
18
- },
19
- },
20
- ],
21
-
22
- build: {
23
- lib: {
24
- entry: path.resolve(__dirname, 'src/index.ts'),
25
- name: 'CoreLib',
26
- fileName: (format) => `core-lib.${format}.js`,
27
- },
28
- rollupOptions: {
29
- external: ['vue'],
30
- output: {
31
- globals: {
32
- vue: 'Vue',
33
- },
34
- },
35
- },
36
- },
37
- });
package/vitest.config.ts DELETED
@@ -1,19 +0,0 @@
1
- import vue from '@vitejs/plugin-vue';
2
- import tsconfigPaths from 'vite-tsconfig-paths';
3
- import { defineConfig } from 'vitest/config';
4
-
5
- export default defineConfig({
6
- test: {
7
- environment: 'happy-dom',
8
- globals: true,
9
- include: ['tests/unit/**/*.{test,spec}.js'],
10
- coverage: {
11
- provider: 'v8',
12
- reporter: ['text', 'html', 'lcov'],
13
- reportsDirectory: './coverage',
14
- include: ['src/**/*.{ts,js,vue}'],
15
- exclude: ['**/tests/**', 'src/types/**', 'src/index.ts'],
16
- },
17
- },
18
- plugins: [vue(), tsconfigPaths()],
19
- });