UNPKG

@botonic/plugin-contentful

Version:

Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet

73 lines 3.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ManageContentful = void 0; const tslib_1 = require("tslib"); const contentful_management_1 = require("contentful-management"); const manage_asset_1 = require("./manage-asset"); const manage_entry_1 = require("./manage-entry"); class ManageContentful { constructor(options) { this.options = options; this.manage = this.createClient(); this.environment = this.getEnvironment(); this.manageAsset = new manage_asset_1.ManageContentfulAsset(options, this.manage, this.environment); this.manageEntry = new manage_entry_1.ManageContentfulEntry(options, this.manage, this.environment); } createClient() { return (0, contentful_management_1.createClient)({ accessToken: this.options.accessToken, timeout: this.options.timeoutMs, }); } getEnvironment() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const space = yield this.manage.getSpace(this.options.spaceId); if (!this.options.environment) { throw new Error('Please specify environment in ContentfulOptions'); } return yield space.getEnvironment(this.options.environment); }); } deleteContent(context, contentId) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageEntry.deleteContent(context, contentId); }); } createContent(context, model, id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageEntry.createContent(context, model, id); }); } updateFields(context, contentId, fields) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageEntry.updateFields(context, contentId, fields); }); } copyField(context, contentId, fieldType, fromLocale, onlyIfTargetEmpty) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageEntry.copyField(context, contentId, fieldType, fromLocale, onlyIfTargetEmpty); }); } removeAssetFile(context, assetId) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageAsset.removeAssetFile(context, assetId); }); } copyAssetFile(context, assetId, fromLocale) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageAsset.copyAssetFile(context, assetId, fromLocale); }); } createAsset(context, file, info) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageAsset.createAsset(context, file, info); }); } removeAsset(context, assetId) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this.manageAsset.removeAsset(context, assetId); }); } } exports.ManageContentful = ManageContentful; //# sourceMappingURL=manage-contentful.js.map