@arch-cadre/panel 0.0.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 (97) hide show
  1. package/dist/actions/actions.cjs +18 -0
  2. package/dist/actions/actions.d.ts +4 -0
  3. package/dist/actions/actions.mjs +10 -0
  4. package/dist/actions/index.cjs +27 -0
  5. package/dist/actions/index.d.ts +2 -0
  6. package/dist/actions/index.mjs +2 -0
  7. package/dist/actions/manager.cjs +138 -0
  8. package/dist/actions/manager.d.ts +14 -0
  9. package/dist/actions/manager.mjs +135 -0
  10. package/dist/actions/profile.cjs +169 -0
  11. package/dist/actions/profile.d.ts +8 -0
  12. package/dist/actions/profile.mjs +135 -0
  13. package/dist/actions/settings.cjs +26 -0
  14. package/dist/actions/settings.d.ts +7 -0
  15. package/dist/actions/settings.mjs +20 -0
  16. package/dist/index.cjs +29 -0
  17. package/dist/index.d.ts +3 -0
  18. package/dist/index.mjs +25 -0
  19. package/dist/intl.d.ts +9 -0
  20. package/dist/navigation.cjs +38 -0
  21. package/dist/navigation.d.ts +2 -0
  22. package/dist/navigation.mjs +39 -0
  23. package/dist/routes.cjs +71 -0
  24. package/dist/routes.d.ts +4 -0
  25. package/dist/routes.mjs +71 -0
  26. package/dist/types.cjs +1 -0
  27. package/dist/types.d.ts +13 -0
  28. package/dist/types.mjs +0 -0
  29. package/dist/ui/[...catchAll]/page.cjs +127 -0
  30. package/dist/ui/[...catchAll]/page.d.ts +13 -0
  31. package/dist/ui/[...catchAll]/page.mjs +88 -0
  32. package/dist/ui/components/app-content.cjs +49 -0
  33. package/dist/ui/components/app-content.d.ts +6 -0
  34. package/dist/ui/components/app-content.mjs +34 -0
  35. package/dist/ui/components/app-header.cjs +55 -0
  36. package/dist/ui/components/app-header.d.ts +6 -0
  37. package/dist/ui/components/app-header.mjs +45 -0
  38. package/dist/ui/components/app-sidebar.cjs +133 -0
  39. package/dist/ui/components/app-sidebar.d.ts +17 -0
  40. package/dist/ui/components/app-sidebar.mjs +142 -0
  41. package/dist/ui/components/app-user.cjs +102 -0
  42. package/dist/ui/components/app-user.d.ts +2 -0
  43. package/dist/ui/components/app-user.mjs +92 -0
  44. package/dist/ui/components/breadcrumb-slot.cjs +35 -0
  45. package/dist/ui/components/breadcrumb-slot.d.ts +2 -0
  46. package/dist/ui/components/breadcrumb-slot.mjs +31 -0
  47. package/dist/ui/components/manager/module-card.cjs +213 -0
  48. package/dist/ui/components/manager/module-card.d.ts +12 -0
  49. package/dist/ui/components/manager/module-card.mjs +197 -0
  50. package/dist/ui/components/manager/module-list.cjs +52 -0
  51. package/dist/ui/components/manager/module-list.d.ts +4 -0
  52. package/dist/ui/components/manager/module-list.mjs +16 -0
  53. package/dist/ui/components/manager/module-upload.cjs +81 -0
  54. package/dist/ui/components/manager/module-upload.d.ts +2 -0
  55. package/dist/ui/components/manager/module-upload.mjs +68 -0
  56. package/dist/ui/components/profile/components.cjs +239 -0
  57. package/dist/ui/components/profile/components.d.ts +8 -0
  58. package/dist/ui/components/profile/components.mjs +219 -0
  59. package/dist/ui/components/profile/link.cjs +25 -0
  60. package/dist/ui/components/profile/link.d.ts +1 -0
  61. package/dist/ui/components/profile/link.mjs +13 -0
  62. package/dist/ui/components/profile/page.cjs +41 -0
  63. package/dist/ui/components/profile/page.d.ts +1 -0
  64. package/dist/ui/components/profile/page.mjs +21 -0
  65. package/dist/ui/components/sidebar-slot.cjs +49 -0
  66. package/dist/ui/components/sidebar-slot.d.ts +2 -0
  67. package/dist/ui/components/sidebar-slot.mjs +33 -0
  68. package/dist/ui/dashboard/page.cjs +31 -0
  69. package/dist/ui/dashboard/page.d.ts +2 -0
  70. package/dist/ui/dashboard/page.mjs +9 -0
  71. package/dist/ui/error.cjs +50 -0
  72. package/dist/ui/error.d.ts +7 -0
  73. package/dist/ui/error.mjs +35 -0
  74. package/dist/ui/layout.cjs +48 -0
  75. package/dist/ui/layout.d.ts +4 -0
  76. package/dist/ui/layout.mjs +35 -0
  77. package/dist/ui/modules/docs/page.cjs +98 -0
  78. package/dist/ui/modules/docs/page.d.ts +6 -0
  79. package/dist/ui/modules/docs/page.mjs +46 -0
  80. package/dist/ui/modules/page.cjs +30 -0
  81. package/dist/ui/modules/page.d.ts +2 -0
  82. package/dist/ui/modules/page.mjs +10 -0
  83. package/dist/ui/page.cjs +18 -0
  84. package/dist/ui/page.d.ts +1 -0
  85. package/dist/ui/page.mjs +9 -0
  86. package/dist/ui/router.cjs +61 -0
  87. package/dist/ui/router.d.ts +5 -0
  88. package/dist/ui/router.mjs +51 -0
  89. package/dist/ui/settings/page.cjs +61 -0
  90. package/dist/ui/settings/page.d.ts +2 -0
  91. package/dist/ui/settings/page.mjs +22 -0
  92. package/dist/ui/settings-page.cjs +76 -0
  93. package/dist/ui/settings-page.d.ts +2 -0
  94. package/dist/ui/settings-page.mjs +57 -0
  95. package/locales/en/global.json +80 -0
  96. package/manifest.json +11 -0
  97. package/package.json +67 -0
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ "use server";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getKryoConfig = getKryoConfig;
8
+ exports.updateKryoConfig = updateKryoConfig;
9
+ var _server = require("@arch-cadre/modules/server");
10
+ var _cache = require("next/cache");
11
+ async function getKryoConfig() {
12
+ const config = await (0, _server.getModuleConfig)("kryo-panel");
13
+ return config ?? {
14
+ pathPrefix: "/kryo"
15
+ };
16
+ }
17
+ async function updateKryoConfig(config) {
18
+ if (!config.pathPrefix.startsWith("/") || config.pathPrefix.length < 2) {
19
+ throw new Error("Path prefix must start with '/' and be valid.");
20
+ }
21
+ await (0, _server.updateModuleConfig)("kryo-panel", config);
22
+ (0, _cache.revalidatePath)("/", "layout");
23
+ return {
24
+ success: true
25
+ };
26
+ }
@@ -0,0 +1,7 @@
1
+ export interface KryoPanelConfig {
2
+ pathPrefix: string;
3
+ }
4
+ export declare function getKryoConfig(): Promise<KryoPanelConfig>;
5
+ export declare function updateKryoConfig(config: KryoPanelConfig): Promise<{
6
+ success: boolean;
7
+ }>;
@@ -0,0 +1,20 @@
1
+ "use server";
2
+ import {
3
+ getModuleConfig,
4
+ updateModuleConfig
5
+ } from "@arch-cadre/modules/server";
6
+ import { revalidatePath } from "next/cache";
7
+ export async function getKryoConfig() {
8
+ const config = await getModuleConfig("kryo-panel");
9
+ return config ?? {
10
+ pathPrefix: "/kryo"
11
+ };
12
+ }
13
+ export async function updateKryoConfig(config) {
14
+ if (!config.pathPrefix.startsWith("/") || config.pathPrefix.length < 2) {
15
+ throw new Error("Path prefix must start with '/' and be valid.");
16
+ }
17
+ await updateModuleConfig("kryo-panel", config);
18
+ revalidatePath("/", "layout");
19
+ return { success: true };
20
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _manifest = _interopRequireDefault(require("../manifest.json"));
8
+ var _navigation = require("./navigation.cjs");
9
+ var _routes = require("./routes.cjs");
10
+ var _link = require("./ui/components/profile/link.cjs");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const kryoPanelModule = {
13
+ manifest: _manifest.default,
14
+ init: async () => {},
15
+ routes: {
16
+ public: _routes.publicRoutes,
17
+ private: _routes.privateRoutes,
18
+ api: _routes.apiRoutes
19
+ },
20
+ navigation: _navigation.navigation,
21
+ extensions: [{
22
+ id: "user-settings-link",
23
+ targetModule: "panel",
24
+ point: "app-user:extra-link",
25
+ component: _link.UserDropdownLink,
26
+ priority: 50
27
+ }]
28
+ };
29
+ module.exports = kryoPanelModule;
@@ -0,0 +1,3 @@
1
+ import type { IModule } from "@arch-cadre/modules";
2
+ declare const kryoPanelModule: IModule;
3
+ export default kryoPanelModule;
package/dist/index.mjs ADDED
@@ -0,0 +1,25 @@
1
+ import manifest from "../manifest.json";
2
+ import { navigation } from "./navigation.mjs";
3
+ import { apiRoutes, privateRoutes, publicRoutes } from "./routes.mjs";
4
+ import { UserDropdownLink } from "./ui/components/profile/link.mjs";
5
+ const kryoPanelModule = {
6
+ manifest,
7
+ init: async () => {
8
+ },
9
+ routes: {
10
+ public: publicRoutes,
11
+ private: privateRoutes,
12
+ api: apiRoutes
13
+ },
14
+ navigation,
15
+ extensions: [
16
+ {
17
+ id: "user-settings-link",
18
+ targetModule: "panel",
19
+ point: "app-user:extra-link",
20
+ component: UserDropdownLink,
21
+ priority: 50
22
+ }
23
+ ]
24
+ };
25
+ export default kryoPanelModule;
package/dist/intl.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type messages from "../locales/en/global.json";
2
+
3
+ type JsonDataType = typeof messages;
4
+
5
+ declare module "@arch-cadre/intl" {
6
+ export interface IntlMessages extends JsonDataType {}
7
+ }
8
+
9
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.navigation = void 0;
7
+ var _intl = require("@arch-cadre/intl");
8
+ const navigation = exports.navigation = {
9
+ admin: {
10
+ [(0, _intl.i18n)("General")]: [{
11
+ id: "dashboard",
12
+ title: (0, _intl.i18n)("Dashboard"),
13
+ url: "/",
14
+ icon: "solar:widget-bold-duotone"
15
+ }, {
16
+ id: "settings",
17
+ title: (0, _intl.i18n)("Settings"),
18
+ url: "/settings",
19
+ icon: "solar:settings-bold-duotone"
20
+ }],
21
+ [(0, _intl.i18n)("System")]: [{
22
+ id: "module-manager-nav",
23
+ title: (0, _intl.i18n)("Module Manager"),
24
+ url: "/modules",
25
+ icon: "solar:settings-bold-duotone",
26
+ roles: ["admin"],
27
+ permissions: ["system:modules"]
28
+ }]
29
+ },
30
+ settings: {
31
+ [(0, _intl.i18n)("Panel Core")]: [{
32
+ id: "kryo-config",
33
+ title: (0, _intl.i18n)("Panel Core Settings"),
34
+ url: "/settings/panel/config",
35
+ icon: "solar:tuning-bold-duotone"
36
+ }]
37
+ }
38
+ };
@@ -0,0 +1,2 @@
1
+ import type { ModuleNavigation } from "@arch-cadre/modules";
2
+ export declare const navigation: ModuleNavigation;
@@ -0,0 +1,39 @@
1
+ import { i18n } from "@arch-cadre/intl";
2
+ export const navigation = {
3
+ admin: {
4
+ [i18n("General")]: [
5
+ {
6
+ id: "dashboard",
7
+ title: i18n("Dashboard"),
8
+ url: "/",
9
+ icon: "solar:widget-bold-duotone"
10
+ },
11
+ {
12
+ id: "settings",
13
+ title: i18n("Settings"),
14
+ url: "/settings",
15
+ icon: "solar:settings-bold-duotone"
16
+ }
17
+ ],
18
+ [i18n("System")]: [
19
+ {
20
+ id: "module-manager-nav",
21
+ title: i18n("Module Manager"),
22
+ url: "/modules",
23
+ icon: "solar:settings-bold-duotone",
24
+ roles: ["admin"],
25
+ permissions: ["system:modules"]
26
+ }
27
+ ]
28
+ },
29
+ settings: {
30
+ [i18n("Panel Core")]: [
31
+ {
32
+ id: "kryo-config",
33
+ title: i18n("Panel Core Settings"),
34
+ url: "/settings/panel/config",
35
+ icon: "solar:tuning-bold-duotone"
36
+ }
37
+ ]
38
+ }
39
+ };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.publicRoutes = exports.privateRoutes = exports.apiRoutes = void 0;
7
+ var _server = require("@arch-cadre/modules/server");
8
+ var _dynamic = _interopRequireDefault(require("next/dynamic"));
9
+ var _server2 = require("next/server");
10
+ var _page = _interopRequireDefault(require("./ui/components/profile/page.cjs"));
11
+ var _page2 = _interopRequireDefault(require("./ui/modules/docs/page.cjs"));
12
+ var _page3 = _interopRequireDefault(require("./ui/modules/page.cjs"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const KryoLayout = (0, _dynamic.default)(() => Promise.resolve().then(() => require("./ui/layout.cjs")));
15
+ const DashboardPage = (0, _dynamic.default)(() => Promise.resolve().then(() => require("./ui/dashboard/page.cjs")));
16
+ const KryoPanelSettingsPage = (0, _dynamic.default)(() => Promise.resolve().then(() => require("./ui/settings-page.cjs")));
17
+ const GlobalSettingsPage = (0, _dynamic.default)(() => Promise.resolve().then(() => require("./ui/settings/page.cjs")));
18
+ const publicRoutes = exports.publicRoutes = [];
19
+ const privateRoutes = exports.privateRoutes = [{
20
+ path: "/",
21
+ // Mapuje na prefiks (np. /kryo)
22
+ component: DashboardPage,
23
+ layout: KryoLayout,
24
+ auth: true,
25
+ roles: ["admin"]
26
+ }, {
27
+ path: "/profile",
28
+ component: _page.default,
29
+ auth: true,
30
+ roles: ["admin", "user"]
31
+ }, {
32
+ path: "/settings",
33
+ component: GlobalSettingsPage,
34
+ layout: KryoLayout,
35
+ auth: true,
36
+ roles: ["admin"]
37
+ }, {
38
+ path: "/settings/panel/config",
39
+ component: KryoPanelSettingsPage,
40
+ layout: KryoLayout,
41
+ auth: true,
42
+ roles: ["admin"]
43
+ }, {
44
+ id: "module-admin",
45
+ path: "/modules",
46
+ component: _page3.default,
47
+ layout: KryoLayout,
48
+ auth: true,
49
+ roles: ["admin"],
50
+ permissions: ["system:modules"]
51
+ }, {
52
+ id: "module-docs",
53
+ path: "/modules/:id/docs",
54
+ component: _page2.default,
55
+ layout: KryoLayout,
56
+ auth: true,
57
+ roles: ["admin"]
58
+ }];
59
+ const apiRoutes = exports.apiRoutes = [{
60
+ id: "module-status-api",
61
+ path: "/api/system/modules/:id/status",
62
+ auth: true,
63
+ roles: ["admin"],
64
+ permissions: ["system:modules"],
65
+ handler: async (_req, {
66
+ params
67
+ }) => {
68
+ const status = await (0, _server.getModuleStatus)(params.id);
69
+ return _server2.NextResponse.json(status);
70
+ }
71
+ }];
@@ -0,0 +1,4 @@
1
+ import type { ApiRouteDefinition, PrivateRouteDefinition, PublicRouteDefinition } from "@arch-cadre/modules";
2
+ export declare const publicRoutes: PublicRouteDefinition[];
3
+ export declare const privateRoutes: PrivateRouteDefinition[];
4
+ export declare const apiRoutes: ApiRouteDefinition[];
@@ -0,0 +1,71 @@
1
+ import { getModuleStatus } from "@arch-cadre/modules/server";
2
+ import dynamic from "next/dynamic";
3
+ import { NextResponse } from "next/server";
4
+ import ProfileSettingsPage from "./ui/components/profile/page.mjs";
5
+ import ModuleDocsPage from "./ui/modules/docs/page.mjs";
6
+ import ModuleAdminPage from "./ui/modules/page.mjs";
7
+ const KryoLayout = dynamic(() => import("./ui/layout.mjs"));
8
+ const DashboardPage = dynamic(() => import("./ui/dashboard/page.mjs"));
9
+ const KryoPanelSettingsPage = dynamic(() => import("./ui/settings-page.mjs"));
10
+ const GlobalSettingsPage = dynamic(() => import("./ui/settings/page.mjs"));
11
+ export const publicRoutes = [];
12
+ export const privateRoutes = [
13
+ {
14
+ path: "/",
15
+ // Mapuje na prefiks (np. /kryo)
16
+ component: DashboardPage,
17
+ layout: KryoLayout,
18
+ auth: true,
19
+ roles: ["admin"]
20
+ },
21
+ {
22
+ path: "/profile",
23
+ component: ProfileSettingsPage,
24
+ auth: true,
25
+ roles: ["admin", "user"]
26
+ },
27
+ {
28
+ path: "/settings",
29
+ component: GlobalSettingsPage,
30
+ layout: KryoLayout,
31
+ auth: true,
32
+ roles: ["admin"]
33
+ },
34
+ {
35
+ path: "/settings/panel/config",
36
+ component: KryoPanelSettingsPage,
37
+ layout: KryoLayout,
38
+ auth: true,
39
+ roles: ["admin"]
40
+ },
41
+ {
42
+ id: "module-admin",
43
+ path: "/modules",
44
+ component: ModuleAdminPage,
45
+ layout: KryoLayout,
46
+ auth: true,
47
+ roles: ["admin"],
48
+ permissions: ["system:modules"]
49
+ },
50
+ {
51
+ id: "module-docs",
52
+ path: "/modules/:id/docs",
53
+ component: ModuleDocsPage,
54
+ layout: KryoLayout,
55
+ auth: true,
56
+ roles: ["admin"]
57
+ }
58
+ ];
59
+ export const apiRoutes = [
60
+ {
61
+ id: "module-status-api",
62
+ path: "/api/system/modules/:id/status",
63
+ auth: true,
64
+ roles: ["admin"],
65
+ permissions: ["system:modules"],
66
+ handler: async (_req, { params }) => {
67
+ const status = await getModuleStatus(params.id);
68
+ return NextResponse.json(status);
69
+ }
70
+ }
71
+ ];
package/dist/types.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,13 @@
1
+ export type { SidebarGroupType, SidebarMenuItemType, SidebarMenuType, } from "@arch-cadre/modules";
2
+ /**
3
+ *Action result.
4
+ */
5
+ export interface ActionResult<T = any> {
6
+ success?: boolean;
7
+ error?: boolean;
8
+ message?: string;
9
+ errors?: {
10
+ [K in keyof T]?: string[];
11
+ };
12
+ inputs?: T;
13
+ }
package/dist/types.mjs ADDED
File without changes
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ module.exports = CatchAllPage;
7
+ exports.generateMetadata = generateMetadata;
8
+ var _server = require("@arch-cadre/core/server");
9
+ var _server2 = require("@arch-cadre/modules/server");
10
+ var _button = require("@arch-cadre/ui/components/button");
11
+ var _empty = require("@arch-cadre/ui/components/empty");
12
+ var _react = require("@iconify/react");
13
+ var _navigation = require("next/navigation");
14
+ var React = _interopRequireWildcard(require("react"));
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ function matchRoute(pattern, path) {
18
+ const paramNames = [];
19
+ const regexPattern = pattern.replace(/:([^/]+)/g, (_, name) => {
20
+ paramNames.push(name);
21
+ return "([^/]+)";
22
+ }).replace(/\//g, "\\/");
23
+ const regex = new RegExp(`^${regexPattern}$`);
24
+ const match = path.match(regex);
25
+ if (!match) return null;
26
+ const params = {};
27
+ paramNames.forEach((name, index) => {
28
+ params[name] = match[index + 1];
29
+ });
30
+ return params;
31
+ }
32
+ async function findMatchedRoute(path) {
33
+ const privateRoutes = await (0, _server2.getPrivateModuleRoutes)();
34
+ const routes = [...privateRoutes];
35
+ for (const route of routes) {
36
+ const params = matchRoute(route.path, path);
37
+ if (params) {
38
+ return {
39
+ route,
40
+ params
41
+ };
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+ async function generateMetadata({
47
+ params
48
+ }) {
49
+ const {
50
+ catchAll
51
+ } = await params;
52
+ const path = `/${catchAll.join("/")}`;
53
+ const matched = await findMatchedRoute(path);
54
+ if (matched?.route.generateMetadata) {
55
+ return matched.route.generateMetadata({
56
+ params: matched.params,
57
+ searchParams: {}
58
+ });
59
+ }
60
+ return {};
61
+ }
62
+ async function CatchAllPage({
63
+ params,
64
+ searchParams
65
+ }) {
66
+ const {
67
+ catchAll
68
+ } = await params;
69
+ const sParams = await searchParams;
70
+ const path = `/${catchAll.join("/")}`;
71
+ const matched = await findMatchedRoute(path);
72
+ if (matched) {
73
+ const {
74
+ route,
75
+ params: routeParams
76
+ } = matched;
77
+ if (route.auth) {
78
+ const {
79
+ user,
80
+ session
81
+ } = await (0, _server.getCurrentSession)();
82
+ if (!user || !session) {
83
+ return (0, _navigation.redirect)("/signin");
84
+ }
85
+ const security = await (0, _server.checkSecurity)(session, user, route.roles, route.permissions);
86
+ if (!security.satisfied) {
87
+ return (0, _navigation.redirect)(security.redirect || "/signin");
88
+ }
89
+ }
90
+ const Component = route.component;
91
+ const Layout = route.layout;
92
+ const content = /* @__PURE__ */React.createElement(Component, {
93
+ params: routeParams,
94
+ searchParams: sParams
95
+ });
96
+ if (Layout) {
97
+ return /* @__PURE__ */React.createElement(Layout, null, content);
98
+ }
99
+ return content;
100
+ }
101
+ return /* @__PURE__ */React.createElement("div", {
102
+ className: "flex-1 flex w-full items-center justify-center"
103
+ }, /* @__PURE__ */React.createElement("div", {
104
+ className: "flex w-full justify-center h-[calc(100svh-56px-var(--header-height))] items-center"
105
+ }, /* @__PURE__ */React.createElement("div", null, /* @__PURE__ */React.createElement(_empty.Empty, null, /* @__PURE__ */React.createElement(_empty.EmptyHeader, null, /* @__PURE__ */React.createElement(_empty.EmptyTitle, {
106
+ className: "font-black font-mono text-8xl"
107
+ }, "404"), /* @__PURE__ */React.createElement(_empty.EmptyDescription, {
108
+ className: "text-nowrap"
109
+ }, "The page you're looking for might have been moved or doesn't exist.")), /* @__PURE__ */React.createElement(_empty.EmptyContent, null, /* @__PURE__ */React.createElement("div", {
110
+ className: "flex gap-2"
111
+ }, /* @__PURE__ */React.createElement(_button.Button, {
112
+ size: "sm",
113
+ asChild: true
114
+ }, /* @__PURE__ */React.createElement("a", {
115
+ href: "/"
116
+ }, /* @__PURE__ */React.createElement(_react.Icon, {
117
+ icon: "solar:home-2-broken"
118
+ }), " Go Home")), /* @__PURE__ */React.createElement(_button.Button, {
119
+ variant: "outline",
120
+ size: "sm",
121
+ asChild: true
122
+ }, /* @__PURE__ */React.createElement("a", {
123
+ href: "/explore"
124
+ }, /* @__PURE__ */React.createElement(_react.Icon, {
125
+ icon: "solar:compass-broken"
126
+ }), " Explore"))))))));
127
+ }
@@ -0,0 +1,13 @@
1
+ import type { Metadata } from "next";
2
+ import * as React from "react";
3
+ export declare function generateMetadata({ params, }: {
4
+ params: Promise<{
5
+ catchAll: string[];
6
+ }>;
7
+ }): Promise<Metadata>;
8
+ export default function CatchAllPage({ params, searchParams, }: {
9
+ params: Promise<{
10
+ catchAll: string[];
11
+ }>;
12
+ searchParams: Promise<any>;
13
+ }): Promise<React.JSX.Element>;
@@ -0,0 +1,88 @@
1
+ import { checkSecurity, getCurrentSession } from "@arch-cadre/core/server";
2
+ import { getPrivateModuleRoutes } from "@arch-cadre/modules/server";
3
+ import { Button } from "@arch-cadre/ui/components/button";
4
+ import {
5
+ Empty,
6
+ EmptyContent,
7
+ EmptyDescription,
8
+ EmptyHeader,
9
+ EmptyTitle
10
+ } from "@arch-cadre/ui/components/empty";
11
+ import { Icon } from "@iconify/react";
12
+ import { redirect } from "next/navigation";
13
+ import * as React from "react";
14
+ function matchRoute(pattern, path) {
15
+ const paramNames = [];
16
+ const regexPattern = pattern.replace(/:([^/]+)/g, (_, name) => {
17
+ paramNames.push(name);
18
+ return "([^/]+)";
19
+ }).replace(/\//g, "\\/");
20
+ const regex = new RegExp(`^${regexPattern}$`);
21
+ const match = path.match(regex);
22
+ if (!match) return null;
23
+ const params = {};
24
+ paramNames.forEach((name, index) => {
25
+ params[name] = match[index + 1];
26
+ });
27
+ return params;
28
+ }
29
+ async function findMatchedRoute(path) {
30
+ const privateRoutes = await getPrivateModuleRoutes();
31
+ const routes = [...privateRoutes];
32
+ for (const route of routes) {
33
+ const params = matchRoute(route.path, path);
34
+ if (params) {
35
+ return { route, params };
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+ export async function generateMetadata({
41
+ params
42
+ }) {
43
+ const { catchAll } = await params;
44
+ const path = `/${catchAll.join("/")}`;
45
+ const matched = await findMatchedRoute(path);
46
+ if (matched?.route.generateMetadata) {
47
+ return matched.route.generateMetadata({
48
+ params: matched.params,
49
+ searchParams: {}
50
+ });
51
+ }
52
+ return {};
53
+ }
54
+ export default async function CatchAllPage({
55
+ params,
56
+ searchParams
57
+ }) {
58
+ const { catchAll } = await params;
59
+ const sParams = await searchParams;
60
+ const path = `/${catchAll.join("/")}`;
61
+ const matched = await findMatchedRoute(path);
62
+ if (matched) {
63
+ const { route, params: routeParams } = matched;
64
+ if (route.auth) {
65
+ const { user, session } = await getCurrentSession();
66
+ if (!user || !session) {
67
+ return redirect("/signin");
68
+ }
69
+ const security = await checkSecurity(
70
+ session,
71
+ user,
72
+ route.roles,
73
+ route.permissions
74
+ );
75
+ if (!security.satisfied) {
76
+ return redirect(security.redirect || "/signin");
77
+ }
78
+ }
79
+ const Component = route.component;
80
+ const Layout = route.layout;
81
+ const content = /* @__PURE__ */ React.createElement(Component, { params: routeParams, searchParams: sParams });
82
+ if (Layout) {
83
+ return /* @__PURE__ */ React.createElement(Layout, null, content);
84
+ }
85
+ return content;
86
+ }
87
+ return /* @__PURE__ */ React.createElement("div", { className: "flex-1 flex w-full items-center justify-center" }, /* @__PURE__ */ React.createElement("div", { className: "flex w-full justify-center h-[calc(100svh-56px-var(--header-height))] items-center" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Empty, null, /* @__PURE__ */ React.createElement(EmptyHeader, null, /* @__PURE__ */ React.createElement(EmptyTitle, { className: "font-black font-mono text-8xl" }, "404"), /* @__PURE__ */ React.createElement(EmptyDescription, { className: "text-nowrap" }, "The page you're looking for might have been moved or doesn't exist.")), /* @__PURE__ */ React.createElement(EmptyContent, null, /* @__PURE__ */ React.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ React.createElement(Button, { size: "sm", asChild: true }, /* @__PURE__ */ React.createElement("a", { href: "/" }, /* @__PURE__ */ React.createElement(Icon, { icon: "solar:home-2-broken" }), " Go Home")), /* @__PURE__ */ React.createElement(Button, { variant: "outline", size: "sm", asChild: true }, /* @__PURE__ */ React.createElement("a", { href: "/explore" }, /* @__PURE__ */ React.createElement(Icon, { icon: "solar:compass-broken" }), " Explore"))))))));
88
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ "use client";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AppContent = AppContent;
8
+ var _scrollArea = require("@arch-cadre/ui/components/scroll-area");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var React = _react;
11
+ var _appHeader = require("./app-header.cjs");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function AppContent({
15
+ children,
16
+ breadcrumbs
17
+ }) {
18
+ const [isScrolled, setIsScrolled] = (0, _react.useState)(false);
19
+ (0, _react.useEffect)(() => {
20
+ const onScroll = () => setIsScrolled(window.scrollY > 64);
21
+ onScroll();
22
+ window.addEventListener("scroll", onScroll, {
23
+ passive: true
24
+ });
25
+ return () => window.removeEventListener("scroll", onScroll);
26
+ }, []);
27
+ const setScrolled = e => {
28
+ const scrollTop = e.currentTarget.scrollTop;
29
+ if (scrollTop > 20) {
30
+ setIsScrolled(true);
31
+ } else {
32
+ setIsScrolled(false);
33
+ }
34
+ };
35
+ return /* @__PURE__ */React.createElement("main", {
36
+ className: "bg-sidebar h-svh overflow-hidden lg:p-2 w-full"
37
+ }, /* @__PURE__ */React.createElement("div", {
38
+ className: "lg:border squircle overflow-hidden flex flex-col items-center justify-start h-full w-full bg-background"
39
+ }, /* @__PURE__ */React.createElement(_appHeader.AppHeader, {
40
+ isScrolled,
41
+ breadcrumbs
42
+ }), /* @__PURE__ */React.createElement(_scrollArea.ScrollArea, {
43
+ onScroll: e => setScrolled(e),
44
+ className: "h-[calc(100svh-56px-var(--header-height))] w-full flex-1",
45
+ orientation: "vertical"
46
+ }, /* @__PURE__ */React.createElement("div", {
47
+ className: "min-h-[calc(100svh-56px-var(--header-height))] p-4"
48
+ }, children))));
49
+ }
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ import { type ReactNode } from "react";
3
+ export declare function AppContent({ children, breadcrumbs, }: {
4
+ children?: ReactNode;
5
+ breadcrumbs?: ReactNode;
6
+ }): React.JSX.Element;