contentful-management
Version:
Client for Contentful's Content Management API
62 lines (59 loc) • 2.36 kB
JavaScript
import { post, put, del as del$1, get as get$1, patch as patch$1 } from './raw.js';
function basePath(organizationId) {
return `/organizations/${organizationId}/taxonomy/concepts`;
}
const create = (http, params, data) => {
return post(http, basePath(params.organizationId), data);
};
const createWithId = (http, params, data) => {
return put(http, `${basePath(params.organizationId)}/${params.conceptId}`, data);
};
const patch = (http, params, data, headers) => {
return patch$1(http, `${basePath(params.organizationId)}/${params.conceptId}`, data, {
headers: {
'X-Contentful-Version': params.version,
'Content-Type': 'application/json-patch+json',
...headers,
},
});
};
const update = (http, params, data, headers) => {
return put(http, `${basePath(params.organizationId)}/${params.conceptId}`, data, {
headers: {
'X-Contentful-Version': params.version,
...headers,
},
});
};
const get = (http, params) => get$1(http, `${basePath(params.organizationId)}/${params.conceptId}`);
const del = (http, params, headers) => del$1(http, `${basePath(params.organizationId)}/${params.conceptId}`, {
headers: {
'X-Contentful-Version': params.version ?? 0,
...headers,
},
});
const getMany = (http, params) => {
const { url, queryParams } = cursorBasedCollection('', params);
return get$1(http, url, {
params: queryParams,
});
};
const getDescendants = (http, params) => {
const { url, queryParams } = cursorBasedCollection(`/${params.conceptId}/descendants`, params);
return get$1(http, url, { params: queryParams });
};
const getAncestors = (http, params) => {
const { url, queryParams } = cursorBasedCollection(`/${params.conceptId}/ancestors`, params);
return get$1(http, url, { params: queryParams });
};
const getTotal = (http, params) => get$1(http, `${basePath(params.organizationId)}/total`);
function cursorBasedCollection(path, params) {
return params.query?.pageUrl
? { url: params.query?.pageUrl }
: {
url: `${basePath(params.organizationId)}${path}`,
queryParams: params.query,
};
}
export { create, createWithId, del, get, getAncestors, getDescendants, getMany, getTotal, patch, update };
//# sourceMappingURL=concept.js.map