Skip to content

Commit 69b4560

Browse files
Merge pull request #24 from contentstack/hotfix-3.8.1
Hotfix 3.8.1
2 parents ee57537 + 44a9894 commit 69b4560

22 files changed

+758
-9424
lines changed

dist/nativescript/contentstack.js

Lines changed: 148 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,40 @@ function resultWrapper(result) {
277277
return result;
278278
};
279279

280+
// // spread the result object
281+
// export function spreadResult(result) {
282+
// let _results = [];
283+
// if (result && Object.keys(result).length) {
284+
// if (typeof result.entries !== 'undefined') _results.push(result.entries);
285+
// if (typeof result.assets !== 'undefined') _results.push(result.assets);
286+
// if (typeof result.content_type !== 'undefined' || typeof result.schema !== 'undefined') _results.push(result.content_type || result.schema);
287+
// if (typeof result.count !== 'undefined') _results.push(result.count);
288+
// if (typeof result.entry !== 'undefined') _results = result.entry;
289+
// if (typeof result.asset !== 'undefined') _results = result.asset;
290+
// if (typeof result.items !== 'undefined') _results.push(result);
291+
// }
292+
// return _results;
293+
// };
294+
280295
// spread the result object
281296
function spreadResult(result) {
282297
var _results = [];
283298
if (result && Object.keys(result).length) {
284-
if (typeof result.entries !== 'undefined') _results.push(result.entries);
299+
if (typeof result.entries !== 'undefined') {
300+
_results.push(result.entries);
301+
if (result.content_type) {
302+
_results['schema'] = result.content_type;
303+
}
304+
}
285305
if (typeof result.assets !== 'undefined') _results.push(result.assets);
286306
if (typeof result.content_type !== 'undefined' || typeof result.schema !== 'undefined') _results.push(result.content_type || result.schema);
287307
if (typeof result.count !== 'undefined') _results.push(result.count);
288-
if (typeof result.entry !== 'undefined') _results = result.entry;
308+
if (typeof result.entry !== 'undefined') {
309+
_results = result.entry;
310+
if (result.schema) {
311+
_results['schema'] = result.schema;
312+
}
313+
}
289314
if (typeof result.asset !== 'undefined') _results = result.asset;
290315
if (typeof result.items !== 'undefined') _results.push(result);
291316
}
@@ -927,10 +952,10 @@ var Stack = function () {
927952
/**
928953
* @method getContentTypes
929954
* @memberOf Stack
955+
* @param {String} param - Query on contentTypes
930956
* @description This method returns comprehensive information of all the content types of a particular stack in your account.
931-
* @example Stack.getContentTypes()
932957
* @example
933-
* let data = Stack.getContentTypes()
958+
* let data = Stack.getContentTypes({"include_global_field_schema": true})
934959
* data
935960
* .then(function(result) {
936961
* // 'result' is list of contentTypes.
@@ -943,7 +968,7 @@ var Stack = function () {
943968

944969
}, {
945970
key: 'getContentTypes',
946-
value: function getContentTypes() {
971+
value: function getContentTypes(param) {
947972
var query = {
948973
method: 'POST',
949974
headers: this.headers,
@@ -953,6 +978,11 @@ var Stack = function () {
953978
environment: this.environment
954979
}
955980
};
981+
if (param && param !== undefined) {
982+
for (var key in param) {
983+
query.body[key] = param[key];
984+
}
985+
}
956986
return (0, _request2.default)(query);
957987
}
958988

@@ -1060,7 +1090,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
10601090
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
10611091

10621092
//JS SDK version
1063-
var version = '3.7.1';
1093+
var version = '3.8.0';
10641094
var environment = void 0,
10651095
api_key = void 0;
10661096

@@ -2104,6 +2134,14 @@ var Query = function (_Entry) {
21042134
* @param {object} query - RAW (JSON) queries
21052135
* @returns {Query}
21062136
* @instance
2137+
* @example
2138+
* let blogQuery = Stack().ContentType('example').Query();
2139+
* let data = blogQuery.query({"brand": {"$nin_query": {"title": "Apple Inc."}}}).find()
2140+
* data.then(function(result) {
2141+
* // ‘result’ contains the total count.
2142+
* },function (error) {
2143+
* // error function
2144+
* })
21072145
*/
21082146

21092147
}, {
@@ -2117,6 +2155,98 @@ var Query = function (_Entry) {
21172155
}
21182156
}
21192157

2158+
/**
2159+
* @method referenceIn
2160+
* @memberOf Query
2161+
* @description Retrieve entries that satisfy the query conditions made on referenced fields.
2162+
* @param {Query} query - RAW (JSON) queries
2163+
* @returns {Query}
2164+
* @instance
2165+
* @example
2166+
* <caption> referenceIn with Query instances</caption>
2167+
* let blogQuery = Stack().ContentType('example').Query();
2168+
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
2169+
* let data = blogQuery.referenceIn("brand", Query).find()
2170+
* data.then(function(result) {
2171+
* // ‘result’ contains the total count.
2172+
* },function (error) {
2173+
* // error function
2174+
* })
2175+
*
2176+
* @example
2177+
* <caption> referenceIn with raw queries</caption>
2178+
* let blogQuery = Stack().ContentType('example').Query();
2179+
* let data = blogQuery.referenceIn("brand", {'title': 'Demo'}).find()
2180+
* data.then(function(result) {
2181+
* // ‘result’ contains the total count.
2182+
* },function (error) {
2183+
* // error function
2184+
* })
2185+
*/
2186+
2187+
}, {
2188+
key: 'referenceIn',
2189+
value: function referenceIn(key, query) {
2190+
var _query = {};
2191+
if (query instanceof Query && query._query.query) {
2192+
_query["$in_query"] = query._query.query;
2193+
} else if ((typeof query === 'undefined' ? 'undefined' : _typeof(query)) === "object") {
2194+
_query["$in_query"] = query;
2195+
}
2196+
if (this._query['query'][key]) {
2197+
this._query['query'][key] = this._query['query'][key].concat(_query);
2198+
} else {
2199+
this._query['query'][key] = _query;
2200+
}
2201+
return this;
2202+
}
2203+
2204+
/**
2205+
* @method referenceNotIn
2206+
* @memberOf Query
2207+
* @description Retrieve entries that does not satisfy the query conditions made on referenced fields.
2208+
* @param {Query} query - RAW (JSON) queries
2209+
* @returns {Query}
2210+
* @instance
2211+
* @example
2212+
* <caption> referenceNotIn with Query instances</caption>
2213+
* let blogQuery = Stack().ContentType('example').Query();
2214+
* let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
2215+
* data.then(function(result) {
2216+
* // ‘result’ contains the total count.
2217+
* },function (error) {
2218+
* // error function
2219+
* })
2220+
*
2221+
* @example
2222+
* <caption> referenceNotIn with raw queries</caption>
2223+
* let blogQuery = Stack().ContentType('example').Query();
2224+
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
2225+
* let data = blogQuery.referenceNotIn("brand", Query).find()
2226+
* data.then(function(result) {
2227+
* // ‘result’ contains the total count.
2228+
* },function (error) {
2229+
* // error function
2230+
* })
2231+
*/
2232+
2233+
}, {
2234+
key: 'referenceNotIn',
2235+
value: function referenceNotIn(key, query) {
2236+
var _query = {};
2237+
if (query instanceof Query && query._query.query) {
2238+
_query["$nin_query"] = query._query.query;
2239+
} else if ((typeof query === 'undefined' ? 'undefined' : _typeof(query)) === "object") {
2240+
_query["$nin_query"] = query;
2241+
}
2242+
if (this._query['query'][key]) {
2243+
this._query['query'][key] = this._query['query'][key].concat(_query);
2244+
} else {
2245+
this._query['query'][key] = _query;
2246+
}
2247+
return this;
2248+
}
2249+
21202250
/**
21212251
* @method tags
21222252
* @memberOf Query
@@ -2192,18 +2322,18 @@ var Query = function (_Entry) {
21922322
}
21932323

21942324
/**
2195-
* @method addParam
2196-
* @description Includes query parameters in your queries.
2197-
* @memberOf Query
2198-
* @example var data = blogQuery.addParam('include_count', 'true').fetch()
2199-
* data.then(function (result) {
2200-
* // 'result' is an object which content the data including count in json object form
2201-
* },function (error) {
2202-
* // error function
2203-
* })
2204-
* @returns {Query}
2205-
* @instance
2206-
*/
2325+
* @method addParam
2326+
* @description Includes query parameters in your queries.
2327+
* @memberOf Query
2328+
* @example var data = blogQuery.addParam('include_count', 'true').fetch()
2329+
* data.then(function (result) {
2330+
* // 'result' is an object which content the data including count in json object form
2331+
* },function (error) {
2332+
* // error function
2333+
* })
2334+
* @returns {Query}
2335+
* @instance
2336+
*/
22072337

22082338
}, {
22092339
key: 'addParam',

dist/node/contentstack.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,10 +1048,10 @@ var Stack = function () {
10481048
/**
10491049
* @method getContentTypes
10501050
* @memberOf Stack
1051+
* @param {String} param - Query on contentTypes
10511052
* @description This method returns comprehensive information of all the content types of a particular stack in your account.
1052-
* @example Stack.getContentTypes()
10531053
* @example
1054-
* let data = Stack.getContentTypes()
1054+
* let data = Stack.getContentTypes({"include_global_field_schema": true})
10551055
* data
10561056
* .then(function(result) {
10571057
* // 'result' is list of contentTypes.
@@ -1589,7 +1589,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15891589
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
15901590

15911591
//JS SDK version
1592-
var version = '3.8.1';
1592+
var version = '3.8.0';
15931593
var environment = void 0,
15941594
api_key = void 0;
15951595

@@ -2030,7 +2030,6 @@ var Entry = function () {
20302030
key: "includeSchema",
20312031
value: function includeSchema() {
20322032
this._query['include_schema'] = true;
2033-
this._query['include_snippet_schema'] = true;
20342033
return this;
20352034
}
20362035

@@ -2072,7 +2071,6 @@ var Entry = function () {
20722071
key: "includeContentType",
20732072
value: function includeContentType() {
20742073
this._query['include_content_type'] = true;
2075-
this._query['include_snippet_schema'] = true;
20762074
return this;
20772075
}
20782076

@@ -2718,7 +2716,7 @@ var Query = function (_Entry) {
27182716
* @example
27192717
* <caption> referenceIn with Query instances</caption>
27202718
* let blogQuery = Stack().ContentType('example').Query();
2721-
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo').find()
2719+
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
27222720
* let data = blogQuery.referenceIn("brand", Query).find()
27232721
* data.then(function(result) {
27242722
* // ‘result’ contains the total count.
@@ -2774,7 +2772,8 @@ var Query = function (_Entry) {
27742772
* @example
27752773
* <caption> referenceNotIn with raw queries</caption>
27762774
* let blogQuery = Stack().ContentType('example').Query();
2777-
* let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
2775+
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
2776+
* let data = blogQuery.referenceNotIn("brand", Query).find()
27782777
* data.then(function(result) {
27792778
* // ‘result’ contains the total count.
27802779
* },function (error) {

0 commit comments

Comments
 (0)