Skip to content

chore(codegen): daily schema refresh (2026-08-24) - #131

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

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

Conversation

@timgl

@timgl timgl commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily refresh of the typed PostHog API client. The live OpenAPI spec drifted (api.d.ts changed: true on 2026-08-24), so the generated types and the managed-resource clients needed to be brought back in sync.

What changed

Regenerated src/generated/api.d.ts via pnpm codegen (never hand-edited) and patched the managed-resource clients affected by schema drift.

Spec diff size: src/generated/api.d.ts — +6,613 / −2,682 lines. Live spec: 1,985 total operationIds, 71 allowlisted.

Endpoints resource relocated (operationIds followed)

The endpoints resource moved from the environment-scoped path to the project-scoped path:

before after
/api/environments/{environment_id}/endpoints/ /api/projects/{project_id}/endpoints/
environments_endpoints_* endpoints_*

New operationIds added to openapi-filter.yaml: endpoints_list, endpoints_create, endpoints_retrieve, endpoints_update, endpoints_partial_update, endpoints_destroy (replacing the six environments_endpoints_* that were retired). endpoint/client.ts updated to the new path and project_id param — response/request component names (EndpointResponse, PaginatedEndpointResponseList, EndpointRequest, PatchedEndpointRequest) are unchanged.

Schema renames absorbed in clients

  • Dashboarddashboards_partial_update body PatchedDashboardPatchedPatchedDashboardOpenApi.
  • Experiment — create/update body ExperimentExperimentWrite; partial_update body PatchedExperimentPatchedExperimentWrite; list response PaginatedExperimentListPaginatedExperimentBasicList.

Resources touched

openapi-filter.yaml, src/generated/api.d.ts, dashboard/client.ts, endpoint/client.ts, experiment/client.ts.

New operationIds NOT added (and why)

The drift detector emits every operationId absent from the allowlist — effectively the entire unmanaged API surface (~1,900 ops across tasks, canvases, signals, warehouse, llm_analytics, billing, etc.), not genuinely-new endpoints. None constitute a new definitional resource family appropriate for automated adoption; onboarding one requires the add-resource skill, a pipeline, and human product judgment about IaC fit. So none were added in this automated pass.

Note for reviewers: several already-managed families now also expose a full _update (PUT) alongside the _partial_update (PATCH) we use — e.g. experiments_update, cohorts_update, event_definitions_update, event_schemas_update / event_schemas_partial_update, experiment_holdouts_update, experiment_saved_metrics_update, schema_property_groups_update, environments_update. Our clients apply changes via PATCH, so these were intentionally left out to keep the generated surface minimal. Add them if a future feature needs PUT semantics.

Unresolved drift

  • No allowlisted operationId was deleted — the only ones that disappeared (environments_endpoints_*) were relocated, and this PR follows the move rather than dropping the resource. Nothing left for a human to hand-delete.

Verification

pnpm typecheck ✅ · pnpm test ✅ (291 passed). Pre-existing repo-wide lint/format:check warnings are untouched (present on the base branch, in files outside this change); no pre-commit hooks are configured.

TaskRun: aea0b0dd-66e1-4c07-bd83-d1b967510d2e


Created with PostHog Desktop

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI spec and
absorb schema drift in managed resources.

- Endpoints resource relocated from the environment-scoped path
  (/api/environments/{environment_id}/endpoints/, operationId
  environments_endpoints_*) to the project-scoped path
  (/api/projects/{project_id}/endpoints/, operationId endpoints_*).
  Updated openapi-filter.yaml and endpoint/client.ts accordingly.
- Dashboard partial_update request body renamed
  PatchedDashboard -> PatchedPatchedDashboardOpenApi.
- Experiment schemas renamed: create/update body Experiment -> ExperimentWrite,
  partial_update body PatchedExperiment -> PatchedExperimentWrite,
  list response PaginatedExperimentList -> PaginatedExperimentBasicList.

Generated-By: PostHog Desktop
Task-Id: aea0b0dd-66e1-4c07-bd83-d1b967510d2e
@timgl
timgl requested a review from pl August 24, 2026 07:31
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