import { DirectusId, Field, IdMappers, WithSyncIdAndWithoutId } from './interfaces'; import { Item, MapperRecord } from './helpers'; import { Logger } from '../../logger'; export declare abstract class DataMapper { protected readonly logger: Logger; /** * These field will be ignored when saving and restoring the data. */ protected fieldsToIgnore: Field[]; /** * Returns a map of fields and id mapper to use when mapping the ids of the items. */ protected idMappers: IdMappers; /** * Computed mapper functions from local to sync id from the id mappers. */ protected localIdToSyncIdMappers: MapperRecord | undefined; /** * Computed mapper functions from sync to local id from the id mappers. */ protected syncIdToLocalIdMappers: MapperRecord | undefined; constructor(logger: Logger); /** * Returns the items with the ids mapped to the sync ids, * without the fields to ignore. */ mapIdsToSyncIdAndRemoveIgnoredFields(items: WithSyncIdAndWithoutId[]): Promise[]>; /** * Discard the fields to ignore from the items. */ protected removeFieldsToIgnore(item: WithSyncIdAndWithoutId): WithSyncIdAndWithoutId; /** * Map the sync id of the item to the local id. * Returns undefined if the item has no sync id. * This allows to create items by order of dependencies. */ mapSyncIdToLocalId(item: T): Promise; /** * Build once the mapper functions from sync to local id. */ protected getSyncIdToLocalIdMapper(): MapperRecord; /** * Returns true if the id is dynamic, i.e. it is a template. */ protected isDynamicId(id: DirectusId): boolean; /** * Map the ids of the item to the sync ids. * For new items, the original id is used. */ protected mapLocalIdToSyncIdIfPossible(item: T): Promise; /** * Build once the mapper functions from local to sync id. */ protected getLocalIdToSyncIdMapper(): MapperRecord; }