From 5a03ef7e28ba053dd6b83208ce88bc771fc7bfcb Mon Sep 17 00:00:00 2001 From: Yanay Date: Sun, 5 Jul 2026 11:22:46 +0300 Subject: [PATCH] feat(spaces): expose visibility on space create/update and type Mirrors the server's new space visibility field (public | unlisted | private) in @sublay/node: SpaceVisibility type, visibility on the Space interface (optional on SpacePreview), and optional visibility on create/update props (forwarded in the request body). No aliases or renames. Co-Authored-By: Claude Opus 4.8 --- __tests__/spaces-lifecycle.test.ts | 22 ++++++++++++++++++++++ src/interfaces/Space.ts | 3 +++ src/modules/spaces/createSpace.ts | 8 +++++++- src/modules/spaces/updateSpace.ts | 8 +++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/__tests__/spaces-lifecycle.test.ts b/__tests__/spaces-lifecycle.test.ts index 4a5cc4a..e87a6f2 100644 --- a/__tests__/spaces-lifecycle.test.ts +++ b/__tests__/spaces-lifecycle.test.ts @@ -24,6 +24,20 @@ describe("node-sdk spaces (lifecycle) — request shaping", () => { }); }); + it("createSpace forwards visibility in the body", async () => { + const { client, projectInstance } = makeClient(); + await createSpace(client, { + userId: "u1", + name: "My Space", + visibility: "private", + }); + expect(projectInstance.post).toHaveBeenCalledWith("/spaces", { + userId: "u1", + name: "My Space", + visibility: "private", + }); + }); + it("fetchManySpaces hits /spaces with the full body as params", async () => { const { client, projectInstance } = makeClient(); await fetchManySpaces(client, { sortBy: "newest", page: 1 }); @@ -100,6 +114,14 @@ describe("node-sdk spaces (lifecycle) — request shaping", () => { }); }); + it("updateSpace forwards visibility in the body", async () => { + const { client, projectInstance } = makeClient(); + await updateSpace(client, { spaceId: "s1", visibility: "unlisted" }); + expect(projectInstance.patch).toHaveBeenCalledWith("/spaces/s1", { + visibility: "unlisted", + }); + }); + it("deleteSpace deletes /spaces/:id", async () => { const { client, projectInstance } = makeClient(); await deleteSpace(client, { spaceId: "s1" }); diff --git a/src/interfaces/Space.ts b/src/interfaces/Space.ts index ec1625d..332b836 100644 --- a/src/interfaces/Space.ts +++ b/src/interfaces/Space.ts @@ -3,6 +3,7 @@ import { File } from "./File"; export type ReadingPermission = "anyone" | "members"; export type PostingPermission = "anyone" | "members" | "admins"; +export type SpaceVisibility = "public" | "unlisted" | "private"; export type SpaceMemberRole = "admin" | "moderator" | "member"; export type SpaceMemberStatus = "pending" | "active" | "banned" | "rejected"; @@ -24,6 +25,7 @@ export interface SpacePreview { slug: string | null; avatarFileId: string | null; readingPermission?: ReadingPermission; + visibility?: SpaceVisibility; parentSpaceId?: string | null; depth?: number; avatarFile?: File; @@ -41,6 +43,7 @@ export interface Space { userId: string; readingPermission: ReadingPermission; postingPermission: PostingPermission; + visibility: SpaceVisibility; requireJoinApproval: boolean; parentSpaceId: string | null; depth: number; diff --git a/src/modules/spaces/createSpace.ts b/src/modules/spaces/createSpace.ts index c2f2d53..18532eb 100644 --- a/src/modules/spaces/createSpace.ts +++ b/src/modules/spaces/createSpace.ts @@ -1,5 +1,10 @@ import { SublayHttpClient } from "../../core/client"; -import { Space, ReadingPermission, PostingPermission } from "../../interfaces/Space"; +import { + Space, + ReadingPermission, + PostingPermission, + SpaceVisibility, +} from "../../interfaces/Space"; export interface CreateSpaceProps { userId: string; @@ -8,6 +13,7 @@ export interface CreateSpaceProps { description?: string; readingPermission?: ReadingPermission; postingPermission?: PostingPermission; + visibility?: SpaceVisibility; requireJoinApproval?: boolean; parentSpaceId?: string; metadata?: Record; diff --git a/src/modules/spaces/updateSpace.ts b/src/modules/spaces/updateSpace.ts index dffeee8..693c914 100644 --- a/src/modules/spaces/updateSpace.ts +++ b/src/modules/spaces/updateSpace.ts @@ -1,5 +1,10 @@ import { SublayHttpClient } from "../../core/client"; -import { Space, ReadingPermission, PostingPermission } from "../../interfaces/Space"; +import { + Space, + ReadingPermission, + PostingPermission, + SpaceVisibility, +} from "../../interfaces/Space"; export interface UpdateSpaceProps { spaceId: string; @@ -8,6 +13,7 @@ export interface UpdateSpaceProps { description?: string; readingPermission?: ReadingPermission; postingPermission?: PostingPermission; + visibility?: SpaceVisibility; metadata?: Record; }