@trackunit/iris-app-api 2.13.2 → 2.13.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 2.13.6 (2026-11-04)
2
+
3
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
4
+
5
+ ## 2.13.5 (2026-11-04)
6
+
7
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
8
+
9
+ ## 2.13.4 (2026-11-04)
10
+
11
+ This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
12
+
13
+ ## 2.13.3 (2026-11-04)
14
+
15
+ ### 🚀 Features
16
+
17
+ - **iris-app-sdk:** guide apps to lazy pages for AI navigation and follow getParentRoute ([#27279](https://github.com/Trackunit/manager/pull/27279))
18
+
19
+ ### ❤️ Thank You
20
+
21
+ - Kasper Laursen @ghost-of-kla-trackunit
22
+
1
23
  ## 2.13.2 (2026-11-04)
2
24
 
3
25
  This was a version bump only for iris-app-api to align it with other projects, there were no code changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-api",
3
- "version": "2.13.2",
3
+ "version": "2.13.6",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "engines": {
@@ -9,6 +9,7 @@ import type { IrisAiNavigationRouteMetadata, IrisExtensionAiNavigation } from ".
9
9
  type TanstackRouteLike = {
10
10
  readonly options?: {
11
11
  readonly path?: string;
12
+ readonly getParentRoute?: () => unknown;
12
13
  readonly staticData?: {
13
14
  readonly aiNavigation?: IrisAiNavigationRouteMetadata;
14
15
  };
@@ -23,9 +24,31 @@ type TanstackRouteLike = {
23
24
  * Pass the `routeTree` itself rather than a router: the tree is inert, so no
24
25
  * router (and no browser environment) has to exist for this to run.
25
26
  *
27
+ * Load pages lazily. The manifest imports the route tree in Node at build
28
+ * time, so every page the tree imports directly runs there too, and a page
29
+ * that needs a browser fails the build. With lazy pages, only the route
30
+ * definitions run:
31
+ *
32
+ * ```tsx
33
+ * import { createRoute, lazyRouteComponent } from "@tanstack/react-router";
34
+ *
35
+ * const assetsRoute = createRoute({
36
+ * getParentRoute: () => rootRoute,
37
+ * path: "assets",
38
+ * // Before: `component: AssetsPage`, with AssetsPage imported at the top.
39
+ * component: lazyRouteComponent(() => import("./AssetsPage"), "AssetsPage"),
40
+ * staticData: { aiNavigation: { title: "Assets", description: "All assets." } },
41
+ * });
42
+ * ```
43
+ *
44
+ * The same goes for `errorComponent`, `pendingComponent` and
45
+ * `notFoundComponent`. Tanstack's `.lazy()` with `createLazyRoute` works too.
46
+ *
26
47
  * The manifest field is router-agnostic, so a `...FromReactRouter` counterpart
27
48
  * can be added alongside this without touching the manifest types.
28
49
  *
50
+ * @example
51
+ * aiNavigation: extractAiNavigationFromTanstackRouter(routeTree),
29
52
  * @param routeTree - The app's Tanstack route tree.
30
53
  * @returns {IrisExtensionAiNavigation} The AI navigation catalog for an extension manifest.
31
54
  */
@@ -5,6 +5,7 @@ const cleanPath = (path) => path.replace(/\/{2,}/g, "/");
5
5
  const trimPathLeft = (path) => (path === "/" ? path : path.replace(/^\/+/, ""));
6
6
  const joinPaths = (paths) => cleanPath(paths.filter((path) => path !== undefined).join("/"));
7
7
  const withoutTrailingSlash = (path) => (path !== "/" && path.endsWith("/") ? path.slice(0, -1) : path);
8
+ const isRouteLike = (value) => value !== null && typeof value === "object";
8
9
  const isRouteList = (children) => Array.isArray(children);
9
10
  const isRouteRecord = (children) => children !== null && typeof children === "object";
10
11
  const toChildRoutes = (children) => {
@@ -15,27 +16,34 @@ const toChildRoutes = (children) => {
15
16
  };
16
17
  /**
17
18
  * Mirrors how Tanstack Router derives `fullPath` in `BaseRoute.init`, so paths
18
- * match the running router without constructing one: a pathless layout route
19
- * (declared with `id` instead of `path`) contributes nothing to the path, and a
20
- * child `path` is joined onto the parent with duplicate slashes collapsed.
19
+ * match the running router without constructing one. The parent is the route
20
+ * `getParentRoute` returns, not the one whose `addChildren` lists the route: a
21
+ * tree may list nested routes flat under the root. Only the root has no
22
+ * parent. A pathless layout route (declared with `id` instead of `path`)
23
+ * contributes nothing to the path, and a child `path` is joined onto the
24
+ * parent with duplicate slashes collapsed.
21
25
  */
22
- const routeFullPath = ({ route, parentFullPath, }) => {
26
+ const fullPathOf = (route) => {
27
+ const parentRoute = route.options?.getParentRoute?.();
28
+ if (!isRouteLike(parentRoute)) {
29
+ return "/";
30
+ }
23
31
  const declaredPath = route.options?.path;
24
32
  const path = declaredPath !== undefined && declaredPath !== "/" ? trimPathLeft(declaredPath) : declaredPath;
25
- return joinPaths([parentFullPath, path]);
33
+ return joinPaths([fullPathOf(parentRoute), path]);
26
34
  };
27
- const collectRoutes = ({ route, fullPath, collected, }) => {
35
+ const collectRoutes = (route, collected) => {
28
36
  const aiNavigation = route.options?.staticData?.aiNavigation;
29
37
  if (aiNavigation !== undefined) {
30
38
  collected.push({
31
- path: withoutTrailingSlash(fullPath),
39
+ path: withoutTrailingSlash(fullPathOf(route)),
32
40
  title: aiNavigation.title,
33
41
  description: aiNavigation.description,
34
42
  ...(aiNavigation.params ? { params: aiNavigation.params } : {}),
35
43
  ...(aiNavigation.search ? { search: aiNavigation.search } : {}),
36
44
  });
37
45
  }
38
- toChildRoutes(route.children).forEach(child => collectRoutes({ route: child, fullPath: routeFullPath({ route: child, parentFullPath: fullPath }), collected }));
46
+ toChildRoutes(route.children).forEach(child => collectRoutes(child, collected));
39
47
  };
40
48
  /**
41
49
  * Harvests `staticData.aiNavigation` from a Tanstack `routeTree` into the plain
@@ -45,15 +53,37 @@ const collectRoutes = ({ route, fullPath, collected, }) => {
45
53
  * Pass the `routeTree` itself rather than a router: the tree is inert, so no
46
54
  * router (and no browser environment) has to exist for this to run.
47
55
  *
56
+ * Load pages lazily. The manifest imports the route tree in Node at build
57
+ * time, so every page the tree imports directly runs there too, and a page
58
+ * that needs a browser fails the build. With lazy pages, only the route
59
+ * definitions run:
60
+ *
61
+ * ```tsx
62
+ * import { createRoute, lazyRouteComponent } from "@tanstack/react-router";
63
+ *
64
+ * const assetsRoute = createRoute({
65
+ * getParentRoute: () => rootRoute,
66
+ * path: "assets",
67
+ * // Before: `component: AssetsPage`, with AssetsPage imported at the top.
68
+ * component: lazyRouteComponent(() => import("./AssetsPage"), "AssetsPage"),
69
+ * staticData: { aiNavigation: { title: "Assets", description: "All assets." } },
70
+ * });
71
+ * ```
72
+ *
73
+ * The same goes for `errorComponent`, `pendingComponent` and
74
+ * `notFoundComponent`. Tanstack's `.lazy()` with `createLazyRoute` works too.
75
+ *
48
76
  * The manifest field is router-agnostic, so a `...FromReactRouter` counterpart
49
77
  * can be added alongside this without touching the manifest types.
50
78
  *
79
+ * @example
80
+ * aiNavigation: extractAiNavigationFromTanstackRouter(routeTree),
51
81
  * @param routeTree - The app's Tanstack route tree.
52
82
  * @returns {IrisExtensionAiNavigation} The AI navigation catalog for an extension manifest.
53
83
  */
54
84
  const extractAiNavigationFromTanstackRouter = (routeTree) => {
55
85
  const collected = [];
56
- collectRoutes({ route: routeTree, fullPath: "/", collected });
86
+ collectRoutes(routeTree, collected);
57
87
  return { routes: collected };
58
88
  };
59
89
  exports.extractAiNavigationFromTanstackRouter = extractAiNavigationFromTanstackRouter;