UNPKG

@opendatasoft/api-client

Version:
114 lines (113 loc) 4.51 kB
import { ExportCatalogFormat, ExportDatasetFormat } from '../client/types'; export type StringOrUpdater = string | ((current: string) => string) | null | undefined | false; export type NumberOrUpdater = number | ((current: number) => number) | null | undefined | false; export declare class Query { private readonly params; private readonly path; private searchParams; constructor(path?: string, init?: Record<string, string | string[]>); getPath(): string; getSearchParams(): URLSearchParams; toString(): string; set(name: string, value: string | string[]): Query; unset(name: string): Query; update(name: string, value: StringOrUpdater): Query; append(name: string, value: string): Query; select(expressions: StringOrUpdater): Query; where(filters: StringOrUpdater): Query; groupBy(expressions: StringOrUpdater): Query; orderBy(expressions: StringOrUpdater): Query; limit(limit: NumberOrUpdater): Query; offset(offset: NumberOrUpdater): Query; facet(facet: string): Query; refine(refine: string): Query; exclude(exclude: string): Query; lang(lang: string): Query; timezone(timezone: string): Query; } export declare const fromCatalog: () => { itself: () => Query; facets: () => Query; datasets: () => Query; /** * FIXME: Update this URL or remove this comment when the endpoint is out of beta. * The assets endpoint is still in development and not yet documented. * Therefore, this URL may change in the future. */ assets: () => Query; export: (format: ExportCatalogFormat) => Query; dataset: (datasetId: string) => { itself: () => Query; facets: () => Query; records: () => Query; export: (format: ExportDatasetFormat) => Query; record: (recordId: string) => Query; }; }; export declare const fromMonitoring: () => { itself: () => Query; facets: () => Query; datasets: () => Query; /** * FIXME: Update this URL or remove this comment when the endpoint is out of beta. * The assets endpoint is still in development and not yet documented. * Therefore, this URL may change in the future. */ assets: () => Query; export: (format: ExportCatalogFormat) => Query; dataset: (datasetId: string) => { itself: () => Query; facets: () => Query; records: () => Query; export: (format: ExportDatasetFormat) => Query; record: (recordId: string) => Query; }; }; export declare const fromDataNetwork: () => { itself: () => Query; facets: () => Query; datasets: () => Query; /** * FIXME: Update this URL or remove this comment when the endpoint is out of beta. * The assets endpoint is still in development and not yet documented. * Therefore, this URL may change in the future. */ assets: () => Query; export: (format: ExportCatalogFormat) => Query; dataset: (datasetId: string) => { itself: () => Query; facets: () => Query; records: () => Query; export: (format: ExportDatasetFormat) => Query; record: (recordId: string) => Query; }; }; export declare const field: (fieldName: string) => string; export declare const string: (value: string) => string; export declare const dateTime: (date: Date) => string; /** * ODSQL function to normalize field name. * * - Can be used for `order_by` and `group_by` clauses. * - Example usage: `select=count(*) & group_by=lower(artist)`. * * @param {string} fieldName - The field name to normalize. * @returns {string} The lower ODSQL function. */ export declare const lower: (fieldName: string) => string; /** Format year month year and day numbers into an API call format. If you have an YYYY-MM-DD string already, use FromIsoString instead. */ export declare const date: ({ year, month, day }: { year: number; month?: number | undefined; day?: number | undefined; }) => string; /** Formats an YYYY-MM-DD date string into an API call string. * Avoids converting to number if you already have a string. */ export declare const dateFromIsoString: (dateStr: string) => string; export declare const all: (...conditions: (string | undefined | null)[]) => string; export declare const one: (...conditions: (string | undefined | null)[]) => string; export declare const list: (...values: (string | undefined | null)[]) => string; export declare const not: (condition: string | undefined | null) => string;