@sublay/js 7.6.0 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +459 -55
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +232 -32
  5. package/dist/index.mjs +232 -32
  6. package/dist/interfaces/Report.d.ts +7 -1
  7. package/dist/interfaces/Space.d.ts +0 -16
  8. package/dist/interfaces/Workspace.d.ts +148 -0
  9. package/dist/modules/chat/editMessage.d.ts +3 -2
  10. package/dist/modules/chat/index.d.ts +0 -1
  11. package/dist/modules/collections/updateCollection.d.ts +1 -1
  12. package/dist/modules/comments/updateComment.d.ts +4 -1
  13. package/dist/modules/reports/createReport.d.ts +2 -2
  14. package/dist/modules/spaces/fetchUserSpaces.d.ts +6 -0
  15. package/dist/modules/spaces/index.d.ts +0 -2
  16. package/dist/modules/workspaces/acceptInvite.d.ts +13 -0
  17. package/dist/modules/workspaces/acceptWorkspaceInvite.d.ts +13 -0
  18. package/dist/modules/workspaces/createInvite.d.ts +17 -0
  19. package/dist/modules/workspaces/createWorkspace.d.ts +12 -0
  20. package/dist/modules/workspaces/createWorkspaceInvite.d.ts +17 -0
  21. package/dist/modules/workspaces/declineInvite.d.ts +12 -0
  22. package/dist/modules/workspaces/declineWorkspaceInvite.d.ts +14 -0
  23. package/dist/modules/workspaces/deleteWorkspace.d.ts +13 -0
  24. package/dist/modules/workspaces/fetchManyWorkspaces.d.ts +13 -0
  25. package/dist/modules/workspaces/fetchMembers.d.ts +13 -0
  26. package/dist/modules/workspaces/fetchMyInvites.d.ts +11 -0
  27. package/dist/modules/workspaces/fetchMyWorkspaceInvites.d.ts +15 -0
  28. package/dist/modules/workspaces/fetchWorkspace.d.ts +7 -0
  29. package/dist/modules/workspaces/fetchWorkspaceAuthority.d.ts +11 -0
  30. package/dist/modules/workspaces/fetchWorkspaceInvites.d.ts +17 -0
  31. package/dist/modules/workspaces/fetchWorkspaceMemberStanding.d.ts +11 -0
  32. package/dist/modules/workspaces/fetchWorkspaceMembers.d.ts +13 -0
  33. package/dist/modules/workspaces/getAuthority.d.ts +11 -0
  34. package/dist/modules/workspaces/index.d.ts +21 -0
  35. package/dist/modules/workspaces/leaveWorkspace.d.ts +11 -0
  36. package/dist/modules/workspaces/removeWorkspaceMember.d.ts +12 -0
  37. package/dist/modules/workspaces/removeWorkspaceMemberFromSubtree.d.ts +16 -0
  38. package/dist/modules/workspaces/resendWorkspaceInvite.d.ts +12 -0
  39. package/dist/modules/workspaces/revokeWorkspaceInvite.d.ts +13 -0
  40. package/dist/modules/workspaces/transferWorkspaceOwnership.d.ts +15 -0
  41. package/dist/modules/workspaces/updateWorkspace.d.ts +12 -0
  42. package/dist/modules/workspaces/updateWorkspaceInheritFlag.d.ts +13 -0
  43. package/dist/modules/workspaces/updateWorkspaceMember.d.ts +17 -0
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -42,7 +42,7 @@ One `SublayClient` with 14 module namespaces (call them as `sublay.<module>.<fn>
42
42
  | `users` | profiles, username lookup, suggestions, updates, and the per-user follow/connection graph |
43
43
  | `entities` | content CRUD, drafts, feeds (`fetchManyEntities`), reactions, saves |
44
44
  | `comments` | threaded comments CRUD, reactions |
45
- | `spaces` | communities: lifecycle, membership, roles, rules, digests, moderation |
45
+ | `spaces` | communities: lifecycle, membership, roles, rules, moderation |
46
46
  | `collections` | saved-entity collections |
47
47
  | `follows` / `connections` | the logged-in user's own follow graph and mutual connections |
48
48
  | `appNotifications` | in-app notifications and unread counts |
package/dist/index.d.mts CHANGED
@@ -967,22 +967,6 @@ interface CheckMyMembershipResponse {
967
967
  }
968
968
  interface DeleteSpaceResponse {
969
969
  message: string;
970
- deletedSpace: {
971
- id: string;
972
- name: string;
973
- };
974
- counts: {
975
- entities: number;
976
- members: number;
977
- childSpaces: number;
978
- };
979
- }
980
- interface DigestConfig {
981
- digestEnabled: boolean;
982
- digestWebhookUrl: string | null;
983
- digestWebhookSecret: string | null;
984
- digestScheduleHour: number | null;
985
- digestTimezone: string | null;
986
970
  }
987
971
  interface SpaceBreadcrumb {
988
972
  breadcrumb: SpacePreview[];
@@ -1623,7 +1607,10 @@ declare function fetchCommentByForeignId(client: SublayHttpClient, data: FetchCo
1623
1607
 
1624
1608
  interface UpdateCommentProps {
1625
1609
  commentId: string;
1626
- content: string;
1610
+ /** New text content. Cannot be empty. Omit to leave the content untouched. */
1611
+ content?: string;
1612
+ /** Replaces the comment's metadata wholesale (not merged). */
1613
+ metadata?: Record<string, any>;
1627
1614
  }
1628
1615
  declare function updateComment(client: SublayHttpClient, data: UpdateCommentProps): Promise<Comment>;
1629
1616
 
@@ -1765,6 +1752,12 @@ interface FetchUserSpacesProps {
1765
1752
  include?: string;
1766
1753
  role?: string;
1767
1754
  all?: "true" | "false";
1755
+ /**
1756
+ * Membership status to list. Defaults to `"active"` (spaces the user is in);
1757
+ * `"pending"` returns join requests awaiting approval, `"banned"` the spaces
1758
+ * they were removed from.
1759
+ */
1760
+ status?: "active" | "pending" | "banned";
1768
1761
  }
1769
1762
  declare function fetchUserSpaces(client: SublayHttpClient, data: FetchUserSpacesProps): Promise<UserSpacesResponse>;
1770
1763
 
@@ -2043,21 +2036,6 @@ interface ModerateSpaceCommentProps {
2043
2036
  }
2044
2037
  declare function moderateSpaceComment(client: SublayHttpClient, data: ModerateSpaceCommentProps): Promise<ModerationResponse>;
2045
2038
 
2046
- interface FetchDigestConfigProps {
2047
- spaceId: string;
2048
- }
2049
- declare function fetchDigestConfig(client: SublayHttpClient, data: FetchDigestConfigProps): Promise<DigestConfig>;
2050
-
2051
- interface UpdateDigestConfigProps {
2052
- spaceId: string;
2053
- digestEnabled?: boolean;
2054
- digestWebhookUrl?: string;
2055
- digestWebhookSecret?: string;
2056
- digestScheduleHour?: number;
2057
- digestTimezone?: string;
2058
- }
2059
- declare function updateDigestConfig(client: SublayHttpClient, data: UpdateDigestConfigProps): Promise<DigestConfig>;
2060
-
2061
2039
  interface ChatMessage {
2062
2040
  id: string;
2063
2041
  projectId: string;
@@ -2173,7 +2151,6 @@ declare const Spaces_declineMembership: typeof declineMembership;
2173
2151
  declare const Spaces_deleteRule: typeof deleteRule;
2174
2152
  declare const Spaces_deleteSpace: typeof deleteSpace;
2175
2153
  declare const Spaces_fetchChildSpaces: typeof fetchChildSpaces;
2176
- declare const Spaces_fetchDigestConfig: typeof fetchDigestConfig;
2177
2154
  declare const Spaces_fetchManyRules: typeof fetchManyRules;
2178
2155
  declare const Spaces_fetchManySpaces: typeof fetchManySpaces;
2179
2156
  declare const Spaces_fetchMutualSpaces: typeof fetchMutualSpaces;
@@ -2197,12 +2174,11 @@ declare const Spaces_moderateSpaceEntity: typeof moderateSpaceEntity;
2197
2174
  declare const Spaces_reorderRules: typeof reorderRules;
2198
2175
  declare const Spaces_setSpaceEntityNsfw: typeof setSpaceEntityNsfw;
2199
2176
  declare const Spaces_unbanMember: typeof unbanMember;
2200
- declare const Spaces_updateDigestConfig: typeof updateDigestConfig;
2201
2177
  declare const Spaces_updateMemberRole: typeof updateMemberRole;
2202
2178
  declare const Spaces_updateRule: typeof updateRule;
2203
2179
  declare const Spaces_updateSpace: typeof updateSpace;
2204
2180
  declare namespace Spaces {
2205
- export { Spaces_approveMembership as approveMembership, Spaces_banMember as banMember, Spaces_checkMyMembership as checkMyMembership, Spaces_checkSlugAvailability as checkSlugAvailability, Spaces_createRule as createRule, Spaces_createSpace as createSpace, Spaces_declineMembership as declineMembership, Spaces_deleteRule as deleteRule, Spaces_deleteSpace as deleteSpace, Spaces_fetchChildSpaces as fetchChildSpaces, Spaces_fetchDigestConfig as fetchDigestConfig, Spaces_fetchManyRules as fetchManyRules, Spaces_fetchManySpaces as fetchManySpaces, Spaces_fetchMutualSpaces as fetchMutualSpaces, Spaces_fetchRule as fetchRule, Spaces_fetchSpace as fetchSpace, Spaces_fetchSpaceBreadcrumb as fetchSpaceBreadcrumb, Spaces_fetchSpaceByShortId as fetchSpaceByShortId, Spaces_fetchSpaceBySlug as fetchSpaceBySlug, Spaces_fetchSpaceMembers as fetchSpaceMembers, Spaces_fetchSpaceTeam as fetchSpaceTeam, Spaces_fetchUserSpaces as fetchUserSpaces, Spaces_getSpaceConversation as getSpaceConversation, Spaces_handleCommentReport as handleCommentReport, Spaces_handleEntityReport as handleEntityReport, Spaces_handleSpaceChatReport as handleSpaceChatReport, Spaces_joinSpace as joinSpace, Spaces_leaveSpace as leaveSpace, Spaces_moderateSpaceChatMessage as moderateSpaceChatMessage, Spaces_moderateSpaceComment as moderateSpaceComment, Spaces_moderateSpaceEntity as moderateSpaceEntity, Spaces_reorderRules as reorderRules, Spaces_setSpaceEntityNsfw as setSpaceEntityNsfw, Spaces_unbanMember as unbanMember, Spaces_updateDigestConfig as updateDigestConfig, Spaces_updateMemberRole as updateMemberRole, Spaces_updateRule as updateRule, Spaces_updateSpace as updateSpace };
2181
+ export { Spaces_approveMembership as approveMembership, Spaces_banMember as banMember, Spaces_checkMyMembership as checkMyMembership, Spaces_checkSlugAvailability as checkSlugAvailability, Spaces_createRule as createRule, Spaces_createSpace as createSpace, Spaces_declineMembership as declineMembership, Spaces_deleteRule as deleteRule, Spaces_deleteSpace as deleteSpace, Spaces_fetchChildSpaces as fetchChildSpaces, Spaces_fetchManyRules as fetchManyRules, Spaces_fetchManySpaces as fetchManySpaces, Spaces_fetchMutualSpaces as fetchMutualSpaces, Spaces_fetchRule as fetchRule, Spaces_fetchSpace as fetchSpace, Spaces_fetchSpaceBreadcrumb as fetchSpaceBreadcrumb, Spaces_fetchSpaceByShortId as fetchSpaceByShortId, Spaces_fetchSpaceBySlug as fetchSpaceBySlug, Spaces_fetchSpaceMembers as fetchSpaceMembers, Spaces_fetchSpaceTeam as fetchSpaceTeam, Spaces_fetchUserSpaces as fetchUserSpaces, Spaces_getSpaceConversation as getSpaceConversation, Spaces_handleCommentReport as handleCommentReport, Spaces_handleEntityReport as handleEntityReport, Spaces_handleSpaceChatReport as handleSpaceChatReport, Spaces_joinSpace as joinSpace, Spaces_leaveSpace as leaveSpace, Spaces_moderateSpaceChatMessage as moderateSpaceChatMessage, Spaces_moderateSpaceComment as moderateSpaceComment, Spaces_moderateSpaceEntity as moderateSpaceEntity, Spaces_reorderRules as reorderRules, Spaces_setSpaceEntityNsfw as setSpaceEntityNsfw, Spaces_unbanMember as unbanMember, Spaces_updateMemberRole as updateMemberRole, Spaces_updateRule as updateRule, Spaces_updateSpace as updateSpace };
2206
2182
  }
2207
2183
 
2208
2184
  interface Collection {
@@ -2262,7 +2238,7 @@ declare function removeEntityFromCollection(client: SublayHttpClient, data: Remo
2262
2238
 
2263
2239
  interface UpdateCollectionProps {
2264
2240
  collectionId: string;
2265
- name?: string;
2241
+ name: string;
2266
2242
  }
2267
2243
  declare function updateCollection(client: SublayHttpClient, data: UpdateCollectionProps): Promise<Collection>;
2268
2244
 
@@ -2645,7 +2621,13 @@ declare namespace AppNotifications {
2645
2621
  export { AppNotifications_countUnreadNotifications as countUnreadNotifications, AppNotifications_fetchNotifications as fetchNotifications, AppNotifications_markAllNotificationsAsRead as markAllNotificationsAsRead, AppNotifications_markNotificationAsRead as markNotificationAsRead };
2646
2622
  }
2647
2623
 
2648
- type ReportTargetType = "entity" | "comment";
2624
+ type ReportTargetType = "entity" | "comment" | "message";
2625
+ /**
2626
+ * The reasons the API accepts on a report. Server-enforced — anything outside
2627
+ * this set is rejected with `report/invalid-body`. Use `other` plus `details`
2628
+ * for anything the taxonomy doesn't cover.
2629
+ */
2630
+ type ReportReason = "spam" | "inappropriateContent" | "harassment" | "misinformation" | "hateSpeech" | "violence" | "illegalActivity" | "selfHarm" | "other";
2649
2631
  type ReportStatus = "pending" | "on-hold" | "escalated" | "dismissed" | "actioned";
2650
2632
  interface UserReport {
2651
2633
  id: string;
@@ -2678,7 +2660,7 @@ interface CreateReportResponse {
2678
2660
  interface CreateReportProps {
2679
2661
  targetType: ReportTargetType;
2680
2662
  targetId: string;
2681
- reason: string;
2663
+ reason: ReportReason;
2682
2664
  details?: string;
2683
2665
  }
2684
2666
  declare function createReport(client: SublayHttpClient, data: CreateReportProps): Promise<CreateReportResponse>;
@@ -3198,8 +3180,8 @@ interface EditMessageProps {
3198
3180
  conversationId: string;
3199
3181
  messageId: string;
3200
3182
  content?: string;
3201
- /** A GIF URL, or null to clear it. */
3202
- gif?: string | null;
3183
+ /** A GIF attachment, or null to clear it. */
3184
+ gif?: GifData | null;
3203
3185
  mentions?: Mention[];
3204
3186
  metadata?: Record<string, any> | null;
3205
3187
  }
@@ -3304,18 +3286,6 @@ interface MuteConversationResponse {
3304
3286
  */
3305
3287
  declare function muteConversation(client: SublayHttpClient, data: MuteConversationProps): Promise<MuteConversationResponse>;
3306
3288
 
3307
- interface ReportMessageProps {
3308
- conversationId: string;
3309
- messageId: string;
3310
- reason: string;
3311
- details?: string;
3312
- }
3313
- interface ReportMessageResponse {
3314
- message: string;
3315
- code: string;
3316
- }
3317
- declare function reportMessage(client: SublayHttpClient, data: ReportMessageProps): Promise<ReportMessageResponse>;
3318
-
3319
3289
  declare const Chat_addMember: typeof addMember;
3320
3290
  declare const Chat_changeMemberRole: typeof changeMemberRole;
3321
3291
  declare const Chat_createDirectConversation: typeof createDirectConversation;
@@ -3334,12 +3304,11 @@ declare const Chat_listReactions: typeof listReactions;
3334
3304
  declare const Chat_markAsRead: typeof markAsRead;
3335
3305
  declare const Chat_muteConversation: typeof muteConversation;
3336
3306
  declare const Chat_removeMember: typeof removeMember;
3337
- declare const Chat_reportMessage: typeof reportMessage;
3338
3307
  declare const Chat_sendMessage: typeof sendMessage;
3339
3308
  declare const Chat_toggleReaction: typeof toggleReaction;
3340
3309
  declare const Chat_updateConversation: typeof updateConversation;
3341
3310
  declare namespace Chat {
3342
- export { Chat_addMember as addMember, Chat_changeMemberRole as changeMemberRole, Chat_createDirectConversation as createDirectConversation, Chat_createGroupConversation as createGroupConversation, Chat_deleteConversation as deleteConversation, Chat_deleteMessage as deleteMessage, Chat_editMessage as editMessage, Chat_getConversation as getConversation, Chat_getMessage as getMessage, Chat_getUnreadCount as getUnreadCount, Chat_leaveConversation as leaveConversation, Chat_listConversations as listConversations, Chat_listMembers as listMembers, Chat_listMessages as listMessages, Chat_listReactions as listReactions, Chat_markAsRead as markAsRead, Chat_muteConversation as muteConversation, Chat_removeMember as removeMember, Chat_reportMessage as reportMessage, Chat_sendMessage as sendMessage, Chat_toggleReaction as toggleReaction, Chat_updateConversation as updateConversation };
3311
+ export { Chat_addMember as addMember, Chat_changeMemberRole as changeMemberRole, Chat_createDirectConversation as createDirectConversation, Chat_createGroupConversation as createGroupConversation, Chat_deleteConversation as deleteConversation, Chat_deleteMessage as deleteMessage, Chat_editMessage as editMessage, Chat_getConversation as getConversation, Chat_getMessage as getMessage, Chat_getUnreadCount as getUnreadCount, Chat_leaveConversation as leaveConversation, Chat_listConversations as listConversations, Chat_listMembers as listMembers, Chat_listMessages as listMessages, Chat_listReactions as listReactions, Chat_markAsRead as markAsRead, Chat_muteConversation as muteConversation, Chat_removeMember as removeMember, Chat_sendMessage as sendMessage, Chat_toggleReaction as toggleReaction, Chat_updateConversation as updateConversation };
3343
3312
  }
3344
3313
 
3345
3314
  /**
@@ -3373,6 +3342,440 @@ declare namespace Push {
3373
3342
  export { Push_getNotificationPreferences as getNotificationPreferences, Push_updateNotificationPreferences as updateNotificationPreferences };
3374
3343
  }
3375
3344
 
3345
+ /**
3346
+ * Workspaces bundle interfaces (client subset). Mirrors the server's
3347
+ * `IWorkspace` / `IWorkspaceMember` / `IWorkspaceInvitation` shapes and the
3348
+ * workspace controller responses.
3349
+ *
3350
+ * `capabilities` is a CLOSED, Sublay-enforced vocabulary (cascades via reach);
3351
+ * `permissions` is opaque free-form developer strings Sublay never consumes
3352
+ * (per-node only, does NOT cascade).
3353
+ */
3354
+ type WorkspaceCapability = "view" | "invite" | "remove-member" | "edit-member-access" | "edit-member-profile" | "create-sub-workspace" | "edit-workspace";
3355
+ type WorkspaceInvitationStatus = "pending" | "accepted" | "declined" | "revoked";
3356
+ type WorkspaceAuthorityReason = "owner" | "ancestor-owner" | "member" | "reach-holder";
3357
+ type WorkspaceAuthorityReasonDetail = {
3358
+ type: "owner" | "member";
3359
+ viaWorkspaceId?: never;
3360
+ } | {
3361
+ type: "ancestor-owner" | "reach-holder";
3362
+ viaWorkspaceId: string;
3363
+ };
3364
+ interface Workspace {
3365
+ id: string;
3366
+ name: string;
3367
+ metadata: Record<string, any>;
3368
+ ownerId: string;
3369
+ parentWorkspaceId: string | null;
3370
+ depth: number;
3371
+ inheritsFromParent: boolean;
3372
+ createdAt: string;
3373
+ updatedAt: string;
3374
+ memberCount?: number;
3375
+ }
3376
+ interface WorkspaceMember {
3377
+ id: string;
3378
+ workspaceId: string;
3379
+ userId: string;
3380
+ capabilities: WorkspaceCapability[];
3381
+ permissions: string[];
3382
+ rank: number;
3383
+ title: string | null;
3384
+ metadata: Record<string, any>;
3385
+ joinedAt: string;
3386
+ createdAt: string;
3387
+ }
3388
+ interface WorkspaceInvitation {
3389
+ id: string;
3390
+ workspaceId: string;
3391
+ invitedBy: string;
3392
+ userId: string | null;
3393
+ email: string | null;
3394
+ capabilities: WorkspaceCapability[];
3395
+ permissions: string[];
3396
+ rank: number;
3397
+ title: string | null;
3398
+ status: WorkspaceInvitationStatus;
3399
+ expiresAt: string;
3400
+ createdAt: string;
3401
+ updatedAt: string;
3402
+ }
3403
+ interface WorkspaceRosterReason {
3404
+ type: "owner" | "member" | "ancestor-owner" | "reach-holder" | "descendant-member";
3405
+ rank?: number;
3406
+ capabilities?: WorkspaceCapability[];
3407
+ permissions?: string[];
3408
+ title?: string | null;
3409
+ metadata?: Record<string, any>;
3410
+ viaWorkspaceId?: string;
3411
+ workspaceId?: string;
3412
+ }
3413
+ interface WorkspaceRosterEntry {
3414
+ user: User;
3415
+ reasons: WorkspaceRosterReason[];
3416
+ }
3417
+ interface WorkspaceRosterResponse {
3418
+ data: WorkspaceRosterEntry[];
3419
+ total: number;
3420
+ }
3421
+ interface WorkspaceRosterCountsResponse {
3422
+ counts: {
3423
+ owner: number;
3424
+ member: number;
3425
+ ancestorOwner: number;
3426
+ reachHolder: number;
3427
+ descendantMember: number;
3428
+ };
3429
+ total: number;
3430
+ distinctUsers: number;
3431
+ }
3432
+ /**
3433
+ * The `user` carried by a standing read. Normally the full user record, but the
3434
+ * server falls back to `{ id }` alone when the user row is gone (a deleted user
3435
+ * with a lingering membership row is a reachable case), so every field except
3436
+ * `id` may be absent.
3437
+ */
3438
+ type WorkspaceStandingUser = Pick<User, "id"> & Partial<Omit<User, "id">>;
3439
+ interface WorkspaceMemberStanding {
3440
+ user: WorkspaceStandingUser;
3441
+ reasons: WorkspaceAuthorityReasonDetail[];
3442
+ capabilities?: WorkspaceCapability[];
3443
+ permissions?: string[];
3444
+ rank?: number | null;
3445
+ title: string | null;
3446
+ metadata: Record<string, any>;
3447
+ }
3448
+ interface WorkspaceAuthority {
3449
+ reasons: WorkspaceAuthorityReasonDetail[];
3450
+ capabilities: WorkspaceCapability[];
3451
+ permissions: string[];
3452
+ rank: number | null;
3453
+ }
3454
+ /**
3455
+ * One descendant the subtree sweep did NOT clear, where the target user still
3456
+ * holds a direct membership.
3457
+ *
3458
+ * `id` / `name` are masked TOGETHER: an entry the acting user may see carries
3459
+ * both, and one they may not carries `null` for both — the sweep reports THAT a
3460
+ * membership survived without disclosing the existence or name of a sealed
3461
+ * sub-workspace the actor has no authority over (the same sealing fence the
3462
+ * descendant roster read applies). Modelled as a discriminated union so a
3463
+ * `null` check on `id` narrows `name` too.
3464
+ */
3465
+ type SkippedWorkspace = {
3466
+ id: string;
3467
+ name: string;
3468
+ /** Why it was skipped. `out-of-reach`: the actor's authority does not extend there. */
3469
+ reason: "out-of-reach";
3470
+ } | {
3471
+ id: null;
3472
+ name: null;
3473
+ /** Why it was skipped. `out-of-reach`: the actor's authority does not extend there. */
3474
+ reason: "out-of-reach";
3475
+ };
3476
+ interface RemoveWorkspaceMemberFromSubtreeResponse {
3477
+ removedCount: number;
3478
+ removed: {
3479
+ workspaceId: string;
3480
+ userId: string;
3481
+ }[];
3482
+ /**
3483
+ * How many descendant memberships the target RETAINED because the sweep could
3484
+ * not reach them. Always `0` for an owner / ancestor-owner / privileged key.
3485
+ * A non-zero value means the offboarding is PARTIAL — never conclude a user is
3486
+ * fully removed from `removedCount` alone.
3487
+ */
3488
+ skippedCount: number;
3489
+ /** One entry per retained membership; `skippedCount === skipped.length`. */
3490
+ skipped: SkippedWorkspace[];
3491
+ }
3492
+
3493
+ interface CreateWorkspaceProps {
3494
+ name: string;
3495
+ metadata?: Record<string, any>;
3496
+ parentWorkspaceId?: string | null;
3497
+ }
3498
+ /**
3499
+ * Create a root or child workspace. The creator (the bearer-token user) becomes
3500
+ * the owner. Root creation requires a verified email.
3501
+ */
3502
+ declare function createWorkspace(client: SublayHttpClient, data: CreateWorkspaceProps): Promise<Workspace>;
3503
+
3504
+ interface FetchWorkspaceProps {
3505
+ workspaceId: string;
3506
+ include?: string;
3507
+ }
3508
+ declare function fetchWorkspace(client: SublayHttpClient, data: FetchWorkspaceProps): Promise<Workspace>;
3509
+
3510
+ interface FetchManyWorkspacesProps {
3511
+ page?: number;
3512
+ limit?: number;
3513
+ include?: string;
3514
+ }
3515
+ /**
3516
+ * List the bearer-token user's direct-membership + owned workspaces. The actor
3517
+ * is derived from the token — no `userId` is sent.
3518
+ */
3519
+ declare function fetchManyWorkspaces(client: SublayHttpClient, data?: FetchManyWorkspacesProps): Promise<PaginatedResponse<Workspace>>;
3520
+
3521
+ interface UpdateWorkspaceProps {
3522
+ workspaceId: string;
3523
+ name?: string;
3524
+ metadata?: Record<string, any>;
3525
+ }
3526
+ /**
3527
+ * Edit a workspace's name / metadata. Requires the `edit-workspace` capability
3528
+ * (or ownership). The actor is the bearer-token user — no `userId` is sent.
3529
+ */
3530
+ declare function updateWorkspace(client: SublayHttpClient, data: UpdateWorkspaceProps): Promise<Workspace>;
3531
+
3532
+ interface UpdateWorkspaceInheritFlagProps {
3533
+ workspaceId: string;
3534
+ inheritsFromParent: boolean;
3535
+ }
3536
+ /**
3537
+ * Flip whether capabilities held on an ancestor "reach" into this workspace.
3538
+ * Owner-only in both directions (own owner or an ancestor owner), and blocked
3539
+ * (403 `workspace/inherit-enforced`) when the project enforces its default.
3540
+ * The actor is the bearer-token user — no `userId` is sent.
3541
+ */
3542
+ declare function updateWorkspaceInheritFlag(client: SublayHttpClient, data: UpdateWorkspaceInheritFlagProps): Promise<Workspace>;
3543
+
3544
+ interface DeleteWorkspaceProps {
3545
+ workspaceId: string;
3546
+ }
3547
+ interface DeleteWorkspaceResponse {
3548
+ message: string;
3549
+ }
3550
+ /**
3551
+ * Owner-only delete (own owner or an ancestor owner). Cascades the whole
3552
+ * subtree transactionally. The actor is the bearer-token user — no `userId`
3553
+ * body is sent.
3554
+ */
3555
+ declare function deleteWorkspace(client: SublayHttpClient, data: DeleteWorkspaceProps): Promise<DeleteWorkspaceResponse>;
3556
+
3557
+ interface TransferWorkspaceOwnershipProps {
3558
+ workspaceId: string;
3559
+ newOwnerId: string;
3560
+ previousOwnerDisposition?: "demote" | "remove";
3561
+ previousOwnerRank?: number;
3562
+ previousOwnerCapabilities?: WorkspaceCapability[];
3563
+ }
3564
+ /**
3565
+ * Hand the workspace to a new owner. Owner-only (own owner or an ancestor
3566
+ * owner). The actor is the bearer-token user — no `userId` is sent;
3567
+ * `newOwnerId` addresses the TARGET, not the actor.
3568
+ */
3569
+ declare function transferWorkspaceOwnership(client: SublayHttpClient, data: TransferWorkspaceOwnershipProps): Promise<Workspace>;
3570
+
3571
+ interface FetchWorkspaceMembersProps {
3572
+ workspaceId: string;
3573
+ include?: string;
3574
+ countOnly?: boolean;
3575
+ }
3576
+ /**
3577
+ * Unified roster read — one entry per distinct user, each with a `reasons`
3578
+ * array. Always returned in full (never paginated). With `countOnly=true` the
3579
+ * shape is `WorkspaceRosterCountsResponse` instead. Actor from the token.
3580
+ */
3581
+ declare function fetchWorkspaceMembers(client: SublayHttpClient, data: FetchWorkspaceMembersProps): Promise<WorkspaceRosterResponse | WorkspaceRosterCountsResponse>;
3582
+
3583
+ interface FetchWorkspaceMemberStandingProps {
3584
+ workspaceId: string;
3585
+ targetUserId: string;
3586
+ }
3587
+ /**
3588
+ * Read one user's resolved standing on a workspace (`reasons`, `capabilities`,
3589
+ * `permissions`, `rank`, `title`, `metadata`).
3590
+ */
3591
+ declare function fetchWorkspaceMemberStanding(client: SublayHttpClient, data: FetchWorkspaceMemberStandingProps): Promise<WorkspaceMemberStanding>;
3592
+
3593
+ interface UpdateWorkspaceMemberProps {
3594
+ workspaceId: string;
3595
+ targetUserId: string;
3596
+ capabilities?: WorkspaceCapability[];
3597
+ permissions?: string[];
3598
+ rank?: number;
3599
+ title?: string | null;
3600
+ metadata?: Record<string, any>;
3601
+ }
3602
+ /**
3603
+ * Edit a member's grant / profile. Powerful fields need `edit-member-access`
3604
+ * plus rank + no-escalation rules; cosmetic fields need only
3605
+ * `edit-member-profile`. No `userId` is sent — the actor comes from the token.
3606
+ */
3607
+ declare function updateWorkspaceMember(client: SublayHttpClient, data: UpdateWorkspaceMemberProps): Promise<WorkspaceMember>;
3608
+
3609
+ interface RemoveWorkspaceMemberProps {
3610
+ workspaceId: string;
3611
+ targetUserId: string;
3612
+ }
3613
+ /**
3614
+ * Remove a member from this workspace. Requires the `remove-member` capability
3615
+ * and is rank-bounded. The workspace owner cannot be removed (409
3616
+ * `workspace/sole-owner`) — transfer ownership first. No `userId` body is sent;
3617
+ * the actor comes from the token.
3618
+ */
3619
+ declare function removeWorkspaceMember(client: SublayHttpClient, data: RemoveWorkspaceMemberProps): Promise<void>;
3620
+
3621
+ interface LeaveWorkspaceProps {
3622
+ workspaceId: string;
3623
+ }
3624
+ /**
3625
+ * The bearer-token user leaves this workspace — removes THEIR OWN direct
3626
+ * membership on THIS node only (owning a child is unaffected). An owner cannot
3627
+ * leave (409 `workspace/sole-owner`); transfer or delete first. No `userId` is
3628
+ * sent — the server derives the leaver from the token.
3629
+ */
3630
+ declare function leaveWorkspace(client: SublayHttpClient, data: LeaveWorkspaceProps): Promise<void>;
3631
+
3632
+ interface RemoveWorkspaceMemberFromSubtreeProps {
3633
+ workspaceId: string;
3634
+ targetUserId: string;
3635
+ }
3636
+ /**
3637
+ * Removes the target user's direct memberships on this workspace and every
3638
+ * descendant. Requires `remove-member` (rank-bounded per node). Blocks (409
3639
+ * `workspace/owns-descendants`) with a report if the user OWNS any descendant
3640
+ * workspace — transfer or delete those first. The actor comes from the token.
3641
+ *
3642
+ * A NON-owner's sweep can be PARTIAL: it stops at sealed sub-workspaces. Check
3643
+ * `skippedCount` / `skipped` before treating the user as fully offboarded.
3644
+ */
3645
+ declare function removeWorkspaceMemberFromSubtree(client: SublayHttpClient, data: RemoveWorkspaceMemberFromSubtreeProps): Promise<RemoveWorkspaceMemberFromSubtreeResponse>;
3646
+
3647
+ interface CreateWorkspaceInviteProps {
3648
+ workspaceId: string;
3649
+ email?: string;
3650
+ userId?: string;
3651
+ username?: string;
3652
+ capabilities?: WorkspaceCapability[];
3653
+ permissions?: string[];
3654
+ rank: number;
3655
+ title?: string | null;
3656
+ }
3657
+ /**
3658
+ * Create an invitation (requires the `invite` capability on the workspace). The
3659
+ * inviter is the bearer-token user.
3660
+ */
3661
+ declare function createWorkspaceInvite(client: SublayHttpClient, data: CreateWorkspaceInviteProps): Promise<WorkspaceInvitation>;
3662
+
3663
+ interface FetchWorkspaceInvitesProps {
3664
+ workspaceId: string;
3665
+ }
3666
+ interface FetchWorkspaceInvitesResponse {
3667
+ data: WorkspaceInvitation[];
3668
+ }
3669
+ /**
3670
+ * List a workspace's LIVE pending invites (`status='pending' AND expiresAt >
3671
+ * now`). Requires the `invite` capability (or owner). Always returned in full —
3672
+ * this list is deliberately unpaginated.
3673
+ *
3674
+ * This is the OUTBOX read — invites this workspace ISSUED. For the invites
3675
+ * addressed TO the caller, use `fetchMyWorkspaceInvites`.
3676
+ */
3677
+ declare function fetchWorkspaceInvites(client: SublayHttpClient, data: FetchWorkspaceInvitesProps): Promise<FetchWorkspaceInvitesResponse>;
3678
+
3679
+ interface RevokeWorkspaceInviteProps {
3680
+ workspaceId: string;
3681
+ inviteId: string;
3682
+ }
3683
+ interface RevokeWorkspaceInviteResponse {
3684
+ success: boolean;
3685
+ }
3686
+ /**
3687
+ * Revoke a pending invitation. Requires the `invite` capability (or owner).
3688
+ * Note the verb-suffixed POST route — this is not a `DELETE`.
3689
+ */
3690
+ declare function revokeWorkspaceInvite(client: SublayHttpClient, data: RevokeWorkspaceInviteProps): Promise<RevokeWorkspaceInviteResponse>;
3691
+
3692
+ interface ResendWorkspaceInviteProps {
3693
+ workspaceId: string;
3694
+ inviteId: string;
3695
+ }
3696
+ /**
3697
+ * Resend / refresh a pending invitation (valid on any `pending` invite, even one
3698
+ * past `expiresAt` — resets a 14-day expiry and resends the email). A terminal
3699
+ * invite (accepted/declined/revoked) → 409. Requires `invite` (or owner).
3700
+ */
3701
+ declare function resendWorkspaceInvite(client: SublayHttpClient, data: ResendWorkspaceInviteProps): Promise<WorkspaceInvitation>;
3702
+
3703
+ interface AcceptWorkspaceInviteProps {
3704
+ inviteId: string;
3705
+ }
3706
+ interface AcceptWorkspaceInviteResponse {
3707
+ success: boolean;
3708
+ workspaceId: string;
3709
+ }
3710
+ /**
3711
+ * Accept an invitation — identity-matched to the bearer-token user + verified
3712
+ * email required. Non-secret id. Idempotent when already a member/owner.
3713
+ */
3714
+ declare function acceptWorkspaceInvite(client: SublayHttpClient, data: AcceptWorkspaceInviteProps): Promise<AcceptWorkspaceInviteResponse>;
3715
+
3716
+ interface DeclineWorkspaceInviteProps {
3717
+ inviteId: string;
3718
+ }
3719
+ interface DeclineWorkspaceInviteResponse {
3720
+ success: boolean;
3721
+ }
3722
+ /**
3723
+ * Decline an invitation — identity-matched to the bearer-token user, and
3724
+ * verified-email-gated (the same gate as accept, so an unverified squatter on
3725
+ * someone else's address cannot burn their invite). An unverified decline
3726
+ * returns `403 workspace/email-not-verified`.
3727
+ */
3728
+ declare function declineWorkspaceInvite(client: SublayHttpClient, data: DeclineWorkspaceInviteProps): Promise<DeclineWorkspaceInviteResponse>;
3729
+
3730
+ interface FetchMyWorkspaceInvitesResponse {
3731
+ data: WorkspaceInvitation[];
3732
+ }
3733
+ /**
3734
+ * The bearer-token user's LIVE pending invites (`status='pending' AND expiresAt
3735
+ * > now`), matched by `userId` from the token. Surfacing is NOT
3736
+ * verification-gated (the verified check applies when the user ACTS on an
3737
+ * invite — accept or decline).
3738
+ *
3739
+ * This is the INBOX read — invites addressed TO the caller. For the invites a
3740
+ * workspace has ISSUED, use `fetchWorkspaceInvites`.
3741
+ */
3742
+ declare function fetchMyWorkspaceInvites(client: SublayHttpClient): Promise<FetchMyWorkspaceInvitesResponse>;
3743
+
3744
+ interface FetchWorkspaceAuthorityProps {
3745
+ workspaceId: string;
3746
+ }
3747
+ /**
3748
+ * Authority-as-a-service read — the bearer-token user's resolved standing
3749
+ * (`{ reasons, capabilities, permissions, rank }`) on the workspace. A
3750
+ * permission check is a one-line `.includes()` on the result.
3751
+ */
3752
+ declare function fetchWorkspaceAuthority(client: SublayHttpClient, data: FetchWorkspaceAuthorityProps): Promise<WorkspaceAuthority>;
3753
+
3754
+ declare const Workspaces_acceptWorkspaceInvite: typeof acceptWorkspaceInvite;
3755
+ declare const Workspaces_createWorkspace: typeof createWorkspace;
3756
+ declare const Workspaces_createWorkspaceInvite: typeof createWorkspaceInvite;
3757
+ declare const Workspaces_declineWorkspaceInvite: typeof declineWorkspaceInvite;
3758
+ declare const Workspaces_deleteWorkspace: typeof deleteWorkspace;
3759
+ declare const Workspaces_fetchManyWorkspaces: typeof fetchManyWorkspaces;
3760
+ declare const Workspaces_fetchMyWorkspaceInvites: typeof fetchMyWorkspaceInvites;
3761
+ declare const Workspaces_fetchWorkspace: typeof fetchWorkspace;
3762
+ declare const Workspaces_fetchWorkspaceAuthority: typeof fetchWorkspaceAuthority;
3763
+ declare const Workspaces_fetchWorkspaceInvites: typeof fetchWorkspaceInvites;
3764
+ declare const Workspaces_fetchWorkspaceMemberStanding: typeof fetchWorkspaceMemberStanding;
3765
+ declare const Workspaces_fetchWorkspaceMembers: typeof fetchWorkspaceMembers;
3766
+ declare const Workspaces_leaveWorkspace: typeof leaveWorkspace;
3767
+ declare const Workspaces_removeWorkspaceMember: typeof removeWorkspaceMember;
3768
+ declare const Workspaces_removeWorkspaceMemberFromSubtree: typeof removeWorkspaceMemberFromSubtree;
3769
+ declare const Workspaces_resendWorkspaceInvite: typeof resendWorkspaceInvite;
3770
+ declare const Workspaces_revokeWorkspaceInvite: typeof revokeWorkspaceInvite;
3771
+ declare const Workspaces_transferWorkspaceOwnership: typeof transferWorkspaceOwnership;
3772
+ declare const Workspaces_updateWorkspace: typeof updateWorkspace;
3773
+ declare const Workspaces_updateWorkspaceInheritFlag: typeof updateWorkspaceInheritFlag;
3774
+ declare const Workspaces_updateWorkspaceMember: typeof updateWorkspaceMember;
3775
+ declare namespace Workspaces {
3776
+ export { Workspaces_acceptWorkspaceInvite as acceptWorkspaceInvite, Workspaces_createWorkspace as createWorkspace, Workspaces_createWorkspaceInvite as createWorkspaceInvite, Workspaces_declineWorkspaceInvite as declineWorkspaceInvite, Workspaces_deleteWorkspace as deleteWorkspace, Workspaces_fetchManyWorkspaces as fetchManyWorkspaces, Workspaces_fetchMyWorkspaceInvites as fetchMyWorkspaceInvites, Workspaces_fetchWorkspace as fetchWorkspace, Workspaces_fetchWorkspaceAuthority as fetchWorkspaceAuthority, Workspaces_fetchWorkspaceInvites as fetchWorkspaceInvites, Workspaces_fetchWorkspaceMemberStanding as fetchWorkspaceMemberStanding, Workspaces_fetchWorkspaceMembers as fetchWorkspaceMembers, Workspaces_leaveWorkspace as leaveWorkspace, Workspaces_removeWorkspaceMember as removeWorkspaceMember, Workspaces_removeWorkspaceMemberFromSubtree as removeWorkspaceMemberFromSubtree, Workspaces_resendWorkspaceInvite as resendWorkspaceInvite, Workspaces_revokeWorkspaceInvite as revokeWorkspaceInvite, Workspaces_transferWorkspaceOwnership as transferWorkspaceOwnership, Workspaces_updateWorkspace as updateWorkspace, Workspaces_updateWorkspaceInheritFlag as updateWorkspaceInheritFlag, Workspaces_updateWorkspaceMember as updateWorkspaceMember };
3777
+ }
3778
+
3376
3779
  /**
3377
3780
  * Custom-table types for the `/db` surface (row ops only — the js-sdk holds no
3378
3781
  * service key, so it carries no table-management/DDL surface).
@@ -3455,6 +3858,7 @@ declare class SublayClient {
3455
3858
  oauth: BoundModule<typeof OAuth>;
3456
3859
  chat: BoundModule<typeof Chat>;
3457
3860
  push: BoundModule<typeof Push>;
3861
+ workspaces: BoundModule<typeof Workspaces>;
3458
3862
  private constructor();
3459
3863
  static init(config: ClientConfig): Promise<SublayClient>;
3460
3864
  /**
@@ -3469,4 +3873,4 @@ declare class SublayClient {
3469
3873
  clearTokens(): void;
3470
3874
  }
3471
3875
 
3472
- export { type AuthTokens, type BulkDeleteProps, type BulkDeleteResult, type ClientConfig, type DbFilter, type DbFilterOperator, type DeleteResult, MUTE_DURATIONS, type MuteConversationProps, type MuteConversationResponse, type MuteDuration, type NotificationPreferences, PUSH_EVENT_TYPES, type PaginatedResponse, type PaginationMetadata, type PushEventType, type SpaceReputationContextParams, type SpaceReputationUserParams, SublayClient, type TableAccessor, type TableQuery, type TableRow, type UpdateNotificationPreferencesProps, type UserSearchParams };
3876
+ export { type AuthTokens, type BulkDeleteProps, type BulkDeleteResult, type ClientConfig, type DbFilter, type DbFilterOperator, type DeleteResult, MUTE_DURATIONS, type MuteConversationProps, type MuteConversationResponse, type MuteDuration, type NotificationPreferences, PUSH_EVENT_TYPES, type PaginatedResponse, type PaginationMetadata, type PushEventType, type RemoveWorkspaceMemberFromSubtreeResponse, type SkippedWorkspace, type SpaceReputationContextParams, type SpaceReputationUserParams, SublayClient, type TableAccessor, type TableQuery, type TableRow, type UpdateNotificationPreferencesProps, type UserSearchParams, type Workspace, type WorkspaceAuthority, type WorkspaceAuthorityReason, type WorkspaceAuthorityReasonDetail, type WorkspaceCapability, type WorkspaceInvitation, type WorkspaceInvitationStatus, type WorkspaceMember, type WorkspaceMemberStanding, type WorkspaceRosterCountsResponse, type WorkspaceRosterEntry, type WorkspaceRosterReason, type WorkspaceRosterResponse, type WorkspaceStandingUser };
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ import * as Storage from "./modules/storage";
15
15
  import * as OAuth from "./modules/oauth";
16
16
  import * as Chat from "./modules/chat";
17
17
  import * as Push from "./modules/push";
18
+ import * as Workspaces from "./modules/workspaces";
18
19
  import { TableAccessor, TableRow } from "./interfaces/Table";
19
20
  type BoundModule<T extends Record<string, (client: SublayHttpClient, ...args: any[]) => any>> = {
20
21
  [K in keyof T]: (...args: Parameters<T[K]> extends [any, ...infer R] ? R : never) => ReturnType<T[K]>;
@@ -37,6 +38,7 @@ export declare class SublayClient {
37
38
  oauth: BoundModule<typeof OAuth>;
38
39
  chat: BoundModule<typeof Chat>;
39
40
  push: BoundModule<typeof Push>;
41
+ workspaces: BoundModule<typeof Workspaces>;
40
42
  private constructor();
41
43
  static init(config: ClientConfig): Promise<SublayClient>;
42
44
  /**
@@ -54,6 +56,7 @@ export type { ClientConfig, AuthTokens } from "./core/client";
54
56
  export type { PaginatedResponse, PaginationMetadata, } from "./interfaces/IPaginatedResponse";
55
57
  export type { SpaceReputationContextParams, SpaceReputationUserParams, } from "./interfaces/SpaceReputation";
56
58
  export type { UserSearchParams } from "./interfaces/UserSearch";
59
+ export type { Workspace, WorkspaceMember, WorkspaceInvitation, WorkspaceCapability, WorkspaceInvitationStatus, WorkspaceAuthorityReason, WorkspaceAuthorityReasonDetail, WorkspaceRosterReason, WorkspaceRosterEntry, WorkspaceRosterResponse, WorkspaceRosterCountsResponse, WorkspaceStandingUser, WorkspaceMemberStanding, WorkspaceAuthority, RemoveWorkspaceMemberFromSubtreeResponse, SkippedWorkspace, } from "./interfaces/Workspace";
57
60
  export { PUSH_EVENT_TYPES, MUTE_DURATIONS } from "./interfaces/Push";
58
61
  export type { PushEventType, MuteDuration, NotificationPreferences, } from "./interfaces/Push";
59
62
  export type { UpdateNotificationPreferencesProps } from "./modules/push/updateNotificationPreferences";