contentful-management
Version:
Client for Contentful's Content Management API
53 lines (50 loc) • 1.73 kB
JavaScript
import copy from 'fast-copy';
import { post, del as del$1, get as get$1, put } from './raw.js';
const getBaseUrl = (params) => `/spaces/${params.spaceId}/environments/${params.environmentId}/component_types`;
const getMany = (http, params, headers) => {
return get$1(http, getBaseUrl(params), {
params: params.query,
headers,
});
};
const get = (http, params, headers) => {
return get$1(http, getBaseUrl(params) + `/${params.componentTypeId}`, {
headers,
});
};
const create = (http, params, rawData, headers) => {
const data = copy(rawData);
return post(http, getBaseUrl(params), data, { headers });
};
const upsert = (http, params, rawData, headers) => {
const { sys, ...body } = copy(rawData);
return put(http, getBaseUrl(params) + `/${params.componentTypeId}`, body, {
headers: {
...(sys.version !== undefined && {
'X-Contentful-Version': sys.version,
}),
...headers,
},
});
};
const del = (http, params) => {
return del$1(http, getBaseUrl(params) + `/${params.componentTypeId}`);
};
const publish = (http, params, headers) => {
return put(http, `${getBaseUrl(params)}/${params.componentTypeId}/published`, null, {
headers: {
'X-Contentful-Version': params.version,
...headers,
},
});
};
const unpublish = (http, params, headers) => {
return del$1(http, `${getBaseUrl(params)}/${params.componentTypeId}/published`, {
headers: {
'X-Contentful-Version': params.version,
...headers,
},
});
};
export { create, del, get, getMany, publish, unpublish, upsert };
//# sourceMappingURL=component-type.js.map