@@ -277,15 +277,40 @@ function resultWrapper(result) {
277
277
return result ;
278
278
} ;
279
279
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
+
280
295
// spread the result object
281
296
function spreadResult ( result ) {
282
297
var _results = [ ] ;
283
298
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
+ }
285
305
if ( typeof result . assets !== 'undefined' ) _results . push ( result . assets ) ;
286
306
if ( typeof result . content_type !== 'undefined' || typeof result . schema !== 'undefined' ) _results . push ( result . content_type || result . schema ) ;
287
307
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
+ }
289
314
if ( typeof result . asset !== 'undefined' ) _results = result . asset ;
290
315
if ( typeof result . items !== 'undefined' ) _results . push ( result ) ;
291
316
}
@@ -927,10 +952,10 @@ var Stack = function () {
927
952
/**
928
953
* @method getContentTypes
929
954
* @memberOf Stack
955
+ * @param {String } param - Query on contentTypes
930
956
* @description This method returns comprehensive information of all the content types of a particular stack in your account.
931
- * @example Stack.getContentTypes()
932
957
* @example
933
- * let data = Stack.getContentTypes()
958
+ * let data = Stack.getContentTypes({"include_global_field_schema": true} )
934
959
* data
935
960
* .then(function(result) {
936
961
* // 'result' is list of contentTypes.
@@ -943,7 +968,7 @@ var Stack = function () {
943
968
944
969
} , {
945
970
key : 'getContentTypes' ,
946
- value : function getContentTypes ( ) {
971
+ value : function getContentTypes ( param ) {
947
972
var query = {
948
973
method : 'POST' ,
949
974
headers : this . headers ,
@@ -953,6 +978,11 @@ var Stack = function () {
953
978
environment : this . environment
954
979
}
955
980
} ;
981
+ if ( param && param !== undefined ) {
982
+ for ( var key in param ) {
983
+ query . body [ key ] = param [ key ] ;
984
+ }
985
+ }
956
986
return ( 0 , _request2 . default ) ( query ) ;
957
987
}
958
988
@@ -1060,7 +1090,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
1060
1090
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 ; } }
1061
1091
1062
1092
//JS SDK version
1063
- var version = '3.7.1 ' ;
1093
+ var version = '3.8.0 ' ;
1064
1094
var environment = void 0 ,
1065
1095
api_key = void 0 ;
1066
1096
@@ -2104,6 +2134,14 @@ var Query = function (_Entry) {
2104
2134
* @param {object } query - RAW (JSON) queries
2105
2135
* @returns {Query }
2106
2136
* @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
+ * })
2107
2145
*/
2108
2146
2109
2147
} , {
@@ -2117,6 +2155,98 @@ var Query = function (_Entry) {
2117
2155
}
2118
2156
}
2119
2157
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
+
2120
2250
/**
2121
2251
* @method tags
2122
2252
* @memberOf Query
@@ -2192,18 +2322,18 @@ var Query = function (_Entry) {
2192
2322
}
2193
2323
2194
2324
/**
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
+ */
2207
2337
2208
2338
} , {
2209
2339
key : 'addParam' ,
0 commit comments