contentstack
Advanced tools
Comparing version 3.13.3 to 3.14.0
## Change log | ||
### Version: 3.14.0 | ||
#### Date: Oct-19-2021 | ||
##### New Features: | ||
- Live preview feature support added | ||
@@ -3,0 +7,0 @@ ### Version: 3.13.2 |
@@ -64,10 +64,21 @@ // Type definitions for contentstack 3.12.2 | ||
export interface ContentTypeCollection{ | ||
contentTypes: Array<any> | ||
content_types: Array<any> | ||
count?: number | ||
} | ||
export interface LivePreview { | ||
host: string | ||
authorization: string | ||
enable: boolean | ||
} | ||
export interface LivePreviewQuery { | ||
hash: string | ||
content_type_uid: string | ||
} | ||
// Stack | ||
export class Stack { | ||
constructor(config: Config); | ||
constructor(api_key: string, delivery_token: string, environment_name: string, region?: Region, fetchOptions?: any); | ||
constructor(api_key: string, delivery_token: string, environment_name: string, region?: Region, fetchOptions?: any, live_preview?: LivePreview); | ||
@@ -88,2 +99,3 @@ environment: string; | ||
setCacheProvider(provider: object): Stack; | ||
livePreviewQuery(query: LivePreviewQuery): void; | ||
clearByQuery(): Stack; | ||
@@ -224,2 +236,2 @@ clearByContentType(): Stack; | ||
findOne(): Promise<any>; | ||
} | ||
} |
{ | ||
"name": "contentstack", | ||
"version": "3.13.3", | ||
"version": "3.14.0", | ||
"description": "Contentstack Javascript SDK", | ||
@@ -13,3 +13,3 @@ "homepage": "https://www.contentstack.com/", | ||
"types": "./index.d.ts", | ||
"_id": "contentstack@3.13.2", | ||
"_id": "contentstack@3.14.0", | ||
"scripts": { | ||
@@ -21,3 +21,3 @@ "test": "npm run test:e2e && npm run test:typescript", | ||
"build:node": "webpack --config webpack/webpack.node.js", | ||
"build:web": "webpack -p --config webpack/webpack.web.js", | ||
"build:web": "webpack --config webpack/webpack.web.js", | ||
"build:react-native": "webpack --config webpack/webpack.react-native.js", | ||
@@ -59,10 +59,10 @@ "build:native-script": "webpack --config webpack/webpack.nativescript.js", | ||
"shasum": "a328ed07240476a26b31a23261355dc929e1da63", | ||
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.2.tgz" | ||
"tarball": "https://registry.npmjs.org/contentstack/-/contentstack-3.14.0.tgz" | ||
}, | ||
"license": "MIT", | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.13.2.tgz", | ||
"_resolved": "https://registry.npmjs.org/contentstack/-/contentstack-3.14.0.tgz", | ||
"_npmOperationalInternal": { | ||
"host": "packages-18-east.internal.npmjs.com", | ||
"tmp": "tmp/contentstack-3.13.2.tgz_1477830884275_0.9869455888401717" | ||
"tmp": "tmp/contentstack-3.14.0.tgz_1477830884275_0.9869455888401717" | ||
}, | ||
@@ -79,2 +79,3 @@ "devDependencies": { | ||
"babel-runtime": "6.26.0", | ||
"clean-webpack-plugin": "^4.0.0", | ||
"compression-webpack-plugin": "1.0.1", | ||
@@ -85,7 +86,7 @@ "es3ify-loader": "0.2.0", | ||
"istanbul": "^0.4.5", | ||
"jest": "^26.4.2", | ||
"jest": "^27.2.5", | ||
"jest-html-reporters": "^2.1.6", | ||
"jsdoc": "^3.6.7", | ||
"jshint": "^2.13.0", | ||
"nodemailer": "^6.6.3", | ||
"jshint": "^2.13.1", | ||
"nodemailer": "^6.6.5", | ||
"request": "^2.88.2", | ||
@@ -98,6 +99,6 @@ "string-replace-loader": "1.3.0", | ||
"ts-jest": "^26.5.6", | ||
"typescript": "^4.3.5", | ||
"typescript": "^4.4.3", | ||
"uglify-js": "2.8.29", | ||
"webpack": "^5.44.0", | ||
"webpack-cli": "^3.3.12", | ||
"webpack": "^5.59.0", | ||
"webpack-cli": "^4.9.0", | ||
"webpack-md5-hash": "0.0.5", | ||
@@ -107,4 +108,4 @@ "webpack-merge": "4.1.0" | ||
"dependencies": { | ||
"@contentstack/utils": "^1.0.2", | ||
"es6-promise": "4.1.1", | ||
"@contentstack/utils": "^1.1.0", | ||
"es6-promise": "^4.1.1", | ||
"isomorphic-fetch": "^3.0.0", | ||
@@ -111,0 +112,0 @@ "localStorage": "1.0.3" |
@@ -46,7 +46,7 @@ import * as Utils from "./utils.js"; | ||
headers, | ||
fetchOptions.retryDelay, | ||
fetchOptions.retryLimit, | ||
fetchOptions, | ||
resolve, | ||
reject) | ||
reject, | ||
fetchOptions.retryDelay, | ||
fetchOptions.retryLimit) | ||
@@ -61,6 +61,4 @@ }); | ||
} | ||
async function safeParseJSON(response) { | ||
const body = await response.text(); | ||
} | ||
function fetchRetry(url, headers, retryDelay = 300, retryLimit = 5, fetchOptions, resolve, reject) { | ||
function fetchRetry(url, headers, fetchOptions, resolve, reject, retryDelay = 300, retryLimit = 5) { | ||
var option = Utils.mergeDeep({ | ||
@@ -67,0 +65,0 @@ method: 'GET', |
import Request from './request'; | ||
import Result from '../modules/result'; | ||
import config from '../../../config'; | ||
/** | ||
@@ -178,17 +178,2 @@ * @method addSpread | ||
// // spread the result object | ||
// export function spreadResult(result) { | ||
// let _results = []; | ||
// if (result && Object.keys(result).length) { | ||
// if (typeof result.entries !== 'undefined') _results.push(result.entries); | ||
// if (typeof result.assets !== 'undefined') _results.push(result.assets); | ||
// if (typeof result.content_type !== 'undefined' || typeof result.schema !== 'undefined') _results.push(result.content_type || result.schema); | ||
// if (typeof result.count !== 'undefined') _results.push(result.count); | ||
// if (typeof result.entry !== 'undefined') _results = result.entry; | ||
// if (typeof result.asset !== 'undefined') _results = result.asset; | ||
// if (typeof result.items !== 'undefined') _results.push(result); | ||
// } | ||
// return _results; | ||
// }; | ||
// spread the result object | ||
@@ -237,3 +222,2 @@ export function spreadResult(result) { | ||
let self = queryObject; | ||
let continueFlag = false; | ||
let cachePolicy = (typeof self.queryCachePolicy !== 'undefined') ? self.queryCachePolicy : self.cachePolicy; | ||
@@ -254,5 +238,20 @@ let tojson = (typeof self.tojson !== 'undefined') ? self.tojson : false; | ||
queryObject.requestParams.body = merge(queryObject.requestParams.body, cloneQueryObj); | ||
if (queryObject.live_preview && queryObject.live_preview.enable === true && queryObject.live_preview.hash && queryObject.live_preview.hash !== "init") { | ||
if(queryObject.live_preview.content_type_uid === queryObject.content_type_uid) { | ||
queryObject.requestParams.body = merge(queryObject.requestParams.body, {live_preview: queryObject.live_preview.hash || "init"}); | ||
cachePolicy = 2; // network else cache | ||
if(queryObject.requestParams.body['environment']) { | ||
delete queryObject.requestParams.body['environment']; | ||
} | ||
if(queryObject.requestParams.headers['access_token']) | ||
delete queryObject.requestParams.headers['access_token']; | ||
queryObject.requestParams.headers['authorization'] = queryObject.live_preview.management_token | ||
} else if(queryObject.live_preview.hash) { | ||
cachePolicy = 1; // cache then network | ||
} | ||
} | ||
} | ||
let getCacheCallback = function() { | ||
@@ -262,3 +261,3 @@ return function(err, entries) { | ||
try { | ||
if (err) throw err; | ||
if (err) reject(err); | ||
if (!tojson) entries = resultWrapper(entries); | ||
@@ -295,6 +294,6 @@ resolve(spreadResult(entries)); | ||
self.provider.get(hashQuery, getCacheCallback()); | ||
return | ||
} else { | ||
return reject({ error_code: 141, error_message: 'The requested entry doesn\'t exist.' }); | ||
} | ||
return; | ||
} | ||
@@ -316,3 +315,3 @@ } | ||
try { | ||
if (err) throw err; | ||
if (err) reject(err); | ||
if (!tojson) entries = resultWrapper(entries); | ||
@@ -371,3 +370,2 @@ return resolve(spreadResult(entries)); | ||
}); | ||
break; | ||
case 2: | ||
@@ -390,3 +388,2 @@ case 0: | ||
reject(err); | ||
//reject(Error("It broke")); | ||
} else { | ||
@@ -404,12 +401,11 @@ if (!tojson) _data = resultWrapper(_data); | ||
return promise.then(function() { | ||
return new Promise(function(resolve, reject) { | ||
return new Promise(function(resolve, reject) { | ||
callback(true, resolve, reject); | ||
}); | ||
}).catch((error) => { | ||
return new Promise(function(resolve, reject) { | ||
return new Promise(function(resolve, reject) { | ||
callback(true, resolve, reject); | ||
}); | ||
console.error(error) | ||
}) | ||
} | ||
}; |
import * as Utils from '../lib/utils'; | ||
import Stack from '../stack'; | ||
import Query from './query'; | ||
@@ -5,0 +3,0 @@ /** |
@@ -334,2 +334,6 @@ import * as Utils from "../lib/utils"; | ||
fetch(fetchOptions) { | ||
var host = this.config.host + ':' + this.config.port | ||
if(this.live_preview && this.live_preview.enable === true && this.live_preview.content_type_uid === this.content_type_uid ) { | ||
host = this.live_preview.host | ||
} | ||
if (this.entry_uid) { | ||
@@ -339,3 +343,3 @@ this.requestParams = { | ||
headers: this.headers, | ||
url: this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version + this.config.urls.content_types + this.content_type_uid + this.config.urls.entries + this.entry_uid, | ||
url: this.config.protocol + "://" + host + '/' + this.config.version + this.config.urls.content_types + this.content_type_uid + this.config.urls.entries + this.entry_uid, | ||
body: { | ||
@@ -342,0 +346,0 @@ _method: 'GET', |
@@ -780,4 +780,8 @@ import Request from '../lib/request'; | ||
findOne() { | ||
const host = this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version, | ||
url = (this.type && this.type === 'asset') ? host + this.config.urls.assets : host + this.config.urls.content_types + this.content_type_uid + this.config.urls.entries; | ||
let host = this.config.protocol + "://" + this.config.host + ':' + this.config.port + '/' + this.config.version | ||
if(this.type && this.type !== 'asset' && this.live_preview && this.live_preview.enable === true && this.live_preview.content_type_uid === this.content_type_uid ) { | ||
host = this.config.protocol + "://" + this.live_preview.host + '/' + this.config.version | ||
} | ||
const url = (this.type && this.type === 'asset') ? host + this.config.urls.assets : host + this.config.urls.content_types + this.content_type_uid + this.config.urls.entries; | ||
this.singleEntry = true; | ||
@@ -784,0 +788,0 @@ this._query.limit = 1; |
@@ -72,2 +72,5 @@ import config from '../../config'; | ||
this.environment = stack_arguments[0].environment; | ||
if (typeof stack_arguments[0].live_preview == "object") { | ||
this.live_preview = stack_arguments[0].live_preview | ||
} | ||
return this; | ||
@@ -200,2 +203,8 @@ } else { | ||
livePreviewQuery(query) { | ||
if (this.live_preview) { | ||
this.live_preview.hash = query.live_preview; | ||
this.live_preview.content_type_uid = query.content_type_uid; | ||
} | ||
} | ||
/** | ||
@@ -202,0 +211,0 @@ * @method setCacheProvider |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1950888
9532
33
28
43
+ Addedes6-promise@4.2.8(transitive)
- Removedes6-promise@4.1.1(transitive)
Updated@contentstack/utils@^1.1.0
Updatedes6-promise@^4.1.1