Skip to content

chore(codegen): daily schema refresh (2026-07-26) - #102

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

chore(codegen): daily schema refresh (2026-07-26)#102
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-07-26

Conversation

@timgl

@timgl timgl commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Why

Daily automated OpenAPI schema refresh. The live PostHog spec drifted from the checked-in typed client, so src/generated/api.d.ts regenerates dirty and the resource clients no longer typecheck against it.

Spec diff size

src/generated/api.d.ts: +3540 / −1521 lines (regenerated via pnpm codegen, never hand-edited).

Real drift fixed

Area Change Fix
Endpoints Route moved from environment-scoped environments_endpoints_* (/api/environments/{environment_id}/endpoints/) to project-scoped endpoints_* (/api/projects/{project_id}/endpoints/) Updated filter allowlist + endpoint client paths/params
Dashboards PATCH body renamed PatchedDashboardPatchedPatchedDashboardOpenApi Updated dashboard/client.ts type alias
Experiments PATCH body PatchedExperimentPatchedExperimentWrite; list PaginatedExperimentListPaginatedExperimentBasicList Updated experiment/client.ts type aliases

EndpointVersionResponse (new GET-by-name response) is a superset of EndpointResponse, so the existing client projection still holds.

New operationIds added to the filter

  • endpoints_list, endpoints_create, endpoints_retrieve, endpoints_update, endpoints_partial_update, endpoints_destroy — these are not new endpoints, they are the renamed replacements for the removed environments_endpoints_* operationIds (same managed "endpoints" resource family, new project-scoped route).

New operationIds intentionally NOT adopted

The drift report lists the entire unmanaged API surface (hundreds of operationIds) — this is every operation not in the allowlist, not a set of genuinely-new-since-yesterday endpoints. None were adopted this cycle:

  • PUT _update variants of managed families (cohorts_update, experiments_update, event_definitions_update, experiment_holdouts_update, experiment_saved_metrics_update, schema_property_groups_update, event_schemas_update, etc.) — the IaC clients deliberately reconcile via PATCH (partial_update) and soft-delete, so the PUT endpoints are not needed.
  • Non-CRUD sub-resources & actions on managed families (e.g. dashboards_collaborators_*, insights_sharing_*, feature_flags_status_retrieve, experiments_stats_retrieve, cohorts_persons_retrieve) — read/side-effect endpoints outside the declarative apply model.
  • Brand-new product areas (agent applications, signals/scout, LLM analytics, error tracking, warehouse, conversations, tasks, vision, etc.) — not managed as infrastructure-as-code resources.

Removed operationIds (flagged for a human)

  • environments_endpoints_list / _create / _retrieve / _update / _partial_update / _destroy disappeared from the live spec. Rather than delete the managed "endpoints" family, this PR repoints it to the new endpoints_* route (same resource, new path). No managed family was dropped.

Resources touched

  • openapi-filter.yaml (endpoints allowlist repointed)
  • src/generated/api.d.ts (regenerated)
  • src/resources/endpoint/client.ts, src/resources/dashboard/client.ts, src/resources/experiment/client.ts (schema/route refs)

Validation

  • pnpm typecheck
  • pnpm test ✅ 291 passing

Pre-existing repo-wide lint (4 errors) and Prettier (68 files) issues are untouched — all in files unrelated to this change; src/generated is Prettier-ignored.

Unresolved drift

None. All managed-family drift is reconciled and the suite is green.

Task-Id: b585cf48-569c-4c08-9c1b-9ad0c27286d4


Created with PostHog Code

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI schema and
patch resource clients for schema/route drift.

- endpoints route moved from environment-scoped (environments_endpoints_*,
  /api/environments/{environment_id}/endpoints/) to project-scoped
  (endpoints_*, /api/projects/{project_id}/endpoints/). Updated the filter
  allowlist and the endpoint client paths/params accordingly.
- dashboards PATCH body renamed PatchedDashboard -> PatchedPatchedDashboardOpenApi.
- experiments PATCH body renamed PatchedExperiment -> PatchedExperimentWrite and
  list response renamed PaginatedExperimentList -> PaginatedExperimentBasicList.

typecheck + test (291 passing) green.

Generated-By: PostHog Code
Task-Id: b585cf48-569c-4c08-9c1b-9ad0c27286d4
@timgl
timgl requested a review from pl July 26, 2026 07:55
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