contentful-import 9.0.21 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,227 +1,178 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createEntities = createEntities;
7
- exports.createEntries = createEntries;
8
- exports.createLocales = createLocales;
9
- var _collection = require("lodash/collection");
10
- var _object = require("lodash/object");
11
- var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
12
- var _logging = require("contentful-batch-libs/dist/logging");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createEntries = exports.createLocales = exports.createEntities = void 0;
7
+ const collection_1 = require("lodash/collection");
8
+ const object_1 = require("lodash/object");
9
+ const get_entity_name_1 = __importDefault(require("contentful-batch-libs/dist/get-entity-name"));
10
+ const logging_1 = require("contentful-batch-libs/dist/logging");
14
11
  /**
15
12
  * Creates a list of entities
16
13
  * Applies to all entities except Entries, as the CMA API for those is slightly different
17
14
  * See handleCreationErrors for details on what errors reject the promise or not.
18
15
  */
19
- function createEntities({
20
- context,
21
- entities,
22
- destinationEntitiesById,
23
- requestQueue
24
- }) {
25
- return createEntitiesWithConcurrency({
26
- context,
27
- entities,
28
- destinationEntitiesById,
29
- requestQueue
30
- });
16
+ function createEntities({ context, entities, destinationEntitiesById, requestQueue }) {
17
+ return createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, requestQueue });
31
18
  }
32
-
19
+ exports.createEntities = createEntities;
33
20
  // TODO
34
21
  // Locales need to be created in series
