@flowselections/admin-installatietechniek 1.0.4 → 1.0.5
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-lib/components/AdminForInstallatieTechniek.d.ts.map +1 -1
- package/dist-lib/components/AdminForInstallatieTechniek.js +15 -4
- package/dist-lib/components/ModuleAccessGuard.d.ts +15 -0
- package/dist-lib/components/ModuleAccessGuard.d.ts.map +1 -0
- package/dist-lib/components/ModuleAccessGuard.js +40 -0
- package/dist-lib/hooks/useModulePermission.d.ts +8 -2
- package/dist-lib/hooks/useModulePermission.d.ts.map +1 -1
- package/dist-lib/hooks/useModulePermission.js +26 -23
- package/dist-lib/index.d.ts +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +2 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/auth-attacher.js +5 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +555 -117
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/auth-middleware.js +21 -7
- package/dist-lib/integrations/supabase/client.d.ts +555 -117
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +555 -117
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +567 -128
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/admin.functions.d.ts +30013 -1785
- package/dist-lib/lib/admin.functions.d.ts.map +1 -1
- package/dist-lib/lib/admin.functions.js +19 -1
- package/dist-lib/lib/permissions.server.d.ts +14 -0
- package/dist-lib/lib/permissions.server.d.ts.map +1 -0
- package/dist-lib/lib/permissions.server.js +26 -0
- package/package.json +87 -87
|
@@ -200,7 +200,7 @@ export const getRoles = createServerFn({ method: "GET" })
|
|
|
200
200
|
const [{ data: roles, error: rolesError }, { data: perms, error: permsError }, { data: registry, error: registryError }, { data: featureRows, error: featuresError },] = await Promise.all([
|
|
201
201
|
context.supabase.from("roles").select("id, key, name, is_protected").order("name", { ascending: true }),
|
|
202
202
|
context.supabase.from("role_permissions").select("role_id, module_id, feature_id, can_view, can_edit"),
|
|
203
|
-
context.supabase.from("module_registry").select("module_id, name, is_active").order("name", { ascending: true }),
|
|
203
|
+
context.supabase.from("module_registry").select("module_id, name, is_active, enforce").order("name", { ascending: true }),
|
|
204
204
|
context.supabase.from("module_features").select("module_id, feature_id, name, is_active").order("name", { ascending: true }),
|
|
205
205
|
]);
|
|
206
206
|
if (rolesError)
|
|
@@ -227,6 +227,7 @@ export const getRoles = createServerFn({ method: "GET" })
|
|
|
227
227
|
.map((m) => ({
|
|
228
228
|
id: m.module_id,
|
|
229
229
|
name: m.name,
|
|
230
|
+
enforce: Boolean(m.enforce),
|
|
230
231
|
features: safeFeatures
|
|
231
232
|
.filter((f) => f.is_active && f.module_id === m.module_id)
|
|
232
233
|
.map((f) => ({ id: f.feature_id, name: f.name })),
|
|
@@ -416,6 +417,23 @@ export const syncModuleRegistry = createServerFn({ method: "POST" })
|
|
|
416
417
|
}
|
|
417
418
|
return { ok: true, count: modules.length };
|
|
418
419
|
});
|
|
420
|
+
const setModuleEnforceInput = z.object({
|
|
421
|
+
moduleId: z.string().trim().min(1).max(100),
|
|
422
|
+
enforce: z.boolean(),
|
|
423
|
+
});
|
|
424
|
+
export const setModuleEnforce = createServerFn({ method: "POST" })
|
|
425
|
+
.middleware([requireSupabaseAuth])
|
|
426
|
+
.inputValidator((data) => setModuleEnforceInput.parse(data))
|
|
427
|
+
.handler(async ({ context, data }) => {
|
|
428
|
+
await requireAdmin(context);
|
|
429
|
+
const { error } = await context.supabase
|
|
430
|
+
.from("module_registry")
|
|
431
|
+
.update({ enforce: data.enforce })
|
|
432
|
+
.eq("module_id", data.moduleId);
|
|
433
|
+
if (error)
|
|
434
|
+
throw error;
|
|
435
|
+
return { ok: true };
|
|
436
|
+
});
|
|
419
437
|
export const getUserModulePermissions = createServerFn({ method: "POST" })
|
|
420
438
|
.middleware([requireSupabaseAuth])
|
|
421
439
|
.inputValidator((data) => userPermissionsInput.parse(data))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ModulePermission } from "../hooks/useModulePermission";
|
|
2
|
+
interface PermissionContext {
|
|
3
|
+
supabase: any;
|
|
4
|
+
userId: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Server-side controle voor moduletoegang. Moet in elke server function van
|
|
8
|
+
* een beveiligde module aangeroepen worden die gevoelige data leest of wijzigt.
|
|
9
|
+
* Deze functie draait dezelfde SQL-check als de frontendguard, dus de database
|
|
10
|
+
* is de enige bron van waarheid.
|
|
11
|
+
*/
|
|
12
|
+
export declare function requireModulePermission(context: PermissionContext, moduleId: string, featureId?: string, level?: "view" | "edit"): Promise<ModulePermission>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=permissions.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.server.d.ts","sourceRoot":"","sources":["../../src/lib/permissions.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,UAAU,iBAAiB;IACzB,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,EAChB,SAAS,SAAK,EACd,KAAK,GAAE,MAAM,GAAG,MAAe,6BA0BhC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side controle voor moduletoegang. Moet in elke server function van
|
|
3
|
+
* een beveiligde module aangeroepen worden die gevoelige data leest of wijzigt.
|
|
4
|
+
* Deze functie draait dezelfde SQL-check als de frontendguard, dus de database
|
|
5
|
+
* is de enige bron van waarheid.
|
|
6
|
+
*/
|
|
7
|
+
export async function requireModulePermission(context, moduleId, featureId = "", level = "view") {
|
|
8
|
+
const { supabase, userId } = context;
|
|
9
|
+
const { data, error } = await supabase.rpc("effective_module_permission", {
|
|
10
|
+
_user_id: userId,
|
|
11
|
+
_module_id: moduleId,
|
|
12
|
+
_feature_id: featureId,
|
|
13
|
+
});
|
|
14
|
+
if (error) {
|
|
15
|
+
console.error("[requireModulePermission] RPC error", error);
|
|
16
|
+
throw new Error("Kan moduletoegang niet controleren");
|
|
17
|
+
}
|
|
18
|
+
const permission = (data ?? "edit");
|
|
19
|
+
if (level === "edit" && permission !== "edit") {
|
|
20
|
+
throw new Error("Geen schrijfrechten voor deze module");
|
|
21
|
+
}
|
|
22
|
+
if (level === "view" && permission !== "view" && permission !== "edit") {
|
|
23
|
+
throw new Error("Geen leesrechten voor deze module");
|
|
24
|
+
}
|
|
25
|
+
return permission;
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@flowselections/admin-installatietechniek",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"flowselections": {
|
|
5
|
-
"moduleId": "admin-installatietechniek",
|
|
6
|
-
"pages": [
|
|
7
|
-
{
|
|
8
|
-
"export": "AdminForInstallatieTechniek",
|
|
9
|
-
"route": "admin-installatietechniek",
|
|
10
|
-
"title": "Rollen & machtigingen"
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
|
-
"private": false,
|
|
15
|
-
"sideEffects": false,
|
|
16
|
-
"type": "module",
|
|
17
|
-
"main": "./dist-lib/index.js",
|
|
18
|
-
"types": "./dist-lib/index.d.ts",
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"types": "./dist-lib/index.d.ts",
|
|
22
|
-
"default": "./dist-lib/index.js"
|
|
23
|
-
},
|
|
24
|
-
"./styles": "./dist-lib/styles.css"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist-lib",
|
|
28
|
-
"public"
|
|
29
|
-
],
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"access": "public"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"dev": "vite dev",
|
|
35
|
-
"build": "vite build",
|
|
36
|
-
"build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
|
|
37
|
-
"build:lib:watch": "tsc -p tsconfig.build.json --watch",
|
|
38
|
-
"build:dev": "vite build --mode development",
|
|
39
|
-
"preview": "vite preview",
|
|
40
|
-
"lint": "eslint ."
|
|
41
|
-
},
|
|
42
|
-
"peerDependencies": {
|
|
43
|
-
"@flowselections/core": "*",
|
|
44
|
-
"@tanstack/react-query": "^5.0.0",
|
|
45
|
-
"@tanstack/react-router": "^1.0.0",
|
|
46
|
-
"@tanstack/react-start": "^1.0.0",
|
|
47
|
-
"lucide-react": "^0.400.0",
|
|
48
|
-
"react": "^18 || ^19",
|
|
49
|
-
"react-dom": "^18 || ^19",
|
|
50
|
-
"sonner": "^2.0.0"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@supabase/supabase-js": "^2.110.7"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@cloudflare/vite-plugin": "^1.25.5",
|
|
57
|
-
"@eslint/js": "^9.32.0",
|
|
58
|
-
"@flowselections/core": "1.0.16",
|
|
59
|
-
"@lovable.dev/vite-tanstack-config": "2.13.1",
|
|
60
|
-
"@rsbuild/core": "^1.0.0",
|
|
61
|
-
"@tailwindcss/vite": "^4.2.1",
|
|
62
|
-
"@tanstack/react-query": "^5.83.0",
|
|
63
|
-
"@tanstack/react-router": "^1.168.0",
|
|
64
|
-
"@tanstack/react-start": "^1.167.14",
|
|
65
|
-
"@tanstack/router-plugin": "^1.167.10",
|
|
66
|
-
"@types/node": "^22.16.5",
|
|
67
|
-
"@types/react": "^19.2.0",
|
|
68
|
-
"@types/react-dom": "^19.2.0",
|
|
69
|
-
"@vitejs/plugin-react": "^5.0.4",
|
|
70
|
-
"eslint": "^9.32.0",
|
|
71
|
-
"eslint-plugin-react-hooks": "^5.2.0",
|
|
72
|
-
"eslint-plugin-react-refresh": "^0.4.20",
|
|
73
|
-
"globals": "^15.15.0",
|
|
74
|
-
"lucide-react": "^0.575.0",
|
|
75
|
-
"react": "^19.2.0",
|
|
76
|
-
"react-dom": "^19.2.0",
|
|
77
|
-
"sonner": "^2.0.7",
|
|
78
|
-
"tailwindcss": "^4.2.1",
|
|
79
|
-
"tw-animate-css": "^1.3.4",
|
|
80
|
-
"typescript": "^5.8.3",
|
|
81
|
-
"tsc-alias": "^1.8.10",
|
|
82
|
-
"typescript-eslint": "^8.56.1",
|
|
83
|
-
"vite": "^7.3.1",
|
|
84
|
-
"vite-tsconfig-paths": "^6.0.2",
|
|
85
|
-
"nitro": "3.0.260603-beta"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowselections/admin-installatietechniek",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"flowselections": {
|
|
5
|
+
"moduleId": "admin-installatietechniek",
|
|
6
|
+
"pages": [
|
|
7
|
+
{
|
|
8
|
+
"export": "AdminForInstallatieTechniek",
|
|
9
|
+
"route": "admin-installatietechniek",
|
|
10
|
+
"title": "Rollen & machtigingen"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"private": false,
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist-lib/index.js",
|
|
18
|
+
"types": "./dist-lib/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist-lib/index.d.ts",
|
|
22
|
+
"default": "./dist-lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./styles": "./dist-lib/styles.css"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist-lib",
|
|
28
|
+
"public"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "vite dev",
|
|
35
|
+
"build": "vite build",
|
|
36
|
+
"build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
|
|
37
|
+
"build:lib:watch": "tsc -p tsconfig.build.json --watch",
|
|
38
|
+
"build:dev": "vite build --mode development",
|
|
39
|
+
"preview": "vite preview",
|
|
40
|
+
"lint": "eslint ."
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@flowselections/core": "*",
|
|
44
|
+
"@tanstack/react-query": "^5.0.0",
|
|
45
|
+
"@tanstack/react-router": "^1.0.0",
|
|
46
|
+
"@tanstack/react-start": "^1.0.0",
|
|
47
|
+
"lucide-react": "^0.400.0",
|
|
48
|
+
"react": "^18 || ^19",
|
|
49
|
+
"react-dom": "^18 || ^19",
|
|
50
|
+
"sonner": "^2.0.0"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@supabase/supabase-js": "^2.110.7"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@cloudflare/vite-plugin": "^1.25.5",
|
|
57
|
+
"@eslint/js": "^9.32.0",
|
|
58
|
+
"@flowselections/core": "1.0.16",
|
|
59
|
+
"@lovable.dev/vite-tanstack-config": "2.13.1",
|
|
60
|
+
"@rsbuild/core": "^1.0.0",
|
|
61
|
+
"@tailwindcss/vite": "^4.2.1",
|
|
62
|
+
"@tanstack/react-query": "^5.83.0",
|
|
63
|
+
"@tanstack/react-router": "^1.168.0",
|
|
64
|
+
"@tanstack/react-start": "^1.167.14",
|
|
65
|
+
"@tanstack/router-plugin": "^1.167.10",
|
|
66
|
+
"@types/node": "^22.16.5",
|
|
67
|
+
"@types/react": "^19.2.0",
|
|
68
|
+
"@types/react-dom": "^19.2.0",
|
|
69
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
70
|
+
"eslint": "^9.32.0",
|
|
71
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
72
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
73
|
+
"globals": "^15.15.0",
|
|
74
|
+
"lucide-react": "^0.575.0",
|
|
75
|
+
"react": "^19.2.0",
|
|
76
|
+
"react-dom": "^19.2.0",
|
|
77
|
+
"sonner": "^2.0.7",
|
|
78
|
+
"tailwindcss": "^4.2.1",
|
|
79
|
+
"tw-animate-css": "^1.3.4",
|
|
80
|
+
"typescript": "^5.8.3",
|
|
81
|
+
"tsc-alias": "^1.8.10",
|
|
82
|
+
"typescript-eslint": "^8.56.1",
|
|
83
|
+
"vite": "^7.3.1",
|
|
84
|
+
"vite-tsconfig-paths": "^6.0.2",
|
|
85
|
+
"nitro": "3.0.260603-beta"
|
|
86
|
+
}
|
|
87
|
+
}
|