Skip to content
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@


### Version: 3.13.1
#### Date: Apr-16-2021
##### Bug fix:
- IE 11 request method issue resolved

### Version: 3.13.0
#### Date:
#### Date: Apr-05-2021

##### Update API:
- [Query]: Added support for method includeEmbeddedItems
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ imageUrl = Stack.imageTransform(imageUrl, {
The Sync API takes care of syncing your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates. Contentstack’s JavaScript SDK supports Sync API, which you can use to build powerful apps. Read through to understand how to use the Sync API with Contentstack JavaScript SDK.
[Read Sync API documentation](https://www.contentstack.com/docs/platforms/javascript-browser#using-the-sync-api-with-javascript-sdk).

> Note: Sync function does not support cache policy. When using the Sync function, we recommend you to set the cache policy to IGNORE_CACHE.
##### Initial sync

The Initial Sync process performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response.
Expand All @@ -235,7 +236,8 @@ data.then(function(sync_data, err) {
if (err) throw err
})
```
> Note: Sync function does not support CachePolicy, we prefer to keep CachePolicy to `IGNORE_CACHE` while using Sync API.
> Note: Sync function does not support cache policy. When using the Sync function, we recommend you to set the cache policy to IGNORE_CACHE.


The response also contains a sync token, which you need to store, since this token is used to get subsequent delta updates later, as shown in the Subsequent Sync section below.

Expand Down
12 changes: 6 additions & 6 deletions dist/nativescript/contentstack.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/node/contentstack.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/react-native/contentstack.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/web/contentstack.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/node/contentstack-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ContentstackDemo {
//console.log("datattatata", Contentstack.Region.EUROPE)

this.Stack = Contentstack.Stack(...config);
console.log(Contentstack.Utils.render());
}


Expand Down
22 changes: 18 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.13.0",
"version": "3.13.1",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand All @@ -10,7 +10,7 @@
"main": "dist/node/contentstack.js",
"browser": "dist/web/contentstack.js",
"types": "./index.d.ts",
"_id": "contentstack@3.13.0",
"_id": "contentstack@3.13.1",
"scripts": {
"test": "npm run test:e2e && npm run test:typescript",
"test:e2e": "istanbul cover tape test/index.js | tap-html --out ./tap-html.html",
Expand All @@ -22,7 +22,8 @@
"buildnativescript": "webpack --config webpack/webpack.nativescript.js",
"build": "NODE_ENV=production && npm run buildnode && npm run buildweb && npm run buildreactnative && npm run buildnativescript",
"generate-docs": "node_modules/.bin/jsdoc --configure docs-config.json --verbose",
"prepare": "npm run build"
"prepare": "npm run build",
"pretest": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -53,14 +54,14 @@
],
"dist": {
"shasum": "a328ed07240476a26b31a23261355dc929e1da63",
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.0.tgz"
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.1.tgz"
},
"license": "MIT",
"directories": {},
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.0.tgz",
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.1.tgz",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/contentstack-3.13.0.tgz_1477830884275_0.9869455888401717"
"tmp": "tmp/contentstack-3.13.1.tgz_1477830884275_0.9869455888401717"
},
"devDependencies": {
"@types/jest": "^26.0.13",
Expand Down Expand Up @@ -99,7 +100,7 @@
"dependencies": {
"@contentstack/utils": "1.0.0",
"es6-promise": "4.1.1",
"localStorage": "1.0.3",
"node-fetch": "^2.6.1"
"isomorphic-fetch": "^3.0.0",
"localStorage": "1.0.3"
}
}
2 changes: 1 addition & 1 deletion src/core/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function safeParseJSON(response) {
const body = await response.text();
}
function fetchRetry(url, headers, retryDelay = 300, retryLimit = 5, fetchOptions, resolve, reject) {
var option = Object.assign({
var option = Utils.mergeDeep({
method: 'GET',
headers: headers,
timeout: 30000,
Expand Down
4 changes: 1 addition & 3 deletions src/core/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ export function sendRequest(queryObject, options) {
let tojson = (typeof self.tojson !== 'undefined') ? self.tojson : false;
let isSingle = (self.entry_uid || self.singleEntry || self.asset_uid) ? true : false;
let hashQuery = getHash(parseQueryFromParams(self, isSingle, tojson));
if (queryObject.requestParams.url.includes(config.urls.sync)) {
cachePolicy = -1;
}

/**
for new api v3
*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class Assets {
query: this._query
}
}
var options = Object.assign({}, this.fetchOptions, fetchOptions);
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
return Utils.sendRequest(this, options);
} else {
console.error("Kindly provide an asset uid. e.g. .Assets('bltsomething123')");
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export default class Entry {
query: this._query
}
};
var options = Object.assign({}, this.fetchOptions, fetchOptions);
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
return Utils.sendRequest(this, options);
} else {
console.error("Kindly provide an entry uid. e.g. .Entry('bltsomething123')");
Expand Down
4 changes: 2 additions & 2 deletions src/core/modules/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ export default class Query extends Entry {
query: this._query
}
};
var options = Object.assign({}, this.fetchOptions, fetchOptions);
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
return Utils.sendRequest(this, options);
}

Expand Down Expand Up @@ -790,7 +790,7 @@ export default class Query extends Entry {
query: this._query
}
};
var options = Object.assign({}, this.fetchOptions);
var options = Utils.mergeDeep({}, this.fetchOptions);
return Utils.sendRequest(this, options);
}

Expand Down
16 changes: 8 additions & 8 deletions src/core/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export default class Stack {
return false
}
};
this.config = Object.assign({}, config)
this.config = Utils.mergeDeep({}, config)

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

if (stack_arguments[0].fetchOptions && stack_arguments[0].fetchOptions !== undefined) {
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[0].fetchOptions);
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[0].fetchOptions);
}

this.cachePolicy = CacheProvider.policies.IGNORE_CACHE;
Expand Down Expand Up @@ -107,7 +107,7 @@ export default class Stack {
if(typeof stack_arguments[3] === "string" && stack_arguments[3] !== undefined && stack_arguments[3] !== "us") {
this.config['host'] = stack_arguments[3]+"-"+"cdn.contentstack.com";
} else if (typeof stack_arguments[3] === 'object') {
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[3]);
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[3]);
}
}
return this;
Expand All @@ -126,11 +126,11 @@ export default class Stack {
if(typeof stack_arguments[3] === "string" && stack_arguments[3] !== undefined && stack_arguments[3] !== "us") {
this.config['host'] = stack_arguments[3]+"-"+"cdn.contentstack.com";
} else if (typeof stack_arguments[3] === 'object') {
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[3]);
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[3]);
}
}
if (stack_arguments[4] && typeof stack_arguments[4] === 'object') {
this.fetchOptions = Object.assign(this.fetchOptions, stack_arguments[4]);
this.fetchOptions = Utils.mergeDeep(this.fetchOptions, stack_arguments[4]);
}
return this;
default:
Expand Down Expand Up @@ -353,7 +353,7 @@ export default class Stack {
environment: this.environment
}
};
var options = Object.assign({}, this.fetchOptions, fetchOptions);
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
return Request(result, options);
}

Expand Down Expand Up @@ -497,7 +497,7 @@ export default class Stack {

sync(params, fetchOptions) {
this._query = {};
this._query = Object.assign(this._query, params);
this._query = Utils.mergeDeep(this._query, params);
this.requestParams = {
method: 'POST',
headers: this.headers,
Expand All @@ -507,7 +507,7 @@ export default class Stack {
query: this._query
}
}
var options = Object.assign({}, this.fetchOptions, fetchOptions);
var options = Utils.mergeDeep({}, this.fetchOptions, fetchOptions);
return Utils.sendRequest(this, options);
}

Expand Down
3 changes: 1 addition & 2 deletions src/runtime/web/http.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ES6Promise from 'es6-promise';
import fetch from 'node-fetch';

import fetch from 'isomorphic-fetch';
ES6Promise.polyfill();

export default fetch;
26 changes: 13 additions & 13 deletions src/runtime/web/localstorage.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// export default window.localStorage;
export default window.localStorage;

let webLocalStoreage = function (){
try {
var storage = window.localStorage
// x = '__storage_test__';
// storage.setItem(x, x);
// storage.removeItem(x);
return storage;
} catch(e) {
return null
}
};
// let webLocalStoreage = function (){
// try {
// var storage = window.localStorage
// // x = '__storage_test__';
// // storage.setItem(x, x);
// // storage.removeItem(x);
// return storage;
// } catch(e) {
// return null
// }
// };

export default webLocalStoreage();
// export default webLocalStoreage();

7 changes: 5 additions & 2 deletions test/entry/findone-result-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ test('findOne: .only() - For the reference - Array', function(assert) {
.only('reference', ['title'])
.findOne()
.then(function success(entry) {
var flag = false;
if (entry && entry.get('reference')) {
var flag = false; if (entry && entry.get('reference')) {
if (entry.get('reference').length) {
if (entry.get('reference').length === 0){
flag = true
Expand All @@ -637,7 +636,11 @@ test('findOne: .only() - For the reference - Array', function(assert) {
return (reference && "title" in reference && "uid" in reference);
});
}
} else {
flag = true
}
} else {
flag = true
}
assert.equal(flag, true, 'Entry do not have the reference with only paramteres.');
assert.end();
Expand Down
2 changes: 2 additions & 0 deletions test/entry/findone.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ test('findOne: .only() - For the reference - Array', function(assert) {
return (reference && "title" in reference && "uid" in reference);
});
}
}else {
flag = true
}
} else {
flag = true
Expand Down