import { FilterSearchQueryI, NestedQuery, QueryOptions, TotalumApiResponse } from "../common/interfaces"; import { DataValues, DeleteObjectResponse, UpdatesRecordResponse } from "../common/response-types"; import { FetchClient } from "../common/fetch-client"; export declare class CrudService { private client; constructor(client: FetchClient); /** * Fetches a record by its ID. * @param {string} tableName - The type of the record. (table name) * @param {string} id - The ID of the record. * @returns {Promise>} - A promise that resolves to the record data. */ getRecordById(tableName: string, id: string): Promise>; /** * Fetches the historic updates of a record by its ID. * @param {string} recordId - The ID of the record to fetch the historic updates. * @returns {Promise>} - A promise that resolves to the historic updates data. */ getHistoricRecordUpdatesById(recordId: string): Promise>; /** * Fetches records with optional filtering, sorting, and pagination. * The response data is an array of records. If returnCount is true, a metadata object with count is also returned. * @deprecated Use `query()` instead, which supports nested relations, filtering, sorting, pagination, and more. * @param {string} tableName - The type of the record. (table name) * @param {FilterSearchQueryI} query - Optional query parameters for filtering. * @returns {Promise>} - A promise that resolves to an array of records. */ getRecords(tableName: string, query?: FilterSearchQueryI): Promise>; /** * Fetches nested data across related tables. The query tree uses table names as keys. * @deprecated Use `query()` instead, which supports nested relations, filtering, sorting, pagination, and more. * @param {NestedQuery} nestedQuery - The nested query structure. * @param {any} options - Optional configuration. * @returns {Promise>} - A promise that resolves to nested data array. */ getNestedData(nestedQuery: NestedQuery, options?: any): Promise>; /** * Powerful query endpoint for fetching records with nested relations, filtering, sorting, pagination, * parent filtering by children (_has), child counts (_count), and response shaping (_include). * * @param {string} tableName - The root table to query. * @param {QueryOptions} queryOptions - Query options with _ prefixed system keys and property names as child expansions. * @returns {Promise>} - Nested records matching the query. * * @example * ```typescript * // Simple: get companies with their employees * sdk.crud.query('company', { employee: true }) * * // Advanced: companies in Spain with active employees, count tasks * sdk.crud.query('company', { * _filter: { country: "Spain" }, * _sort: { name: "asc" }, * _limit: 10, * employee: { * _has: true, * _filter: { status: { in: ["active", "probation"] } }, * _count: true, * task: { _sort: { createdAt: "desc" }, _limit: 5 } * } * }) * ``` */ query(tableName: string, queryOptions?: QueryOptions): Promise>; /** * Recursively encodes dots in _sort keys to @ so they survive express-mongo-sanitize. * The server restores @ → . before processing. */ private encodeSortKeys; /** * Deletes a record by its ID. * @param {string} tableName - The type of the record. (table name) * @param {string} id - The ID of the record. * @returns {Promise>} - A promise that resolves when deletion is complete. */ deleteRecordById(tableName: string, id: string): Promise>; /** * Edits a record by its ID. * @param {string} tableName - The type of the record. (table name) * @param {string} id - The ID of the record. * @param {T} properties - The properties to update. * @returns {Promise>} - A promise that resolves to the updated record. */ editRecordById(tableName: string, id: string, properties: Partial): Promise>; /** * Creates a new record. * @param {string} tableName - The type of the record. (table name) * @param {Partial} record - The record data to create. * @returns {Promise>} - A promise that resolves to the created record. */ createRecord(tableName: string, record: Partial): Promise>; /** * Adds a many-to-many reference between records. * @param {string} type - The type id of the record (table name) * @param {string} id - The id of the record that we want to add a many to many reference * @param {string} propertyName - The property that we want to add a many to many reference * @param {string} referenceId - The id of the record that we want to add as a many to many reference * @returns {Promise>} */ addManyToManyReferenceRecord(type: string, id: string, propertyName: string, referenceId: string): Promise>; /** * Drops a many-to-many reference between records. * @param {string} type - The type id of the record (table name) * @param {string} id - The id of the record that we want to drop a many to many reference * @param {string} propertyName - The property that we want to drop a many to many reference * @param {string} referenceId - The id of the record that we want to drop as a many to many reference * @returns {Promise>} */ dropManyToManyReferenceRecord(type: string, id: string, propertyName: string, referenceId: string): Promise>; /** * Gets many-to-many reference records with optional filtering. * @deprecated Use `query()` instead, which supports nested relations including many-to-many. * @param {string} type - The type id of the record (table name) * @param {string} id - The id of the record that we want to get many to many references * @param {string} propertyName - The property that we want to get many to many references * @param {FilterSearchQueryI} query - The query to filter and sort the results * @returns {Promise>} */ getManyToManyReferencesRecords(type: string, id: string, propertyName: string, query?: FilterSearchQueryI): Promise>; }