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)
import { ContentItem, Fields,TypeResolver,DeliveryClient,DeliveryClientConfig } from 'kentico-cloud-delivery-typescript-sdk';
export class Movie extends ContentItem {
public title: Fields.TextField;
}
let typeResolvers: TypeResolver[] = [
new TypeResolver('movie', () => new Movie()),
];
var deliveryClient = new DeliveryClient(
new DeliveryClientConfig('projectId', typeResolvers)
);
deliveryClient.items<Movie>()
.type('movie')
.get()
.subscribe(response => {
console.log(response);
console.log(response.items[0].title.text);
});
deliveryClient.items<ContentItem>()
.type('movie')
.get()
.subscribe(response => {
console.log(response);
console.log(response.items[0].title.text);
});
JavaScript (CommonJS)
var KenticoCloud = require('kentico-cloud-delivery-typescript-sdk');
class Movie extends KenticoCloud.ContentItem {
constructor() {
super();
}
}
var typeResolvers = [
new KenticoCloud.TypeResolver('movie', () => new Movie()),
];
var config = new KenticoCloud.DeliveryClientConfig(projectId, typeResolvers);
var deliveryClient = new KenticoCloud.DeliveryClient(config);
deliveryClient.items()
.type('movie')
.get()
.subscribe(response => console.log(response));
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 in dev-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):
Feedback & Contribution
Feedback & Contributions are welcomed. Feel free to take/start an issue & submit PR.