@agility/content-sync 1.2.0-beta.4 → 1.2.0-beta.6
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/dist/agility-sync-sdk.node.js +3754 -1319
- package/package.json +2 -3
- package/src/sync-client.js +1 -1
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -25
- package/dist/methods/clearSync.d.ts +0 -3
- package/dist/methods/clearSync.js +0 -21
- package/dist/methods/runSync.d.ts +0 -39
- package/dist/methods/runSync.js +0 -94
- package/dist/methods/syncAssets.d.ts +0 -18
- package/dist/methods/syncAssets.js +0 -34
- package/dist/methods/syncContainers.d.ts +0 -18
- package/dist/methods/syncContainers.js +0 -34
- package/dist/methods/syncContent.d.ts +0 -20
- package/dist/methods/syncContent.js +0 -83
- package/dist/methods/syncContentModels.d.ts +0 -10
- package/dist/methods/syncContentModels.js +0 -34
- package/dist/methods/syncGalleries.d.ts +0 -18
- package/dist/methods/syncGalleries.js +0 -34
- package/dist/methods/syncPageModels.d.ts +0 -18
- package/dist/methods/syncPageModels.js +0 -34
- package/dist/methods/syncPages.d.ts +0 -20
- package/dist/methods/syncPages.js +0 -82
- package/dist/store-interface-console.d.ts +0 -163
- package/dist/store-interface-console.js +0 -146
- package/dist/store-interface-filesystem.d.ts +0 -166
- package/dist/store-interface-filesystem.js +0 -362
- package/dist/store-interface.d.ts +0 -69
- package/dist/store-interface.js +0 -430
- package/dist/sync-client.d.ts +0 -29
- package/dist/sync-client.js +0 -126
- package/dist/types/AgilityClient.d.ts +0 -12
- package/dist/types/AgilityClient.js +0 -1
- package/dist/types/Asset.d.ts +0 -18
- package/dist/types/Asset.js +0 -1
- package/dist/types/Container.d.ts +0 -15
- package/dist/types/Container.js +0 -1
- package/dist/types/ContentItem.d.ts +0 -20
- package/dist/types/ContentItem.js +0 -1
- package/dist/types/ContentModel.d.ts +0 -23
- package/dist/types/ContentModel.js +0 -1
- package/dist/types/Gallery.d.ts +0 -15
- package/dist/types/Gallery.js +0 -1
- package/dist/types/Page.d.ts +0 -14
- package/dist/types/Page.js +0 -1
- package/dist/types/PageModel.d.ts +0 -36
- package/dist/types/PageModel.js +0 -1
- package/dist/types/StoreInterface.d.ts +0 -165
- package/dist/types/StoreInterface.js +0 -1
- package/dist/types/SyncProgress.d.ts +0 -11
- package/dist/types/SyncProgress.js +0 -1
- package/dist/types.d.ts +0 -11
- package/dist/types.js +0 -1
- package/dist/util.d.ts +0 -7
- package/dist/util.js +0 -23
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agility/content-sync",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.6",
|
|
4
4
|
"description": "JavaScript SDK for synchronizing content from Agility CMS",
|
|
5
5
|
"main": "dist/agility-sync-sdk.node.js",
|
|
6
|
-
|
|
7
6
|
"scripts": {
|
|
8
|
-
"preinstall": "node -e \"const major = process.version.match(/^v(\\d+)/)[1]; if (major != 16) { console.error('Node 16 required, found Node ' + major); process.exit(1); }\"",
|
|
9
7
|
"test": "nyc --reporter=html --reporter=text mocha --require @babel/register --recursive ./test/",
|
|
10
8
|
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose",
|
|
11
9
|
"build": "webpack --config webpack.config -p"
|
|
@@ -39,6 +37,7 @@
|
|
|
39
37
|
"@babel/plugin-transform-runtime": "^7.28.0",
|
|
40
38
|
"@babel/preset-env": "^7.3.4",
|
|
41
39
|
"@babel/register": "^7.0.0",
|
|
40
|
+
"@babel/runtime": "^7.27.6",
|
|
42
41
|
"agility-jsdoc-template": "1.0.3",
|
|
43
42
|
"babel-loader": "^8.0.5",
|
|
44
43
|
"chai": "^4.2.0",
|
package/src/sync-client.js
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from './types/StoreInterface';
|
|
2
|
-
export * from './types/ContentItem';
|
|
3
|
-
export * from './types/Page';
|
|
4
|
-
export * from './types/Asset';
|
|
5
|
-
export * from './types/Container';
|
|
6
|
-
export { ConsoleStore } from './store-interface-console';
|
|
7
|
-
export { FileSystemStore } from './store-interface-filesystem';
|
|
8
|
-
export { SyncClient } from './sync-client';
|
|
9
|
-
export { logDebug, logInfo, logError, logWarning, logSuccess, asyncForEach } from './util';
|
|
10
|
-
export { syncContentModels } from './methods/syncContentModels';
|
|
11
|
-
export { syncPageModels } from './methods/syncPageModels';
|
|
12
|
-
import syncContent from './methods/syncContent';
|
|
13
|
-
import syncPages from './methods/syncPages';
|
|
14
|
-
export { syncContent, syncPages };
|
|
15
|
-
export { syncAssets } from './methods/syncAssets';
|
|
16
|
-
export { syncGalleries } from './methods/syncGalleries';
|
|
17
|
-
export { syncContainers } from './methods/syncContainers';
|
|
18
|
-
export { clearSync } from './methods/clearSync';
|
|
19
|
-
import runSync from './methods/runSync';
|
|
20
|
-
export { runSync };
|
package/dist/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Export types
|
|
2
|
-
export * from './types/StoreInterface';
|
|
3
|
-
export * from './types/ContentItem';
|
|
4
|
-
export * from './types/Page';
|
|
5
|
-
export * from './types/Asset';
|
|
6
|
-
export * from './types/Container';
|
|
7
|
-
// Export store interface implementations
|
|
8
|
-
export { ConsoleStore } from './store-interface-console';
|
|
9
|
-
export { FileSystemStore } from './store-interface-filesystem';
|
|
10
|
-
// Export sync client
|
|
11
|
-
export { SyncClient } from './sync-client';
|
|
12
|
-
// Export utility functions
|
|
13
|
-
export { logDebug, logInfo, logError, logWarning, logSuccess, asyncForEach } from './util';
|
|
14
|
-
// Export sync methods
|
|
15
|
-
export { syncContentModels } from './methods/syncContentModels';
|
|
16
|
-
export { syncPageModels } from './methods/syncPageModels';
|
|
17
|
-
import syncContent from './methods/syncContent';
|
|
18
|
-
import syncPages from './methods/syncPages';
|
|
19
|
-
export { syncContent, syncPages };
|
|
20
|
-
export { syncAssets } from './methods/syncAssets';
|
|
21
|
-
export { syncGalleries } from './methods/syncGalleries';
|
|
22
|
-
export { syncContainers } from './methods/syncContainers';
|
|
23
|
-
export { clearSync } from './methods/clearSync';
|
|
24
|
-
import runSync from './methods/runSync';
|
|
25
|
-
export { runSync };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { logDebug, logError } from '../util';
|
|
2
|
-
import { clear } from '../store-interface';
|
|
3
|
-
let store = null;
|
|
4
|
-
let options = null;
|
|
5
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
6
|
-
store = storeToUse;
|
|
7
|
-
options = storeOptions;
|
|
8
|
-
};
|
|
9
|
-
export const clearSync = async () => {
|
|
10
|
-
if (!store || !options) {
|
|
11
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
await clear();
|
|
15
|
-
logDebug('Cleared all sync data');
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
logError('Error clearing sync data');
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { StoreInterface, StoreOptions } from '../types/StoreInterface';
|
|
2
|
-
import type { AgilityClient } from '../types/AgilityClient';
|
|
3
|
-
export declare const setStore: (storeToUse: StoreInterface, storeOptions: StoreOptions) => void;
|
|
4
|
-
export interface SyncData {
|
|
5
|
-
contentModels?: any[];
|
|
6
|
-
pageModels?: any[];
|
|
7
|
-
assets?: any[];
|
|
8
|
-
galleries?: any[];
|
|
9
|
-
containers?: any[];
|
|
10
|
-
}
|
|
11
|
-
interface SyncProgress {
|
|
12
|
-
status: 'init' | 'progress' | 'done';
|
|
13
|
-
current?: number;
|
|
14
|
-
total?: number;
|
|
15
|
-
item?: any;
|
|
16
|
-
languageCode?: string;
|
|
17
|
-
model?: string;
|
|
18
|
-
}
|
|
19
|
-
interface SyncOptions {
|
|
20
|
-
clearData?: boolean;
|
|
21
|
-
contentModels?: boolean;
|
|
22
|
-
pageModels?: boolean;
|
|
23
|
-
content?: boolean;
|
|
24
|
-
pages?: boolean;
|
|
25
|
-
assets?: boolean;
|
|
26
|
-
galleries?: boolean;
|
|
27
|
-
containers?: boolean;
|
|
28
|
-
languageCode?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Run a complete sync operation for the specified data models
|
|
32
|
-
* @param options - Sync options including which models to sync and whether to clear data first
|
|
33
|
-
* @returns AsyncGenerator that yields progress information
|
|
34
|
-
*/
|
|
35
|
-
export default function runSync(this: {
|
|
36
|
-
store: StoreInterface;
|
|
37
|
-
agilityClient: AgilityClient;
|
|
38
|
-
}, options?: SyncOptions): AsyncGenerator<SyncProgress, void>;
|
|
39
|
-
export {};
|
package/dist/methods/runSync.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { logError, logSuccess } from '../util';
|
|
2
|
-
import { syncContentModels } from './syncContentModels';
|
|
3
|
-
import { syncPageModels } from './syncPageModels';
|
|
4
|
-
import syncContent from './syncContent';
|
|
5
|
-
import syncPages from './syncPages';
|
|
6
|
-
import { syncAssets } from './syncAssets';
|
|
7
|
-
import { syncGalleries } from './syncGalleries';
|
|
8
|
-
import { syncContainers } from './syncContainers';
|
|
9
|
-
import { clearSync } from './clearSync';
|
|
10
|
-
let store = null;
|
|
11
|
-
let options = null;
|
|
12
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
13
|
-
store = storeToUse;
|
|
14
|
-
options = storeOptions;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Run a complete sync operation for the specified data models
|
|
18
|
-
* @param options - Sync options including which models to sync and whether to clear data first
|
|
19
|
-
* @returns AsyncGenerator that yields progress information
|
|
20
|
-
*/
|
|
21
|
-
export default async function* runSync(options = {}) {
|
|
22
|
-
const { clearData = false, contentModels = false, pageModels = false, content = false, pages = false, assets = false, galleries = false, containers = false, languageCode = 'en-us' } = options;
|
|
23
|
-
// Check if store is initialized
|
|
24
|
-
if (!this.store) {
|
|
25
|
-
logError('Store not initialized. Please call setStore first.');
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
// Clear data if requested
|
|
30
|
-
if (clearData) {
|
|
31
|
-
yield { status: 'init', model: 'clear' };
|
|
32
|
-
await clearSync.call(this);
|
|
33
|
-
yield { status: 'done', model: 'clear' };
|
|
34
|
-
}
|
|
35
|
-
// Sync content models if requested
|
|
36
|
-
if (contentModels) {
|
|
37
|
-
yield { status: 'init', model: 'contentModels' };
|
|
38
|
-
await syncContentModels.call(this, languageCode);
|
|
39
|
-
yield { status: 'done', model: 'contentModels' };
|
|
40
|
-
}
|
|
41
|
-
// Sync page models if requested
|
|
42
|
-
if (pageModels) {
|
|
43
|
-
yield { status: 'init', model: 'pageModels' };
|
|
44
|
-
await syncPageModels.call(this, languageCode);
|
|
45
|
-
yield { status: 'done', model: 'pageModels' };
|
|
46
|
-
}
|
|
47
|
-
// Sync content if requested
|
|
48
|
-
if (content) {
|
|
49
|
-
yield { status: 'init', model: 'content' };
|
|
50
|
-
const contentGenerator = syncContent.call(this, languageCode);
|
|
51
|
-
for await (const progress of contentGenerator) {
|
|
52
|
-
yield { ...progress, model: 'content' };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// Sync pages if requested
|
|
56
|
-
if (pages) {
|
|
57
|
-
yield { status: 'init', model: 'pages' };
|
|
58
|
-
const pagesGenerator = syncPages.call(this, languageCode);
|
|
59
|
-
for await (const progress of pagesGenerator) {
|
|
60
|
-
yield { ...progress, model: 'pages' };
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Sync assets if requested
|
|
64
|
-
if (assets) {
|
|
65
|
-
yield { status: 'init', model: 'assets' };
|
|
66
|
-
const assetsGenerator = syncAssets.call(this, languageCode);
|
|
67
|
-
for await (const progress of assetsGenerator) {
|
|
68
|
-
yield { ...progress, model: 'assets' };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Sync galleries if requested
|
|
72
|
-
if (galleries) {
|
|
73
|
-
yield { status: 'init', model: 'galleries' };
|
|
74
|
-
const galleriesGenerator = syncGalleries.call(this, languageCode);
|
|
75
|
-
for await (const progress of galleriesGenerator) {
|
|
76
|
-
yield { ...progress, model: 'galleries' };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// Sync containers if requested
|
|
80
|
-
if (containers) {
|
|
81
|
-
yield { status: 'init', model: 'containers' };
|
|
82
|
-
const containersGenerator = syncContainers.call(this, languageCode);
|
|
83
|
-
for await (const progress of containersGenerator) {
|
|
84
|
-
yield { ...progress, model: 'containers' };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
logSuccess('Sync completed successfully');
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
91
|
-
logError(`Error during sync: ${errorMessage}`);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StoreInterface, StoreOptions } from '../types/StoreInterface';
|
|
2
|
-
export declare const setStore: (storeToUse: StoreInterface, storeOptions: StoreOptions) => void;
|
|
3
|
-
interface SyncProgress {
|
|
4
|
-
status: 'init' | 'progress' | 'done';
|
|
5
|
-
current?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
item?: any;
|
|
8
|
-
languageCode?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sync assets from Agility CMS
|
|
12
|
-
* @param languageCode - The language code to sync assets for
|
|
13
|
-
* @returns AsyncGenerator that yields progress information
|
|
14
|
-
*/
|
|
15
|
-
export declare function syncAssets(this: {
|
|
16
|
-
store: StoreInterface;
|
|
17
|
-
}, languageCode: string): AsyncGenerator<SyncProgress, void>;
|
|
18
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { logError, logInfo } from '../util';
|
|
2
|
-
let store = null;
|
|
3
|
-
let options = null;
|
|
4
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
5
|
-
store = storeToUse;
|
|
6
|
-
options = storeOptions;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Sync assets from Agility CMS
|
|
10
|
-
* @param languageCode - The language code to sync assets for
|
|
11
|
-
* @returns AsyncGenerator that yields progress information
|
|
12
|
-
*/
|
|
13
|
-
export async function* syncAssets(languageCode) {
|
|
14
|
-
const storeInterface = this.store;
|
|
15
|
-
try {
|
|
16
|
-
yield { status: 'init' };
|
|
17
|
-
// Get all assets
|
|
18
|
-
const assets = await storeInterface.getAssets({ languageCode });
|
|
19
|
-
const total = assets.length;
|
|
20
|
-
yield { status: 'progress', total };
|
|
21
|
-
// Process each asset
|
|
22
|
-
for (let i = 0; i < assets.length; i++) {
|
|
23
|
-
const asset = assets[i];
|
|
24
|
-
await storeInterface.saveAsset({ asset, languageCode });
|
|
25
|
-
yield { status: 'progress', current: i + 1, total, item: asset, languageCode };
|
|
26
|
-
}
|
|
27
|
-
yield { status: 'done' };
|
|
28
|
-
logInfo(`Synced ${total} assets`);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
logError('Error syncing assets');
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StoreInterface, StoreOptions } from '../types/StoreInterface';
|
|
2
|
-
export declare const setStore: (storeToUse: StoreInterface, storeOptions: StoreOptions) => void;
|
|
3
|
-
interface SyncProgress {
|
|
4
|
-
status: 'init' | 'progress' | 'done';
|
|
5
|
-
current?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
item?: any;
|
|
8
|
-
languageCode?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sync containers from Agility CMS
|
|
12
|
-
* @param languageCode - The language code to sync containers for
|
|
13
|
-
* @returns AsyncGenerator that yields progress information
|
|
14
|
-
*/
|
|
15
|
-
export declare function syncContainers(this: {
|
|
16
|
-
store: StoreInterface;
|
|
17
|
-
}, languageCode: string): AsyncGenerator<SyncProgress, void>;
|
|
18
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { logError, logInfo } from '../util';
|
|
2
|
-
let store = null;
|
|
3
|
-
let options = null;
|
|
4
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
5
|
-
store = storeToUse;
|
|
6
|
-
options = storeOptions;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Sync containers from Agility CMS
|
|
10
|
-
* @param languageCode - The language code to sync containers for
|
|
11
|
-
* @returns AsyncGenerator that yields progress information
|
|
12
|
-
*/
|
|
13
|
-
export async function* syncContainers(languageCode) {
|
|
14
|
-
const storeInterface = this.store;
|
|
15
|
-
try {
|
|
16
|
-
yield { status: 'init' };
|
|
17
|
-
// Get all containers
|
|
18
|
-
const containers = await storeInterface.getContainers({ languageCode });
|
|
19
|
-
const total = containers.length;
|
|
20
|
-
yield { status: 'progress', total };
|
|
21
|
-
// Process each container
|
|
22
|
-
for (let i = 0; i < containers.length; i++) {
|
|
23
|
-
const container = containers[i];
|
|
24
|
-
await storeInterface.saveContainer({ container, languageCode });
|
|
25
|
-
yield { status: 'progress', current: i + 1, total, item: container, languageCode };
|
|
26
|
-
}
|
|
27
|
-
yield { status: 'done' };
|
|
28
|
-
logInfo(`Synced ${total} containers`);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
logError('Error syncing containers');
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { StoreInterface } from '../types/StoreInterface';
|
|
2
|
-
import { AgilityClient } from '../types/AgilityClient';
|
|
3
|
-
interface SyncProgress {
|
|
4
|
-
status: 'init' | 'progress' | 'done';
|
|
5
|
-
current?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
item?: any;
|
|
8
|
-
languageCode?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sync the content items in the specified Agility Instance.
|
|
12
|
-
* @param languageCode - The language code to sync content for
|
|
13
|
-
* @param token - The sync token to start from
|
|
14
|
-
* @returns The last sync token used
|
|
15
|
-
*/
|
|
16
|
-
export default function syncContent(this: {
|
|
17
|
-
store: StoreInterface;
|
|
18
|
-
agilityClient: AgilityClient;
|
|
19
|
-
}, languageCode: string, token?: number): AsyncGenerator<SyncProgress, number>;
|
|
20
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { logInfo, logWarning, sleep } from '../util';
|
|
2
|
-
/**
|
|
3
|
-
* Sync the content items in the specified Agility Instance.
|
|
4
|
-
* @param languageCode - The language code to sync content for
|
|
5
|
-
* @param token - The sync token to start from
|
|
6
|
-
* @returns The last sync token used
|
|
7
|
-
*/
|
|
8
|
-
export default async function* syncContent(languageCode, token = 0) {
|
|
9
|
-
const storeInterface = this.store;
|
|
10
|
-
let itemCount = 0;
|
|
11
|
-
let busy = false;
|
|
12
|
-
let waitMS = 0;
|
|
13
|
-
const waitMaxMS = 10 * 60 * 1000;
|
|
14
|
-
const waitIntervalMS = 1000;
|
|
15
|
-
// Initialize progress
|
|
16
|
-
yield { status: 'init' };
|
|
17
|
-
do {
|
|
18
|
-
//sync content items...
|
|
19
|
-
const syncRet = await this.agilityClient.getSyncContent({
|
|
20
|
-
syncToken: token,
|
|
21
|
-
pageSize: 100,
|
|
22
|
-
languageCode: languageCode,
|
|
23
|
-
});
|
|
24
|
-
if (syncRet === undefined || syncRet === null || (syncRet.busy !== undefined && syncRet.busy === true)) {
|
|
25
|
-
//if the api is being updated, wait a few ms and try again...
|
|
26
|
-
waitMS += waitIntervalMS;
|
|
27
|
-
if (waitMS > waitMaxMS) {
|
|
28
|
-
logWarning("Sync API has been busy for too long, canceling.");
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
if (!busy) {
|
|
32
|
-
//first time we're busy...
|
|
33
|
-
busy = true;
|
|
34
|
-
logInfo("Sync API is busy. Waiting...");
|
|
35
|
-
}
|
|
36
|
-
await sleep(waitIntervalMS);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (busy === true) {
|
|
40
|
-
logInfo("Continuing sync...");
|
|
41
|
-
busy = false;
|
|
42
|
-
waitMS = 0;
|
|
43
|
-
}
|
|
44
|
-
const syncItems = syncRet.items;
|
|
45
|
-
//if we don't get anything back, kick out
|
|
46
|
-
if (syncItems.length > 0) {
|
|
47
|
-
for (let index = 0; index < syncItems.length; index++) {
|
|
48
|
-
const item = syncItems[index];
|
|
49
|
-
await storeInterface.saveItem({
|
|
50
|
-
options: {
|
|
51
|
-
rootPath: './data',
|
|
52
|
-
languageCode: languageCode
|
|
53
|
-
},
|
|
54
|
-
item,
|
|
55
|
-
itemType: 'content',
|
|
56
|
-
languageCode,
|
|
57
|
-
itemID: item.contentID
|
|
58
|
-
});
|
|
59
|
-
itemCount++;
|
|
60
|
-
yield {
|
|
61
|
-
status: 'progress',
|
|
62
|
-
current: itemCount,
|
|
63
|
-
item,
|
|
64
|
-
languageCode
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (syncRet.syncToken > token) {
|
|
69
|
-
token = syncRet.syncToken;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
} while (token > 0 || busy === true);
|
|
75
|
-
if (itemCount > 0) {
|
|
76
|
-
logInfo(`Content Sync returned ${itemCount} item(s).`);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
logInfo(`Content Sync returned no item(s).`);
|
|
80
|
-
}
|
|
81
|
-
yield { status: 'done' };
|
|
82
|
-
return token;
|
|
83
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { StoreInterface, StoreOptions } from '../types/StoreInterface';
|
|
2
|
-
import { SyncProgress } from '../types';
|
|
3
|
-
export declare const setStore: (storeToUse: StoreInterface, storeOptions: StoreOptions) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Sync content models from Agility CMS
|
|
6
|
-
* @param store - The store interface to use
|
|
7
|
-
* @param languageCode - The language code to sync content models for
|
|
8
|
-
* @returns AsyncGenerator that yields progress information
|
|
9
|
-
*/
|
|
10
|
-
export declare function syncContentModels(store: StoreInterface, languageCode: string): AsyncGenerator<SyncProgress, void>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { logError, logInfo } from '../util';
|
|
2
|
-
let store = null;
|
|
3
|
-
let options = null;
|
|
4
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
5
|
-
store = storeToUse;
|
|
6
|
-
options = storeOptions;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Sync content models from Agility CMS
|
|
10
|
-
* @param store - The store interface to use
|
|
11
|
-
* @param languageCode - The language code to sync content models for
|
|
12
|
-
* @returns AsyncGenerator that yields progress information
|
|
13
|
-
*/
|
|
14
|
-
export async function* syncContentModels(store, languageCode) {
|
|
15
|
-
try {
|
|
16
|
-
yield { status: 'init' };
|
|
17
|
-
// Get all content models
|
|
18
|
-
const contentModels = await store.getContentModels({ languageCode });
|
|
19
|
-
const total = contentModels.length;
|
|
20
|
-
yield { status: 'progress', total };
|
|
21
|
-
// Process each content model
|
|
22
|
-
for (let i = 0; i < contentModels.length; i++) {
|
|
23
|
-
const contentModel = contentModels[i];
|
|
24
|
-
await store.saveContentModel({ contentModel, languageCode });
|
|
25
|
-
yield { status: 'progress', current: i + 1, total, item: contentModel, languageCode };
|
|
26
|
-
}
|
|
27
|
-
yield { status: 'done' };
|
|
28
|
-
logInfo(`Synced ${total} content models`);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
logError('Error syncing content models');
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StoreInterface, StoreOptions } from '../types/StoreInterface';
|
|
2
|
-
export declare const setStore: (storeToUse: StoreInterface, storeOptions: StoreOptions) => void;
|
|
3
|
-
interface SyncProgress {
|
|
4
|
-
status: 'init' | 'progress' | 'done';
|
|
5
|
-
current?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
item?: any;
|
|
8
|
-
languageCode?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sync galleries from Agility CMS
|
|
12
|
-
* @param languageCode - The language code to sync galleries for
|
|
13
|
-
* @returns AsyncGenerator that yields progress information
|
|
14
|
-
*/
|
|
15
|
-
export declare function syncGalleries(this: {
|
|
16
|
-
store: StoreInterface;
|
|
17
|
-
}, languageCode: string): AsyncGenerator<SyncProgress, void>;
|
|
18
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { logError, logInfo } from '../util';
|
|
2
|
-
let store = null;
|
|
3
|
-
let options = null;
|
|
4
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
5
|
-
store = storeToUse;
|
|
6
|
-
options = storeOptions;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Sync galleries from Agility CMS
|
|
10
|
-
* @param languageCode - The language code to sync galleries for
|
|
11
|
-
* @returns AsyncGenerator that yields progress information
|
|
12
|
-
*/
|
|
13
|
-
export async function* syncGalleries(languageCode) {
|
|
14
|
-
const storeInterface = this.store;
|
|
15
|
-
try {
|
|
16
|
-
yield { status: 'init' };
|
|
17
|
-
// Get all galleries
|
|
18
|
-
const galleries = await storeInterface.getGalleries({ languageCode });
|
|
19
|
-
const total = galleries.length;
|
|
20
|
-
yield { status: 'progress', total };
|
|
21
|
-
// Process each gallery
|
|
22
|
-
for (let i = 0; i < galleries.length; i++) {
|
|
23
|
-
const gallery = galleries[i];
|
|
24
|
-
await storeInterface.saveGallery({ gallery, languageCode });
|
|
25
|
-
yield { status: 'progress', current: i + 1, total, item: gallery, languageCode };
|
|
26
|
-
}
|
|
27
|
-
yield { status: 'done' };
|
|
28
|
-
logInfo(`Synced ${total} galleries`);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
logError('Error syncing galleries');
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StoreInterface, StoreOptions } from '../types/StoreInterface';
|
|
2
|
-
export declare const setStore: (storeToUse: StoreInterface, storeOptions: StoreOptions) => void;
|
|
3
|
-
interface SyncProgress {
|
|
4
|
-
status: 'init' | 'progress' | 'done';
|
|
5
|
-
current?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
item?: any;
|
|
8
|
-
languageCode?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sync page models from Agility CMS
|
|
12
|
-
* @param languageCode - The language code to sync page models for
|
|
13
|
-
* @returns AsyncGenerator that yields progress information
|
|
14
|
-
*/
|
|
15
|
-
export declare function syncPageModels(this: {
|
|
16
|
-
store: StoreInterface;
|
|
17
|
-
}, languageCode: string): AsyncGenerator<SyncProgress, void>;
|
|
18
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { logError, logInfo } from '../util';
|
|
2
|
-
let store = null;
|
|
3
|
-
let options = null;
|
|
4
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
5
|
-
store = storeToUse;
|
|
6
|
-
options = storeOptions;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Sync page models from Agility CMS
|
|
10
|
-
* @param languageCode - The language code to sync page models for
|
|
11
|
-
* @returns AsyncGenerator that yields progress information
|
|
12
|
-
*/
|
|
13
|
-
export async function* syncPageModels(languageCode) {
|
|
14
|
-
const storeInterface = this.store;
|
|
15
|
-
try {
|
|
16
|
-
yield { status: 'init' };
|
|
17
|
-
// Get all page models
|
|
18
|
-
const pageModels = await storeInterface.getPageModels({ languageCode });
|
|
19
|
-
const total = pageModels.length;
|
|
20
|
-
yield { status: 'progress', total };
|
|
21
|
-
// Process each page model
|
|
22
|
-
for (let i = 0; i < pageModels.length; i++) {
|
|
23
|
-
const pageModel = pageModels[i];
|
|
24
|
-
await storeInterface.savePageModel({ pageModel, languageCode });
|
|
25
|
-
yield { status: 'progress', current: i + 1, total, item: pageModel, languageCode };
|
|
26
|
-
}
|
|
27
|
-
yield { status: 'done' };
|
|
28
|
-
logInfo(`Synced ${total} page models`);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
logError('Error syncing page models');
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { StoreInterface } from '../types/StoreInterface';
|
|
2
|
-
import { AgilityClient } from '../types/AgilityClient';
|
|
3
|
-
interface SyncProgress {
|
|
4
|
-
status: 'init' | 'progress' | 'done';
|
|
5
|
-
current?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
item?: any;
|
|
8
|
-
languageCode?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Sync the pages in the specified Agility Instance.
|
|
12
|
-
* @param languageCode - The language code to sync pages for
|
|
13
|
-
* @param token - The sync token to start from
|
|
14
|
-
* @returns The last sync token used
|
|
15
|
-
*/
|
|
16
|
-
export default function syncPages(this: {
|
|
17
|
-
store: StoreInterface;
|
|
18
|
-
agilityClient: AgilityClient;
|
|
19
|
-
}, languageCode: string, token?: number): AsyncGenerator<SyncProgress, number>;
|
|
20
|
-
export {};
|