@commercetools/sync-actions
Version:
Build API update actions for the commercetools platform.
47 lines (46 loc) • 2.14 kB
TypeScript
import { Delta, UpdateAction } from './types';
export declare const createIsEmptyValue: <T extends string | object>(emptyValues: T[]) => (value: string | unknown) => boolean;
export declare const isOptionalField: (action: string) => boolean;
/**
* Builds actions for simple object properties, given a list of actions
* E.g. [{ action: `changeName`, key: 'name' }]
*
* @param {Array} options.actions - a list of actions to be built
* based on the given property
* @param {Object} options.diff - the diff object
* @param {Object} options.oldObj - the object that needs to be updated
* @param {Object} options.newObj - the new representation of the object
* @param {Boolean} options.shouldOmitEmptyString - a flag to determine if we should treat an empty string a NON-value
* @param {Boolean} options.shouldUnsetOmittedProperties - a flag to determine if we should unset fields which are omitted in the newObj
* @param {Boolean} options.shouldPreventUnsettingRequiredFields - a flag to determine if required fields should be unset
*/
export declare function buildBaseAttributesActions<T, U>({ actions, diff, oldObj, newObj, shouldOmitEmptyString, shouldUnsetOmittedProperties, shouldPreventUnsettingRequiredFields, }: {
actions: Array<UpdateAction>;
diff: Delta;
oldObj: T;
newObj: U;
shouldOmitEmptyString?: boolean;
shouldUnsetOmittedProperties?: boolean;
shouldPreventUnsettingRequiredFields?: boolean;
}): {
[x: string]: any;
action: string;
}[];
/**
* Builds actions for simple reference objects, given a list of actions
* E.g. [{ action: `setTaxCategory`, key: 'taxCategory' }]
*
* @param {Array} options.actions - a list of actions to be built
* based on the given property
* @param {Object} options.diff - the diff object
* @param {Object} options.oldObj - the object that needs to be updated
* @param {Object} options.newObj - the new representation of the object
*/
export declare function buildReferenceActions<T>({ actions, diff, oldObj, newObj, }: {
actions: Array<UpdateAction>;
diff: Delta;
oldObj: T;
newObj: T;
}): {
action: string;
}[];