Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class Utils {
export enum Region {
US = "us",
EU = "eu",
AZURE_NA = "azure-na"
AZURE_NA = "azure-na",
AZURE_EU = "azure-eu"
}

//Enum for Contentstack CachePolicy
Expand All @@ -37,11 +38,11 @@ export enum CachePolicy {
// Sync Result
export interface SyncResult {
items: Array<any>;
paginationToken?: string;
syncToken?: string;
pagination_token?: string;
sync_token?: string;
skip: number;
limit: number;
totalCount: number;
total_count: number;
}

// Contentstack Config
Expand Down Expand Up @@ -209,6 +210,9 @@ export class Entry {
includeSchema(): this;
includeReferenceContentTypeUID(): this;
includeContentType(): this;
/**
* @deprecated since version 3.3.0
*/
includeOwner(): this;
toJSON(): this;
addParam(key: string, value: any): this;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "contentstack",
"version": "3.16.1",
"version": "3.17.0",
"description": "Contentstack Javascript SDK",
"homepage": "https://www.contentstack.com/",
"author": {
Expand Down
3 changes: 2 additions & 1 deletion src/core/contentstackregion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const ContentstackRegion = {
EU: "eu",
US: "us",
AZURE_NA: "azure-na"
AZURE_NA: "azure-na",
AZURE_EU: "azure-eu"
};

export default ContentstackRegion;
Expand Down
13 changes: 8 additions & 5 deletions src/core/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,19 @@ function fetchRetry(stack, queryParams, fetchOptions, resolve, reject, retryDela
})

} else {
const {status, statusText} = response
data.then((json) => {
const {error_message, error_code, errors} = json
const errorDetails = { error_message, error_code, errors, status, statusText }
if (fetchOptions.retryCondition && fetchOptions.retryCondition(response)) {
onError(json)
onError(errorDetails)
} else {
if (fetchOptions.debug) fetchOptions.logHandler('error', json);
reject(json)
if (fetchOptions.debug) fetchOptions.logHandler('error', errorDetails);
reject(errorDetails)
}
}).catch(() => {
if (fetchOptions.debug) fetchOptions.logHandler('error', {status: response.status, statusText: response.statusText});
reject({status: response.status, statusText: response.statusText})
if (fetchOptions.debug) fetchOptions.logHandler('error', {status, statusText});
reject({status, statusText})
});
}
}).catch((error) => {
Expand Down
30 changes: 10 additions & 20 deletions src/core/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ export function sendRequest(queryObject, options) {
if (err || !_data) {
callback(true, resolve, reject);
} else {
const originalData = JSON.parse(JSON.stringify(_data));
try {

const doesQueryRequestForReferences =
Expand Down Expand Up @@ -388,25 +387,16 @@ export function sendRequest(queryObject, options) {
}
} catch (error) {
}

await self.provider.set(
hashQuery,
originalData,
function (err) {
try {

if (err) reject(err);
if (!tojson)
_data =
resultWrapper(_data);
return resolve(
spreadResult(_data)
);
} catch (e) {
return reject(e);
}
}
);
try {
if (!tojson)
_data =
resultWrapper(_data);
return resolve(
spreadResult(_data)
);
} catch (e) {
return reject(e);
}
}
} catch (e) {
return reject(e);
Expand Down
17 changes: 14 additions & 3 deletions src/core/modules/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,28 @@ export default class Assets {

/**
* @method includeFallback
* @memberOf Entry
* @memberOf Asset
* @description Include the fallback locale publish content, if specified locale content is not publish.
* @example stack.ContentType(contentType_uid).Entry(entry_uid).includeFallback().fetch()
* @example stack.ContentType(contentType_uid).Assets(assetUid).includeFallback().fetch()
* @returns {Asset}
* @instance
*/
includeFallback() {
this._query['include_fallback'] = true;
return this;
}

/**
* @method includeMetadata
* @memberOf Asset
* @description Include the metadata for getting metadata content for the asset.
* @example stack.ContentType(contentType_uid).Assets(assetUid).includeMetadata().fetch()
* @returns {Asset}
* @instance
*/
includeMetadata() {
this._query['include_metadata'] = true;
return this;
}
/**
* Fetches a particular asset based on the provided asset UID.
* @memberOf Assets
Expand Down
13 changes: 13 additions & 0 deletions src/core/modules/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ export default class Entry {
this._query['include_branch'] = true;
return this;
}

/**
* @method includeMetadata
* @memberOf Entry
* @description Include the metadata for getting metadata content for the entry.
* @example stack.ContentType(contentType_uid).Entry(entry_uid).includeMetadata().fetch()
* @returns {Entry}
* @instance
*/
includeMetadata() {
this._query['include_metadata'] = true;
return this;
}

/**
* @method includeContentType
Expand Down