Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ai/context/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ anyone's real domain). Nothing that uses the domain was removed; it waits:
| `apps/api-edge/wrangler.template.jsonc` | `CONSOLE_CUSTOM_DOMAIN`, the console origin CORS allows besides the workers.dev one |
| `apps/identity-worker/wrangler.template.jsonc` | `OAUTH_ALLOWED_CONSOLE_ORIGINS`, which lists the workers.dev console and CMS too, so sign-in works without a domain |
| `apps/notifications-worker/wrangler.template.jsonc` | `EMAIL_FROM_ADDRESS`, `no-reply@mail.lumen-payload.example.com` |
| `apps/billing-worker/wrangler.template.jsonc` | `POLAR_SUCCESS_URL`, the fallback return after checkout |
| `tests/api-edge` | the CORS fixtures, which follow the edge's config |

To set it, in one PR:
Expand Down
11 changes: 6 additions & 5 deletions apps/billing-worker/wrangler.template.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
// wrangler secret put POLAR_ACCESS_TOKEN --env <env>
// wrangler secret put POLAR_WEBHOOK_SECRET --env <env>
// - POLAR_PRODUCT_MAP (plan code → Polar product id) is set per env.
// - POLAR_SUCCESS_URL is the FALLBACK post-checkout return (console root) for
// callers that don't supply embedOrigin+returnPath; the console always does,
// so the buyer normally returns to its own billing page.
// - POLAR_SUCCESS_URL is the FALLBACK post-checkout return for callers that
// don't supply embedOrigin+returnPath: the CMS's Billing & plan page (the
// CMS is the console, lumen-payload-console PX4). The CMS always supplies
// both, so the buyer normally returns there anyway.
"vars": {
"ENVIRONMENT": "local",
"BILLING_PROVIDER": "polar",
Expand All @@ -41,7 +42,7 @@
"BILLING_PROVIDER": "polar",
"POLAR_SERVER": "sandbox",
"POLAR_PRODUCT_MAP": "{\"pro\":\"c3e33c12-1ec6-4843-aed1-10b21c6fcb4f\",\"business\":\"aefd7468-6f9f-4ebc-b373-31c852b9842a\"}",
"POLAR_SUCCESS_URL": "https://stage.lumen-payload.example.com/"
"POLAR_SUCCESS_URL": "https://lumen-payload-cms-stage.nexo-7be.workers.dev/admin/organization/billing?checkout=complete"
},
"hyperdrive": [
{
Expand All @@ -67,7 +68,7 @@
"BILLING_PROVIDER": "polar",
"POLAR_SERVER": "production",
"POLAR_PRODUCT_MAP": "{\"pro\":\"c711fc4c-74e2-47f5-991e-b940df833899\",\"business\":\"e2ba3e96-b97a-4348-82ef-87bcebad1d17\"}",
"POLAR_SUCCESS_URL": "https://prod.lumen-payload.example.com/"
"POLAR_SUCCESS_URL": "https://lumen-payload-cms-prod.nexo-7be.workers.dev/admin/organization/billing?checkout=complete"
},
"hyperdrive": [
{
Expand Down
5 changes: 3 additions & 2 deletions apps/cms/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ into `.open-next/worker.js` plus `.open-next/assets`, deployed by the
itself, so the composition's `wrangler deploy` ships the whole build.

```
browser ──► lumen-payload-cms-<env> (Worker)
/admin Payload admin (React, server components)
browser ──► lumen-payload-cms-<env> (Worker) ◄──308── lumen-payload-web-console-next-<env> (the old console URL)
/ 308 → /admin
/admin Payload admin (React, server components): the product's console
/api/<collection> REST ┐
/api/graphql GraphQL ├─ payload ─► HYPERDRIVE_CMS ─► Supabase Postgres, schema cms
/health liveness + db ┘ │ (cache disabled)
Expand Down
2 changes: 1 addition & 1 deletion apps/cms/docs/overview.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cms

Payload CMS on Cloudflare Workers: the admin panel at `/admin`, the REST API
Payload CMS on Cloudflare Workers, and the product's console: the admin panel at `/admin` (`/` and the old console URL open it), the REST API
at `/api/<collection>` and GraphQL at `/api/graphql`, over Postgres schema
`cms`, deployed beside the fleet as `lumen-payload-cms-<env>`.

Expand Down
4 changes: 4 additions & 0 deletions apps/cms/src/app/(payload)/admin/importMap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/cms/src/app/(site)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ReactNode } from 'react'

export const metadata = { title: 'Lumen Payload — CMS' }
export const metadata = { title: 'Lumen Payload' }

export default function SiteLayout({ children }: { children: ReactNode }) {
return (
Expand Down
19 changes: 6 additions & 13 deletions apps/cms/src/app/(site)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { redirect } from 'next/navigation'

export const dynamic = 'force-dynamic'

// The CMS's own front door. Products built on this baseline read content from
// /api (REST) or /api/graphql; editors work in /admin.
export default function Home() {
return (
<main style={{ maxWidth: 640, margin: '4rem auto', padding: '0 1rem', lineHeight: 1.6 }}>
<h1>Lumen Payload CMS</h1>
<p>
Editors sign in at <a href="/admin">/admin</a>. Published content is served from{' '}
<code>/api/pages</code>, <code>/api/posts</code> and <code>/api/categories</code>, and over
GraphQL at <code>/api/graphql</code>.
</p>
</main>
)
// The product's front door is the admin (lumen-payload-console design §5).
// Content is still served from /api and /api/graphql.
export default function Home(): never {
redirect('/admin')
}
31 changes: 31 additions & 0 deletions apps/cms/src/components/admin/Brand.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// The product's mark in the admin (lumen-payload-console design §5): the name
// from .rebrand/values.json ("Lumen Payload") beside a simple glyph, drawn in
// the admin's own text colour so it follows the light and dark themes.

function Glyph({ size }: { size: number }) {
return (
<svg width={size} height={size} viewBox="0 0 24 24" aria-hidden="true" fill="none">
<circle cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="2" />
<path d="M8 6.5v11h8" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" />
</svg>
)
}

/** The sign-in and loading screens' logo. */
export function Logo() {
return (
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 10, color: 'var(--theme-text)', fontSize: 22, fontWeight: 600 }}>
<Glyph size={30} />
Lumen Payload
</span>
)
}

/** The nav's icon. */
export function Icon() {
return (
<span style={{ color: 'var(--theme-text)', display: 'inline-flex' }} title="Lumen Payload">
<Glyph size={24} />
</span>
)
}
20 changes: 13 additions & 7 deletions apps/cms/src/components/admin/LumenLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { redirect } from 'next/navigation'

import { safeAdminRedirect } from '../../lib/lumen/cookies'
import { lumenPublicApiUrl } from '../../lib/lumen/transport'
import { Logo } from './Brand'
import { LumenSignIn } from './LumenSignIn'

const first = (value: string | string[] | undefined): string | null => (typeof value === 'string' ? value : null)
Expand All @@ -13,12 +14,17 @@ export async function LumenLogin({ initPageResult, searchParams }: AdminViewServ
const target = safeAdminRedirect(first(searchParams?.redirect))
if (initPageResult.req.user) redirect(target)
return (
<LumenSignIn
apiUrl={lumenPublicApiUrl()}
redirect={target}
error={first(searchParams?.error)}
signedOut={first(searchParams?.signedOut) === '1'}
productName="Lumen Payload"
/>
<>
<div style={{ marginBottom: 'calc(var(--base) * 1.5)' }}>
<Logo />
</div>
<LumenSignIn
apiUrl={lumenPublicApiUrl()}
redirect={target}
error={first(searchParams?.error)}
signedOut={first(searchParams?.signedOut) === '1'}
productName="Lumen Payload"
/>
</>
)
}
3 changes: 2 additions & 1 deletion apps/cms/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ export default buildConfig({
admin: {
user: Users.slug,
importMap: { baseDir: path.resolve(dirname) },
meta: { titleSuffix: ' — CMS' },
meta: { titleSuffix: ' — Lumen Payload' },
// Lumen sign-in replaces Payload's password views (lumen-payload-console
// design §1, §3): Payload's local strategy is off on `users`.
components: {
// The Lumen account pages (design §4): Payload's account view becomes
// the Lumen profile, and the rest are custom views under an Account
// group in the nav.
afterNavLinks: ['/components/admin/account/AccountNav#AccountNav'],
graphics: { Logo: '/components/admin/Brand#Logo', Icon: '/components/admin/Brand#Icon' },
views: {
login: { Component: '/components/admin/LumenLogin#LumenLogin' },
unauthorized: { Component: '/components/admin/PendingAccess#PendingAccess' },
Expand Down
14 changes: 2 additions & 12 deletions apps/web-console-next/.gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# Next.js build output
.next/
out/

# OpenNext / @opennextjs/cloudflare build output
.open-next/

# Local env files
.env*.local
# Build output
dist/

# Wrangler local state
.wrangler/

# TS build info
*.tsbuildinfo
114 changes: 16 additions & 98 deletions apps/web-console-next/README.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,16 @@
# @saas/web-console-next

Next.js 15 + [opennextjs/cloudflare](https://github.com/opennextjs/opennextjs-cloudflare) delivery of the Lumen Payload web console.

Wired against the same `@saas/contracts` typed envelope as `apps/web-console`,
deployed via the same `cloudflare-pages-turbo` orun composition (with
`outputDir: .open-next/assets` instead of `dist/`).

## Scripts

```bash
pnpm -F @saas/web-console-next dev # next dev on :3001
pnpm -F @saas/web-console-next typecheck # tsc --noEmit
pnpm -F @saas/web-console-next lint # eslint
pnpm -F @saas/web-console-next build # next build (standalone) + opennextjs-cloudflare build
```

The `build` script runs Next's standalone build (configured via
`output: "standalone"` + `outputFileTracingRoot` in `next.config.mjs`) and
then invokes `opennextjs-cloudflare build --skipBuild
--skipWranglerConfigCheck`, which reads `.next/standalone/**` and emits the
Cloudflare Pages-compatible bundle into `.open-next/`:

- `.open-next/assets/**` — static assets the `cloudflare-pages-turbo`
orun component publishes (matches `outputDir` in `component.yaml`).
- `.open-next/worker.js` — Pages Function entrypoint, referenced from
`wrangler.jsonc#main`.

`open-next.config.ts` keeps the in-memory `dummy` overrides for the
incremental cache / tag cache / queue — this app has no R2/KV/D1 bindings
and runs fully session-authenticated, so no persistent caching layer is
needed.

## Parity vs. apps/web-console

| Surface | web-console (Vite) | web-console-next (Next 15) |
|-----------------------------|--------------------|----------------------------|
| Login (email-code) | ✅ inline form | ✅ Zod form + tabs |
| Login (bearer token paste) | ✅ | ✅ |
| Org listing | ✅ | ✅ card grid |
| Create organization | ✅ | ✅ Zod dialog form |
| Projects list | ✅ | ✅ card grid + status |
| Create project | ✅ | ✅ Zod dialog form |
| Members list | ✅ | ✅ table + role badges |
| Remove member | ✅ | ✅ |
| Invitations list | ✅ | ✅ table + status badges |
| Create invitation | ✅ | ✅ Zod dialog form (role enum) |
| Revoke invitation | ✅ | ✅ |
| API keys list | ✅ | ✅ table |
| Create API key + one-time secret reveal | ✅ | ✅ reveal modal + copy |
| Revoke API key | ✅ | ✅ |
| Environments list | ✅ | ✅ card grid |
| Create environment | ✅ | ✅ Zod dialog form |
| Environment detail | (basic) | ✅ identity card |
| Audit log | ✅ | ✅ category filter |
| Billing (plan/ents/invoices)| ✅ | ✅ + precondition_failed UX|
| Config / org identifiers | partial | ✅ |
| Target switching | ✅ | ✅ (sidebar + palette) |
| Dark mode | ❌ | ✅ next-themes (default) |
| Empty states + skeletons | minimal | ✅ across every list |
| Cmd-K command palette | ❌ | ✅ |
| URL-driven scope | sessionStorage | ✅ `useParams` |
| Designed precondition_failed UX | ❌ | ✅ four reason-coded shapes|

## Notable design choices

- **Tailwind 3.4 + Next 15.0 stable** rather than Tailwind v4-beta + Next 15 alpha (risk reduction).
- **Design system co-located** in `src/components/ui/`; promoting to `packages/ui` is a future task.
- **URL is the source of truth for scope**: `/orgs/[orgSlug]/projects/[projectSlug]/environments/[envSlug]`. We never cache scope in storage so cross-tab tenant isolation is enforced.
- **Per-target `ApiClient` instance** constructed by `SessionProvider`, not a module singleton.
- **Error envelope preserves `meta.requestId`** on the failure branch so `PreconditionInsight` can always surface request IDs.
- **`NEXT_PUBLIC_DEPLOY_ENV`** mirrors the old `VITE_DEPLOY_ENV` build-time lock — when set, the target switcher is hidden.
- **`/demo`** is a token-free showcase route used for verifier screenshots.
- **`ZodForm`** is the canonical contracts→form proof: a single Zod schema feeds validation, types, and the rendered fields.

## Designed `precondition_failed` UX

Reason codes (per `ai/context/current.md`):

- `limit_reached` — entitlement quota exhausted; offer upgrade.
- `disabled` — feature exists on a higher plan; offer upgrade.
- `not_configured` — no entitlement record; offer "talk to sales".
- `malformed_limit` — defensive; surfaces request ID for support escalation.

All four shapes are rendered on `/demo` for screenshot evidence.

## Deployment

Identical orun composition pattern to `apps/web-console`:

- `spec.type: cloudflare-pages-turbo`
- `outputDir: .open-next/assets` (opennextjs/cloudflare output)
- `environmentBuildVar: NEXT_PUBLIC_DEPLOY_ENV` (was `VITE_DEPLOY_ENV`)
- Per-env Cloudflare Pages projects: `lumen-payload-web-console-next-{dev,stage,prod}`
- Smoke probe identical to the existing console.

Verification is via the same `verify`/`deploy` profile split, so this app
fits cleanly into the existing platform pipeline.
# web-console-next — retired to a redirect

This was the Lumen Payload web console (Next.js on Workers). The console is
now the **Payload admin** (`apps/cms`, specs/epics/lumen-payload-console), and
this component keeps only the old URL alive:
`lumen-payload-web-console-next-<env>.nexo-7be.workers.dev` answers every
request with a `308` to the same page's place in the CMS of the same
environment, so bookmarks, old links and old OAuth returns land in Payload.

The console's UI, its models and its tests were removed in PX4. The models
the admin still uses were copied into `apps/cms/src/lib/lumen/models/` with
their tests; the rest is in git history.

- [Overview](docs/overview.md)
- [Architecture](docs/architecture.md)
- [Runbook](docs/runbook.md)
Loading
Loading