contentful-management
Version:
Client for Contentful's Content Management API
57 lines (54 loc) • 2.29 kB
JavaScript
import copy from 'fast-copy';
import { post, put, get as get$1, patch as patch$1 } from './raw.js';
import { normalizeSelect } from './utils.js';
const get = (http, params, rawData, headers) => {
return get$1(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, {
params: normalizeSelect(params.query),
headers: { ...headers },
});
};
const getMany = (http, params, rawData, headers) => {
return get$1(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries`, {
params: normalizeSelect(params.query),
headers: { ...headers },
});
};
const update = (http, params, rawData, headers) => {
const data = copy(rawData);
delete data.sys;
return put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, data, {
headers: {
'X-Contentful-Version': rawData.sys.version ?? 0,
...headers,
},
});
};
const patch = (http, params, data, headers) => {
return patch$1(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, data, {
headers: {
'X-Contentful-Version': params.version,
'Content-Type': 'application/json-patch+json',
...headers,
},
});
};
const create = (http, params, rawData, headers) => {
const data = copy(rawData);
return post(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries`, data, {
headers: {
'X-Contentful-Content-Type': params.contentTypeId,
...headers,
},
});
};
const createWithId = (http, params, rawData, headers) => {
const data = copy(rawData);
return put(http, `/spaces/${params.spaceId}/environments/${params.environmentId}/releases/${params.releaseId}/entries/${params.entryId}`, data, {
headers: {
'X-Contentful-Content-Type': params.contentTypeId,
...headers,
},
});
};
export { create, createWithId, get, getMany, patch, update };
//# sourceMappingURL=release-entry.js.map