@@ -10,44 +10,36 @@ const BATCH_CHAR_LIMIT = 1990
10
10
* Only the supplied entry/asset IDs will be retrieved. All contentTypes
11
11
* and Locales will be retrieved.
12
12
*/
13
- export default function getOutdatedDestinationContent ( {
14
- managementClient,
15
- spaceId,
16
- entryIds = [ ] ,
17
- assetIds = [ ] ,
18
- webhookIds = [ ] ,
19
- skipContentModel,
20
- skipContent
21
- } ) {
13
+ export default function getOutdatedDestinationContent ( { managementClient, spaceId, entryIds = [ ] , assetIds = [ ] , webhookIds = [ ] , skipContentModel, skipContent} ) {
22
14
log . info ( 'Checking if destination space already has any content and retrieving it' )
23
15
24
16
return managementClient . getSpace ( spaceId )
25
17
. then ( ( space ) => {
26
- return Promise . props ( {
27
- contentTypes : skipContentModel ? Promise . resolve ( [ ] ) : space . getContentTypes ( ) . then ( extractItems ) ,
28
- entries : skipContent ? Promise . resolve ( [ ] ) : batchedIdQuery ( space , 'getEntries' , entryIds ) ,
29
- assets : skipContent ? Promise . resolve ( [ ] ) : batchedIdQuery ( space , 'getAssets' , assetIds ) ,
30
- locales : skipContentModel ? Promise . resolve ( [ ] ) : space . getLocales ( ) . then ( extractItems ) ,
31
- webhooks : [ ]
32
- } ) } , ( err ) => {
33
- log . error ( `
18
+ return Promise . props ( {
19
+ contentTypes : skipContentModel ? Promise . resolve ( [ ] ) : space . getContentTypes ( ) . then ( extractItems ) ,
20
+ entries : skipContent ? Promise . resolve ( [ ] ) : batchedIdQuery ( space , 'getEntries' , entryIds ) ,
21
+ assets : skipContent ? Promise . resolve ( [ ] ) : batchedIdQuery ( space , 'getAssets' , assetIds ) ,
22
+ locales : skipContentModel ? Promise . resolve ( [ ] ) : space . getLocales ( ) . then ( extractItems ) ,
23
+ webhooks : [ ]
24
+ } ) } , ( err ) => {
25
+ log . error ( `
34
26
The destination space was not found. This can happen for multiple reasons:
35
27
- If you haven't yet, you should create your space manually.
36
28
- If your destination space is in another organization, and your user from the source space does not have access to it, you'll need to specify separate sourceManagementToken and destinationManagementToken
37
29
38
30
Full error details below.
39
31
` )
40
- throw err
41
- } )
32
+ throw err
33
+ } )
42
34
}
43
35
44
36
function batchedIdQuery ( space , method , ids ) {
45
37
return Promise . reduce ( getIdBatches ( ids ) , ( fullResponse , batch ) => {
46
38
return space [ method ] ( { 'sys.id[in]' : batch } )
47
- . then ( ( response ) => {
48
- fullResponse = fullResponse . concat ( response . items )
49
- return fullResponse
50
- } )
39
+ . then ( ( response ) => {
40
+ fullResponse = fullResponse . concat ( response . items )
41
+ return fullResponse
42
+ } )
51
43
} , [ ] )
52
44
}
53
45
0 commit comments