Skip to content

Commit 2a870f8

Browse files
authored
Merge pull request #55 from contentstack/bug/utils-lib
Update Utils Package
2 parents 6f22178 + be7cd40 commit 2a870f8

14 files changed

Lines changed: 272 additions & 310 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
## Change log
12

2-
3+
### Version: 3.13.2
4+
#### Date: May-26-2021
5+
##### Dependency:
6+
- Update Utils SDK dependency version
7+
38
### Version: 3.13.1
49
#### Date: Apr-16-2021
510
##### Bug fix:

dist/nativescript/contentstack.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-native/contentstack.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web/contentstack.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node/contentstack-demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ContentstackDemo {
2626
*/
2727
getEntries(contentTypeUid) {
2828
contentTypeUid = contentTypeUid || 'source'
29-
return this.Stack.ContentType('test').Query().includeContentType().toJSON().find()
29+
return this.Stack.ContentType(contentTypeUid).Query().includeContentType().toJSON().find()
3030
//return this.Stack.getContentTypes(contentTypeUid)
3131

3232
}

js-sdk-reference/Stack.html

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h2>
6464

6565

6666

67-
<h4 class="name" id="Stack"><span class="type-signature"></span>new Stack<span class="signature">(api_key, delivery_token, environment, region, fetchOptions)</span><span class="type-signature"> &rarr; {<a href="Stack.html">Stack</a>}</span></h4>
67+
<h4 class="name" id="Stack"><span class="type-signature"></span>new Stack<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Stack.html">Stack</a>}</span></h4>
6868

6969

7070

@@ -105,7 +105,7 @@ <h5>Parameters:</h5>
105105

106106
<tr>
107107

108-
<td class="name"><code>api_key</code></td>
108+
<td class="name"><code>stack.api_key</code></td>
109109

110110

111111

@@ -119,7 +119,7 @@ <h5>Parameters:</h5>
119119

120120
<tr>
121121

122-
<td class="name"><code>delivery_token</code></td>
122+
<td class="name"><code>stack.delivery_token</code></td>
123123

124124

125125

@@ -133,7 +133,7 @@ <h5>Parameters:</h5>
133133

134134
<tr>
135135

136-
<td class="name"><code>environment</code></td>
136+
<td class="name"><code>stack.environment</code></td>
137137

138138

139139

@@ -147,7 +147,7 @@ <h5>Parameters:</h5>
147147

148148
<tr>
149149

150-
<td class="name"><code>region</code></td>
150+
<td class="name"><code>stack.region</code></td>
151151

152152

153153

@@ -161,7 +161,7 @@ <h5>Parameters:</h5>
161161

162162
<tr>
163163

164-
<td class="name"><code>fetchOptions</code></td>
164+
<td class="name"><code>stack.fetchOptions</code></td>
165165

166166

167167

@@ -333,7 +333,7 @@ <h6>Properties</h6>
333333

334334

335335

336-
<h5>Examples</h5>
336+
<h5>Example</h5>
337337

338338
<pre class="prettyprint"><code>var Stack = Contentstack.Stack({
339339
'api_key':'api_key',
@@ -345,14 +345,6 @@ <h5>Examples</h5>
345345
}
346346
});</code></pre>
347347

348-
<pre class="prettyprint"><code>var Stack = Contentstack.Stack('api_key', 'access_token', 'environment', {
349-
350-
});</code></pre>
351-
352-
<pre class="prettyprint"><code>// For Setting the European Region:
353-
// If you want to set and use European region, refer to the code below:
354-
const Stack = Contentstack.Stack("api_key", "delivery_token", "environment_name", Contentstack.Region.EU);</code></pre>
355-
356348

357349

358350

js-sdk-reference/modules_assets.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ <h1 class="page-title">modules/assets.js</h1>
167167
query: this._query
168168
}
169169
}
170-
var options = Object.assign({}, this.fetchOptions, fetchOptions);
170+
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
171171
return Utils.sendRequest(this, options);
172172
} else {
173173
console.error("Kindly provide an asset uid. e.g. .Assets('bltsomething123')");

js-sdk-reference/modules_entry.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ <h1 class="page-title">modules/entry.js</h1>
390390
query: this._query
391391
}
392392
};
393-
var options = Object.assign({}, this.fetchOptions, fetchOptions);
393+
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
394394
return Utils.sendRequest(this, options);
395395
} else {
396396
console.error("Kindly provide an entry uid. e.g. .Entry('bltsomething123')");

js-sdk-reference/modules_query.js.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ <h1 class="page-title">modules/query.js</h1>
806806
query: this._query
807807
}
808808
};
809-
var options = Object.assign({}, this.fetchOptions, fetchOptions);
809+
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
810810
return Utils.sendRequest(this, options);
811811
}
812812

@@ -839,7 +839,7 @@ <h1 class="page-title">modules/query.js</h1>
839839
query: this._query
840840
}
841841
};
842-
var options = Object.assign({}, this.fetchOptions);
842+
var options = Utils.mergeDeep({}, this.fetchOptions);
843843
return Utils.sendRequest(this, options);
844844
}
845845

