diff --git a/__tests__/entities.test.ts b/__tests__/entities.test.ts index a76fe5f..8a989ff 100644 --- a/__tests__/entities.test.ts +++ b/__tests__/entities.test.ts @@ -74,12 +74,26 @@ describe("node-sdk entities — request shaping", () => { }); }); - it("incrementEntityViews strips entityId into the path and patches the rest", async () => { + it("incrementEntityViews sends count as a query param, not a body field", async () => { const { client, projectInstance } = makeClient(); await incrementEntityViews(client, { entityId: "e1", count: 3 }); - expect(projectInstance.patch).toHaveBeenCalledWith("/entities/e1/increment-views", { - count: 3, - }); + // The server reads `count` from the query string; as a body field it was + // ignored and every call incremented by the default of 1. + expect(projectInstance.patch).toHaveBeenCalledWith( + "/entities/e1/increment-views", + undefined, + { params: { count: 3 } }, + ); + }); + + it("incrementEntityViews omits count when not supplied", async () => { + const { client, projectInstance } = makeClient(); + await incrementEntityViews(client, { entityId: "e1" }); + expect(projectInstance.patch).toHaveBeenCalledWith( + "/entities/e1/increment-views", + undefined, + { params: {} }, + ); }); it("deleteEntity deletes /entities/:id", async () => { diff --git a/src/modules/entities/incrementEntityViews.ts b/src/modules/entities/incrementEntityViews.ts index ab537c5..eb7c922 100644 --- a/src/modules/entities/incrementEntityViews.ts +++ b/src/modules/entities/incrementEntityViews.ts @@ -11,7 +11,11 @@ export async function incrementEntityViews( data: IncrementEntityViewsProps ): Promise { const { entityId, ...restOfProps } = data; - const path = `/entities/${data.entityId}/increment-views`; - const response = await client.projectInstance.patch(path, restOfProps); + const path = `/entities/${entityId}/increment-views`; + // `count` is read from the query string, not the body — sending it as a body + // field left the server on its default of 1, silently ignoring the amount. + const response = await client.projectInstance.patch(path, undefined, { + params: restOfProps, + }); return response.data; } diff --git a/src/modules/spaces/fetchUserSpaces.ts b/src/modules/spaces/fetchUserSpaces.ts index cc43ade..866c989 100644 --- a/src/modules/spaces/fetchUserSpaces.ts +++ b/src/modules/spaces/fetchUserSpaces.ts @@ -9,6 +9,12 @@ export interface FetchUserSpacesProps { include?: string; role?: string; // single role or comma-separated, e.g. "admin,moderator" all?: "true" | "false"; + /** + * Membership status to list. Defaults to `"active"` (spaces the user is in); + * `"pending"` returns join requests awaiting approval, `"banned"` the spaces + * they were removed from. + */ + status?: "active" | "pending" | "banned"; } export async function fetchUserSpaces(