@agility/content-sync 1.1.9 → 1.2.0-beta.3

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.
Files changed (66) hide show
  1. package/.babelrc +9 -6
  2. package/dist/agility-sync-sdk.node.js +9282 -8644
  3. package/dist/index.d.ts +20 -0
  4. package/dist/index.js +25 -0
  5. package/dist/methods/clearSync.d.ts +3 -0
  6. package/dist/methods/clearSync.js +21 -0
  7. package/dist/methods/runSync.d.ts +39 -0
  8. package/dist/methods/runSync.js +94 -0
  9. package/dist/methods/syncAssets.d.ts +18 -0
  10. package/dist/methods/syncAssets.js +34 -0
  11. package/dist/methods/syncContainers.d.ts +18 -0
  12. package/dist/methods/syncContainers.js +34 -0
  13. package/dist/methods/syncContent.d.ts +20 -0
  14. package/dist/methods/syncContent.js +83 -0
  15. package/dist/methods/syncContentModels.d.ts +10 -0
  16. package/dist/methods/syncContentModels.js +34 -0
  17. package/dist/methods/syncGalleries.d.ts +18 -0
  18. package/dist/methods/syncGalleries.js +34 -0
  19. package/dist/methods/syncPageModels.d.ts +18 -0
  20. package/dist/methods/syncPageModels.js +34 -0
  21. package/dist/methods/syncPages.d.ts +20 -0
  22. package/dist/methods/syncPages.js +82 -0
  23. package/dist/store-interface-console.d.ts +163 -0
  24. package/dist/store-interface-console.js +146 -0
  25. package/dist/store-interface-filesystem.d.ts +166 -0
  26. package/dist/store-interface-filesystem.js +362 -0
  27. package/dist/store-interface.d.ts +69 -0
  28. package/dist/store-interface.js +430 -0
  29. package/dist/sync-client.d.ts +29 -0
  30. package/dist/sync-client.js +126 -0
  31. package/dist/types/AgilityClient.d.ts +12 -0
  32. package/dist/types/AgilityClient.js +1 -0
  33. package/dist/types/Asset.d.ts +18 -0
  34. package/dist/types/Asset.js +1 -0
  35. package/dist/types/Container.d.ts +15 -0
  36. package/dist/types/Container.js +1 -0
  37. package/dist/types/ContentItem.d.ts +20 -0
  38. package/dist/types/ContentItem.js +1 -0
  39. package/dist/types/ContentModel.d.ts +23 -0
  40. package/dist/types/ContentModel.js +1 -0
  41. package/dist/types/Gallery.d.ts +15 -0
  42. package/dist/types/Gallery.js +1 -0
  43. package/dist/types/Page.d.ts +14 -0
  44. package/dist/types/Page.js +1 -0
  45. package/dist/types/PageModel.d.ts +36 -0
  46. package/dist/types/PageModel.js +1 -0
  47. package/dist/types/StoreInterface.d.ts +165 -0
  48. package/dist/types/StoreInterface.js +1 -0
  49. package/dist/types/SyncProgress.d.ts +11 -0
  50. package/dist/types/SyncProgress.js +1 -0
  51. package/dist/types.d.ts +11 -0
  52. package/dist/types.js +1 -0
  53. package/dist/util.d.ts +7 -0
  54. package/dist/util.js +23 -0
  55. package/package.json +7 -3
  56. package/src/methods/clearSync.js +1 -2
  57. package/src/methods/runSync.js +11 -13
  58. package/src/methods/syncContent.js +5 -5
  59. package/src/methods/syncPages.js +3 -3
  60. package/src/store-interface.js +405 -423
  61. package/src/sync-client.js +17 -10
  62. package/test/03-store.getContentItem.tests.js +6 -4
  63. package/test/04-store.getContentList.tests.js +10 -10
  64. package/test/99-clearSync.tests.js +3 -3
  65. package/test/_syncClients.config.js +3 -3
  66. package/webpack.config.js +11 -0
@@ -1,10 +1,10 @@
1
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'
2
+ import syncContentInternal from './methods/syncContent'
3
+ import clearSyncInternal from './methods/clearSync'
4
+ import syncPagesInternal from './methods/syncPages'
5
+ import runSyncInternal from './methods/runSync'
6
6
 
7
- import storeInterface from './store-interface'
7
+ import { StoreInterface } from './store-interface'
8
8
  import storeInterfaceFileSystem from './store-interface-filesystem'
9
9
 
