import type { HttpErrorTransformer, ResponseAs } from "./http-client"; /** * Environment for the API. * * @typedef {'dev' | 'prod' | string} Environment */ export type Environment = "dev" | "prod" | string; /** * Configuration object for the BaseApi class. * * @typedef {Object} Config * @property {string} [apiKey] - API key. * @property {Environment} [environment='prod'] - Environment for the API (e.g. 'dev', 'prod'). */ export interface Config { apiKey?: string; environment?: Environment; headers?: Record; verbose?: boolean; responseAs?: ResponseAs; /** * Optional hook to centrally observe or transform request failures — both * non-2xx responses (as an {@link HttpError}) and native fetch/network * rejections. Return a replacement error to throw, return the original error * to preserve it, or return `undefined` to rethrow it unchanged. With no * transformer configured, errors propagate exactly as before. * * The SDK only supplies the mechanism; the consuming application decides * whether a given failure is local, authentication-related, retryable, or * fatal. A 500, for instance, is not treated as application-fatal here. */ errorTransformer?: HttpErrorTransformer; /** * Optional `fetch` implementation, useful for testing and non-browser * runtimes. Defaults to `globalThis.fetch`. */ fetch?: typeof globalThis.fetch; } export interface ApiRecordsV2 extends PaginationMetadata { records: T[]; } export interface ApiRecords { records: T[]; } export interface MonetaryAmount { value: { amount: number; currency: { code: CurrencyCode; }; }; microCentsUsd: number; } type CurrencyCode = "USD"; export interface PaginationMetadata { prev_page: number | null; current_page: number; next_page: number | null; total_records: number; total_pages: number; } /** * A value that can be rendered into a query string. * * Arrays are repeated (`?tag=a&tag=b`) rather than joined, matching how the * backend's `OptionalMultiQueryParamDecoderMatcher` reads them. */ export type QueryValue = string | number | boolean | null | undefined | Array; /** * Constrains a params type's *values* to what a query string can express, without * requiring an index signature. * * This is a homomorphic mapped type, so it preserves optional modifiers and maps * only over `P`'s own keys. That's the difference that matters: a plain interface * satisfies it, whereas `Record` requires an index signature that * TypeScript never gives an interface — and an index signature would also disable * excess-property checking, silently accepting misspelled parameter names. */ export type QueryParamsOf

= { [K in keyof P]: QueryValue; }; /** * `per_page` + `offset`. Server defaults: `per_page` 50, `offset` 0. * * The original pagination scheme (`http4s.pagination`), used by billing, * contracts, dataset snapshots, dataset stats, data streams, jobs and product * admin. Sending `page` to one of these endpoints does nothing — it is ignored * and you get the first page every time. */ export interface OffsetPagination { per_page?: number | null; offset?: number | null; } /** * `per_page` + `page`. Server default: `page` 1, page size per route. * * The `http4s.paginationV2` scheme, and the most common one: access rules, * agents, app invites, attributes, datasets, installations, models, queries, * views and the workflows list. */ export interface PagePagination { page?: number | null; per_page?: number | null; } /** * `per_page` + `page_token`. Server default: `per_page` 10. * * Opaque-cursor pagination. Read `next_page_token` off the response and pass it * back as `page_token`; a null/absent token means the last page. */ export interface CursorPagination { per_page?: number; page_token?: string; } /** * Page-number pagination. * * @deprecated Prefer {@link PagePagination}, which names the scheme explicitly. * Not every endpoint paginates this way — see {@link OffsetPagination} and * {@link CursorPagination}. */ export type PaginationOptions = PagePagination; /** * Interface for search parameters */ export interface SearchParams { q?: string; } /** * Interfaces defining collaborators configuration across API services */ export type GeneralCollaboratorType = "all" | "none"; export type SpecificCollaboratorType = "inclusion" | "exclusion"; export type NonAuthenticatedCollaborator = { type: "anonymous"; }; export type CollaboratorList = { type: SpecificCollaboratorType; company_ids: number[]; }; export type GeneralCollaborator = { type: GeneralCollaboratorType; }; export type QueryCollaborator = CollaboratorList | GeneralCollaborator; export type ViewCollaborator = CollaboratorList | GeneralCollaborator | NonAuthenticatedCollaborator; export type QueryAccess = QueryCollaborator; export type ViewAccess = ViewCollaborator; export type CollaboratorsConfig = { query: QueryAccess; view: ViewAccess; }; export {};