Skip to content

Commit e6728dc

Browse files
Js Sdk reference doc
1 parent f0aff07 commit e6728dc

File tree

7 files changed

+363
-209
lines changed

7 files changed

+363
-209
lines changed

js-sdk-reference.zip

608 KB
Binary file not shown.

package.json

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
{
2-
"name": "contentstack",
3-
"version": "3.5.0",
4-
"description": "Contentstack Javascript SDK",
5-
"homepage": "https://www.contentstack.com/",
6-
"author": {
7-
"name": "Contentstack",
8-
"url": "https://www.contentstack.com/"
2+
"name": "contentstack",
3+
"version": "3.5.0",
4+
"description": "Contentstack Javascript SDK",
5+
"homepage": "https://www.contentstack.com/",
6+
"author": {
7+
"name": "Contentstack",
8+
"url": "https://www.contentstack.com/"
9+
},
10+
"main": "dist/node/contentstack.js",
11+
"browser": "dist/web/contentstack.js",
12+
13+
"scripts": {
14+
"test": "node test.js",
15+
"buildnode": "webpack --config webpack/webpack.node.js",
16+
"buildweb": "webpack -p --config webpack/webpack.web.js",
17+
"buildreactnative": "webpack --config webpack/webpack.react-native.js",
18+
"buildnativescript": "webpack --config webpack/webpack.nativescript.js",
19+
"buildall": "npm run buildnode&npm run buildweb&npm run buildreactnative&npm run buildnativescript",
20+
"generate-docs": "node_modules/.bin/jsdoc --configure docs-config.json --verbose"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/builtio-contentstack/contentstack-javascript.git"
25+
},
26+
"_shasum": "a328ed07240476a26b31a23261355dc929e1da63",
27+
"_from": "contentstack@latest",
28+
"_npmVersion": "3.8.9",
29+
"_nodeVersion": "6.2.0",
30+
"_npmUser": {
31+
"name": "mynk",
32+
"email": "[email protected]"
33+
},
34+
"maintainers": [
35+
{
36+
"name": "hiteshbal",
37+
"email": "[email protected]"
938
},
10-
"main": "dist/node/contentstack.js",
11-
"browser": "dist/web/contentstack.js",
12-
13-
"scripts": {
14-
"test": "node test.js",
15-
"buildnode": "webpack --config webpack/webpack.node.js",
16-
"buildweb": "webpack -p --config webpack/webpack.web.js",
17-
"buildreactnative": "webpack --config webpack/webpack.react-native.js",
18-
"buildnativescript": "webpack --config webpack/webpack.nativescript.js",
19-
"buildall": "npm run buildnode&npm run buildweb&npm run buildreactnative&npm run buildnativescript",
20-
"generate-docs": "node_modules/.bin/jsdoc --configure docs-config.json --verbose"
21-
},
22-
"repository": {
23-
"type": "git",
24-
"url": "https://github.com/builtio-contentstack/contentstack-javascript.git"
25-
},
26-
"_shasum": "a328ed07240476a26b31a23261355dc929e1da63",
27-
"_from": "contentstack@latest",
28-
"_npmVersion": "3.8.9",
29-
"_nodeVersion": "6.2.0",
30-
"_npmUser": {
31-
"name": "mynk",
32-
"email": "[email protected]"
33-
},
34-
"maintainers": [
35-
{
36-
"name": "hiteshbal",
37-
"email": "[email protected]"
38-
},
39-
{
40-
"name": "mynk",
41-
"email": "[email protected]"
42-
}
43-
],
44-
"dist": {
45-
"shasum": "a328ed07240476a26b31a23261355dc929e1da63",
46-
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.0.0.tgz"
47-
},
48-
"license": "MIT",
49-
"directories": {},
50-
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.0.0.tgz",
51-
"_npmOperationalInternal": {
52-
"host": "packages-18-east.internal.npmjs.com",
53-
"tmp": "tmp/contentstack-3.0.0.tgz_1477830884275_0.9869455888401717"
54-
},
55-
"devDependencies": {
56-
"babel-core": "6.26.0",
57-
"babel-loader": "7.1.2",
58-
"babel-plugin-transform-runtime": "6.23.0",
59-
"babel-preset-env": "1.6.1",
60-
"babel-preset-es2015": "6.24.1",
61-
"babel-preset-es2016": "6.24.1",
62-
"babel-preset-stage-1": "6.24.1",
63-
"babel-runtime": "6.26.0",
64-
"compression-webpack-plugin": "1.0.1",
65-
"es3ify-loader": "0.2.0",
66-
"jsdoc": "3.5.5",
67-
"jshint": "2.9.5",
68-
"nodemailer": "^4.3.1",
69-
"request": "^2.83.0",
70-
"string-replace-loader": "1.3.0",
71-
"string-replace-webpack-plugin": "0.1.3",
72-
"tap-json": "1.0.0",
73-
"tape": "4.8.0",
74-
"uglify-js": "2.8.29",
75-
"webpack": "2.7.0",
76-
"webpack-md5-hash": "0.0.5",
77-
"webpack-merge": "4.1.0"
78-
},
79-
"dependencies": {
80-
"es6-promise": "4.1.1",
81-
"isomorphic-fetch": "2.2.1",
82-
"localStorage": "1.0.3"
39+
{
40+
"name": "mynk",
41+
"email": "[email protected]"
8342
}
43+
],
44+
"dist": {
45+
"shasum": "a328ed07240476a26b31a23261355dc929e1da63",
46+
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.0.0.tgz"
47+
},
48+
"license": "MIT",
49+
"directories": {},
50+
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.0.0.tgz",
51+
"_npmOperationalInternal": {
52+
"host": "packages-18-east.internal.npmjs.com",
53+
"tmp": "tmp/contentstack-3.0.0.tgz_1477830884275_0.9869455888401717"
54+
},
55+
"devDependencies": {
56+
"babel-core": "6.26.0",
57+
"babel-loader": "7.1.2",
58+
"babel-plugin-transform-runtime": "6.23.0",
59+
"babel-preset-env": "1.6.1",
60+
"babel-preset-es2015": "6.24.1",
61+
"babel-preset-es2016": "6.24.1",
62+
"babel-preset-stage-1": "6.24.1",
63+
"babel-runtime": "6.26.0",
64+
"compression-webpack-plugin": "1.0.1",
65+
"es3ify-loader": "0.2.0",
66+
"jsdoc": "^3.5.5",
67+
"jshint": "2.9.5",
68+
"nodemailer": "^4.3.1",
69+
"request": "^2.83.0",
70+
"string-replace-loader": "1.3.0",
71+
"string-replace-webpack-plugin": "0.1.3",
72+
"tap-json": "1.0.0",
73+
"tape": "4.8.0",
74+
"uglify-js": "2.8.29",
75+
"webpack": "2.7.0",
76+
"webpack-md5-hash": "0.0.5",
77+
"webpack-merge": "4.1.0"
78+
},
79+
"dependencies": {
80+
"es6-promise": "4.1.1",
81+
"isomorphic-fetch": "2.2.1",
82+
"localStorage": "1.0.3"
83+
}
8484
}

src/core/contentstack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Contentstack {
2424

2525
/**
2626
* @method Stack
27-
* @description Initialize "Built.io Contentstack" Stack javascript-SDK instance
27+
* @description Initialize "Contentstack" Stack javascript-SDK instance
2828
* @api public
2929
* @example
3030
* var Stack = Contentstack.Stack('api_key', 'access_token', 'environment');
@@ -36,7 +36,7 @@ class Contentstack {
3636
* });
3737
*
3838
* @returns {Stack}
39-
*/
39+
*/
4040
Stack(...stack_arguments){
4141
return new Stack(...stack_arguments);
4242
}

src/core/modules/assets.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class Assets {
3636

3737
/**
3838
* @method toJSON
39-
* @description This method is used to convert the result in to plain javascript object.
39+
* @description Converts your response into plain JavasScript object.
4040
* @example
4141
* assetQuery
4242
* .toJSON()
@@ -52,10 +52,15 @@ export default class Assets {
5252
return this;
5353
}
5454

55-
/**
55+
/**
5656
* @method AddParam
57-
* @description This method includes query parameter in query.
58-
* @example Stack.Assets('bltsomething123').addParam('include_dimension', 'true').fetch()
57+
* @description Includes query parameters in your query.
58+
* @example var data = blogQuery.addParam('include_count', 'true').toJSON().fetch()
59+
* data.then(function (result) {
60+
* // result contents count in JSON object form
61+
* },function (error) {
62+
* // error function
63+
* })
5964
*/
6065
addParam(key, value) {
6166
if (key && typeof key === 'string' && value && typeof value === 'string') {
@@ -68,9 +73,9 @@ export default class Assets {
6873

6974
/**
7075
* @method fetch
71-
* @description fetch asset obhect of requested Asset uid of defined query if present.
76+
* @description Fetches a particular Asset based on the provided assets UID.
7277
* @example
73-
* Stack.Assets('bltsomething123').fetch()
78+
* Stack.Assets('bltsomething123').toJSON().fetch()
7479
*/
7580
fetch() {
7681
if (this.asset_uid) {

src/core/modules/entry.js

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export default class Entry {
1515
this._query = {};
1616
/**
1717
* @method only
18-
* @description This method is use to show the selected fields of the entries in resultset.
19-
* @param {String} [key=BASE] - reference field in the entry/single field in entry
20-
* @param {Array} values - array of fields to be show in resultset
18+
* @description Displays values of only the specified fields in the response
19+
* @param {String} [key=BASE] - BASE (default value) - retrieves default fields of the schema.
20+
- referenced content-type-uid - retrieves fields of the referred content type.
21+
* @param {Array} values - array of fields that you want to display in the response
2122
* @example
2223
* <caption> .only with field uid </caption>
2324
* blogEntry.only('title')
@@ -38,24 +39,25 @@ export default class Entry {
3839
this.only = Utils.transform('only');
3940
/**
4041
* @method except
41-
* @description This method is use to hide the selected fields of the entries in resultset.
42-
* @param {String} [key=BASE] - reference field in the entry/single field in entry
43-
* @param {Array} values - array of fields to be show in resultset
42+
* @description Displays all data of an entry excluding the data of the specified fields.
43+
* @param {String} [key=BASE] - BASE (default value) - retrieves default fields of the schema.
44+
- referenced_content-type-uid - retrieves fields of the referred content type.
45+
* @param {Array} values - array of fields that you want to skip in the response
4446
* @example
4547
* <caption> .except with field uid </caption>
46-
* blogEntry.except('title')
48+
* Stack.ContentType('contentTypeUid').Query().except('title').toJSON().find()
4749
* @example
4850
* <caption> .except with field uid </caption>
49-
* blogEntry.except('BASE','title')
51+
* Stack.ContentType('contentTypeUid').Query().except('BASE','title').toJSON().find()
5052
* @example
5153
* <caption> .except with field uids(array) </caption>
52-
* blogEntry.except(['title','description'])
54+
* Stack.ContentType('contentTypeUid').Query().except(['title','description']).toJSON().find()
5355
* @example
5456
* <caption> .except with reference_field_uid and field uid </caption>
55-
* blogEntry.includeReference('category').except('category','title')
57+
* Stack.ContentType('contentTypeUid').Query().includeReference('category').except('category','title').toJSON().find()
5658
* @example
5759
* <caption> .except with reference_field_uid and field uids(array) </caption>
58-
* blogEntry.includeReference('category').except('category', ['title', 'description'])
60+
* Stack.ContentType('contentTypeUid').Query().includeReference('category').except('category', ['title', 'description']).toJSON().find()
5961
* @returns {Entry} */
6062
this.except = Utils.transform('except');
6163
return this;
@@ -83,7 +85,7 @@ export default class Entry {
8385

8486
/**
8587
* @method includeReference
86-
* @description This method is use to include referenced entries from the other Contenttype.
88+
* @description Fetches the entire content of referenced entry(ies)
8789
* @example
8890
* <caption> .includeReference with reference_field_uids as array </caption>
8991
* blogEntry.includeReference(['category', 'author'])
@@ -106,11 +108,19 @@ export default class Entry {
106108
}
107109
}
108110

109-
/**
111+
/**
110112
* @method language
111-
* @description This method is used set language code, which language's data to be retrieve.
113+
* @description Sets the language code of which you want to retrieve data.
112114
* @param {String} language_code - language code. e.g. 'en-us', 'ja-jp', etc.
113-
* @example blogEntry.language('en-us')
115+
* @example
116+
* let data = blogEntry.language('en-us')
117+
* data
118+
* .then(function(result) {
119+
* // result is an object used to retrieve data of en-us language.
120+
* }, function(error) {
121+
* // error function
122+
* })
123+
*
114124
* @returns {Entry}
115125
*/
116126
language(language_code) {
@@ -122,9 +132,9 @@ export default class Entry {
122132
}
123133
}
124134

125-
/**
135+
/**
126136
* @method addQuery
127-
* @description This method is used to add query to Entry object.
137+
* @description Adds query to Entry object.
128138
* @param {String} key - key of the query
129139
* @param {String} value - value of the query
130140
* @example blogEntry.addQuery('include_schema',true)
@@ -140,10 +150,10 @@ export default class Entry {
140150
}
141151

142152
/**
143-
* @method includeSchema
153+
* @method IncludeSchema
144154
* @deprecated since verion 3.3.0
145-
* @description This method is used to include the schema of the current contenttype in result set along with the entry/entries.
146-
* @example blogEntry.includeSchema()
155+
* @description Include schema of the current contenttype along with entry/entries details.
156+
* @example Stack.ContentType("contentType_uid").Entry("entry_uid").includeSchema().fetch()
147157
* @returns {Entry}
148158
*/
149159
includeSchema() {
@@ -153,7 +163,7 @@ export default class Entry {
153163

154164
/**
155165
* @method includeContentType
156-
* @description This method is used to include the current contenttype in result set along with the entry/entries.
166+
* @description Include the details of the contenttype along with the entry/entries details.
157167
* @example blogEntry.includeContentType()
158168
* @returns {Entry}
159169
*/
@@ -162,9 +172,9 @@ export default class Entry {
162172
return this;
163173
}
164174

165-
/**
175+
/**
166176
* @method includeOwner
167-
* @description This method is used to include the owner of the entry/entries in resultset.
177+
* @description Includes the owner details of the entry/entries
168178
* @example blogEntry.includeOwner()
169179
* @returns {Entry}
170180
*/
@@ -193,8 +203,13 @@ export default class Entry {
193203

194204
/**
195205
* @method AddParam
196-
* @description This method includes query parameter in query.
197-
* @example blogQuery.addParam('include_count', 'true').fetch()
206+
* @description AddParam method includes query parameter in query.
207+
* @example var data = blogQuery.addParam('include_count', 'true').fetch()
208+
* data.then(function (result) {
209+
* // result is an object which content the data including count in json object form
210+
* },function (error) {
211+
* // error function
212+
* })
198213
*/
199214
addParam(key, value) {
200215
if (key && value && typeof key === 'string' && typeof value === 'string') {
@@ -206,11 +221,11 @@ export default class Entry {
206221
}
207222

208223

209-
/**
224+
/**
210225
* @method fetch
211-
* @description fetch entry of requested content_type of defined query if present.
226+
* @description Fetches a particular entry based on the provided entry UID.
212227
* @example
213-
* blogEntry.fetch()
228+
* Stack.blogEntry('entry_uid').fetch()
214229
*/
215230
fetch() {
216231
if (this.entry_uid) {

0 commit comments

Comments
 (0)