js-sdk-reference/stack.js.html

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,18 @@ <h1 class="page-title">stack.js</h1>
6060
* @class
6161
Stack
6262
* @description Initialize an instance of ‘Stack’
63-
* @param api_key - Stack API Key.
64-
* @param delivery_token - Stack Delivery token.
65-
* @param environment - Stack Environment name.
66-
* @param region - DB region for Stack.
67-
* @param fetchOptions - Custom setting for the request.
68-
* @param fetchOptions.timeout - Set timeout for the request.
69-
* @param fetchOptions.retryLimit - The number of retries before failure. Default is 5
70-
* @param fetchOptions.retryDelay - The number of ms to use for operation retries. Default is 300ms
71-
* @param fetchOptions.retryCondition - A function to determine if the error can be retried. Default retry is on status codes 408, 429.
72-
* @param fetchOptions.retryDelayOptions.base - The base number of milliseconds to use in the exponential backoff for operation retries.
73-
* @param fetchOptions.retryDelayOptions.customBackoff - A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds.
63+
64+
* @param {String} stack.api_key - Stack API Key.
65+
* @param {String} stack.delivery_token - Stack Delivery token.
66+
* @param {String} stack.environment - Stack Environment name.
67+
* @param {String} stack.region - DB region for Stack.
68+
* @param {Object} stack.fetchOptions - Custom setting for the request.
69+
* @param {number} stack.fetchOptions.timeout - Set timeout for the request.
70+
* @param {number} stack.fetchOptions.retryLimit - The number of retries before failure. Default is 5
71+
* @param {number} stack.fetchOptions.retryDelay - The number of ms to use for operation retries. Default is 300ms
72+
* @param {function} stack.fetchOptions.retryCondition - A function to determine if the error can be retried. Default retry is on status codes 408, 429.
73+
* @param {function} stack.fetchOptions.retryDelayOptions.base - The base number of milliseconds to use in the exponential backoff for operation retries.
74+
* @param {function} stack.fetchOptions.retryDelayOptions.customBackoff - A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds.
7475
* @example
7576
* var Stack = Contentstack.Stack({
7677
* 'api_key':'api_key',
@@ -82,16 +83,6 @@ <h1 class="page-title">stack.js</h1>
8283
* }
8384
* });
8485
*
85-
* @example
86-
* var Stack = Contentstack.Stack('api_key', 'access_token', 'environment', {
87-
*
88-
* });
89-
*
90-
* @example
91-
* // For Setting the European Region:
92-
* // If you want to set and use European region, refer to the code below:
93-
* const Stack = Contentstack.Stack("api_key", "delivery_token", "environment_name", Contentstack.Region.EU);
94-
*
9586
* @returns {Stack}
9687
* @instance
9788
*/
@@ -106,14 +97,14 @@ <h1 class="page-title">stack.js</h1>
10697
return false
10798
}
10899
};
109-
this.config = Object.assign({}, config)
100+
this.config = Utils.mergeDeep({}, config)
110101

111102
if(stack_arguments[0].region &amp;&amp; stack_arguments[0].region !== undefined &amp;&amp; stack_arguments[0].region !== "us") {
112103
this.config['host'] = stack_arguments[0].region+"-"+"cdn.contentstack.com";
113104
}
114105

115106
if (stack_arguments[0].fetchOptions &amp;&amp; stack_arguments[0].fetchOptions !== undefined) {
116-
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[0].fetchOptions);
107+
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[0].fetchOptions);
117108
}
118109

119110
this.cachePolicy = CacheProvider.policies.IGNORE_CACHE;
@@ -156,7 +147,7 @@ <h1 class="page-title">stack.js</h1>
156147
if(typeof stack_arguments[3] === "string" &amp;&amp; stack_arguments[3] !== undefined &amp;&amp; stack_arguments[3] !== "us") {
157148
this.config['host'] = stack_arguments[3]+"-"+"cdn.contentstack.com";
158149
} else if (typeof stack_arguments[3] === 'object') {
159-
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[3]);
150+
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[3]);
160151
}
161152
}
162153
return this;
@@ -175,11 +166,11 @@ <h1 class="page-title">stack.js</h1>
175166
if(typeof stack_arguments[3] === "string" &amp;&amp; stack_arguments[3] !== undefined &amp;&amp; stack_arguments[3] !== "us") {
176167
this.config['host'] = stack_arguments[3]+"-"+"cdn.contentstack.com";
177168
} else if (typeof stack_arguments[3] === 'object') {
178-
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[3]);
169+
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[3]);
179170
}
180171
}
181172
if (stack_arguments[4] &amp;&amp; typeof stack_arguments[4] === 'object') {
182-
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[4]);
173+
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[4]);
183174
}
184175
return this;
185176
default:
@@ -402,7 +393,7 @@ <h1 class="page-title">stack.js</h1>
402393
environment: this.environment
403394
}
404395
};
405-
var options = Object.assign({}, this.fetchOptions, fetchOptions);
396+
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
406397
return Request(result, options);
407398
}
408399

@@ -546,7 +537,7 @@ <h1 class="page-title">stack.js</h1>
546537

547538
sync(params, fetchOptions) {
548539
this._query = {};
549-
this._query = Object.assign(this._query, params);
540+
this._query = Utils.mergeDeep(this._query, params);
550541
this.requestParams = {
551542
method: 'POST',
552543
headers: this.headers,
@@ -556,7 +547,7 @@ <h1 class="page-title">stack.js</h1>
556547
query: this._query
557548
}
558549
}
559-
var options = Object.assign({}, this.fetchOptions, fetchOptions);
550+
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
560551
return Utils.sendRequest(this, options);
561552
}
562553

0 commit comments

Comments
 (0)