Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions __tests__/entities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
8 changes: 6 additions & 2 deletions src/modules/entities/incrementEntityViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export async function incrementEntityViews(
data: IncrementEntityViewsProps
): Promise<Entity> {
const { entityId, ...restOfProps } = data;
const path = `/entities/${data.entityId}/increment-views`;
const response = await client.projectInstance.patch<Entity>(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<Entity>(path, undefined, {
params: restOfProps,
});
return response.data;
}
6 changes: 6 additions & 0 deletions src/modules/spaces/fetchUserSpaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading