UNPKG

@amplience/dc-cli

Version:
24 lines (23 loc) 975 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContentItemUnpublishingService = void 0; const dc_management_sdk_js_1 = require("dc-management-sdk-js"); const burstable_queue_1 = require("../burstable-queue/burstable-queue"); class ContentItemUnpublishingService { constructor() { this.queue = new burstable_queue_1.BurstableQueue({}); } async unpublish(contentItem, action) { const canUnpublish = (state) => state && [dc_management_sdk_js_1.ContentItemPublishingStatus.LATEST, dc_management_sdk_js_1.ContentItemPublishingStatus.EARLY].includes(state); this.queue.add(async () => { if (canUnpublish(contentItem.publishingStatus)) { await contentItem.related.unpublish(); } action(contentItem); }); } async onIdle() { return this.queue.onIdle(); } } exports.ContentItemUnpublishingService = ContentItemUnpublishingService;