create-stitchkit 0.6.17 → 0.6.19
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 +42 -0
- package/dist/cli.js +62 -27
- package/examples/repository/packages/frontend/src/app/[locale]/page.tsx +2 -0
- package/examples/repository/packages/frontend/src/app/[locale]/starter-page.tsx +12 -8
- package/examples/repository/project.json +9 -0
- package/package.json +10 -9
- package/template/README.md +7 -0
- package/template/_env.example +5 -0
- package/template/biome.json +4 -1
- package/template/bun.lock +303 -301
- package/template/docs/ADMIN_MOCK.md +38 -0
- package/template/e2e/starter.spec.ts +2 -2
- package/template/package.json +17 -16
- package/template/packages/backend/package.json +6 -6
- package/template/packages/backend/src/cleanup.ts +4 -7
- package/template/packages/backend/src/index.ts +2 -1
- package/template/packages/backend/src/surface-manifest.test.ts +3 -3
- package/template/packages/backend/src/surface.ts +7 -6
- package/template/packages/backend/src/trusted-origins.test.ts +40 -0
- package/template/packages/backend/src/trusted-origins.ts +21 -0
- package/template/packages/config/package.json +3 -3
- package/template/packages/config/src/shutdown.ts +3 -4
- package/template/packages/config/src/variables.ts +21 -9
- package/template/packages/db/package.json +4 -4
- package/template/packages/frontend/next.config.ts +10 -1
- package/template/packages/frontend/package.json +29 -29
- package/template/packages/frontend/scripts/serve.ts +4 -4
- package/template/packages/frontend/src/app/[locale]/admin/[[...section]]/page.dev.tsx +21 -0
- package/template/packages/frontend/src/app/[locale]/page.tsx +2 -1
- package/template/packages/frontend/src/app/[locale]/starter-page.tsx +12 -8
- package/template/packages/frontend/src/app/api/[...path]/route.ts +2 -37
- package/template/packages/frontend/src/app/sitemap.ts +4 -1
- package/template/packages/frontend/src/components/ui/toaster.tsx +2 -2
- package/template/packages/frontend/src/env.ts +12 -3
- package/template/packages/frontend/src/features/admin/admin-data.ts +13 -0
- package/template/packages/frontend/src/features/admin/admin-sections.ts +78 -0
- package/template/packages/frontend/src/features/admin/admin-workspace.test.tsx +59 -0
- package/template/packages/frontend/src/features/admin/admin-workspace.tsx +127 -0
- package/template/packages/frontend/src/features/admin/fixture/admin-fixture.ts +35 -0
- package/template/packages/frontend/src/lib/api-proxy.test.ts +131 -0
- package/template/packages/frontend/src/lib/api-proxy.ts +89 -0
- package/template/packages/frontend/src/lib/query-client.test.ts +1 -1
- package/template/packages/frontend/src/lib/query-client.ts +2 -3
- package/template/packages/frontend/src/lib/seo/cache-by-origin.ts +2 -2
- package/template/packages/frontend/src/lib/seo/request-origin.ts +5 -5
- package/template/packages/frontend/src/proxy.ts +12 -1
- package/template/packages/shared/package.json +2 -2
- package/template/packages/shared/src/contracts/board.ts +1 -3
- package/template/packages/shared/src/contracts/system.ts +1 -3
- package/template/project.json +9 -0
- package/template/scripts/acceptance-database.test.ts +4 -4
- package/template/scripts/acceptance-database.ts +4 -6
- package/template/scripts/acceptance-local.ts +14 -9
- package/template/scripts/build-stamp.test.ts +3 -5
- package/template/scripts/build-stamp.ts +8 -11
- package/template/scripts/check-authored.test.ts +16 -1
- package/template/scripts/check-authored.ts +7 -6
- package/template/scripts/client-boundary.test.ts +26 -8
- package/template/scripts/client-boundary.ts +30 -27
- package/template/scripts/declaration.test.ts +5 -7
- package/template/scripts/declaration.ts +14 -19
- package/template/scripts/deployment-preflight.ts +2 -3
- package/template/scripts/dev.ts +6 -8
- package/template/scripts/fixture-boundary.test.ts +34 -0
- package/template/scripts/fixture-boundary.ts +25 -0
- package/template/scripts/guide-paths.ts +2 -4
- package/template/scripts/readiness.ts +4 -5
- package/template/scripts/release-steps.test.ts +2 -4
- package/template/scripts/release-steps.ts +2 -2
- package/template/scripts/runtime-smoke.test.ts +6 -7
- package/template/scripts/serve-mode.test.ts +2 -2
- package/template/scripts/service-surfaces-closed.ts +13 -0
- package/template/scripts/shutdown-budget.fixture.ts +3 -5
- package/template/scripts/shutdown-budget.test.ts +4 -8
- package/template/scripts/supervision-signal.test.ts +1 -1
- package/template/scripts/web-surface-smoke.ts +38 -8
- package/templates/agent/biome.json +4 -1
- package/templates/agent/package.json +11 -7
- package/templates/telegram-bot/biome.json +4 -1
- package/templates/telegram-bot/package.json +8 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# The admin panel on fixture
|
|
2
|
+
|
|
3
|
+
`/en/admin` shows the shape of a future admin panel before any of its API exists: sections, roles, tables
|
|
4
|
+
and dialogs, on invented rows and with no database. A customer sees the system and answers questions
|
|
5
|
+
about it before the first migration.
|
|
6
|
+
|
|
7
|
+
It exists in development only. Its route is `app/[locale]/admin/[[...section]]/page.dev.tsx`, and `.dev.tsx`
|
|
8
|
+
is a page extension of the development server alone (`next.config.ts`), so a production build has no such
|
|
9
|
+
route: the address answers 404 and the rows are not in the artifact.
|
|
10
|
+
`bun run acceptance:local` proves that on the built files (`scripts/fixture-boundary.ts`).
|
|
11
|
+
|
|
12
|
+
## Addresses
|
|
13
|
+
|
|
14
|
+
| Address | Section | Read | Write | Status |
|
|
15
|
+
|---|---|---|---|---|
|
|
16
|
+
| `/admin` | Records | `records.read` | `records.write` | `mock` |
|
|
17
|
+
| `/admin/people` | People | `people.read` | `people.write` | `mock` |
|
|
18
|
+
|
|
19
|
+
`features/admin/admin-sections.ts` is the source of this table. Keep them in step.
|
|
20
|
+
|
|
21
|
+
## Changing it
|
|
22
|
+
|
|
23
|
+
Rename the sections and the columns of `AdminRow` to your domain, in `admin-sections.ts`, `admin-data.ts`
|
|
24
|
+
and `fixture/admin-fixture.ts`. `adminPermissions` must decide every role against every operation, and the
|
|
25
|
+
role buttons in the sidebar switch between them for a demonstration only: they prove nothing to a server.
|
|
26
|
+
|
|
27
|
+
## Taking a section off fixture
|
|
28
|
+
|
|
29
|
+
1. Build the vertical slice by [`ADDING_A_FEATURE.md`](ADDING_A_FEATURE.md), answering `AdminRow`.
|
|
30
|
+
2. Enforce the same operation on the server, with `adminPermissions` moved to `packages/shared` so both sides
|
|
31
|
+
read one matrix.
|
|
32
|
+
3. Set the section's `status` to `live`, supply its rows from the API, and rename the route to `page.tsx`, which
|
|
33
|
+
production builds. Keep a section that is still `mock` behind a page of its own in `page.dev.tsx`.
|
|
34
|
+
4. Delete its rows from the fixture.
|
|
35
|
+
|
|
36
|
+
When no section is `mock`, delete `features/admin/fixture/`, `scripts/fixture-boundary.ts` and its acceptance
|
|
37
|
+
step. If the panel is not wanted at all, delete `features/admin` and
|
|
38
|
+
`app/[locale]/admin` as two directories, with the same script and step.
|
|
@@ -40,8 +40,8 @@ test('a note posted in one tab reaches another through the web origin and the so
|
|
|
40
40
|
}) => {
|
|
41
41
|
// The browser's own origin carries HTTP (`/api` is forwarded by the web
|
|
42
42
|
// role) and the socket dials the API role; a post in one tab must reach a
|
|
43
|
-
// second tab that never asked for it.
|
|
44
|
-
//
|
|
43
|
+
// second tab that never asked for it. The assertion requires both HTTP
|
|
44
|
+
// forwarding on the web port and a working socket in the browser build.
|
|
45
45
|
const writer = await browser.newPage();
|
|
46
46
|
const reader = await browser.newPage();
|
|
47
47
|
await Promise.all([writer.goto('/en'), reader.goto('/en')]);
|
package/template/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"packages/*"
|
|
8
8
|
],
|
|
9
9
|
"catalog": {
|
|
10
|
-
"stitchkit": "^0.
|
|
10
|
+
"stitchkit": "^0.119.0"
|
|
11
11
|
},
|
|
12
12
|
"overrides": {
|
|
13
|
-
"@playwright/test": "1.
|
|
14
|
-
"playwright": "1.
|
|
15
|
-
"playwright-core": "1.
|
|
16
|
-
"zod": "4.6.
|
|
13
|
+
"@playwright/test": "1.64.1",
|
|
14
|
+
"playwright": "1.64.1",
|
|
15
|
+
"playwright-core": "1.64.1",
|
|
16
|
+
"zod": "4.6.7"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"dev": "bun scripts/dev.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"cli": "bun packages/backend/src/cli.ts",
|
|
34
34
|
"tools": "bun packages/backend/src/tools.ts",
|
|
35
35
|
"runtime:smoke": "bun scripts/runtime-smoke.ts",
|
|
36
|
+
"surfaces:closed": "bun scripts/service-surfaces-closed.ts",
|
|
36
37
|
"surface:snapshot": "bun scripts/surface-snapshot.ts",
|
|
37
38
|
"e2e": "playwright test",
|
|
38
39
|
"acceptance:local": "bun scripts/acceptance-local.ts",
|
|
@@ -43,26 +44,26 @@
|
|
|
43
44
|
"gen:declaration": "bun scripts/declaration.ts"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"dotenv": "^18.0.
|
|
47
|
+
"dotenv": "^18.0.9"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@app/config": "workspace:*",
|
|
50
51
|
"@app/shared": "workspace:*",
|
|
51
|
-
"@axe-core/playwright": "^4.
|
|
52
|
-
"@biomejs/biome": "
|
|
53
|
-
"@modelcontextprotocol/client": "^2.
|
|
54
|
-
"@playwright/test": "^1.
|
|
55
|
-
"@types/bun": "^1.4.
|
|
56
|
-
"@types/node": "^26.6.
|
|
57
|
-
"oxc-parser": "^0.
|
|
58
|
-
"socket.io-client": "^4.8.
|
|
52
|
+
"@axe-core/playwright": "^4.14.0",
|
|
53
|
+
"@biomejs/biome": "2.6.5",
|
|
54
|
+
"@modelcontextprotocol/client": "^2.4.0",
|
|
55
|
+
"@playwright/test": "^1.64.1",
|
|
56
|
+
"@types/bun": "^1.4.4",
|
|
57
|
+
"@types/node": "^26.6.6",
|
|
58
|
+
"oxc-parser": "^0.157.0",
|
|
59
|
+
"socket.io-client": "^4.8.4",
|
|
59
60
|
"stitchkit": "catalog:",
|
|
60
61
|
"typescript": "^7.0.2",
|
|
61
|
-
"zod": "^4.6.
|
|
62
|
+
"zod": "^4.6.7"
|
|
62
63
|
},
|
|
63
64
|
"engines": {
|
|
64
65
|
"bun": ">=1.2.0",
|
|
65
66
|
"node": ">=22"
|
|
66
67
|
},
|
|
67
|
-
"packageManager": "bun@1.4.
|
|
68
|
+
"packageManager": "bun@1.4.4"
|
|
68
69
|
}
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
"@app/config": "workspace:*",
|
|
17
17
|
"@app/db": "workspace:*",
|
|
18
18
|
"@app/shared": "workspace:*",
|
|
19
|
-
"@modelcontextprotocol/server": "^2.
|
|
20
|
-
"@prisma/adapter-pg": "^7.10.
|
|
19
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
20
|
+
"@prisma/adapter-pg": "^7.10.1",
|
|
21
21
|
"@socket.io/bun-engine": "^0.1.2",
|
|
22
|
-
"ai": "^7.0.
|
|
23
|
-
"socket.io": "^4.8.
|
|
22
|
+
"ai": "^7.0.162",
|
|
23
|
+
"socket.io": "^4.8.4",
|
|
24
24
|
"stitchkit": "catalog:",
|
|
25
|
-
"zod": "^4.6.
|
|
25
|
+
"zod": "^4.6.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/bun": "^1.4.
|
|
28
|
+
"@types/bun": "^1.4.4",
|
|
29
29
|
"typescript": "^7.0.2"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -38,14 +38,11 @@ type StepOutcome =
|
|
|
38
38
|
*
|
|
39
39
|
* The two ways a step can end are kept apart. Running out of time and throwing
|
|
40
40
|
* are different facts about a shutdown — one says a resource is still held, the
|
|
41
|
-
* other says closing it is broken
|
|
42
|
-
*
|
|
43
|
-
* reason gone.
|
|
41
|
+
* other says closing it is broken. Both must retain their cause so a failed
|
|
42
|
+
* shutdown cannot appear as a clean exit.
|
|
44
43
|
*
|
|
45
|
-
* The clock is `performance.now()` and cannot be replaced
|
|
46
|
-
*
|
|
47
|
-
* wrong for a deadline: a wall clock stepped backwards widens the very upper
|
|
48
|
-
* bound a supervisor's kill timeout was derived from, and an injected clock
|
|
44
|
+
* The clock is `performance.now()` and cannot be replaced: a wall clock stepped
|
|
45
|
+
* backwards widens the upper bound of a supervisor's kill timeout, and an injected clock
|
|
49
46
|
* that does not advance hands every step a full budget — a shutdown budget that
|
|
50
47
|
* a test could switch off. Nothing needs to fake it: the regression that
|
|
51
48
|
* matters runs a real process.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { env } from '@app/config';
|
|
2
2
|
import { apiRole, appDeclaration } from '@app/config/declaration';
|
|
3
|
+
import { serviceSurfacesAreOpen } from '@app/config/variables';
|
|
3
4
|
import { wrapInRequestContext } from 'stitchkit/observability';
|
|
4
5
|
import {
|
|
5
6
|
bindProcessSignals,
|
|
@@ -44,7 +45,7 @@ async function main(): Promise<void> {
|
|
|
44
45
|
logging: { format: env.LOG_FORMAT },
|
|
45
46
|
socket,
|
|
46
47
|
rawRoutes: [
|
|
47
|
-
openApiRoute('/openapi.json', openApi),
|
|
48
|
+
...(serviceSurfacesAreOpen(env) ? [openApiRoute('/openapi.json', openApi)] : []),
|
|
48
49
|
createMcpHttpRoute({ path: '/mcp', handler: mcp }),
|
|
49
50
|
{
|
|
50
51
|
method: 'GET',
|
|
@@ -103,8 +103,8 @@ describe('surface conformance', () => {
|
|
|
103
103
|
agentToolNames: ['read_note'],
|
|
104
104
|
cliToolNames: ['read_note'],
|
|
105
105
|
};
|
|
106
|
-
//
|
|
107
|
-
//
|
|
106
|
+
// Without x-stitchkit-* metadata there is nothing to compare. The default
|
|
107
|
+
// mode rejects the document; opting out is an explicit decision.
|
|
108
108
|
expect(() =>
|
|
109
109
|
assertSurfaceConformance({ manifest, openApi: standardDocument, ...names }),
|
|
110
110
|
).toThrow(/no x-stitchkit-\* contract metadata/);
|
|
@@ -145,7 +145,7 @@ describe('surface conformance', () => {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
test('the committed snapshot catches an expose edit that moves BOTH in-process sides together', () => {
|
|
148
|
-
//
|
|
148
|
+
// Removing AGENT/CLI from `expose`
|
|
149
149
|
// changes the manifest AND the in-process tool lists in lockstep. The
|
|
150
150
|
// snapshot is the anchor that does not move with the source.
|
|
151
151
|
const snapshot = buildSurfaceManifest([service]);
|
|
@@ -4,6 +4,7 @@ import { type BoardRuntime, openBoard } from './lib/board';
|
|
|
4
4
|
import { bindLive } from './lib/live';
|
|
5
5
|
import { createBoardService } from './transport/board-service';
|
|
6
6
|
import { createSystemService } from './transport/system-service';
|
|
7
|
+
import { trustedBrowserAuthorities } from './trusted-origins';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The fence this deployment answers behind, or nothing.
|
|
@@ -13,15 +14,15 @@ import { createSystemService } from './transport/system-service';
|
|
|
13
14
|
* Unset means no fence, which is honest for a checkout on a laptop and wrong for
|
|
14
15
|
* anything a network can reach.
|
|
15
16
|
*
|
|
16
|
-
* The browser
|
|
17
|
-
* questions — CORS says what a page may *read*, the
|
|
18
|
-
* this server agreed to *answer on* — but a deployment
|
|
19
|
-
* browser has named it once, and asking twice is asking for two
|
|
20
|
-
* disagree.
|
|
17
|
+
* The browser origins are the ones already declared, for CORS and for the web
|
|
18
|
+
* role. They answer different questions — CORS says what a page may *read*, the
|
|
19
|
+
* fence says which authority this server agreed to *answer on* — but a deployment
|
|
20
|
+
* that names its browser has named it once, and asking twice is asking for two
|
|
21
|
+
* answers that disagree.
|
|
21
22
|
*/
|
|
22
23
|
function createFence(): TrustFence | undefined {
|
|
23
24
|
if (!env.TRUSTED_HOSTS) return undefined;
|
|
24
|
-
const browserOrigin =
|
|
25
|
+
const browserOrigin = trustedBrowserAuthorities(env);
|
|
25
26
|
return createTrustFence({
|
|
26
27
|
trustedHosts: env.TRUSTED_HOSTS.split(',').map((entry) => entry.trim()),
|
|
27
28
|
...(browserOrigin.length > 0 && { trustedOrigins: browserOrigin }),
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { createTrustFence } from 'stitchkit/server';
|
|
3
|
+
import { trustedBrowserAuthorities } from './trusted-origins';
|
|
4
|
+
|
|
5
|
+
function proxied(origin: string): Request {
|
|
6
|
+
return new Request('http://127.0.0.1:3211/api/board', {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: { host: '127.0.0.1:3211', origin },
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('a fenced API role behind the web role', () => {
|
|
13
|
+
const fence = createTrustFence({
|
|
14
|
+
trustedHosts: ['127.0.0.1:3211'],
|
|
15
|
+
trustedOrigins: trustedBrowserAuthorities({
|
|
16
|
+
PUBLIC_WEB_HOSTS: 'app.example, www.app.example:8443',
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('admits a browser on an address the deployment claims', () => {
|
|
21
|
+
expect(fence.check(proxied('https://app.example'), 'http')).toBeUndefined();
|
|
22
|
+
expect(fence.check(proxied('https://www.app.example:8443'), 'http')).toBeUndefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('refuses a page anywhere else', () => {
|
|
26
|
+
expect(fence.check(proxied('https://evil.example'), 'http')?.reason).toBe(
|
|
27
|
+
'origin-mismatch',
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('names each declared host once', () => {
|
|
32
|
+
expect(
|
|
33
|
+
trustedBrowserAuthorities({
|
|
34
|
+
CORS_ORIGIN: 'https://app.example',
|
|
35
|
+
PUBLIC_WEB_ORIGIN: 'https://app.example',
|
|
36
|
+
PUBLIC_WEB_HOSTS: 'app.example,other.example',
|
|
37
|
+
}),
|
|
38
|
+
).toEqual(['app.example', 'other.example']);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser origins a fenced API role admits, all of them already declared.
|
|
3
|
+
*
|
|
4
|
+
* A browser on the web role's own address reaches this role through the `/api`
|
|
5
|
+
* forwarding, so its request arrives with that address as `Origin` and the
|
|
6
|
+
* internal one as `Host`. Those disagree by construction, and only the public
|
|
7
|
+
* hosts the deployment claims can tell it from a forged page.
|
|
8
|
+
*/
|
|
9
|
+
export function trustedBrowserAuthorities(env: {
|
|
10
|
+
CORS_ORIGIN?: string | undefined;
|
|
11
|
+
PUBLIC_WEB_ORIGIN?: string | undefined;
|
|
12
|
+
PUBLIC_WEB_HOSTS?: string | undefined;
|
|
13
|
+
}): string[] {
|
|
14
|
+
const authorities = [
|
|
15
|
+
...[env.CORS_ORIGIN, env.PUBLIC_WEB_ORIGIN].flatMap((origin) =>
|
|
16
|
+
origin ? [new URL(origin).host] : [],
|
|
17
|
+
),
|
|
18
|
+
...(env.PUBLIC_WEB_HOSTS ?? '').split(',').map((host) => host.trim()),
|
|
19
|
+
];
|
|
20
|
+
return [...new Set(authorities.filter((host) => host !== ''))];
|
|
21
|
+
}
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@t3-oss/env-core": "^0.13.11",
|
|
19
|
-
"dotenv": "^18.0.
|
|
19
|
+
"dotenv": "^18.0.9",
|
|
20
20
|
"stitchkit": "catalog:",
|
|
21
|
-
"zod": "^4.6.
|
|
21
|
+
"zod": "^4.6.7"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/bun": "^1.4.
|
|
24
|
+
"@types/bun": "^1.4.4",
|
|
25
25
|
"typescript": "^7.0.2"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `terminationBudgetMs` adds these to a role's drain floor and refuses a
|
|
5
5
|
* supervision policy that allows less. That only means something if each part
|
|
6
|
-
* is really bounded
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* could still be killed mid-shutdown by a timeout the generator had approved.
|
|
6
|
+
* is really bounded: MCP and database closes share a cleanup deadline after the
|
|
7
|
+
* drain. An unbounded close would turn the declared upper bound into an estimate
|
|
8
|
+
* and let the supervisor kill a role before its shutdown ends.
|
|
10
9
|
*
|
|
11
10
|
* They live here rather than in the generator because two readers need them and
|
|
12
11
|
* a number in two places is two numbers: the generator, which tells a
|
|
@@ -4,21 +4,33 @@ import { featureServerSchema } from './features';
|
|
|
4
4
|
/**
|
|
5
5
|
* Every environment variable this application reads, declared **once**.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* A fourth copy in the project declaration would have been worse still, so this
|
|
10
|
-
* module is the source and everything else is a projection of it:
|
|
7
|
+
* This module is the source; the server schema, frontend schema, tooling schema
|
|
8
|
+
* and project declaration are projections so their requirements cannot drift:
|
|
11
9
|
*
|
|
12
10
|
* - `server.ts` validates all of them for the API role;
|
|
13
11
|
* - `frontend/src/env.ts` projects the handful the web role reads;
|
|
14
|
-
* - `scripts/declaration.ts`
|
|
12
|
+
* - `scripts/declaration.ts` derives `env.variables` in `project.json` from
|
|
15
13
|
* here, so the declaration a deployment reads can never fall behind.
|
|
16
14
|
*
|
|
17
15
|
* Defaults, coercion and error messages live here and only here. The
|
|
18
16
|
* declaration carries names and shapes; it deliberately carries no values.
|
|
19
17
|
*/
|
|
18
|
+
/** The one reading of `SERVICE_SURFACES`, for both roles. */
|
|
19
|
+
export function serviceSurfacesAreOpen(env: {
|
|
20
|
+
NODE_ENV?: string | undefined;
|
|
21
|
+
SERVICE_SURFACES?: 'open' | 'closed' | undefined;
|
|
22
|
+
}): boolean {
|
|
23
|
+
return env.SERVICE_SURFACES ? env.SERVICE_SURFACES === 'open' : env.NODE_ENV !== 'production';
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
const baseVariables = {
|
|
21
27
|
NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
|
|
28
|
+
/**
|
|
29
|
+
* The component catalogue and `/openapi.json`: they describe how this
|
|
30
|
+
* application is built, so production answers 404 for them unless it says
|
|
31
|
+
* `open`, which is what a deployment under acceptance does.
|
|
32
|
+
*/
|
|
33
|
+
SERVICE_SURFACES: z.enum(['open', 'closed']).optional(),
|
|
22
34
|
DATABASE_URL: z.url(),
|
|
23
35
|
// Loopback by default — exposing the app to the network is an explicit
|
|
24
36
|
// opt-in (`BIND_HOST=0.0.0.0`), never something a forgotten edit causes.
|
|
@@ -86,7 +98,8 @@ const baseVariables = {
|
|
|
86
98
|
* and the realtime handshake, which never reaches a lifecycle hook on either
|
|
87
99
|
* runtime. Unset and there is no fence, which is honest for a local checkout
|
|
88
100
|
* and wrong for anything reachable from a network — a fence cannot invent the
|
|
89
|
-
* list of names it should answer to.
|
|
101
|
+
* list of names it should answer to. A browser reaching this role through the
|
|
102
|
+
* web role is admitted by its address in `PUBLIC_WEB_HOSTS` or `PUBLIC_WEB_ORIGIN`.
|
|
90
103
|
*/
|
|
91
104
|
TRUSTED_HOSTS: z.string().min(1).optional(),
|
|
92
105
|
};
|
|
@@ -96,9 +109,8 @@ const baseVariables = {
|
|
|
96
109
|
*
|
|
97
110
|
* A merge rather than a spread inside one literal, so an overlay can **tighten**
|
|
98
111
|
* a variable the base declares optional — not only add new ones. Without that,
|
|
99
|
-
* a
|
|
100
|
-
*
|
|
101
|
-
* the first render threw.
|
|
112
|
+
* a feature that requires a variable could not express that requirement, and
|
|
113
|
+
* the declaration would call it optional while the first render throws.
|
|
102
114
|
*/
|
|
103
115
|
export const applicationVariables = { ...baseVariables, ...featureServerSchema };
|
|
104
116
|
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@app/config": "workspace:*",
|
|
20
|
-
"@prisma/adapter-pg": "^7.10.
|
|
21
|
-
"@prisma/client": "^7.10.
|
|
22
|
-
"pg": "^8.23.
|
|
20
|
+
"@prisma/adapter-pg": "^7.10.1",
|
|
21
|
+
"@prisma/client": "^7.10.1",
|
|
22
|
+
"pg": "^8.23.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/pg": "^8.23.1",
|
|
26
|
-
"prisma": "^7.10.
|
|
26
|
+
"prisma": "^7.10.1",
|
|
27
27
|
"typescript": "^7.0.2"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import type { NextConfig } from 'next';
|
|
3
|
+
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants';
|
|
3
4
|
import createNextIntlPlugin from 'next-intl/plugin';
|
|
4
5
|
|
|
5
6
|
const config: NextConfig = {
|
|
@@ -16,4 +17,12 @@ const config: NextConfig = {
|
|
|
16
17
|
images: { remotePatterns: [] },
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* A `page.dev.tsx` exists for the development server alone, so what it imports
|
|
22
|
+
* is absent from a production build rather than guarded inside it.
|
|
23
|
+
*/
|
|
24
|
+
export default function nextConfig(phase: string): NextConfig {
|
|
25
|
+
const pageExtensions =
|
|
26
|
+
phase === PHASE_DEVELOPMENT_SERVER ? ['dev.tsx', 'tsx', 'ts'] : ['tsx', 'ts'];
|
|
27
|
+
return createNextIntlPlugin()({ ...config, pageExtensions });
|
|
28
|
+
}
|
|
@@ -13,49 +13,49 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@app/config": "workspace:*",
|
|
15
15
|
"@app/shared": "workspace:*",
|
|
16
|
-
"@radix-ui/react-alert-dialog": "^1.1
|
|
17
|
-
"@radix-ui/react-avatar": "^1.
|
|
18
|
-
"@radix-ui/react-checkbox": "^1.
|
|
19
|
-
"@radix-ui/react-dialog": "^1.1
|
|
20
|
-
"@radix-ui/react-dropdown-menu": "^2.1
|
|
21
|
-
"@radix-ui/react-select": "^2.
|
|
22
|
-
"@radix-ui/react-slider": "^1.
|
|
23
|
-
"@radix-ui/react-slot": "^1.
|
|
24
|
-
"@radix-ui/react-switch": "^1.
|
|
25
|
-
"@radix-ui/react-tabs": "^1.1
|
|
26
|
-
"@radix-ui/react-tooltip": "^1.
|
|
16
|
+
"@radix-ui/react-alert-dialog": "^1.2.1",
|
|
17
|
+
"@radix-ui/react-avatar": "^1.3.1",
|
|
18
|
+
"@radix-ui/react-checkbox": "^1.4.1",
|
|
19
|
+
"@radix-ui/react-dialog": "^1.3.1",
|
|
20
|
+
"@radix-ui/react-dropdown-menu": "^2.2.1",
|
|
21
|
+
"@radix-ui/react-select": "^2.4.1",
|
|
22
|
+
"@radix-ui/react-slider": "^1.6.1",
|
|
23
|
+
"@radix-ui/react-slot": "^1.5.0",
|
|
24
|
+
"@radix-ui/react-switch": "^1.4.1",
|
|
25
|
+
"@radix-ui/react-tabs": "^1.2.1",
|
|
26
|
+
"@radix-ui/react-tooltip": "^1.4.1",
|
|
27
27
|
"@t3-oss/env-nextjs": "^0.13.11",
|
|
28
|
-
"@tabler/icons-react": "^3.
|
|
29
|
-
"@tanstack/react-query": "^5.
|
|
30
|
-
"@tanstack/react-table": "^9.
|
|
31
|
-
"@wrksz/themes": "^1.
|
|
28
|
+
"@tabler/icons-react": "^3.50.0",
|
|
29
|
+
"@tanstack/react-query": "^5.105.3",
|
|
30
|
+
"@tanstack/react-table": "^9.3.1",
|
|
31
|
+
"@wrksz/themes": "^2.1.1",
|
|
32
32
|
"class-variance-authority": "^0.7.1",
|
|
33
33
|
"clsx": "^2.1.1",
|
|
34
34
|
"date-fns": "^4.4.0",
|
|
35
|
-
"dotenv": "^18.0.
|
|
36
|
-
"framer-motion": "^
|
|
37
|
-
"next": "^16.
|
|
38
|
-
"next-intl": "^4.14.
|
|
39
|
-
"react": "^19.3.
|
|
40
|
-
"react-dom": "^19.3.
|
|
41
|
-
"react-query-kit": "^3.
|
|
35
|
+
"dotenv": "^18.0.9",
|
|
36
|
+
"framer-motion": "^14.9.1",
|
|
37
|
+
"next": "^16.4.5",
|
|
38
|
+
"next-intl": "^4.14.9",
|
|
39
|
+
"react": "^19.3.1",
|
|
40
|
+
"react-dom": "^19.3.1",
|
|
41
|
+
"react-query-kit": "^3.4.0",
|
|
42
42
|
"recharts": "^3.10.1",
|
|
43
|
-
"shiki": "^4.
|
|
44
|
-
"socket.io-client": "^4.8.
|
|
43
|
+
"shiki": "^4.6.0",
|
|
44
|
+
"socket.io-client": "^4.8.4",
|
|
45
45
|
"sonner": "^2.0.8",
|
|
46
46
|
"stitchkit": "catalog:",
|
|
47
47
|
"tailwind-merge": "^3.7.0",
|
|
48
48
|
"vaul": "^1.1.2",
|
|
49
|
-
"zod": "^4.6.
|
|
49
|
+
"zod": "^4.6.7"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@tailwindcss/postcss": "^4.3.
|
|
53
|
-
"@types/bun": "^1.4.
|
|
54
|
-
"@types/node": "^26.6.
|
|
52
|
+
"@tailwindcss/postcss": "^4.3.4",
|
|
53
|
+
"@types/bun": "^1.4.4",
|
|
54
|
+
"@types/node": "^26.6.6",
|
|
55
55
|
"@types/react": "^19.3.0",
|
|
56
56
|
"@types/react-dom": "^19.3.0",
|
|
57
57
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
58
|
-
"tailwindcss": "^4.3.
|
|
58
|
+
"tailwindcss": "^4.3.4",
|
|
59
59
|
"tw-animate-css": "^1.4.0",
|
|
60
60
|
"typescript": "^7.0.2"
|
|
61
61
|
}
|
|
@@ -17,8 +17,8 @@ import { env } from '../src/env';
|
|
|
17
17
|
/**
|
|
18
18
|
* The run mode, fail-closed.
|
|
19
19
|
*
|
|
20
|
-
* `argv[2] === 'development' ? 'dev' : 'start'`
|
|
21
|
-
* and a missing argument
|
|
20
|
+
* `argv[2] === 'development' ? 'dev' : 'start'` would turn a typo, an empty string
|
|
21
|
+
* and a missing argument into production. A wrong mode is not a
|
|
22
22
|
* detail — it decides whether the role serves a build or compiles on demand —
|
|
23
23
|
* and the supervision files pass it explicitly, so anything else is a mistake
|
|
24
24
|
* worth seeing.
|
|
@@ -60,8 +60,8 @@ const code = await child.exited;
|
|
|
60
60
|
* A stop that was ASKED for is a success — but only for the codes a stop
|
|
61
61
|
* actually produces.
|
|
62
62
|
*
|
|
63
|
-
* `stopping ? 0 : code`
|
|
64
|
-
*
|
|
63
|
+
* `stopping ? 0 : code` would report success for any exit during shutdown and
|
|
64
|
+
* hide a crash during drain. Next
|
|
65
65
|
* exits 130 on SIGINT and 143 on SIGTERM, and reporting those upward would make
|
|
66
66
|
* every ordinary supervised stop look like a failure; anything else during a
|
|
67
67
|
* shutdown is a real failure and keeps its code.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { notFound } from 'next/navigation';
|
|
2
|
+
import { sectionAt } from '@/features/admin/admin-sections';
|
|
3
|
+
import { AdminWorkspace } from '@/features/admin/admin-workspace';
|
|
4
|
+
import { adminFixture } from '@/features/admin/fixture/admin-fixture';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `.dev.tsx` is a page extension of the development server only (`next.config.ts`),
|
|
8
|
+
* so a production build has no such route and nothing here enters its graph.
|
|
9
|
+
* `scripts/fixture-boundary.ts` proves that on the built files. Once a section
|
|
10
|
+
* reads the API, name this file `page.tsx` and drop the fixture import.
|
|
11
|
+
*/
|
|
12
|
+
export default async function AdminPage({
|
|
13
|
+
params,
|
|
14
|
+
}: {
|
|
15
|
+
params: Promise<{ section?: string[] }>;
|
|
16
|
+
}) {
|
|
17
|
+
const { section: segments = [] } = await params;
|
|
18
|
+
const section = segments.length > 1 ? undefined : sectionAt(segments[0]);
|
|
19
|
+
if (!section) notFound();
|
|
20
|
+
return <AdminWorkspace section={section} data={adminFixture} />;
|
|
21
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appIdentity } from '@app/config/app-identity';
|
|
2
2
|
import type { Metadata } from 'next';
|
|
3
3
|
import { getTranslations } from 'next-intl/server';
|
|
4
|
-
import { env } from '@/env';
|
|
4
|
+
import { catalogueIsOpen, env } from '@/env';
|
|
5
5
|
import { LocaleSchema } from '@/i18n/locales';
|
|
6
6
|
import { createPageMetadata } from '@/lib/seo/metadata';
|
|
7
7
|
import { StarterPage } from './starter-page';
|
|
@@ -28,6 +28,7 @@ export default async function Page({ params }: { params: Promise<{ locale: strin
|
|
|
28
28
|
applicationDescription={appIdentity.description[appLocale]}
|
|
29
29
|
heroTitle={t('heroTitle')}
|
|
30
30
|
catalogueLabel={t('ui')}
|
|
31
|
+
catalogueOpen={catalogueIsOpen()}
|
|
31
32
|
locale={appLocale}
|
|
32
33
|
realtimeOrigin={env.PUBLIC_REALTIME_ORIGIN}
|
|
33
34
|
/>
|
|
@@ -15,6 +15,7 @@ interface StarterPageProps {
|
|
|
15
15
|
applicationDescription: string;
|
|
16
16
|
heroTitle: string;
|
|
17
17
|
catalogueLabel: string;
|
|
18
|
+
catalogueOpen: boolean;
|
|
18
19
|
realtimeOrigin?: string;
|
|
19
20
|
locale: AppLocale;
|
|
20
21
|
}
|
|
@@ -63,6 +64,7 @@ export async function StarterPage({
|
|
|
63
64
|
applicationDescription,
|
|
64
65
|
heroTitle,
|
|
65
66
|
catalogueLabel,
|
|
67
|
+
catalogueOpen,
|
|
66
68
|
realtimeOrigin,
|
|
67
69
|
locale,
|
|
68
70
|
}: StarterPageProps) {
|
|
@@ -89,14 +91,16 @@ export async function StarterPage({
|
|
|
89
91
|
<div className='flex items-center gap-2'>
|
|
90
92
|
<LanguageSwitcher />
|
|
91
93
|
<ThemeToggle />
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
{catalogueOpen ? (
|
|
95
|
+
<Link
|
|
96
|
+
aria-label={catalogueLabel}
|
|
97
|
+
className={cn(buttonVariants({ variant: 'outline', size: 'sm' }))}
|
|
98
|
+
href='/ui'
|
|
99
|
+
>
|
|
100
|
+
<span className='hidden sm:inline'>{catalogueLabel}</span>
|
|
101
|
+
<IconArrowUpRight />
|
|
102
|
+
</Link>
|
|
103
|
+
) : null}
|
|
100
104
|
</div>
|
|
101
105
|
</header>
|
|
102
106
|
|