@atlashub/smartstack-cli 4.14.0 → 4.16.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.
@@ -1,133 +0,0 @@
1
- {{!-- SmartStack NavRoute Registry Template --}}
2
- {{!-- Generates centralized route registry for frontend --}}
3
-
4
- /**
5
- * NavRoute Registry
6
- *
7
- * Auto-generated by SmartStack MCP - DO NOT EDIT MANUALLY
8
- * Generated: {{generatedAt}}
9
- * Source: {{source}}
10
- * Routes: {{routeCount}}
11
- */
12
-
13
- export interface NavRoute {
14
- /** NavRoute path (e.g., "administration.users") */
15
- navRoute: string;
16
- /** API endpoint path (e.g., "/api/administration/users") */
17
- api: string;
18
- /** Frontend route path (e.g., "/administration/users") */
19
- web: string;
20
- /** Required permissions to access this route */
21
- permissions: string[];
22
- /** Backend controller name */
23
- controller?: string;
24
- /** Supported HTTP methods */
25
- methods: string[];
26
- }
27
-
28
- /**
29
- * All registered NavRoutes
30
- */
31
- export const ROUTES: Record<string, NavRoute> = {
32
- {{#each routes}}
33
- '{{this.navRoute}}': {
34
- navRoute: '{{this.navRoute}}',
35
- api: '{{this.apiPath}}',
36
- web: '{{this.webPath}}',
37
- permissions: [{{#each this.permissions}}'{{this}}'{{#unless @last}}, {{/unless}}{{/each}}],
38
- {{#if this.controller}}
39
- controller: '{{this.controller}}',
40
- {{/if}}
41
- methods: [{{#each this.methods}}'{{this}}'{{#unless @last}}, {{/unless}}{{/each}}],
42
- },
43
- {{/each}}
44
- };
45
-
46
- /**
47
- * Get route configuration by NavRoute path
48
- * @throws Error if route not found
49
- */
50
- export function getRoute(navRoute: string): NavRoute {
51
- const route = ROUTES[navRoute];
52
- if (!route) {
53
- throw new Error(`Route not found: ${navRoute}. Run scaffold_routes to regenerate.`);
54
- }
55
- return route;
56
- }
57
-
58
- /**
59
- * Safely get route configuration, returns undefined if not found
60
- */
61
- export function tryGetRoute(navRoute: string): NavRoute | undefined {
62
- return ROUTES[navRoute];
63
- }
64
-
65
- /**
66
- * Check if user has permission for route
67
- */
68
- export function hasRoutePermission(navRoute: string, userPermissions: string[]): boolean {
69
- const route = ROUTES[navRoute];
70
- if (!route || route.permissions.length === 0) return true;
71
- return route.permissions.some(p => userPermissions.includes(p));
72
- }
73
-
74
- /**
75
- * Get all routes for an application (e.g., "administration")
76
- */
77
- export function getRoutesByApplication(application: string): NavRoute[] {
78
- return Object.values(ROUTES).filter(r => r.navRoute.startsWith(`${application}.`));
79
- }
80
-
81
- /**
82
- * Get all routes for an application and module (e.g., "administration.users")
83
- */
84
- export function getRoutesByModule(application: string, module: string): NavRoute[] {
85
- const prefix = `${application}.${module}`;
86
- return Object.values(ROUTES).filter(r => r.navRoute.startsWith(`${prefix}.`) || r.navRoute === prefix);
87
- }
88
-
89
- /**
90
- * Get all unique applications
91
- */
92
- export function getApplications(): string[] {
93
- const applications = new Set<string>();
94
- for (const route of Object.values(ROUTES)) {
95
- applications.add(route.navRoute.split('.')[0]);
96
- }
97
- return Array.from(applications);
98
- }
99
-
100
- /**
101
- * Get all unique modules within an application
102
- */
103
- export function getModules(application: string): string[] {
104
- const modules = new Set<string>();
105
- for (const route of Object.values(ROUTES)) {
106
- const parts = route.navRoute.split('.');
107
- if (parts[0] === application && parts.length >= 2) {
108
- modules.add(parts[1]);
109
- }
110
- }
111
- return Array.from(modules);
112
- }
113
-
114
- /**
115
- * Build API URL from NavRoute with optional path segments
116
- */
117
- export function buildApiUrl(navRoute: string, ...segments: string[]): string {
118
- const route = getRoute(navRoute);
119
- if (segments.length === 0) return route.api;
120
- return `${route.api}/${segments.join('/')}`;
121
- }
122
-
123
- /**
124
- * Build frontend URL from NavRoute with optional path segments
125
- */
126
- export function buildWebUrl(navRoute: string, ...segments: string[]): string {
127
- const route = getRoute(navRoute);
128
- if (segments.length === 0) return route.web;
129
- return `${route.web}/${segments.join('/')}`;
130
- }
131
-
132
- // Route count for debugging
133
- export const ROUTE_COUNT = {{routeCount}};
@@ -1,126 +0,0 @@
1
- {{!-- SmartStack React Router Configuration Template --}}
2
- {{!-- Generates router configuration from NavRoute registry --}}
3
-
4
- /**
5
- * React Router Configuration
6
- *
7
- * Auto-generated by SmartStack MCP - DO NOT EDIT MANUALLY
8
- * Generated: {{generatedAt}}
9
- */
10
-
11
- import React, { Suspense, lazy } from 'react';
12
- import { createBrowserRouter, RouteObject, Navigate } from 'react-router-dom';
13
- import { ROUTES } from './navRoutes.generated';
14
- {{#if includeGuards}}
15
- import { ProtectedRoute, PermissionGuard } from './guards';
16
- {{/if}}
17
-
18
- // ============================================================================
19
- // Layouts
20
- // ============================================================================
21
-
22
- {{#each applications}}
23
- import { {{capitalize this}}Layout } from '../layouts/{{capitalize this}}Layout';
24
- {{/each}}
25
-
26
- // ============================================================================
27
- // Pages (lazy loaded for code splitting)
28
- // ============================================================================
29
-
30
- {{#each routes}}
31
- const {{pageName this.navRoute}}Page = lazy(() => import('../pages/{{pagePath this.navRoute}}'));
32
- {{/each}}
33
-
34
- // ============================================================================
35
- // Loading Component
36
- // ============================================================================
37
-
38
- const PageLoader: React.FC = () => (
39
- <div className="flex items-center justify-center h-64">
40
- <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500" />
41
- </div>
42
- );
43
-
44
- // ============================================================================
45
- // Route Configuration
46
- // ============================================================================
47
-
48
- const routes: RouteObject[] = [
49
- // Root redirect
50
- {
51
- path: '/',
52
- element: <Navigate to="{{defaultPath}}" replace />,
53
- },
54
-
55
- {{#each applicationTree}}
56
- // {{uppercase @key}} Application
57
- {
58
- path: '{{@key}}',
59
- element: <{{capitalize @key}}Layout />,
60
- children: [
61
- {{#each this}}
62
- {
63
- path: '{{modulePath this.navRoute}}',
64
- {{#if this.permissions.length}}
65
- element: (
66
- <PermissionGuard permissions={ROUTES['{{this.navRoute}}'].permissions}>
67
- <Suspense fallback={<PageLoader />}>
68
- <{{pageName this.navRoute}}Page />
69
- </Suspense>
70
- </PermissionGuard>
71
- ),
72
- {{else}}
73
- element: (
74
- <Suspense fallback={<PageLoader />}>
75
- <{{pageName this.navRoute}}Page />
76
- </Suspense>
77
- ),
78
- {{/if}}
79
- },
80
- {{/each}}
81
- ],
82
- },
83
- {{/each}}
84
-
85
- // 404 Not Found
86
- {
87
- path: '*',
88
- element: (
89
- <div className="flex flex-col items-center justify-center h-screen">
90
- <h1 className="text-4xl font-bold text-gray-900">404</h1>
91
- <p className="mt-2 text-gray-600">Page not found</p>
92
- <a href="{{defaultPath}}" className="mt-4 text-blue-600 hover:underline">
93
- Return to home
94
- </a>
95
- </div>
96
- ),
97
- },
98
- ];
99
-
100
- // ============================================================================
101
- // Router Export
102
- // ============================================================================
103
-
104
- {{#if includeGuards}}
105
- export const router = createBrowserRouter([
106
- {
107
- element: <ProtectedRoute />,
108
- children: routes,
109
- },
110
- ]);
111
- {{else}}
112
- export const router = createBrowserRouter(routes);
113
- {{/if}}
114
-
115
- export default router;
116
-
117
- // ============================================================================
118
- // Type Exports
119
- // ============================================================================
120
-
121
- export type { RouteObject };
122
-
123
- /**
124
- * Get route configuration by NavRoute path
125
- */
126
- export const getRouteConfig = (navRoute: string) => ROUTES[navRoute];