@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/dist/store-interface.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import { logWarning, } from "./util";
|
|
2
|
-
let store = null;
|
|
3
|
-
let options = null;
|
|
4
|
-
const validateStoreInterface = (storeCandidate) => {
|
|
5
|
-
if (!storeCandidate.clearItems) {
|
|
6
|
-
throw new TypeError("Your sync store interface must implement `clearItems`.");
|
|
7
|
-
}
|
|
8
|
-
if (!storeCandidate.deleteItem) {
|
|
9
|
-
throw new TypeError("Your sync store interface must implement `deleteItem`.");
|
|
10
|
-
}
|
|
11
|
-
if (!storeCandidate.getItem) {
|
|
12
|
-
throw new TypeError("Your sync store interface must implement `getItem`.");
|
|
13
|
-
}
|
|
14
|
-
if (!storeCandidate.saveItem) {
|
|
15
|
-
throw new TypeError("Your sync store interface must implement `saveItem`.");
|
|
16
|
-
}
|
|
17
|
-
if (!storeCandidate.mergeItemToList) {
|
|
18
|
-
throw new TypeError("Your sync store interface must implement `mergeItemToList`.");
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const setStore = (storeToUse, storeOptions) => {
|
|
22
|
-
validateStoreInterface(storeToUse);
|
|
23
|
-
store = storeToUse;
|
|
24
|
-
options = storeOptions;
|
|
25
|
-
};
|
|
26
|
-
export const getStore = () => {
|
|
27
|
-
return store;
|
|
28
|
-
};
|
|
29
|
-
// sanitize graphql node names
|
|
30
|
-
const sanitizeName = (name) => {
|
|
31
|
-
if (name !== undefined && name !== null) {
|
|
32
|
-
return name.replace(/\W/g, "");
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export const saveContentItem = async ({ contentItem, languageCode }) => {
|
|
39
|
-
if (!store || !options) {
|
|
40
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
41
|
-
}
|
|
42
|
-
if (!contentItem || !contentItem.properties) {
|
|
43
|
-
logWarning("Null item or item with no properties cannot be saved");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
let definitionName = sanitizeName(contentItem.properties.definitionName);
|
|
47
|
-
let referenceName = contentItem.properties.referenceName;
|
|
48
|
-
if (contentItem.properties.state === 3) {
|
|
49
|
-
//if the item is deleted
|
|
50
|
-
const currentItem = await store.getItem({
|
|
51
|
-
options,
|
|
52
|
-
itemType: "item",
|
|
53
|
-
languageCode,
|
|
54
|
-
itemID: contentItem.contentID,
|
|
55
|
-
});
|
|
56
|
-
if (currentItem) {
|
|
57
|
-
//if the item is deleted, we need to grab the def and ref name from the current
|
|
58
|
-
definitionName = sanitizeName(currentItem.properties.definitionName);
|
|
59
|
-
referenceName = currentItem.properties.referenceName;
|
|
60
|
-
await store.deleteItem({
|
|
61
|
-
options,
|
|
62
|
-
itemType: "item",
|
|
63
|
-
languageCode,
|
|
64
|
-
itemID: contentItem.contentID,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
//regular item
|
|
70
|
-
if (!contentItem.properties.definitionName || !contentItem.properties.referenceName) {
|
|
71
|
-
logWarning(`Content with id ${contentItem.contentID} does not have the necessary properties to be saved.`);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
await store.saveItem({
|
|
75
|
-
options,
|
|
76
|
-
item: contentItem,
|
|
77
|
-
itemType: "item",
|
|
78
|
-
languageCode,
|
|
79
|
-
itemID: contentItem.contentID,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (referenceName) {
|
|
83
|
-
//merge the item by reference or definition name - it might need to be merged into a list
|
|
84
|
-
await store.mergeItemToList({
|
|
85
|
-
options,
|
|
86
|
-
item: contentItem,
|
|
87
|
-
languageCode,
|
|
88
|
-
itemID: contentItem.contentID,
|
|
89
|
-
referenceName,
|
|
90
|
-
definitionName: definitionName || "",
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
export const savePageItem = async ({ pageItem, languageCode }) => {
|
|
95
|
-
if (!store || !options) {
|
|
96
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
97
|
-
}
|
|
98
|
-
if (pageItem.properties.state === 3) {
|
|
99
|
-
//item is deleted
|
|
100
|
-
await store.deleteItem({
|
|
101
|
-
options,
|
|
102
|
-
itemType: "page",
|
|
103
|
-
languageCode,
|
|
104
|
-
itemID: pageItem.pageID,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
//regular item
|
|
109
|
-
await store.saveItem({
|
|
110
|
-
options,
|
|
111
|
-
item: pageItem,
|
|
112
|
-
itemType: "page",
|
|
113
|
-
languageCode,
|
|
114
|
-
itemID: pageItem.pageID,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
export const saveSitemap = async ({ sitemap, channelName, languageCode }) => {
|
|
119
|
-
if (!store || !options) {
|
|
120
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
121
|
-
}
|
|
122
|
-
await store.saveItem({
|
|
123
|
-
options,
|
|
124
|
-
item: sitemap,
|
|
125
|
-
itemType: "sitemap",
|
|
126
|
-
languageCode,
|
|
127
|
-
itemID: channelName,
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
export const saveSitemapNested = async ({ sitemapNested, channelName, languageCode }) => {
|
|
131
|
-
if (!store || !options) {
|
|
132
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
133
|
-
}
|
|
134
|
-
await store.saveItem({
|
|
135
|
-
options,
|
|
136
|
-
item: sitemapNested,
|
|
137
|
-
itemType: "nestedsitemap",
|
|
138
|
-
languageCode,
|
|
139
|
-
itemID: channelName,
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
export const saveUrlRedirections = async ({ urlRedirections, languageCode }) => {
|
|
143
|
-
if (!store || !options) {
|
|
144
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
145
|
-
}
|
|
146
|
-
await store.saveItem({
|
|
147
|
-
options,
|
|
148
|
-
item: urlRedirections,
|
|
149
|
-
itemType: "urlredirections",
|
|
150
|
-
languageCode,
|
|
151
|
-
itemID: "urlredirections",
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
export const getUrlRedirections = async ({ languageCode }) => {
|
|
155
|
-
if (!store || !options) {
|
|
156
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
157
|
-
}
|
|
158
|
-
return await store.getItem({
|
|
159
|
-
options,
|
|
160
|
-
itemType: "urlredirections",
|
|
161
|
-
languageCode,
|
|
162
|
-
itemID: "urlredirections",
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
export const saveSyncState = async ({ syncState, languageCode }) => {
|
|
166
|
-
if (!store || !options) {
|
|
167
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
168
|
-
}
|
|
169
|
-
await store.saveItem({
|
|
170
|
-
options,
|
|
171
|
-
item: syncState,
|
|
172
|
-
itemType: "state",
|
|
173
|
-
languageCode,
|
|
174
|
-
itemID: "sync",
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
export const getSyncState = async (languageCode) => {
|
|
178
|
-
if (!store || !options) {
|
|
179
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
180
|
-
}
|
|
181
|
-
return await store.getItem({
|
|
182
|
-
options,
|
|
183
|
-
itemType: "state",
|
|
184
|
-
languageCode,
|
|
185
|
-
itemID: "sync",
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
export const getContentItem = async ({ contentID, languageCode, depth, contentLinkDepth, expandAllContentLinks = false, skip, take }) => {
|
|
189
|
-
if (!store || !options) {
|
|
190
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
191
|
-
}
|
|
192
|
-
let finalDepth = 2;
|
|
193
|
-
if (depth !== undefined) {
|
|
194
|
-
finalDepth = depth;
|
|
195
|
-
}
|
|
196
|
-
else if (contentLinkDepth !== undefined) {
|
|
197
|
-
finalDepth = contentLinkDepth;
|
|
198
|
-
}
|
|
199
|
-
const contentItem = await store.getItem({
|
|
200
|
-
options,
|
|
201
|
-
itemType: "item",
|
|
202
|
-
languageCode,
|
|
203
|
-
itemID: contentID,
|
|
204
|
-
});
|
|
205
|
-
return await expandContentItem({ contentItem, languageCode, depth: finalDepth, expandAllContentLinks, skip, take });
|
|
206
|
-
};
|
|
207
|
-
const expandContentItem = async ({ contentItem, languageCode, depth, expandAllContentLinks = false, skip, take }) => {
|
|
208
|
-
if (!contentItem)
|
|
209
|
-
return null;
|
|
210
|
-
if (depth > 0) {
|
|
211
|
-
//make this work for the .fields or the .customFields property...
|
|
212
|
-
let fields = contentItem.fields;
|
|
213
|
-
if (!fields)
|
|
214
|
-
fields = contentItem.customFields;
|
|
215
|
-
for (const fieldName in fields) {
|
|
216
|
-
const fieldValue = fields[fieldName];
|
|
217
|
-
if (!fieldValue) {
|
|
218
|
-
//do nothing...
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
else if (fieldValue.contentid > 0) {
|
|
222
|
-
//single linked item
|
|
223
|
-
const childItem = await getContentItem({
|
|
224
|
-
contentID: fieldValue.contentid,
|
|
225
|
-
languageCode,
|
|
226
|
-
depth: depth - 1,
|
|
227
|
-
expandAllContentLinks,
|
|
228
|
-
skip,
|
|
229
|
-
take
|
|
230
|
-
});
|
|
231
|
-
if (childItem != null)
|
|
232
|
-
fields[fieldName] = childItem;
|
|
233
|
-
}
|
|
234
|
-
else if (fieldValue.fulllist === true && fieldValue.referencename && expandAllContentLinks === true) {
|
|
235
|
-
//LINK TO THE FULL LIST
|
|
236
|
-
const referenceName = fieldValue.referencename;
|
|
237
|
-
const listSkip = skip || 0;
|
|
238
|
-
const listTake = take || 50;
|
|
239
|
-
const list = await getContentList({
|
|
240
|
-
referenceName,
|
|
241
|
-
languageCode,
|
|
242
|
-
depth: depth - 1,
|
|
243
|
-
expandAllContentLinks,
|
|
244
|
-
skip: listSkip,
|
|
245
|
-
take: listTake
|
|
246
|
-
});
|
|
247
|
-
let sortIDAry = [];
|
|
248
|
-
if (fieldValue.sortids && fieldValue.sortids.split) {
|
|
249
|
-
sortIDAry = fieldValue.sortids.split(",");
|
|
250
|
-
}
|
|
251
|
-
let itemCount = 0;
|
|
252
|
-
const childItems = [];
|
|
253
|
-
for (const childItemID of sortIDAry) {
|
|
254
|
-
itemCount++;
|
|
255
|
-
const childItem = await getContentItem({
|
|
256
|
-
contentID: parseInt(childItemID),
|
|
257
|
-
languageCode,
|
|
258
|
-
depth: depth - 1,
|
|
259
|
-
expandAllContentLinks,
|
|
260
|
-
skip: listSkip,
|
|
261
|
-
take: listTake
|
|
262
|
-
});
|
|
263
|
-
if (childItem != null) {
|
|
264
|
-
childItems.push(childItem);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
for (const listItem of list.items) {
|
|
268
|
-
itemCount++;
|
|
269
|
-
if (itemCount > 50)
|
|
270
|
-
break;
|
|
271
|
-
const listItemContentID = listItem.contentID;
|
|
272
|
-
if (sortIDAry.includes(`${listItemContentID}`)) {
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
const childItem = await getContentItem({
|
|
276
|
-
contentID: listItemContentID,
|
|
277
|
-
languageCode,
|
|
278
|
-
depth: depth - 1,
|
|
279
|
-
expandAllContentLinks,
|
|
280
|
-
skip: listSkip,
|
|
281
|
-
take: listTake
|
|
282
|
-
});
|
|
283
|
-
if (childItem != null)
|
|
284
|
-
childItems.push(childItem);
|
|
285
|
-
}
|
|
286
|
-
fields[fieldName] = childItems;
|
|
287
|
-
}
|
|
288
|
-
else if (fieldValue.sortids && fieldValue.sortids.split && fieldValue.fulllist !== true) {
|
|
289
|
-
//MULTI LINKED ITEM
|
|
290
|
-
let sortIDAry = [];
|
|
291
|
-
if (fieldValue.sortids && fieldValue.sortids.split) {
|
|
292
|
-
sortIDAry = fieldValue.sortids.split(",");
|
|
293
|
-
}
|
|
294
|
-
const listSkip = expandAllContentLinks ? (skip || 0) : undefined;
|
|
295
|
-
const listTake = expandAllContentLinks ? (take || 50) : undefined;
|
|
296
|
-
const childItems = [];
|
|
297
|
-
for (const childItemID of sortIDAry) {
|
|
298
|
-
const childItem = await getContentItem({
|
|
299
|
-
contentID: parseInt(childItemID),
|
|
300
|
-
languageCode,
|
|
301
|
-
depth: depth - 1,
|
|
302
|
-
expandAllContentLinks,
|
|
303
|
-
skip: listSkip,
|
|
304
|
-
take: listTake
|
|
305
|
-
});
|
|
306
|
-
if (childItem != null)
|
|
307
|
-
childItems.push(childItem);
|
|
308
|
-
}
|
|
309
|
-
fields[fieldName] = childItems;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return contentItem;
|
|
314
|
-
};
|
|
315
|
-
export const getContentList = async ({ referenceName, languageCode, depth, contentLinkDepth, expandAllContentLinks = false, skip = -1, take = -1 }) => {
|
|
316
|
-
if (!store || !options) {
|
|
317
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
318
|
-
}
|
|
319
|
-
let finalDepth = 0;
|
|
320
|
-
if (depth !== undefined) {
|
|
321
|
-
finalDepth = depth;
|
|
322
|
-
}
|
|
323
|
-
else if (contentLinkDepth !== undefined) {
|
|
324
|
-
finalDepth = contentLinkDepth;
|
|
325
|
-
}
|
|
326
|
-
let lst = await store.getItem({
|
|
327
|
-
options,
|
|
328
|
-
itemType: "list",
|
|
329
|
-
languageCode,
|
|
330
|
-
itemID: referenceName,
|
|
331
|
-
}) || [];
|
|
332
|
-
if (finalDepth > 0 && take === -1) {
|
|
333
|
-
throw new Error("If you specify depth > 0, you must also specify the take parameter.");
|
|
334
|
-
}
|
|
335
|
-
if (expandAllContentLinks && take === -1) {
|
|
336
|
-
throw new Error("If you specify expandAllContentLinks=true, you must also specify the take parameter.");
|
|
337
|
-
}
|
|
338
|
-
const totalCount = lst.length;
|
|
339
|
-
if (skip > 0 && skip < lst.length) {
|
|
340
|
-
lst = lst.slice(skip);
|
|
341
|
-
}
|
|
342
|
-
if (take > 0 && take < lst.length) {
|
|
343
|
-
lst = lst.slice(0, take);
|
|
344
|
-
}
|
|
345
|
-
if (finalDepth > 0) {
|
|
346
|
-
for (let i = 0; i < lst.length; i++) {
|
|
347
|
-
lst[i] = await expandContentItem({
|
|
348
|
-
contentItem: lst[i],
|
|
349
|
-
depth: finalDepth - 1,
|
|
350
|
-
languageCode,
|
|
351
|
-
expandAllContentLinks,
|
|
352
|
-
skip,
|
|
353
|
-
take
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (skip > 0 || take > 0) {
|
|
358
|
-
//if we have sliced this array, return an object with an items and totalCount property
|
|
359
|
-
return {
|
|
360
|
-
items: lst,
|
|
361
|
-
totalCount
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
//just return the full list
|
|
366
|
-
return lst;
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
export const getPage = async ({ pageID, languageCode, depth, contentLinkDepth, expandAllContentLinks = false }) => {
|
|
370
|
-
if (!store || !options) {
|
|
371
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
372
|
-
}
|
|
373
|
-
let finalDepth = 2;
|
|
374
|
-
if (depth !== undefined) {
|
|
375
|
-
finalDepth = depth;
|
|
376
|
-
}
|
|
377
|
-
else if (contentLinkDepth !== undefined) {
|
|
378
|
-
finalDepth = contentLinkDepth;
|
|
379
|
-
}
|
|
380
|
-
let pageItem = await store.getItem({
|
|
381
|
-
options,
|
|
382
|
-
itemType: "page",
|
|
383
|
-
languageCode,
|
|
384
|
-
itemID: pageID,
|
|
385
|
-
});
|
|
386
|
-
if (finalDepth > 0) {
|
|
387
|
-
//if a depth was specified, pull in the modules (content items) for this page
|
|
388
|
-
for (const zoneName in pageItem.zones) {
|
|
389
|
-
const zone = pageItem.zones[zoneName];
|
|
390
|
-
for (const mod of zone) {
|
|
391
|
-
const moduleItem = await getContentItem({
|
|
392
|
-
contentID: mod.item.contentid,
|
|
393
|
-
languageCode,
|
|
394
|
-
depth: finalDepth - 1,
|
|
395
|
-
expandAllContentLinks
|
|
396
|
-
});
|
|
397
|
-
mod.item = moduleItem;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return pageItem;
|
|
402
|
-
};
|
|
403
|
-
export const getSitemap = async ({ channelName, languageCode }) => {
|
|
404
|
-
if (!store || !options) {
|
|
405
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
406
|
-
}
|
|
407
|
-
return await store.getItem({
|
|
408
|
-
options,
|
|
409
|
-
itemType: "sitemap",
|
|
410
|
-
languageCode,
|
|
411
|
-
itemID: channelName,
|
|
412
|
-
});
|
|
413
|
-
};
|
|
414
|
-
export const getSitemapNested = async ({ channelName, languageCode }) => {
|
|
415
|
-
if (!store || !options) {
|
|
416
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
417
|
-
}
|
|
418
|
-
return await store.getItem({
|
|
419
|
-
options,
|
|
420
|
-
itemType: "nestedsitemap",
|
|
421
|
-
languageCode,
|
|
422
|
-
itemID: channelName,
|
|
423
|
-
});
|
|
424
|
-
};
|
|
425
|
-
export const clear = async () => {
|
|
426
|
-
if (!store || !options) {
|
|
427
|
-
throw new Error('Store not initialized. Call setStore first.');
|
|
428
|
-
}
|
|
429
|
-
await store.clearItems({ options });
|
|
430
|
-
};
|
package/dist/sync-client.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { StoreInterface, StoreOptions } from './types/StoreInterface';
|
|
3
|
-
import type { AgilityClient } from './types/AgilityClient';
|
|
4
|
-
import { SyncProgress } from './types/SyncProgress';
|
|
5
|
-
export interface SyncClientOptions extends StoreOptions {
|
|
6
|
-
contentModels?: boolean;
|
|
7
|
-
pageModels?: boolean;
|
|
8
|
-
content?: boolean;
|
|
9
|
-
pages?: boolean;
|
|
10
|
-
assets?: boolean;
|
|
11
|
-
galleries?: boolean;
|
|
12
|
-
containers?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class SyncClient extends EventEmitter {
|
|
15
|
-
store: StoreInterface;
|
|
16
|
-
agilityClient: AgilityClient;
|
|
17
|
-
private options;
|
|
18
|
-
private syncState;
|
|
19
|
-
constructor(store: StoreInterface, agilityClient: AgilityClient, options: SyncClientOptions);
|
|
20
|
-
syncContentModels(languageCode: string): Promise<AsyncGenerator<SyncProgress, void>>;
|
|
21
|
-
syncPageModels(): Promise<void>;
|
|
22
|
-
syncContent(): Promise<void>;
|
|
23
|
-
syncPages(): Promise<void>;
|
|
24
|
-
syncAssets(): Promise<void>;
|
|
25
|
-
syncGalleries(): Promise<void>;
|
|
26
|
-
syncContainers(): Promise<void>;
|
|
27
|
-
private updateSyncState;
|
|
28
|
-
clearSync(): Promise<void>;
|
|
29
|
-
}
|
package/dist/sync-client.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { logInfo, logError, logSuccess } from './util';
|
|
3
|
-
import { syncContentModels } from './methods/syncContentModels';
|
|
4
|
-
import { syncPageModels } from './methods/syncPageModels';
|
|
5
|
-
import syncContent from './methods/syncContent';
|
|
6
|
-
import syncPages from './methods/syncPages';
|
|
7
|
-
import { syncAssets } from './methods/syncAssets';
|
|
8
|
-
import { syncGalleries } from './methods/syncGalleries';
|
|
9
|
-
import { syncContainers } from './methods/syncContainers';
|
|
10
|
-
import { clearSync } from './methods/clearSync';
|
|
11
|
-
export class SyncClient extends EventEmitter {
|
|
12
|
-
store;
|
|
13
|
-
agilityClient;
|
|
14
|
-
options;
|
|
15
|
-
syncState = {};
|
|
16
|
-
constructor(store, agilityClient, options) {
|
|
17
|
-
super();
|
|
18
|
-
this.store = store;
|
|
19
|
-
this.agilityClient = agilityClient;
|
|
20
|
-
this.options = options;
|
|
21
|
-
}
|
|
22
|
-
async syncContentModels(languageCode) {
|
|
23
|
-
const generator = syncContentModels.call({ store: this.store }, languageCode);
|
|
24
|
-
await this.updateSyncState('contentModels');
|
|
25
|
-
return generator;
|
|
26
|
-
}
|
|
27
|
-
async syncPageModels() {
|
|
28
|
-
try {
|
|
29
|
-
const pageModelsGenerator = syncPageModels.call({ store: this.store }, this.options.languageCode);
|
|
30
|
-
for await (const progress of pageModelsGenerator) {
|
|
31
|
-
this.emit('progress', progress);
|
|
32
|
-
}
|
|
33
|
-
await this.updateSyncState('pageModels');
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
logError('Error syncing page models:', error);
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async syncContent() {
|
|
41
|
-
try {
|
|
42
|
-
const contentGenerator = syncContent.call({
|
|
43
|
-
store: this.store,
|
|
44
|
-
agilityClient: this.agilityClient
|
|
45
|
-
}, this.options.languageCode);
|
|
46
|
-
for await (const progress of contentGenerator) {
|
|
47
|
-
this.emit('progress', progress);
|
|
48
|
-
}
|
|
49
|
-
await this.updateSyncState('content');
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
logError('Error syncing content:', error);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async syncPages() {
|
|
57
|
-
try {
|
|
58
|
-
const pagesGenerator = syncPages.call({
|
|
59
|
-
store: this.store,
|
|
60
|
-
agilityClient: this.agilityClient
|
|
61
|
-
}, this.options.languageCode);
|
|
62
|
-
for await (const progress of pagesGenerator) {
|
|
63
|
-
this.emit('progress', progress);
|
|
64
|
-
}
|
|
65
|
-
await this.updateSyncState('pages');
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
logError('Error syncing pages:', error);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async syncAssets() {
|
|
73
|
-
try {
|
|
74
|
-
const assetsGenerator = syncAssets.call({ store: this.store }, this.options.languageCode);
|
|
75
|
-
for await (const progress of assetsGenerator) {
|
|
76
|
-
this.emit('progress', progress);
|
|
77
|
-
}
|
|
78
|
-
await this.updateSyncState('assets');
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
logError('Error syncing assets:', error);
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async syncGalleries() {
|
|
86
|
-
try {
|
|
87
|
-
const galleriesGenerator = syncGalleries.call({ store: this.store }, this.options.languageCode);
|
|
88
|
-
for await (const progress of galleriesGenerator) {
|
|
89
|
-
this.emit('progress', progress);
|
|
90
|
-
}
|
|
91
|
-
await this.updateSyncState('galleries');
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
logError('Error syncing galleries:', error);
|
|
95
|
-
throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async syncContainers() {
|
|
99
|
-
try {
|
|
100
|
-
const containersGenerator = syncContainers.call({ store: this.store }, this.options.languageCode);
|
|
101
|
-
for await (const progress of containersGenerator) {
|
|
102
|
-
this.emit('progress', progress);
|
|
103
|
-
}
|
|
104
|
-
await this.updateSyncState('containers');
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
logError('Error syncing containers:', error);
|
|
108
|
-
throw error;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async updateSyncState(model) {
|
|
112
|
-
this.syncState[model] = true;
|
|
113
|
-
logInfo(`Updated sync state for ${model}`);
|
|
114
|
-
}
|
|
115
|
-
async clearSync() {
|
|
116
|
-
try {
|
|
117
|
-
await clearSync.call({ store: this.store });
|
|
118
|
-
this.syncState = {};
|
|
119
|
-
logSuccess('Cleared sync state');
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
logError('Error clearing sync:', error);
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface AgilityClient {
|
|
2
|
-
getSyncContent(params: {
|
|
3
|
-
syncToken: number;
|
|
4
|
-
pageSize: number;
|
|
5
|
-
languageCode: string;
|
|
6
|
-
}): Promise<any>;
|
|
7
|
-
getSyncPages(params: {
|
|
8
|
-
syncToken: number;
|
|
9
|
-
pageSize: number;
|
|
10
|
-
languageCode: string;
|
|
11
|
-
}): Promise<any>;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/Asset.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface Asset {
|
|
2
|
-
assetID: number;
|
|
3
|
-
properties: {
|
|
4
|
-
fileName: string;
|
|
5
|
-
url: string;
|
|
6
|
-
size: number;
|
|
7
|
-
type: string;
|
|
8
|
-
state: number;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export interface Gallery {
|
|
12
|
-
galleryID: number;
|
|
13
|
-
properties: {
|
|
14
|
-
name: string;
|
|
15
|
-
state: number;
|
|
16
|
-
};
|
|
17
|
-
assets: Asset[];
|
|
18
|
-
}
|
package/dist/types/Asset.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface Container {
|
|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
items: ContainerItem[];
|
|
6
|
-
languageCode: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ContainerItem {
|
|
9
|
-
id: number;
|
|
10
|
-
title: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
url: string;
|
|
13
|
-
thumbnailUrl?: string;
|
|
14
|
-
order: number;
|
|
15
|
-
}
|
package/dist/types/Container.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface ContentItem {
|
|
2
|
-
contentID: number;
|
|
3
|
-
properties: {
|
|
4
|
-
definitionName: string;
|
|
5
|
-
referenceName: string;
|
|
6
|
-
state: number;
|
|
7
|
-
};
|
|
8
|
-
fields?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
customFields?: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface ContentItemField {
|
|
16
|
-
contentid?: number;
|
|
17
|
-
referencename?: string;
|
|
18
|
-
fulllist?: boolean;
|
|
19
|
-
sortids?: string;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface ContentModel {
|
|
2
|
-
id: number;
|
|
3
|
-
name: string;
|
|
4
|
-
definitionName: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
fields: ContentModelField[];
|
|
7
|
-
languageCode: string;
|
|
8
|
-
}
|
|
9
|
-
export interface ContentModelField {
|
|
10
|
-
name: string;
|
|
11
|
-
label: string;
|
|
12
|
-
type: string;
|
|
13
|
-
required: boolean;
|
|
14
|
-
defaultValue?: any;
|
|
15
|
-
validation?: ContentModelFieldValidation;
|
|
16
|
-
}
|
|
17
|
-
export interface ContentModelFieldValidation {
|
|
18
|
-
type: string;
|
|
19
|
-
message?: string;
|
|
20
|
-
pattern?: string;
|
|
21
|
-
min?: number;
|
|
22
|
-
max?: number;
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|