Pack
TypeScript shapes for packs, members, roles, lists, and updates.
Pack
Pack describes a Packbase community that the API returns. Optional fields end in ?. These fields can be absent because of the endpoint or authentication state.
interface Pack {
id: string
display_name: string
about?: { bio?: string; flair?: string }
images?: { avatar?: string; header?: string }
owner_id?: string
membership?: {
id: number
user_id: string
permissions: number
}
statistics?: {
members: number
heartbeat?: number
}
created_at: string
}The list endpoint wraps its array in PackList so it can return visibility information beside the packs. It also omits the per-pack heartbeat field:
interface PackList {
packs: Pack[]
hidden: number
total_count?: number
}pb.packs.list({ search }) is all-at-once; the SDK does not expose a continuation flag without a usable continuation parameter.
PackMember
extends Profile means that a PackMember has the standard profile fields and membership-specific fields:
interface PackMember extends Profile {
membership_id: number
joined_at: string
permissions: number
online?: boolean
last_online?: string
roles?: PackRoleSummary[]
}Roles and permissions
Permissions are bit flags. One number contains multiple Boolean permissions. Use the exported PackPermissionBits values. Combine them with the bitwise OR operator (|). Do not use hard-coded totals.
interface PackRole {
id: string
tenant_id: string
name: string
permissions: number
created_at: string
updated_at: string
}const PackPermissionBits = {
Owner: 1,
Administrator: 2,
BanMembers: 4,
KickMembers: 8,
ManageRoles: 16,
DeleteHowls: 128,
CreateHowls: 256,
ManagePack: 512,
PinHowls: 1024,
} as constCustom roles cannot carry the Owner bit.
For example, PackPermissionBits.BanMembers | PackPermissionBits.KickMembers creates the permission number for a role that can do both.
Create and edit input
interface PackCreateInput {
display_name: string
description: string
}
interface PackEditInput {
display_name?: string
about?: { bio?: string; flair?: string }
images?: { header?: string; avatar?: string }
}The edit endpoint returns PackUpdateResult. This type matches the database update result, not a formatted Pack. To get the standard response structure after an edit, fetch the pack again.
Import
import type {
Pack,
PackList,
PackMember,
PackRole,
PackRoleInput,
PackRoleSummary,
PackCreateInput,
PackEditInput,
PackUpdateResult,
PackSetting,
} from '@packbase/sdk-ts'