@unito/integration-sdk
Version:
Integration SDK
30 lines (29 loc) • 1.42 kB
TypeScript
import { FieldSchema } from '@unito/integration-api';
import { Filter } from './index.js';
/**
* Use this helper function to retrieve the applicable filters from the context object. While using filters
* directly from context might work, it doesn't offer any guarantees about the shape of the filters nor the
* validity of the fields against which the filters are applied. On the other hand, this function ensures that
* all filters are valid and that the fields against which the filters are applied are present in the schema.
*
* @param context The object containing the raw filters
* @param fields The schema of the item against which the filters are applied
* @returns The validated filters
*/
export declare function getApplicableFilters(context: {
filters: Filter[];
}, fields: FieldSchema[]): Filter[];
/**
* Use this helper function to build the query params for a collection next page URL.
* It re-encodes the parsed filters and selects back into query-param form,
* so integrations can easily construct `nextPage` URLs.
*
* @example
* const params = buildCollectionQueryParams({ filters: context.filters, selects: context.selects });
* params.append('cursor', nextCursor);
* return { info: { nextPage: `/items?${params.toString()}` }, data: [...] };
*/
export declare function buildCollectionQueryParams(params?: {
filters?: Filter[];
selects?: string[];
}): URLSearchParams;