@amplience/dc-cli
Version:
Dynamic Content CLI Tool
34 lines (33 loc) • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContentItemPublishingJobService = void 0;
const burstable_queue_1 = require("../burstable-queue/burstable-queue");
const PublishingJobStatus_1 = require("dc-management-sdk-js/build/main/lib/model/PublishingJobStatus");
class ContentItemPublishingJobService {
constructor(client) {
this.client = client;
this.queue = new burstable_queue_1.BurstableQueue({});
}
async check(publishingJob, action) {
this.queue.add(async () => {
const latestPublishJob = await this.client.publishingJob.get(publishingJob.id);
if (latestPublishJob.state === PublishingJobStatus_1.PublishingJobStatus.FAILED ||
latestPublishJob.state === PublishingJobStatus_1.PublishingJobStatus.COMPLETED) {
action(latestPublishJob);
}
else {
this.check(latestPublishJob, action);
}
});
}
async onIdle() {
return this.queue.onIdle();
}
get size() {
return this.queue.size();
}
get pending() {
return this.queue.pending();
}
}
exports.ContentItemPublishingJobService = ContentItemPublishingJobService;