Skip to content

feat: switch the data layer and auth exchange to the ATK API, retire auth-function - #2

Merged
JasonPaff merged 1 commit into
mainfrom
feat/api-data-layer
Sep 11, 2026
Merged

JasonPaff merged 1 commit into
mainfrom
feat/api-data-layer

Conversation

@JasonPaff

Copy link
Copy Markdown
Collaborator

Step 4 of the ATK API-first plan (docs/Direction.md in the monorepo): the web app's data layer and auth exchange move from GitHub to the ATK API, and auth-function is retired. Hard switch, no fallback.

What changed

  • Client: @hey-api/openapi-ts 0.99.0 generates src/lib/api/ from the vendored openapi/openapi.json (pnpm refresh-openapi, pnpm generate-api). src/lib/api-client.ts owns VITE_ATK_API_URL, bearer auth, retries, and error mapping (ApiRequestError with code / status / details).
  • Auth: POST /auth/github/exchange replaces the auth-function; SessionProvider verifies with GET /me (401 → signed-out, 403 not_org_member / org_membership_unverifiable → non-member). useSession().api replaces octokit; @octokit/rest is removed.
  • Reads: /registry, /assets/{type}/{name}/{version}/manifest|readme|files, /bundles/{name}/{version}/manifest, all ?org= scoped. The Files card now shows the API's directory listing (new useAssetFiles hook; useManifestGraph also lists files per dependency).
  • Downloads: one request to …/download?format=zip|skill; JSZip zip-building deleted (JSZip stays for the Contribute .skill upload).
  • Publish: POST /publish with client: "web", POST /publish/plan for ?dryRun=1. 409 branch_existsPublishBranchCollisionError; 409 version_*PublishVersionConflictError; 400 validation_failed|schema_invalidPublishValidationError whose details[] render on the review step. CreateBundle gains an Org field so org bundles carry org in bundle.json.
  • Retired: auth-function/, deploy-auth-function.yml, and the auth-function steps in validate.yml / deploy-pages.yml. The Pages build now reads vars.VITE_ATK_API_URL.
  • Docs: docs/deployment.md, docs/OAUTH_APP_SETUP.md, PROJECT_OVERVIEW.md describe the API-based setup and the real repo-variable names.

Verification

  • pnpm lint && pnpm typecheck && pnpm test (272 tests) and pnpm build are green.
  • Local dev against https://func-atk-dev.azurewebsites.net: see the session notes in the PR conversation.

Before merging (merging deploys Pages = prod cutover)

gh variable set VITE_ATK_API_URL --body https://func-atk-prod.azurewebsites.net

After the Pages deploy is verified against prod

Out-of-band: delete the atk-auth Function App, the AZURE_CREDENTIALS secret, and the AZURE_FUNCTION_APP_NAME / VITE_AUTH_FUNCTION_URL repo variables.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AVx9yUuzMoxCS3xYaxzKbc

…auth-function

Hard switch from GitHub (Octokit + Contents API + client-side JSZip) to the
ATK API for every registry interaction. No fallback flag.

- Generate a typed client from the vendored contract (`openapi/openapi.json`)
  with @hey-api/openapi-ts 0.99.0 into `src/lib/api/` (`pnpm refresh-openapi`,
  `pnpm generate-api`). `src/lib/api-client.ts` owns the base URL
  (`VITE_ATK_API_URL` replaces `VITE_AUTH_FUNCTION_URL`), bearer auth from
  the session token, retries via `fetch-retry.ts` (now accepts a Request),
  and maps every `{ error, message, details? }` envelope to `ApiRequestError`.
- Auth: the OAuth code exchange posts to `POST /auth/github/exchange`;
  `SessionProvider` verifies with `GET /me` (401 -> signed-out, 403
  not_org_member / org_membership_unverifiable -> non-member, hints kept).
  The session context exposes a configured `api` client instead of `octokit`.
- Registry reads go to `/registry`, `/assets/.../manifest|readme|files` and
  `/bundles/.../manifest` (Zod guards kept). The Files card reads the API
  directory listing via a new `useAssetFiles` hook and `useManifestGraph`
  (one cached request per asset); `file-list.ts` and `registry-paths.ts`
  are gone.
- Downloads fetch the server-built zip / .skill archives in one request.
- Publish sends `POST /publish` (`client: "web"`), `POST /publish/plan` for
  dry runs; API error codes map to typed PublishErrors and validation
  `details[]` render on the review step. CreateBundle gains an org field so
  org bundles publish with `org` in bundle.json.
- Delete `auth-function/`, its deploy workflow, and its steps in
  validate.yml / deploy-pages.yml; the Pages build reads
  `vars.VITE_ATK_API_URL`. `@octokit/rest` removed; `jszip` stays for the
  Contribute .skill upload.
- Tests rewritten against the API shapes with fetch stubs; docs updated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVx9yUuzMoxCS3xYaxzKbc
@JasonPaff
JasonPaff merged commit 90cb60a into main Sep 11, 2026
1 check passed
@JasonPaff
JasonPaff deleted the feat/api-data-layer branch September 11, 2026 18:51
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