10
10
  function getSyncClient(userConfig) {
@@ -24,6 +24,7 @@ function validateConfigParams(configParams) {
24
24
  }
25
25
 
26
26
  const defaultConfig = {
27
+ region: null,
27
28
  baseUrl: null,
28
29
  isPreview: false,
29
30
  guid: null,
@@ -54,7 +55,8 @@ function createSyncClient(userConfig) {
54
55
  apiKey: config.apiKey,
55
56
  isPreview: config.isPreview,
56
57
  debug: config.debug,
57
- baseUrl: config.baseUrl
58
+ baseUrl: config.baseUrl,
59
+ region: config.region
58
60
  });
59
61
 
60
62
 
@@ -62,17 +64,22 @@ function createSyncClient(userConfig) {
62
64
  let store = config.store.interface;
63
65
 
64
66
  //set the sync storage interface provider, it will also validate it
65
- storeInterface.setStore(store, config.store.options);
67
+ const storeInterface = new StoreInterface(store, config.store.options);
68
+
69
+
70
+ const syncPages = (languageCode, token) => syncPagesInternal(languageCode, token, storeInterface, agilityClient);
71
+
72
+ const syncContent = (languageCode, token) => syncContentInternal(languageCode, token, storeInterface, agilityClient);
66
73
 
67
74
  return {
68
75
  config,
69
76
  agilityClient,
70
77
  syncContent,
71
78
  syncPages,
72
- clearSync,
73
- runSync,
79
+ clearSync: () => clearSyncInternal(storeInterface),
80
+ runSync: () => runSyncInternal(config, agilityClient, storeInterface, syncContent, syncPages),
74
81
  store: storeInterface
75
82
  }
76
83
  }
77
84
 
78
- export default { getSyncClient }
85
+ export default { getSyncClient }
@@ -10,15 +10,17 @@ import { createSyncClient, createPreviewSyncClient } from './_syncClients.config
10
10
 
11
11
  const languageCode = 'en-us'
12
12
 
13
- describe('store.getContentItem:', async function() {
13
+ describe('store.getContentItem:', async function () {
14
14
 
15
- it('should be able to retrieve an item from the store', async function() {
15
+ it('should be able to retrieve an item from the store', async function () {
16
16
  var syncClient = createSyncClient();
17
+
17
18
  const contentItem = await syncClient.store.getContentItem({
18
- contentID: 21,
19
+ contentID: 22,
19
20
  languageCode: languageCode,
20
21
  })
21
- assert.strictEqual(contentItem.contentID, 21, 'retrieved the content item we asked for')
22
+
23
+ assert.strictEqual(contentItem.contentID, 22, 'retrieved the content item we asked for')
22
24
  })
23
25
 
24
26
  });
@@ -10,9 +10,9 @@ import { createSyncClient, createPreviewSyncClient } from './_syncClients.config
10
10
 
11
11
  const languageCode = 'en-us'
12
12
 
13
- describe('store.getContentList:', async function() {
13
+ describe('store.getContentList:', async function () {
14
14
 
15
- it('should be able to retrieve a list from the store', async function() {
15
+ it('should be able to retrieve a list from the store', async function () {
16
16
  var syncClient = createSyncClient();
17
17
 
18
18
  const contentList = await syncClient.store.getContentList({
@@ -24,22 +24,22 @@ describe('store.getContentList:', async function() {
24
24
  })
25
25
 
26
26
 
27
- it('should be able to expand and page a list from the store', async function() {
27
+ it('should be able to expand and page a list from the store', async function () {
28
28
  var syncClient = createSyncClient();
29
29
 
30
30
  const contentList = await syncClient.store.getContentList({
31
31
  referenceName: 'posts',
32
32
  languageCode: languageCode,
33
- depth: 2,
34
- take: 1,
35
- skip: 1,
36
- expandAllContentLinks: true
33
+ depth: 2,
34
+ take: 1,
35
+ skip: 1,
36
+ expandAllContentLinks: true
37
37
  })
38
38
 
39
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')
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
43
 
44
44
  })
45
45
 
@@ -10,10 +10,10 @@ import { createSyncClient, createPreviewSyncClient } from './_syncClients.config
10
10
 
11
11
 
12
12
  const languageCode = 'en-us'
13
- describe('clearSync:', async function() {
13
+ describe('clearSync:', async function () {
14
14
 
15
- it('should run the clear sync method which should remove local files', async function() {
16
- var sync = createSyncClient();
15
+ it('should run the clear sync method which should remove local files', async function () {
16
+ var sync = createSyncClient();
17
17
 
18
18
  await sync.clearSync();
19
19
 
@@ -17,7 +17,7 @@ function createSyncClient() {
17
17
  logLevel: 'info',
18
18
  channels: ['website'],
19
19
  languages: ['en-us'],
20
- baseUrl: "https://api-dev.aglty.io"
20
+ baseUrl: `https://api-dev.aglty.io/${guid}`
21
21
  });
22
22
 
23
23
  return syncClient;
@@ -34,7 +34,7 @@ function createSyncClientUsingConsoleStore() {
34
34
  interface: storeInterfaceConsole,
35
35
  options: {}
36
36
  },
37
- baseUrl: "https://api-dev.aglty.io"
37
+ baseUrl: `https://api-dev.aglty.io/${guid}`
38
38
  });
39
39
  return syncClient;
40
40
  }
@@ -47,7 +47,7 @@ function createPreviewSyncClient() {
47
47
  isPreview: true,
48
48
  channels: ['website'],
49
49
  languages: ['en-us'],
50
- baseUrl: "https://api-dev.aglty.io"
50
+ baseUrl: `https://api-dev.aglty.io/${guid}`
51
51
  });
52
52
  return syncClient;
53
53
  }
package/webpack.config.js CHANGED
@@ -23,6 +23,17 @@ const nodeConfig = {
23
23
  test: /\.js$/,
24
24
  exclude: /node_modules/,
25
25
  use: ['babel-loader'],
26
+ },
27
+ // JavaScript
28
+ {
29
+ test: /\.js$/,
30
+ exclude: /node_modules\/(?!@agility\/content-fetch)/, // Transpile @agility/content-fetch
31
+ use: {
32
+ loader: 'babel-loader',
33
+ options: {
34
+ presets: ['@babel/preset-env'], // Ensure compatibility with modern syntax
35
+ }
36
+ }
26
37
  }
27
38
  ]
28
39
  },