@linagora/linid-im-front-corelib 0.0.4 → 0.0.6
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/.github/workflows/pull-request.yml +26 -1
- package/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +13 -0
- package/CONTRIBUTING.md +7 -2
- package/dist/core-lib.es.js +921 -851
- package/dist/core-lib.umd.js +9 -9
- package/dist/package.json +20 -12
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/services/httpClientService.d.ts +13 -0
- package/dist/types/src/services/linIdConfigurationService.d.ts +21 -0
- package/dist/types/src/stores/linIdConfigurationStore.d.ts +79 -0
- package/dist/types/src/types/linidConfiguration.d.ts +42 -0
- package/docs/services.md +39 -0
- package/docs/types-and-interfaces.md +56 -9
- package/eslint.config.js +2 -1
- package/package.json +19 -11
- package/src/index.ts +11 -0
- package/src/services/httpClientService.ts +61 -0
- package/src/services/linIdConfigurationService.ts +73 -0
- package/src/stores/linIdConfigurationStore.ts +116 -0
- package/src/types/linidConfiguration.ts +70 -0
- package/tests/unit/components/LinidZoneRenderer.spec.js +135 -0
- package/tests/unit/lifecycle/skeleton.spec.js +138 -0
- package/tests/unit/services/federationService.spec.js +146 -0
- package/tests/unit/services/httpClientService.spec.js +49 -0
- package/tests/unit/services/linIdConfigurationService.spec.js +113 -0
- package/tests/unit/stores/linIdConfigurationStore.spec.js +171 -0
- package/tests/unit/stores/linidZoneStore.spec.js +94 -0
- package/tsconfig.json +11 -27
- package/tsconfig.lib.json +20 -0
- package/tsconfig.node.json +9 -0
- package/tsconfig.spec.json +16 -0
- package/vite.config.ts +11 -16
- package/vitest.config.ts +19 -0
- package/dist/types/vite.config.d.ts +0 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes a single attribute of an entity.
|
|
3
|
+
* Corresponds to `AttributeDescription` from the backend API.
|
|
4
|
+
*/
|
|
5
|
+
export interface LinIdAttributeConfiguration {
|
|
6
|
+
/** The name of the attribute (e.g., "email"). */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The backend type of the attribute (e.g., "string", "integer"). */
|
|
9
|
+
type: string;
|
|
10
|
+
/** Whether the attribute is required. */
|
|
11
|
+
required: boolean;
|
|
12
|
+
/** Whether the attribute has validation rules. */
|
|
13
|
+
hasValidations: boolean;
|
|
14
|
+
/** The UI input type to be used on the front-end (e.g., "text", "select"). */
|
|
15
|
+
input: string;
|
|
16
|
+
/** Settings for the input (e.g., options, placeholder). */
|
|
17
|
+
inputSettings: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents the configuration of an entity declared in the application.
|
|
21
|
+
* Returned by the `/metadata/entities` endpoint.
|
|
22
|
+
*/
|
|
23
|
+
export interface LinIdEntityConfiguration {
|
|
24
|
+
/** The name of the entity (e.g., "user", "group"). */
|
|
25
|
+
name: string;
|
|
26
|
+
/** The list of attributes defined for this entity. */
|
|
27
|
+
attributes: LinIdAttributeConfiguration[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents a REST route configuration exposed by the application.
|
|
31
|
+
* Returned by the `/metadata/routes` endpoint.
|
|
32
|
+
*/
|
|
33
|
+
export interface LinIdRouteConfiguration {
|
|
34
|
+
/** The HTTP method (e.g., "GET", "POST", "PUT", "DELETE"). */
|
|
35
|
+
method: string;
|
|
36
|
+
/** The full route path (e.g., "/entities/{entity}"). */
|
|
37
|
+
path: string;
|
|
38
|
+
/** The name of the entity this route is related to; may be null for generic routes. */
|
|
39
|
+
entity: string | null;
|
|
40
|
+
/** The list of path variable names used in the route (e.g., ["entity", "id"]). */
|
|
41
|
+
variables: string[];
|
|
42
|
+
}
|
package/docs/services.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Services 🔧
|
|
2
|
+
|
|
3
|
+
This document describes the **services** provided by `linid-im-front-corelib`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🔌 HTTP Client Service
|
|
8
|
+
|
|
9
|
+
Singleton Axios wrapper shared across all modules.
|
|
10
|
+
|
|
11
|
+
### Functions
|
|
12
|
+
|
|
13
|
+
| Function | Description |
|
|
14
|
+
| ----------------------- | ------------------------------------------------- |
|
|
15
|
+
| `setHttpClient(client)` | Initializes the shared Axios instance (call once) |
|
|
16
|
+
| `getHttpClient()` | Returns the shared Axios instance |
|
|
17
|
+
|
|
18
|
+
### Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { setHttpClient, getHttpClient } from '@linagora/linid-im-front-corelib';
|
|
22
|
+
|
|
23
|
+
// Host initializes once during boot
|
|
24
|
+
setHttpClient(axiosInstance);
|
|
25
|
+
|
|
26
|
+
// Modules retrieve the shared instance
|
|
27
|
+
const http = getHttpClient();
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Rules
|
|
31
|
+
|
|
32
|
+
- ✅ Host calls `setHttpClient()` once during boot
|
|
33
|
+
- ✅ Modules use `getHttpClient()` to access the same instance
|
|
34
|
+
- ⚠️ Warning logged if re-initialization is attempted
|
|
35
|
+
- ❌ Error thrown if `getHttpClient()` is called before initialization
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
> Additional services will be added as new features are implemented in the library.
|
|
@@ -34,8 +34,8 @@ interface LinidZoneState {
|
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
- `zones` is a reactive object.
|
|
38
|
+
- Each key corresponds to a zone, each value is an array of plugins for that zone.
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
@@ -69,21 +69,68 @@ Used internally by [`loadAsyncComponent`](./helpers.md#loadasynccomponent) to en
|
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
71
|
// ❌ Wrong - named export only
|
|
72
|
-
export const MyComponent = defineComponent({
|
|
72
|
+
export const MyComponent = defineComponent({
|
|
73
|
+
/* ... */
|
|
74
|
+
});
|
|
73
75
|
|
|
74
76
|
// ✅ Correct - default export
|
|
75
|
-
export default defineComponent({
|
|
77
|
+
export default defineComponent({
|
|
78
|
+
/* ... */
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 🏢 Entity Configuration Types
|
|
85
|
+
|
|
86
|
+
Types for entity and route metadata returned by the backend API.
|
|
87
|
+
|
|
88
|
+
### LinIdAttributeConfiguration
|
|
89
|
+
|
|
90
|
+
Describes a single attribute of an entity (name, type, input settings, validations).
|
|
91
|
+
|
|
92
|
+
### LinIdEntityConfiguration
|
|
93
|
+
|
|
94
|
+
Represents an entity with its name and list of attributes.
|
|
95
|
+
Returned by `/metadata/entities` and `/metadata/entities/:entity`.
|
|
96
|
+
|
|
97
|
+
### LinIdRouteConfiguration
|
|
98
|
+
|
|
99
|
+
Represents a REST route (method, path, entity, variables).
|
|
100
|
+
Returned by `/metadata/routes`.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🗃️ LinIdConfigurationState
|
|
105
|
+
|
|
106
|
+
Represents the state of the Pinia store that manages entity and route configurations.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
interface LinIdConfigurationState {
|
|
110
|
+
/** List of entity configurations fetched from the backend. */
|
|
111
|
+
entities: LinIdEntityConfiguration[];
|
|
112
|
+
/** List of route configurations fetched from the backend. */
|
|
113
|
+
routes: LinIdRouteConfiguration[];
|
|
114
|
+
/** Indicates if the configuration is currently being loaded. */
|
|
115
|
+
loading: boolean;
|
|
116
|
+
/** Error message if the configuration fetch failed. */
|
|
117
|
+
error: string | null;
|
|
118
|
+
}
|
|
76
119
|
```
|
|
77
120
|
|
|
78
121
|
---
|
|
79
122
|
|
|
80
123
|
## 🧰 Summary
|
|
81
124
|
|
|
82
|
-
| Type / Interface
|
|
83
|
-
|
|
|
84
|
-
| `LinidZoneEntry`
|
|
85
|
-
| `LinidZoneState`
|
|
86
|
-
| `RemoteComponentModule`
|
|
125
|
+
| Type / Interface | Purpose |
|
|
126
|
+
| ----------------------------- | ----------------------------------------------------- |
|
|
127
|
+
| `LinidZoneEntry` | Defines the contract for a plugin component |
|
|
128
|
+
| `LinidZoneState` | Defines the structure of the zone store |
|
|
129
|
+
| `RemoteComponentModule` | Defines the structure of a federated component module |
|
|
130
|
+
| `LinIdAttributeConfiguration` | Describes an entity attribute |
|
|
131
|
+
| `LinIdEntityConfiguration` | Describes an entity and its attributes |
|
|
132
|
+
| `LinIdRouteConfiguration` | Describes a REST route |
|
|
133
|
+
| `LinIdConfigurationState` | Defines the structure of the configuration store |
|
|
87
134
|
|
|
88
135
|
These types enforce **consistency and type safety** across all front-end modules and plugins.
|
|
89
136
|
|
package/eslint.config.js
CHANGED
|
@@ -123,9 +123,10 @@ export default defineConfigWithVueTs(
|
|
|
123
123
|
files: [
|
|
124
124
|
'**/*.test.ts',
|
|
125
125
|
'**/*.spec.ts',
|
|
126
|
+
'**/*.test.js',
|
|
127
|
+
'**/*.spec.js',
|
|
126
128
|
'**/__tests__/**',
|
|
127
129
|
'**/*.config.*',
|
|
128
|
-
'**/*.config.*',
|
|
129
130
|
],
|
|
130
131
|
rules: {
|
|
131
132
|
'jsdoc/require-jsdoc': 'off',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linagora/linid-im-front-corelib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Core library of the LinID Identity Manager project. Provides shared types, services, components, and utilities for front-end and plugin, enabling consistent integration across the LinID ecosystem.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/core-lib.umd.js",
|
|
@@ -40,28 +40,36 @@
|
|
|
40
40
|
"homepage": "https://github.com/linagora/linid-im-front-corelib#readme",
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@module-federation/enhanced": "0.21.4",
|
|
43
|
+
"axios": "1.13.2",
|
|
43
44
|
"pinia": "3.0.4",
|
|
44
45
|
"vue": "3.5.24"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@eslint/js": "9.39.1",
|
|
48
|
-
"@types/node": "
|
|
49
|
-
"@vitejs/plugin-vue": "6.0.
|
|
49
|
+
"@types/node": "24.10.2",
|
|
50
|
+
"@vitejs/plugin-vue": "6.0.2",
|
|
51
|
+
"@vitest/coverage-v8": "4.0.15",
|
|
50
52
|
"@vue/eslint-config-prettier": "10.2.0",
|
|
51
53
|
"@vue/eslint-config-typescript": "14.6.0",
|
|
54
|
+
"@vue/test-utils": "2.4.6",
|
|
52
55
|
"eslint": "9.39.1",
|
|
53
56
|
"eslint-plugin-headers": "1.3.3",
|
|
54
|
-
"eslint-plugin-jsdoc": "61.
|
|
55
|
-
"eslint-plugin-vue": "10.
|
|
56
|
-
"
|
|
57
|
+
"eslint-plugin-jsdoc": "61.5.0",
|
|
58
|
+
"eslint-plugin-vue": "10.6.2",
|
|
59
|
+
"happy-dom": "20.0.11",
|
|
60
|
+
"prettier": "3.7.4",
|
|
57
61
|
"typescript": "5.9.3",
|
|
58
|
-
"vite": "7.2.
|
|
59
|
-
"
|
|
60
|
-
"
|
|
62
|
+
"vite": "7.2.7",
|
|
63
|
+
"vite-tsconfig-paths": "5.1.4",
|
|
64
|
+
"vitest": "4.0.15",
|
|
65
|
+
"vue-tsc": "3.1.8"
|
|
61
66
|
},
|
|
62
67
|
"scripts": {
|
|
63
|
-
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly",
|
|
64
|
-
"test": "vitest",
|
|
68
|
+
"build": "vite build && vue-tsc --declaration --emitDeclarationOnly -p tsconfig.lib.json",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:coverage": "vitest --run --coverage",
|
|
71
|
+
"test:watch": "vitest",
|
|
72
|
+
"test:ci": "vitest run --coverage --reporter=dot",
|
|
65
73
|
"dev": "vite",
|
|
66
74
|
"lint": "eslint . --max-warnings 0",
|
|
67
75
|
"lint:fix": "eslint . --fix",
|
package/src/index.ts
CHANGED
|
@@ -29,10 +29,21 @@ export { default as LinidZoneRenderer } from './components/LinidZoneRenderer.vue
|
|
|
29
29
|
|
|
30
30
|
// Stores
|
|
31
31
|
export { useLinidZoneStore } from './stores/linidZoneStore';
|
|
32
|
+
export { useLinIdConfigurationStore } from './stores/linIdConfigurationStore';
|
|
33
|
+
|
|
34
|
+
// Services
|
|
35
|
+
export { getHttpClient, setHttpClient } from './services/httpClientService';
|
|
32
36
|
|
|
33
37
|
// Types - Zones
|
|
34
38
|
export type { LinidZoneEntry } from './types/linidZone';
|
|
35
39
|
|
|
40
|
+
// Types - Configuration
|
|
41
|
+
export type {
|
|
42
|
+
LinIdAttributeConfiguration,
|
|
43
|
+
LinIdEntityConfiguration,
|
|
44
|
+
LinIdRouteConfiguration,
|
|
45
|
+
} from './types/linidConfiguration';
|
|
46
|
+
|
|
36
47
|
export type {
|
|
37
48
|
ModuleHostConfig,
|
|
38
49
|
RemoteComponentModule,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2025 Linagora
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
|
5
|
+
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
|
|
6
|
+
* any later version, provided you comply with the Additional Terms applicable for LinID Identity Manager software by
|
|
7
|
+
* LINAGORA pursuant to Section 7 of the GNU Affero General Public License, subsections (b), (c), and (e), pursuant to
|
|
8
|
+
* which these Appropriate Legal Notices must notably (i) retain the display of the "LinID™" trademark/logo at the top
|
|
9
|
+
* of the interface window, the display of the “You are using the Open Source and free version of LinID™, powered by
|
|
10
|
+
* Linagora © 2009–2013. Contribute to LinID R&D by subscribing to an Enterprise offer!” infobox and in the e-mails
|
|
11
|
+
* sent with the Program, notice appended to any type of outbound messages (e.g. e-mail and meeting requests) as well
|
|
12
|
+
* as in the LinID Identity Manager user interface, (ii) retain all hypertext links between LinID Identity Manager
|
|
13
|
+
* and https://linid.org/, as well as between LINAGORA and LINAGORA.com, and (iii) refrain from infringing LINAGORA
|
|
14
|
+
* intellectual property rights over its trademarks and commercial brands. Other Additional Terms apply, see
|
|
15
|
+
* <http://www.linagora.com/licenses/> for more details.
|
|
16
|
+
*
|
|
17
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
18
|
+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
19
|
+
* details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU Affero General Public License and its applicable Additional Terms for
|
|
22
|
+
* LinID Identity Manager along with this program. If not, see <http://www.gnu.org/licenses/> for the GNU Affero
|
|
23
|
+
* General Public License version 3 and <http://www.linagora.com/licenses/> for the Additional Terms applicable to the
|
|
24
|
+
* LinID Identity Manager software.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { AxiosInstance } from 'axios';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Singleton HTTP client instance shared across all modules.
|
|
31
|
+
*/
|
|
32
|
+
let httpClient: AxiosInstance | null = null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the shared HTTP client instance.
|
|
36
|
+
* Should be called once by the host application during boot.
|
|
37
|
+
* @param client - The Axios instance to use as the shared HTTP client.
|
|
38
|
+
*/
|
|
39
|
+
export function setHttpClient(client: AxiosInstance): void {
|
|
40
|
+
if (httpClient !== null) {
|
|
41
|
+
console.warn(
|
|
42
|
+
'[LinID CoreLib] HTTP client has already been initialized. Re-initialization is ignored.'
|
|
43
|
+
);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
httpClient = client;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns the shared HTTP client instance.
|
|
51
|
+
* Must be called after initialization via `setHttpClient()`.
|
|
52
|
+
* @returns The shared Axios instance.
|
|
53
|
+
*/
|
|
54
|
+
export function getHttpClient(): AxiosInstance {
|
|
55
|
+
if (httpClient === null) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
'[LinID CoreLib] HTTP client is not initialized. Call setHttpClient() first.'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return httpClient;
|
|
61
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2025 Linagora
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
|
5
|
+
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
|
|
6
|
+
* any later version, provided you comply with the Additional Terms applicable for LinID Identity Manager software by
|
|
7
|
+
* LINAGORA pursuant to Section 7 of the GNU Affero General Public License, subsections (b), (c), and (e), pursuant to
|
|
8
|
+
* which these Appropriate Legal Notices must notably (i) retain the display of the "LinID™" trademark/logo at the top
|
|
9
|
+
* of the interface window, the display of the “You are using the Open Source and free version of LinID™, powered by
|
|
10
|
+
* Linagora © 2009–2013. Contribute to LinID R&D by subscribing to an Enterprise offer!” infobox and in the e-mails
|
|
11
|
+
* sent with the Program, notice appended to any type of outbound messages (e.g. e-mail and meeting requests) as well
|
|
12
|
+
* as in the LinID Identity Manager user interface, (ii) retain all hypertext links between LinID Identity Manager
|
|
13
|
+
* and https://linid.org/, as well as between LINAGORA and LINAGORA.com, and (iii) refrain from infringing LINAGORA
|
|
14
|
+
* intellectual property rights over its trademarks and commercial brands. Other Additional Terms apply, see
|
|
15
|
+
* <http://www.linagora.com/licenses/> for more details.
|
|
16
|
+
*
|
|
17
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
18
|
+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
19
|
+
* details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU Affero General Public License and its applicable Additional Terms for
|
|
22
|
+
* LinID Identity Manager along with this program. If not, see <http://www.gnu.org/licenses/> for the GNU Affero
|
|
23
|
+
* General Public License version 3 and <http://www.linagora.com/licenses/> for the Additional Terms applicable to the
|
|
24
|
+
* LinID Identity Manager software.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
LinIdEntityConfiguration,
|
|
29
|
+
LinIdRouteConfiguration,
|
|
30
|
+
} from '../types/linidConfiguration';
|
|
31
|
+
import { getHttpClient } from './httpClientService';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Service for managing and exposing LinID entity and route configurations.
|
|
35
|
+
* Fetches metadata from the backend API.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Fetches all entity configurations from the backend.
|
|
39
|
+
* @returns A promise resolving to an array of entity configurations.
|
|
40
|
+
*/
|
|
41
|
+
export async function getEntitiesConfiguration(): Promise<
|
|
42
|
+
LinIdEntityConfiguration[]
|
|
43
|
+
> {
|
|
44
|
+
const response =
|
|
45
|
+
await getHttpClient().get<LinIdEntityConfiguration[]>('/metadata/entities');
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Fetches a specific entity configuration by name.
|
|
51
|
+
* @param entityId - The name/identifier of the entity.
|
|
52
|
+
* @returns A promise resolving to the entity configuration.
|
|
53
|
+
*/
|
|
54
|
+
export async function getEntityConfiguration(
|
|
55
|
+
entityId: string
|
|
56
|
+
): Promise<LinIdEntityConfiguration> {
|
|
57
|
+
const response = await getHttpClient().get<LinIdEntityConfiguration>(
|
|
58
|
+
`/metadata/entities/${entityId}`
|
|
59
|
+
);
|
|
60
|
+
return response.data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Fetches all route configurations from the backend.
|
|
65
|
+
* @returns A promise resolving to an array of route configurations.
|
|
66
|
+
*/
|
|
67
|
+
export async function getRoutesConfiguration(): Promise<
|
|
68
|
+
LinIdRouteConfiguration[]
|
|
69
|
+
> {
|
|
70
|
+
const response =
|
|
71
|
+
await getHttpClient().get<LinIdRouteConfiguration[]>('/metadata/routes');
|
|
72
|
+
return response.data;
|
|
73
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2025 Linagora
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
|
5
|
+
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
|
|
6
|
+
* any later version, provided you comply with the Additional Terms applicable for LinID Identity Manager software by
|
|
7
|
+
* LINAGORA pursuant to Section 7 of the GNU Affero General Public License, subsections (b), (c), and (e), pursuant to
|
|
8
|
+
* which these Appropriate Legal Notices must notably (i) retain the display of the "LinID™" trademark/logo at the top
|
|
9
|
+
* of the interface window, the display of the “You are using the Open Source and free version of LinID™, powered by
|
|
10
|
+
* Linagora © 2009–2013. Contribute to LinID R&D by subscribing to an Enterprise offer!” infobox and in the e-mails
|
|
11
|
+
* sent with the Program, notice appended to any type of outbound messages (e.g. e-mail and meeting requests) as well
|
|
12
|
+
* as in the LinID Identity Manager user interface, (ii) retain all hypertext links between LinID Identity Manager
|
|
13
|
+
* and https://linid.org/, as well as between LINAGORA and LINAGORA.com, and (iii) refrain from infringing LINAGORA
|
|
14
|
+
* intellectual property rights over its trademarks and commercial brands. Other Additional Terms apply, see
|
|
15
|
+
* <http://www.linagora.com/licenses/> for more details.
|
|
16
|
+
*
|
|
17
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
18
|
+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
19
|
+
* details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU Affero General Public License and its applicable Additional Terms for
|
|
22
|
+
* LinID Identity Manager along with this program. If not, see <http://www.gnu.org/licenses/> for the GNU Affero
|
|
23
|
+
* General Public License version 3 and <http://www.linagora.com/licenses/> for the Additional Terms applicable to the
|
|
24
|
+
* LinID Identity Manager software.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { defineStore } from 'pinia';
|
|
28
|
+
import {
|
|
29
|
+
getEntitiesConfiguration,
|
|
30
|
+
getRoutesConfiguration,
|
|
31
|
+
} from '../services/linIdConfigurationService';
|
|
32
|
+
import type {
|
|
33
|
+
LinIdEntityConfiguration,
|
|
34
|
+
LinIdRouteConfiguration,
|
|
35
|
+
} from '../types/linidConfiguration';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* State interface for the LinId Configuration Store.
|
|
39
|
+
*/
|
|
40
|
+
interface LinIdConfigurationState {
|
|
41
|
+
/** List of entity configurations fetched from the backend. */
|
|
42
|
+
entities: LinIdEntityConfiguration[];
|
|
43
|
+
/** List of route configurations fetched from the backend. */
|
|
44
|
+
routes: LinIdRouteConfiguration[];
|
|
45
|
+
/** Indicates if the configuration is currently being loaded. */
|
|
46
|
+
loading: boolean;
|
|
47
|
+
/** Error message if the configuration fetch failed. */
|
|
48
|
+
error: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Pinia store managing LinID entity and route configurations.
|
|
53
|
+
*
|
|
54
|
+
* Fetches and stores metadata from the backend API.
|
|
55
|
+
*/
|
|
56
|
+
export const useLinIdConfigurationStore = defineStore(
|
|
57
|
+
'linidConfigurationStore',
|
|
58
|
+
{
|
|
59
|
+
state: (): LinIdConfigurationState => ({
|
|
60
|
+
entities: [],
|
|
61
|
+
routes: [],
|
|
62
|
+
loading: false,
|
|
63
|
+
error: null,
|
|
64
|
+
}),
|
|
65
|
+
|
|
66
|
+
getters: {
|
|
67
|
+
/**
|
|
68
|
+
* Returns an entity configuration by name.
|
|
69
|
+
* @param state - The store state.
|
|
70
|
+
* @returns A function that takes an entity name and returns the configuration.
|
|
71
|
+
*/
|
|
72
|
+
getEntityByName:
|
|
73
|
+
(state) =>
|
|
74
|
+
(name: string): LinIdEntityConfiguration | undefined =>
|
|
75
|
+
state.entities.find((entity) => entity.name === name),
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns all routes for a specific entity.
|
|
79
|
+
* @param state - The store state.
|
|
80
|
+
* @returns A function that takes an entity name and returns its routes.
|
|
81
|
+
*/
|
|
82
|
+
getRoutesByEntity:
|
|
83
|
+
(state) =>
|
|
84
|
+
(entityName: string): LinIdRouteConfiguration[] =>
|
|
85
|
+
state.routes.filter((route) => route.entity === entityName),
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
actions: {
|
|
89
|
+
/**
|
|
90
|
+
* Fetches all entity and route configurations from the backend.
|
|
91
|
+
*/
|
|
92
|
+
async fetchConfiguration(): Promise<void> {
|
|
93
|
+
this.loading = true;
|
|
94
|
+
this.error = null;
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const [entities, routes] = await Promise.all([
|
|
98
|
+
getEntitiesConfiguration(),
|
|
99
|
+
getRoutesConfiguration(),
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
this.entities = entities;
|
|
103
|
+
this.routes = routes;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
this.error =
|
|
106
|
+
err instanceof Error
|
|
107
|
+
? err.message
|
|
108
|
+
: 'Failed to fetch configuration';
|
|
109
|
+
console.error('[LinID CoreLib] Failed to fetch configuration:', err);
|
|
110
|
+
} finally {
|
|
111
|
+
this.loading = false;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2025 Linagora
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
|
5
|
+
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
|
|
6
|
+
* any later version, provided you comply with the Additional Terms applicable for LinID Identity Manager software by
|
|
7
|
+
* LINAGORA pursuant to Section 7 of the GNU Affero General Public License, subsections (b), (c), and (e), pursuant to
|
|
8
|
+
* which these Appropriate Legal Notices must notably (i) retain the display of the "LinID™" trademark/logo at the top
|
|
9
|
+
* of the interface window, the display of the “You are using the Open Source and free version of LinID™, powered by
|
|
10
|
+
* Linagora © 2009–2013. Contribute to LinID R&D by subscribing to an Enterprise offer!” infobox and in the e-mails
|
|
11
|
+
* sent with the Program, notice appended to any type of outbound messages (e.g. e-mail and meeting requests) as well
|
|
12
|
+
* as in the LinID Identity Manager user interface, (ii) retain all hypertext links between LinID Identity Manager
|
|
13
|
+
* and https://linid.org/, as well as between LINAGORA and LINAGORA.com, and (iii) refrain from infringing LINAGORA
|
|
14
|
+
* intellectual property rights over its trademarks and commercial brands. Other Additional Terms apply, see
|
|
15
|
+
* <http://www.linagora.com/licenses/> for more details.
|
|
16
|
+
*
|
|
17
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
18
|
+
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
19
|
+
* details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU Affero General Public License and its applicable Additional Terms for
|
|
22
|
+
* LinID Identity Manager along with this program. If not, see <http://www.gnu.org/licenses/> for the GNU Affero
|
|
23
|
+
* General Public License version 3 and <http://www.linagora.com/licenses/> for the Additional Terms applicable to the
|
|
24
|
+
* LinID Identity Manager software.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Describes a single attribute of an entity.
|
|
29
|
+
* Corresponds to `AttributeDescription` from the backend API.
|
|
30
|
+
*/
|
|
31
|
+
export interface LinIdAttributeConfiguration {
|
|
32
|
+
/** The name of the attribute (e.g., "email"). */
|
|
33
|
+
name: string;
|
|
34
|
+
/** The backend type of the attribute (e.g., "string", "integer"). */
|
|
35
|
+
type: string;
|
|
36
|
+
/** Whether the attribute is required. */
|
|
37
|
+
required: boolean;
|
|
38
|
+
/** Whether the attribute has validation rules. */
|
|
39
|
+
hasValidations: boolean;
|
|
40
|
+
/** The UI input type to be used on the front-end (e.g., "text", "select"). */
|
|
41
|
+
input: string;
|
|
42
|
+
/** Settings for the input (e.g., options, placeholder). */
|
|
43
|
+
inputSettings: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Represents the configuration of an entity declared in the application.
|
|
48
|
+
* Returned by the `/metadata/entities` endpoint.
|
|
49
|
+
*/
|
|
50
|
+
export interface LinIdEntityConfiguration {
|
|
51
|
+
/** The name of the entity (e.g., "user", "group"). */
|
|
52
|
+
name: string;
|
|
53
|
+
/** The list of attributes defined for this entity. */
|
|
54
|
+
attributes: LinIdAttributeConfiguration[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Represents a REST route configuration exposed by the application.
|
|
59
|
+
* Returned by the `/metadata/routes` endpoint.
|
|
60
|
+
*/
|
|
61
|
+
export interface LinIdRouteConfiguration {
|
|
62
|
+
/** The HTTP method (e.g., "GET", "POST", "PUT", "DELETE"). */
|
|
63
|
+
method: string;
|
|
64
|
+
/** The full route path (e.g., "/entities/{entity}"). */
|
|
65
|
+
path: string;
|
|
66
|
+
/** The name of the entity this route is related to; may be null for generic routes. */
|
|
67
|
+
entity: string | null;
|
|
68
|
+
/** The list of path variable names used in the route (e.g., ["entity", "id"]). */
|
|
69
|
+
variables: string[];
|
|
70
|
+
}
|