import { Knex } from 'knex'; import { AbstractServiceOptions, Item, PrimaryKey } from '../types'; import { Accountability, SchemaOverview } from '@directus/shared/types'; import { Helpers } from '../database/helpers'; declare type Action = 'create' | 'read' | 'update'; declare type Transformers = { [type: string]: (context: { action: Action; value: any; payload: Partial; accountability: Accountability | null; specials: string[]; }) => Promise; }; interface ITransformerOptions { transformers: { conceal?: boolean; hash?: boolean; json?: boolean; boolean?: boolean; uuid?: boolean; 'user-created'?: boolean; 'user-updated'?: boolean; 'role-created'?: boolean; 'role-updated'?: boolean; 'date-created'?: boolean; 'date-updated'?: boolean; csv?: boolean; 'json-stringify'?: boolean; }; } /** * Process a given payload for a collection to ensure the special fields (hash, uuid, date etc) are * handled correctly. */ export declare class PayloadService { accountability: Accountability | null; knex: Knex; helpers: Helpers; collection: string; schema: SchemaOverview; constructor(collection: string, options: AbstractServiceOptions); transformers: Transformers; processValues(action: Action, payloads: Partial[], options?: ITransformerOptions): Promise[]>; processValues(action: Action, payload: Partial, options?: ITransformerOptions): Promise>; processAggregates(payload: Partial[]): void; processField(field: SchemaOverview['collections'][string]['fields'][string], payload: Partial, action: Action, accountability: Accountability | null, options: { [type: string]: boolean; }): Promise; /** * Native geometries are stored in custom binary format. We need to insert them with * the function st_geomfromtext. For this to work, that function call must not be * escaped. It's therefore placed as a Knex.Raw object in the payload. Thus the need * to check if the value is a raw instance before stringifying it in the next step. */ processGeometries>[]>(payloads: T, action: Action): T; /** * Knex returns `datetime` and `date` columns as Date.. This is wrong for date / datetime, as those * shouldn't return with time / timezone info respectively */ processDates(payloads: Partial>[], action: Action): Partial>[]; /** * Recursively save/update all nested related Any-to-One items */ processA2O(data: Partial): Promise<{ payload: Partial; revisions: PrimaryKey[]; }>; /** * Save/update all nested related m2o items inside the payload */ processM2O(data: Partial): Promise<{ payload: Partial; revisions: PrimaryKey[]; }>; /** * Recursively save/update all nested related o2m items */ processO2M(data: Partial, parent: PrimaryKey): Promise<{ revisions: PrimaryKey[]; }>; /** * Transforms the input partial payload to match the output structure, to have consistency * between delta and data */ prepareDelta(data: Partial): Promise; } export {};