Repository navigation
feat(kody): seed the headless-api starter #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,58 @@ | ||
| # Go-day deltas — headless-api | ||
|
|
||
| Everything in this package is built and **locally validated** (real Postgres, | ||
| `scripts/local-smoke.mts` → SMOKE PASS) against the workspace packages. What | ||
| remains is only what requires the external blockers to clear. | ||
| Built and validated two ways: (1) node + real Postgres via | ||
| `scripts/local-smoke.mts` → SMOKE PASS (CMS logic, auth, governance, jobs); | ||
| (2) **`kody dev` (local workerd)** — see "What kody dev proved" below. | ||
|
|
||
| ## What `kody dev` already proved (local workerd, no publish) | ||
|
|
||
| - ✅ **The CMS graph bundles and boots under workerd** (same esbuild path as | ||
| publish). The `{ fetch }` entry loads and the CMS API handler serves — `GET /` | ||
| returns the CMS's own `404 {"code":"NOT_FOUND"}`. | ||
| - ✅ **`kody.jobs` manifest schema confirmed** (kody dev validated it): | ||
| `"schedule": { "type": "interval", "every": "5m" }` (or | ||
| `{ "type": "cron", "expression": "<5-field>" }`), `entry: | ||
| "./src/jobs.ts#<fn>"`. A bare cron string and `schedule.type: "once"` are | ||
| rejected. | ||
| - ⚠️ **U2 answer (local):** the first DB-touching request fails under workerd | ||
| with **`Error: No such module "pg"`** during `migrateTo`. The stock `pg` | ||
| driver does not load under Kody workerd. Everything upstream of the DB works. | ||
|
|
||
| ## Must run `kody dev` from a STANDALONE checkout | ||
|
|
||
| `kody dev` snapshots the package via its git repo. Run inside this monorepo it | ||
| fails with `Package bundle target(s) missing from the repo session snapshot: | ||
| src/jobs.ts#...` — a **nesting artifact, not a real error**. In a standalone | ||
| git repo (how the go-day git lane works) the same files build cleanly. For local | ||
| iteration, copy the package to its own dir + `git init` (see the scratch at | ||
| `/tmp/kody-standalone` used during the spike), with `node_modules/@tanstack/*` | ||
| symlinked to the workspace packages and `node_modules/pg` to the pnpm store. | ||
|
|
||
| ## Blocked until the Preview builds land | ||
|
|
||
| 1. **Pin dependency URLs.** Replace `@REF` in `package.json` for the four | ||
| `@tanstack/cms-*` deps with the pkg-pr-new refs the Preview CI job reports | ||
| (spec §7-1). `pg` stays an npm dep. | ||
| `@tanstack/cms-*` deps with the pkg-pr-new refs. `pg` stays declared. | ||
|
|
||
| ## Blocked on Kody (App install + `package:write` in the tanstack org) | ||
|
|
||
| 2. **Publish via the git lane** (D3): `packageGetGitRemote({ create: true, | ||
| name: '@tanstack/cms-starter-headless-api' })` → clone → copy this package in | ||
| → push → `packagePublishExternalPush`. If it returns `locked`, open the | ||
| `approval_url`. | ||
| 3. **Set the `CMS_DATABASE_URL` package secret** to the prod Postgres string. | ||
| 4. **Resolve U1 (secret accessor).** Fill `src/secrets.ts#getDatabaseUrl` with | ||
| the synchronous `kody:runtime` package-secret read. Confirm whether the value | ||
| is available synchronously at module scope; if only request-scoped, capture | ||
| it into the module cache on the first request (the resolver is sync by | ||
| design — store types.ts:85). | ||
| 5. **Confirm `kody.jobs` field schema** via `repoRunChecks` (the manifest | ||
| validator). Current best-effort shape: `{ entry: "./src/jobs.ts#<fn>", | ||
| schedule: "*/5 * * * *" }`. | ||
| 6. **Run U2 test** (spec §7-5): the first REST call on the published app is the | ||
| pg-over-workerd-TCP test. If egress fails, swap the pool for Neon's serverless | ||
| driver — config-side only (`PgPoolLike` is a structural interface). | ||
| 2. **Resolve U2 — swap `pg` for a workerd-native driver.** Confirmed required | ||
| (above). Use Neon's serverless driver behind the store's `PgPoolLike` | ||
| interface — config-side only, no store-postgres change (the store types the | ||
| pool structurally). Then re-run `kody dev` against a reachable Postgres and | ||
| confirm a DB-backed request + a job succeed. | ||
| 3. **Resolve U1 — secret accessor.** Fill `src/secrets.ts#getDatabaseUrl` with a | ||
| synchronous `kody:runtime` package-secret read. NB under `kody dev --target | ||
| mock` package secrets are **placeholders** by design, so a real DB URL can't | ||
| flow through them locally — test U1 against the published app or with a | ||
| `.kody/mocks.ts`-style stand-in. | ||
| 4. **Publish via the git lane** (D3) and set the `CMS_DATABASE_URL` package | ||
| secret. | ||
| 5. **Public read for §8.** Grant anonymous read on `contentItem` so the seeded | ||
| doc is readable over REST with no `x-cms-role` header (the `seed` itself is | ||
| in place and validated). | ||
|
|
||
| ## Post-publish acceptance (spec §8) | ||
|
|
||
| `appFetch` (`synthetic: true`): seeded doc readable over REST with no auth; | ||
| `x-cms-role` write succeeds and is attributed; MCP tool list answers; a second | ||
| package importing `@tanstack/cms-client` reads the same document. | ||
|
|
||
| > Note: the §8 "seeded document readable with **no auth**" check needs a seed + | ||
| > public read access — not yet added here (the smoke uses authenticated writes). | ||
| > Add a small `seed` and confirm anonymous read on go-day. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { SeedStore } from '@tanstack/cms-core' | ||
|
|
||
| // Content written on first run against an empty store, so a freshly-published | ||
| // app isn't empty (spec §8). Published so it is live immediately. Public (no | ||
| // auth) read access is still a go-day item — see GO-DAY.md. | ||
| export const seed: SeedStore = { | ||
| documents: { | ||
| contentItem: { | ||
| welcome: { | ||
| title: 'Welcome', | ||
| slug: 'welcome', | ||
| channel: 'web', | ||
| priority: 1, | ||
| body: 'This headless CMS serves one schema over REST, a typed client, and MCP.', | ||
| published: true, | ||
| }, | ||
| }, | ||
| }, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the database endpoint prerequisite for the Neon driver.
If the database is ordinary Postgres, replacing
pgalone does not enable the requested workerd validation. Neon's driver requires a WebSocket proxy for non-Neon Postgres. A reachable TCP endpoint is not sufficient. Require either a Neon endpoint or a configured proxy before the DB-backed request and job checks. (github.com)