@gravitee/gamma-modules-sdk 1.0.0-alpha.3-feat-dev-mock-middleware.0e211b0 → 1.0.0-alpha.3-fix-nested-route-paths.ea28a0b

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/routing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Routing domain — generic helpers for federated modules mounted under the
3
- * gamma host URL scheme `/environments/:envHrid/:moduleId/<routeKey>`.
3
+ * gamma host URL scheme `/environments/:envHrid/:moduleId/<routePath>`.
4
4
  */
5
5
  export interface ModuleRouteDefinition {
6
6
  readonly path: string;
@@ -17,9 +17,11 @@ export declare function isRouteKey<K extends string>(segment: string, routeKeys:
17
17
  * Resolves the active sidebar key and optional host module prefix from the URL.
18
18
  *
19
19
  * Handles three mounting modes:
20
- * 1. **Federated** — `/environments/:envHrid/:moduleId/<routeKey>`
21
- * 2. **Standalone with prefix** — `/:moduleId/<routeKey>`
22
- * 3. **Legacy standalone** — `/<routeKey>` (first segment is itself a key)
20
+ * 1. **Federated** — `/environments/:envHrid/:moduleId/<routePath>`
21
+ * 2. **Standalone with prefix** — `/:prefix/<routePath>`
22
+ * 3. **Standalone flat** — `/<routePath>` (route path starts at root)
23
+ *
24
+ * Route paths can contain slashes (e.g. `import/models`).
23
25
  */
24
26
  export declare function resolveModulePath<K extends string>(pathname: string, config: ModuleRouteConfig<K>): {
25
27
  modulePrefix: string;
@@ -31,7 +33,7 @@ export declare function resolveModulePath<K extends string>(pathname: string, co
31
33
  *
32
34
  * When federated, the environment prefix is extracted from `currentPathname`.
33
35
  */
34
- export declare function buildModuleNavPath(modulePrefix: string, key: string, currentPathname?: string): string;
36
+ export declare function buildModuleNavPath(modulePrefix: string, routePath: string, currentPathname?: string): string;
35
37
  /**
36
38
  * Returns the "root" pathname for breadcrumbs (e.g. the module's landing page
37
39
  * under the current environment).
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":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,GAAG,MAAM,CAS3G;AAID,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,CAAC,CAAC;IAChB,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAsBvG"}
package/dist/routing.js CHANGED
@@ -5,47 +5,61 @@ function i(e, t) {
5
5
  return t.includes(e);
6
6
  }
7
7
  function a(e, t) {
8
- let n = e.split("/").filter(Boolean), { routeKeys: r, defaultRouteKey: a } = t;
9
- if (n.length === 0) return {
8
+ let n = e.startsWith("/") ? e.slice(1) : e;
9
+ for (let e of t.routeKeys) {
10
+ let r = t.routes[e].path, i = n.indexOf(r);
11
+ if (i >= 0) {
12
+ let t = n.slice(0, i);
13
+ return {
14
+ prefix: t.endsWith("/") ? t.slice(0, -1) : t,
15
+ key: e
16
+ };
17
+ }
18
+ }
19
+ return null;
20
+ }
21
+ function o(e, t) {
22
+ let { defaultRouteKey: n } = t;
23
+ if (e === "/" || e === "") return {
10
24
  modulePrefix: "",
11
- activeNavKey: a
25
+ activeNavKey: n
12
26
  };
13
- if (n[0] === "environments") {
14
- if (n.length < 3) return {
27
+ if (e.startsWith("/environments/")) {
28
+ let r = e.split("/").filter(Boolean);
29
+ if (r.length < 3) return {
15
30
  modulePrefix: "",
16
- activeNavKey: a
31
+ activeNavKey: n
17
32
  };
18
- let e = n[2], t = n[3] ?? a;
33
+ let i = r[2], o = e.indexOf(i) + i.length;
19
34
  return {
20
- modulePrefix: e,
21
- activeNavKey: i(t, r) ? t : a
35
+ modulePrefix: i,
36
+ activeNavKey: a(e.slice(o), t)?.key ?? n
22
37
  };
23
38
  }
24
- if (i(n[0], r)) return {
39
+ let r = a(e, t);
40
+ return r ? {
41
+ modulePrefix: r.prefix,
42
+ activeNavKey: r.key
43
+ } : {
25
44
  modulePrefix: "",
26
- activeNavKey: n[0]
27
- };
28
- let o = n[0], s = n[1] ?? a;
29
- return {
30
- modulePrefix: o,
31
- activeNavKey: i(s, r) ? s : a
45
+ activeNavKey: n
32
46
  };
33
47
  }
34
- function o(e, t, n) {
48
+ function s(e, t, n) {
35
49
  if (e) {
36
50
  let r = n ?? (typeof window < "u" ? window.location.pathname : ""), i = r.indexOf("/", 14);
37
51
  return r.startsWith("/environments/") && i > 0 ? `${r.slice(0, i)}/${e}/${t}` : `/${e}/${t}`;
38
52
  }
39
53
  return `/${t}`;
40
54
  }
41
- function s(e, t, n) {
55
+ function c(e, t, n) {
42
56
  if (!t) return "/";
43
57
  let r = e.indexOf("/", 14);
44
58
  return e.startsWith("/environments/") && r > 0 ? `${e.slice(0, r)}/${t}/${n}` : `/${t}/${n}`;
45
59
  }
46
- function c(i) {
47
- let c = n(), l = r(), { modulePrefix: u, activeNavKey: d } = t(() => a(c.pathname, i), [c.pathname, i]), f = t(() => s(c.pathname, u, i.defaultRouteKey), [
48
- c.pathname,
60
+ function l(i) {
61
+ let a = n(), l = r(), { modulePrefix: u, activeNavKey: d } = t(() => o(a.pathname, i), [a.pathname, i]), f = t(() => c(a.pathname, u, i.defaultRouteKey), [
62
+ a.pathname,
49
63
  u,
50
64
  i.defaultRouteKey
51
65
  ]);
@@ -53,14 +67,15 @@ function c(i) {
53
67
  modulePrefix: u,
54
68
  activeNavKey: d,
55
69
  navigateToKey: e((e) => {
56
- l(o(u, e, c.pathname));
70
+ l(s(u, i.routes[e].path, a.pathname));
57
71
  }, [
58
72
  l,
59
73
  u,
60
- c.pathname
74
+ a.pathname,
75
+ i.routes
61
76
  ]),
62
77
  rootPath: f
63
78
  };
64
79
  }
65
80
  //#endregion
66
- export { o as buildModuleNavPath, s as buildModuleRootPath, i as isRouteKey, a as resolveModulePath, c as useModuleRouting };
81
+ export { s as buildModuleNavPath, c as buildModuleRootPath, i as isRouteKey, o as resolveModulePath, l as useModuleRouting };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravitee/gamma-modules-sdk",
3
- "version": "1.0.0-alpha.3-feat-dev-mock-middleware.0e211b0",
3
+ "version": "1.0.0-alpha.3-fix-nested-route-paths.ea28a0b",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "packageManager": "yarn@4.13.0",