Skip to content

chore(codegen): daily schema refresh (2026-07-27) - #103

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

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

Conversation

@timgl

@timgl timgl commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily refresh of the typed PostHog API client. Keeps src/generated/api.d.ts in sync with the live OpenAPI spec (filtered by openapi-filter.yaml) so schema drift is caught and fixed the day it lands rather than surfacing as a surprise later.

Spec diff size

Regenerated src/generated/api.d.ts via pnpm codegen: +3,571 / −1,546 lines (net ~19.6k lines). This is mostly upstream field churn on the managed schemas plus the endpoint relocation below.

New operationIds added to the filter

The endpoints resource was relocated upstream — it moved out of the /api/environments/{environment_id}/endpoints/ scope into /api/projects/{project_id}/endpoints/, and its operationIds were renamed environments_endpoints_*endpoints_*. The old operationIds no longer exist in the live spec, so the endpoint schemas were being pruned as orphans (breaking typecheck). Swapped the six CRUD operationIds in openapi-filter.yaml:

  • endpoints_list, endpoints_create, endpoints_retrieve, endpoints_update, endpoints_partial_update, endpoints_destroy

No brand-new resource families were adopted this run. The live spec surfaces a large number of unmanaged operationIds (accounts, agent_applications, conversations, warehouse, error_tracking, vision, signals, etc.) plus many non-lifecycle action endpoints on existing families (*_activity, *_sharing, *_bulk_*, dashboard tile mutations, experiment lifecycle helpers, cohort person ops). These are intentionally left out — the IaC client only manages the standard CRUD lifecycle (list/create/retrieve/update/partial_update/destroy) of each resource, and pulling in the extra endpoints would bloat the generated types without any client code consuming them.

Resources touched

Schema drift required minimal client patches (type-alias renames only, no behavior change):

  • endpoint (src/resources/endpoint/client.ts) — repointed all five paths from the /environments/{environment_id}/ scope to /projects/{project_id}/ (value is still config.projectId).
  • experiment (src/resources/experiment/client.ts) — write body ExperimentExperimentWrite, PatchedExperimentPatchedExperimentWrite, list payload PaginatedExperimentListPaginatedExperimentBasicList.
  • dashboard (src/resources/dashboard/client.ts) — PATCH body PatchedDashboardPatchedPatchedDashboardOpenApi (fields used — restriction_level, tiles, delete_insights — all still present).

pnpm typecheck and pnpm test (291 tests) both pass. Managed-resource safety invariants (tag/description prefix filtering) are unchanged.

Unresolved drift

None. Every operationId in openapi-filter.yaml resolves in the current live spec, and no previously-managed operationId disappeared without a replacement (the endpoint relocation is handled above).


TaskRun: 4f17c8b7-a75e-4682-a2d0-d1ae16095720


Created with PostHog Code

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

- Endpoints resource relocated upstream from /api/environments/.../endpoints/
  (environments_endpoints_*) to /api/projects/.../endpoints/ (endpoints_*);
  updated the filter allowlist and endpoint client paths accordingly.
- Experiment write body renamed to ExperimentWrite / PatchedExperimentWrite and
  list payload to PaginatedExperimentBasicList.
- Dashboard PATCH body renamed to PatchedPatchedDashboardOpenApi.

Generated-By: PostHog Code
Task-Id: 4f17c8b7-a75e-4682-a2d0-d1ae16095720
@timgl
timgl requested a review from pl July 27, 2026 08:15
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