UNPKG

contentful-management

Version:
43 lines (40 loc) 1.5 kB
import copy from 'fast-copy'; import { put, post, del as del$1, get as get$1 } from './raw.mjs'; const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/workflows`; const getWorkflowUrl = (params) => `${getBaseUrl(params)}/${params.workflowId}`; const completeWorkflowUrl = (params) => `${getWorkflowUrl(params)}/complete`; const getMany = (http, params, headers) => get$1(http, getBaseUrl(params), { headers, params: params.query, }); const get = (http, params, headers) => get$1(http, getWorkflowUrl(params), { headers, }); const create = (http, params, rawData, headers) => { const data = copy(rawData); return post(http, getBaseUrl(params), data, { headers, }); }; const update = (http, params, rawData, headers) => { const data = copy(rawData); delete data.sys; return put(http, getWorkflowUrl(params), data, { headers: { 'X-Contentful-Version': rawData.sys.version ?? 0, ...headers, }, }); }; const del = (http, { version, ...params }, headers) => { return del$1(http, getWorkflowUrl(params), { headers: { 'X-Contentful-Version': version, ...headers }, }); }; const complete = (http, { version, ...params }, headers) => { return put(http, completeWorkflowUrl(params), null, { headers: { 'X-Contentful-Version': version, ...headers }, }); }; export { complete, create, del, get, getMany, update }; //# sourceMappingURL=workflow.mjs.map