Skip to content

Commit 026c440

Browse files
Merge branch 'master' into umb-build
2 parents bfc3f34 + c060fb0 commit 026c440

File tree

4 files changed

+114
-2
lines changed

4 files changed

+114
-2
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
We appreciate any community contributions to this project, whether in the form of issues or Pull Requests.
22

3-
This document outlines the we'd like you to follow in terms of commit messages and code style.
3+
This document outlines what we'd like you to follow in terms of commit messages and code style.
44

55
It also explains what to do in case you want to setup the project locally and run tests.
66

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Check the [releases](https://github.com/contentful/contentful.js/releases) page
6161

6262
## Authentication
6363

64-
To get content from Contentful, an app should authenticate with an with an OAuth bearer token.
64+
To get content from Contentful, an app should authenticate with an OAuth bearer token.
6565

6666
You can create API keys using [Contentful's web interface](https://app.contentful.com). Go to the app, open the space that you want to access (top left corner lists all the spaces), and navigate to the APIs area. Open the API Keys section and create your first token. Done.
6767

index.d.ts

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// Type definitions for contentful
2+
// Definitions by: Miika Hänninen <https://github.com/googol>
3+
4+
export interface CreateClientParams {
5+
space: string;
6+
accessToken: string;
7+
insecure?: boolean;
8+
host?: string;
9+
agent?: any;
10+
headers?: any;
11+
concurrency?: number;
12+
delay?: number;
13+
maxRetries?: number;
14+
retryOnTooManyRequests?: boolean;
15+
resolveLinks?: boolean;
16+
}
17+
18+
export interface ContentfulClientApi {
19+
getAsset(id: string, query?: any): Promise<Asset>;
20+
getAssets(query?: any): Promise<AssetCollection>;
21+
getContentType(id: string): Promise<ContentType>;
22+
getContentTypes(query?: any): Promise<ContentTypeCollection>;
23+
getEntries(query?: any): Promise<EntryCollection<any>>;
24+
getEntry(id: string, query?: any): Promise<Entry<any>>;
25+
getSpace(): Promise<Space>;
26+
sync(query: any): Promise<SyncCollection>;
27+
}
28+
29+
export interface Asset {
30+
sys: Sys;
31+
fields: {
32+
title: string;
33+
description: string;
34+
file: {
35+
url: string;
36+
details: any;
37+
fileNmae: string;
38+
contentType: string;
39+
};
40+
};
41+
toPlainObject(): Asset;
42+
}
43+
44+
export interface ContentfulCollection<T> {
45+
total: number;
46+
skip: number;
47+
limit: number;
48+
items: Array<T>;
49+
toPlainObject(): this;
50+
}
51+
52+
export type AssetCollection = ContentfulCollection<Asset>
53+
54+
export interface Entry<T> {
55+
sys: Sys;
56+
fields: T;
57+
toPlainObject(): Entry<T>;
58+
}
59+
60+
export interface EntryCollection<T> extends ContentfulCollection<Entry<T>> {
61+
errors?: Array<any>;
62+
includes?: any;
63+
stringifySafe(replacer: any, space: any): string;
64+
}
65+
66+
export interface ContentType {
67+
sys: Sys;
68+
name: string;
69+
description: string;
70+
displayField: string;
71+
Array: string;
72+
toPlainObject(): ContentType;
73+
}
74+
75+
export type ContentTypeCollection = ContentfulCollection<ContentType>;
76+
77+
export interface Space {
78+
sys: Sys;
79+
name: string;
80+
locales: Array<string>;
81+
toPlainObject(): Space;
82+
}
83+
84+
export interface SyncCollection {
85+
entries: Array<Entry<any>>;
86+
assets: Array<Asset>;
87+
deletedEntries: Array<Entry<any>>;
88+
deletedAssets: Array<Asset>;
89+
nextSyncToken: string;
90+
toPlainObject(): SyncCollection;
91+
stringifySafe(replacer: any, space: any): string;
92+
}
93+
94+
export interface Sys {
95+
type: string;
96+
id: string;
97+
createdAt: string;
98+
updatedAt: string;
99+
locale: string;
100+
contentType: {
101+
sys: ContentTypeLink;
102+
};
103+
}
104+
105+
export interface ContentTypeLink {
106+
type: 'Link';
107+
linkType: 'ContentType';
108+
id: string;
109+
}
110+
111+
export function createClient(params: CreateClientParams): ContentfulClientApi;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"devdep:install": "npm run devdep:build && rm -rf node_modules/contentful-sdk-core && npm install ../contentful-sdk-core && npm run devdep:clean",
4040
"devdep:uninstall": "npm run devdep:clean && rimraf node_modules/contentful-sdk-core"
4141
},
42+
"types": "./index.d.ts",
4243
"files": [
4344
"index.js",
4445
"version.js",

0 commit comments

Comments
 (0)