Skip to content

chore(codegen): daily schema refresh (2026-08-27) - #134

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

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

Conversation

@timgl

@timgl timgl commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Daily regeneration of src/generated/api.d.ts from the live PostHog OpenAPI schema (https://us.posthog.com/api/schema/?format=json, filtered by openapi-filter.yaml).

Why: the daily drift check reported api.d.ts changed: true. Regenerating surfaced that the managed endpoints resource had been relocated server-side and would have broken apply/pull without a fix.

Spec diff size

  • src/generated/api.d.ts: +6694 / −2678 lines (17,571 → 21,587).
  • Change is dominated by upstream component-schema evolution across the kept operations; the only path-level change to a managed resource is the endpoints relocation below.

Managed-resource drift resolved

Endpoints relocated (path + operationId rename). The endpoints resource moved from /api/environments/{environment_id}/endpoints/ (operationId environments_endpoints_*) to /api/projects/{project_id}/endpoints/ (operationId endpoints_*). This is a rename of a resource we actively manage, not a genuine removal, so it was updated rather than merely flagged:

  • openapi-filter.yaml: environments_endpoints_{list,create,retrieve,update,partial_update,destroy}endpoints_{...}.
  • src/resources/endpoint/client.ts: path strings and path params (environment_idproject_id) updated. The retrieve response schema is now EndpointVersionResponse, a structural superset of EndpointResponse, so the projection is unchanged.

Component-schema renames (Zod/type projections patched, minimal edits).

  • dashboard/client.ts: partial-update body PatchedDashboardPatchedPatchedDashboardOpenApi.
  • experiment/client.ts: ExperimentExperimentWrite (write body), PatchedExperimentPatchedExperimentWrite, PaginatedExperimentListPaginatedExperimentBasicList.

New operationIds NOT added to the filter (intentional)

The drift report listed ~1,800 new operationIds in the live spec. The overwhelming majority belong to product families outside this tool's declarative IaC scope (billing, canvases, conversations, error-tracking, warehouse, tasks, vision, logs, etc.) and are intentionally left out.

Within the families this repo does manage, the new operationIds are all imperative sub-actions / sub-resources (e.g. insights_bulk_delete_create, dashboards_collaborators_*, feature_flags_activity_retrieve, cohorts_update (PUT), actions_bulk_update_tags_create, event_definitions_update). None are consumed by a resource client, and the declarative model only exposes the CRUD lifecycle (+ experiment lifecycle actions). Adding them would bloat the generated types with no consumer, so they were left out. No brand-new resource family warranted add-resource wiring this cycle.

Unresolved drift / for human review

  • None outstanding. After the endpoints relocation fix, all 71 filter operationIds resolve against the live spec (0 disappearances remaining).

Verification

  • pnpm typecheck
  • pnpm test ✅ (291 passing)
  • pnpm build

TaskRun: https://us.posthog.com/project/423401/tasks/aa7bd30e-d786-4803-a6d7-1dc72e501d37


Created with PostHog Desktop

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI schema.

- Relocate the managed `endpoints` resource from
  /api/environments/{environment_id}/endpoints/ (operationId
  environments_endpoints_*) to /api/projects/{project_id}/endpoints/
  (operationId endpoints_*). Update openapi-filter.yaml and
  endpoint/client.ts paths/params accordingly.
- Patch stale component schema references after upstream renames:
  dashboard PatchedDashboard -> PatchedPatchedDashboardOpenApi;
  experiment Experiment/PatchedExperiment/PaginatedExperimentList ->
  ExperimentWrite/PatchedExperimentWrite/PaginatedExperimentBasicList.

typecheck, test (291 passing), and build all green.

Why: the daily drift check flagged that api.d.ts no longer matched the
live spec; the endpoints resource had been moved server-side and would
have broken apply/pull without the path + filter fix.

Generated-By: PostHog Desktop
Task-Id: aa7bd30e-d786-4803-a6d7-1dc72e501d37
@timgl
timgl requested a review from pl August 27, 2026 10:22
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