Gathering detailed insights and metrics for @agility/content-sync
Gathering detailed insights and metrics for @agility/content-sync
Gathering detailed insights and metrics for @agility/content-sync
Gathering detailed insights and metrics for @agility/content-sync
npm install @agility/content-sync
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
254,456
Last Day
273
Last Week
1,922
Last Month
9,400
Last Year
95,794
3 Stars
70 Commits
3 Forks
5 Watching
15 Branches
7 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.8
Package Id
@agility/content-sync@1.1.8
Unpacked Size
222.76 kB
Size
46.46 kB
File Count
23
NPM Version
8.19.4
Node Version
16.20.2
Publised On
13 Dec 2024
Cumulative downloads
Total Downloads
Last day
4.6%
273
Compared to previous day
Last week
-13.1%
1,922
Compared to previous week
Last month
-5.5%
9,400
Compared to previous month
Last year
92.2%
95,794
Compared to previous year
The Agility CMS Sync SDK provides an interface to sync, store and access content locally.
By keeping a local cache of your content, your web app can access content faster.
This Sync SDK uses the Sync API getSyncPages
and getSyncContent
found in our Agility CMS Content Fetch JS SDK and aims to abstract some of the complexities involved in managing synced content.
It Calls the Sync API and returns content that has not yet been synced. The first call will pull everything and save it to your local store. Subsequent calls will only refresh content that has changed since the last time the Sync API was called.
This SDK:
syncToken
for youInstall @agility/content-sync
:
npm install @agility/content-sync
Create a sync client:
1import agilitySync from '@agility/content-sync' 2const syncClient = agilitySync.getSyncClient({ 3 //your 'guid' from Agility CMS 4 guid: 'some-guid', 5 //your 'apiKey' from Agility CMS 6 apiKey: 'some-api-key', 7 //the language(s) of content you want to source 8 languages: ['en-us'], 9 //your channel(s) for the pages you want to source 10 channels: ['website'], 11 //whether you are using the preview key or not 12 isPreview: false 13});
Run the runSync
command to synchronize your Agility CMS content (Content and Pages) to your local filesystem
1await syncClient.runSync();
runSync()
will pull down all your Sitemap, Pages, and Content and store them in your local filesystem under the default path .agility-files
.
Once content is in your sync store, you can easily access it as you need it:
1import agilitySync from '@agility/constent-sync' 2const syncClient = agilitySync.getSyncClient({ 3 //your 'guid' from Agility CMS 4 guid: 'some-guid', 5 //your 'apiKey' from Agility CMS 6 apiKey: 'some-api-key', 7 //the language(s) of content you want to source 8 languages: ['en-us'], 9 //your channel(s) for the pages you want to source 10 channels: ['website'] 11}); 12 13//start the sync process 14await syncClient.runSync(); 15 16//query and retrieve your content 17const contentItem = await syncClient.store.getContentItem({ 18 contentID: 21, 19 languageCode: languageCode 20}) 21 22const contentList = await syncClient.store.getContentList({ 23 referenceName: 'posts', 24 languageCode: languageCode 25})
To clear out the locally synced content, run the clearSync command.
1await syncClient.clearSync();
While this SDK provides a filesystem sync interface by default, you can change this and use another one or create your own.
.js
file which exports the following methods:1/** 2 * The function to handle saving/updating an item to your storage. This could be a Content Item, Page, Url Redirections, Sync State (state), or Sitemap. 3 * @param {Object} params - The parameters object 4 * @param {Object} params.options - A flexible object that can contain any properties specifically related to this interface 5 * @param {Object} params.item - The object representing the Content Item, Page, Url Redirections, Sync State (state), or Sitemap that needs to be saved/updated 6 * @param {String} params.itemType - The type of item being saved/updated, expected values are `item`, `page`, `sitemap`, `nestedsitemap`, `state`, `urlredirections` 7 * @param {String} params.languageCode - The locale code associated to the item being saved/updated 8 * @param {(String|Number)} params.itemID - The ID of the item being saved/updated - this could be a string or number depending on the itemType 9 * @returns {Void} 10 */ 11const saveItem = async ({ options, item, itemType, languageCode, itemID }) => { 12 console.log(`Console Interface: saveItem has been called`); 13 return null; 14} 15/** 16 * The function to handle deleting an item to your storage. This could be a Content Item, Page, Url Redirections, Sync State (state), or Sitemap. 17 * @param {Object} params - The parameters object 18 * @param {Object} params.options - A flexible object that can contain any properties specifically related to this interface 19 * @param {String} params.itemType - The type of item being deleted, expected values are `item`, `page`, `sitemap`, `nestedsitemap`, `state`, `urlredirections` 20 * @param {String} params.languageCode - The locale code associated to the item being saved/updated 21 * @param {(String|Number)} params.itemID - The ID of the item being deleted - this could be a string or number depending on the itemType 22 * @returns {Void} 23 */ 24const deleteItem = async ({ options, itemType, languageCode, itemID }) => { 25 console.log(`Console Interface: deleteItem has been called`); 26 return null; 27} 28/** 29 * The function to handle updating and placing a Content Item into a "list" so that you can handle querying a collection of items. 30 * @param {Object} params - The parameters object 31 * @param {Object} params.options - A flexible object that can contain any properties specifically related to this interface 32 * @param {Object} params.item - The object representing the Content Item 33 * @param {String} params.languageCode - The locale code associated to the item being saved/updated 34 * @param {(String|Number)} params.itemID - The ID of the item being updated - this could be a string or number depending on the itemType 35 * @param {String} params.referenceName - The reference name of the Content List that this Content Item should be added to 36 * @param {String} params.definitionName - The Model name that the Content Item is based on 37 * @returns {Void} 38 */ 39const mergeItemToList = async ({ options, item, languageCode, itemID, referenceName, definitionName }) => { 40 console.log(`Console Interface: mergeItemToList has been called`); 41 return null; 42} 43/** 44 * The function to handle retrieving a Content Item, Page, Url Redirections, Sync State (state), or Sitemap 45 * @param {Object} params - The parameters object 46 * @param {Object} params.options - A flexible object that can contain any properties specifically related to this interface 47 * @param {String} params.itemType - The type of item being accessed, expected values are `item`, `list`, `page`, `sitemap`, `nestedsitemap`, `state`, `urlredirections` 48 * @param {String} params.languageCode - The locale code associated to the item being accessed 49 * @param {(String|Number)} params.itemID - The ID of the item being accessed - this could be a string or number depending on the itemType 50 * @returns {Object} 51 */ 52const getItem = async ({ options, itemType, languageCode, itemID }) => { 53 console.log(`Console Interface: getItem has been called`) 54 return null; 55} 56/** 57 * The function to handle clearing the cache of synchronized data from the CMS 58 * @param {Object} params - The parameters object 59 * @param {Object} params.options - A flexible object that can contain any properties specifically related to this interface 60 * @returns {Void} 61 */ 62const clearItems = async ({ options }) => { 63 console.log(`Console Interface: clearItem has been called`) 64 return null; 65} 66 67module.exports = { 68 saveItem, 69 deleteItem, 70 mergeItemToList, 71 getItem, 72 clearItems 73}
syncClient
to use your Sync Store1import agilitySync from '@agility/constent-sync' 2import sampleSyncConsoleInterface from './store-interface-console' 3const syncClient = agilitySync.getSyncClient({ 4 //your 'guid' from Agility CMS 5 guid: 'some-guid', 6 //your 'apiKey' from Agility CMS 7 apiKey: 'some-api-key', 8 //the language(s) of content you want to source 9 languages: ['en-us'], 10 //your channel(s) for the pages you want to source 11 channels: ['website'], 12 //your custom storage/access interface 13 store: { 14 //must be the interface used to store and access content 15 interface: sampleSyncConsoleInterface, 16 //any options/config that you want to pass along to your interface as an argument 'options' 17 options: {} 18 } 19}); 20//start the sync process 21syncClient.runSync();
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 6/16 approved changesets -- score normalized to 3
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
24 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More