import { Data } from "../support/interfaces"; import Model from "../orm/model"; /** * This class provides methods to transform incoming data from GraphQL in to a format Vuex-ORM understands and * vice versa. */ export default class Transformer { /** * Transforms outgoing data. Use for variables param. * * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ static transformOutgoingData(model: Model, data: Data, read: boolean, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean): Data; /** * Transforms a set of incoming data to the format vuex-orm requires. * * @param {Data | Array} data * @param model * @param mutation required to transform something like `disableUserAddress` to the actual model name. * @param {boolean} recursiveCall * @returns {Data} */ static transformIncomingData(data: Data | Array, model: Model, mutation?: boolean, recursiveCall?: boolean): Data; /** * Tells if a field should be included in the outgoing data. * @param {boolean} forFilter Tells whether a filter is constructed or not. * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, whitelist?: Array): boolean; /** * Registers a record for recursion detection. * @param {Map>} records Map of IDs. * @param {ORMModel} record The record to register. */ private static addRecordForRecursionDetection; /** * Detects recursions. * @param {Map>} records Map of IDs. * @param {ORMModel} record The record to check. * @return {boolean} true when the record is already included in the records. */ private static isRecursion; }