@@ -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
}
@@ -1039,7 +1064,7 @@ var Stack = function () {
1039
1064
1040
1065
} , {
1041
1066
key : 'getContentTypes' ,
1042
- value : function getContentTypes ( ) {
1067
+ value : function getContentTypes ( param ) {
1043
1068
var query = {
1044
1069
method : 'POST' ,
1045
1070
headers : this . headers ,
@@ -1049,6 +1074,11 @@ var Stack = function () {
1049
1074
environment : this . environment
1050
1075
}
1051
1076
} ;
1077
+ if ( param && param !== undefined ) {
1078
+ for ( var key in param ) {
1079
+ query . body [ key ] = param [ key ] ;
1080
+ }
1081
+ }
1052
1082
return ( 0 , _request2 . default ) ( query ) ;
1053
1083
}
1054
1084
@@ -1559,7 +1589,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
1559
1589
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 ; } }
1560
1590
1561
1591
//JS SDK version
1562
- var version = '3.7 .1' ;
1592
+ var version = '3.8 .1' ;
1563
1593
var environment = void 0 ,
1564
1594
api_key = void 0 ;
1565
1595
@@ -2000,6 +2030,7 @@ var Entry = function () {
2000
2030
key : "includeSchema" ,
2001
2031
value : function includeSchema ( ) {
2002
2032
this . _query [ 'include_schema' ] = true ;
2033
+ this . _query [ 'include_snippet_schema' ] = true ;
2003
2034
return this ;
2004
2035
}
2005
2036
@@ -2041,6 +2072,7 @@ var Entry = function () {
2041
2072
key : "includeContentType" ,
2042
2073
value : function includeContentType ( ) {
2043
2074
this . _query [ 'include_content_type' ] = true ;
2075
+ this . _query [ 'include_snippet_schema' ] = true ;
2044
2076
return this ;
2045
2077
}
2046
2078
@@ -2655,6 +2687,14 @@ var Query = function (_Entry) {
2655
2687
* @param {object } query - RAW (JSON) queries
2656
2688
* @returns {Query }
2657
2689
* @instance
2690
+ * @example
2691
+ * let blogQuery = Stack().ContentType('example').Query();
2692
+ * let data = blogQuery.query({"brand": {"$nin_query": {"title": "Apple Inc."}}}).find()
2693
+ * data.then(function(result) {
2694
+ * // ‘result’ contains the total count.
2695
+ * },function (error) {
2696
+ * // error function
2697
+ * })
2658
2698
*/
2659
2699
2660
2700
} , {
@@ -2668,6 +2708,97 @@ var Query = function (_Entry) {
2668
2708
}
2669
2709
}
2670
2710
2711
+ /**
2712
+ * @method referenceIn
2713
+ * @memberOf Query
2714
+ * @description Retrieve entries that satisfy the query conditions made on referenced fields.
2715
+ * @param {Query } query - RAW (JSON) queries
2716
+ * @returns {Query }
2717
+ * @instance
2718
+ * @example
2719
+ * <caption> referenceIn with Query instances</caption>
2720
+ * let blogQuery = Stack().ContentType('example').Query();
2721
+ * let Query = Stack.ContentType('blog').Query().where('title', 'Demo').find()
2722
+ * let data = blogQuery.referenceIn("brand", Query).find()
2723
+ * data.then(function(result) {
2724
+ * // ‘result’ contains the total count.
2725
+ * },function (error) {
2726
+ * // error function
2727
+ * })
2728
+ *
2729
+ * @example
2730
+ * <caption> referenceIn with raw queries</caption>
2731
+ * let blogQuery = Stack().ContentType('example').Query();
2732
+ * let data = blogQuery.referenceIn("brand", {'title': 'Demo'}).find()
2733
+ * data.then(function(result) {
2734
+ * // ‘result’ contains the total count.
2735
+ * },function (error) {
2736
+ * // error function
2737
+ * })
2738
+ */
2739
+
2740
+ } , {
2741
+ key : 'referenceIn' ,
2742
+ value : function referenceIn ( key , query ) {
2743
+ var _query = { } ;
2744
+ if ( query instanceof Query && query . _query . query ) {
2745
+ _query [ "$in_query" ] = query . _query . query ;
2746
+ } else if ( ( typeof query === 'undefined' ? 'undefined' : _typeof ( query ) ) === "object" ) {
2747
+ _query [ "$in_query" ] = query ;
2748
+ }
2749
+ if ( this . _query [ 'query' ] [ key ] ) {
2750
+ this . _query [ 'query' ] [ key ] = this . _query [ 'query' ] [ key ] . concat ( _query ) ;
2751
+ } else {
2752
+ this . _query [ 'query' ] [ key ] = _query ;
2753
+ }
2754
+ return this ;
2755
+ }
2756
+
2757
+ /**
2758
+ * @method referenceNotIn
2759
+ * @memberOf Query
2760
+ * @description Retrieve entries that does not satisfy the query conditions made on referenced fields.
2761
+ * @param {Query } query - RAW (JSON) queries
2762
+ * @returns {Query }
2763
+ * @instance
2764
+ * @example
2765
+ * <caption> referenceNotIn with Query instances</caption>
2766
+ * let blogQuery = Stack().ContentType('example').Query();
2767
+ * let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
2768
+ * data.then(function(result) {
2769
+ * // ‘result’ contains the total count.
2770
+ * },function (error) {
2771
+ * // error function
2772
+ * })
2773
+ *
2774
+ * @example
2775
+ * <caption> referenceNotIn with raw queries</caption>
2776
+ * let blogQuery = Stack().ContentType('example').Query();
2777
+ * let data = blogQuery.referenceNotIn("brand", {'title': 'Demo'}).find()
2778
+ * data.then(function(result) {
2779
+ * // ‘result’ contains the total count.
2780
+ * },function (error) {
2781
+ * // error function
2782
+ * })
2783
+ */
2784
+
2785
+ } , {
2786
+ key : 'referenceNotIn' ,
2787
+ value : function referenceNotIn ( key , query ) {
2788
+ var _query = { } ;
2789
+ if ( query instanceof Query && query . _query . query ) {
2790
+ _query [ "$nin_query" ] = query . _query . query ;
2791
+ } else if ( ( typeof query === 'undefined' ? 'undefined' : _typeof ( query ) ) === "object" ) {
2792
+ _query [ "$nin_query" ] = query ;
2793
+ }
2794
+ if ( this . _query [ 'query' ] [ key ] ) {
2795
+ this . _query [ 'query' ] [ key ] = this . _query [ 'query' ] [ key ] . concat ( _query ) ;
2796
+ } else {
2797
+ this . _query [ 'query' ] [ key ] = _query ;
2798
+ }
2799
+ return this ;
2800
+ }
2801
+
2671
2802
/**
2672
2803
* @method tags
2673
2804
* @memberOf Query
@@ -2743,18 +2874,18 @@ var Query = function (_Entry) {
2743
2874
}
2744
2875
2745
2876
/**
2746
- * @method addParam
2747
- * @description Includes query parameters in your queries.
2748
- * @memberOf Query
2749
- * @example var data = blogQuery.addParam('include_count', 'true').fetch()
2750
- * data.then(function (result) {
2751
- * // 'result' is an object which content the data including count in json object form
2752
- * },function (error) {
2753
- * // error function
2754
- * })
2755
- * @returns {Query }
2756
- * @instance
2757
- */
2877
+ * @method addParam
2878
+ * @description Includes query parameters in your queries.
2879
+ * @memberOf Query
2880
+ * @example var data = blogQuery.addParam('include_count', 'true').fetch()
2881
+ * data.then(function (result) {
2882
+ * // 'result' is an object which content the data including count in json object form
2883
+ * },function (error) {
2884
+ * // error function
2885
+ * })
2886
+ * @returns {Query }
2887
+ * @instance
2888
+ */
2758
2889
2759
2890
} , {
2760
2891
key : 'addParam' ,
0 commit comments