Skip to content

Commit c0c965b

Browse files
authored
Merge pull request #93 from contentstack/fix/CS-36608-cache-issue
fix: 🐛 cache issue
2 parents e1e57f9 + 90f66cf commit c0c965b

8 files changed

+128
-116
lines changed

index.d.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export class Utils {
2222
export enum Region {
2323
US = "us",
2424
EU = "eu",
25-
AZURE_NA = "azure-na"
25+
AZURE_NA = "azure-na",
26+
AZURE_EU = "azure-eu"
2627
}
2728

2829
//Enum for Contentstack CachePolicy
@@ -37,11 +38,11 @@ export enum CachePolicy {
3738
// Sync Result
3839
export interface SyncResult {
3940
items: Array<any>;
40-
paginationToken?: string;
41-
syncToken?: string;
41+
pagination_token?: string;
42+
sync_token?: string;
4243
skip: number;
4344
limit: number;
44-
totalCount: number;
45+
total_count: number;
4546
}
4647

4748
// Contentstack Config
@@ -209,6 +210,9 @@ export class Entry {
209210
includeSchema(): this;
210211
includeReferenceContentTypeUID(): this;
211212
includeContentType(): this;
213+
/**
214+
* @deprecated since version 3.3.0
215+
*/
212216
includeOwner(): this;
213217
toJSON(): this;
214218
addParam(key: string, value: any): this;

package-lock.json

+68-78
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contentstack",
3-
"version": "3.16.1",
3+
"version": "3.17.0",
44
"description": "Contentstack Javascript SDK",
55
"homepage": "https://www.contentstack.com/",
66
"author": {
@@ -90,14 +90,14 @@
9090
"request": "^2.88.2",
9191
"string-replace-loader": "1.3.0",
9292
"tap": "^16.3.4",
93-
"tap-html": "^1.0.1",
93+
"tap-html": "^1.1.0",
9494
"tap-json": "1.0.0",
9595
"tape": "4.8.0",
96-
"terser-webpack-plugin": "^5.3.6",
96+
"terser-webpack-plugin": "^5.3.7",
9797
"ts-jest": "^27.1.5",
9898
"typescript": "^4.9.5",
9999
"uglify-js": "2.8.29",
100-
"webpack": "^5.75.0",
100+
"webpack": "^5.76.3",
101101
"webpack-cli": "^4.10.0",
102102
"webpack-md5-hash": "0.0.5",
103103
"webpack-merge": "4.1.0",
@@ -108,6 +108,6 @@
108108
"es6-promise": "^4.1.1",
109109
"isomorphic-fetch": "^3.0.0",
110110
"localStorage": "1.0.4",
111-
"qs": "^6.11.0"
111+
"qs": "^6.11.1"
112112
}
113113
}

src/core/contentstackregion.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const ContentstackRegion = {
22
EU: "eu",
33
US: "us",
4-
AZURE_NA: "azure-na"
4+
AZURE_NA: "azure-na",
5+
AZURE_EU: "azure-eu"
56
};
67

78
export default ContentstackRegion;

src/core/lib/request.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,19 @@ function fetchRetry(stack, queryParams, fetchOptions, resolve, reject, retryDela
124124
})
125125

126126
} else {
127+
const {status, statusText} = response
127128
data.then((json) => {
129+
const {error_message, error_code, errors} = json
130+
const errorDetails = { error_message, error_code, errors, status, statusText }
128131
if (fetchOptions.retryCondition && fetchOptions.retryCondition(response)) {
129-
onError(json)
132+
onError(errorDetails)
130133
} else {
131-
if (fetchOptions.debug) fetchOptions.logHandler('error', json);
132-
reject(json)
134+
if (fetchOptions.debug) fetchOptions.logHandler('error', errorDetails);
135+
reject(errorDetails)
133136
}
134137
}).catch(() => {
135-
if (fetchOptions.debug) fetchOptions.logHandler('error', {status: response.status, statusText: response.statusText});
136-
reject({status: response.status, statusText: response.statusText})
138+
if (fetchOptions.debug) fetchOptions.logHandler('error', {status, statusText});
139+
reject({status, statusText})
137140
});
138141
}
139142
}).catch((error) => {

src/core/lib/utils.js

+10-20
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ export function sendRequest(queryObject, options) {
347347
if (err || !_data) {
348348
callback(true, resolve, reject);
349349
} else {
350-
const originalData = JSON.parse(JSON.stringify(_data));
351350
try {
352351

353352
const doesQueryRequestForReferences =
@@ -388,25 +387,16 @@ export function sendRequest(queryObject, options) {
388387
}
389388
} catch (error) {
390389
}
391-
392-
await self.provider.set(
393-
hashQuery,
394-
originalData,
395-
function (err) {
396-
try {
397-
398-
if (err) reject(err);
399-
if (!tojson)
400-
_data =
401-
resultWrapper(_data);
402-
return resolve(
403-
spreadResult(_data)
404-
);
405-
} catch (e) {
406-
return reject(e);
407-
}
408-
}
409-
);
390+
try {
391+
if (!tojson)
392+
_data =
393+
resultWrapper(_data);
394+
return resolve(
395+
spreadResult(_data)
396+
);
397+
} catch (e) {
398+
return reject(e);
399+
}
410400
}
411401
} catch (e) {
412402
return reject(e);

0 commit comments

Comments
 (0)