@stacksjs/router 0.75.94 → 0.75.96
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/dashboard-access.d.ts +48 -0
- package/dist/dashboard-access.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/package.json +16 -16
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { MiddlewareReference } from '@stacksjs/bun-router/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Read `dashboard.access` into a prefix-to-roles map.
|
|
4
|
+
*
|
|
5
|
+
* Tolerant by design: this runs at route-registration time, on a value an app
|
|
6
|
+
* wrote, and a malformed entry must not take the dashboard down. Anything that
|
|
7
|
+
* is not a prefix with at least one non-empty role name is dropped, and a key
|
|
8
|
+
* naming no known group is collected for the caller to report rather than
|
|
9
|
+
* silently ignored - a typo'd prefix would otherwise read as a gate that is
|
|
10
|
+
* quietly absent, which is the failure this whole surface exists to stop.
|
|
11
|
+
*
|
|
12
|
+
* An entry with an empty role list is treated as unset rather than as "nobody":
|
|
13
|
+
* the base middleware still applies, and an app cannot lock itself out of its
|
|
14
|
+
* own dashboard with `[]`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveDashboardAccess(configured: unknown): DashboardAccess;
|
|
17
|
+
/**
|
|
18
|
+
* The middleware list for one group: its base, plus the role gate if the app
|
|
19
|
+
* declared one.
|
|
20
|
+
*
|
|
21
|
+
* One `role:a,b` entry rather than one per role, because that is Role.ts's
|
|
22
|
+
* any-of form and matches what a list of roles means everywhere else in the
|
|
23
|
+
* framework. Appended after the base so `auth` runs first and the role check
|
|
24
|
+
* never asks the roles of nobody.
|
|
25
|
+
*/
|
|
26
|
+
export declare function dashboardGroupMiddleware(prefix: string, access: DashboardAccess, base?: readonly MiddlewareReference[]): MiddlewareReference[];
|
|
27
|
+
/**
|
|
28
|
+
* The one-line boot report about `access` keys naming no known group.
|
|
29
|
+
*
|
|
30
|
+
* Returns null when there is nothing to report, matching the ORM's sibling
|
|
31
|
+
* reports.
|
|
32
|
+
*/
|
|
33
|
+
export declare function describeUnknownDashboardGroups(unknown: readonly string[]): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Every group an app may gate, and the single source of truth for the
|
|
36
|
+
* `DashboardRouteGroup` union in `@stacksjs/types`.
|
|
37
|
+
*
|
|
38
|
+
* `dashboard-access.test.ts` pins this list, that union and the prefixes
|
|
39
|
+
* `defaults/routes/dashboard.ts` actually registers against each other. Three
|
|
40
|
+
* copies of one list is a mirror, and mirrors drift: a group added to the
|
|
41
|
+
* routes file and not to this one is a group an app silently cannot gate.
|
|
42
|
+
*/
|
|
43
|
+
export declare const DASHBOARD_ROUTE_GROUPS: readonly ['/ai', '/api/analytics', '/api/commerce', '/api/data', '/api/marketing', '/api/monitoring', '/api/notifications', '/api/queries', '/api/settings', '/cms', '/dashboard', '/dashboard/cms', '/dashboard/commerce', '/deployments', '/infrastructure', '/jobs', '/library', '/models', '/payments', '/queue', '/queues', '/realtime', '/releases', '/voide'];
|
|
44
|
+
export declare interface DashboardAccess {
|
|
45
|
+
roles: Map<string, string[]>
|
|
46
|
+
unknown: string[]
|
|
47
|
+
}
|
|
48
|
+
export type DashboardRouteGroupPrefix = (typeof DASHBOARD_ROUTE_GROUPS)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DASHBOARD_ROUTE_GROUPS=["/ai","/api/analytics","/api/commerce","/api/data","/api/marketing","/api/monitoring","/api/notifications","/api/queries","/api/settings","/cms","/dashboard","/dashboard/cms","/dashboard/commerce","/deployments","/infrastructure","/jobs","/library","/models","/payments","/queue","/queues","/realtime","/releases","/voide"];export function resolveDashboardAccess(configured){const roles=new Map,unknown=[];if(!configured||typeof configured!=="object"||Array.isArray(configured))return{roles,unknown};const known=new Set(DASHBOARD_ROUTE_GROUPS);for(const[key,value]of Object.entries(configured)){const prefix=key.trim();if(!prefix)continue;if(!known.has(prefix)){unknown.push(prefix);continue}const names=(Array.isArray(value)?value:[value]).filter((name)=>typeof name==="string").map((name)=>name.trim()).filter((name)=>name.length>0);if(names.length>0)roles.set(prefix,names)}return{roles,unknown}}export function dashboardGroupMiddleware(prefix,access,base=["auth"]){const names=access.roles.get(prefix);return names?[...base,`role:${names.join(",")}`]:[...base]}export function describeUnknownDashboardGroups(unknown){if(unknown.length===0)return null;return`[dashboard] config/dashboard.ts \`access\` names ${unknown.length===1?"a route group":"route groups"} this framework does not register, so ${unknown.length===1?"it gates":"they gate"} nothing: ${[...unknown].sort().join(", ")}. Valid prefixes are ${DASHBOARD_ROUTE_GROUPS.join(", ")}.`}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type { DefaultRouteBundleSelection } from './route-loader';
|
|
|
11
11
|
// so the path doesn't depend on a 5-level relative reach across the
|
|
12
12
|
// framework defaults tree (stacksjs/stacks#1863, T-10).
|
|
13
13
|
export type { RouteDefinition, RouteRegistry } from './route-types';
|
|
14
|
+
export type { DashboardAccess, DashboardRouteGroupPrefix } from './dashboard-access';
|
|
14
15
|
export type { UrlParams } from './stacks-router';
|
|
15
16
|
export type { ChainableRoute, RouterAction, StacksHandler, StacksRouterInstance } from './stacks-router';
|
|
16
17
|
export type { PathParamRejection, SanitizePathParamOptions } from './path-sanitize';
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
} from './error-handler';
|
|
48
49
|
// Export route introspection helpers
|
|
49
50
|
export { listNamedRoutes, listRegisteredRoutes, routeParams } from './stacks-router';
|
|
51
|
+
export { DASHBOARD_ROUTE_GROUPS, dashboardGroupMiddleware, describeUnknownDashboardGroups, resolveDashboardAccess } from './dashboard-access';
|
|
50
52
|
// Registering an action by import rather than by name: the seam that lets a
|
|
51
53
|
// route hand over the action object it already has, instead of a string that
|
|
52
54
|
// only a runtime `import()` can make sense of. `listRegisteredRoutes()` reports
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./request-augmentation";export*from"@stacksjs/bun-router";export{assertRouteMiddlewareResolvable,configureViewDirectories,clearCsrfModuleCache,clearMiddlewareCache,createStacksRouter,disableViewRouting,enhanceRequest,findUnresolvableRouteMiddleware,installMiddlewareHotReload,loadMiddlewareHandlers,resetBootHooks,route,runBootHooks,serve,serverResponse,url,warnOnMultipleRouterInstances}from"./stacks-router";export{cacheRequestQuery,clearCurrentRequest,getCurrentRequest,getTraceId,request,runWithRequest,setCurrentRequest,withTraceId}from"./request-context";export{defineMiddleware,Middleware}from"./middleware";export{appRouteRegistry,bundleMounts,DEFAULT_ROUTE_BUNDLE_FEATURES,DEFAULT_ROUTE_REGISTRY,listRootMountedAppRoutes,loadRoutes,mountedDefaultRouteBundles}from"./route-loader";export{clearTrackedQueries,createErrorResponse,createMiddlewareErrorResponse,createNotFoundResponse,createValidationErrorResponse,getQueryShapeCounts,trackQuery}from"./error-handler";export{listNamedRoutes,listRegisteredRoutes,routeParams}from"./stacks-router";export{isRouterAction,wrapAction}from"./stacks-router";export{createTypedRouter}from"./typed-router";export{clearRouteModelBindings,defineRouteModelBinding,resolveRouteModel,routeModelBindings,setRouteModelFallback}from"./route-model-binding";export{isApiRequest,JSON_CONTENT_TYPE}from"./api-shape";export{rateLimit,rateLimitStatus,clearRateLimit}from"./rate-limit";export{PathParamError,safePathParam,sanitizePathParam}from"./path-sanitize";export{checkApplicationHealth,runHealthProbes}from"./health";export{stream}from"./stacks-router";export{signedUrl,signUrl,verifySignedUrl,verifySignedUrlMiddleware}from"./signed-url";export{EncryptedSessionStore}from"./encrypted-session-store";export{createSessionStore,createStacksSessionStore,DatabaseSessionStore,FileSessionStore,MemorySessionStore,RedisSessionStore}from"./session-factory";
|
|
1
|
+
import"./request-augmentation";export*from"@stacksjs/bun-router";export{assertRouteMiddlewareResolvable,configureViewDirectories,clearCsrfModuleCache,clearMiddlewareCache,createStacksRouter,disableViewRouting,enhanceRequest,findUnresolvableRouteMiddleware,installMiddlewareHotReload,loadMiddlewareHandlers,resetBootHooks,route,runBootHooks,serve,serverResponse,url,warnOnMultipleRouterInstances}from"./stacks-router";export{cacheRequestQuery,clearCurrentRequest,getCurrentRequest,getTraceId,request,runWithRequest,setCurrentRequest,withTraceId}from"./request-context";export{defineMiddleware,Middleware}from"./middleware";export{appRouteRegistry,bundleMounts,DEFAULT_ROUTE_BUNDLE_FEATURES,DEFAULT_ROUTE_REGISTRY,listRootMountedAppRoutes,loadRoutes,mountedDefaultRouteBundles}from"./route-loader";export{clearTrackedQueries,createErrorResponse,createMiddlewareErrorResponse,createNotFoundResponse,createValidationErrorResponse,getQueryShapeCounts,trackQuery}from"./error-handler";export{listNamedRoutes,listRegisteredRoutes,routeParams}from"./stacks-router";export{DASHBOARD_ROUTE_GROUPS,dashboardGroupMiddleware,describeUnknownDashboardGroups,resolveDashboardAccess}from"./dashboard-access";export{isRouterAction,wrapAction}from"./stacks-router";export{createTypedRouter}from"./typed-router";export{clearRouteModelBindings,defineRouteModelBinding,resolveRouteModel,routeModelBindings,setRouteModelFallback}from"./route-model-binding";export{isApiRequest,JSON_CONTENT_TYPE}from"./api-shape";export{rateLimit,rateLimitStatus,clearRateLimit}from"./rate-limit";export{PathParamError,safePathParam,sanitizePathParam}from"./path-sanitize";export{checkApplicationHealth,runHealthProbes}from"./health";export{stream}from"./stacks-router";export{signedUrl,signUrl,verifySignedUrl,verifySignedUrlMiddleware}from"./signed-url";export{EncryptedSessionStore}from"./encrypted-session-store";export{createSessionStore,createStacksSessionStore,DatabaseSessionStore,FileSessionStore,MemorySessionStore,RedisSessionStore}from"./session-factory";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/router",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.96",
|
|
6
6
|
"description": "The Stacks framework router.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -67,27 +67,27 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@stacksjs/bun-router": "^0.1.24",
|
|
70
|
-
"@stacksjs/cache": "0.75.
|
|
71
|
-
"@stacksjs/collections": "0.75.
|
|
72
|
-
"@stacksjs/config": "0.75.
|
|
73
|
-
"@stacksjs/error-handling": "0.75.
|
|
74
|
-
"@stacksjs/logging": "0.75.
|
|
75
|
-
"@stacksjs/pagination": "0.75.
|
|
76
|
-
"@stacksjs/path": "0.75.
|
|
77
|
-
"@stacksjs/security": "0.75.
|
|
78
|
-
"@stacksjs/storage": "0.75.
|
|
70
|
+
"@stacksjs/cache": "0.75.96",
|
|
71
|
+
"@stacksjs/collections": "0.75.96",
|
|
72
|
+
"@stacksjs/config": "0.75.96",
|
|
73
|
+
"@stacksjs/error-handling": "0.75.96",
|
|
74
|
+
"@stacksjs/logging": "0.75.96",
|
|
75
|
+
"@stacksjs/pagination": "0.75.96",
|
|
76
|
+
"@stacksjs/path": "0.75.96",
|
|
77
|
+
"@stacksjs/security": "0.75.96",
|
|
78
|
+
"@stacksjs/storage": "0.75.96",
|
|
79
79
|
"ts-rate-limiter": "^0.4.10"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@stacksjs/actions": "0.75.
|
|
83
|
-
"@stacksjs/types": "0.75.
|
|
82
|
+
"@stacksjs/actions": "0.75.96",
|
|
83
|
+
"@stacksjs/types": "0.75.96",
|
|
84
84
|
"better-dx": "^0.2.24"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@stacksjs/api": "0.75.
|
|
88
|
-
"@stacksjs/auth": "0.75.
|
|
89
|
-
"@stacksjs/database": "0.75.
|
|
90
|
-
"@stacksjs/validation": "0.75.
|
|
87
|
+
"@stacksjs/api": "0.75.96",
|
|
88
|
+
"@stacksjs/auth": "0.75.96",
|
|
89
|
+
"@stacksjs/database": "0.75.96",
|
|
90
|
+
"@stacksjs/validation": "0.75.96"
|
|
91
91
|
},
|
|
92
92
|
"peerDependenciesMeta": {
|
|
93
93
|
"@stacksjs/api": {
|