Skip to content

Live preview SSR error on page refresh #81

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 18 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 15 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
34 changes: 34 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Publish package to NPM repository
on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-git:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
scope: '@contentstack'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ src
.env
*.tgz
.talismanrc
tap-html.html
tap-html.html
.github
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
threshold: medium
fileignoreconfig:
- filename: package-lock.json
checksum: 032d3a56d28528673b84e083a30d726d15b7c0616d1d6e7e4936d7e6c05534ee
checksum: be538ba2f4b106e5de0a55a3137271f659901e287ec09e8ae93351543242712e
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Change log

### Version: 3.15.3
#### Date: July-26-2022
##### New Features:
- Live preview with reference in entry on SSR web app issue resolved
### Version: 3.15.2
#### Date: May-03-2022
##### New Features:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ We have introduced Image Delivery APIs that let you retrieve images and then man

For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/owl.jpg?crop=300,400. There are several more parameters that you can use for your images.

[Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
[Read Image Delivery API documentation](https://www.contentstack.com/docs/developers/apis/image-delivery-api/).

Following are Image Delivery API examples.

Expand Down
4 changes: 2 additions & 2 deletions contentstack-templates/tmpl/layout.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Query.setCachePolicy(Contentstack.CachePolicy.CACHE_THEN_NETWORK)
<h3><a id="Working_with_Images_147"></a>Working with Images</h3>
<p>We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.</p>
<p>For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, <a href=" https://images.contentstack.io/owl.jpg?crop=300,400"> https://images.contentstack.io/owl.jpg?crop=300,400</a>. There are several more parameters that you can use for your images.</p>
<p><a href="https://www.contentstack.com/docs/apis/image-delivery-api/">Read Image Delivery API documentation</a>.</p>
<p><a href="https://www.contentstack.com/docs/developers/apis/image-delivery-api/">Read Image Delivery API documentation</a>.</p>

<h5><a id="Following_are_Image_Delivery_API_examples_203"></a>Following are Image Delivery API examples</h5>
<p>Following are Image Delivery API examples.</p>
Expand All @@ -233,7 +233,7 @@ const imageUrl = Stack.imageTransform(imageUrl, {
<ul>
<li><a href="https://www.contentstack.com">Contentstack Website</a></li>
<li><a href="https://www.contentstack.com/docs">Official Documentation</a></li>
<li><a href="https://www.contentstack.com/docs/apis/content-delivery-api/">Content Delivery API Docs</a></li>
<li><a href="https://www.contentstack.com/docs/developers/apis/content-delivery-api/">Content Delivery API Docs</a></li>
</ul>
<h3><a id="The_MIT_License_MIT_163"></a>The MIT License (MIT)</h3>
<p>Copyright © 2016-2021 <a href="https://www.contentstack.com">Contentstack</a>. All Rights Reserved</p>
Expand Down
89 changes: 65 additions & 24 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.15.2",
"version": "3.15.4",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand All @@ -11,7 +11,7 @@
"browser": "dist/web/contentstack.js",
"react-native": "dist/react-native/contentstack.js",
"types": "./index.d.ts",
"_id": "[email protected].0",
"_id": "[email protected].4",
"scripts": {
"test": "npm run test:e2e && npm run test:typescript",
"test:e2e": "tape test/index.js | tap-html --out ./tap-html.html",
Expand Down Expand Up @@ -55,11 +55,11 @@
],
"dist": {
"shasum": "a328ed07240476a26b31a23261355dc929e1da63",
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.15.0.tgz"
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.15.4.tgz"
},
"license": "MIT",
"directories": {},
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.15.0.tgz",
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.15.4.tgz",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/contentstack-3.15.0.tgz_1477830884275_0.9869455888401717"
Expand Down Expand Up @@ -106,6 +106,6 @@
"@contentstack/utils": "^1.1.1",
"es6-promise": "^4.1.1",
"isomorphic-fetch": "^3.0.0",
"localStorage": "1.0.3"
"localStorage": "1.0.4"
}
}
8 changes: 7 additions & 1 deletion src/core/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function fetchRetry(url, headers, fetchOptions, resolve, reject, retryDelay = 30

function onError (error) {
if (retryLimit === 0) {
fetchOptions.logHandler('error', error);
reject(error);
}else {
var msDelay = retryDelay
Expand All @@ -89,23 +90,28 @@ function fetchRetry(url, headers, fetchOptions, resolve, reject, retryDelay = 30
})
}
}
fetchOptions.logHandler('info', { url: url, option: option});
fetch(url, option)
.then(function(response) {
fetchOptions.logHandler('info', response);
let data = response.json();
if (response.ok && response.status === 200) {
resolve(data);
} else {
data.then((json) => {
if (fetchOptions.retryCondition && fetchOptions.retryCondition(response)) {
onError(json)
onError(json)
} else {
fetchOptions.logHandler('error', json);
reject(json)
}
}).catch(() => {
fetchOptions.logHandler('error', {status: response.status, statusText: response.statusText});
reject({status: response.status, statusText: response.statusText})
});
}
}).catch((error) => {
fetchOptions.logHandler('error', error);
reject(error)
});
}
6 changes: 3 additions & 3 deletions src/core/modules/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class Assets {
this._query[key] = value;
return this;
} else {
console.error("Kindly provide a valid parameters.");
this.fetchOptions.logHandler('error',"Kindly provide a valid parameters.");
}
}

Expand Down Expand Up @@ -117,9 +117,9 @@ export default class Assets {
}
}
var options = Utils.mergeDeep(this.fetchOptions, fetchOptions);
return Utils.sendRequest(this, options);
return Utils.sendRequest(Utils.mergeDeep({}, this), options);
} else {
console.error("Kindly provide an asset uid. e.g. .Assets('asset_uid')");
fetchOptions.logHandler('error', "Kindly provide an asset uid. e.g. .Assets('asset_uid')");
}
}
}
14 changes: 7 additions & 7 deletions src/core/modules/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class Entry {
this.queryCachePolicy = policy;
}
} else {
console.error("Kindly provide the valid policy");
this.fetchOptions.logHandler('error', "Kindly provide the valid policy");
}
return this;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ export default class Entry {
}
return this;
} else {
console.error("Argument should be a String or an Array.");
this.fetchOptions.logHandler('error', "Argument should be a String or an Array.");
}
}

Expand All @@ -160,7 +160,7 @@ export default class Entry {
this._query['locale'] = language_code;
return this;
} else {
console.error("Argument should be a String.");
this.fetchOptions.logHandler('error', "Argument should be a String.");
}
}

Expand All @@ -179,7 +179,7 @@ export default class Entry {
this._query[key] = value;
return this;
} else {
console.error("First argument should be a String.");
this.fetchOptions.logHandler('error', "First argument should be a String.");
}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ export default class Entry {
this._query[key] = value;
return this;
} else {
console.error("Kindly provide valid parameters.");
this.fetchOptions.logHandler('error', "Kindly provide valid parameters.");
}
}

Expand Down Expand Up @@ -358,9 +358,9 @@ export default class Entry {
}
};
var options = Utils.mergeDeep(this.fetchOptions, fetchOptions);
return Utils.sendRequest(this, options);
return Utils.sendRequest(Utils.mergeDeep({}, this), options);
} else {
console.error("Kindly provide an entry uid. e.g. .Entry('asset_uid')");
this.fetchOptions.logHandler('error', "Kindly provide an entry uid. e.g. .Entry('asset_uid')");
}
}
}
Loading