Skip to content

refactor(global-variables): strip remaining any from adminRoutes + resolver (types-only) - #1025

Open
mmcintosh wants to merge 1 commit into
mainfrom
fix/global-variables-typing
Open

refactor(global-variables): strip remaining any from adminRoutes + resolver (types-only)#1025
mmcintosh wants to merge 1 commit into
mainfrom
fix/global-variables-typing

Conversation

@mmcintosh

Copy link
Copy Markdown
Collaborator

Description

Follow-up to the auth fix (#1024, which was intentionally "Split scope"): types the adminRoutes surface and variable-resolver.ts that the security PR deferred so the security change stayed reviewable. Types-only — no behavior change (resolver test 13/13, tsc clean).

Stacked PR: based on fix/global-variables-auth so the diff shows only the typing changes. Please merge/retarget after #1024 lands (I'll retarget to main then).

Changes

  • adminRoutes typed new Hono<{ Bindings; Variables }>() — removes every c: any/(c: any, next: any) (same pattern as apiRoutes in fix(global-variables): require auth on the /api/global-variables routes #1024). The plugin-active gate returns next() to satisfy noImplicitReturns.
  • Row projections typedPluginSettingsRow replaces .first() as any; parsed plugin settings typed as GvSettings; the admin variable list typed FormattedVariable[] end-to-end into renderAdminPage.
  • variable-resolver.tsdb: any → D1Database; the recursive resolveVariablesInObject / resolveContentVariables any → unknown; the row read typed via .all<{ key; value }>() (drops the (row as any) casts).
  • install/uninstall — context typed (the SDK types it unknown) via a minimal LifecycleContext narrowing.

Net: plugin any count 26 → 2.

Deferred (with reason)

The content:read hook keeps data: any, context: any (the only remaining 2). Its typed payload is ContentEventPayload (content at .data), but the handler treats data as the content itself and reads context.context.env.DB — and the event is currently reserved/unwired (no dispatch site). Reconciling that is a behavior change, out of scope for a types-only PR; flagged in an in-code note.

Testing

tsc --noEmit clean for the plugin and project-wide (external callers — api-content-crud, core-plugins/index, the resolver test — all still compile against the stricter unknown). global-variables-resolver.test.ts 13/13.

Unit Tests

  • All unit tests passing (no new tests — types-only refactor)

E2E Tests

  • N/A

Screenshots/Videos

N/A — no behavior/UI change.

Checklist

  • Code follows project conventions
  • Type checking passes
  • No console errors or warnings
  • Documentation updated (if needed) — N/A

@mmcintosh
mmcintosh marked this pull request as ready for review July 24, 2026 19:55
@mmcintosh
mmcintosh requested a review from lane711 as a code owner July 24, 2026 19:55
…resolver (types-only)

Follow-up to the auth fix (Split scope): types the adminRoutes surface and
variable-resolver.ts that the security PR deferred. No behavior change.

- adminRoutes typed as new Hono<{Bindings;Variables}> (removes every `c: any`); the
  plugin-active gate returns next() to satisfy noImplicitReturns.
- Row projections typed (PluginSettingsRow) instead of `.first() as any`; parsed
  settings typed (GvSettings); the variables list typed (FormattedVariable)
  end-to-end into renderAdminPage.
- variable-resolver.ts: db -> D1Database, the recursive resolver obj/return -> unknown,
  and the row read typed via .all<{key,value}>() (drops the `(row as any)` casts).
- install/uninstall context typed (the SDK types it `unknown`) via a minimal
  LifecycleContext narrowing.

Deferred (1 handler, 2 `any`): the `content:read` hook — its typed payload is
ContentEventPayload, but the handler treats `data` as the content itself and reads
`context.context.env.DB`; reconciling that (plus the event's reserved/unwired
dispatch) is a behavior change, not a types-only strip. Noted in-code.

Net: global-variables-plugin `any` count 26 -> 2. tsc clean; resolver test 13/13.
@mmcintosh
mmcintosh force-pushed the fix/global-variables-typing branch from 5f8cd80 to 8ff049a Compare August 17, 2026 23:53
@mmcintosh
mmcintosh changed the base branch from fix/global-variables-auth to main August 17, 2026 23:53
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