create-ailk 0.46.5 → 0.47.0

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.
Files changed (30) hide show
  1. package/component-catalog.json +90 -7
  2. package/dist/lib/env-catalog.js +4 -0
  3. package/package.json +3 -3
  4. package/templates/apps/api/.env.example +18 -0
  5. package/templates/apps/api/CLAUDE.md +7 -2
  6. package/templates/apps/api/src/__tests__/vercel-handler.test.ts +176 -2
  7. package/templates/apps/api/src/lib/__mocks__/prisma.ts +31 -0
  8. package/templates/apps/api/src/vercel-handler.ts +32 -2
  9. package/templates/apps/mcp/.env.example +8 -0
  10. package/templates/apps/mcp/CLAUDE.md +2 -2
  11. package/templates/apps/web/CLAUDE.md +31 -3
  12. package/templates/apps/web/app/[locale]/layout.tsx +98 -37
  13. package/templates/apps/web/app/llms.txt/__tests__/site-listing.test.ts +13 -3
  14. package/templates/apps/web/lib/__tests__/grid-read.test.ts +212 -0
  15. package/templates/apps/web/lib/__tests__/hub-read.test.ts +90 -0
  16. package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +394 -10
  17. package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +194 -0
  18. package/templates/apps/web/lib/__tests__/pricing-page.test.ts +210 -0
  19. package/templates/apps/web/lib/__tests__/site-identity-feature-list.test.ts +19 -1
  20. package/templates/apps/web/lib/__tests__/site-navigation.test.ts +288 -0
  21. package/templates/apps/web/lib/grid-read.ts +115 -0
  22. package/templates/apps/web/lib/hub-read.ts +35 -0
  23. package/templates/apps/web/lib/hub-site-config.ts +154 -29
  24. package/templates/apps/web/lib/in-page-blocks.ts +11 -67
  25. package/templates/apps/web/lib/in-page-magnet.ts +5 -24
  26. package/templates/apps/web/lib/page-chrome.ts +70 -3
  27. package/templates/apps/web/lib/pricing-page.ts +33 -2
  28. package/templates/apps/web/lib/site-navigation.ts +208 -0
  29. package/templates/apps/web/next.config.mjs +19 -6
  30. package/versions.json +51 -51
