UNPKG

contentful-management

Version:
35 lines (32 loc) 1.3 kB
import copy from 'fast-copy'; import { post, del as del$1, get as get$1, put } from './raw.js'; import { normalizeSelect } from './utils.js'; const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/entries/${params.entryId}/tasks`; const getTaskUrl = (params) => `${getBaseUrl(params)}/${params.taskId}`; const get = (http, params) => get$1(http, getTaskUrl(params)); const getMany = (http, params) => get$1(http, getBaseUrl(params), { params: normalizeSelect(params.query), }); /** * @deprecated use `getMany` instead. `getAll` may never be removed for app compatibility reasons. */ const getAll = getMany; const create = (http, params, rawData) => { const data = copy(rawData); return post(http, getBaseUrl(params), data); }; const update = (http, params, rawData, headers) => { const data = copy(rawData); delete data.sys; return put(http, getTaskUrl(params), data, { headers: { 'X-Contentful-Version': rawData.sys.version ?? 0, ...headers, }, }); }; const del = (http, { version, ...params }) => { return del$1(http, getTaskUrl(params), { headers: { 'X-Contentful-Version': version } }); }; export { create, del, get, getAll, getMany, update }; //# sourceMappingURL=task.js.map