35
- function createLocales({
36
- context,
37
- entities,
38
- destinationEntitiesById,
39
- requestQueue
40
- }) {
41
- return createEntitiesInSequence({
42
- context,
43
- entities,
44
- destinationEntitiesById,
45
- requestQueue
46
- });
22
+ function createLocales({ context, entities, destinationEntitiesById, requestQueue }) {
23
+ return createEntitiesInSequence({ context, entities, destinationEntitiesById, requestQueue });
47
24
  }
48
- async function createEntitiesWithConcurrency({
49
- context,
50
- entities,
51
- destinationEntitiesById,
52
- requestQueue
53
- }) {
54
- const pendingCreatedEntities = entities.map(entity => {
55
- const destinationEntity = getDestinationEntityForSourceEntity(destinationEntitiesById, entity.transformed);
56
- const operation = destinationEntity ? 'update' : 'create';
57
- return requestQueue.add(async () => {
58
- try {
59
- const createdEntity = await (destinationEntity ? updateDestinationWithSourceData(destinationEntity, entity.transformed) : createInDestination(context, entity.transformed));
60
- creationSuccessNotifier(operation, createdEntity);
61
- return createdEntity;
62
- } catch (err) {
63
- return handleCreationErrors(entity, err);
64
- }
25
+ exports.createLocales = createLocales;
26
+ async function createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, requestQueue }) {
27
+ const pendingCreatedEntities = entities.map((entity) => {
28
+ const destinationEntity = getDestinationEntityForSourceEntity(destinationEntitiesById, entity.transformed);
29
+ const operation = destinationEntity ? 'update' : 'create';
30
+ return requestQueue.add(async () => {
31
+ try {
32
+ const createdEntity = await (destinationEntity
33
+ ? updateDestinationWithSourceData(destinationEntity, entity.transformed)
34
+ : createInDestination(context, entity.transformed));
35
+ creationSuccessNotifier(operation, createdEntity);
36
+ return createdEntity;
37
+ }
38
+ catch (err) {
39
+ return handleCreationErrors(entity, err);
40
+ }
41
+ });
65
42
  });
66
- });
67
- const createdEntities = await Promise.all(pendingCreatedEntities);
68
-
69
- // Filter null values in case of errors
70
- return createdEntities.filter(entity => entity);
43
+ const createdEntities = await Promise.all(pendingCreatedEntities);
44
+ // Filter null values in case of errors
45
+ return createdEntities.filter((entity) => entity);
71
46
  }
72
- async function createEntitiesInSequence({
73
- context,
74
- entities,
75
- destinationEntitiesById,
76
- requestQueue
77
- }) {
78
- const createdEntities = [];
79
- for (const entity of entities) {
80
- const destinationEntity = getDestinationEntityForSourceEntity(destinationEntitiesById, entity.transformed);
81
- const operation = destinationEntity ? 'update' : 'create';
82
- try {
83
- // Even though we run things in sequence here,
84
- // we still want to go through the normal rate limiting queue
85
- const createdEntity = await requestQueue.add(async () => {
86
- const createdOrUpdatedEntity = await (destinationEntity ? updateDestinationWithSourceData(destinationEntity, entity.transformed) : createInDestination(context, entity.transformed));
87
- return createdOrUpdatedEntity;
88
- });
89
- creationSuccessNotifier(operation, createdEntity);
90
- createdEntities.push(createdEntity);
91
- } catch (err) {
92
- const maybeSubstituteEntity = handleCreationErrors(entity, err);
93
- if (maybeSubstituteEntity) {
94
- createdEntities.push(maybeSubstituteEntity);
95
- }
47
+ async function createEntitiesInSequence({ context, entities, destinationEntitiesById, requestQueue }) {
48
+ const createdEntities = [];
49
+ for (const entity of entities) {
50
+ const destinationEntity = getDestinationEntityForSourceEntity(destinationEntitiesById, entity.transformed);
51
+ const operation = destinationEntity ? 'update' : 'create';
52
+ try {
53
+ // Even though we run things in sequence here,
54
+ // we still want to go through the normal rate limiting queue
55
+ const createdEntity = await requestQueue.add(async () => {
56
+ const createdOrUpdatedEntity = await (destinationEntity
57
+ ? updateDestinationWithSourceData(destinationEntity, entity.transformed)
58
+ : createInDestination(context, entity.transformed));
59
+ return createdOrUpdatedEntity;
60
+ });
61
+ creationSuccessNotifier(operation, createdEntity);
62
+ createdEntities.push(createdEntity);
63
+ }
64
+ catch (err) {
65
+ const maybeSubstituteEntity = handleCreationErrors(entity, err);
66
+ if (maybeSubstituteEntity) {
67
+ createdEntities.push(maybeSubstituteEntity);
68
+ }
69
+ }
96
70
  }
97
- }
98
- return createdEntities;
71
+ return createdEntities;
99
72
  }
100
-
101
73
  /**
102
74
  * Creates a list of entries
103
75
  */
104
- async function createEntries({
105
- context,
106
- entities,
107
- destinationEntitiesById,
108
- requestQueue
109
- }) {
110
- const createdEntries = await Promise.all(entities.map(entry => {
111
- return createEntry({
112
- entry,
113
- target: context.target,
114
- skipContentModel: context.skipContentModel,
115
- destinationEntitiesById,
116
- requestQueue
117
- });
118
- }));
119
- return createdEntries.filter(entry => entry);
76
+ async function createEntries({ context, entities, destinationEntitiesById, requestQueue }) {
77
+ const createdEntries = await Promise.all(entities.map((entry) => {
78
+ return createEntry({ entry, target: context.target, skipContentModel: context.skipContentModel, destinationEntitiesById, requestQueue });
79
+ }));
80
+ return createdEntries.filter((entry) => entry);
120
81
  }
121
- async function createEntry({
122
- entry,
123
- target,
124
- skipContentModel,
125
- destinationEntitiesById,
126
- requestQueue
127
- }) {
128
- const contentTypeId = entry.original.sys.contentType.sys.id;
129
- const destinationEntry = getDestinationEntityForSourceEntity(destinationEntitiesById, entry.transformed);
130
- const operation = destinationEntry ? 'update' : 'create';
131
- try {
132
- const createdOrUpdatedEntry = await requestQueue.add(() => {
133
- return destinationEntry ? updateDestinationWithSourceData(destinationEntry, entry.transformed) : createEntryInDestination(target, contentTypeId, entry.transformed);
134
- });
135
- creationSuccessNotifier(operation, createdOrUpdatedEntry);
136
- return createdOrUpdatedEntry;
137
- } catch (err) {
138
- /* If a field doesn't exist, it means it has been removed from the content types
139
- * In that case, the field is removed from the entry, and creation is attempted again.
140
- */
141
- if (skipContentModel && err.name === 'UnknownField') {
142
- const errors = (0, _object.get)(JSON.parse(err.message), 'details.errors');
143
- entry.transformed.fields = cleanupUnknownFields(entry.transformed.fields, errors);
144
- return createEntry({
145
- entry,
146
- target,
147
- skipContentModel,
148
- destinationEntitiesById,
149
- requestQueue
150
- });
82
+ exports.createEntries = createEntries;
83
+ async function createEntry({ entry, target, skipContentModel, destinationEntitiesById, requestQueue }) {
84
+ const contentTypeId = entry.original.sys.contentType.sys.id;
85
+ const destinationEntry = getDestinationEntityForSourceEntity(destinationEntitiesById, entry.transformed);
86
+ const operation = destinationEntry ? 'update' : 'create';
87
+ try {
88
+ const createdOrUpdatedEntry = await requestQueue.add(() => {
89
+ return (destinationEntry
90
+ ? updateDestinationWithSourceData(destinationEntry, entry.transformed)
91
+ : createEntryInDestination(target, contentTypeId, entry.transformed));
92
+ });
93
+ creationSuccessNotifier(operation, createdOrUpdatedEntry);
94
+ return createdOrUpdatedEntry;
95
+ }
96
+ catch (err) {
97
+ /* If a field doesn't exist, it means it has been removed from the content types
98
+ * In that case, the field is removed from the entry, and creation is attempted again.
99
+ */
100
+ if (skipContentModel && err.name === 'UnknownField') {
101
+ const errors = (0, object_1.get)(JSON.parse(err.message), 'details.errors');
102
+ entry.transformed.fields = cleanupUnknownFields(entry.transformed.fields, errors);
103
+ return createEntry({ entry, target, skipContentModel, destinationEntitiesById, requestQueue });
104
+ }
105
+ err.entity = entry;
106
+ logging_1.logEmitter.emit('error', err);
107
+ // No need to pass this entry down to publishing if it wasn't created
108
+ return null;
151
109
  }
152
- err.entity = entry;
153
- _logging.logEmitter.emit('error', err);
154
-
155
- // No need to pass this entry down to publishing if it wasn't created
156
- return null;
157
- }
158
110
  }
159
111
  function updateDestinationWithSourceData(destinationEntity, sourceEntity) {
160
- const plainData = getPlainData(sourceEntity);
161
- (0, _object.assign)(destinationEntity, plainData);
162
- return destinationEntity.update();
112
+ const plainData = getPlainData(sourceEntity);
113
+ (0, object_1.assign)(destinationEntity, plainData);
114
+ return destinationEntity.update();
163
115
  }
164
116
  function createInDestination(context, sourceEntity) {
165
- const {
166
- type,
167
- target
168
- } = context;
169
- if (type === 'Tag') {
170
- // tags are created with a different signature
171
- return createTagInDestination(context, sourceEntity);
172
- }
173
- const id = (0, _object.get)(sourceEntity, 'sys.id');
174
- const plainData = getPlainData(sourceEntity);
175
- return id ? target[`create${type}WithId`](id, plainData) : target[`create${type}`](plainData);
117
+ const { type, target } = context;
118
+ if (type === 'Tag') {
119
+ // tags are created with a different signature
120
+ return createTagInDestination(context, sourceEntity);
121
+ }
122
+ const id = (0, object_1.get)(sourceEntity, 'sys.id');
123
+ const plainData = getPlainData(sourceEntity);
124
+ return id
125
+ ? target[`create${type}WithId`](id, plainData)
126
+ : target[`create${type}`](plainData);
176
127
  }
177
128
  function createEntryInDestination(space, contentTypeId, sourceEntity) {
178
- const id = sourceEntity.sys.id;
179
- const plainData = getPlainData(sourceEntity);
180
- return id ? space.createEntryWithId(contentTypeId, id, plainData) : space.createEntry(contentTypeId, plainData);
129
+ const id = sourceEntity.sys.id;
130
+ const plainData = getPlainData(sourceEntity);
131
+ return id
132
+ ? space.createEntryWithId(contentTypeId, id, plainData)
133
+ : space.createEntry(contentTypeId, plainData);
181
134
  }
182
135
  function createTagInDestination(context, sourceEntity) {
183
- const id = sourceEntity.sys.id;
184
- const visibility = sourceEntity.sys.visibility || 'private';
185
- const name = sourceEntity.name;
186
- return context.target.createTag(id, name, visibility);
136
+ const id = sourceEntity.sys.id;
137
+ const visibility = sourceEntity.sys.visibility || 'private';
138
+ const name = sourceEntity.name;
139
+ return context.target.createTag(id, name, visibility);
187
140
  }
188
-
189
141
  /**
190
142
  * Handles entity creation errors.
191
143
  * If the error is a VersionMismatch the error is thrown and a message is returned
192
144
  * instructing the user on what this situation probably means.
193
145
  */
194
146
  function handleCreationErrors(entity, err) {
195
- // Handle the case where a locale already exists and skip it
196
- if ((0, _object.get)(err, 'error.sys.id') === 'ValidationFailed') {
197
- const errors = (0, _object.get)(err, 'error.details.errors');
198
- if (errors && errors.length > 0 && errors[0].name === 'taken') {
199
- return entity;
147
+ // Handle the case where a locale already exists and skip it
148
+ if ((0, object_1.get)(err, 'error.sys.id') === 'ValidationFailed') {
149
+ const errors = (0, object_1.get)(err, 'error.details.errors');
150
+ if (errors && errors.length > 0 && errors[0].name === 'taken') {
151
+ return entity;
152
+ }
200
153
  }
201
- }
202
- err.entity = entity.original;
203
- _logging.logEmitter.emit('error', err);
204
-
205
- // No need to pass this entity down to publishing if it wasn't created
206
- return null;
154
+ err.entity = entity.original;
155
+ logging_1.logEmitter.emit('error', err);
156
+ // No need to pass this entity down to publishing if it wasn't created
157
+ return null;
207
158
  }
208
159
  function cleanupUnknownFields(fields, errors) {
209
- return (0, _object.omitBy)(fields, (field, fieldId) => {
210
- return (0, _collection.find)(errors, error => {
211
- const [, errorFieldId] = error.path;
212
- return error.name === 'unknown' && errorFieldId === fieldId;
160
+ return (0, object_1.omitBy)(fields, (field, fieldId) => {
161
+ return (0, collection_1.find)(errors, (error) => {
162
+ const [, errorFieldId] = error.path;
163
+ return error.name === 'unknown' && errorFieldId === fieldId;
164
+ });
213
165
  });
214
- });
215
166
  }
216
167
  function getDestinationEntityForSourceEntity(destinationEntitiesById, sourceEntity) {
217
- return destinationEntitiesById.get((0, _object.get)(sourceEntity, 'sys.id')) || null;
168
+ return destinationEntitiesById.get((0, object_1.get)(sourceEntity, 'sys.id')) || null;
218
169
  }
219
170
  function creationSuccessNotifier(method, createdEntity) {
220
- const verb = method[0].toUpperCase() + method.substr(1, method.length) + 'd';
221
- _logging.logEmitter.emit('info', `${verb} ${createdEntity.sys.type} ${(0, _getEntityName.default)(createdEntity)}`);
222
- return createdEntity;
171
+ const verb = method[0].toUpperCase() + method.substr(1, method.length) + 'd';
172
+ logging_1.logEmitter.emit('info', `${verb} ${createdEntity.sys.type} ${(0, get_entity_name_1.default)(createdEntity)}`);
173
+ return createdEntity;
223
174
  }
224
175
  function getPlainData(entity) {
225
- const data = entity.toPlainObject ? entity.toPlainObject() : entity;
226
- return (0, _object.omit)(data, 'sys');
227
- }
176
+ const data = entity.toPlainObject ? entity.toPlainObject() : entity;
177
+ return (0, object_1.omit)(data, 'sys');
178
+ }
@@ -1,100 +1,100 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.archiveEntities = archiveEntities;
7
- exports.publishEntities = publishEntities;
8
- var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
9
- var _logging = require("contentful-batch-libs/dist/logging");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.archiveEntities = exports.publishEntities = void 0;
7
+ const get_entity_name_1 = __importDefault(require("contentful-batch-libs/dist/get-entity-name"));
8
+ const logging_1 = require("contentful-batch-libs/dist/logging");
11
9
  /**
12
10
  * Publish a list of entities.
13
11
  * Does not return a rejected promise in the case of an error, pushing it
14
12
  * to an error buffer instead.
15
13
  */
16
- async function publishEntities({
17
- entities,
18
- requestQueue
19
- }) {
20
- const entitiesToPublish = entities.filter(entity => {
21
- if (!entity || !entity.publish) {
22
- _logging.logEmitter.emit('warning', `Unable to publish ${(0, _getEntityName.default)(entity)}`);
23
- return false;
14
+ async function publishEntities({ entities, requestQueue }) {
15
+ const entitiesToPublish = entities.filter((entity) => {
16
+ if (!entity || !entity.publish) {
17
+ logging_1.logEmitter.emit('warning', `Unable to publish ${(0, get_entity_name_1.default)(entity)}`);
18
+ return false;
19
+ }
20
+ return true;
21
+ });
22
+ if (entitiesToPublish.length === 0) {
23
+ logging_1.logEmitter.emit('info', 'Skipping publishing since zero valid entities passed');
24
+ return [];
24
25
  }
25
- return true;
26
- });
27
- if (entitiesToPublish.length === 0) {
28
- _logging.logEmitter.emit('info', 'Skipping publishing since zero valid entities passed');
29
- return [];
30
- }
31
- const entity = entities[0].original || entities[0];
32
- const type = entity.sys.type || 'unknown type';
33
- _logging.logEmitter.emit('info', `Publishing ${entities.length} ${type}s`);
34
- const result = await runQueue(entitiesToPublish, [], requestQueue);
35
- _logging.logEmitter.emit('info', `Successfully published ${result.length} ${type}s`);
36
- return result;
26
+ const entity = entities[0].original || entities[0];
27
+ const type = entity.sys.type || 'unknown type';
28
+ logging_1.logEmitter.emit('info', `Publishing ${entities.length} ${type}s`);
29
+ const result = await runQueue(entitiesToPublish, [], requestQueue);
30
+ logging_1.logEmitter.emit('info', `Successfully published ${result.length} ${type}s`);
31
+ return result;
37
32
  }
38
- async function archiveEntities({
39
- entities,
40
- requestQueue
41
- }) {
42
- const entitiesToArchive = entities.filter(entity => {
43
- if (!entity || !entity.archive) {
44
- _logging.logEmitter.emit('warning', `Unable to archive ${(0, _getEntityName.default)(entity)}`);
45
- return false;
33
+ exports.publishEntities = publishEntities;
34
+ async function archiveEntities({ entities, requestQueue }) {
35
+ const entitiesToArchive = entities.filter((entity) => {
36
+ if (!entity || !entity.archive) {
37
+ logging_1.logEmitter.emit('warning', `Unable to archive ${(0, get_entity_name_1.default)(entity)}`);
38
+ return false;
39
+ }
40
+ return true;
41
+ });
42
+ if (entitiesToArchive.length === 0) {
43
+ logging_1.logEmitter.emit('info', 'Skipping archiving since zero valid entities passed');
44
+ return [];
46
45
  }
47
- return true;
48
- });
49
- if (entitiesToArchive.length === 0) {
50
- _logging.logEmitter.emit('info', 'Skipping archiving since zero valid entities passed');
51
- return [];
52
- }
53
- const entity = entities[0].original || entities[0];
54
- const type = entity.sys.type || 'unknown type';
55
- _logging.logEmitter.emit('info', `Archiving ${entities.length} ${type}s`);
56
- const pendingArchivedEntities = entitiesToArchive.map(entity => {
57
- return requestQueue.add(async () => {
58
- try {
59
- const archivedEntity = await entity.archive();
60
- return archivedEntity;
61
- } catch (err) {
62
- err.entity = entity;
63
- _logging.logEmitter.emit('error', err);
64
- return null;
65
- }
46
+ const entity = entities[0].original || entities[0];
47
+ const type = entity.sys.type || 'unknown type';
48
+ logging_1.logEmitter.emit('info', `Archiving ${entities.length} ${type}s`);
49
+ const pendingArchivedEntities = entitiesToArchive.map((entity) => {
50
+ return requestQueue.add(async () => {
51
+ try {
52
+ const archivedEntity = await entity.archive();
53
+ return archivedEntity;
54
+ }
55
+ catch (err) {
56
+ err.entity = entity;
57
+ logging_1.logEmitter.emit('error', err);
58
+ return null;
59
+ }
60
+ });
66
61
  });
67
- });
68
- const allPossiblyArchivedEntities = await Promise.all(pendingArchivedEntities);
69
- const allArchivedEntities = allPossiblyArchivedEntities.filter(entity => entity);
70
- _logging.logEmitter.emit('info', `Successfully archived ${allArchivedEntities.length} ${type}s`);
71
- return allArchivedEntities;
62
+ const allPossiblyArchivedEntities = await Promise.all(pendingArchivedEntities);
63
+ const allArchivedEntities = allPossiblyArchivedEntities.filter((entity) => entity);
64
+ logging_1.logEmitter.emit('info', `Successfully archived ${allArchivedEntities.length} ${type}s`);
65
+ return allArchivedEntities;
72
66
  }
67
+ exports.archiveEntities = archiveEntities;
73
68
  async function runQueue(queue, result = [], requestQueue) {
74
- const publishedEntities = [];
75
- for (const entity of queue) {
76
- _logging.logEmitter.emit('info', `Publishing ${entity.sys.type} ${(0, _getEntityName.default)(entity)}`);
77
- try {
78
- const publishedEntity = await requestQueue.add(() => entity.publish());
79
- publishedEntities.push(publishedEntity);
80
- } catch (err) {
81
- err.entity = entity;
82
- _logging.logEmitter.emit('error', err);
69
+ const publishedEntities = [];
70
+ for (const entity of queue) {
71
+ logging_1.logEmitter.emit('info', `Publishing ${entity.sys.type} ${(0, get_entity_name_1.default)(entity)}`);
72
+ try {
73
+ const publishedEntity = await requestQueue.add(() => entity.publish());
74
+ publishedEntities.push(publishedEntity);
75
+ }
76
+ catch (err) {
77
+ err.entity = entity;
78
+ logging_1.logEmitter.emit('error', err);
79
+ }
83
80
  }
84
- }
85
- result = [...result, ...publishedEntities];
86
- const publishedEntityIds = new Set(publishedEntities.map(entity => entity.sys.id));
87
- const unpublishedEntities = queue.filter(entity => !publishedEntityIds.has(entity.sys.id));
88
- if (unpublishedEntities.length > 0) {
89
- if (queue.length === unpublishedEntities.length) {
90
- // Fail when queue could not publish at least one item
91
- const unpublishedEntityNames = unpublishedEntities.map(_getEntityName.default).join(', ');
92
- _logging.logEmitter.emit('error', `Could not publish the following entities: ${unpublishedEntityNames}`);
93
- } else {
94
- // Rerun queue with unpublished entities
95
- return runQueue(unpublishedEntities, result, requestQueue);
81
+ result = [
82
+ ...result,
83
+ ...publishedEntities
84
+ ];
85
+ const publishedEntityIds = new Set(publishedEntities.map((entity) => entity.sys.id));
86
+ const unpublishedEntities = queue.filter((entity) => !publishedEntityIds.has(entity.sys.id));
87
+ if (unpublishedEntities.length > 0) {
88
+ if (queue.length === unpublishedEntities.length) {
89
+ // Fail when queue could not publish at least one item
90
+ const unpublishedEntityNames = unpublishedEntities.map(get_entity_name_1.default).join(', ');
91
+ logging_1.logEmitter.emit('error', `Could not publish the following entities: ${unpublishedEntityNames}`);
92
+ }
93
+ else {
94
+ // Rerun queue with unpublished entities
95
+ return runQueue(unpublishedEntities, result, requestQueue);
96
+ }
96
97
  }
97
- }
98
- // Return only published entities + last result
99
- return result;
100
- }
98
+ // Return only published entities + last result
99
+ return result;
100
+ }