@agility/content-sync 1.1.3 → 1.1.5
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 +4246 -1481
- 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 -511
- 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
|
@@ -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.getPage:', async function() {
|
|
14
|
-
|
|
15
|
-
it('should be able to retrieve a page from the store', async function() {
|
|
16
|
-
var syncClient = createSyncClient();
|
|
17
|
-
|
|
18
|
-
const page = await syncClient.store.getPage({
|
|
19
|
-
pageID: 2,
|
|
20
|
-
languageCode: languageCode
|
|
21
|
-
})
|
|
22
|
-
assert.strictEqual(page.pageID, 2, 'retrieved the page we asked for')
|
|
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.getPage:', async function() {
|
|
14
|
+
|
|
15
|
+
it('should be able to retrieve a page from the store', async function() {
|
|
16
|
+
var syncClient = createSyncClient();
|
|
17
|
+
|
|
18
|
+
const page = await syncClient.store.getPage({
|
|
19
|
+
pageID: 2,
|
|
20
|
+
languageCode: languageCode
|
|
21
|
+
})
|
|
22
|
+
assert.strictEqual(page.pageID, 2, 'retrieved the page we asked for')
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
|
|
@@ -1,26 +1,26 @@
|
|
|
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.getUrlRedirections:', async function() {
|
|
14
|
-
|
|
15
|
-
it('should be able to retrieve the redirections from the store', async function() {
|
|
16
|
-
var syncClient = createSyncClient();
|
|
17
|
-
|
|
18
|
-
const redirections = await syncClient.store.getUrlRedirections({
|
|
19
|
-
languageCode: languageCode
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
assert.isArray(redirections.items, 'items should be an array.')
|
|
23
|
-
assert.isBoolean(redirections.isUpToDate, 'isUpToDate should be a boolean.')
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
|
|
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.getUrlRedirections:', async function() {
|
|
14
|
+
|
|
15
|
+
it('should be able to retrieve the redirections from the store', async function() {
|
|
16
|
+
var syncClient = createSyncClient();
|
|
17
|
+
|
|
18
|
+
const redirections = await syncClient.store.getUrlRedirections({
|
|
19
|
+
languageCode: languageCode
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
assert.isArray(redirections.items, 'items should be an array.')
|
|
23
|
+
assert.isBoolean(redirections.isUpToDate, 'isUpToDate should be a boolean.')
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
|
|
@@ -1,29 +1,29 @@
|
|
|
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
|
-
|
|
12
|
-
const languageCode = 'en-us'
|
|
13
|
-
describe('clearSync:', async function() {
|
|
14
|
-
|
|
15
|
-
it('should run the clear sync method which should remove local files', async function() {
|
|
16
|
-
var sync = createSyncClient();
|
|
17
|
-
|
|
18
|
-
await sync.clearSync();
|
|
19
|
-
|
|
20
|
-
//test items are no longer there
|
|
21
|
-
const contentItem = await sync.store.getContentItem({
|
|
22
|
-
contentID: 21,
|
|
23
|
-
languageCode: languageCode
|
|
24
|
-
})
|
|
25
|
-
assert.strictEqual(contentItem, null, 'item that should be there is no longer there')
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
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
|
+
|
|
12
|
+
const languageCode = 'en-us'
|
|
13
|
+
describe('clearSync:', async function() {
|
|
14
|
+
|
|
15
|
+
it('should run the clear sync method which should remove local files', async function() {
|
|
16
|
+
var sync = createSyncClient();
|
|
17
|
+
|
|
18
|
+
await sync.clearSync();
|
|
19
|
+
|
|
20
|
+
//test items are no longer there
|
|
21
|
+
const contentItem = await sync.store.getContentItem({
|
|
22
|
+
contentID: 21,
|
|
23
|
+
languageCode: languageCode
|
|
24
|
+
})
|
|
25
|
+
assert.strictEqual(contentItem, null, 'item that should be there is no longer there')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
//import agilitySync from '../dist/agility-sync-sdk.node'
|
|
2
|
-
import agilitySync from '../src/sync-client'
|
|
3
|
-
|
|
4
|
-
import storeInterfaceConsole from '../src/store-interface-console'
|
|
5
|
-
|
|
6
|
-
// Agility Instance = 'Headless Integration Testing' [Dev]
|
|
7
|
-
const guid = 'c741222b-1080-45f6-9a7f-982381c5a485';
|
|
8
|
-
const apiKeyFetch = 'UnitTestsFetch.2ace650991363fbcffa6776d411d1b0d616b8e3424ce842b81cba7af0039197e';
|
|
9
|
-
const apiKeyPreview = 'UnitTestsPreview.69e6bca345ced0b7ca5ab358b351ea5c870790a5945c25d749a865332906b124';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function createSyncClient() {
|
|
13
|
-
var syncClient = agilitySync.getSyncClient({
|
|
14
|
-
guid: guid,
|
|
15
|
-
apiKey: apiKeyFetch,
|
|
16
|
-
isPreview: false,
|
|
17
|
-
channels: [ 'website'],
|
|
18
|
-
languages: ['en-us'],
|
|
19
|
-
baseUrl: "https://api-dev.aglty.io"
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return syncClient;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function createSyncClientUsingConsoleStore() {
|
|
26
|
-
var syncClient = agilitySync.getSyncClient({
|
|
27
|
-
guid: guid,
|
|
28
|
-
apiKey: apiKeyFetch,
|
|
29
|
-
isPreview: false,
|
|
30
|
-
channels: [ 'website'],
|
|
31
|
-
languages: ['en-us'],
|
|
32
|
-
store: {
|
|
33
|
-
interface: storeInterfaceConsole,
|
|
34
|
-
options: {}
|
|
35
|
-
},
|
|
36
|
-
baseUrl: "https://api-dev.aglty.io"
|
|
37
|
-
});
|
|
38
|
-
return syncClient;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function createPreviewSyncClient() {
|
|
43
|
-
var syncClient = agilitySync.getSyncClient({
|
|
44
|
-
guid: guid,
|
|
45
|
-
apiKey: apiKeyPreview,
|
|
46
|
-
isPreview: true,
|
|
47
|
-
channels: [ 'website'],
|
|
48
|
-
languages: ['en-us'],
|
|
49
|
-
baseUrl: "https://api-dev.aglty.io"
|
|
50
|
-
});
|
|
51
|
-
return syncClient;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
createSyncClient,
|
|
56
|
-
createSyncClientUsingConsoleStore,
|
|
57
|
-
createPreviewSyncClient
|
|
1
|
+
//import agilitySync from '../dist/agility-sync-sdk.node'
|
|
2
|
+
import agilitySync from '../src/sync-client'
|
|
3
|
+
|
|
4
|
+
import storeInterfaceConsole from '../src/store-interface-console'
|
|
5
|
+
|
|
6
|
+
// Agility Instance = 'Headless Integration Testing' [Dev]
|
|
7
|
+
const guid = 'c741222b-1080-45f6-9a7f-982381c5a485';
|
|
8
|
+
const apiKeyFetch = 'UnitTestsFetch.2ace650991363fbcffa6776d411d1b0d616b8e3424ce842b81cba7af0039197e';
|
|
9
|
+
const apiKeyPreview = 'UnitTestsPreview.69e6bca345ced0b7ca5ab358b351ea5c870790a5945c25d749a865332906b124';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function createSyncClient() {
|
|
13
|
+
var syncClient = agilitySync.getSyncClient({
|
|
14
|
+
guid: guid,
|
|
15
|
+
apiKey: apiKeyFetch,
|
|
16
|
+
isPreview: false,
|
|
17
|
+
channels: [ 'website'],
|
|
18
|
+
languages: ['en-us'],
|
|
19
|
+
baseUrl: "https://api-dev.aglty.io"
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return syncClient;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createSyncClientUsingConsoleStore() {
|
|
26
|
+
var syncClient = agilitySync.getSyncClient({
|
|
27
|
+
guid: guid,
|
|
28
|
+
apiKey: apiKeyFetch,
|
|
29
|
+
isPreview: false,
|
|
30
|
+
channels: [ 'website'],
|
|
31
|
+
languages: ['en-us'],
|
|
32
|
+
store: {
|
|
33
|
+
interface: storeInterfaceConsole,
|
|
34
|
+
options: {}
|
|
35
|
+
},
|
|
36
|
+
baseUrl: "https://api-dev.aglty.io"
|
|
37
|
+
});
|
|
38
|
+
return syncClient;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
function createPreviewSyncClient() {
|
|
43
|
+
var syncClient = agilitySync.getSyncClient({
|
|
44
|
+
guid: guid,
|
|
45
|
+
apiKey: apiKeyPreview,
|
|
46
|
+
isPreview: true,
|
|
47
|
+
channels: [ 'website'],
|
|
48
|
+
languages: ['en-us'],
|
|
49
|
+
baseUrl: "https://api-dev.aglty.io"
|
|
50
|
+
});
|
|
51
|
+
return syncClient;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
createSyncClient,
|
|
56
|
+
createSyncClientUsingConsoleStore,
|
|
57
|
+
createPreviewSyncClient
|
|
58
58
|
}
|
package/webpack.config.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const nodeConfig = {
|
|
5
|
-
target: 'node',
|
|
6
|
-
entry: './src/sync-client.js',
|
|
7
|
-
output: {
|
|
8
|
-
filename: 'agility-sync-sdk.node.js',
|
|
9
|
-
path: path.resolve(__dirname, 'dist'),
|
|
10
|
-
library: 'agilitySync',
|
|
11
|
-
libraryTarget: 'umd',
|
|
12
|
-
libraryExport: 'default',
|
|
13
|
-
umdNamedDefine: true,
|
|
14
|
-
globalObject: 'typeof self !== \'undefined\' ? self : this'
|
|
15
|
-
},
|
|
16
|
-
optimization: {
|
|
17
|
-
minimize: false
|
|
18
|
-
},
|
|
19
|
-
module: {
|
|
20
|
-
rules : [
|
|
21
|
-
// JavaScript
|
|
22
|
-
{
|
|
23
|
-
test: /\.js$/,
|
|
24
|
-
exclude: /node_modules/,
|
|
25
|
-
use: ['babel-loader'],
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
// Plugins
|
|
30
|
-
plugins: []
|
|
31
|
-
}
|
|
32
|
-
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const nodeConfig = {
|
|
5
|
+
target: 'node',
|
|
6
|
+
entry: './src/sync-client.js',
|
|
7
|
+
output: {
|
|
8
|
+
filename: 'agility-sync-sdk.node.js',
|
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
|
10
|
+
library: 'agilitySync',
|
|
11
|
+
libraryTarget: 'umd',
|
|
12
|
+
libraryExport: 'default',
|
|
13
|
+
umdNamedDefine: true,
|
|
14
|
+
globalObject: 'typeof self !== \'undefined\' ? self : this'
|
|
15
|
+
},
|
|
16
|
+
optimization: {
|
|
17
|
+
minimize: false
|
|
18
|
+
},
|
|
19
|
+
module: {
|
|
20
|
+
rules : [
|
|
21
|
+
// JavaScript
|
|
22
|
+
{
|
|
23
|
+
test: /\.js$/,
|
|
24
|
+
exclude: /node_modules/,
|
|
25
|
+
use: ['babel-loader'],
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
// Plugins
|
|
30
|
+
plugins: []
|
|
31
|
+
}
|
|
32
|
+
|
|
33
33
|
module.exports = nodeConfig
|