Skip to content

Commit 2922d2f

Browse files
Merge pull request #469 from contentstack/staging
DX | 15-12-2025 | Release
2 parents 7ef6c45 + 97343d3 commit 2922d2f

File tree

8 files changed

+278
-311
lines changed

8 files changed

+278
-311
lines changed

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fileignoreconfig:
99
ignore_detectors:
1010
- filecontent
1111
- filename: package-lock.json
12-
checksum: 1475ee2c6a615f4e6f8393f4a209398aa6b827e7d036302c6fc065d5914e8292
12+
checksum: 424e5c45fa8043c95e0da5b215279c41cbe85230f75262ec7ac9ba01520e8821
1313
- filename: .husky/pre-commit
1414
checksum: 52a664f536cf5d1be0bea19cb6031ca6e8107b45b6314fe7d47b7fad7d800632
1515
- filename: test/sanity-check/api/user-test.js

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v1.27.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.27.0) (2025-12-15)
4+
- Enhancement
5+
- Refactored region endpoint resolution to use centralized `@contentstack/utils` package
6+
- Improved region handling flexibility by leveraging shared utility functions
7+
38
## [v1.26.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.26.0) (2025-10-20)
49
- Enhancement
510
- Added taxonomy localization support

lib/contentstack.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@ import clonedeep from 'lodash/cloneDeep'
77
import getUserAgent from './core/Util.js'
88
import contentstackClient from './contentstackClient.js'
99
import httpClient from './core/contentstackHTTPClient.js'
10-
const regionHostMap = {
11-
NA: 'api.contentstack.io',
12-
EU: 'eu-api.contentstack.com',
13-
AU: 'au-api.contentstack.com',
14-
AZURE_NA: 'azure-na-api.contentstack.com',
15-
AZURE_EU: 'azure-eu-api.contentstack.com',
16-
GCP_NA: 'gcp-na-api.contentstack.com',
17-
GCP_EU: 'gcp-eu-api.contentstack.com'
18-
}
10+
import { getContentstackEndpoint } from '@contentstack/utils'
1911

2012
/**
2113
* Create client instance
@@ -179,18 +171,12 @@ const regionHostMap = {
179171
* @returns {ContentstackClient} Instance of ContentstackClient
180172
*/
181173
export function client (params = {}) {
182-
let defaultHostName
174+
let defaultHostName = params.region
175+
? getContentstackEndpoint(params.region.toUpperCase(), 'contentManagement', true)
176+
: getContentstackEndpoint('NA', 'contentManagement', true)
183177

184-
if (params.region) {
185-
const region = params.region.toUpperCase()
186-
if (!regionHostMap[region]) {
187-
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
188-
}
189-
defaultHostName = regionHostMap[region]
190-
} else if (params.host) {
178+
if (params.host) {
191179
defaultHostName = params.host
192-
} else {
193-
defaultHostName = regionHostMap['NA']
194180
}
195181

196182
const defaultParameter = {

0 commit comments

Comments
 (0)