Skip to content

List & Pagination Types

Type definitions for pagination and filtering.

ListOptions

Options for listing resources.

typescript
interface ListOptions {
  page?: {
    number?: number;
    size?: number;
  };
  cursor?: string;
  limit?: number;
  filter?: Record<string, FilterValue>;
  sort?: string;
  include?: string[];
  fields?: Record<string, string[]>;
}

Parameters

ParameterTypeDescription
page.numbernumberPage number (1-indexed)
page.sizenumberItems per page
cursorstringCursor for cursor-based pagination
limitnumberMaximum items to return
filterRecord<string, FilterValue>Filter criteria
sortstringSort field (prefix with - for descending)
includestring[]Related resources to include
fieldsRecord<string, string[]>Sparse fieldsets

ListResponse

Response structure for list operations.

typescript
interface ListResponse<T> {
  data: T[];
  meta: PaginationMeta;
  links: PaginationLinks;
  included?: unknown[];
}

PaginationMeta

Metadata about the current page.

typescript
interface PaginationMeta {
  totalCount: number;
  pageCount: number;
  currentPage: number;
  perPage: number;
  hasMore?: boolean;
  nextCursor?: string;
}

Links for pagination navigation.

typescript
interface PaginationLinks {
  self: string;
  first: string;
  last: string;
  next?: string;
  prev?: string;
}

FilterOperator

Available filter operators.

typescript
type FilterOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'like';

FilterValue

Filter value types.

typescript
type FilterValue = 
  | string 
  | number 
  | boolean 
  | Date 
  | string[]
  | { [K in FilterOperator]?: string | number | boolean | Date | string[] };

Usage Examples

Basic Pagination

typescript
const response = await client.risks.list({
  page: { number: 1, size: 25 }
});

console.log(`Page ${response.meta.currentPage} of ${response.meta.pageCount}`);
console.log(`Total: ${response.meta.totalCount}`);

Filtering

typescript
// Simple filter
const response = await client.risks.list({
  filter: { status: 'active' }
});

// Filter with operator
const response = await client.risks.list({
  filter: { 
    severity: { in: ['high', 'critical'] },
    createdAt: { gte: '2024-01-01' }
  }
});

Sorting

typescript
// Ascending
const response = await client.risks.list({
  sort: 'createdAt'
});

// Descending
const response = await client.risks.list({
  sort: '-createdAt'
});
typescript
const response = await client.risks.list({
  include: ['controls', 'owner']
});

Released under the MIT License.