Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* perform(content) {
// Warning: semi-private e-c API
const owner = get(this, 'owner');
const libraryEntry = content || get(owner, 'libraryEntry');
// Send the task to the onUpdate function
get(owner, 'onUpdate')(libraryEntry, this);
try {
yield libraryEntry.save();
get(owner, 'queryCache').invalidateType('library-entry');
} catch (error) {
if (isChangeset(libraryEntry)) {
libraryEntry.rollback();
} else {
libraryEntry.rollbackAttributes();
}
throw error;
}
}
}).enqueue(),
export function changeset(
[obj, validations]: [object | Promise, ValidatorFunc],
options: Config = {}
): Changeset | Promise {
if (isChangeset(obj)) {
return obj;
}
if (isPromise(obj)) {
return Promise.resolve(obj).then((resolved: any) => new Changeset(resolved, validations, {}, options));
}
return new Changeset(obj, validations, {}, options);
}
merge(
changeset /*: ChangesetDef */
) /*: ChangesetDef */ {
let content /*: Object */ = get(this, CONTENT);
assert('Cannot merge with a non-changeset', isChangeset(changeset));
assert('Cannot merge with a changeset of different content', get(changeset, CONTENT) === content);
if (get(this, 'isPristine') && get(changeset, 'isPristine')) {
return this;
}
let c1 /*: Changes */ = get(this, CHANGES);
let c2 /*: Changes */ = get(changeset, CHANGES);
let e1 /*: Errors */ = get(this, ERRORS);
let e2 /*: Errors */ = get(changeset, ERRORS);
let newChangeset /*: ChangesetDef */ = new Changeset(content, get(this, VALIDATOR));
let newErrors /*: Errors */ = objectWithout(keys(c2), e1);
let newChanges /*: Changes */ = objectWithout(keys(e2), c1);
let mergedErrors /*: Errors */ = mergeNested(newErrors, e2);
let mergedChanges /*: Changes */ = mergeNested(newChanges, c2);