@@ -0,0 +1,208 @@
1
+ /**
2
+ * A site's navigation from its hub (#12401, spec
3
+ * docs/specs/12401-a-site-renders-its-header-spec.md D2, D3).
4
+ *
5
+ * `navigationChrome` turns the workspace's navigation record (#12400 D1) into
6
+ * the props the locale layout hands `Nav` and `Footer` — the components'
7
+ * names and props do not change. It is pure: no I/O, and no environment read
8
+ * beyond the three its path helpers make (the docs base, the services base
9
+ * and the route-family renames `pagePath` applies).
10
+ *
11
+ * - A `page` target links to the page's public path on this site:
12
+ * `pagePath` puts a service at the services base and applies the
13
+ * route-family renames, and `toPublicDocsHref` moves `/docs` to the docs
14
+ * path. A `path` or `url` target is used as stored — the record holds the
15
+ * address a visitor sees. No locale prefix is added: the chrome adds it.
16
+ * - A label is the visitor's locale's text when the record has one, else its
17
+ * default text. Every key made here contains a dot and no `nav` message key
18
+ * does, so a record label never replaces a translated one; keys are by
19
+ * position, so two links with the same label stay two links.
20
+ * - Order is the record's; nothing is added, merged or sorted. The hub has
21
+ * already left out every item whose page is not live (#12400 D5).
22
+ * - Every address it emits is checked before it returns, by the record's own
23
+ * target rules: a site path or an `http:`/`https:` URL. Anything else throws, so
24
+ * `safeNavigationChrome` answers `null` and the site's own files render.
25
+ *
26
+ * It imports no site module but `docs-path` and `services-path`, so it closes
27
+ * no import cycle (#12385).
28
+ */
29
+
30
+ import { pagePath } from "@working-theory/templates/routes";
31
+ import type { NavItem } from "@working-theory/ui";
32
+ import {
33
+ siteNavigationTargetSchema,
34
+ type SiteNavigation,
35
+ type SiteNavigationLabel,
36
+ type SiteNavigationLink,
37
+ type SiteNavigationTarget,
38
+ } from "@working-theory/validation";
39
+
40
+ import { toPublicDocsHref } from "./docs-path";
41
+ import { SERVICES_PATH } from "./services-path";
42
+
43
+ type NavFlyoutFeature = NonNullable<NavItem["flyout"]>["features"][number];
44
+
45
+ /** A link with a label already in the visitor's locale. */
46
+ export interface NavigationLink {
47
+ label: string;
48
+ href: string;
49
+ }
50
+
51
+ /** What the layout puts into `Nav` and `Footer` from a record. */
52
+ export interface NavigationChrome {
53
+ /** `Nav`'s and `Footer`'s `navItems`. */
54
+ navItems: NavItem[];
55
+ /** `Footer`'s `columns`. */
56
+ columns: {
57
+ heading: string;
58
+ headingKey: string;
59
+ items: { labelKey: string; path: string; label: string }[];
60
+ }[];
61
+ /** Every label, heading and description, merged into the layout's label map. */
62
+ labels: Record<string, string>;
63
+ /** The signed-out header's button. */
64
+ button?: NavigationLink;
65
+ signIn?: "link" | "hidden";
66
+ /** The bottom bar's links, before the cookie-settings link. */
67
+ legalLinks: NavigationLink[];
68
+ /** The closing footer's locality line and actions. */
69
+ closing?: { locality?: string; actions: NavigationLink[] };
70
+ }
71
+
72
+ /**
73
+ * Whether an emitted address passes the record's own target rules — a site
74
+ * path (one leading `/` not followed by `/` or a backslash, no whitespace or
75
+ * backslash), else an `http:`/`https:` URL with no user or password — the
76
+ * schema's checks, shared rather than restated.
77
+ */
78
+ function isSafeAddress(address: string): boolean {
79
+ return siteNavigationTargetSchema.safeParse(
80
+ address.startsWith("/") ? { kind: "path", path: address } : { kind: "url", href: address },
81
+ ).success;
82
+ }
83
+
84
+ /**
85
+ * The record's header and footer as the layout's chrome props, for the
86
+ * visitor's `locale`. Throws on an address that is neither a site path nor an
87
+ * `http:`/`https:` URL.
88
+ */
89
+ export function navigationChrome(record: SiteNavigation, locale: string): NavigationChrome {
90
+ const wanted = locale.toLowerCase();
91
+ const labels: Record<string, string> = {};
92
+ const emitted: string[] = [];
93
+
94
+ const text = (label: SiteNavigationLabel): string => {
95
+ for (const [code, value] of Object.entries(label.byLocale ?? {})) {
96
+ if (code.toLowerCase() === wanted) return value;
97
+ }
98
+ return label.text;
99
+ };
100
+ const addressOf = (target: SiteNavigationTarget): string => {
101
+ const address =
102
+ target.kind === "page"
103
+ ? toPublicDocsHref(pagePath({ type: target.address.type, slug: target.address.slug }, SERVICES_PATH))
104
+ : target.kind === "path"
105
+ ? target.path
106
+ : target.href;
107
+ emitted.push(address);
108
+ return address;
109
+ };
110
+ const linkOf = (link: SiteNavigationLink): NavigationLink => ({
111
+ label: text(link.label),
112
+ href: addressOf(link.target),
113
+ });
114
+ const keyed = (key: string, link: SiteNavigationLink): NavFlyoutFeature => {
115
+ labels[key] = text(link.label);
116
+ const feature: NavFlyoutFeature = { labelKey: key, path: addressOf(link.target) };
117
+ if (link.description !== undefined) {
118
+ labels[`${key}.d`] = text(link.description);
119
+ feature.descKey = `${key}.d`;
120
+ }
121
+ return feature;
122
+ };
123
+
124
+ const navItems = record.header.items.map((item, i): NavItem => {
125
+ const key = `rec.h${i}`;
126
+ labels[key] = text(item.label);
127
+ if (item.kind === "link") return { labelKey: key, path: addressOf(item.target) };
128
+ const [only] = item.groups;
129
+ if (item.groups.length === 1 && only !== undefined && only.heading === undefined) {
130
+ const features = only.links.map((link, l) => keyed(`${key}.g0.l${l}`, link));
131
+ const described = features.some((feature) => feature.descKey !== undefined);
132
+ return {
133
+ labelKey: key,
134
+ flyout: described
135
+ ? { features, presentation: "grid", width: "panel" }
136
+ : { features, presentation: "list", width: "trigger" },
137
+ };
138
+ }
139
+ const groups = item.groups.map((group, g) => {
140
+ const headingKey = `${key}.g${g}`;
141
+ labels[headingKey] = group.heading === undefined ? "" : text(group.heading);
142
+ return {
143
+ headingKey,
144
+ items: group.links.map((link, l) => keyed(`${headingKey}.l${l}`, link)),
145
+ };
146
+ });
147
+ return {
148
+ labelKey: key,
149
+ flyout: { features: groups.flatMap((group) => group.items), groups, width: "panel" },
150
+ };
151
+ });
152
+
153
+ const columns = record.footer.columns.map((column, c) => {
154
+ const headingKey = `rec.f${c}`;
155
+ const heading = text(column.heading);
156
+ labels[headingKey] = heading;
157
+ return {
158
+ heading,
159
+ headingKey,
160
+ items: column.links.map((link, l) => {
161
+ const labelKey = `${headingKey}.l${l}`;
162
+ const label = text(link.label);
163
+ labels[labelKey] = label;
164
+ return { labelKey, path: addressOf(link.target), label };
165
+ }),
166
+ };
167
+ });
168
+
169
+ const { button, signIn } = record.header;
170
+ const { closing } = record.footer;
171
+ const chrome: NavigationChrome = {
172
+ navItems,
173
+ columns,
174
+ labels,
175
+ legalLinks: (record.footer.bottomBar?.links ?? []).map(linkOf),
176
+ ...(button !== undefined ? { button: linkOf(button) } : {}),
177
+ ...(signIn !== undefined ? { signIn } : {}),
178
+ ...(closing !== undefined
179
+ ? {
180
+ closing: {
181
+ ...(closing.location !== undefined ? { locality: closing.location } : {}),
182
+ actions: closing.buttons.map(linkOf),
183
+ },
184
+ }
185
+ : {}),
186
+ };
187
+
188
+ for (const address of emitted) {
189
+ if (!isSafeAddress(address)) throw new TypeError("navigation address refused");
190
+ }
191
+ return chrome;
192
+ }
193
+
194
+ /**
195
+ * `navigationChrome`, or `null` when it throws — with one warning naming the
196
+ * error's kind, never a value — so a record that cannot be rendered never
197
+ * throws into a page and the site's own files render.
198
+ */
199
+ export function safeNavigationChrome(record: SiteNavigation, locale: string): NavigationChrome | null {
200
+ try {
201
+ return navigationChrome(record, locale);
202
+ } catch (err) {
203
+ console.warn(
204
+ `[site-navigation] record not rendered (${err instanceof Error ? err.name : typeof err})`,
205
+ );
206
+ return null;
207
+ }
208
+ }
@@ -11,7 +11,7 @@ import {
11
11
  ROUTES,
12
12
  SERVICES_ROUTE,
13
13
  } from "@working-theory/templates/routes";
14
- import { assetRemotePattern } from "@working-theory/validation";
14
+ import { assetImageConfigWarning, assetRemotePattern } from "@working-theory/validation";
15
15
  import { parseStealth } from "@working-theory/web-i18n/stealth";
16
16
  import { withBotId } from "botid/next/config";
17
17
 
@@ -401,10 +401,20 @@ process.env.NEXT_PUBLIC_AILK_ROUTE_PATHS = routePathsAtBuild;
401
401
  // which the hub resolves to its own `/v1/assets/:id` URLs. `next/image` admits
402
402
  // that path on the hub's origin, and nothing else, when `AILK_API_URL` (the
403
403
  // server-side hub origin this site already reads) is an http(s) URL at build
404
- // time; otherwise there is no `images` key, as before. A change of hub origin
405
- // needs a rebuild.
404
+ // time; otherwise there are no remote patterns. A change of hub origin needs a
405
+ // rebuild.
406
+ //
407
+ // #12428 D4 (M3) — `minimumCacheTTL: 60` always, in place of Next's four-hour
408
+ // default, so a made-private, disabled or deleted image leaves this site's
409
+ // image cache within a minute of the hub and the store dropping it.
406
410
  const assetPatternAtBuild = assetRemotePattern(process.env.AILK_API_URL);
407
411
 
412
+ // #12420 D7 — every site that reads hub pages needs that origin, not only a
413
+ // spoke: a database site built without it is told so, once, by name. It
414
+ // reads `CONTENT_ADAPTER` and `AILK_API_URL` only.
415
+ const assetConfigWarning = assetImageConfigWarning(process.env);
416
+ if (assetConfigWarning !== null) console.warn(`[next.config] ${assetConfigWarning}`);
417
+
408
418
  /** @type {import('next').NextConfig} */
409
419
  const nextConfig = {
410
420
  reactStrictMode: true,
@@ -519,9 +529,12 @@ const nextConfig = {
519
529
  // mutates a tracked file as a side effect of running the dev server,
520
530
  // which this scaffold does not want.
521
531
  agentRules: false,
522
- ...(assetPatternAtBuild === null
523
- ? {}
524
- : { images: { remotePatterns: [assetPatternAtBuild] } }),
532
+ images: {
533
+ minimumCacheTTL: 60,
534
+ ...(assetPatternAtBuild === null
535
+ ? {}
536
+ : { remotePatterns: [assetPatternAtBuild] }),
537
+ },
525
538
  env: {
526
539
  // Comma-separated locale list baked at build time — consumed by middleware
527
540
  // and the sitemap route. NEXT_PUBLIC_ prefix makes it available in Edge
package/versions.json CHANGED
@@ -1,69 +1,69 @@
1
1
  {
2
- "@working-theory/account": "0.79.0",
3
- "@working-theory/admin-ui": "0.79.0",
4
- "@working-theory/aeo": "0.79.0",
5
- "@working-theory/agent-context": "0.79.0",
2
+ "@working-theory/account": "0.81.0",
3
+ "@working-theory/admin-ui": "0.81.0",
4
+ "@working-theory/aeo": "0.81.0",
5
+ "@working-theory/agent-context": "0.81.0",
6
6
  "@working-theory/agent-contract": "0.1.0",
7
7
  "@working-theory/agent-memory": "0.0.0",
8
8
  "@working-theory/ai": "0.1.0",
9
- "@working-theory/analytics": "0.79.0",
10
- "@working-theory/api": "0.79.0",
11
- "@working-theory/api-client": "0.79.0",
12
- "@working-theory/auth": "0.79.0",
9
+ "@working-theory/analytics": "0.81.0",
10
+ "@working-theory/api": "0.81.0",
11
+ "@working-theory/api-client": "0.81.0",
12
+ "@working-theory/auth": "0.81.0",
13
13
  "@working-theory/cda-filesystem": "0.0.0",
14
- "@working-theory/cli": "0.79.0",
15
- "@working-theory/common": "0.79.0",
14
+ "@working-theory/cli": "0.81.0",
15
+ "@working-theory/common": "0.81.0",
16
16
  "@working-theory/consent": "0.1.0",
17
- "@working-theory/content-adapters": "0.79.0",
18
- "@working-theory/content-projection": "0.79.0",
19
- "@working-theory/email": "0.79.0",
17
+ "@working-theory/content-adapters": "0.81.0",
18
+ "@working-theory/content-projection": "0.81.0",
19
+ "@working-theory/email": "0.81.0",
20
20
  "@working-theory/env": "0.0.0",
21
- "@working-theory/eslint-config": "0.79.0",
22
- "@working-theory/fumadocs-schema": "0.79.0",
23
- "@working-theory/ids": "0.23.0",
24
- "@working-theory/jsonld": "0.79.0",
25
- "@working-theory/license": "0.79.0",
26
- "@working-theory/mcp-server": "0.79.0",
27
- "@working-theory/metadata": "0.79.0",
28
- "@working-theory/observability": "0.79.0",
29
- "@working-theory/page-renderer": "0.79.0",
21
+ "@working-theory/eslint-config": "0.81.0",
22
+ "@working-theory/fumadocs-schema": "0.81.0",
23
+ "@working-theory/ids": "0.24.0",
24
+ "@working-theory/jsonld": "0.81.0",
25
+ "@working-theory/license": "0.81.0",
26
+ "@working-theory/mcp-server": "0.81.0",
27
+ "@working-theory/metadata": "0.81.0",
28
+ "@working-theory/observability": "0.81.0",
29
+ "@working-theory/page-renderer": "0.81.0",
30
30
  "@working-theory/plugin-mcp": "0.1.3",
31
- "@working-theory/schema": "0.79.0",
32
- "@working-theory/schema-pack-registry": "0.79.0",
33
- "@working-theory/schema-validator": "0.79.0",
34
- "@working-theory/sections-registry": "0.79.0",
35
- "@working-theory/site-config": "0.79.0",
36
- "@working-theory/site-pages": "0.79.0",
37
- "@working-theory/spoke-checkout": "0.7.36",
38
- "@working-theory/stripe-client": "0.79.0",
39
- "@working-theory/templates": "0.79.0",
40
- "@working-theory/theme": "0.79.0",
41
- "@working-theory/ui": "0.79.0",
42
- "@working-theory/validation": "0.79.0",
43
- "@working-theory/web-i18n": "0.79.0",
44
- "@working-theory/admin": "0.27.0",
45
- "@working-theory/api-commerce": "0.2.14",
46
- "@working-theory/api-content-write": "0.18.1",
47
- "@working-theory/api-hub": "0.9.4",
48
- "@working-theory/api-multi-tenant": "0.5.6",
49
- "@working-theory/api-scheduling": "0.6.19",
50
- "@working-theory/api-signal-collectors": "0.9.0",
51
- "@working-theory/api-workspace": "0.19.0",
31
+ "@working-theory/schema": "0.81.0",
32
+ "@working-theory/schema-pack-registry": "0.81.0",
33
+ "@working-theory/schema-validator": "0.81.0",
34
+ "@working-theory/sections-registry": "0.81.0",
35
+ "@working-theory/site-config": "0.81.0",
36
+ "@working-theory/site-pages": "0.81.0",
37
+ "@working-theory/spoke-checkout": "0.7.38",
38
+ "@working-theory/stripe-client": "0.81.0",
39
+ "@working-theory/templates": "0.81.0",
40
+ "@working-theory/theme": "0.81.0",
41
+ "@working-theory/ui": "0.81.0",
42
+ "@working-theory/validation": "0.81.0",
43
+ "@working-theory/web-i18n": "0.81.0",
44
+ "@working-theory/admin": "0.29.0",
45
+ "@working-theory/api-commerce": "0.2.16",
46
+ "@working-theory/api-content-write": "0.19.0",
47
+ "@working-theory/api-hub": "0.10.1",
48
+ "@working-theory/api-multi-tenant": "0.6.1",
49
+ "@working-theory/api-scheduling": "0.6.21",
50
+ "@working-theory/api-signal-collectors": "0.10.0",
51
+ "@working-theory/api-workspace": "0.21.0",
52
52
  "@working-theory/billing-client": "0.0.0",
53
53
  "@working-theory/branding": "0.0.0",
54
54
  "@working-theory/license-client": "0.0.0",
55
55
  "@working-theory/license-manifest": "0.0.0",
56
- "@working-theory/mcp-scheduling": "0.4.21",
57
- "@working-theory/mcp-signal-collectors": "0.2.34",
58
- "@working-theory/mcp-workspace": "0.17.0",
56
+ "@working-theory/mcp-scheduling": "0.4.23",
57
+ "@working-theory/mcp-signal-collectors": "0.2.36",
58
+ "@working-theory/mcp-workspace": "0.18.0",
59
59
  "@working-theory/partner-session": "0.0.0",
60
60
  "@working-theory/preview-protocol": "0.0.0",
61
- "@working-theory/ui-commerce": "0.79.0",
62
- "@working-theory/ui-docs-blog": "0.79.0",
63
- "@working-theory/ui-scheduling": "0.79.0",
64
- "@working-theory/ui-signal-collectors": "0.79.0",
61
+ "@working-theory/ui-commerce": "0.81.0",
62
+ "@working-theory/ui-docs-blog": "0.81.0",
63
+ "@working-theory/ui-scheduling": "0.81.0",
64
+ "@working-theory/ui-signal-collectors": "0.81.0",
65
65
  "@working-theory/web": "0.0.0",
66
66
  "@working-theory/app-api": "1.0.0",
67
67
  "@working-theory/mcp": "0.0.0",
68
- "@working-theory/database": "0.79.0"
68
+ "@working-theory/database": "0.81.0"
69
69
  }