contentful-management
Version:
Client for Contentful's Content Management API
35 lines (32 loc) • 1.03 kB
JavaScript
import copy from 'fast-copy';
import { toPlainObject, freezeSys } from 'contentful-sdk-core';
import enhanceWithMethods from '../enhance-with-methods.js';
import { wrapCollection } from '../common-utils.js';
/**
* @internal
*/
function createSnapshotApi() {
return {
/* In case the snapshot object evolve later */
};
}
/**
* @internal
* @param makeRequest - function to make requests via an adapter
* @param data - Raw snapshot data
* @returns Wrapped snapshot data
*/
function wrapSnapshot(_makeRequest, data) {
const snapshot = toPlainObject(copy(data));
const snapshotWithMethods = enhanceWithMethods(snapshot, createSnapshotApi());
return freezeSys(snapshotWithMethods);
}
/**
* @internal
* @param makeRequest - function to make requests via an adapter
* @param data - Raw snapshot collection data
* @returns Wrapped snapshot collection data
*/
const wrapSnapshotCollection = wrapCollection(wrapSnapshot);
export { wrapSnapshot, wrapSnapshotCollection };
//# sourceMappingURL=snapshot.js.map