@arch-cadre/modules 0.0.49 → 0.0.52
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/client/extension-point-client.cjs +33 -26
- package/dist/client/extension-point-client.d.ts +10 -0
- package/dist/client/extension-point-client.mjs +19 -23
- package/dist/client/extension-point.cjs +25 -18
- package/dist/client/extension-point.d.ts +9 -0
- package/dist/client/extension-point.mjs +14 -17
- package/dist/client/index.cjs +38 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.mjs +3 -0
- package/dist/client/widget-area.cjs +29 -22
- package/dist/client/widget-area.d.ts +9 -0
- package/dist/client/widget-area.mjs +16 -20
- package/dist/index.cjs +42 -9
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +4 -6
- package/dist/server/lifecycle.cjs +204 -180
- package/dist/server/lifecycle.d.ts +5 -0
- package/dist/server/lifecycle.mjs +223 -173
- package/dist/server/manage.cjs +124 -110
- package/dist/server/manage.d.ts +12 -0
- package/dist/server/manage.mjs +113 -104
- package/dist/server/registry.cjs +90 -82
- package/dist/server/registry.d.ts +1 -0
- package/dist/server/registry.mjs +94 -80
- package/dist/server/ui.cjs +197 -155
- package/dist/server/ui.d.ts +12 -0
- package/dist/server/ui.mjs +203 -154
- package/dist/server.cjs +59 -29
- package/dist/server.d.ts +5 -0
- package/dist/server.mjs +5 -7
- package/dist/types.cjs +18 -17
- package/dist/types.d.ts +113 -0
- package/dist/types.mjs +12 -16
- package/package.json +20 -6
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
package/dist/server/ui.mjs
CHANGED
|
@@ -1,169 +1,218 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
3
|
-
import { getModuleConfig, getModuleInstance, getModules } from "./manage.mjs";
|
|
4
2
|
import { getCurrentSession } from "@arch-cadre/core/server";
|
|
5
|
-
|
|
6
|
-
//#region src/server/ui.ts
|
|
7
|
-
/**
|
|
8
|
-
* Helper to check and filter a navigation item based on roles and permissions.
|
|
9
|
-
* Returns the item (potentially with filtered sub-items) or null if access is denied.
|
|
10
|
-
*/
|
|
3
|
+
import { getModuleConfig, getModuleInstance, getModules } from "./manage.js";
|
|
11
4
|
function filterNavItem(item, userRoles, userPermissions) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
if (item.roles && item.roles.length > 0) {
|
|
6
|
+
if (!item.roles.some((role) => userRoles.includes(role))) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
if (item.permissions && item.permissions.length > 0) {
|
|
11
|
+
if (!item.permissions.every((perm) => userPermissions.includes(perm))) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (item.items && item.items.length > 0) {
|
|
16
|
+
const filteredSubItems = item.items.map(
|
|
17
|
+
(subItem) => filterNavItem(subItem, userRoles, userPermissions)
|
|
18
|
+
).filter((subItem) => subItem !== null);
|
|
19
|
+
return {
|
|
20
|
+
...item,
|
|
21
|
+
items: filteredSubItems
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return item;
|
|
26
25
|
}
|
|
27
|
-
async function getModuleNavigationGrouped(type) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
export async function getModuleNavigationGrouped(type) {
|
|
27
|
+
const { user } = await getCurrentSession();
|
|
28
|
+
const userRoles = user?.roles || [];
|
|
29
|
+
const userPermissions = user?.permissions || [];
|
|
30
|
+
const modules = await getModules();
|
|
31
|
+
const active = modules.filter((m) => m.enabled);
|
|
32
|
+
const groups = {};
|
|
33
|
+
for (const mod of active) {
|
|
34
|
+
try {
|
|
35
|
+
const instance = await getModuleInstance(mod.id);
|
|
36
|
+
const instanceNav = instance?.navigation?.[type];
|
|
37
|
+
if (instanceNav) {
|
|
38
|
+
for (const [groupName, items] of Object.entries(
|
|
39
|
+
instanceNav
|
|
40
|
+
)) {
|
|
41
|
+
if (!groups[groupName]) groups[groupName] = [];
|
|
42
|
+
for (const rawItem of items) {
|
|
43
|
+
const item = filterNavItem(rawItem, userRoles, userPermissions);
|
|
44
|
+
if (item && !groups[groupName].some((existing) => existing.url === item.url)) {
|
|
45
|
+
groups[groupName].push(item);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (_e) {
|
|
51
|
+
console.warn(
|
|
52
|
+
`[Kernel:UI] Failed to load navigation for module ${mod.id}:`,
|
|
53
|
+
_e
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return groups;
|
|
46
58
|
}
|
|
47
|
-
async function getKryoPathPrefix() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
export async function getKryoPathPrefix() {
|
|
60
|
+
try {
|
|
61
|
+
const config = await getModuleConfig("kryo-panel");
|
|
62
|
+
return config?.pathPrefix ?? "/kryo";
|
|
63
|
+
} catch (_e) {
|
|
64
|
+
return "/kryo";
|
|
65
|
+
}
|
|
53
66
|
}
|
|
54
|
-
async function getKryoModuleNavigationGrouped(type) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
export async function getKryoModuleNavigationGrouped(type) {
|
|
68
|
+
const groups = await getModuleNavigationGrouped(type);
|
|
69
|
+
const prefix = await getKryoPathPrefix();
|
|
70
|
+
const prefixUrl = (url) => {
|
|
71
|
+
if (url.startsWith(prefix)) return url;
|
|
72
|
+
return url === "/" ? prefix : `${prefix}${url}`;
|
|
73
|
+
};
|
|
74
|
+
const processItems = (items) => {
|
|
75
|
+
return items.map((item) => ({
|
|
76
|
+
...item,
|
|
77
|
+
url: prefixUrl(item.url),
|
|
78
|
+
items: item.items ? processItems(item.items) : void 0
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
const transformedGroups = {};
|
|
82
|
+
for (const [group, items] of Object.entries(groups)) {
|
|
83
|
+
transformedGroups[group] = processItems(items);
|
|
84
|
+
}
|
|
85
|
+
return transformedGroups;
|
|
71
86
|
}
|
|
72
|
-
async function getModuleNavigation(type) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
export async function getModuleNavigation(type) {
|
|
88
|
+
const { user } = await getCurrentSession();
|
|
89
|
+
const userRoles = user?.roles || [];
|
|
90
|
+
const userPermissions = user?.permissions || [];
|
|
91
|
+
const modules = await getModules();
|
|
92
|
+
const active = modules.filter((m) => m.enabled);
|
|
93
|
+
const all = [];
|
|
94
|
+
for (const mod of active) {
|
|
95
|
+
try {
|
|
96
|
+
const instance = await getModuleInstance(mod.id);
|
|
97
|
+
if (instance?.navigation?.[type]) {
|
|
98
|
+
const items = instance.navigation[type];
|
|
99
|
+
for (const rawItem of items) {
|
|
100
|
+
const item = filterNavItem(rawItem, userRoles, userPermissions);
|
|
101
|
+
if (item) all.push(item);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return all;
|
|
89
108
|
}
|
|
90
|
-
async function getPublicModuleRoutes() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
export async function getPublicModuleRoutes() {
|
|
110
|
+
const modules = await getModules();
|
|
111
|
+
const active = modules.filter((m) => m.enabled);
|
|
112
|
+
const allRoutes = [];
|
|
113
|
+
for (const mod of active) {
|
|
114
|
+
try {
|
|
115
|
+
const instance = await getModuleInstance(mod.id);
|
|
116
|
+
if (instance?.routes?.public) {
|
|
117
|
+
allRoutes.push(...instance.routes.public);
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return allRoutes;
|
|
98
123
|
}
|
|
99
|
-
async function getPrivateModuleRoutes() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
export async function getPrivateModuleRoutes() {
|
|
125
|
+
const modules = await getModules();
|
|
126
|
+
const active = modules.filter((m) => m.enabled);
|
|
127
|
+
const allRoutes = [];
|
|
128
|
+
for (const mod of active) {
|
|
129
|
+
try {
|
|
130
|
+
const instance = await getModuleInstance(mod.id);
|
|
131
|
+
if (instance?.routes?.private) {
|
|
132
|
+
allRoutes.push(...instance.routes.private);
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return allRoutes;
|
|
107
138
|
}
|
|
108
|
-
async function getKryoModuleRoutes() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
export async function getKryoModuleRoutes() {
|
|
140
|
+
const routes = await getPrivateModuleRoutes();
|
|
141
|
+
const prefix = await getKryoPathPrefix();
|
|
142
|
+
return routes.map((route) => ({
|
|
143
|
+
...route,
|
|
144
|
+
path: route.path === "/" ? prefix : `${prefix}${route.path}`
|
|
145
|
+
}));
|
|
115
146
|
}
|
|
116
|
-
async function getApiModuleRoutes() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
export async function getApiModuleRoutes() {
|
|
148
|
+
const modules = await getModules();
|
|
149
|
+
const active = modules.filter((m) => m.enabled);
|
|
150
|
+
const allRoutes = [];
|
|
151
|
+
for (const mod of active) {
|
|
152
|
+
try {
|
|
153
|
+
const instance = await getModuleInstance(mod.id);
|
|
154
|
+
if (instance?.routes?.api) {
|
|
155
|
+
allRoutes.push(...instance.routes.api);
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return allRoutes;
|
|
124
161
|
}
|
|
125
|
-
async function getModuleWidgets(area) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
162
|
+
export async function getModuleWidgets(area) {
|
|
163
|
+
const modules = await getModules();
|
|
164
|
+
const active = modules.filter((m) => m.enabled);
|
|
165
|
+
const widgets = [];
|
|
166
|
+
for (const mod of active) {
|
|
167
|
+
try {
|
|
168
|
+
const instance = await getModuleInstance(mod.id);
|
|
169
|
+
if (instance?.widgets) {
|
|
170
|
+
const matching = instance.widgets.filter(
|
|
171
|
+
(w) => w.area === area
|
|
172
|
+
);
|
|
173
|
+
widgets.push(...matching);
|
|
174
|
+
}
|
|
175
|
+
} catch (_e) {
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return widgets.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
136
179
|
}
|
|
137
|
-
async function getExtensions(targetModule, point) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
180
|
+
export async function getExtensions(targetModule, point) {
|
|
181
|
+
const modules = await getModules();
|
|
182
|
+
const active = modules.filter((m) => m.enabled);
|
|
183
|
+
const extensions = [];
|
|
184
|
+
for (const mod of active) {
|
|
185
|
+
try {
|
|
186
|
+
const instance = await getModuleInstance(mod.id);
|
|
187
|
+
if (instance?.extensions) {
|
|
188
|
+
const matching = instance.extensions.filter((ext) => {
|
|
189
|
+
const isTarget = ext.targetModule === targetModule;
|
|
190
|
+
const isPoint = point ? ext.point === point : true;
|
|
191
|
+
return isTarget && isPoint;
|
|
192
|
+
});
|
|
193
|
+
extensions.push(...matching);
|
|
194
|
+
}
|
|
195
|
+
} catch (_e) {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return extensions.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
152
199
|
}
|
|
153
|
-
async function hasExtension(targetModule, point) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
200
|
+
export async function hasExtension(targetModule, point) {
|
|
201
|
+
const modules = await getModules();
|
|
202
|
+
const active = modules.filter((m) => m.enabled);
|
|
203
|
+
for (const mod of active) {
|
|
204
|
+
try {
|
|
205
|
+
const instance = await getModuleInstance(mod.id);
|
|
206
|
+
if (instance?.extensions) {
|
|
207
|
+
const matching = instance.extensions.filter((ext) => {
|
|
208
|
+
const isTarget = ext.targetModule === targetModule;
|
|
209
|
+
const isPoint = point ? ext.point === point : true;
|
|
210
|
+
return isTarget && isPoint;
|
|
211
|
+
});
|
|
212
|
+
if (matching.length > 0) return true;
|
|
213
|
+
}
|
|
214
|
+
} catch (_e) {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
166
218
|
}
|
|
167
|
-
|
|
168
|
-
//#endregion
|
|
169
|
-
export { getApiModuleRoutes, getExtensions, getKryoModuleNavigationGrouped, getKryoModuleRoutes, getKryoPathPrefix, getModuleNavigation, getModuleNavigationGrouped, getModuleWidgets, getPrivateModuleRoutes, getPublicModuleRoutes, hasExtension };
|
package/dist/server.cjs
CHANGED
|
@@ -1,30 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
const require_types = require('./types.cjs');
|
|
3
|
-
const require_manage = require('./server/manage.cjs');
|
|
4
|
-
const require_ui = require('./server/ui.cjs');
|
|
5
|
-
const require_lifecycle = require('./server/lifecycle.cjs');
|
|
6
|
-
const require_registry = require('./server/registry.cjs');
|
|
1
|
+
"use strict";
|
|
7
2
|
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports
|
|
26
|
-
exports
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _lifecycle = require("./server/lifecycle.js");
|
|
7
|
+
Object.keys(_lifecycle).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _lifecycle[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _lifecycle[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _manage = require("./server/manage.js");
|
|
18
|
+
Object.keys(_manage).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _manage[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _manage[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _registry = require("./server/registry.js");
|
|
29
|
+
Object.keys(_registry).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _registry[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _registry[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _ui = require("./server/ui.js");
|
|
40
|
+
Object.keys(_ui).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _ui[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _ui[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _types = require("./types.js");
|
|
51
|
+
Object.keys(_types).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _types[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
package/dist/server.d.ts
ADDED
package/dist/server.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export { ModuleManifestSchema, getApiModuleRoutes, getExtensions, getKryoModuleNavigationGrouped, getKryoModuleRoutes, getKryoPathPrefix, getModuleConfig, getModuleInstance, getModuleNavigation, getModuleNavigationGrouped, getModuleStatus, getModuleWidgets, getModules, getPrivateModuleRoutes, getPublicModuleRoutes, hasExtension, initModules, initOperationalModules, isModuleEnabled, pushModuleSchema, registerModules, toggleModuleState, updateModuleConfig };
|
|
1
|
+
export * from "./server/lifecycle.js";
|
|
2
|
+
export * from "./server/manage.js";
|
|
3
|
+
export * from "./server/registry.js";
|
|
4
|
+
export * from "./server/ui.js";
|
|
5
|
+
export * from "./types.js";
|
package/dist/types.cjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
let zod = require("zod");
|
|
1
|
+
"use strict";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id: zod.z.string(),
|
|
7
|
-
name: zod.z.string(),
|
|
8
|
-
version: zod.z.string(),
|
|
9
|
-
description: zod.z.string().optional(),
|
|
10
|
-
dependencies: zod.z.array(zod.z.string()).default([]),
|
|
11
|
-
extends: zod.z.array(zod.z.string()).default([]),
|
|
12
|
-
enabled: zod.z.boolean().default(true),
|
|
13
|
-
system: zod.z.boolean().default(false),
|
|
14
|
-
npmDependencies: zod.z.array(zod.z.string()).optional(),
|
|
15
|
-
npmDevDependencies: zod.z.array(zod.z.string()).optional()
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
16
5
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.ModuleManifestSchema =
|
|
6
|
+
exports.ModuleManifestSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
const ModuleManifestSchema = exports.ModuleManifestSchema = _zod.z.object({
|
|
9
|
+
id: _zod.z.string(),
|
|
10
|
+
name: _zod.z.string(),
|
|
11
|
+
version: _zod.z.string(),
|
|
12
|
+
description: _zod.z.string().optional(),
|
|
13
|
+
dependencies: _zod.z.array(_zod.z.string()).default([]),
|
|
14
|
+
extends: _zod.z.array(_zod.z.string()).default([]),
|
|
15
|
+
// NOWE: Lista modułów, które ten moduł rozszerza
|
|
16
|
+
enabled: _zod.z.boolean().default(true),
|
|
17
|
+
system: _zod.z.boolean().default(false),
|
|
18
|
+
npmDependencies: _zod.z.array(_zod.z.string()).optional(),
|
|
19
|
+
npmDevDependencies: _zod.z.array(_zod.z.string()).optional()
|
|
20
|
+
});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { SystemEvent, UserPermission, UserRole } from "@arch-cadre/core";
|
|
2
|
+
export type { SystemEvent };
|
|
3
|
+
import type { Metadata } from "next";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export type SidebarGroupType = {
|
|
6
|
+
title: string;
|
|
7
|
+
items: SidebarMenuType;
|
|
8
|
+
};
|
|
9
|
+
export type SidebarMenuItemType<T = Record<string, string>> = {
|
|
10
|
+
id?: string;
|
|
11
|
+
title: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
url: string;
|
|
14
|
+
roles?: string[];
|
|
15
|
+
permissions?: string[];
|
|
16
|
+
badge?: string | number | null | undefined;
|
|
17
|
+
badgeVariant?: "default" | "secondary" | "destructive" | "outline" | null | undefined;
|
|
18
|
+
} & T;
|
|
19
|
+
export type SidebarMenuType = SidebarMenuItemType<{
|
|
20
|
+
items?: SidebarMenuItemType[];
|
|
21
|
+
}>[];
|
|
22
|
+
export declare const ModuleManifestSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
version: z.ZodString;
|
|
26
|
+
description: z.ZodOptional<z.ZodString>;
|
|
27
|
+
dependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
28
|
+
extends: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
29
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
system: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
npmDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
npmDevDependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type ModuleManifest = z.infer<typeof ModuleManifestSchema>;
|
|
35
|
+
export interface ModuleExtension {
|
|
36
|
+
id: string;
|
|
37
|
+
targetModule: string;
|
|
38
|
+
point: string;
|
|
39
|
+
component: React.ComponentType<any>;
|
|
40
|
+
priority?: number;
|
|
41
|
+
metadata?: any;
|
|
42
|
+
}
|
|
43
|
+
export interface ModulePageProps {
|
|
44
|
+
params: any;
|
|
45
|
+
searchParams: any;
|
|
46
|
+
}
|
|
47
|
+
export interface ModuleRouteDefinition {
|
|
48
|
+
id?: string;
|
|
49
|
+
roles?: UserRole[];
|
|
50
|
+
permissions?: UserPermission[];
|
|
51
|
+
component: React.ComponentType<any>;
|
|
52
|
+
layout?: React.ComponentType<{
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
}>;
|
|
55
|
+
generateMetadata?: (props: ModulePageProps) => Promise<Metadata> | Metadata;
|
|
56
|
+
}
|
|
57
|
+
export interface ModuleWidget {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
area: "dashboard-stats" | "dashboard-main" | "sidebar-bottom" | string;
|
|
61
|
+
component: React.ComponentType<any>;
|
|
62
|
+
priority?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface IModule {
|
|
65
|
+
manifest: ModuleManifest;
|
|
66
|
+
schema?: any;
|
|
67
|
+
onMigrate?: () => Promise<void>;
|
|
68
|
+
onEnable?: () => Promise<void>;
|
|
69
|
+
onDisable?: () => Promise<void>;
|
|
70
|
+
init?: () => Promise<void>;
|
|
71
|
+
widgets?: ModuleWidget[];
|
|
72
|
+
extensions?: ModuleExtension[];
|
|
73
|
+
navigation?: ModuleNavigation;
|
|
74
|
+
routes?: {
|
|
75
|
+
public?: PublicRouteDefinition[];
|
|
76
|
+
private?: PrivateRouteDefinition[];
|
|
77
|
+
api?: ApiRouteDefinition[];
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Element menu zarejestrowany przez moduł.
|
|
82
|
+
*/
|
|
83
|
+
export type ModuleNavElement = SidebarMenuItemType<{
|
|
84
|
+
items?: SidebarMenuItemType[];
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Mapa nawigacji modułu.
|
|
88
|
+
* Klucz: Nazwa grupy (np. "CMS", "Platform", "Journal")
|
|
89
|
+
* Vartość: Tablica elementów menu trafiających do tej grupy.
|
|
90
|
+
*/
|
|
91
|
+
export type ModuleNavigationGroupMap = Record<string, ModuleNavElement[]>;
|
|
92
|
+
export interface PublicRouteDefinition extends ModuleRouteDefinition {
|
|
93
|
+
path: string;
|
|
94
|
+
auth?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export interface PrivateRouteDefinition extends ModuleRouteDefinition {
|
|
97
|
+
path: string;
|
|
98
|
+
auth?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface ApiRouteDefinition {
|
|
101
|
+
id?: string;
|
|
102
|
+
path: string;
|
|
103
|
+
handler: (request: Request, context: any) => Promise<Response> | Response;
|
|
104
|
+
auth?: boolean;
|
|
105
|
+
roles?: UserRole[];
|
|
106
|
+
permissions?: UserPermission[];
|
|
107
|
+
}
|
|
108
|
+
export interface ModuleNavigation {
|
|
109
|
+
public?: ModuleNavElement[];
|
|
110
|
+
admin?: ModuleNavigationGroupMap;
|
|
111
|
+
settings?: ModuleNavigationGroupMap;
|
|
112
|
+
globalRoutes?: (PublicRouteDefinition | PrivateRouteDefinition | ApiRouteDefinition)[];
|
|
113
|
+
}
|