Skip to content

Hotfix 3.8.1 #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 148 additions & 18 deletions dist/nativescript/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,40 @@ function resultWrapper(result) {
return result;
};

// // spread the result object
// export function spreadResult(result) {
// let _results = [];
// if (result && Object.keys(result).length) {
// if (typeof result.entries !== 'undefined') _results.push(result.entries);
// if (typeof result.assets !== 'undefined') _results.push(result.assets);
// if (typeof result.content_type !== 'undefined' || typeof result.schema !== 'undefined') _results.push(result.content_type || result.schema);
// if (typeof result.count !== 'undefined') _results.push(result.count);
// if (typeof result.entry !== 'undefined') _results = result.entry;
// if (typeof result.asset !== 'undefined') _results = result.asset;
// if (typeof result.items !== 'undefined') _results.push(result);
// }
// return _results;
// };

// spread the result object
function spreadResult(result) {
var _results = [];
if (result && Object.keys(result).length) {
if (typeof result.entries !== 'undefined') _results.push(result.entries);
if (typeof result.entries !== 'undefined') {
_results.push(result.entries);
if (result.content_type) {
_results['schema'] = result.content_type;
}
}
if (typeof result.assets !== 'undefined') _results.push(result.assets);
if (typeof result.content_type !== 'undefined' || typeof result.schema !== 'undefined') _results.push(result.content_type || result.schema);
if (typeof result.count !== 'undefined') _results.push(result.count);
if (typeof result.entry !== 'undefined') _results = result.entry;
if (typeof result.entry !== 'undefined') {
_results = result.entry;
if (result.schema) {
_results['schema'] = result.schema;
}
}
if (typeof result.asset !== 'undefined') _results = result.asset;
if (typeof result.items !== 'undefined') _results.push(result);
}
Expand Down Expand Up @@ -927,10 +952,10 @@ var Stack = function () {
/**
* @method getContentTypes
* @memberOf Stack
* @param {String} param - Query on contentTypes
* @description This method returns comprehensive information of all the content types of a particular stack in your account.
* @example Stack.getContentTypes()
* @example
* let data = Stack.getContentTypes()
* let data = Stack.getContentTypes({"include_global_field_schema": true})
* data
* .then(function(result) {
* // 'result' is list of contentTypes.
Expand All @@ -943,7 +968,7 @@ var Stack = function () {

}, {
key: 'getContentTypes',
value: function getContentTypes() {
value: function getContentTypes(param) {
var query = {
method: 'POST',
headers: this.headers,
Expand All @@ -953,6 +978,11 @@ var Stack = function () {
environment: this.environment
}
};
if (param && param !== undefined) {
for (var key in param) {
query.body[key] = param[key];
}
}
return (0, _request2.default)(query);
}

Expand Down Expand Up @@ -1060,7 +1090,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
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; } }

//JS SDK version
var version = '3.7.1';
var version = '3.8.0';
var environment = void 0,
api_key = void 0;

Expand Down Expand Up @@ -2104,6 +2134,14 @@ var Query = function (_Entry) {
* @param {object} query - RAW (JSON) queries
* @returns {Query}
* @instance
* @example
* let blogQuery = Stack().ContentType('example').Query();
* let data = blogQuery.query({"brand": {"$nin_query": {"title": "Apple Inc."}}}).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
* },function (error) {
* // error function
* })
*/

}, {
Expand All @@ -2117,6 +2155,98 @@ var Query = function (_Entry) {
}
}

/**
* @method referenceIn
* @memberOf Query
* @description Retrieve entries that satisfy the query conditions made on referenced fields.
* @param {Query} query - RAW (JSON) queries
* @returns {Query}
* @instance
* @example
* <caption> referenceIn with Query instances</caption>
* let blogQuery = Stack().ContentType('example').Query();
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
* let data = blogQuery.referenceIn("brand", Query).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
* },function (error) {
* // error function
* })
*
* @example
* <caption> referenceIn with raw queries</caption>
* let blogQuery = Stack().ContentType('example').Query();
* let data = blogQuery.referenceIn("brand", {'title': 'Demo'}).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
* },function (error) {
* // error function
* })
*/

}, {
key: 'referenceIn',
value: function referenceIn(key, query) {
var _query = {};
if (query instanceof Query && query._query.query) {
_query["$in_query"] = query._query.query;
} else if ((typeof query === 'undefined' ? 'undefined' : _typeof(query)) === "object") {
_query["$in_query"] = query;
}
if (this._query['query'][key]) {
this._query['query'][key] = this._query['query'][key].concat(_query);
} else {
this._query['query'][key] = _query;
}
return this;
}

/**
* @method referenceNotIn
* @memberOf Query
* @description Retrieve entries that does not satisfy the query conditions made on referenced fields.
* @param {Query} query - RAW (JSON) queries
* @returns {Query}
* @instance
* @example
* <caption> referenceNotIn with Query instances</caption>
* let blogQuery = Stack().ContentType('example').Query();
* let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
* },function (error) {
* // error function
* })
*
* @example
* <caption> referenceNotIn with raw queries</caption>
* let blogQuery = Stack().ContentType('example').Query();
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
* let data = blogQuery.referenceNotIn("brand", Query).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
* },function (error) {
* // error function
* })
*/

}, {
key: 'referenceNotIn',
value: function referenceNotIn(key, query) {
var _query = {};
if (query instanceof Query && query._query.query) {
_query["$nin_query"] = query._query.query;
} else if ((typeof query === 'undefined' ? 'undefined' : _typeof(query)) === "object") {
_query["$nin_query"] = query;
}
if (this._query['query'][key]) {
this._query['query'][key] = this._query['query'][key].concat(_query);
} else {
this._query['query'][key] = _query;
}
return this;
}

/**
* @method tags
* @memberOf Query
Expand Down Expand Up @@ -2192,18 +2322,18 @@ var Query = function (_Entry) {
}

/**
* @method addParam
* @description Includes query parameters in your queries.
* @memberOf Query
* @example var data = blogQuery.addParam('include_count', 'true').fetch()
* data.then(function (result) {
* // 'result' is an object which content the data including count in json object form
* },function (error) {
* // error function
* })
* @returns {Query}
* @instance
*/
* @method addParam
* @description Includes query parameters in your queries.
* @memberOf Query
* @example var data = blogQuery.addParam('include_count', 'true').fetch()
* data.then(function (result) {
* // 'result' is an object which content the data including count in json object form
* },function (error) {
* // error function
* })
* @returns {Query}
* @instance
*/

}, {
key: 'addParam',
Expand Down
13 changes: 6 additions & 7 deletions dist/node/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1048,10 +1048,10 @@ var Stack = function () {
/**
* @method getContentTypes
* @memberOf Stack
* @param {String} param - Query on contentTypes
* @description This method returns comprehensive information of all the content types of a particular stack in your account.
* @example Stack.getContentTypes()
* @example
* let data = Stack.getContentTypes()
* let data = Stack.getContentTypes({"include_global_field_schema": true})
* data
* .then(function(result) {
* // 'result' is list of contentTypes.
Expand Down Expand Up @@ -1589,7 +1589,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
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; } }

//JS SDK version
var version = '3.8.1';
var version = '3.8.0';
var environment = void 0,
api_key = void 0;

Expand Down Expand Up @@ -2030,7 +2030,6 @@ var Entry = function () {
key: "includeSchema",
value: function includeSchema() {
this._query['include_schema'] = true;
this._query['include_snippet_schema'] = true;
return this;
}

Expand Down Expand Up @@ -2072,7 +2071,6 @@ var Entry = function () {
key: "includeContentType",
value: function includeContentType() {
this._query['include_content_type'] = true;
this._query['include_snippet_schema'] = true;
return this;
}

Expand Down Expand Up @@ -2718,7 +2716,7 @@ var Query = function (_Entry) {
* @example
* <caption> referenceIn with Query instances</caption>
* let blogQuery = Stack().ContentType('example').Query();
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo').find()
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
* let data = blogQuery.referenceIn("brand", Query).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
Expand Down Expand Up @@ -2774,7 +2772,8 @@ var Query = function (_Entry) {
* @example
* <caption> referenceNotIn with raw queries</caption>
* let blogQuery = Stack().ContentType('example').Query();
* let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
* let Query = Stack.ContentType('blog').Query().where('title', 'Demo')
* let data = blogQuery.referenceNotIn("brand", Query).find()
* data.then(function(result) {
* // ‘result’ contains the total count.
* },function (error) {
Expand Down
Loading