@@ -13,6 +13,7 @@ import {
1313 getCollectionName ,
1414 getLocalesFromCollections ,
1515} from "./util/index" ;
16+ import { MESSAGES } from "./util/messages" ;
1617import {
1718 validateAssetDelete ,
1819 validateAssetPublish ,
@@ -93,7 +94,7 @@ export class Mongodb {
9394 * @returns {Promise } Returns a promise
9495 */
9596 public publishAsset ( data ) {
96- debug ( `Asset publish called ${ JSON . stringify ( data ) } ` ) ;
97+ debug ( MESSAGES . ASSET . PUBLISH_INITIATED ( data ) ) ;
9798
9899 return new Promise ( async ( resolve , reject ) => {
99100 try {
@@ -127,7 +128,7 @@ export class Mongodb {
127128 upsert : true ,
128129 }
129130 ) ;
130- debug ( `Asset publish result ${ JSON . stringify ( result ) } ` ) ;
131+ debug ( MESSAGES . ASSET . PUBLISH_RESULT ( result ) ) ;
131132
132133 return resolve ( data ) ;
133134 } catch ( error ) {
@@ -142,7 +143,7 @@ export class Mongodb {
142143 * @returns {Promise } Returns a promise
143144 */
144145 public updateContentType ( contentType ) {
145- debug ( `Entry publish called ${ JSON . stringify ( contentType ) } ` ) ;
146+ debug ( MESSAGES . ENTRY . PUBLISH_INITIATED ( contentType ) ) ;
146147
147148 return new Promise ( async ( resolve , reject ) => {
148149 try {
@@ -164,11 +165,7 @@ export class Mongodb {
164165 upsert : true ,
165166 }
166167 ) ;
167- debug (
168- `Content type update result ${ JSON . stringify (
169- contentTypeUpdateResult
170- ) } `
171- ) ;
168+ debug ( MESSAGES . CONTENT_TYPE . UPDATE_RESULT ( contentTypeUpdateResult ) ) ;
172169
173170 return resolve ( contentType ) ;
174171 } catch ( error ) {
@@ -183,7 +180,7 @@ export class Mongodb {
183180 * @returns {Promise } Returns a promise
184181 */
185182 public publishEntry ( entry ) {
186- debug ( `Entry publish called ${ JSON . stringify ( entry ) } ` ) ;
183+ debug ( MESSAGES . ENTRY . PUBLISH_INITIATED ( entry ) ) ;
187184
188185 return new Promise ( ( resolve , reject ) => {
189186 try {
@@ -220,7 +217,7 @@ export class Mongodb {
220217 }
221218 )
222219 . then ( ( entryPublishResult ) => {
223- debug ( `Entry publish result ${ JSON . stringify ( entryPublishResult ) } ` ) ;
220+ debug ( MESSAGES . ENTRY . PUBLISH_RESULT ( entryPublishResult ) ) ;
224221
225222 return resolve ( entry ) ;
226223 } )
@@ -270,7 +267,7 @@ export class Mongodb {
270267 * @returns {Promise } Returns a promise
271268 */
272269 private unpublishEntry ( entry ) {
273- debug ( `Delete entry called ${ JSON . stringify ( entry ) } ` ) ;
270+ debug ( MESSAGES . ENTRY . DELETE_INITIATED ( entry ) ) ;
274271
275272 return new Promise ( ( resolve , reject ) => {
276273 try {
@@ -284,7 +281,7 @@ export class Mongodb {
284281 uid : entry . uid ,
285282 } )
286283 . then ( ( result ) => {
287- debug ( `Delete entry result ${ JSON . stringify ( result ) } ` ) ;
284+ debug ( MESSAGES . ENTRY . DELETE_RESULT ( result ) ) ;
288285
289286 return resolve ( entry ) ;
290287 } )
@@ -301,7 +298,7 @@ export class Mongodb {
301298 * @returns {Promise } Returns a promise
302299 */
303300 private deleteEntry ( entry ) {
304- debug ( `Delete entry called ${ JSON . stringify ( entry ) } ` ) ;
301+ debug ( MESSAGES . ENTRY . DELETE_INITIATED ( entry ) ) ;
305302
306303 return new Promise ( ( resolve , reject ) => {
307304 try {
@@ -314,7 +311,7 @@ export class Mongodb {
314311 uid : entry . uid ,
315312 } )
316313 . then ( ( result ) => {
317- debug ( `Delete entry result ${ JSON . stringify ( result ) } ` ) ;
314+ debug ( MESSAGES . ENTRY . DELETE_RESULT ( result ) ) ;
318315
319316 return resolve ( entry ) ;
320317 } )
@@ -331,7 +328,7 @@ export class Mongodb {
331328 * @returns {Promise } Returns a promise
332329 */
333330 private unpublishAsset ( asset ) {
334- debug ( `Unpublish asset called ${ JSON . stringify ( asset ) } ` ) ;
331+ debug ( MESSAGES . ASSET . UNPUBLISH_INITIATED ( asset ) ) ;
335332
336333 return new Promise ( ( resolve , reject ) => {
337334 try {
@@ -348,7 +345,7 @@ export class Mongodb {
348345 uid : asset . uid ,
349346 } )
350347 . then ( ( result ) => {
351- debug ( `Asset unpublish status: ${ JSON . stringify ( result ) } ` ) ;
348+ debug ( MESSAGES . ASSET . UNPUBLISH_RESULT ( result ) ) ;
352349 if ( ! result ?. value ) {
353350 return resolve ( asset ) ;
354351 }
@@ -367,19 +364,13 @@ export class Mongodb {
367364 . toArray ( )
368365 . then ( ( assets ) => {
369366 if ( assets . length === 0 ) {
370- debug (
371- `Only published object of ${ JSON . stringify (
372- asset
373- ) } was present`
374- ) ;
367+ debug ( MESSAGES . ASSET . ONLY_PUBLISHED_PRESENT ( asset ) ) ;
375368
376369 return this . assetStore
377370 . unpublish ( result . value )
378371 . then ( ( ) => resolve ( asset ) ) ;
379372 }
380- debug (
381- "Asset existed in pubilshed and RTE/Markdown form. Removed published asset object."
382- ) ;
373+ debug ( MESSAGES . ASSET . EXISTED_IN_MULTIPLE_FORMS ) ;
383374
384375 return resolve ( asset ) ;
385376 } ) ;
@@ -397,7 +388,7 @@ export class Mongodb {
397388 * @returns {Promise } Returns a promise
398389 */
399390 private deleteAsset ( asset ) {
400- debug ( `Delete asset called ${ JSON . stringify ( asset ) } ` ) ;
391+ debug ( MESSAGES . ASSET . DELETE_INITIATED ( asset ) ) ;
401392
402393 return new Promise ( ( resolve , reject ) => {
403394 try {
@@ -413,7 +404,7 @@ export class Mongodb {
413404 . toArray ( )
414405 . then ( ( result ) => {
415406 if ( result . length === 0 ) {
416- debug ( "Asset did not exist!" ) ;
407+ debug ( MESSAGES . ASSET . DOES_NOT_EXIST ) ;
417408
418409 return resolve ( asset ) ;
419410 }
@@ -445,7 +436,7 @@ export class Mongodb {
445436 * @returns {Promise } Returns a promise
446437 */
447438 private deleteContentType ( contentType ) {
448- debug ( `Delete content type called ${ JSON . stringify ( contentType ) } ` ) ;
439+ debug ( MESSAGES . CONTENT_TYPE . DELETE_INITIATED ( contentType ) ) ;
449440
450441 return new Promise ( async ( resolve , reject ) => {
451442 try {
@@ -485,9 +476,7 @@ export class Mongodb {
485476 _content_type_uid : uid ,
486477 } )
487478 . then ( ( entriesDeleteResult ) => {
488- debug (
489- `Delete entries result ${ JSON . stringify ( entriesDeleteResult ) } `
490- ) ;
479+ debug ( MESSAGES . CONTENT_TYPE . DELETE_ENTRIES_RESULT ( entriesDeleteResult ) ) ;
491480
492481 return this . db
493482 . collection ( collection . name )
@@ -496,11 +485,7 @@ export class Mongodb {
496485 uid,
497486 } )
498487 . then ( ( contentTypeDeleteResult ) => {
499- debug (
500- `Content type delete result ${ JSON . stringify (
501- contentTypeDeleteResult
502- ) } `
503- ) ;
488+ debug ( MESSAGES . CONTENT_TYPE . DELETE_RESULT ( contentTypeDeleteResult ) ) ;
504489
505490 return resolve ( 0 ) ;
506491 } ) ;
0 commit comments