@arch-cadre/modules 0.0.63 → 0.0.65
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.d.ts +11 -0
- package/dist/client/extension-point-client.d.ts.map +1 -0
- package/dist/client/extension-point-client.js +19 -0
- package/dist/client/extension-point.d.ts +10 -0
- package/dist/client/extension-point.d.ts.map +1 -0
- package/dist/client/extension-point.js +12 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/widget-area.d.ts +10 -0
- package/dist/client/widget-area.d.ts.map +1 -0
- package/dist/client/widget-area.js +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/server/lifecycle.d.ts +6 -0
- package/dist/server/lifecycle.d.ts.map +1 -0
- package/dist/server/lifecycle.js +250 -0
- package/dist/server/manage.d.ts +27 -0
- package/dist/server/manage.d.ts.map +1 -0
- package/dist/server/manage.js +143 -0
- package/dist/server/registry.d.ts +2 -0
- package/dist/server/registry.d.ts.map +1 -0
- package/dist/server/registry.js +118 -0
- package/dist/server/ui.d.ts +13 -0
- package/dist/server/ui.d.ts.map +1 -0
- package/dist/server/ui.js +235 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +8 -0
- package/dist/types.d.ts +114 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/package.json +9 -16
- package/dist/_virtual/_rolldown/runtime.cjs +0 -1
- package/dist/client/extension-point-client.cjs +0 -1
- package/dist/client/extension-point-client.d.cts +0 -20
- package/dist/client/extension-point-client.d.cts.map +0 -1
- package/dist/client/extension-point-client.d.mts +0 -20
- package/dist/client/extension-point-client.d.mts.map +0 -1
- package/dist/client/extension-point-client.mjs +0 -2
- package/dist/client/extension-point-client.mjs.map +0 -1
- package/dist/client/extension-point.cjs +0 -1
- package/dist/client/extension-point.d.cts +0 -21
- package/dist/client/extension-point.d.cts.map +0 -1
- package/dist/client/extension-point.d.mts +0 -21
- package/dist/client/extension-point.d.mts.map +0 -1
- package/dist/client/extension-point.mjs +0 -2
- package/dist/client/extension-point.mjs.map +0 -1
- package/dist/client/widget-area.cjs +0 -1
- package/dist/client/widget-area.d.cts +0 -19
- package/dist/client/widget-area.d.cts.map +0 -1
- package/dist/client/widget-area.d.mts +0 -19
- package/dist/client/widget-area.d.mts.map +0 -1
- package/dist/client/widget-area.mjs +0 -2
- package/dist/client/widget-area.mjs.map +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -5
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -1
- package/dist/server/lifecycle.cjs +0 -1
- package/dist/server/lifecycle.d.cts +0 -9
- package/dist/server/lifecycle.d.cts.map +0 -1
- package/dist/server/lifecycle.d.mts +0 -9
- package/dist/server/lifecycle.d.mts.map +0 -1
- package/dist/server/lifecycle.mjs +0 -2
- package/dist/server/lifecycle.mjs.map +0 -1
- package/dist/server/manage.cjs +0 -1
- package/dist/server/manage.d.cts +0 -31
- package/dist/server/manage.d.cts.map +0 -1
- package/dist/server/manage.d.mts +0 -31
- package/dist/server/manage.d.mts.map +0 -1
- package/dist/server/manage.mjs +0 -2
- package/dist/server/manage.mjs.map +0 -1
- package/dist/server/registry.cjs +0 -1
- package/dist/server/registry.d.cts +0 -5
- package/dist/server/registry.d.cts.map +0 -1
- package/dist/server/registry.d.mts +0 -5
- package/dist/server/registry.d.mts.map +0 -1
- package/dist/server/registry.mjs +0 -2
- package/dist/server/registry.mjs.map +0 -1
- package/dist/server/ui.cjs +0 -1
- package/dist/server/ui.d.cts +0 -17
- package/dist/server/ui.d.cts.map +0 -1
- package/dist/server/ui.d.mts +0 -17
- package/dist/server/ui.d.mts.map +0 -1
- package/dist/server/ui.mjs +0 -2
- package/dist/server/ui.mjs.map +0 -1
- package/dist/server.cjs +0 -1
- package/dist/server.d.cts +0 -6
- package/dist/server.d.mts +0 -6
- package/dist/server.mjs +0 -1
- package/dist/types.cjs +0 -1
- package/dist/types.d.cts +0 -117
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts +0 -117
- package/dist/types.d.mts.map +0 -1
- package/dist/types.mjs +0 -2
- package/dist/types.mjs.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { eventBus, systemModulesTable } from "@arch-cadre/core";
|
|
3
|
+
import { db } from "@arch-cadre/core/server";
|
|
4
|
+
import { eq } from "drizzle-orm";
|
|
5
|
+
import { getModuleInstance, getModules, isModuleEnabled } from "./manage";
|
|
6
|
+
const globalForRegistry = globalThis;
|
|
7
|
+
export async function initModules(force = false) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
if (globalForRegistry.__KRYO_MODULES_INITIALIZED__ && !force)
|
|
10
|
+
return;
|
|
11
|
+
if (force) {
|
|
12
|
+
console.log("[Kernel:Registry] Forcing re-initialization...");
|
|
13
|
+
eventBus.clearAll();
|
|
14
|
+
}
|
|
15
|
+
console.log("[Kernel:Registry] Synchronizing module listeners...");
|
|
16
|
+
globalForRegistry.__KRYO_MODULES_INITIALIZED__ = true;
|
|
17
|
+
await eventBus.publish("system:modules:init:start", {
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
});
|
|
20
|
+
const processedModuleIds = new Set();
|
|
21
|
+
let hasNewModules = true;
|
|
22
|
+
let iterations = 0;
|
|
23
|
+
const MAX_ITERATIONS = 10; // Bezpiecznik przed nieskończoną pętlą
|
|
24
|
+
while (hasNewModules && iterations < MAX_ITERATIONS) {
|
|
25
|
+
hasNewModules = false;
|
|
26
|
+
iterations++;
|
|
27
|
+
// 1. Get ALL currently registered modules (including newly added ones)
|
|
28
|
+
const currentModules = await getModules();
|
|
29
|
+
// 2. Filter out modules that are already processed
|
|
30
|
+
const pendingModules = currentModules.filter((mod) => !processedModuleIds.has(mod.id));
|
|
31
|
+
if (pendingModules.length === 0) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
// 3. Synchronize new modules with database
|
|
35
|
+
for (const mod of pendingModules) {
|
|
36
|
+
try {
|
|
37
|
+
await db
|
|
38
|
+
.insert(systemModulesTable)
|
|
39
|
+
.values({
|
|
40
|
+
id: mod.id,
|
|
41
|
+
enabled: (_a = mod.system) !== null && _a !== void 0 ? _a : false,
|
|
42
|
+
installed: (_b = mod.system) !== null && _b !== void 0 ? _b : false,
|
|
43
|
+
system: (_c = mod.system) !== null && _c !== void 0 ? _c : false,
|
|
44
|
+
})
|
|
45
|
+
.onConflictDoNothing();
|
|
46
|
+
}
|
|
47
|
+
catch (_e) {
|
|
48
|
+
// Table might not exist yet
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// 4. Sort pending modules: system modules first
|
|
52
|
+
const sortedPending = [...pendingModules].sort((a, b) => a.system === b.system ? 0 : a.system ? -1 : 1);
|
|
53
|
+
// 5. Initialize modules
|
|
54
|
+
for (const mod of sortedPending) {
|
|
55
|
+
// Mark as processed immediately to avoid cycles
|
|
56
|
+
processedModuleIds.add(mod.id);
|
|
57
|
+
hasNewModules = true; // We processed something, so we should check again in case it added more
|
|
58
|
+
try {
|
|
59
|
+
const enabled = await isModuleEnabled(mod.id);
|
|
60
|
+
if (!enabled)
|
|
61
|
+
continue;
|
|
62
|
+
const instance = await getModuleInstance(mod.id);
|
|
63
|
+
if (!instance) {
|
|
64
|
+
console.warn(`[Kernel:Registry] No instance found for module ${mod.id}. Ensure it is registered correctly.`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
let dbMod = null;
|
|
68
|
+
try {
|
|
69
|
+
[dbMod] = await db
|
|
70
|
+
.select()
|
|
71
|
+
.from(systemModulesTable)
|
|
72
|
+
.where(eq(systemModulesTable.id, mod.id));
|
|
73
|
+
}
|
|
74
|
+
catch (_e) {
|
|
75
|
+
// Ignore missing table
|
|
76
|
+
}
|
|
77
|
+
// onEnable lifecycle
|
|
78
|
+
if (enabled && (!dbMod || !dbMod.installed)) {
|
|
79
|
+
console.log(`[Kernel:Registry] Installing module ${mod.id}...`);
|
|
80
|
+
// 1. Run migrations first
|
|
81
|
+
if (instance.onMigrate) {
|
|
82
|
+
console.log(`[Kernel:Registry] Running onMigrate for ${mod.id}...`);
|
|
83
|
+
await instance.onMigrate();
|
|
84
|
+
}
|
|
85
|
+
// 2. Run enable hook
|
|
86
|
+
console.log(`[Kernel:Registry] Running onEnable for ${mod.id}...`);
|
|
87
|
+
if (instance.onEnable)
|
|
88
|
+
await instance.onEnable();
|
|
89
|
+
try {
|
|
90
|
+
await db
|
|
91
|
+
.update(systemModulesTable)
|
|
92
|
+
.set({ installed: true, lastStep: null })
|
|
93
|
+
.where(eq(systemModulesTable.id, mod.id));
|
|
94
|
+
}
|
|
95
|
+
catch (_e) {
|
|
96
|
+
// Ignore missing table
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Operational init
|
|
100
|
+
if (instance.init) {
|
|
101
|
+
console.log(`[Kernel:Registry] Initializing ${mod.id}...`);
|
|
102
|
+
await instance.init();
|
|
103
|
+
console.log(`[Kernel:Registry] Module ${mod.id} is active.`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error(`[Kernel:Registry] Critical failure for ${mod.id}:`, error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (iterations >= MAX_ITERATIONS) {
|
|
112
|
+
console.warn("[Kernel:Registry] Max init iterations reached. Check for circular module registrations.");
|
|
113
|
+
}
|
|
114
|
+
await eventBus.publish("system:modules:init:end", {
|
|
115
|
+
timestamp: Date.now(),
|
|
116
|
+
moduleCount: processedModuleIds.size,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ApiRouteDefinition, ModuleExtension, ModuleNavElement, ModuleWidget, PrivateRouteDefinition, PublicRouteDefinition } from "../types";
|
|
2
|
+
export declare function getModuleNavigationGrouped(type: "admin" | "settings"): Promise<Record<string, ModuleNavElement[]>>;
|
|
3
|
+
export declare function getKryoPathPrefix(): Promise<string>;
|
|
4
|
+
export declare function getKryoModuleNavigationGrouped(type: "admin" | "settings"): Promise<Record<string, ModuleNavElement[]>>;
|
|
5
|
+
export declare function getModuleNavigation(type: "public"): Promise<ModuleNavElement[]>;
|
|
6
|
+
export declare function getPublicModuleRoutes(): Promise<PublicRouteDefinition[]>;
|
|
7
|
+
export declare function getPrivateModuleRoutes(): Promise<PrivateRouteDefinition[]>;
|
|
8
|
+
export declare function getKryoModuleRoutes(): Promise<PrivateRouteDefinition[]>;
|
|
9
|
+
export declare function getApiModuleRoutes(): Promise<ApiRouteDefinition[]>;
|
|
10
|
+
export declare function getModuleWidgets(area: string): Promise<ModuleWidget[]>;
|
|
11
|
+
export declare function getExtensions(targetModule: string, point?: string): Promise<ModuleExtension[]>;
|
|
12
|
+
export declare function hasExtension(targetModule: string, point?: string): Promise<boolean>;
|
|
13
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/server/ui.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAEhB,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AA0ClB,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,+CAuC1E;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAOzD;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,OAAO,GAAG,UAAU,+CA0B3B;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAsB7B;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CACpD,qBAAqB,EAAE,CACxB,CAgBA;AAED,wBAAsB,sBAAsB,IAAI,OAAO,CACrD,sBAAsB,EAAE,CACzB,CAgBA;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAQ7E;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAcxE;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,2BAmBlD;AAED,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,8BAqBvE;AAED,wBAAsB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,oBAoBtE"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { getCurrentSession } from "@arch-cadre/core/server";
|
|
3
|
+
import { getModuleConfig, getModuleInstance, getModules } from "./manage";
|
|
4
|
+
/**
|
|
5
|
+
* Helper to check and filter a navigation item based on roles and permissions.
|
|
6
|
+
* Returns the item (potentially with filtered sub-items) or null if access is denied.
|
|
7
|
+
*/
|
|
8
|
+
function filterNavItem(item, userRoles, userPermissions) {
|
|
9
|
+
// 1. Check access for the item itself
|
|
10
|
+
if (item.roles && item.roles.length > 0) {
|
|
11
|
+
if (!item.roles.some((role) => userRoles.includes(role))) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (item.permissions && item.permissions.length > 0) {
|
|
16
|
+
if (!item.permissions.every((perm) => userPermissions.includes(perm))) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// 2. Recursively filter sub-items if they exist
|
|
21
|
+
if (item.items && item.items.length > 0) {
|
|
22
|
+
const filteredSubItems = item.items
|
|
23
|
+
.map((subItem) => filterNavItem(subItem, userRoles, userPermissions))
|
|
24
|
+
.filter((subItem) => subItem !== null);
|
|
25
|
+
return {
|
|
26
|
+
...item,
|
|
27
|
+
items: filteredSubItems,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return item;
|
|
31
|
+
}
|
|
32
|
+
export async function getModuleNavigationGrouped(type) {
|
|
33
|
+
var _a;
|
|
34
|
+
const { user } = await getCurrentSession();
|
|
35
|
+
const userRoles = (user === null || user === void 0 ? void 0 : user.roles) || [];
|
|
36
|
+
const userPermissions = (user === null || user === void 0 ? void 0 : user.permissions) || [];
|
|
37
|
+
const modules = await getModules();
|
|
38
|
+
const active = modules.filter((m) => m.enabled);
|
|
39
|
+
const groups = {};
|
|
40
|
+
for (const mod of active) {
|
|
41
|
+
try {
|
|
42
|
+
const instance = await getModuleInstance(mod.id);
|
|
43
|
+
// 1. From instance
|
|
44
|
+
const instanceNav = (_a = instance === null || instance === void 0 ? void 0 : instance.navigation) === null || _a === void 0 ? void 0 : _a[type];
|
|
45
|
+
if (instanceNav) {
|
|
46
|
+
for (const [groupName, items] of Object.entries(instanceNav)) {
|
|
47
|
+
if (!groups[groupName])
|
|
48
|
+
groups[groupName] = [];
|
|
49
|
+
for (const rawItem of items) {
|
|
50
|
+
const item = filterNavItem(rawItem, userRoles, userPermissions);
|
|
51
|
+
if (item &&
|
|
52
|
+
!groups[groupName].some((existing) => existing.url === item.url)) {
|
|
53
|
+
groups[groupName].push(item);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (_e) {
|
|
60
|
+
console.warn(`[Kernel:UI] Failed to load navigation for module ${mod.id}:`, _e);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return groups;
|
|
64
|
+
}
|
|
65
|
+
export async function getKryoPathPrefix() {
|
|
66
|
+
var _a;
|
|
67
|
+
try {
|
|
68
|
+
const config = await getModuleConfig("kryo-panel");
|
|
69
|
+
return (_a = config === null || config === void 0 ? void 0 : config.pathPrefix) !== null && _a !== void 0 ? _a : "/kryo";
|
|
70
|
+
}
|
|
71
|
+
catch (_e) {
|
|
72
|
+
return "/kryo";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export async function getKryoModuleNavigationGrouped(type) {
|
|
76
|
+
const groups = await getModuleNavigationGrouped(type);
|
|
77
|
+
const prefix = await getKryoPathPrefix();
|
|
78
|
+
const prefixUrl = (url) => {
|
|
79
|
+
if (url.startsWith(prefix))
|
|
80
|
+
return url;
|
|
81
|
+
return url === "/" ? prefix : `${prefix}${url}`;
|
|
82
|
+
};
|
|
83
|
+
const processItems = (items) => {
|
|
84
|
+
return items.map((item) => ({
|
|
85
|
+
...item,
|
|
86
|
+
url: prefixUrl(item.url),
|
|
87
|
+
items: item.items
|
|
88
|
+
? processItems(item.items)
|
|
89
|
+
: undefined,
|
|
90
|
+
}));
|
|
91
|
+
};
|
|
92
|
+
const transformedGroups = {};
|
|
93
|
+
for (const [group, items] of Object.entries(groups)) {
|
|
94
|
+
transformedGroups[group] = processItems(items);
|
|
95
|
+
}
|
|
96
|
+
return transformedGroups;
|
|
97
|
+
}
|
|
98
|
+
export async function getModuleNavigation(type) {
|
|
99
|
+
var _a;
|
|
100
|
+
const { user } = await getCurrentSession();
|
|
101
|
+
const userRoles = (user === null || user === void 0 ? void 0 : user.roles) || [];
|
|
102
|
+
const userPermissions = (user === null || user === void 0 ? void 0 : user.permissions) || [];
|
|
103
|
+
const modules = await getModules();
|
|
104
|
+
const active = modules.filter((m) => m.enabled);
|
|
105
|
+
const all = [];
|
|
106
|
+
for (const mod of active) {
|
|
107
|
+
try {
|
|
108
|
+
const instance = await getModuleInstance(mod.id);
|
|
109
|
+
if ((_a = instance === null || instance === void 0 ? void 0 : instance.navigation) === null || _a === void 0 ? void 0 : _a[type]) {
|
|
110
|
+
const items = instance.navigation[type];
|
|
111
|
+
for (const rawItem of items) {
|
|
112
|
+
const item = filterNavItem(rawItem, userRoles, userPermissions);
|
|
113
|
+
if (item)
|
|
114
|
+
all.push(item);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch { }
|
|
119
|
+
}
|
|
120
|
+
return all;
|
|
121
|
+
}
|
|
122
|
+
export async function getPublicModuleRoutes() {
|
|
123
|
+
var _a;
|
|
124
|
+
const modules = await getModules();
|
|
125
|
+
const active = modules.filter((m) => m.enabled);
|
|
126
|
+
const allRoutes = [];
|
|
127
|
+
for (const mod of active) {
|
|
128
|
+
try {
|
|
129
|
+
const instance = await getModuleInstance(mod.id);
|
|
130
|
+
// 1. Try from instance (if pre-defined)
|
|
131
|
+
if ((_a = instance === null || instance === void 0 ? void 0 : instance.routes) === null || _a === void 0 ? void 0 : _a.public) {
|
|
132
|
+
allRoutes.push(...instance.routes.public);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch { }
|
|
136
|
+
}
|
|
137
|
+
return allRoutes;
|
|
138
|
+
}
|
|
139
|
+
export async function getPrivateModuleRoutes() {
|
|
140
|
+
var _a;
|
|
141
|
+
const modules = await getModules();
|
|
142
|
+
const active = modules.filter((m) => m.enabled);
|
|
143
|
+
const allRoutes = [];
|
|
144
|
+
for (const mod of active) {
|
|
145
|
+
try {
|
|
146
|
+
const instance = await getModuleInstance(mod.id);
|
|
147
|
+
// 1. Try from instance
|
|
148
|
+
if ((_a = instance === null || instance === void 0 ? void 0 : instance.routes) === null || _a === void 0 ? void 0 : _a.private) {
|
|
149
|
+
allRoutes.push(...instance.routes.private);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch { }
|
|
153
|
+
}
|
|
154
|
+
return allRoutes;
|
|
155
|
+
}
|
|
156
|
+
export async function getKryoModuleRoutes() {
|
|
157
|
+
const routes = await getPrivateModuleRoutes();
|
|
158
|
+
const prefix = await getKryoPathPrefix();
|
|
159
|
+
return routes.map((route) => ({
|
|
160
|
+
...route,
|
|
161
|
+
path: route.path === "/" ? prefix : `${prefix}${route.path}`,
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
export async function getApiModuleRoutes() {
|
|
165
|
+
var _a;
|
|
166
|
+
const modules = await getModules();
|
|
167
|
+
const active = modules.filter((m) => m.enabled);
|
|
168
|
+
const allRoutes = [];
|
|
169
|
+
for (const mod of active) {
|
|
170
|
+
try {
|
|
171
|
+
const instance = await getModuleInstance(mod.id);
|
|
172
|
+
if ((_a = instance === null || instance === void 0 ? void 0 : instance.routes) === null || _a === void 0 ? void 0 : _a.api) {
|
|
173
|
+
allRoutes.push(...instance.routes.api);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch { }
|
|
177
|
+
}
|
|
178
|
+
return allRoutes;
|
|
179
|
+
}
|
|
180
|
+
export async function getModuleWidgets(area) {
|
|
181
|
+
const modules = await getModules();
|
|
182
|
+
const active = modules.filter((m) => m.enabled);
|
|
183
|
+
const widgets = [];
|
|
184
|
+
for (const mod of active) {
|
|
185
|
+
try {
|
|
186
|
+
const instance = await getModuleInstance(mod.id);
|
|
187
|
+
if (instance === null || instance === void 0 ? void 0 : instance.widgets) {
|
|
188
|
+
const matching = instance.widgets.filter((w) => w.area === area);
|
|
189
|
+
widgets.push(...matching);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (_e) { }
|
|
193
|
+
}
|
|
194
|
+
return widgets.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
195
|
+
}
|
|
196
|
+
export async function getExtensions(targetModule, point) {
|
|
197
|
+
const modules = await getModules();
|
|
198
|
+
const active = modules.filter((m) => m.enabled);
|
|
199
|
+
const extensions = [];
|
|
200
|
+
for (const mod of active) {
|
|
201
|
+
try {
|
|
202
|
+
const instance = await getModuleInstance(mod.id);
|
|
203
|
+
if (instance === null || instance === void 0 ? void 0 : instance.extensions) {
|
|
204
|
+
const matching = instance.extensions.filter((ext) => {
|
|
205
|
+
const isTarget = ext.targetModule === targetModule;
|
|
206
|
+
const isPoint = point ? ext.point === point : true;
|
|
207
|
+
return isTarget && isPoint;
|
|
208
|
+
});
|
|
209
|
+
extensions.push(...matching);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (_e) { }
|
|
213
|
+
}
|
|
214
|
+
return extensions.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
215
|
+
}
|
|
216
|
+
export async function hasExtension(targetModule, point) {
|
|
217
|
+
const modules = await getModules();
|
|
218
|
+
const active = modules.filter((m) => m.enabled);
|
|
219
|
+
for (const mod of active) {
|
|
220
|
+
try {
|
|
221
|
+
const instance = await getModuleInstance(mod.id);
|
|
222
|
+
if (instance === null || instance === void 0 ? void 0 : instance.extensions) {
|
|
223
|
+
const matching = instance.extensions.filter((ext) => {
|
|
224
|
+
const isTarget = ext.targetModule === targetModule;
|
|
225
|
+
const isPoint = point ? ext.point === point : true;
|
|
226
|
+
return isTarget && isPoint;
|
|
227
|
+
});
|
|
228
|
+
if (matching.length > 0)
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (_e) { }
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
235
|
+
}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// export { ExtensionPoint } from "./client/extension-point";
|
|
2
|
+
// Server-side Logic
|
|
3
|
+
export * from "./server/lifecycle";
|
|
4
|
+
export * from "./server/manage";
|
|
5
|
+
export * from "./server/registry";
|
|
6
|
+
export * from "./server/ui";
|
|
7
|
+
// Shared exports (from types/common logic)
|
|
8
|
+
export * from "./types";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
}
|
|
114
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ModuleManifestSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
name: z.string(),
|
|
5
|
+
version: z.string(),
|
|
6
|
+
description: z.string().optional(),
|
|
7
|
+
dependencies: z.array(z.string()).default([]),
|
|
8
|
+
extends: z.array(z.string()).default([]), // NOWE: Lista modułów, które ten moduł rozszerza
|
|
9
|
+
enabled: z.boolean().default(true),
|
|
10
|
+
system: z.boolean().default(false),
|
|
11
|
+
npmDependencies: z.array(z.string()).optional(),
|
|
12
|
+
npmDevDependencies: z.array(z.string()).optional(),
|
|
13
|
+
});
|
package/package.json
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arch-cadre/modules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"description": "Core Modules for Kryo framework",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "./dist/index.d.cts",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
9
8
|
"exports": {
|
|
10
|
-
".":
|
|
11
|
-
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
},
|
|
14
|
-
"./server": {
|
|
15
|
-
"import": "./dist/server.mjs",
|
|
16
|
-
"require": "./dist/server.cjs"
|
|
17
|
-
},
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./server": "./dist/server.js",
|
|
18
11
|
"./package.json": "./package.json"
|
|
19
12
|
},
|
|
20
13
|
"files": [
|
|
@@ -26,23 +19,23 @@
|
|
|
26
19
|
"switch:prod": "node scripts/switchToDist.js",
|
|
27
20
|
"release": "npm publish --access public --no-git-checks",
|
|
28
21
|
"dev": "tsdown --watch",
|
|
29
|
-
"build": "
|
|
22
|
+
"build": "tsc",
|
|
30
23
|
"postbuilds": "find dist -name '*.d.mts' -exec sh -c 'mv \"$1\" \"${1%.d.mts}.d.ts\"' _ {} \\; && find dist -name '*.d.mts.map' -exec sh -c 'mv \"$1\" \"${1%.d.mts.map}.d.ts.map\"' _ {} \\;"
|
|
31
24
|
},
|
|
32
25
|
"dependencies": {
|
|
33
|
-
"@arch-cadre/core": "^0.0.
|
|
26
|
+
"@arch-cadre/core": "^0.0.39",
|
|
34
27
|
"server-only": "^0.0.1",
|
|
35
28
|
"zod": "^4.1.12"
|
|
36
29
|
},
|
|
37
30
|
"peerDependencies": {
|
|
38
|
-
"@arch-cadre/core": "^0.0.
|
|
31
|
+
"@arch-cadre/core": "^0.0.39",
|
|
39
32
|
"drizzle-orm": "1.0.0-beta.6-4414a19",
|
|
40
33
|
"next": ">=15.0.0",
|
|
41
34
|
"react": "^19.0.0",
|
|
42
35
|
"react-dom": "^19.0.0"
|
|
43
36
|
},
|
|
44
37
|
"devDependencies": {
|
|
45
|
-
"@arch-cadre/core": "^0.0.
|
|
38
|
+
"@arch-cadre/core": "^0.0.39",
|
|
46
39
|
"@types/react": "^19",
|
|
47
40
|
"@types/react-dom": "^19",
|
|
48
41
|
"tsdown": "^0.20.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../server/ui.cjs`);let n=require(`react/jsx-runtime`),r=require(`react`);r=e.__toESM(r);function i({module:e,point:i,className:a,props:o,fallback:s}){let[c,l]=(0,r.useState)([]);return(0,r.useEffect)(()=>{t.getExtensions(e,i).then(l)},[e,i]),c.length===0?s||null:(0,n.jsx)(`div`,{className:a,children:c.map(e=>{let t=e.component;return t?(0,n.jsx)(t,{...o},e.id):null})})}exports.ExtensionPointClient=i;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/client/extension-point-client.d.ts
|
|
4
|
-
interface ExtensionPointProps {
|
|
5
|
-
module: string;
|
|
6
|
-
point: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
props?: any;
|
|
9
|
-
fallback?: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
declare function ExtensionPointClient({
|
|
12
|
-
module,
|
|
13
|
-
point,
|
|
14
|
-
className,
|
|
15
|
-
props,
|
|
16
|
-
fallback
|
|
17
|
-
}: ExtensionPointProps): any;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { ExtensionPointClient };
|
|
20
|
-
//# sourceMappingURL=extension-point-client.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension-point-client.d.cts","names":[],"sources":["../../src/client/extension-point-client.tsx"],"mappings":";;;UAOU,mBAAA;EACR,MAAA;EACA,KAAA;EACA,SAAA;EACA,KAAA;EACA,QAAA,GAAW,KAAA,CAAM,SAAA;AAAA;AAAA,iBAGH,oBAAA,CAAA;EACd,MAAA;EACA,KAAA;EACA,SAAA;EACA,KAAA;EACA;AAAA,GACC,mBAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/client/extension-point-client.d.ts
|
|
4
|
-
interface ExtensionPointProps {
|
|
5
|
-
module: string;
|
|
6
|
-
point: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
props?: any;
|
|
9
|
-
fallback?: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
declare function ExtensionPointClient({
|
|
12
|
-
module,
|
|
13
|
-
point,
|
|
14
|
-
className,
|
|
15
|
-
props,
|
|
16
|
-
fallback
|
|
17
|
-
}: ExtensionPointProps): any;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { ExtensionPointClient };
|
|
20
|
-
//# sourceMappingURL=extension-point-client.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension-point-client.d.mts","names":[],"sources":["../../src/client/extension-point-client.tsx"],"mappings":";;;UAOU,mBAAA;EACR,MAAA;EACA,KAAA;EACA,SAAA;EACA,KAAA;EACA,QAAA,GAAW,KAAA,CAAM,SAAA;AAAA;AAAA,iBAGH,oBAAA,CAAA;EACd,MAAA;EACA,KAAA;EACA,SAAA;EACA,KAAA;EACA;AAAA,GACC,mBAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{getExtensions as e}from"../server/ui.mjs";import{jsx as t}from"react/jsx-runtime";import{useEffect as n,useState as r}from"react";function i({module:i,point:a,className:o,props:s,fallback:c}){let[l,u]=r([]);return n(()=>{e(i,a).then(u)},[i,a]),l.length===0?c||null:t(`div`,{className:o,children:l.map(e=>{let n=e.component;return n?t(n,{...s},e.id):null})})}export{i as ExtensionPointClient};
|
|
2
|
-
//# sourceMappingURL=extension-point-client.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension-point-client.mjs","names":[],"sources":["../../src/client/extension-point-client.tsx"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: <> */\n\"use client\";\nimport * as React from \"react\";\n\nimport { useEffect, useState } from \"react\";\nimport { getExtensions } from \"../server/ui\";\n\ninterface ExtensionPointProps {\n module: string;\n point: string;\n className?: string;\n props?: any;\n fallback?: React.ReactNode;\n}\n\nexport function ExtensionPointClient({\n module,\n point,\n className,\n props,\n fallback,\n}: ExtensionPointProps) {\n const [extensions, setExtensions] = useState<any[]>([]);\n\n useEffect(() => {\n getExtensions(module, point).then(setExtensions);\n }, [module, point]);\n\n if (extensions.length === 0) return (fallback as any) || null;\n\n return (\n <div className={className}>\n {extensions.map((ext) => {\n const Component = ext.component;\n if (!Component) return null;\n return <Component key={ext.id} {...props} />;\n })}\n </div>\n );\n}\n"],"mappings":"sJAeA,SAAgB,EAAqB,CACnC,SACA,QACA,YACA,QACA,YACsB,CACtB,GAAM,CAAC,EAAY,GAAiB,EAAgB,EAAE,CAAC,CAQvD,OANA,MAAgB,CACd,EAAc,EAAQ,EAAM,CAAC,KAAK,EAAc,EAC/C,CAAC,EAAQ,EAAM,CAAC,CAEf,EAAW,SAAW,EAAW,GAAoB,KAGvD,EAAC,MAAA,CAAe,qBACb,EAAW,IAAK,GAAQ,CACvB,IAAM,EAAY,EAAI,UAEtB,OADK,EACE,EAAC,EAAA,CAAuB,GAAI,EAAA,CAAZ,EAAI,GAAiB,CADrB,MAEvB,EACE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../server/ui.cjs`);let t=require(`react/jsx-runtime`);async function n({module:n,point:r,className:i,props:a,fallback:o}){let s=await e.getExtensions(n,r);return s.length===0?o||null:(0,t.jsx)(`div`,{className:i,children:s.map(e=>{let n=e.component;return(0,t.jsx)(n,{...a},e.id)})})}exports.ExtensionPoint=n;
|