Common Types
Shared SDK types for paginated responses and client configuration.
Paginated<T>
Some endpoints return a long list in smaller pages. Paginated<T> describes one page. The T identifies the item type in the list. For example, the data array in Paginated<Notification> contains notifications.
interface Paginated<T> {
data: T[]
has_more: boolean
cursor?: string
total_count?: number
}Field reference
| Field | Type | Description |
|---|---|---|
data | T[] | The current page of results. |
has_more | boolean | true if there are more pages available. |
cursor | string? | A server-generated bookmark to pass in the next request. Do not change it. |
total_count | number? | Total matching items across all pages (not always returned). |
Usage
import type { Paginated } from '@packbase/sdk-ts'
async function loadPage(cursor?: string): Promise<Paginated<Notification>> {
return pb.inbox.fetch({ limit: 50, cursor })
}
let page = await loadPage()
while (page.has_more) {
page = await loadPage(page.cursor)
}PackbaseSDKConfig
This is the structure of the optional object that you pass to new PackbaseSDK(...). Each property has a ?. Thus, you can omit properties that you do not require. You can also omit the object.
interface PackbaseSDKConfig {
/**
* Base URL of the Packbase API, without a trailing slash.
* @default 'https://vgs.packbase.app'
*/
baseUrl?: string
/**
* Clerk JWT or API key.
* When set, the SDK sends Authorization: Bearer <apiKey> and disables cookies.
* When omitted, the SDK uses credentials: 'include' (browser session cookie).
*/
apiKey?: string
/** Disable the constructor's automatic `pb.me()` request. @default true */
autoLogin?: boolean
}Examples
// Default (cookie auth, production API)
const pb = new PackbaseSDK()
// API key auth
const pb = new PackbaseSDK({ apiKey: process.env.PACKBASE_KEY })
// Custom base URL (staging or local dev)
const pb = new PackbaseSDK({
apiKey: 'my-key',
baseUrl: 'http://localhost:3001',
})The SDK does not maintain its own response cache. Add response caching in your application's data layer when needed.
The default value of autoLogin is true. Set it to false for a public-only client. The exported SDK interface is authoritative. The documentation does not specify resources that PackbaseSDK does not export.
RequestOptions
Read and write methods accept shared request controls. Operation-specific option types extend this shape.
interface RequestOptions {
signal?: AbortSignal
}signal cancels native fetches and howl polling.
Import
import type { Paginated, PackbaseSDKConfig } from '@packbase/sdk-ts'