Skip to content

Commit

Permalink
Merge branch 'next' into next-feature-update
Browse files Browse the repository at this point in the history
  • Loading branch information
sunil-lakshman authored Jul 23, 2024
2 parents 5d4669c + 8b75387 commit 91af5fe
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
uses: atlassian/gajira-transition@v3
with:
issue: ${{ steps.create.outputs.issue }}
transition: ${{ secrets.JIRA_TRANSITION }}
transition: ${{ secrets.JIRA_TRANSITION }}
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.PAT_TOKEN }}
11 changes: 11 additions & 0 deletions .github/workflows/sast-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: SAST Scan
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
security-sast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Semgrep Scan
run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto
4 changes: 4 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fileignoreconfig:
- filename: package-lock.json
checksum: f3c78348e6bb5b0d9521aed5fab5eeff46ccc3b0d2a4c5e3b272c4b23cfa891b
checksum: 28f8e6d0e7856b4a568fd260dcc4deb531bcdbebbbff956b008ce7dd26a0475d
- filename: test/typescript/taxonomy.test.ts
checksum: e4bdf633e147fd60d929d379f20c814eed5f68b11421d7b53ec8826e9142de37
- filename: src/core/modules/taxonomy.js
Expand All @@ -11,4 +12,7 @@ fileignoreconfig:
checksum: c88b336f9a271397ffedcf8c5085941ceb0bd1cd7e25ed9ada3acd8ce4f8970c
- filename: test/typescript/stack.test.ts
checksum: f90544059eacaf20571f59bac90acd4e4c2178601a6f00ede49816a4621aefa8
checksum: bbb3c425f8e1a63d4793f69ee9eaba9559294ff53f163a28f70ae54b1792276a
- filename: src/core/contentstack.js
checksum: 90a3b07300155a34f67dc3df87363107eec202123a21bc0cefda324e477a676d
version: ""
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
## Change log

### Version: 3.20.0

#### Date: March-12-2024
##### New Features:
- Variants Feature support added


#### Date: May-31-2024
##### Enhanncement:
- Adds Timeline Preview changes

### Version: 3.20.1
#### Date: July-09-2024
##### Fix:
- Type support for LivePreviewQuery method params

### Version: 3.19.3
#### Date: May-17-2024
##### Enhanncement:
- Update Asset URL method added

### Version: 3.19.2
#### Date: April-17-2024
##### Dependency:
Expand Down
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export interface LivePreviewConfigWithPreviewToken {
export interface LivePreviewQuery {
live_preview: string
content_type_uid: string
preview_timestamp: string
release_id: string
}

export interface RetryDelayOption {
Expand Down Expand Up @@ -170,6 +172,7 @@ export function Stack(config: Config): Stack;
*/
export function Stack(api_key: string, access_token: string, environment_name: string, region?: string, fetchOptions?: FetchOptions): Stack;

export function updateAssetURL(entry: object): object;
export class ContentType {
constructor();
content_type_uid: string
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.20.0",
"version": "4.0.0",
"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": "contentstack@3.16.1",
"_id": "contentstack@3.19.3",
"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 @@ -99,7 +99,7 @@
"webpack-node-externals": "^3.0.0"
},
"dependencies": {
"@contentstack/utils": "^1.3.3",
"@contentstack/utils": "^1.3.8",
"cheerio": "^1.0.0-rc.12",
"es6-promise": "^4.1.1",
"isomorphic-fetch": "^3.0.0",
Expand Down
32 changes: 29 additions & 3 deletions src/core/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,39 @@ class Contentstack {

this.Utils = require('@contentstack/utils');
}
/**

* @memberOf Contentstack
*/
/**
* @memberOf Contentstack
*/
Stack(...stack_arguments){
return new Stack(...stack_arguments);
}

updateAssetURL(entry) {
// check if entry consist of _embedded_items object
if (entry._embedded_items == undefined) {
throw new Error("_embedded_items not present in entry. Call includeEmbeddedItems() before fetching entry.");
}

// Iterate through each object in _embedded_items and update the asset link
for (let key in entry._embedded_items) {
let embedded_item = entry._embedded_items[key];
if (Array.isArray(embedded_item)) {

embedded_item.forEach((item) => {

if (item._content_type_uid == 'sys_assets' && item.filename) {

const correspondingAsset = entry[key].children.find(child => child.attrs['asset-uid'] === item.uid);
if (correspondingAsset) {
correspondingAsset.attrs['asset-link'] = item.url;
}
}
});
}
}
}
}

module.exports = new Contentstack();
2 changes: 1 addition & 1 deletion src/core/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function merge(target, source) {

// return true if process is running in browser else false
export function isBrowser() {
return (typeof window !== "undefined" && typeof process === "object" && process.title === "browser");
return (typeof window !== "undefined");
}


Expand Down
24 changes: 24 additions & 0 deletions src/core/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default class Stack {
};
if (typeof stack_arguments[0].live_preview == "object") {
this.live_preview = Utils.mergeDeep(this.config.live_preview , stack_arguments[0].live_preview)
this.setLivePreviewTimelinePreviewForClient()
}
if (typeof stack_arguments[0].branch === "string" && stack_arguments[0].branch !== undefined) {
this.headers.branch = stack_arguments[0].branch
Expand Down Expand Up @@ -276,12 +277,35 @@ export default class Stack {
}


setLivePreviewTimelinePreviewForClient() {
if (Utils.isBrowser()){
const params = new URL(document.location.toString()).searchParams;
if (params.has('live_preview')) {
this.live_preview.live_preview = params.get('live_preview');
}
if (params.has('release_id')) {
this.headers['release_id'] = params.get('release_id');
}
if (params.has('preview_timestamp')) {
this.headers['preview_timestamp'] = params.get('preview_timestamp');
}
}
}


livePreviewQuery(query) {
if (this.live_preview) {
this.live_preview.live_preview = query.live_preview || 'init';
this.live_preview.content_type_uid = query.content_type_uid;
this.live_preview.entry_uid = query.entry_uid
}

if (query.hasOwnProperty('release_id')) {
this.headers['release_id'] = query.release_id;
}
if (query.hasOwnProperty('preview_timestamp')) {
this.headers['preview_timestamp'] = query.preview_timestamp;
}
}

/**
Expand Down

0 comments on commit 91af5fe

Please sign in to comment.