From a3be428b72e6d27d40e7b380c097a56ebb51f90d Mon Sep 17 00:00:00 2001 From: Fabiano Cruz Date: Thu, 23 Apr 2026 22:27:58 -0300 Subject: [PATCH] =?UTF-8?q?fix(api-types):=20drop=20org=5Fid=20+=20project?= =?UTF-8?q?=5Fid=20from=20ConnectionRow=20=E2=80=94=20match=20real=20wire?= =?UTF-8?q?=20shape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #12. The backend's serializeConnection() strips both fields before responding; any runtime parse of a real /v1/connections response would have rejected it. Test updated to the real shape. Discovered during enterprise adoption (codespar-enterprise#41) — the fix landed on the api-types branch after #12 was merged, so it needs to ship as its own PR. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/api-types/src/connections.ts | 7 +++++-- packages/api-types/src/index.test.ts | 6 +----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/api-types/src/connections.ts b/packages/api-types/src/connections.ts index 676dc6ac..4c0ca2d 100644 --- a/packages/api-types/src/connections.ts +++ b/packages/api-types/src/connections.ts @@ -28,10 +28,13 @@ export type CreateConnectionRequest = z.infer< typeof CreateConnectionRequestSchema >; +// org_id and project_id are intentionally omitted from the wire response — +// the backend's serializeConnection() strips them. Callers already know +// their own org/project from the auth context, and leaking either across +// a poorly-scoped proxy would be a cross-tenant signal we'd rather not +// emit by default. export const ConnectionRowSchema = z.object({ id: z.string(), - org_id: z.string(), - project_id: z.string().nullable(), user_id: z.string(), server_id: z.string(), auth_type: AuthTypeSchema, diff --git a/packages/api-types/src/index.test.ts b/packages/api-types/src/index.test.ts index 9c1e6a8..94728da 100644 --- a/packages/api-types/src/index.test.ts +++ b/packages/api-types/src/index.test.ts @@ -116,12 +116,10 @@ describe("projects", () => { }); describe("connections", () => { - it("accepts a connected ConnectionRow", () => { + it("accepts a connected ConnectionRow (no org_id / project_id — the backend strips them)", () => { expect( ConnectionRowSchema.parse({ id: "ca_abc", - org_id: "org_123", - project_id: "prj_abcdef0123456789", user_id: "dashboard", server_id: "asaas", auth_type: "api_key", @@ -139,8 +137,6 @@ describe("connections", () => { it("rejects ConnectionRow with unknown status", () => { const res = ConnectionRowSchema.safeParse({ id: "ca_abc", - org_id: "org_123", - project_id: null, user_id: "x", server_id: "asaas", auth_type: "api_key",