Skip to content

fix(nextjs-template): flow-aware degradation + api-<sub> endpoint + scoped tsconfig#25

Draft
yyyyaaa wants to merge 1 commit into
mainfrom
feat/blocks
Draft

fix(nextjs-template): flow-aware degradation + api-<sub> endpoint + scoped tsconfig#25
yyyyaaa wants to merge 1 commit into
mainfrom
feat/blocks

Conversation

@yyyyaaa
Copy link
Copy Markdown
Contributor

@yyyyaaa yyyyaaa commented Jun 2, 2026

What

Makes the nextjs/constructive-app template scaffold cleanly when consuming Constructive Blocks under a minimal auth preset — the template half of the cross-repo Blocks effort (library/docs constructive-io/dashboard#227, skill constructive-skills, harness constructive-sdk-agentic-flow).

Contents (single commit 0c064ff)

  • Flow-aware admin-compat degradation — the template hard-imports org/invite/member admin-SDK ops that don't exist under the auth:email preset, hard-failing tsc+next build out of the box. A compat shim lets the scaffold compile under both auth:email and b2b.
  • App data endpoint → api-<sub> — point codegen + runtime at api-<sub> (with a CODEGEN_APP_HOST seam) instead of the dead app-public-<sub> Host.
  • Scoped tsconfig — so next build type-checks the app, not unrelated sibling workspace packages.

Status

Draft / WIP. Unblocks the Blocks on-ramp scaffold; in repeated harness runs 8–10 of every fleet's agents hand-wrote these same fixes, so landing them in the template removes that per-build friction. Follow-up: harden the b2b-import degradation (the compat shim currently lives inside the codegen-regenerated dir and must be re-applied after pnpm codegen).

🤖 Generated with Claude Code

… + scoped tsconfig

Make a freshly-scaffolded constructive-app green-build for a minimal auth:email
flow with NO manual stubbing, while keeping the b2b org surface fully functional
when the admin SDK has it.

F1 — degrade org/invite/members/settings when the admin SDK lacks Org*/Invite*:
- Add src/lib/gql/admin-compat.ts: re-exports @sdk/admin and, for each symbol that
  exists only in the b2b admin SDK, exports a value that resolves to the REAL
  export when present (sdk[name] ?? stub). Lives outside src/graphql/sdk so codegen
  (which wipes the generated SDK dirs) never clobbers it.
    - auth:email build → org/invite symbols absent → typed stubs keep the dead
      template code type-checking; they are never on the runtime path and throw
      loudly if invoked.
    - b2b build → symbols present → genuine hooks/fns are used at runtime.
- Repoint the 13 org/invite/app hook + members-route imports of the 23 at-risk
  symbols from @sdk/admin to @/lib/gql/admin-compat.
- Annotate 5 derived id arrays as string[] so the where:{id:{in:…}} sites stay
  typed when the upstream fetch degrades to any (no-op cast on the b2b path).
- Verified by overlaying the full template src against BOTH a real auth:email SDK
  (org symbols absent) and a real b2b/org-roles SDK (org symbols present):
  tsc --noEmit = 0 errors in both.

F2 (template half) — app DATA endpoint is api-<sub>, not app-public-<sub>:
- graphql-codegen.config.ts: the app target Host now honors CODEGEN_APP_HOST and
  defaults to api-{db}.localhost:3000; endpoint + Host header stay in sync (Host
  drives routing, so a URL-only override still 404s). admin/auth gain matching
  CODEGEN_*_HOST overrides.
- config-core.ts getAppEndpoint(): default resolves to http://api-{db}.localhost,
  still overridable via NEXT_PUBLIC_APP_ENDPOINT.

F11 — scope tsconfig:
- include limited to src/** (+ Next types); add "packages" to exclude so the
  provision sub-package isn't greedily compiled by the app's tsc --noEmit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant