hazo_admin 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGE_LOG.md +11 -0
  2. package/README.md +86 -0
  3. package/SETUP_CHECKLIST.md +36 -0
  4. package/dist/api/env_migrate_handler.d.ts +19 -0
  5. package/dist/api/env_migrate_handler.d.ts.map +1 -0
  6. package/dist/api/env_migrate_handler.js +44 -0
  7. package/dist/api/index.d.ts +46 -0
  8. package/dist/api/index.d.ts.map +1 -0
  9. package/dist/api/index.js +257 -0
  10. package/dist/components/admin_app.d.ts +10 -0
  11. package/dist/components/admin_app.d.ts.map +1 -0
  12. package/dist/components/admin_app.js +32 -0
  13. package/dist/components/admin_layout.d.ts +15 -0
  14. package/dist/components/admin_layout.d.ts.map +1 -0
  15. package/dist/components/admin_layout.js +37 -0
  16. package/dist/components/admin_nav.d.ts +31 -0
  17. package/dist/components/admin_nav.d.ts.map +1 -0
  18. package/dist/components/admin_nav.js +73 -0
  19. package/dist/components/env_migration_panel.d.ts +6 -0
  20. package/dist/components/env_migration_panel.d.ts.map +1 -0
  21. package/dist/components/env_migration_panel.js +218 -0
  22. package/dist/components/health_panel.d.ts +5 -0
  23. package/dist/components/health_panel.d.ts.map +1 -0
  24. package/dist/components/health_panel.js +23 -0
  25. package/dist/components/jobs_panel.d.ts +6 -0
  26. package/dist/components/jobs_panel.d.ts.map +1 -0
  27. package/dist/components/jobs_panel.js +21 -0
  28. package/dist/components/logs_panel.d.ts +6 -0
  29. package/dist/components/logs_panel.d.ts.map +1 -0
  30. package/dist/components/logs_panel.js +17 -0
  31. package/dist/components/users_panel.d.ts +7 -0
  32. package/dist/components/users_panel.d.ts.map +1 -0
  33. package/dist/components/users_panel.js +21 -0
  34. package/dist/index.client.d.ts +8 -0
  35. package/dist/index.client.d.ts.map +1 -0
  36. package/dist/index.client.js +5 -0
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +2 -0
  40. package/dist/index.ui.d.ts +17 -0
  41. package/dist/index.ui.d.ts.map +1 -0
  42. package/dist/index.ui.js +9 -0
  43. package/dist/lib/admin_gate.server.d.ts +37 -0
  44. package/dist/lib/admin_gate.server.d.ts.map +1 -0
  45. package/dist/lib/admin_gate.server.js +58 -0
  46. package/dist/lib/index.d.ts +2 -0
  47. package/dist/lib/index.d.ts.map +1 -0
  48. package/dist/lib/index.js +1 -0
  49. package/dist/preset/index.d.ts +3 -0
  50. package/dist/preset/index.d.ts.map +1 -0
  51. package/dist/preset/index.js +1 -0
  52. package/dist/preset/page_factory.d.ts +12 -0
  53. package/dist/preset/page_factory.d.ts.map +1 -0
  54. package/dist/preset/page_factory.js +57 -0
  55. package/package.json +139 -0
