Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
47 lines
1.7 KiB
Plaintext
47 lines
1.7 KiB
Plaintext
import { APIError } from '../../../errors/index.js';
|
|
import { getFileByPath } from '../../../uploads/getFileByPath.js';
|
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
import { updateOperation } from '../update.js';
|
|
import { updateByIDOperation } from '../updateByID.js';
|
|
async function updateLocal(payload, options) {
|
|
const { id, autosave, collection: collectionSlug, data, depth, disableTransaction, draft, file, filePath, limit, overrideAccess = true, overrideLock, overwriteExistingFiles = false, populate, publishAllLocales, publishSpecificLocale, select, showHiddenFields, sort, trash = false, unpublishAllLocales, where } = options;
|
|
const collection = payload.collections[collectionSlug];
|
|
if (!collection) {
|
|
throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Update Operation.`);
|
|
}
|
|
const req = await createLocalReq(options, payload);
|
|
req.file = file ?? await getFileByPath(filePath);
|
|
const args = {
|
|
id,
|
|
autosave,
|
|
collection,
|
|
data,
|
|
depth,
|
|
disableTransaction,
|
|
draft,
|
|
limit,
|
|
overrideAccess,
|
|
overrideLock,
|
|
overwriteExistingFiles,
|
|
payload,
|
|
populate,
|
|
publishAllLocales,
|
|
publishSpecificLocale,
|
|
req,
|
|
select,
|
|
showHiddenFields,
|
|
sort,
|
|
trash,
|
|
unpublishAllLocales,
|
|
where
|
|
};
|
|
if (options.id) {
|
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
return updateByIDOperation(args);
|
|
}
|
|
// @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve
|
|
return updateOperation(args);
|
|
}
|
|
export { updateLocal };
|
|
|
|
//# sourceMappingURL=update.js.map |