Skip to content

chore(codegen): daily schema refresh (2026-08-12) - #119

Draft
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-08-12
Draft

chore(codegen): daily schema refresh (2026-08-12)#119
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-08-12

Conversation

@timgl

@timgl timgl commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Automated daily refresh of src/generated/api.d.ts from the live PostHog OpenAPI
spec (https://us.posthog.com/api/schema/?format=json, filtered by
openapi-filter.yaml), plus the minimal client fixes needed to reconcile drift
in the managed resource families.

Why: the scheduled drift check flagged that api.d.ts changed and that
managed operations had moved/renamed upstream; regenerating keeps the typed
client in sync with the live API.

Spec diff size

src/generated/api.d.ts: 17,571 → 21,295 lines (+5,803 / −2,079).

New operationIds added to the filter

The endpoints resource moved namespaces upstream — the old operationIds no longer
exist, so their replacements were added to openapi-filter.yaml:

  • environments_endpoints_listendpoints_list
  • environments_endpoints_createendpoints_create
  • environments_endpoints_retrieveendpoints_retrieve
  • environments_endpoints_updateendpoints_update
  • environments_endpoints_partial_updateendpoints_partial_update
  • environments_endpoints_destroyendpoints_destroy

The path also moved from /api/environments/{environment_id}/endpoints/ to
/api/projects/{project_id}/endpoints/.

Resources touched

  • endpoint (src/resources/endpoint/client.ts): repointed all 5 calls to the
    new /api/projects/{project_id}/endpoints/ path and project_id param.
  • experiment (src/resources/experiment/client.ts): schema aliases renamed —
    ExperimentExperimentWrite (create body), PatchedExperiment
    PatchedExperimentWrite, PaginatedExperimentListPaginatedExperimentBasicList.
  • dashboard (src/resources/dashboard/client.ts): PATCH schema alias renamed
    PatchedDashboardPatchedPatchedDashboardOpenApi.

No hand-edits to src/generated/api.d.ts — regenerated via pnpm codegen.

Verification

  • pnpm typecheck
  • pnpm test ✅ (291 tests)
  • Pre-existing repo-wide lint/prettier debt in untouched files was left as-is to
    avoid touching unrelated files; the heavily-edited endpoint/client.ts is
    prettier-clean.

Unresolved drift / notes for reviewers

  • The drift check reports "new operationIds missing from the filter" by diffing
    every live operationId against the allowlist, so that list is dominated by
    intentionally-unmanaged API surface (accounts, alerts, annotations, warehouse,
    etc.). None of those are in scope for this IaC client, so they were left out of
    the filter by design. Only the endpoints rename was actionable.
  • The experiments list response is now PaginatedExperimentBasicList (results are
    ExperimentBasic, a narrower shape than the full Experiment). ExperimentBasic
    still carries description, feature_flag_key, name, status, etc., so the
    managed-filter and pull paths are unaffected, but flagging in case a reviewer
    wants the list to hydrate full experiments.
  • No managed operationIds disappeared without a replacement — all 71 filter entries
    resolve in the live spec after the endpoints remap.

TaskRun: https://us.posthog.com/project/423401/tasks/9c5d8153-96c4-4656-8830-f942a48ad501


Created with PostHog Desktop

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI spec and
reconcile managed-resource drift.

- Endpoints resource moved from /api/environments/{environment_id}/endpoints/
  to /api/projects/{project_id}/endpoints/ (operationIds environments_endpoints_*
  → endpoints_*). Update openapi-filter.yaml and endpoint/client.ts paths/params.
- Experiment schemas renamed: Experiment→ExperimentWrite (create body),
  PatchedExperiment→PatchedExperimentWrite, PaginatedExperimentList→
  PaginatedExperimentBasicList. Update experiment/client.ts type aliases.
- Dashboard PATCH schema renamed PatchedDashboard→PatchedPatchedDashboardOpenApi.
  Update dashboard/client.ts type alias.

typecheck + test (291 tests) green.

Generated-By: PostHog Desktop
Task-Id: 9c5d8153-96c4-4656-8830-f942a48ad501
@timgl
timgl requested a review from pl August 12, 2026 07:38
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