import Collection from "./collection.js"; import type { QueryStage } from "../datastore/query-stage.js"; import sealious_to_mongo_sort_param from "../utils/mongo-sorts.js"; import type { ExtractFilterParams } from "./field.js"; import type Context from "../context.js"; import type CollectionItem from "./collection-item.js"; import { ItemListResult } from "./item-list-result.js"; type FilterT = Partial<{ [FieldName in keyof T["fields"]]: ExtractFilterParams | null; }>; type PaginationParams = { page: number; items: number; forward_buffer: number; }; export type SortParams = Partial<{ [key in keyof T["fields"]]: keyof typeof sealious_to_mongo_sort_param; } & Partial<{ "_metadata.created_at": keyof typeof sealious_to_mongo_sort_param; "_metadata.modified_at": keyof typeof sealious_to_mongo_sort_param; }>>; type AllInOneParams = { search: Parameters["search"]>[0]; sort: Parameters["sort"]>[0]; filter: Parameters["filter"]>[0]; pagination: Parameters["paginate"]>[0]; attachments: Parameters["attach"]>[0]; }; /** Which fields to fetch attachments for. Can be nested, as one * resource can point to another one and that one can also have * attachments */ export type AttachmentOptions = Partial<{ [key in keyof T["fields"]]: any; }>; export default class ItemList { fields_with_attachments_fetched: string[]; private _attachments_options; private _filter; private _ids; private _search; private _sort; private context; private collection; private aggregation_stages; private await_before_fetch; private is_paginated; private is_sorted; private pagination; constructor(collection: T, context: Context); filter(filter?: FilterT): ItemList; static parsePaginationParams(params: Partial): Partial; paginate(pagination_params?: Partial): ItemList; search(term?: string): ItemList; ids(ids: string[]): ItemList; namedFilter(filter_name: string): ItemList; attach(attachment_options?: AttachmentOptions): ItemList; private fetchAttachments; addPolicyStagesToPipeline(): Promise; /** * execute crated database request */ fetch({ is_http_api_request }?: { is_http_api_request: boolean; }): Promise>; /** * execute crated database request and return one item */ fetchOne({ is_http_api_request }?: { is_http_api_request: boolean; }): Promise | null>; toCSV(): Promise; getAggregationStages(): Promise<(Partial<{ $match: import("../datastore/query-stage.js").MatchBody; $lookup: import("../datastore/query-step.js").SimpleLookupBody | import("../datastore/query-step.js").ComplexLookupBody; $unwind: string; $skip: number; $limit: number; $sort: { [field_name: string]: 1 | -1; }; $group: { _id: string; [other: string]: any; }; $count: string; $unset: string; }> | { $sort: { [field_name: string]: 1 | -1; }; })[]>; sort(sort_params?: SortParams): this; setParams(params: Partial>): ItemList; private getSortingStages; private getPaginationStages; addCustomAggregationStages(stages: QueryStage[]): this; } export {};