create-ailk 0.41.0 → 0.42.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.
- package/README.md +31 -1
- package/component-catalog.json +6 -0
- package/dist/add-route.d.ts +2 -6
- package/dist/add-route.js +2 -43
- package/dist/export-content.d.ts +10 -3
- package/dist/export-content.js +61 -9
- package/dist/language-import.js +5 -2
- package/dist/lib/env-catalog.js +4 -0
- package/dist/lib/import-mdx.d.ts +2 -0
- package/dist/lib/import-mdx.js +46 -22
- package/dist/magnet-page.d.ts +36 -0
- package/dist/magnet-page.js +70 -0
- package/dist/migrate-content.d.ts +12 -3
- package/dist/migrate-content.js +62 -11
- package/dist/routes.d.ts +38 -2
- package/dist/routes.js +586 -27
- package/dist/surfaces.d.ts +16 -0
- package/dist/surfaces.js +36 -0
- package/dist/update.d.ts +1 -1
- package/dist/update.js +24 -2
- package/package.json +3 -3
- package/templates/.claude/hooks/template-guard.sh +145 -36
- package/templates/CLAUDE.md +1 -1
- package/templates/apps/api/CLAUDE.md +2 -0
- package/templates/apps/mcp/CLAUDE.md +9 -3
- package/templates/apps/web/CLAUDE.md +16 -2
- package/templates/apps/web/app/[locale]/layout.tsx +6 -3
- package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +28 -0
- package/templates/apps/web/app/sitemap.xml/__tests__/site-listing.test.ts +28 -0
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +24 -0
- package/templates/apps/web/lib/__tests__/route-paths.test.ts +57 -0
- package/templates/apps/web/lib/mcp-oauth.ts +14 -10
- package/templates/apps/web/lib/page-chrome.ts +8 -5
- package/templates/apps/web/lib/route-paths.ts +22 -0
- package/templates/apps/web/lib/services-path.ts +27 -18
- package/templates/apps/web/middleware.ts +2 -1
- package/templates/apps/web/next.config.mjs +123 -2
- package/templates/apps/web/src/lib/routes.ts +4 -2
- package/versions.json +51 -51
|
@@ -707,7 +707,9 @@ What a site that carries `commerce` gets (#8748, #11253); a site without
|
|
|
707
707
|
`generateMetadata` too). The `checkoutThankYou`, `checkoutUnavailable` and
|
|
708
708
|
`purchase` strings ship in the package (`commerceMessages`), merged under
|
|
709
709
|
this app's catalog by `i18n/request.ts` through `loadUiCommerce()`; a key in
|
|
710
|
-
`messages/en.json` is an override.
|
|
710
|
+
`messages/en.json` is an override. The thank-you page's own words are the
|
|
711
|
+
site's `ThankYouPage/checkout-thank-you` row when it has one (#11716): its
|
|
712
|
+
sections render in place of the catalog's, and the account link stays.
|
|
711
713
|
- **One data file.** `lib/checkout-config.ts` is the site's stamp,
|
|
712
714
|
`checkoutConfig.site`, and nothing else: no import and no code. The commerce
|
|
713
715
|
bundle delivers it with the placeholder `example-site`, and on a spoke
|
|
@@ -766,6 +768,16 @@ A site serves its services at `/services` unless `content/_site.mdx` sets `servi
|
|
|
766
768
|
- **Surfaces.** The canonical, hreflang and `BreadcrumbList` (the base's title-cased last segment, then the category's title), `/sitemap.xml` and `/llms.txt` (`pagePathFor`), every nav and footer entry at `/services` (mapped in the locale layout), the hub's own section links, and route-family chrome (`lib/page-chrome.ts`) all follow it. A site that sets neither `services.path` nor any `parent` serves every URL exactly as before.
|
|
767
769
|
- **Moving it.** `/ailk:growth-ops page rename` moves the base (`--from <current base> --to <new base>`): it writes `services.path` and keeps a previous moved base redirecting.
|
|
768
770
|
|
|
771
|
+
## Renaming a route family (`<family>.path`)
|
|
772
|
+
|
|
773
|
+
A site serves a route family at its convention segment (`/portfolio`, `/meet`) unless that family's `content/_site.mdx` entry sets `path`, for example `portfolio: { path: /writing-samples }` or `meet: { path: /meetings }` (#11385). The key sits beside the family's `header` / `footer`. Twelve families take it: `meet`, `caseStudies`, `portfolio`, `team`, `courses`, `events`, `integrations`, `partners`, `features`, `products`, `resources` and `for`. The value is exactly one lowercase kebab segment, never `api`, `og`, `v1` or `apple-icon`. `docs` and `services` move through `docsPath` and `services.path` instead. Every other family refuses the key, because its package still writes its own links.
|
|
774
|
+
|
|
775
|
+
- **Generate first.** `create-ailk routes --write` writes the family's route files under the new segment (`app/[locale]/meetings/…`) and deletes its generated files from the old directory, listing them under `removed`. Unlike `services.path`, the route files themselves move. The command refuses, before it writes anything, a rename onto a served route, a reserved segment, another family's target, a renamed family's old segment, the family's own segment, or a content page `[slug]` serves. It also refuses when a non-generated file would be left behind in the old directory, when a `customizations.yaml` record names a file there, when the target directory already holds a file that is not one of the family's own generated route files, or when either directory holds a symbolic link.
|
|
776
|
+
- **Build.** `next.config.mjs` reads each family's `path`, checks it against the same rules plus the enabled locales and the docs and services segments, and bakes the result into `NEXT_PUBLIC_AILK_ROUTE_PATHS` (`{"portfolio":"writing-samples"}`, or `{}`). It fails the build, naming the value, when the files were not regenerated: a rename whose `app/[locale]/<new>/page.tsx` is not a generated route file, or a generated route file that re-exports a family's page from a directory where that family is not served. Both name `create-ailk routes --write`.
|
|
777
|
+
- **Request.** `legacyRedirects()`, which `redirects()` returns unchanged, adds four 308s per rename: `/<old>`, `/<old>/…` and their locale-prefixed twins onto the same rest under the new segment. A legacy route into the family (`/schedule/confirmed`) lands on the new segment in one hop. Links inside authored content are not rewritten; they keep working through the 308.
|
|
778
|
+
- **Surfaces.** Every surface reads the renames through `@working-theory/templates/route-paths` (re-exported from `./routes`): `renamedPath`, `conventionPath` and `routeSegment`. That covers the canonical and hreflang (`pagePath`), `/sitemap.xml` and `/llms.txt` (`pagePathFor`, with no `SITE_LISTING` row needed), the nav and footer (`lib/route-paths.ts`, mapped in the locale layout), breadcrumbs, the site-pages hub cards, family and page chrome (`lib/page-chrome.ts`), and the booking pages. A renamed `meet` keeps the chrome-free frame and the Cal.com CSP at its new path (`isBookingPath`'s third argument), and the scheduling package's cards, ItemList, one-meeting redirect and confirmation hand-off point there. `routeFor` does not change: it is the path the hub stores a page under.
|
|
779
|
+
- **Rollout.** A `@working-theory/site-config` older than this setting rejects a `_site.mdx` carrying it, because its schema is strict. `@working-theory/api` and `@working-theory/mcp-server` then read the site as having no config. Set `path` only once the site's packages carry it.
|
|
780
|
+
|
|
769
781
|
## Nav-only lists (`navOnly`)
|
|
770
782
|
|
|
771
783
|
A list page whose frontmatter sets `navOnly: true` (valid on a registry list type only, #10200) has no page of its own: `honourNavOnly` (`lib/hub-children.tsx`) answers `permanentRedirect` (308) to the first child in the route's own child order (a hub's is slug order after `includeChild`, not the order of links its authored sections carry), at the card's public path with the locale prefix kept, and `notFound()` when it lists none. Only an exact `true` acts; anything else renders as before.
|
|
@@ -808,7 +820,9 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
|
|
|
808
820
|
- Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
|
|
809
821
|
- Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
|
|
810
822
|
|
|
811
|
-
Last updated: 2026-11-
|
|
823
|
+
Last updated: 2026-11-14 — § Renaming a route family: one `path` key on a family's `_site.mdx` entry moves its route files, public URLs, nav, breadcrumbs, hub cards and booking CSP, with a 308 from the old segment (#11385) — verified against `packages/templates/src/{route-paths,routes-map}.ts`, `packages/create-ailk/src/routes.ts`, `next.config.mjs`, `middleware.ts` and `lib/{route-paths,page-chrome}.ts`.
|
|
824
|
+
|
|
825
|
+
Prior: 2026-11-13 — § Magnet pages: the magnet pages ship in `@working-theory/ui-signal-collectors` beside the flows pages, the careers walks adopted from site-pages' prefix, the `reports` strings in the package, and `/downloads` a routes-map redirect; `/dev/purchase` and its Server Action are retired (#11657) — verified against `packages-paid/ui-signal-collectors/{routes.json,src/pages/}`, `app/[locale]/{reports,trial,careers/apply,careers/[slug]/apply}/`, `packages/templates/src/routes-map.ts` and `next.config.mjs`.
|
|
812
826
|
|
|
813
827
|
Prior: 2026-11-13 — § Where the docs live: the blog category index `/blog/category/[tag]` ships as its own route in `@working-theory/ui-docs-blog`, so `app/[locale]/blog/` holds two generated route files (#11658) — verified against `packages-paid/ui-docs-blog/routes.json` and `app/[locale]/blog/`.
|
|
814
828
|
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
SiteConsentSchema,
|
|
36
36
|
type ConsentAppearance,
|
|
37
37
|
} from "@working-theory/site-config/schema";
|
|
38
|
+
import { routeSegment } from "@working-theory/templates/routes";
|
|
38
39
|
import { MarketingShell } from "@working-theory/templates/shells";
|
|
39
40
|
import { themeToShellCss } from "@working-theory/theme";
|
|
40
41
|
import { Link, NewsletterSignupProvider, isRtl, localeHref } from "@working-theory/ui";
|
|
@@ -105,6 +106,7 @@ import {
|
|
|
105
106
|
parentHref,
|
|
106
107
|
servedParent,
|
|
107
108
|
} from "../../lib/profile-back-link";
|
|
109
|
+
import { withRenamedColumns, withRenamedNavPaths } from "../../lib/route-paths";
|
|
108
110
|
import { servedPages } from "../../lib/served-pages";
|
|
109
111
|
import {
|
|
110
112
|
withPublicServicesColumns,
|
|
@@ -633,7 +635,7 @@ export default async function LocaleLayout({
|
|
|
633
635
|
// the marketing frame; /meet/confirmed keeps it too. The consent Banner
|
|
634
636
|
// stays, as on the auth branch. The same fail-safe direction: an absent
|
|
635
637
|
// `x-pathname` keeps the full frame.
|
|
636
|
-
const isBookingRoute = SCHEDULING_PAGES && isBookingPath(pathname, enabledLocales);
|
|
638
|
+
const isBookingRoute = SCHEDULING_PAGES && isBookingPath(pathname, enabledLocales, routeSegment("meet"));
|
|
637
639
|
|
|
638
640
|
// #8840 D10 — a magnet's walk (`/<magnet>/start`, `/careers/apply`,
|
|
639
641
|
// `/careers/<posting>/apply`) renders full-screen: the auth branch's frame,
|
|
@@ -719,8 +721,9 @@ export default async function LocaleLayout({
|
|
|
719
721
|
// #10041 D10 — every nav and footer path at `/docs` is rendered at the
|
|
720
722
|
// site's docs path; `nav-config.ts` itself is never edited.
|
|
721
723
|
// #10043 D9 — likewise every path at `/services`, at the services base.
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
+
// #11385 D8 — a renamed route family's links follow its served segment.
|
|
725
|
+
const publicNavItems = withRenamedNavPaths(withPublicServicesPaths(withPublicDocsPaths(navItems)));
|
|
726
|
+
const footerColumnDefs = withRenamedColumns(withPublicServicesColumns(withPublicDocsColumns(footerColumns))).map((col) => ({
|
|
724
727
|
heading: labelFor(col.headingKey),
|
|
725
728
|
headingKey: col.headingKey,
|
|
726
729
|
items: col.items.map((item) => ({ ...item, label: labelFor(item.labelKey) })),
|
|
@@ -198,3 +198,31 @@ describe("the llms.txt heading — a hub-connected site's name (#11456 D4, AC-2)
|
|
|
198
198
|
expect(mockSiteConfigGet).not.toHaveBeenCalled();
|
|
199
199
|
});
|
|
200
200
|
});
|
|
201
|
+
|
|
202
|
+
// #11385 D3, AC-1, AC-3 — one site-config entry renames the portfolio's
|
|
203
|
+
// segment: llms.txt lists every PortfolioItem at /writing-samples with no
|
|
204
|
+
// listing row, and no URL keeps the old segment.
|
|
205
|
+
describe.each(ROUTES)("GET /llms.txt (%s) — a renamed route family (#11385)", (path) => {
|
|
206
|
+
const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
207
|
+
beforeEach(() => {
|
|
208
|
+
process.env.CONTENT_ADAPTER = "database";
|
|
209
|
+
process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en";
|
|
210
|
+
process.env.NEXT_PUBLIC_BASE_URL = BASE;
|
|
211
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
|
|
212
|
+
});
|
|
213
|
+
afterEach(() => {
|
|
214
|
+
delete process.env.CONTENT_ADAPTER;
|
|
215
|
+
delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
|
|
216
|
+
delete process.env.NEXT_PUBLIC_BASE_URL;
|
|
217
|
+
if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
218
|
+
else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("lists the PortfolioItem at /writing-samples/acme and nothing under /portfolio", async () => {
|
|
222
|
+
const text = await llms(path, {
|
|
223
|
+
PortfolioItem: [{ type: "PortfolioItem", slug: "acme", title: "Acme" }],
|
|
224
|
+
});
|
|
225
|
+
expect(urls(text)).toContain(`${BASE}/writing-samples/acme`);
|
|
226
|
+
expect(urls(text).filter((url) => url.includes("/portfolio"))).toEqual([]);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
@@ -108,3 +108,31 @@ describe("GET /sitemap.xml — the site listing (#10940)", () => {
|
|
|
108
108
|
expect(xml).not.toContain("evil.example");
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
|
+
|
|
112
|
+
// #11385 D3, AC-1, AC-3 — one site-config entry renames the portfolio's
|
|
113
|
+
// segment: every PortfolioItem is listed at /writing-samples with no listing
|
|
114
|
+
// row, and no URL keeps the old segment.
|
|
115
|
+
describe("GET /sitemap.xml — a renamed route family (#11385)", () => {
|
|
116
|
+
const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
117
|
+
beforeEach(() => {
|
|
118
|
+
process.env.CONTENT_ADAPTER = "database";
|
|
119
|
+
process.env.NEXT_PUBLIC_ENABLED_LOCALES = "en";
|
|
120
|
+
process.env.NEXT_PUBLIC_BASE_URL = BASE;
|
|
121
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
|
|
122
|
+
ROWS.PortfolioItem = [{ type: "PortfolioItem", slug: "acme", title: "Acme" }];
|
|
123
|
+
});
|
|
124
|
+
afterEach(() => {
|
|
125
|
+
delete process.env.CONTENT_ADAPTER;
|
|
126
|
+
delete process.env.NEXT_PUBLIC_ENABLED_LOCALES;
|
|
127
|
+
delete process.env.NEXT_PUBLIC_BASE_URL;
|
|
128
|
+
delete ROWS.PortfolioItem;
|
|
129
|
+
if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
130
|
+
else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("lists the PortfolioItem at /writing-samples/acme and nothing under /portfolio", async () => {
|
|
134
|
+
const all = locs(await sitemap({}));
|
|
135
|
+
expect(all.some((loc) => loc.endsWith("/writing-samples/acme"))).toBe(true);
|
|
136
|
+
expect(all.filter((loc) => loc.includes("/portfolio"))).toEqual([]);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -521,3 +521,27 @@ describe("private pages (#11659)", () => {
|
|
|
521
521
|
]);
|
|
522
522
|
});
|
|
523
523
|
});
|
|
524
|
+
|
|
525
|
+
// #11385 D8, AC-9 — a renamed family keeps its chrome at its served segment.
|
|
526
|
+
describe("a renamed route family (#11385 AC-9)", () => {
|
|
527
|
+
const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
528
|
+
beforeEach(() => {
|
|
529
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
|
|
530
|
+
});
|
|
531
|
+
afterEach(() => {
|
|
532
|
+
if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
533
|
+
else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it("finds the portfolio family at /writing-samples", () => {
|
|
537
|
+
expect(routeFamilyOf("/writing-samples/acme", ["en"])).toBe("portfolio");
|
|
538
|
+
expect(routeFamilyOf("/writing-samples", ["en"])).toBe("portfolio");
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
it("names the PortfolioItem and the PortfolioList as the chrome pages, never a LandingPage writing-samples", () => {
|
|
542
|
+
expect(chromePageCandidates("/writing-samples/acme", ["en"])[0]).toEqual({ type: "PortfolioItem", slug: "acme" });
|
|
543
|
+
const list = chromePageCandidates("/writing-samples", ["en"]);
|
|
544
|
+
expect(list[0]).toMatchObject({ type: "PortfolioList" });
|
|
545
|
+
expect(list).not.toContainEqual({ type: "LandingPage", slug: "writing-samples" });
|
|
546
|
+
});
|
|
547
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nav and footer follow a site's route-family renames (#11385 D8, AC-1, AC-9).
|
|
3
|
+
*/
|
|
4
|
+
import type { NavItem } from "@working-theory/ui";
|
|
5
|
+
import { ArrowRight } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { withRenamedColumns, withRenamedNavPaths } from "../route-paths";
|
|
8
|
+
|
|
9
|
+
const saved = process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = '{"portfolio":"writing-samples"}';
|
|
12
|
+
});
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
if (saved === undefined) delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
15
|
+
else process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = saved;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("withRenamedNavPaths", () => {
|
|
19
|
+
it("maps a renamed family's item path", () => {
|
|
20
|
+
expect(withRenamedNavPaths([{ labelKey: "work", path: "/portfolio" }])[0]?.path).toBe(
|
|
21
|
+
"/writing-samples",
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("maps a flyout feature, a group item and an action, and leaves /about alone", () => {
|
|
26
|
+
const items: NavItem[] = [
|
|
27
|
+
{
|
|
28
|
+
labelKey: "work",
|
|
29
|
+
path: "/about",
|
|
30
|
+
flyout: {
|
|
31
|
+
features: [{ labelKey: "acme", path: "/portfolio/acme" }],
|
|
32
|
+
groups: [{ headingKey: "more", items: [{ labelKey: "beta", path: "/portfolio/beta" }] }],
|
|
33
|
+
actions: [{ labelKey: "all", icon: ArrowRight, path: "/portfolio" }],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
const [item] = withRenamedNavPaths(items);
|
|
38
|
+
expect(item?.path).toBe("/about");
|
|
39
|
+
expect(item?.flyout?.features[0]?.path).toBe("/writing-samples/acme");
|
|
40
|
+
expect(item?.flyout?.groups?.[0]?.items[0]?.path).toBe("/writing-samples/beta");
|
|
41
|
+
expect(item?.flyout?.actions?.[0]?.path).toBe("/writing-samples");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("is the identity with no rename", () => {
|
|
45
|
+
delete process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS;
|
|
46
|
+
expect(withRenamedNavPaths([{ labelKey: "work", path: "/portfolio" }])[0]?.path).toBe("/portfolio");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe("withRenamedColumns", () => {
|
|
51
|
+
it("maps a column item", () => {
|
|
52
|
+
expect(
|
|
53
|
+
withRenamedColumns([{ heading: "Work", items: [{ label: "Acme", path: "/portfolio/acme" }] }])[0]?.items[0]
|
|
54
|
+
?.path,
|
|
55
|
+
).toBe("/writing-samples/acme");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
* for a server with no tag, as a site's apps/web has;
|
|
24
24
|
* - one sign-in for every workspace (#11607 D1a): a server given
|
|
25
25
|
* `allWorkspaces` (the Admin) binds `ailk:all-workspaces` in place of the
|
|
26
|
-
* one workspace,
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* another server's.
|
|
26
|
+
* one workspace, and its token-info answers the person's live memberships
|
|
27
|
+
* at each call (D2). Its consent offers no choice (#11672 D1): the server
|
|
28
|
+
* binds every requested scope the person's roles hold. A server without
|
|
29
|
+
* it never binds one and treats such a token as another server's.
|
|
30
30
|
*
|
|
31
31
|
* Every refusal is code-shaped: no English string reaches a client. No answer
|
|
32
32
|
* or log line carries a token, code, verifier or client secret.
|
|
@@ -648,18 +648,22 @@ export function mcpOAuthPlugin(deps: McpOAuthDeps) {
|
|
|
648
648
|
return ctx.json({ redirectURI: redirect.toString() });
|
|
649
649
|
}
|
|
650
650
|
|
|
651
|
-
|
|
651
|
+
let chosen: readonly string[];
|
|
652
652
|
let binding: string;
|
|
653
653
|
if (allWorkspaces) {
|
|
654
654
|
// The reach is every workspace, so naming one is a client of the
|
|
655
|
-
// single-workspace consent (#11607 D1a).
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
if (
|
|
659
|
-
throw refuse("BAD_REQUEST", "
|
|
655
|
+
// single-workspace consent (#11607 D1a). The server decides the
|
|
656
|
+
// grant (#11672 D1): a body naming scopes is refused, never
|
|
657
|
+
// ignored — a client posting a subset believes it is narrowing.
|
|
658
|
+
if (ctx.body.workspace_id !== undefined || ctx.body.scopes !== undefined) {
|
|
659
|
+
throw refuse("BAD_REQUEST", "invalid_request");
|
|
660
660
|
}
|
|
661
|
+
const reach = await offeredReach(userId, value.scope);
|
|
662
|
+
if (reach.workspaces.length === 0) throw refuse("BAD_REQUEST", "invalid_scope");
|
|
663
|
+
chosen = reach.offered;
|
|
661
664
|
binding = ALL_WORKSPACES_SCOPE;
|
|
662
665
|
} else {
|
|
666
|
+
chosen = ctx.body.scopes ?? [];
|
|
663
667
|
const workspace = (await offeredWorkspaces(userId, value.scope)).find(
|
|
664
668
|
(w) => w.id === ctx.body.workspace_id,
|
|
665
669
|
);
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
type RouteFamilyKey,
|
|
38
38
|
type SiteLayout,
|
|
39
39
|
} from "@working-theory/site-config/schema";
|
|
40
|
-
import { ROUTES } from "@working-theory/templates/routes";
|
|
40
|
+
import { conventionPath, ROUTES } from "@working-theory/templates/routes";
|
|
41
41
|
import { readLocales } from "@working-theory/web-i18n";
|
|
42
42
|
import { cache } from "react";
|
|
43
43
|
import { parse as parseYaml } from "yaml";
|
|
@@ -240,14 +240,16 @@ function matchesPattern(pattern: string, segments: readonly string[]): boolean {
|
|
|
240
240
|
* The route family a pathname belongs to, else `null`: the first routes-map
|
|
241
241
|
* hub whose prefix is the path, prefixes it, or whose detail pattern matches
|
|
242
242
|
* it. A site's moved docs are mapped back onto `/docs` first, and its moved
|
|
243
|
-
* services onto `/services` (#10043 D9)
|
|
243
|
+
* services onto `/services` (#10043 D9), then a renamed family's served
|
|
244
|
+
* segment onto its own (#11385 D8).
|
|
244
245
|
*/
|
|
245
246
|
export function routeFamilyOf(
|
|
246
247
|
pathname: string,
|
|
247
248
|
locales: readonly string[],
|
|
248
249
|
): RouteFamilyKey | null {
|
|
249
250
|
const bare = normalizeRoutePath(pathname, locales);
|
|
250
|
-
|
|
251
|
+
// #11385 D8 — a renamed family's served segment maps back onto its own.
|
|
252
|
+
const path = conventionPath(toInternalDocsPath(bare) ?? toInternalServicesPath(bare) ?? bare);
|
|
251
253
|
const segments = path.split("/").filter((segment) => segment.length > 0);
|
|
252
254
|
for (const row of ROUTES) {
|
|
253
255
|
if (!row.hub) continue;
|
|
@@ -277,8 +279,9 @@ export function chromePageCandidates(
|
|
|
277
279
|
locales: readonly string[],
|
|
278
280
|
): Array<{ type: SchemaOrgType; slug: string }> {
|
|
279
281
|
const normalized = normalizeRoutePath(pathname, locales);
|
|
280
|
-
// #10043 D9 — a site's moved services are mapped back onto `/services
|
|
281
|
-
|
|
282
|
+
// #10043 D9 — a site's moved services are mapped back onto `/services`,
|
|
283
|
+
// and #11385 D8 a renamed family's served segment onto its own.
|
|
284
|
+
const path = conventionPath(toInternalServicesPath(normalized) ?? normalized);
|
|
282
285
|
if (path === "/") return [{ type: "HomePage", slug: "home" }];
|
|
283
286
|
const segments = path.split("/").filter((segment) => segment.length > 0);
|
|
284
287
|
// A service under its category (`/services/<category>/<slug>`): the nested
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// route-paths.ts — the nav and footer follow a site's route-family renames
|
|
2
|
+
// (#11385 D8).
|
|
3
|
+
//
|
|
4
|
+
// A site writes `<family>: { path: /<segment> }` in `content/_site.mdx`;
|
|
5
|
+
// `next.config.mjs` bakes the renames into `NEXT_PUBLIC_AILK_ROUTE_PATHS`, and
|
|
6
|
+
// `renamedPath` reads them. The generated nav (`lib/nav-config.ts`) names the
|
|
7
|
+
// convention paths (`/portfolio`), so the layout maps them here at render, as
|
|
8
|
+
// it maps the docs and services paths.
|
|
9
|
+
import { renamedPath } from "@working-theory/templates/routes";
|
|
10
|
+
import type { NavItem } from "@working-theory/ui";
|
|
11
|
+
|
|
12
|
+
import { mapColumnPaths, mapNavItemPaths } from "./services-path";
|
|
13
|
+
|
|
14
|
+
/** Copies of the nav items with every renamed family's path at its served segment. */
|
|
15
|
+
export function withRenamedNavPaths(items: NavItem[]): NavItem[] {
|
|
16
|
+
return mapNavItemPaths(items, (path) => renamedPath(path));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Copies of the footer columns with every renamed family's path at its served segment. */
|
|
20
|
+
export function withRenamedColumns<C extends { items: { path: string }[] }>(columns: C[]): C[] {
|
|
21
|
+
return mapColumnPaths(columns, (path) => renamedPath(path));
|
|
22
|
+
}
|
|
@@ -51,12 +51,14 @@ export function toInternalServicesPath(bare: string): string | null {
|
|
|
51
51
|
|
|
52
52
|
type NavFlyout = NonNullable<NavItem["flyout"]>;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Copies of the nav items with every path mapped through `toPublic` — the
|
|
56
|
+
* item's own `path` and each flyout feature, group item and action. Every
|
|
57
|
+
* other field is carried by reference. Shared with `route-paths.ts` (#11385 D8).
|
|
58
|
+
*/
|
|
59
|
+
export function mapNavItemPaths(items: NavItem[], toPublic: (path: string) => string): NavItem[] {
|
|
60
|
+
const mapPath = <T extends { path: string }>(entry: T): T => ({ ...entry, path: toPublic(entry.path) });
|
|
61
|
+
const mapFlyout = (flyout: NavFlyout): NavFlyout => ({
|
|
60
62
|
...flyout,
|
|
61
63
|
features: flyout.features.map(mapPath),
|
|
62
64
|
...(flyout.groups
|
|
@@ -68,7 +70,23 @@ function mapFlyout(flyout: NavFlyout): NavFlyout {
|
|
|
68
70
|
}
|
|
69
71
|
: {}),
|
|
70
72
|
...(flyout.actions ? { actions: flyout.actions.map(mapPath) } : {}),
|
|
71
|
-
};
|
|
73
|
+
});
|
|
74
|
+
return items.map((item) => ({
|
|
75
|
+
...item,
|
|
76
|
+
...(item.path !== undefined ? { path: toPublic(item.path) } : {}),
|
|
77
|
+
...(item.flyout ? { flyout: mapFlyout(item.flyout) } : {}),
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Copies of the footer columns with every item's path mapped through `toPublic`. */
|
|
82
|
+
export function mapColumnPaths<C extends { items: { path: string }[] }>(
|
|
83
|
+
columns: C[],
|
|
84
|
+
toPublic: (path: string) => string,
|
|
85
|
+
): C[] {
|
|
86
|
+
return columns.map((column) => ({
|
|
87
|
+
...column,
|
|
88
|
+
items: column.items.map((item) => ({ ...item, path: toPublic(item.path) })),
|
|
89
|
+
}));
|
|
72
90
|
}
|
|
73
91
|
|
|
74
92
|
/**
|
|
@@ -77,21 +95,12 @@ function mapFlyout(flyout: NavFlyout): NavFlyout {
|
|
|
77
95
|
* and action. Every other field is carried by reference.
|
|
78
96
|
*/
|
|
79
97
|
export function withPublicServicesPaths(items: NavItem[]): NavItem[] {
|
|
80
|
-
return items
|
|
81
|
-
...item,
|
|
82
|
-
...(item.path !== undefined
|
|
83
|
-
? { path: toPublicServicesHref(item.path) }
|
|
84
|
-
: {}),
|
|
85
|
-
...(item.flyout ? { flyout: mapFlyout(item.flyout) } : {}),
|
|
86
|
-
}));
|
|
98
|
+
return mapNavItemPaths(items, toPublicServicesHref);
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
/** Copies of the footer columns with every item's services path mapped onto `SERVICES_PATH`. */
|
|
90
102
|
export function withPublicServicesColumns<
|
|
91
103
|
C extends { items: { path: string }[] },
|
|
92
104
|
>(columns: C[]): C[] {
|
|
93
|
-
return columns
|
|
94
|
-
...column,
|
|
95
|
-
items: column.items.map(mapPath),
|
|
96
|
-
}));
|
|
105
|
+
return mapColumnPaths(columns, toPublicServicesHref);
|
|
97
106
|
}
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
isBookingPath,
|
|
53
53
|
setAuthRequestHeaders,
|
|
54
54
|
} from "@working-theory/auth/edge";
|
|
55
|
+
import { routeSegment } from "@working-theory/templates/routes";
|
|
55
56
|
import { NextRequest, NextResponse } from "next/server";
|
|
56
57
|
import createMiddleware from "next-intl/middleware";
|
|
57
58
|
|
|
@@ -272,7 +273,7 @@ export function middleware(request: NextRequest): NextResponse {
|
|
|
272
273
|
isFileRoutePath(request.nextUrl.pathname)
|
|
273
274
|
? FILE_ROUTE_SECURITY_HEADERS
|
|
274
275
|
: SCHEDULING_PAGES &&
|
|
275
|
-
isBookingPath(request.nextUrl.pathname, enabledLocales)
|
|
276
|
+
isBookingPath(request.nextUrl.pathname, enabledLocales, routeSegment("meet"))
|
|
276
277
|
? SCHEDULING_SECURITY_HEADERS
|
|
277
278
|
: auth.oneTap
|
|
278
279
|
? ONE_TAP_SECURITY_HEADERS
|
|
@@ -4,8 +4,13 @@ import { parse as parseYaml } from "yaml";
|
|
|
4
4
|
import bundleAnalyzer from "@next/bundle-analyzer";
|
|
5
5
|
import { withSentryConfig } from "@sentry/nextjs";
|
|
6
6
|
import createNextIntlPlugin from "next-intl/plugin";
|
|
7
|
-
import { DocsPathSchema, ServicesPathSchema } from "@working-theory/site-config/schema";
|
|
8
|
-
import {
|
|
7
|
+
import { DocsPathSchema, ServicesPathSchema, SiteConfigSchema } from "@working-theory/site-config/schema";
|
|
8
|
+
import {
|
|
9
|
+
legacyRedirects,
|
|
10
|
+
routeRenameRefusals,
|
|
11
|
+
ROUTES,
|
|
12
|
+
SERVICES_ROUTE,
|
|
13
|
+
} from "@working-theory/templates/routes";
|
|
9
14
|
import { assetRemotePattern } from "@working-theory/validation";
|
|
10
15
|
import { parseStealth } from "@working-theory/web-i18n/stealth";
|
|
11
16
|
import { withBotId } from "botid/next/config";
|
|
@@ -280,6 +285,118 @@ function readServiceParents() {
|
|
|
280
285
|
const servicesPathAtBuild = readServicesPathFromSiteMdx();
|
|
281
286
|
readServiceParents();
|
|
282
287
|
|
|
288
|
+
// #11385 D4 — a renamed route family. A site sets `portfolio: { path:
|
|
289
|
+
// /writing-samples }` in content/_site.mdx on one of the renamable families
|
|
290
|
+
// (the `_site.mdx` keys other than `services` whose schema takes a `path`);
|
|
291
|
+
// it is read here, refused by name when it cannot be served or when its route
|
|
292
|
+
// files were not regenerated, and baked into NEXT_PUBLIC_AILK_ROUTE_PATHS,
|
|
293
|
+
// keyed by convention segment, for @working-theory/templates/route-paths.
|
|
294
|
+
// `redirects()` reads the same value through `legacyRedirects()`.
|
|
295
|
+
const ROUTE_PATH_SCHEMAS = Object.fromEntries(
|
|
296
|
+
Object.entries(SiteConfigSchema.shape)
|
|
297
|
+
.filter(([key, schema]) => key !== "services" && schema.unwrap?.()?.shape?.path !== undefined)
|
|
298
|
+
.map(([key, schema]) => [key, schema.unwrap().shape.path.unwrap()]),
|
|
299
|
+
);
|
|
300
|
+
/** Family → convention segment: the key's kebab form (`caseStudies` → `case-studies`). */
|
|
301
|
+
const ROUTE_CONVENTIONS = Object.fromEntries(
|
|
302
|
+
Object.keys(ROUTE_PATH_SCHEMAS).map((family) => [
|
|
303
|
+
family,
|
|
304
|
+
family.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`),
|
|
305
|
+
]),
|
|
306
|
+
);
|
|
307
|
+
// middleware.ts's NON_LOCALE_ROUTE_PREFIXES, without their slash.
|
|
308
|
+
const NON_LOCALE_SEGMENTS = ["api", "apple-icon", "og", "v1"];
|
|
309
|
+
const ROUTE_ROOT = join(process.cwd(), "app/[locale]");
|
|
310
|
+
const GENERATED_ROUTE_HEADER = /^(?:\/\/ oss: false\r?\n)?\/\/ Generated by create-ailk routes from /;
|
|
311
|
+
|
|
312
|
+
function refuseRouteRename(family, value, reason) {
|
|
313
|
+
throw new Error(`content/_site.mdx ${family}.path ${value}: ${reason}`);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** A route file's text when create-ailk generated it; `undefined` otherwise. */
|
|
317
|
+
function readGeneratedRoute(path) {
|
|
318
|
+
let text;
|
|
319
|
+
try {
|
|
320
|
+
text = readFileSync(path, "utf8");
|
|
321
|
+
} catch {
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
324
|
+
return GENERATED_ROUTE_HEADER.test(text) ? text : undefined;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function readRouteRenamesFromSiteMdx() {
|
|
328
|
+
const renames = {};
|
|
329
|
+
for (const [family, schema] of Object.entries(ROUTE_PATH_SCHEMAS)) {
|
|
330
|
+
const value = siteFrontmatterAtBuild?.[family]?.path;
|
|
331
|
+
if (value === undefined || value === null) continue;
|
|
332
|
+
const parsed = schema.safeParse(value);
|
|
333
|
+
if (!parsed.success) refuseRouteRename(family, value, parsed.error.issues[0].message);
|
|
334
|
+
renames[family] = parsed.data.slice(1);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const [refusal] = routeRenameRefusals(renames, ROUTE_CONVENTIONS, NON_LOCALE_SEGMENTS, [
|
|
338
|
+
...enabledLocalesAtBuild.split(",").map((l) => l.toLowerCase()),
|
|
339
|
+
docsPathAtBuild.split("/")[1],
|
|
340
|
+
servicesPathAtBuild.split("/")[1],
|
|
341
|
+
...NON_LOCALE_SEGMENTS,
|
|
342
|
+
]);
|
|
343
|
+
if (refusal !== undefined) {
|
|
344
|
+
const family = refusal.split(" → ")[0];
|
|
345
|
+
const value = `/${renames[family]}`;
|
|
346
|
+
refuseRouteRename(family, value, refusal.slice(`${family} → ${value}: `.length));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// A renamed family's route files must be generated under its new segment,
|
|
350
|
+
// and that page must be the family's own (`…/pages/<convention>/…`).
|
|
351
|
+
for (const [family, segment] of Object.entries(renames)) {
|
|
352
|
+
const text = readGeneratedRoute(join(ROUTE_ROOT, segment, "page.tsx"));
|
|
353
|
+
const module = text && /\bfrom "(@working-theory\/[^"]+)"/.exec(text)?.[1];
|
|
354
|
+
if (!module?.includes(`/pages/${ROUTE_CONVENTIONS[family]}/`)) {
|
|
355
|
+
refuseRouteRename(
|
|
356
|
+
family,
|
|
357
|
+
`/${segment}`,
|
|
358
|
+
`app/[locale]/${segment}/page.tsx is not the ${family} family's generated route file; run create-ailk routes --write`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// And no generated route file may serve a family away from its segment:
|
|
364
|
+
// the package page it re-exports (`…/pages/<segment>/…`) names its family.
|
|
365
|
+
const familyOfSegment = Object.fromEntries(
|
|
366
|
+
Object.entries(ROUTE_CONVENTIONS).map(([family, segment]) => [segment, family]),
|
|
367
|
+
);
|
|
368
|
+
let dirs = [];
|
|
369
|
+
try {
|
|
370
|
+
dirs = readdirSync(ROUTE_ROOT, { withFileTypes: true }).filter((e) => e.isDirectory());
|
|
371
|
+
} catch {
|
|
372
|
+
// No app/[locale]/ — nothing generated to check.
|
|
373
|
+
}
|
|
374
|
+
for (const { name: dir } of dirs) {
|
|
375
|
+
const text = readGeneratedRoute(join(ROUTE_ROOT, dir, "page.tsx"));
|
|
376
|
+
const module = text && /\bfrom "(@working-theory\/[^"]+)"/.exec(text)?.[1];
|
|
377
|
+
const family = module && familyOfSegment[/\/pages\/([^/]+)\//.exec(module)?.[1]];
|
|
378
|
+
if (!family) continue;
|
|
379
|
+
const served = renames[family] ?? ROUTE_CONVENTIONS[family];
|
|
380
|
+
if (dir !== served) {
|
|
381
|
+
throw new Error(
|
|
382
|
+
`app/[locale]/${dir}/page.tsx re-exports ${module}, the ${family} family's page, which this site serves at /${served}; run create-ailk routes --write`,
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return renames;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const routePathsAtBuild = JSON.stringify(
|
|
390
|
+
Object.fromEntries(
|
|
391
|
+
Object.entries(readRouteRenamesFromSiteMdx()).map(([family, segment]) => [
|
|
392
|
+
ROUTE_CONVENTIONS[family],
|
|
393
|
+
segment,
|
|
394
|
+
]),
|
|
395
|
+
),
|
|
396
|
+
);
|
|
397
|
+
// Before the config is built, so `legacyRedirects()` in `redirects()` reads it.
|
|
398
|
+
process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = routePathsAtBuild;
|
|
399
|
+
|
|
283
400
|
// #10647 D6 — a database spoke's pages name library images as `asset:<key>`,
|
|
284
401
|
// which the hub resolves to its own `/v1/assets/:id` URLs. `next/image` admits
|
|
285
402
|
// that path on the hub's origin, and nothing else, when `AILK_API_URL` (the
|
|
@@ -426,6 +543,10 @@ const nextConfig = {
|
|
|
426
543
|
// services.path, or `/services`. Read by middleware.ts,
|
|
427
544
|
// lib/services-path.ts and @working-theory/page-renderer.
|
|
428
545
|
NEXT_PUBLIC_AILK_SERVICES_PATH: servicesPathAtBuild,
|
|
546
|
+
// The route-family renames (#11385), from content/_site.mdx's
|
|
547
|
+
// `<family>.path` keys, as `{ <convention segment>: <served segment> }`,
|
|
548
|
+
// or `{}`. Read by @working-theory/templates/route-paths.
|
|
549
|
+
NEXT_PUBLIC_AILK_ROUTE_PATHS: routePathsAtBuild,
|
|
429
550
|
},
|
|
430
551
|
async headers() {
|
|
431
552
|
if (!STEALTH) return [];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* handlers to avoid copy-paste duplication.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { pagePath, routeFor } from "@working-theory/templates/routes";
|
|
8
|
+
import { pagePath, renamedPath, routeFor } from "@working-theory/templates/routes";
|
|
9
9
|
|
|
10
10
|
import { SERVICES_PATH } from "../../lib/services-path";
|
|
11
11
|
import { SITE_BASE_URL } from "../../lib/site-brand";
|
|
@@ -44,8 +44,10 @@ export function resolveBaseUrl(): string {
|
|
|
44
44
|
* optional. `sitemap.xml`, `llms.txt` and, since #10775, the docs-blog
|
|
45
45
|
* module's `docs-blog/llms-route.ts` call `pagePathFor` instead; the export
|
|
46
46
|
* stays for a docs-blog site that installed the older copy of that route.
|
|
47
|
+
* It answers the public path, so a renamed route family's segment applies
|
|
48
|
+
* (#11385 D3); `routeFor` stays the hub's path key.
|
|
47
49
|
*/
|
|
48
|
-
export const slugToPath
|
|
50
|
+
export const slugToPath = (type: string, slug: string): string => renamedPath(routeFor(type, slug));
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* One listed page's public path (#10043 D9): `slugToPath`, except that the
|