Kentico Cloud Delivery JavaScript / TypeScript SDK
A client library for retrieving content from Kentico Cloud that supports JavaScript and TypeScript.
Node.js support
Visit GitHub repository to see how you can use this SDK in Node.js environment.
Quick start
npm i kentico-cloud-delivery-typescript-sdk --save
TypeScript (ES6)
; /** * This is optional, but it is considered a best practice to define your models * so you can leverage intellisense and so that you can extend your models with * additional properties / methods. */ /** * Type resolvers make sure instance of proper class is created for your content types. * If you don't use any custom models, return an empty array. */; /** * Create new instance of Delivery Client */; /** * Get typed data from Cloud (note that the 'Movie' has to be registered in your type resolvers) */deliveryClient.items .type'movie' .get .subscribe; /** * Get data without having custom models */deliveryClient.items .type'movie' .get .subscribe;
JavaScript (CommonJS)
var KenticoCloud = ; /** * This is optional, but it is considered a best practice to define your models * so that you can leverage intellisense and extend your models with * additional methods. */ContentItem { super; } /** * Type resolvers make sure instance of proper class is created for your content types. * If you don't use any custom classes, return an empty array. */var typeResolvers = 'movie' ; /** * Delivery client configuration object */var config = projectId typeResolvers; /** * Create new instance of Delivery Client */var deliveryClient = config; /** * Fetch all items of 'movie' type and given parameters from Kentico Cloud. * Important note: SDK will convert items to your type if you registered it. For example, * in this case the objects will be of 'Movie' type we defined above. * If you don't use custom models, 'ContentItem' object instances will be returned. */deliveryClient type'movie' ;
Testing
Note: You need to have Firefox
installed in order to run tests via Karma.
- Use
npm test
to run all tests. - Use
npm run dev-test
to run developer tests created indev-test
folder. Use this for your testing purposes.
Publishing
In order to publish SDK first run one of following tasks to increase version & update sdk info file:
npm run new-patch
npm run new-minor
npm run new-major
And then run (note that tests and necessary scripts are automatically executed using the prepublishOnly
script):
npm run publish
Feedback & Contribution
Feedback & Contributions are welcomed. Feel free to take/start an issue & submit PR.