@@ -0,0 +1,3 @@
1
+ export { AdminPresetPage } from './page_factory.js';
2
+ export type { AdminPresetPageConfig } from './page_factory.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/preset/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ export { AdminPresetPage } from './page_factory.js';
@@ -0,0 +1,12 @@
1
+ import 'server-only';
2
+ import type { AdminManifest } from '../components/admin_nav.js';
3
+ import type { AdminPresetRoutesConfig } from '../api/index.js';
4
+ export type AdminPresetPageConfig = Omit<AdminPresetRoutesConfig, 'getHazoConnect'> & {
5
+ getHazoConnect?: () => Promise<any> | any;
6
+ };
7
+ export declare function AdminPresetPage(manifest: AdminManifest, _cfg?: AdminPresetPageConfig): ({ params }: {
8
+ params: Promise<{
9
+ slug?: string[];
10
+ }>;
11
+ }) => Promise<import("react").JSX.Element>;
12
+ //# sourceMappingURL=page_factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page_factory.d.ts","sourceRoot":"","sources":["../../src/preset/page_factory.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,GAAG;IACpF,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;CAC3C,CAAC;AAoBF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,qBAAqB,IACxD,YAAY;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAA;CAAE,0CAkDhF"}
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import 'server-only';
3
+ import { cookies, headers } from 'next/headers';
4
+ import { adminGate } from '../lib/admin_gate.server.js';
5
+ import { defaultPermissionForKind } from '../components/admin_nav.js';
6
+ function Forbidden({ reason }) {
7
+ return (_jsx("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', minHeight: '100vh', fontFamily: 'system-ui' }, children: _jsxs("div", { style: { textAlign: 'center', maxWidth: 400 }, children: [_jsx("div", { style: { fontSize: '3rem' }, children: "\uD83D\uDD12" }), _jsx("h1", { style: { fontSize: '1.5rem', fontWeight: 600, marginBottom: '0.5rem' }, children: "Access Denied" }), _jsx("p", { style: { color: '#6b7280' }, children: reason === 'unauthenticated'
8
+ ? 'You must be logged in to access this area.'
9
+ : reason === 'forbidden'
10
+ ? 'You do not have permission to access this area.'
11
+ : 'Access denied.' })] }) }));
12
+ }
13
+ export function AdminPresetPage(manifest, _cfg) {
14
+ return async function Page({ params }) {
15
+ const { slug = [] } = await params;
16
+ const sectionPermission = (() => {
17
+ if (slug.length === 0)
18
+ return 'admin_system';
19
+ const section = manifest.sections.find((s) => {
20
+ if (s.kind === 'users')
21
+ return slug[0] === 'users';
22
+ if (s.kind === 'jobs')
23
+ return slug[0] === 'jobs';
24
+ if (s.kind === 'logs')
25
+ return slug[0] === 'logs';
26
+ if (s.kind === 'env_migration')
27
+ return slug[0] === 'env-migration';
28
+ if (s.kind === 'health')
29
+ return slug[0] === 'health';
30
+ if (s.kind === 'custom')
31
+ return s.path.endsWith(`/${slug[0]}`);
32
+ return false;
33
+ });
34
+ return section?.permission ?? defaultPermissionForKind(section?.kind ?? '');
35
+ })();
36
+ const cookieStore = await cookies();
37
+ const headerStore = await headers();
38
+ const cookieHeader = cookieStore.getAll().map((c) => `${c.name}=${c.value}`).join('; ');
39
+ const adminRequest = {
40
+ headers: new Headers({ cookie: cookieHeader, ...Object.fromEntries(headerStore.entries()) }),
41
+ cookies: {
42
+ get: (name) => {
43
+ const c = cookieStore.get(name);
44
+ return c ? { value: c.value } : undefined;
45
+ },
46
+ },
47
+ };
48
+ const gate = await adminGate(adminRequest, {
49
+ required_permissions: [sectionPermission],
50
+ });
51
+ if (!gate.allowed) {
52
+ return _jsx(Forbidden, { reason: gate.reason });
53
+ }
54
+ const { AdminApp } = await import('../components/admin_app.js');
55
+ return (_jsx(AdminApp, { manifest: manifest, user: gate.user, permissions: gate.permissions }));
56
+ };
57
+ }
package/package.json ADDED
@@ -0,0 +1,139 @@
1
+ {
2
+ "name": "hazo_admin",
3
+ "version": "0.1.1",
4
+ "description": "Standard site-admin package — auth-gated admin shell + panel kit + drop-in /admin preset",
5
+ "type": "module",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./dist/index.client.d.ts",
15
+ "import": "./dist/index.client.js"
16
+ },
17
+ "./api": {
18
+ "types": "./dist/api/index.d.ts",
19
+ "import": "./dist/api/index.js"
20
+ },
21
+ "./ui": {
22
+ "types": "./dist/index.ui.d.ts",
23
+ "import": "./dist/index.ui.js"
24
+ },
25
+ "./preset": {
26
+ "types": "./dist/preset/index.d.ts",
27
+ "import": "./dist/preset/index.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "CHANGE_LOG.md",
35
+ "SETUP_CHECKLIST.md"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.build.json",
39
+ "type-check": "tsc --noEmit",
40
+ "test": "node --experimental-vm-modules ../node_modules/jest/bin/jest.js --config jest.config.cjs",
41
+ "dev:test-app": "npm run build && cd test-app && npm run dev",
42
+ "build:test-app": "npm run build && cd test-app && npm run build"
43
+ },
44
+ "peerDependencies": {
45
+ "hazo_core": "^1.1.0",
46
+ "hazo_ui": "^3.2.1",
47
+ "react": "^18.0.0 || ^19.0.0",
48
+ "react-dom": "^18.0.0 || ^19.0.0",
49
+ "next": "^14.0.0 || ^16.0.0",
50
+ "hazo_auth": "^9.1.2",
51
+ "hazo_logs": "^2.0.2",
52
+ "hazo_debug": "^3.1.1",
53
+ "hazo_connect": "^3.4.1",
54
+ "hazo_config": "^2.1.7",
55
+ "hazo_api": "^2.3.1",
56
+ "hazo_files": "^3.0.0",
57
+ "hazo_jobs": "^0.12.0",
58
+ "hazo_env": "^0.2.0",
59
+ "hazo_audit": "^2.1.1",
60
+ "hazo_feedback": "^2.2.0",
61
+ "hazo_secure": "^1.2.0",
62
+ "hazo_blog": "^0.2.0",
63
+ "hazo_testing": "^0.1.1",
64
+ "lucide-react": "^0.553.0"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "hazo_auth": {
68
+ "optional": true
69
+ },
70
+ "hazo_logs": {
71
+ "optional": true
72
+ },
73
+ "hazo_debug": {
74
+ "optional": true
75
+ },
76
+ "hazo_connect": {
77
+ "optional": true
78
+ },
79
+ "hazo_config": {
80
+ "optional": true
81
+ },
82
+ "hazo_api": {
83
+ "optional": true
84
+ },
85
+ "hazo_files": {
86
+ "optional": true
87
+ },
88
+ "hazo_jobs": {
89
+ "optional": true
90
+ },
91
+ "hazo_env": {
92
+ "optional": true
93
+ },
94
+ "hazo_audit": {
95
+ "optional": true
96
+ },
97
+ "hazo_feedback": {
98
+ "optional": true
99
+ },
100
+ "hazo_secure": {
101
+ "optional": true
102
+ },
103
+ "hazo_blog": {
104
+ "optional": true
105
+ },
106
+ "hazo_testing": {
107
+ "optional": true
108
+ }
109
+ },
110
+ "devDependencies": {
111
+ "typescript": "^5.7.2",
112
+ "jest": "^30.2.0",
113
+ "ts-jest": "^29.4.5",
114
+ "@types/jest": "^30.0.0",
115
+ "jest-environment-node": "^30.2.0",
116
+ "jest-environment-jsdom": "^30.2.0",
117
+ "@types/node": "^22.10.0",
118
+ "@types/react": "^19.0.0",
119
+ "@types/react-dom": "^19.0.0",
120
+ "hazo_core": "^1.1.0",
121
+ "hazo_ui": "^3.2.1",
122
+ "hazo_auth": "^9.1.2",
123
+ "hazo_testing": "^0.1.1",
124
+ "next": "^16.0.10",
125
+ "server-only": "^0.0.1",
126
+ "tailwindcss": "^4.2.4",
127
+ "@tailwindcss/postcss": "^4.2.4",
128
+ "postcss": "^8.4.49"
129
+ },
130
+ "keywords": [
131
+ "admin",
132
+ "admin-panel",
133
+ "auth",
134
+ "permissions",
135
+ "hazo"
136
+ ],
137
+ "author": "Pubs Abayasiri",
138
+ "license": "MIT"
139
+ }