@agility/content-sync 1.1.2 → 1.1.4
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.
- package/.babelrc +6 -6
- package/.vscode/launch.json +34 -34
- package/README.md +206 -206
- package/dist/agility-sync-sdk.node.js +4244 -1473
- package/package.json +46 -46
- package/src/methods/clearSync.js +7 -7
- package/src/methods/runSync.js +94 -94
- package/src/methods/syncContent.js +80 -80
- package/src/methods/syncPages.js +75 -75
- package/src/store-interface-console.js +72 -72
- package/src/store-interface-filesystem.js +201 -198
- package/src/store-interface.js +511 -505
- package/src/sync-client.js +74 -74
- package/src/util.js +45 -45
- package/test/01-getSyncClient.tests.js +37 -37
- package/test/02-runSync.tests.js +74 -74
- package/test/03-store.getContentItem.tests.js +25 -25
- package/test/04-store.getContentList.tests.js +67 -67
- package/test/05-store.getPage.tests.js +25 -25
- package/test/06-store.getRedirects.tests.js +26 -26
- package/test/99-clearSync.tests.js +29 -29
- package/test/_syncClients.config.js +57 -57
- package/webpack.config.js +32 -32
package/src/sync-client.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import agility from '@agility/content-fetch'
|
|
2
|
-
import syncContent from './methods/syncContent'
|
|
3
|
-
import clearSync from './methods/clearSync'
|
|
4
|
-
import syncPages from './methods/syncPages'
|
|
5
|
-
import runSync from './methods/runSync'
|
|
6
|
-
|
|
7
|
-
import storeInterface from './store-interface'
|
|
8
|
-
import storeInterfaceFileSystem from './store-interface-filesystem'
|
|
9
|
-
|
|
10
|
-
function getSyncClient (userConfig) {
|
|
11
|
-
validateConfigParams(userConfig);
|
|
12
|
-
return createSyncClient(userConfig);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function validateConfigParams(configParams) {
|
|
16
|
-
|
|
17
|
-
if(!configParams.guid || configParams.guid.length == 0) {
|
|
18
|
-
throw new TypeError('You must provide an guid.');
|
|
19
|
-
} else if(!configParams.apiKey || configParams.apiKey.length == 0) {
|
|
20
|
-
throw new TypeError('You must provide an access token.');
|
|
21
|
-
} else {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const defaultConfig = {
|
|
27
|
-
baseUrl: null,
|
|
28
|
-
isPreview: false,
|
|
29
|
-
guid: null,
|
|
30
|
-
apiKey: null,
|
|
31
|
-
languages: [],
|
|
32
|
-
channels: [],
|
|
33
|
-
debug: false,
|
|
34
|
-
store: {
|
|
35
|
-
interface: storeInterfaceFileSystem,
|
|
36
|
-
options: {
|
|
37
|
-
rootPath: '.agility-files'
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function createSyncClient(userConfig) {
|
|
43
|
-
let config = {
|
|
44
|
-
...defaultConfig,
|
|
45
|
-
...userConfig
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const agilityClient = agility.getApi({
|
|
50
|
-
guid: config.guid,
|
|
51
|
-
apiKey: config.apiKey,
|
|
52
|
-
isPreview: config.isPreview,
|
|
53
|
-
debug: config.debug,
|
|
54
|
-
baseUrl: config.baseUrl
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//resolve the dependancy for store interface implementation (uses file-system by default)
|
|
59
|
-
let store = config.store.interface;
|
|
60
|
-
|
|
61
|
-
//set the sync storage interface provider, it will also validate it
|
|
62
|
-
storeInterface.setStore(store, config.store.options);
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
config,
|
|
66
|
-
agilityClient,
|
|
67
|
-
syncContent,
|
|
68
|
-
syncPages,
|
|
69
|
-
clearSync,
|
|
70
|
-
runSync,
|
|
71
|
-
store: storeInterface
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
1
|
+
import agility from '@agility/content-fetch'
|
|
2
|
+
import syncContent from './methods/syncContent'
|
|
3
|
+
import clearSync from './methods/clearSync'
|
|
4
|
+
import syncPages from './methods/syncPages'
|
|
5
|
+
import runSync from './methods/runSync'
|
|
6
|
+
|
|
7
|
+
import storeInterface from './store-interface'
|
|
8
|
+
import storeInterfaceFileSystem from './store-interface-filesystem'
|
|
9
|
+
|
|
10
|
+
function getSyncClient (userConfig) {
|
|
11
|
+
validateConfigParams(userConfig);
|
|
12
|
+
return createSyncClient(userConfig);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function validateConfigParams(configParams) {
|
|
16
|
+
|
|
17
|
+
if(!configParams.guid || configParams.guid.length == 0) {
|
|
18
|
+
throw new TypeError('You must provide an guid.');
|
|
19
|
+
} else if(!configParams.apiKey || configParams.apiKey.length == 0) {
|
|
20
|
+
throw new TypeError('You must provide an access token.');
|
|
21
|
+
} else {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const defaultConfig = {
|
|
27
|
+
baseUrl: null,
|
|
28
|
+
isPreview: false,
|
|
29
|
+
guid: null,
|
|
30
|
+
apiKey: null,
|
|
31
|
+
languages: [],
|
|
32
|
+
channels: [],
|
|
33
|
+
debug: false,
|
|
34
|
+
store: {
|
|
35
|
+
interface: storeInterfaceFileSystem,
|
|
36
|
+
options: {
|
|
37
|
+
rootPath: '.agility-files'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function createSyncClient(userConfig) {
|
|
43
|
+
let config = {
|
|
44
|
+
...defaultConfig,
|
|
45
|
+
...userConfig
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const agilityClient = agility.getApi({
|
|
50
|
+
guid: config.guid,
|
|
51
|
+
apiKey: config.apiKey,
|
|
52
|
+
isPreview: config.isPreview,
|
|
53
|
+
debug: config.debug,
|
|
54
|
+
baseUrl: config.baseUrl
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
//resolve the dependancy for store interface implementation (uses file-system by default)
|
|
59
|
+
let store = config.store.interface;
|
|
60
|
+
|
|
61
|
+
//set the sync storage interface provider, it will also validate it
|
|
62
|
+
storeInterface.setStore(store, config.store.options);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
config,
|
|
66
|
+
agilityClient,
|
|
67
|
+
syncContent,
|
|
68
|
+
syncPages,
|
|
69
|
+
clearSync,
|
|
70
|
+
runSync,
|
|
71
|
+
store: storeInterface
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
75
|
export default { getSyncClient }
|
package/src/util.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
const asyncForEach = async (array, callback) => {
|
|
2
|
-
for (let index = 0; index < array.length; index++) {
|
|
3
|
-
await callback(array[index], index, array);
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const logSuccess = (message) => {
|
|
8
|
-
message = `AgilityCMS => ${message} `;
|
|
9
|
-
console.log('\x1b[32m%s\x1b[0m', message);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const logWarning = (message) => {
|
|
13
|
-
message = `AgilityCMS => ${message} `;
|
|
14
|
-
console.log('\x1b[33m%s\x1b[0m', message);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const logError = (message) => {
|
|
18
|
-
message = `AgilityCMS => ${message} `;
|
|
19
|
-
console.log('\x1b[31m%s\x1b[0m', message);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const logInfo = (message) => {
|
|
23
|
-
message = `AgilityCMS => ${message} `;
|
|
24
|
-
console.log(message);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const logDebug = (message) => {
|
|
28
|
-
console.log('#######################################################################');
|
|
29
|
-
message = `AgilityCMS(debug) => ${message} `;
|
|
30
|
-
console.log('"\x1b[35m%s\x1b[0m', message);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const sleep = (ms) => {
|
|
35
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = {
|
|
39
|
-
logDebug,
|
|
40
|
-
logInfo,
|
|
41
|
-
logError,
|
|
42
|
-
logWarning,
|
|
43
|
-
logSuccess,
|
|
44
|
-
asyncForEach,
|
|
45
|
-
sleep
|
|
1
|
+
const asyncForEach = async (array, callback) => {
|
|
2
|
+
for (let index = 0; index < array.length; index++) {
|
|
3
|
+
await callback(array[index], index, array);
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const logSuccess = (message) => {
|
|
8
|
+
message = `AgilityCMS => ${message} `;
|
|
9
|
+
console.log('\x1b[32m%s\x1b[0m', message);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const logWarning = (message) => {
|
|
13
|
+
message = `AgilityCMS => ${message} `;
|
|
14
|
+
console.log('\x1b[33m%s\x1b[0m', message);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const logError = (message) => {
|
|
18
|
+
message = `AgilityCMS => ${message} `;
|
|
19
|
+
console.log('\x1b[31m%s\x1b[0m', message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const logInfo = (message) => {
|
|
23
|
+
message = `AgilityCMS => ${message} `;
|
|
24
|
+
console.log(message);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const logDebug = (message) => {
|
|
28
|
+
console.log('#######################################################################');
|
|
29
|
+
message = `AgilityCMS(debug) => ${message} `;
|
|
30
|
+
console.log('"\x1b[35m%s\x1b[0m', message);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const sleep = (ms) => {
|
|
35
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
logDebug,
|
|
40
|
+
logInfo,
|
|
41
|
+
logError,
|
|
42
|
+
logWarning,
|
|
43
|
+
logSuccess,
|
|
44
|
+
asyncForEach,
|
|
45
|
+
sleep
|
|
46
46
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import chai from 'chai'
|
|
2
|
-
const assert = chai.assert;
|
|
3
|
-
|
|
4
|
-
import agilitySync from '../src/sync-client'
|
|
5
|
-
import { createSyncClientUsingConsoleStore } from './_syncClients.config'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//This is a synchronous test
|
|
9
|
-
describe('getSyncClient:', function() {
|
|
10
|
-
|
|
11
|
-
this.timeout('120s');
|
|
12
|
-
|
|
13
|
-
it('should return a sync worker object with required params', function(done) {
|
|
14
|
-
const syncClient = agilitySync.getSyncClient({
|
|
15
|
-
guid: 'some-guid',
|
|
16
|
-
apiKey: 'some-access-token'
|
|
17
|
-
});
|
|
18
|
-
assert.strictEqual(typeof(syncClient), "object");
|
|
19
|
-
done();
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should return an sync worker object in preview mode', function(done) {
|
|
23
|
-
const syncClient = agilitySync.getSyncClient({
|
|
24
|
-
guid: 'some-guid',
|
|
25
|
-
apiKey: 'some-access-token',
|
|
26
|
-
isPreview: true
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
assert.strictEqual(syncClient.config.isPreview, true);
|
|
30
|
-
done();
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should validate a valid external store interface (console)', function(done) {
|
|
34
|
-
const syncClient = createSyncClientUsingConsoleStore()
|
|
35
|
-
done();
|
|
36
|
-
})
|
|
37
|
-
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
const assert = chai.assert;
|
|
3
|
+
|
|
4
|
+
import agilitySync from '../src/sync-client'
|
|
5
|
+
import { createSyncClientUsingConsoleStore } from './_syncClients.config'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
//This is a synchronous test
|
|
9
|
+
describe('getSyncClient:', function() {
|
|
10
|
+
|
|
11
|
+
this.timeout('120s');
|
|
12
|
+
|
|
13
|
+
it('should return a sync worker object with required params', function(done) {
|
|
14
|
+
const syncClient = agilitySync.getSyncClient({
|
|
15
|
+
guid: 'some-guid',
|
|
16
|
+
apiKey: 'some-access-token'
|
|
17
|
+
});
|
|
18
|
+
assert.strictEqual(typeof(syncClient), "object");
|
|
19
|
+
done();
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('should return an sync worker object in preview mode', function(done) {
|
|
23
|
+
const syncClient = agilitySync.getSyncClient({
|
|
24
|
+
guid: 'some-guid',
|
|
25
|
+
apiKey: 'some-access-token',
|
|
26
|
+
isPreview: true
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
assert.strictEqual(syncClient.config.isPreview, true);
|
|
30
|
+
done();
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('should validate a valid external store interface (console)', function(done) {
|
|
34
|
+
const syncClient = createSyncClientUsingConsoleStore()
|
|
35
|
+
done();
|
|
36
|
+
})
|
|
37
|
+
|
|
38
38
|
});
|
package/test/02-runSync.tests.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import chai from 'chai'
|
|
2
|
-
const assert = chai.assert;
|
|
3
|
-
const expect = chai.expect;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { createSyncClient, createSyncClientUsingConsoleStore, createPreviewSyncClient } from './_syncClients.config'
|
|
7
|
-
|
|
8
|
-
const sleep = (ms) => {
|
|
9
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
This file contains static references to content from the instance configured in the apiClient.config file.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
//this file should always run first in the tests...
|
|
18
|
-
|
|
19
|
-
describe('runSync:', async function () {
|
|
20
|
-
|
|
21
|
-
this.timeout('120s');
|
|
22
|
-
|
|
23
|
-
it('should run 1 sync method using the filesystem', async function () {
|
|
24
|
-
|
|
25
|
-
var sync = createSyncClient();
|
|
26
|
-
await sync.runSync();
|
|
27
|
-
|
|
28
|
-
await sync.clearSync();
|
|
29
|
-
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
it('should run 3 syncs at the same time method using the filesystem', async function () {
|
|
34
|
-
|
|
35
|
-
let sync1 = createSyncClient();
|
|
36
|
-
let sync2 = createSyncClient();
|
|
37
|
-
let sync3 = createSyncClient();
|
|
38
|
-
|
|
39
|
-
let p1 = sync1.runSync();
|
|
40
|
-
let p2 = sync2.runSync();
|
|
41
|
-
let p3 = sync3.runSync();
|
|
42
|
-
|
|
43
|
-
await Promise.all([p1, p2, p3])
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
it('should run 3 syncs 1.5 secs apart', async function () {
|
|
49
|
-
|
|
50
|
-
let sync1 = createSyncClient();
|
|
51
|
-
let sync2 = createSyncClient();
|
|
52
|
-
let sync3 = createSyncClient();
|
|
53
|
-
await sleep(1500)
|
|
54
|
-
await sync1.runSync();
|
|
55
|
-
await sleep(1500)
|
|
56
|
-
await sync2.runSync();
|
|
57
|
-
await sleep(1500)
|
|
58
|
-
await sync3.runSync();
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('runSync:', async function () {
|
|
65
|
-
|
|
66
|
-
this.timeout('120s');
|
|
67
|
-
|
|
68
|
-
it('should run sync method using the console store', async function () {
|
|
69
|
-
var sync = createSyncClientUsingConsoleStore();
|
|
70
|
-
await sync.runSync();
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
const assert = chai.assert;
|
|
3
|
+
const expect = chai.expect;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import { createSyncClient, createSyncClientUsingConsoleStore, createPreviewSyncClient } from './_syncClients.config'
|
|
7
|
+
|
|
8
|
+
const sleep = (ms) => {
|
|
9
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
This file contains static references to content from the instance configured in the apiClient.config file.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
//this file should always run first in the tests...
|
|
18
|
+
|
|
19
|
+
describe('runSync:', async function () {
|
|
20
|
+
|
|
21
|
+
this.timeout('120s');
|
|
22
|
+
|
|
23
|
+
it('should run 1 sync method using the filesystem', async function () {
|
|
24
|
+
|
|
25
|
+
var sync = createSyncClient();
|
|
26
|
+
await sync.runSync();
|
|
27
|
+
|
|
28
|
+
await sync.clearSync();
|
|
29
|
+
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
it('should run 3 syncs at the same time method using the filesystem', async function () {
|
|
34
|
+
|
|
35
|
+
let sync1 = createSyncClient();
|
|
36
|
+
let sync2 = createSyncClient();
|
|
37
|
+
let sync3 = createSyncClient();
|
|
38
|
+
|
|
39
|
+
let p1 = sync1.runSync();
|
|
40
|
+
let p2 = sync2.runSync();
|
|
41
|
+
let p3 = sync3.runSync();
|
|
42
|
+
|
|
43
|
+
await Promise.all([p1, p2, p3])
|
|
44
|
+
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
it('should run 3 syncs 1.5 secs apart', async function () {
|
|
49
|
+
|
|
50
|
+
let sync1 = createSyncClient();
|
|
51
|
+
let sync2 = createSyncClient();
|
|
52
|
+
let sync3 = createSyncClient();
|
|
53
|
+
await sleep(1500)
|
|
54
|
+
await sync1.runSync();
|
|
55
|
+
await sleep(1500)
|
|
56
|
+
await sync2.runSync();
|
|
57
|
+
await sleep(1500)
|
|
58
|
+
await sync3.runSync();
|
|
59
|
+
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('runSync:', async function () {
|
|
65
|
+
|
|
66
|
+
this.timeout('120s');
|
|
67
|
+
|
|
68
|
+
it('should run sync method using the console store', async function () {
|
|
69
|
+
var sync = createSyncClientUsingConsoleStore();
|
|
70
|
+
await sync.runSync();
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import chai from 'chai'
|
|
2
|
-
const assert = chai.assert;
|
|
3
|
-
const expect = chai.expect;
|
|
4
|
-
|
|
5
|
-
import { createSyncClient, createPreviewSyncClient } from './_syncClients.config'
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
This file contains static references to content from the instance configured in the apiClient.config file.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const languageCode = 'en-us'
|
|
12
|
-
|
|
13
|
-
describe('store.getContentItem:', async function() {
|
|
14
|
-
|
|
15
|
-
it('should be able to retrieve an item from the store', async function() {
|
|
16
|
-
var syncClient = createSyncClient();
|
|
17
|
-
const contentItem = await syncClient.store.getContentItem({
|
|
18
|
-
contentID: 21,
|
|
19
|
-
languageCode: languageCode,
|
|
20
|
-
})
|
|
21
|
-
assert.strictEqual(contentItem.contentID, 21, 'retrieved the content item we asked for')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
const assert = chai.assert;
|
|
3
|
+
const expect = chai.expect;
|
|
4
|
+
|
|
5
|
+
import { createSyncClient, createPreviewSyncClient } from './_syncClients.config'
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
This file contains static references to content from the instance configured in the apiClient.config file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const languageCode = 'en-us'
|
|
12
|
+
|
|
13
|
+
describe('store.getContentItem:', async function() {
|
|
14
|
+
|
|
15
|
+
it('should be able to retrieve an item from the store', async function() {
|
|
16
|
+
var syncClient = createSyncClient();
|
|
17
|
+
const contentItem = await syncClient.store.getContentItem({
|
|
18
|
+
contentID: 21,
|
|
19
|
+
languageCode: languageCode,
|
|
20
|
+
})
|
|
21
|
+
assert.strictEqual(contentItem.contentID, 21, 'retrieved the content item we asked for')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
});
|
|
25
|
+
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import chai from 'chai'
|
|
2
|
-
const assert = chai.assert;
|
|
3
|
-
const expect = chai.expect;
|
|
4
|
-
|
|
5
|
-
import { createSyncClient, createPreviewSyncClient } from './_syncClients.config'
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
This file contains static references to content from the instance configured in the apiClient.config file.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const languageCode = 'en-us'
|
|
12
|
-
|
|
13
|
-
describe('store.getContentList:', async function() {
|
|
14
|
-
|
|
15
|
-
it('should be able to retrieve a list from the store', async function() {
|
|
16
|
-
var syncClient = createSyncClient();
|
|
17
|
-
|
|
18
|
-
const contentList = await syncClient.store.getContentList({
|
|
19
|
-
referenceName: 'posts',
|
|
20
|
-
languageCode: languageCode
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
assert.strictEqual(contentList[0].properties.referenceName, "posts", 'retrieved the content list we asked for')
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
it('should be able to expand and page a list from the store', async function() {
|
|
28
|
-
var syncClient = createSyncClient();
|
|
29
|
-
|
|
30
|
-
const contentList = await syncClient.store.getContentList({
|
|
31
|
-
referenceName: 'posts',
|
|
32
|
-
languageCode: languageCode,
|
|
33
|
-
depth: 2,
|
|
34
|
-
take: 1,
|
|
35
|
-
skip: 1,
|
|
36
|
-
expandAllContentLinks: true
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
assert.isAtLeast(contentList.totalCount, 1, 'retrieved the totalCount of the content list we asked for')
|
|
40
|
-
assert.exists(contentList.items, 'retrieved the items of the content list we asked for')
|
|
41
|
-
assert.exists(contentList.items[0].fields, 'retrieved the item of the content list we asked for')
|
|
42
|
-
assert.strictEqual(contentList.items.length, 1, 'retrieved only the item of the content list we asked for')
|
|
43
|
-
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
it('should be able to expand a nested list with expandAllContentLinks', async function () {
|
|
48
|
-
var syncClient = createSyncClient();
|
|
49
|
-
|
|
50
|
-
const contentList = await syncClient.store.getContentList({
|
|
51
|
-
referenceName: 'listwithnestedcontentlink',
|
|
52
|
-
languageCode: languageCode,
|
|
53
|
-
depth: 10,
|
|
54
|
-
take: 50,
|
|
55
|
-
skip: 0,
|
|
56
|
-
expandAllContentLinks: true
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
assert.isAtLeast(contentList.totalCount, 1, 'retrieved the totalCount of the content list we asked for')
|
|
60
|
-
assert.exists(contentList.items, 'retrieved the items of the content list we asked for')
|
|
61
|
-
assert.exists(contentList.items[0].fields, 'retrieved the item of the content list we asked for')
|
|
62
|
-
assert.isAtLeast(contentList.items[0].fields.posts.length, 1, 'expanded the linked cotnent of the posts field')
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
|
|
1
|
+
import chai from 'chai'
|
|
2
|
+
const assert = chai.assert;
|
|
3
|
+
const expect = chai.expect;
|
|
4
|
+
|
|
5
|
+
import { createSyncClient, createPreviewSyncClient } from './_syncClients.config'
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
This file contains static references to content from the instance configured in the apiClient.config file.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const languageCode = 'en-us'
|
|
12
|
+
|
|
13
|
+
describe('store.getContentList:', async function() {
|
|
14
|
+
|
|
15
|
+
it('should be able to retrieve a list from the store', async function() {
|
|
16
|
+
var syncClient = createSyncClient();
|
|
17
|
+
|
|
18
|
+
const contentList = await syncClient.store.getContentList({
|
|
19
|
+
referenceName: 'posts',
|
|
20
|
+
languageCode: languageCode
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
assert.strictEqual(contentList[0].properties.referenceName, "posts", 'retrieved the content list we asked for')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
it('should be able to expand and page a list from the store', async function() {
|
|
28
|
+
var syncClient = createSyncClient();
|
|
29
|
+
|
|
30
|
+
const contentList = await syncClient.store.getContentList({
|
|
31
|
+
referenceName: 'posts',
|
|
32
|
+
languageCode: languageCode,
|
|
33
|
+
depth: 2,
|
|
34
|
+
take: 1,
|
|
35
|
+
skip: 1,
|
|
36
|
+
expandAllContentLinks: true
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
assert.isAtLeast(contentList.totalCount, 1, 'retrieved the totalCount of the content list we asked for')
|
|
40
|
+
assert.exists(contentList.items, 'retrieved the items of the content list we asked for')
|
|
41
|
+
assert.exists(contentList.items[0].fields, 'retrieved the item of the content list we asked for')
|
|
42
|
+
assert.strictEqual(contentList.items.length, 1, 'retrieved only the item of the content list we asked for')
|
|
43
|
+
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
it('should be able to expand a nested list with expandAllContentLinks', async function () {
|
|
48
|
+
var syncClient = createSyncClient();
|
|
49
|
+
|
|
50
|
+
const contentList = await syncClient.store.getContentList({
|
|
51
|
+
referenceName: 'listwithnestedcontentlink',
|
|
52
|
+
languageCode: languageCode,
|
|
53
|
+
depth: 10,
|
|
54
|
+
take: 50,
|
|
55
|
+
skip: 0,
|
|
56
|
+
expandAllContentLinks: true
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
assert.isAtLeast(contentList.totalCount, 1, 'retrieved the totalCount of the content list we asked for')
|
|
60
|
+
assert.exists(contentList.items, 'retrieved the items of the content list we asked for')
|
|
61
|
+
assert.exists(contentList.items[0].fields, 'retrieved the item of the content list we asked for')
|
|
62
|
+
assert.isAtLeast(contentList.items[0].fields.posts.length, 1, 'expanded the linked cotnent of the posts field')
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
|