Skip to content

Commit a2c80b3

Browse files
committed
fix: 🐛 Org stack and Entry issue
Fetch Stack for specific Org and Update entry on query find
1 parent f4aafa6 commit a2c80b3

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

lib/contentstack.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import httpClient from './core/contentstackHTTPClient.js'
4444
* import * as contentstack from '@contentstack/management'
4545
* const client = contentstack.client({ maxRequests: 5 })
4646
*
47-
* @prop {boolean=} params.retryOnError - Optional boolean for retry on failuer. Default is true
47+
* @prop {boolean=} params.retryOnError - Optional boolean for retry on failure. Default is true
4848
* @example //Set the `retryOnError` to false
4949
* import * as contentstack from '@contentstack/management'
5050
* const client = contentstack.client({ retryOnError: false })
@@ -54,7 +54,7 @@ import httpClient from './core/contentstackHTTPClient.js'
5454
* import * as contentstack from '@contentstack/management'
5555
* const client = contentstack.client({ retryLimit: 2 })
5656
*
57-
* @prop {number=} params.retryDelay - The number of miliseconds to use for operation retries. Default is 300ms
57+
* @prop {number=} params.retryDelay - The number of milliseconds to use for operation retries. Default is 300ms
5858
* @example //Set the `retryDelay` to 500ms
5959
* import * as contentstack from '@contentstack/management'
6060
* const client = contentstack.client({ retryDelay: 500 })
@@ -93,7 +93,7 @@ import httpClient from './core/contentstackHTTPClient.js'
9393
* const client = contentstack.client({ maxContentLength: 1024 ** 3 })
9494
*
9595
* @prop {number=} params.maxBodyLength - Optional maximum body length in bytes (default: 10 MB)
96-
* @example //Set the `maxContentLength` to 1024 ** 2 * 10 // 10 MB
96+
* @example //Set the `maxBodyLength` to 1024 ** 2 * 10 // 10 MB
9797
* import * as contentstack from '@contentstack/management'
9898
* const client = contentstack.client({ maxBodyLength: 1024 ** 2 * 10 })
9999
*

lib/entity.js

+7
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ export const exportObject = ({ http }) => {
119119
export const query = ({ http, wrapperCollection }) => {
120120
return function (params = {}) {
121121
if (this.organization_uid) {
122+
if (!params.query) {
123+
params.query = {}
124+
}
122125
params.query['org_uid'] = this.organization_uid
123126
}
127+
128+
if (this.content_type_uid) {
129+
params.content_type_uid = this.content_type_uid
130+
}
124131
return Query(http, this.urlPath, params, this.stackHeaders, wrapperCollection)
125132
}
126133
}

lib/query/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe
77
if (stackHeaders) {
88
headers.headers = stackHeaders
99
}
10+
var contentTypeUid = null
1011
if (param) {
12+
if (param.content_type_uid) {
13+
contentTypeUid = param.content_type_uid
14+
delete param.content_type_uid
15+
}
1116
headers.params = {
1217
...cloneDeep(param)
1318
}
@@ -34,6 +39,9 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe
3439
try {
3540
const response = await http.get(urlPath, headers)
3641
if (response.data) {
42+
if (contentTypeUid) {
43+
response.data.content_type_uid = contentTypeUid
44+
}
3745
return new ContentstackCollection(response, http, stackHeaders, wrapperCollection)
3846
} else {
3947
throw error(response)
@@ -100,6 +108,9 @@ export default function Query (http, urlPath, param, stackHeaders = null, wrappe
100108
try {
101109
const response = await http.get(urlPath, limitHeader)
102110
if (response.data) {
111+
if (contentTypeUid) {
112+
response.data.content_type_uid = contentTypeUid
113+
}
103114
return new ContentstackCollection(response, http, stackHeaders, wrapperCollection)
104115
} else {
105116
throw error(response)

0 commit comments

Comments
 (0)