/** * Shapes shared by every module. Declared here rather than imported from * `@crm/contracts` so the published package has no private dependencies; they * are kept in step with the zod schemas in `packages/contracts/src/common.ts`. */ /** A 24-character hex MongoDB id. Aliased for readability, not enforced. */ export type ObjectId = string; /** An ISO-8601 timestamp string, e.g. `2026-03-14T09:21:55.412Z`. */ export type IsoDate = string; /** An untyped JSON object, as a `Record`. */ export type JsonObject = Record; /** * Cursor pagination. Used by the two endpoints that page through rows written * by the platform rather than by a caller: contact notes and audience webhooks. */ export interface PageQuery { /** 1..100, default 50. */ limit: number; /** Opaque marker from the previous page's `nextCursor`. Omit for the first page. */ cursor?: string; } export interface Page { data: T[]; /** `null` on the last page. */ nextCursor: string | null; } /** * Offset pagination with free-text search, used by every other list endpoint. * Which fields `search` matches is per resource and documented with it. */ export interface ListQuery { /** 1-based, default 1. */ page: number; /** Rows per page, 1..100, default 25. */ rows: number; /** Trimmed, 1..120 characters. Omit for no search. */ search?: string; } export interface PaginationMeta { page: number; rows: number; /** Rows matching the filter, across all pages. */ total: number; /** Number of pages for `total` at `rows` per page; at least 1. */ pages: number; } export interface Paginated { data: T[]; pagination: PaginationMeta; } /** * Every list method takes its query as a partial: the server applies the * defaults above for anything left out. */ export type QueryOf = Partial;