Skip to content

chore(codegen): daily schema refresh (2026-07-28) - #105

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

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

Conversation

@timgl

@timgl timgl commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily OpenAPI schema refresh. The live PostHog spec drifted (api.d.ts changed: true), so src/generated/api.d.ts was regenerated and managed-resource drift reconciled.

Spec diff size

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

New operationIds added to the filter

The endpoints resource was renamed/moved in the live spec:

  • environments_endpoints_* at /api/environments/{environment_id}/endpoints/endpoints_* at /api/projects/{project_id}/endpoints/.

Added the matching CRUD operationIds to openapi-filter.yaml:

endpoints_list
endpoints_create
endpoints_retrieve
endpoints_update
endpoints_partial_update
endpoints_destroy

Only the 6 CRUD ops the endpoint resource manages were added (the spec also exposes endpoints_logs_*, endpoints_run_*, endpoints_versions_*, endpoints_materialization_*, etc. — out of scope for this resource).

Resources touched

  • endpoint (src/resources/endpoint/client.ts): repointed all five operations from /api/environments/{environment_id}/endpoints/… to /api/projects/{project_id}/endpoints/… and renamed the environment_id path param to project_id. Retrieve now returns EndpointVersionResponse (a superset of EndpointResponse), so the projection is unaffected.
  • dashboard (src/resources/dashboard/client.ts): PATCH body schema renamed PatchedDashboardPatchedPatchedDashboardOpenApi. That schema no longer lists deleted, so the soft-delete PATCH now casts past the schema (same pattern the experiment client already uses); runtime behavior is unchanged.
  • experiment (src/resources/experiment/client.ts): PatchedExperimentPatchedExperimentWrite, PaginatedExperimentListPaginatedExperimentBasicList, and the create/update body target ExperimentExperimentWrite (POST/PUT/PATCH now take the *Write variants). Bodies are cast, so this is a type-alias accuracy fix.

Unresolved drift (needs a human)

  • Disappeared managed operationIds: environments_endpoints_list/create/retrieve/update/partial_update/destroy no longer exist in the live spec (renamed as above). Per policy they were not removed — they are kept in openapi-filter.yaml with a note so a human can confirm the migration and delete them (openapi-format ignores unmatched ids, so they're harmless meanwhile).
  • PUT variants for existing families left out: the drift report surfaces event_definitions_update, event_schemas_update/event_schemas_partial_update, experiment_holdouts_update, experiment_saved_metrics_update, experiments_update, and cohorts_update. These families intentionally manage updates via PATCH, not PUT, and their clients have no PUT consumer, so adding them would only widen the generated surface. Left out by design.
  • Brand-new resource families: the drift detector lists every live operationId not in the allowlist (essentially the whole API — accounts, alerts, annotations, logs, tasks, …). None are added: introducing a new managed family is a product decision that needs the add-resource skill, registration, and tests — out of scope for an automated refresh.

Verification

pnpm typecheck, pnpm test (291 passed), and pnpm build all pass. Pre-existing repo-wide lint/format warnings are untouched (unrelated files).

TaskRun

https://us.posthog.com/project/423401/tasks/db3032f0-7553-4d21-9ab5-ccd55a893746


Created with PostHog Code

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/
  (environments_endpoints_*) to /api/projects/{project_id}/endpoints/
  (endpoints_*); added the endpoints_* CRUD ops to openapi-filter.yaml and
  repointed the endpoint client paths/params.
- patched stale schema references: PatchedDashboard -> PatchedPatchedDashboardOpenApi,
  PatchedExperiment -> PatchedExperimentWrite, PaginatedExperimentList ->
  PaginatedExperimentBasicList, and the experiment write body Experiment ->
  ExperimentWrite.

Generated-By: PostHog Code
Task-Id: db3032f0-7553-4d21-9ab5-ccd55a893746
@timgl
timgl requested a review from pl July 28, 2026 07:59
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