@cedarjs/router 8.0.0-canary.3541 → 8.0.0-canary.3545

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,9 +1,12 @@
1
1
  import React from 'react';
2
- import type { GeneratedRoutesMap } from './analyzeRoutes.js';
3
2
  interface AuthenticatedRouteProps {
4
- children: React.ReactNode | Thenable<React.ReactNode>;
3
+ children: React.ReactNode;
5
4
  roles?: string | string[];
6
- unauthenticated: keyof GeneratedRoutesMap;
5
+ userRoles?: string | string[];
6
+ orgRoles?: string | string[];
7
+ orgPermission?: string;
8
+ unauthenticated: string;
9
+ unauthorized?: string;
7
10
  whileLoadingAuth?: () => React.ReactElement | null;
8
11
  }
9
12
  export declare const AuthenticatedRoute: React.FC<AuthenticatedRouteProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticatedRoute.d.ts","sourceRoot":"","sources":["../src/AuthenticatedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAK5D,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACrD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,eAAe,EAAE,MAAM,kBAAkB,CAAA;IACzC,gBAAgB,CAAC,EAAE,MAAM,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACnD;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA6DhE,CAAA"}
1
+ {"version":3,"file":"AuthenticatedRoute.d.ts","sourceRoot":"","sources":["../src/AuthenticatedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAQxD,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,KAAK,CAAC,YAAY,GAAG,IAAI,CAAA;CACnD;AAgFD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAkJhE,CAAA"}
@@ -1,48 +1,137 @@
1
- import React, { useCallback } from "react";
2
- import { namedRoutes } from "./namedRoutes.js";
1
+ import React, { createContext, useContext } from "react";
2
+ import { useLocation } from "./location.js";
3
3
  import { Redirect } from "./redirect.js";
4
4
  import { useRouterState } from "./router-context.js";
5
+ import { paramsForRoute, pathParamsText } from "./util.js";
6
+ const REPLACE = { replace: true };
7
+ const useNoOrg = () => null;
8
+ const MountedOrgContext = createContext(void 0);
9
+ const toList = (roles) => Array.isArray(roles) ? roles : [roles];
10
+ function currentPathParams(routerState, pathname) {
11
+ const route = Object.values(routerState.routes.pathRouteMap).find(
12
+ (candidate) => candidate.name === routerState.activeRouteName
13
+ );
14
+ if (!route?.path) {
15
+ return {};
16
+ }
17
+ return pathParamsText(route.path, pathname, routerState.paramTypes);
18
+ }
19
+ function redirectPath(routes, name, params) {
20
+ if (!Object.hasOwn(routes.namedRoutesMap, name)) {
21
+ throw new Error(`We could not find a route named ${name}`);
22
+ }
23
+ const route = Object.values(routes.pathRouteMap).find(
24
+ (candidate) => candidate.name === name
25
+ );
26
+ if (!route) {
27
+ return routes.namedRoutesMap[name]();
28
+ }
29
+ const routeParams = {};
30
+ for (const [paramName] of paramsForRoute(route.path)) {
31
+ const value = params[paramName];
32
+ if (value === void 0) {
33
+ throw new Error(
34
+ `Redirecting to route "${name}" requires the route parameter "${paramName}", which the current route doesn't have. Please choose a different route`
35
+ );
36
+ }
37
+ routeParams[paramName] = value;
38
+ }
39
+ try {
40
+ return routes.namedRoutesMap[name](routeParams);
41
+ } catch {
42
+ throw new Error(`Could not redirect to the route named ${name}`);
43
+ }
44
+ }
5
45
  const AuthenticatedRoute = ({
6
46
  unauthenticated,
47
+ unauthorized,
7
48
  roles,
49
+ userRoles,
50
+ orgRoles,
51
+ orgPermission,
8
52
  whileLoadingAuth,
9
53
  children
10
54
  }) => {
11
55
  const routerState = useRouterState();
56
+ const mountedOrgId = useContext(MountedOrgContext);
12
57
  const {
13
58
  loading: authLoading,
14
59
  isAuthenticated,
15
60
  hasRole
16
61
  } = routerState.useAuth();
17
- const unauthorized = useCallback(() => {
18
- return !(isAuthenticated && (!roles || hasRole(roles)));
19
- }, [isAuthenticated, roles, hasRole]);
20
- if (unauthorized()) {
62
+ const { pathname } = useLocation();
63
+ const pathParams = currentPathParams(routerState, pathname);
64
+ const { tenancy } = routerState;
65
+ const useOrg = tenancy?.useOrg ?? useNoOrg;
66
+ const org = useOrg(routerState.useAuth, pathParams);
67
+ const needsOrg = orgRoles !== void 0 || orgPermission !== void 0;
68
+ if (needsOrg && !org) {
69
+ const prop = orgRoles !== void 0 ? "orgRoles" : "orgPermission";
70
+ if (!tenancy) {
71
+ throw new Error(
72
+ `A PrivateSet with \`${prop}\` needs \`tenancy\` on the Router to find the organization with. Please pass \`tenancy\` from \`@cedarjs/tenancy/web\`: <Router useAuth={useAuth} tenancy={tenancy}>`
73
+ );
74
+ }
21
75
  if (authLoading) {
22
76
  return whileLoadingAuth?.() || null;
23
- } else {
24
- const currentLocation = globalThis.location.pathname + encodeURIComponent(globalThis.location.search);
25
- const generatedRoutesMap = namedRoutes;
26
- if (!generatedRoutesMap[unauthenticated]) {
27
- throw new Error(`We could not find a route named ${unauthenticated}`);
77
+ }
78
+ if (pathParams["orgSlug"] === void 0) {
79
+ throw new Error(
80
+ `A PrivateSet with \`${prop}\` needs an organization to check it in, and the route has no \`orgSlug\` param. Please only use \`${prop}\` on routes with \`{orgSlug}\` in their path, or pass \`createTenancy\` a \`useOrg\` that finds the organization another way`
81
+ );
82
+ }
83
+ throw new Error(
84
+ `A PrivateSet with \`${prop}\` got no organization from the Router's \`tenancy\` for this route, so there is nothing to check it in`
85
+ );
86
+ }
87
+ const hasRequiredUserRoles = (!roles || hasRole(roles)) && (!userRoles || hasRole(userRoles));
88
+ if (isAuthenticated && hasRequiredUserRoles) {
89
+ if (!tenancy || !org) {
90
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
91
+ }
92
+ const { membership, memberships } = org;
93
+ if (!membership) {
94
+ if (authLoading) {
95
+ return whileLoadingAuth?.() || null;
28
96
  }
29
- let unauthenticatedPath;
30
- try {
31
- unauthenticatedPath = generatedRoutesMap[unauthenticated]();
32
- } catch (e) {
33
- if (e instanceof Error && /Missing parameter .* for route/.test(e.message)) {
34
- throw new Error(
35
- `Redirecting to route "${unauthenticated}" would require route parameters, which currently is not supported. Please choose a different route`
36
- );
37
- }
38
- throw new Error(
39
- `Could not redirect to the route named ${unauthenticated}`
40
- );
97
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, tenancy.notAMember ?? null);
98
+ }
99
+ const hasRequiredOrgAccess = (orgRoles === void 0 || toList(orgRoles).includes(membership.role)) && (orgPermission === void 0 || (membership.permissions?.includes(orgPermission) ?? false));
100
+ if (hasRequiredOrgAccess) {
101
+ if (mountedOrgId === membership.organizationId) {
102
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
41
103
  }
42
- return /* @__PURE__ */ React.createElement(Redirect, { to: `${unauthenticatedPath}?redirectTo=${currentLocation}` });
104
+ return /* @__PURE__ */ React.createElement(
105
+ tenancy.OrgProvider,
106
+ {
107
+ key: membership.organizationId,
108
+ useAuth: routerState.useAuth,
109
+ membership,
110
+ memberships
111
+ },
112
+ /* @__PURE__ */ React.createElement(MountedOrgContext.Provider, { value: membership.organizationId }, children)
113
+ );
43
114
  }
44
115
  }
45
- return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
116
+ if (authLoading) {
117
+ return whileLoadingAuth?.() || null;
118
+ }
119
+ if (isAuthenticated && unauthorized) {
120
+ return /* @__PURE__ */ React.createElement(
121
+ Redirect,
122
+ {
123
+ to: redirectPath(routerState.routes, unauthorized, pathParams),
124
+ options: REPLACE
125
+ }
126
+ );
127
+ }
128
+ const currentLocation = globalThis.location.pathname + encodeURIComponent(globalThis.location.search);
129
+ const unauthenticatedPath = redirectPath(
130
+ routerState.routes,
131
+ unauthenticated,
132
+ pathParams
133
+ );
134
+ return /* @__PURE__ */ React.createElement(Redirect, { to: `${unauthenticatedPath}?redirectTo=${currentLocation}` });
46
135
  };
47
136
  export {
48
137
  AuthenticatedRoute
package/dist/Set.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType, ReactElement, ReactNode } from 'react';
2
2
  import React from 'react';
3
- import type { AuthTenancy } from '@cedarjs/auth' with {
3
+ import type { AuthTenancy, PermissionName } from '@cedarjs/auth' with {
4
4
  'resolution-mode': 'import'
5
5
  };
6
6
  /**
@@ -26,12 +26,42 @@ export interface WrapperProps {
26
26
  */
27
27
  export type WrapperType = ComponentType<WrapperProps>;
28
28
  /**
29
- * The `roles` prop, which an app with tenancy doesn't have (see
30
- * `AuthTenancy`): there, every role check says which kind it is.
29
+ * The role props. An app with tenancy (see `AuthTenancy`) has `userRoles` and
30
+ * `orgRoles` instead of `roles`: there, every role check says which kind it
31
+ * is. It also has `orgPermission`.
31
32
  */
32
33
  type SetRoles = AuthTenancy extends {
33
34
  enabled: true;
34
- } ? Record<never, never> : {
35
+ } ? {
36
+ /**
37
+ * Route is permitted when authenticated and user has any of the
38
+ * provided roles such as "admin" or ["admin", "editor"], in
39
+ * `currentUser.roles`, as opposed to a role in the organization they're
40
+ * in (see `orgRoles`). With `orgRoles` as well, they need both.
41
+ */
42
+ userRoles?: string | string[];
43
+ /**
44
+ * Route is permitted when authenticated and user has any of the
45
+ * provided roles such as "owner" or ["owner", "admin"] in the current
46
+ * organization. With `userRoles` as well, they need both.
47
+ *
48
+ * The organization is the one the Router's `tenancy` finds for the
49
+ * route, by default the one with the route's `orgSlug` param:
50
+ *
51
+ * <Router useAuth={useAuth} tenancy={tenancy}>
52
+ *
53
+ * A `PrivateSet` with `orgRoles` throws without `tenancy` on the
54
+ * router, or on a route that isn't in an organization.
55
+ */
56
+ orgRoles?: string | string[];
57
+ /**
58
+ * Route is permitted when authenticated and the user's membership in
59
+ * the current organization has this permission (see
60
+ * `createPermissions` in `@cedarjs/tenancy`). The organization is found
61
+ * like for `orgRoles`, which it can be combined with: they need both.
62
+ */
63
+ orgPermission?: PermissionName;
64
+ } : {
35
65
  /**
36
66
  * Route is permitted when authenticated and user has any of the
37
67
  * provided roles such as "admin" or ["admin", "editor"], in
@@ -61,6 +91,13 @@ interface SetProps extends SetRoles {
61
91
  * @deprecated Please use `<PrivateSet>` instead and specify this prop there
62
92
  */
63
93
  unauthenticated?: string;
94
+ /**
95
+ * The page name where a user will be redirected when authenticated but
96
+ * without the required roles
97
+ *
98
+ * @deprecated Please use `<PrivateSet>` instead and specify this prop there
99
+ */
100
+ unauthorized?: string;
64
101
  /** Prerender all pages in the set */
65
102
  prerender?: boolean;
66
103
  children: ReactNode;
@@ -77,16 +114,32 @@ interface SetProps extends SetRoles {
77
114
  * </Set>
78
115
  */
79
116
  export declare function Set(props: SetProps): React.JSX.Element;
80
- type PrivateSetProps = Omit<SetProps, 'private' | 'unauthenticated'> & {
81
- /** The page name where a user will be redirected when not authenticated */
117
+ type PrivateSetProps = Omit<SetProps, 'private' | 'unauthenticated' | 'unauthorized'> & {
118
+ /**
119
+ * The page name where a user will be redirected when not authenticated.
120
+ * Also where one without the required roles is redirected, unless the set
121
+ * has `unauthorized`.
122
+ */
82
123
  unauthenticated: string;
124
+ /**
125
+ * The page name where a user will be redirected when authenticated but
126
+ * without the required roles. Without it, they're redirected to
127
+ * `unauthenticated`.
128
+ */
129
+ unauthorized?: string;
83
130
  };
84
131
  /** @deprecated Please use `<PrivateSet>` instead */
85
132
  export declare function Private(props: PrivateSetProps): React.JSX.Element;
86
133
  /**
87
134
  * Wraps a set of routes that require the user to be authenticated before
88
135
  * rendering. Unauthenticated users are redirected to the route named by
89
- * `unauthenticated`.
136
+ * `unauthenticated`, and users without the required roles to the one named by
137
+ * `unauthorized`. Either route can have path params the current route has,
138
+ * like `orgSlug`: they're filled in from the current route.
139
+ *
140
+ * In an app with tenancy, a `PrivateSet` whose routes have `{orgSlug}` in
141
+ * their path provides the organization to its layouts and page, see `tenancy`
142
+ * on the `Router`.
90
143
  *
91
144
  * Coming from React Router or a similar library and looking for something
92
145
  * like `RequireAuth` or `ProtectedRoute`? This is the Cedar equivalent.
package/dist/Set.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Set.d.ts","sourceRoot":"","sources":["../src/Set.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;IAC/C,iBAAiB,EAAE,QAAQ;CAC5B,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA;AAErD;;;GAGG;AACH,KAAK,QAAQ,GAAG,WAAW,SAAS;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjD,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GACpB;IACE;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1B,CAAA;AAEL,UAAU,QAAS,SAAQ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G,IAAI,CAAA;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,qBAIlC;AAED,KAAK,eAAe,GAAG,IAAI,CACzB,QAAQ,EACR,SAAS,GAAG,iBAAiB,GAAG,cAAc,CAC/C,GAAG;IACF;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,oDAAoD;AACpD,wBAAgB,OAAO,CAAC,KAAK,EAAE,eAAe,qBAI7C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,qBAIhD;AAED,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,KAAG,IAAI,IAAI,YAAY,CAAC,QAAQ,CAOxE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAC3B,MAAM,SAAS,KACd,IAAI,IAAI,YAAY,CAAC,eAAe,CAEtC,CAAA;AAGD,eAAO,MAAM,aAAa,GACxB,MAAM,SAAS,KACd,IAAI,IAAI,YAAY,CAAC,eAAe,CAEtC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,SAAS,aAKpB"}
@@ -14,7 +14,11 @@ export type Wrappers = readonly WrapperType[];
14
14
  interface SetRenderProps {
15
15
  private?: boolean;
16
16
  unauthenticated?: string;
17
+ unauthorized?: string;
17
18
  roles?: string | string[];
19
+ userRoles?: string | string[];
20
+ orgRoles?: string | string[];
21
+ orgPermission?: string;
18
22
  whileLoadingAuth?: () => ReactElement | null;
19
23
  }
20
24
  interface Set {
@@ -1 +1 @@
1
- {"version":3,"file":"analyzeRoutes.d.ts","sourceRoot":"","sources":["../src/analyzeRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM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AAM,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,cAAc,CAAA;CACtB;AAuDD,KAAK,SAAS,GAAG,MAAM,CAAA;AAEvB;;;;GAIG;AACH,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,UAAU,oBAAoB;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC3C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,EACnB,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,oBAAoB;;;;;;EAqK1D"}
@@ -19,9 +19,21 @@ function pickSetRenderProps(props) {
19
19
  if (props.unauthenticated !== void 0) {
20
20
  picked.unauthenticated = props.unauthenticated;
21
21
  }
22
+ if (props.unauthorized !== void 0) {
23
+ picked.unauthorized = props.unauthorized;
24
+ }
22
25
  if (props.roles !== void 0) {
23
26
  picked.roles = props.roles;
24
27
  }
28
+ if (props.userRoles !== void 0) {
29
+ picked.userRoles = props.userRoles;
30
+ }
31
+ if (props.orgRoles !== void 0) {
32
+ picked.orgRoles = props.orgRoles;
33
+ }
34
+ if (props.orgPermission !== void 0) {
35
+ picked.orgPermission = props.orgPermission;
36
+ }
25
37
  if (props.whileLoadingAuth !== void 0) {
26
38
  picked.whileLoadingAuth = props.whileLoadingAuth;
27
39
  }
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { Redirect } from './redirect.js';
6
6
  export { usePageLoadingContext, PageLoadingContextProvider, } from './PageLoadingContext.js';
7
7
  export { useParams, ParamsProvider, ParamsContext } from './params.js';
8
8
  export { Router } from './router.js';
9
+ export type { OrgProviderProps, RouterMembership, RouterOrg, Tenancy, UseOrg, } from './router-context.js';
9
10
  export { Route } from './Route.js';
10
11
  export { namedRoutes as routes } from './namedRoutes.js';
11
12
  export { Set, Private, PrivateSet, isSetNode, isPrivateSetNode, isPrivateNode, } from './Set.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,EACL,GAAG,EACH,OAAO,EACP,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,aAAa,GACd,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEzD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AACtE,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxD,cAAc,kBAAkB,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zD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AACtE,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxD,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE1D;;;;;;;;;GASG;AAGH,MAAM,WAAW,eAAe;CAAG;AAGnC,cAAc,uBAAuB,CAAA"}
@@ -4,10 +4,72 @@ import type { AuthContextInterface } from '@cedarjs/auth' with {
4
4
  };
5
5
  import type { analyzeRoutes } from './analyzeRoutes.js';
6
6
  import type { ParamType } from './util.js';
7
- type UseAuth = () => AuthContextInterface<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown>;
7
+ export type UseAuth = () => AuthContextInterface<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown>;
8
+ /**
9
+ * What the router reads of a membership in an organization. A tenancy's
10
+ * memberships can have more; the router passes them on to its `OrgProvider`
11
+ * as they are.
12
+ */
13
+ export interface RouterMembership {
14
+ /** Identifies the organization, so one provider stays mounted across it */
15
+ organizationId: string;
16
+ /** The user's role in the organization, for `<PrivateSet orgRoles>` */
17
+ role: string;
18
+ /** What the membership may do, for `<PrivateSet orgPermission>` */
19
+ permissions?: readonly string[] | undefined;
20
+ }
21
+ /**
22
+ * What a tenancy's `useOrg` found for a route in an organization. A
23
+ * `membership` of `null` means the signed-in user isn't a member of it, or
24
+ * isn't signed in.
25
+ */
26
+ export interface RouterOrg {
27
+ membership: RouterMembership | null;
28
+ memberships: readonly RouterMembership[];
29
+ }
30
+ /**
31
+ * Finds the organization of the current route, given the router's `useAuth`
32
+ * and the route's path params: `null` when the route isn't in an
33
+ * organization. The router calls it like a hook, on every render of a
34
+ * private set.
35
+ *
36
+ * One of the app's own can answer in three ways:
37
+ * - an organization, with the user's membership in it or `null` for none.
38
+ * A set with `orgRoles` or `orgPermission` denies a user with no
39
+ * membership, and the router renders the tenancy's `notAMember`.
40
+ * - `null`, for no organization: a set with `orgRoles` or `orgPermission`
41
+ * then throws the router's own error.
42
+ * - throw an error of its own, such as for an organization that's been
43
+ * suspended. It reaches the app's error boundary like any error thrown
44
+ * while rendering.
45
+ */
46
+ export type UseOrg = (useAuth: UseAuth, params: Record<string, string>) => RouterOrg | null;
47
+ /** What the router gives a tenancy's `OrgProvider` */
48
+ export interface OrgProviderProps {
49
+ useAuth: UseAuth;
50
+ membership: RouterMembership;
51
+ memberships: readonly RouterMembership[];
52
+ children: React.ReactNode;
53
+ }
54
+ /**
55
+ * How the router handles organizations. `createTenancy` from
56
+ * `@cedarjs/tenancy/web` makes one. The router renders its `OrgProvider`
57
+ * around the layouts and page of a `PrivateSet` whose route is in an
58
+ * organization, and checks `orgRoles` and `orgPermission` against the
59
+ * membership its `useOrg` finds.
60
+ */
61
+ export interface Tenancy {
62
+ useOrg: UseOrg;
63
+ /** Provides the organization to everything below it */
64
+ OrgProvider: React.ComponentType<OrgProviderProps>;
65
+ /** Rendered for a signed-in user who isn't a member of the route's organization */
66
+ notAMember?: React.ReactNode;
67
+ }
8
68
  export interface RouterState {
9
69
  paramTypes?: Record<string, ParamType>;
10
70
  useAuth: UseAuth;
71
+ /** Unset in apps that don't pass one to the router */
72
+ tenancy?: Tenancy;
11
73
  routes: ReturnType<typeof analyzeRoutes>;
12
74
  activeRouteName?: string | undefined | null;
13
75
  }
@@ -19,5 +81,4 @@ export interface RouterContextProviderProps extends Omit<RouterState, 'useAuth'>
19
81
  }
20
82
  export declare const RouterContextProvider: React.FC<RouterContextProviderProps>;
21
83
  export declare const useRouterState: () => RouterState;
22
- export {};
23
84
  //# sourceMappingURL=router-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-context.d.ts","sourceRoot":"","sources":["../src/router-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;IACxD,iBAAiB,EAAE,QAAQ;CAC5B,CAAA;AAGD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,KAAK,OAAO,GAAG,MAAM,oBAAoB,CACvC,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,CACR,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CAC5C;AAID,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CACtD,WAAW,EACX,SAAS,CACV;IACC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAsBtE,CAAA;AAED,eAAO,MAAM,cAAc,mBAU1B,CAAA"}
1
+ {"version":3,"file":"router-context.d.ts","s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tB,MAAM,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAA;IAClD,mFAAmF;IACnF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CAC5C;AAID,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CACtD,WAAW,EACX,SAAS,CACV;IACC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;IACxC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAwBtE,CAAA;AAED,eAAO,MAAM,cAAc,mBAU1B,CAAA"}
@@ -3,6 +3,7 @@ import { useNoAuth } from "@cedarjs/auth";
3
3
  const RouterStateContext = createContext(void 0);
4
4
  const RouterContextProvider = ({
5
5
  useAuth,
6
+ tenancy,
6
7
  paramTypes,
7
8
  routes,
8
9
  activeRouteName,
@@ -11,11 +12,12 @@ const RouterContextProvider = ({
11
12
  const state = useMemo(
12
13
  () => ({
13
14
  useAuth: useAuth || useNoAuth,
15
+ tenancy,
14
16
  paramTypes,
15
17
  routes,
16
18
  activeRouteName
17
19
  }),
18
- [useAuth, paramTypes, routes, activeRouteName]
20
+ [useAuth, tenancy, paramTypes, routes, activeRouteName]
19
21
  );
20
22
  return /* @__PURE__ */ React.createElement(RouterStateContext.Provider, { value: state }, children);
21
23
  };
package/dist/router.d.ts CHANGED
@@ -1,11 +1,32 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import React from 'react';
3
- import type { RouterContextProviderProps } from './router-context.js';
3
+ import type { AuthTenancy } from '@cedarjs/auth' with {
4
+ 'resolution-mode': 'import'
5
+ };
6
+ import type { RouterContextProviderProps, Tenancy } from './router-context.js';
4
7
  import type { TrailingSlashesTypes } from './util.js';
5
- export interface RouterProps extends Omit<RouterContextProviderProps, 'routes' | 'activeRouteName'> {
8
+ /**
9
+ * `tenancy`, only in an app with tenancy (see `AuthTenancy`), where sets have
10
+ * `orgRoles` and `orgPermission`
11
+ */
12
+ type RouterTenancy = AuthTenancy extends {
13
+ enabled: true;
14
+ } ? {
15
+ /**
16
+ * How the router handles organizations: finding the one of the current
17
+ * route, checking `orgRoles` and `orgPermission` in it, and providing
18
+ * it to the layouts and page of a `PrivateSet`. Pass the `tenancy` from
19
+ * `createTenancy` in `@cedarjs/tenancy/web`:
20
+ *
21
+ * <Router useAuth={useAuth} tenancy={tenancy}>
22
+ */
23
+ tenancy?: Tenancy;
24
+ } : Record<never, never>;
25
+ export interface RouterProps extends Omit<RouterContextProviderProps, 'routes' | 'activeRouteName' | 'tenancy'>, RouterTenancy {
6
26
  trailingSlashes?: TrailingSlashesTypes;
7
27
  pageLoadingDelay?: number;
8
28
  children: ReactNode;
9
29
  }
10
30
  export declare const Router: React.FC<RouterProps>;
31
+ export {};
11
32
  //# sourceMappingURL=router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAwB,MAAM,OAAO,CAAA;AAY5C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAKrE,OAAO,KAAK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import { RouterContextProvider } from "./router-context.js";
12
12
  import { wrapWithSetWrappers } from "./Set.js";
13
13
  import { SplashPage } from "./splash-page.js";
14
14
  import { matchPath, parseSearch, replaceParams, validatePath } from "./util.js";
15
- const Router = ({
15
+ const RouterImplementation = ({
16
16
  useAuth,
17
+ tenancy,
17
18
  paramTypes,
18
19
  pageLoadingDelay,
19
20
  trailingSlashes = "never",
@@ -26,6 +27,7 @@ const Router = ({
26
27
  LocationAwareRouter,
27
28
  {
28
29
  useAuth,
30
+ tenancy,
29
31
  paramTypes,
30
32
  pageLoadingDelay
31
33
  },
@@ -33,8 +35,11 @@ const Router = ({
33
35
  ))
34
36
  );
35
37
  };
38
+ RouterImplementation.displayName = "Router";
39
+ const Router = RouterImplementation;
36
40
  const LocationAwareRouter = ({
37
41
  useAuth,
42
+ tenancy,
38
43
  paramTypes,
39
44
  pageLoadingDelay,
40
45
  children
@@ -78,6 +83,7 @@ const LocationAwareRouter = ({
78
83
  RouterContextProvider,
79
84
  {
80
85
  useAuth,
86
+ tenancy,
81
87
  paramTypes,
82
88
  routes: analyzeRoutesResult
83
89
  },
@@ -122,6 +128,7 @@ const LocationAwareRouter = ({
122
128
  RouterContextProvider,
123
129
  {
124
130
  useAuth,
131
+ tenancy,
125
132
  paramTypes,
126
133
  routes: analyzeRoutesResult,
127
134
  activeRouteName: name
@@ -154,7 +161,11 @@ const WrappedPage = memo(({ sets, children }) => {
154
161
  AuthenticatedRoute,
155
162
  {
156
163
  unauthenticated,
164
+ unauthorized: set.props.unauthorized,
157
165
  roles: set.props.roles,
166
+ userRoles: set.props.userRoles,
167
+ orgRoles: set.props.orgRoles,
168
+ orgPermission: set.props.orgPermission,
158
169
  whileLoadingAuth: set.props.whileLoadingAuth
159
170
  },
160
171
  wrapped
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { RouterProps } from '../router.js';
3
- export declare const Router: ({ useAuth, paramTypes, children }: RouterProps) => React.JSX.Element;
3
+ export declare const Router: (props: RouterProps) => React.JSX.Element;
4
4
  //# sourceMappingURL=ClientRouter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientRouter.d.ts","sourceRoot":"","sources":["../../src/rsc/ClientRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI/C,eAAO,MAAM,MAAM,GAAI,mCAAmC,WAAW,sBASpE,CAAA"}
1
+ {"version":3,"file":"ClientRouter.d.ts","sourceRoot":"","sources":["../../src/rsc/ClientRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI/C,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,sBAiBxC,CAAA"}
@@ -5,7 +5,11 @@ import { LocationProvider, useLocation } from "../location.js";
5
5
  import { namedRoutes } from "../namedRoutes.js";
6
6
  import { RouterContextProvider } from "../router-context.js";
7
7
  import { RscRoutes } from "./RscRoutes.js";
8
- const Router = ({ useAuth, paramTypes, children }) => {
8
+ const Router = (props) => {
9
+ const { useAuth, paramTypes, children } = props;
10
+ if ("tenancy" in props && props.tenancy) {
11
+ throw new Error("`tenancy` is not supported with RSC yet");
12
+ }
9
13
  return (
10
14
  // Wrap it in the provider so that useLocation can be used
11
15
  /* @__PURE__ */ React.createElement(LocationProvider, null, /* @__PURE__ */ React.createElement(LocationAwareRouter, { paramTypes, useAuth }, children))
@@ -29,6 +33,14 @@ const LocationAwareRouter = ({
29
33
  return /* @__PURE__ */ React.createElement(RscRoutes, { pathname, search });
30
34
  }
31
35
  const requestedRoute = pathRouteMap[activeRoutePath];
36
+ for (const set of requestedRoute.sets) {
37
+ if (set.props.orgRoles !== void 0) {
38
+ throw new Error("`orgRoles` is not supported with RSC yet");
39
+ }
40
+ if (set.props.orgPermission !== void 0) {
41
+ throw new Error("`orgPermission` is not supported with RSC yet");
42
+ }
43
+ }
32
44
  const reversedSets = requestedRoute.sets.toReversed();
33
45
  const privateSet = reversedSets.find((set) => set.isPrivate);
34
46
  if (privateSet) {
@@ -1 +1 @@
1
- {"version":3,"file":"ServerRouter.d.ts","sourceRoot":"","sources":["../../src/rsc/ServerRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,0BAA0B,EAC1B,QAAQ,GAAG,iBAAiB,CAC7B;IACC,eAAe,CAAC,EAAE,oBAAoB,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4GxC,CAAA"}
1
+ {"version":3,"file":"ServerRouter.d.ts","sourceRoot":"","sources":["../../src/rsc/ServerRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,0BAA0B,EAC1B,QAAQ,GAAG,iBAAiB,CAC7B;IACC,eAAe,CAAC,EAAE,oBAAoB,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAqHxC,CAAA"}
@@ -7,7 +7,14 @@ import { wrapWithSetWrappers } from "../Set.js";
7
7
  import { SplashPage } from "../splash-page.js";
8
8
  import { matchPath, parseSearch, replaceParams, validatePath } from "../util.js";
9
9
  import { ServerRouteLoader } from "./ServerRouteLoader.js";
10
- const Router = ({ paramTypes, children }) => {
10
+ const Router = ({
11
+ paramTypes,
12
+ tenancy,
13
+ children
14
+ }) => {
15
+ if (tenancy) {
16
+ throw new Error("`tenancy` is not supported with RSC yet");
17
+ }
11
18
  const location = getLocation();
12
19
  console.log("ServerRouter.tsx location", location);
13
20
  const analyzedRoutes = analyzeRoutes(children, {
@@ -96,10 +103,19 @@ function hasRole(requiredRoles) {
96
103
  }
97
104
  const AuthenticatedRoute = ({
98
105
  children,
99
- roles
106
+ roles,
107
+ userRoles,
108
+ orgRoles,
109
+ orgPermission
100
110
  }) => {
101
111
  const { isAuthenticated } = getAuthState();
102
- const isAuthorized = isAuthenticated && (!roles || hasRole(roles));
112
+ if (orgRoles !== void 0) {
113
+ throw new Error("`orgRoles` is not supported with RSC yet");
114
+ }
115
+ if (orgPermission !== void 0) {
116
+ throw new Error("`orgPermission` is not supported with RSC yet");
117
+ }
118
+ const isAuthorized = isAuthenticated && (!roles || hasRole(roles)) && (!userRoles || hasRole(userRoles));
103
119
  if (isAuthorized) {
104
120
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
105
121
  }
@@ -126,6 +142,9 @@ const WrappedPage = ({ routeLoaderElement, sets }) => {
126
142
  {
127
143
  unauthenticated,
128
144
  roles: set.props.roles,
145
+ userRoles: set.props.userRoles,
146
+ orgRoles: set.props.orgRoles,
147
+ orgPermission: set.props.orgPermission,
129
148
  whileLoadingAuth: set.props.whileLoadingAuth
130
149
  },
131
150
  wrapped
package/dist/util.d.ts CHANGED
@@ -50,6 +50,16 @@ export declare function matchPath(routeDefinition: string, pathname: string, { u
50
50
  match: boolean;
51
51
  params: Record<string, unknown>;
52
52
  };
53
+ /**
54
+ * The path params of `pathname` for the route `routeDefinition`, as the text
55
+ * in the path, without parsing them with their param types. For putting into
56
+ * another route's path, where a parsed value (whatever a custom type's `parse`
57
+ * returns, say) wouldn't be the same text.
58
+ *
59
+ * pathParamsText('/post/{id:Int}', '/post/7')
60
+ * => { id: '7' }
61
+ */
62
+ export declare function pathParamsText(routeDefinition: string, pathname: string, userParamTypes?: Record<string, ParamType>): Record<string, string>;
53
63
  interface GetRouteRegexOptions {
54
64
  matchSubPaths?: boolean;
55
65
  allParamTypes?: Record<string, ParamType>;
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,cAyB3C;AAED,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;AAElE,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAA;CAChC;AAwBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CACvB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,EACE,cAAc,EACd,aAAa,GACd,GAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAA;CAIxB;;;;;;EA2CF;AAED,UAAU,oBAAoB;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC1C;AACD;;;;;GAKG;AAEH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,EACE,aAAqB,EACrB,aAA8B,GAC/B,GAAE,oBAAoB,GAAG,SAAc;;;;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CAC5B,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAM,0BAgB/C;AAED,UAAU,oBAAoB;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC1C;AACD;;;;;GAKG;AAEH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,EACE,aAAqB,EACrB,aAA8B,GAC/B,GAAE,oBAAoB,GAAG,SAAc;;;;EA+BzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,MAAM,EACJ,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,eAAe,GAAG,SAAS,MAW7E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAyC3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,UAiCnC;AAED,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAExE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,6BAQtD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,YAMvB"}
package/dist/util.js CHANGED
@@ -1,5 +1,5 @@
1
1
  function paramsForRoute(route) {
2
- const params = [...route.matchAll(/\{([^}]+)\}/g)];
2
+ const params = [...route.matchAll(/\{([^{}]+)\}/g)];
3
3
  return params.map((match) => match[1]).map((match) => {
4
4
  const parts = match.split(":");
5
5
  let name = parts[0];
@@ -70,6 +70,19 @@ function matchPath(routeDefinition, pathname, {
70
70
  }
71
71
  return { match: true };
72
72
  }
73
+ function pathParamsText(routeDefinition, pathname, userParamTypes = {}) {
74
+ const { matchRegex, routeParams } = getRouteRegexAndParams(routeDefinition, {
75
+ allParamTypes: { ...coreParamTypes, ...userParamTypes }
76
+ });
77
+ const match = matchRegex.exec(pathname);
78
+ const params = {};
79
+ if (match) {
80
+ routeParams.forEach(([name], index) => {
81
+ params[name] = match[index + 1];
82
+ });
83
+ }
84
+ return params;
85
+ }
73
86
  function getRouteRegexAndParams(route, {
74
87
  matchSubPaths = false,
75
88
  allParamTypes = coreParamTypes
@@ -140,7 +153,7 @@ function replaceParams(route, args = {}) {
140
153
  const [name, _type, match] = param;
141
154
  const value = args[name];
142
155
  if (value !== void 0) {
143
- path = path.replace(match, value);
156
+ path = path.replace(match, () => String(value));
144
157
  } else {
145
158
  throw new Error(
146
159
  `Missing parameter '${name}' for route '${route}' when generating a navigation URL.`
@@ -178,6 +191,7 @@ export {
178
191
  matchPath,
179
192
  paramsForRoute,
180
193
  parseSearch,
194
+ pathParamsText,
181
195
  replaceParams,
182
196
  validatePath
183
197
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/router",
3
- "version": "8.0.0-canary.3541",
3
+ "version": "8.0.0-canary.3545",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -52,15 +52,15 @@
52
52
  "test:watch": "vitest watch"
53
53
  },
54
54
  "dependencies": {
55
- "@cedarjs/project-config": "8.0.0-canary.3541",
56
- "@cedarjs/server-store": "8.0.0-canary.3541",
55
+ "@cedarjs/project-config": "8.0.0-canary.3545",
56
+ "@cedarjs/server-store": "8.0.0-canary.3545",
57
57
  "react-server-dom-webpack": "19.3.1",
58
58
  "ts-toolbelt": "9.6.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@arethetypeswrong/cli": "0.18.5",
62
- "@cedarjs/auth": "8.0.0-canary.3541",
63
- "@cedarjs/framework-tools": "8.0.0-canary.3541",
62
+ "@cedarjs/auth": "8.0.0-canary.3545",
63
+ "@cedarjs/framework-tools": "8.0.0-canary.3545",
64
64
  "@testing-library/jest-dom": "6.9.1",
65
65
  "@types/react": "^19.2.0",
66
66
  "@types/react-dom": "^19.2.0",
@@ -74,7 +74,7 @@
74
74
  "vitest": "4.1.12"
75
75
  },
76
76
  "peerDependencies": {
77
- "@cedarjs/auth": "8.0.0-canary.3541",
77
+ "@cedarjs/auth": "8.0.0-canary.3545",
78
78
  "react": "19.3.1",
79
79
  "react-dom": "19.3.1"
80
80
  },