Skip to content

Commit 8b72afa

Browse files
committed
Added AWS-AU support
1 parent 8259836 commit 8b72afa

File tree

6 files changed

+286
-300
lines changed

6 files changed

+286
-300
lines changed

.talismanrc

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
11
fileignoreconfig:
2-
- filename: .github/workflows/secrets-scan.yml
3-
ignore_detectors:
4-
- filecontent
5-
- filename: package-lock.json
6-
checksum: 9d0340f9359927d477fe8ab4650642c068c592be63fb817651d866849e0dbbc2
7-
- filename: .husky/pre-commit
8-
checksum: 5baabd7d2c391648163f9371f0e5e9484f8fb90fa2284cfc378732ec3192c193
2+
- filename: test/sanity-check/api/user-test.js
3+
checksum: c82c76ef1a4d175044b9a30a82ed20f004320ec297ea37f27fdbd5c3fec9ff34
94
version: ""
10-
fileignoreconfig:
11-
- filename: test/unit/globalField-test.js
12-
checksum: 25185e3400a12e10a043dc47502d8f30b7e1c4f2b6b4d3b8b55cdc19850c48bf
13-
version: "1.0"
14-
fileignoreconfig:
15-
- filename: lib/stack/index.js
16-
checksum: 6aab5edf85efb17951418b4dc4402889cd24c8d786c671185074aeb4d50f0242
17-
- filename: test/sanity-check/api/stack-test.js
18-
checksum: 198d5cf7ead33b079249dc3ecdee61a9c57453e93f1073ed0341400983e5aa53
19-
version: "1.0"
20-
fileignoreconfig:
21-
- filename: test/sanity-check/api/previewToken-test.js
22-
checksum: 9a42e079b7c71f76932896a0d2390d86ac626678ab20d36821dcf962820a886c
23-
- filename: lib/stack/deliveryToken/index.js
24-
checksum: 51ae00f07f4cc75c1cd832b311c2e2482f04a8467a0139da6013ceb88fbdda2f
25-
- filename: lib/stack/deliveryToken/previewToken/index.js
26-
checksum: b506f33bffdd20dfc701f964370707f5d7b28a2c05c70665f0edb7b3c53c165b
27-
version: "1.0"

lib/contentstack.js

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import getUserAgent from './core/Util.js'
88
import contentstackClient from './contentstackClient.js'
99
import httpClient from './core/contentstackHTTPClient.js'
1010
const regionHostMap = {
11-
NA: 'api.contentstack.io',
12-
EU: 'eu-api.contentstack.com',
13-
AZURE_NA: 'azure-na-api.contentstack.com',
14-
AZURE_EU: 'azure-eu-api.contentstack.com',
15-
GCP_NA: 'gcp-na-api.contentstack.com',
16-
GCP_EU: 'gcp-eu-api.contentstack.com'
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'
1718
}
1819

1920
/**
@@ -168,56 +169,56 @@ const regionHostMap = {
168169
* @prop {string=} params.integration - Integration name and version e.g react/version
169170
* @returns Contentstack.Client
170171
*/
171-
export function client (params = {}) {
172-
let defaultHostName
172+
export function client(params = {}) {
173+
let defaultHostName
173174

174-
if (params.region) {
175-
const region = params.region.toUpperCase()
176-
if (!regionHostMap[region]) {
177-
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
175+
if (params.region) {
176+
const region = params.region.toUpperCase()
177+
if (!regionHostMap[region]) {
178+
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
179+
}
180+
defaultHostName = regionHostMap[region]
181+
} else if (params.host) {
182+
defaultHostName = params.host
183+
} else {
184+
defaultHostName = regionHostMap['NA']
178185
}
179-
defaultHostName = regionHostMap[region]
180-
} else if (params.host) {
181-
defaultHostName = params.host
182-
} else {
183-
defaultHostName = regionHostMap['NA']
184-
}
185186

186-
const defaultParameter = {
187-
defaultHostName: defaultHostName
188-
}
187+
const defaultParameter = {
188+
defaultHostName: defaultHostName
189+
}
189190

190-
const sdkAgent = `contentstack-management-javascript/${packages.version}`
191-
const userAgentHeader = getUserAgent(sdkAgent,
192-
params.application,
193-
params.integration,
194-
params.feature
195-
)
196-
const requiredHeaders = {
197-
'X-User-Agent': sdkAgent,
198-
'User-Agent': userAgentHeader
199-
}
191+
const sdkAgent = `contentstack-management-javascript/${packages.version}`
192+
const userAgentHeader = getUserAgent(sdkAgent,
193+
params.application,
194+
params.integration,
195+
params.feature
196+
)
197+
const requiredHeaders = {
198+
'X-User-Agent': sdkAgent,
199+
'User-Agent': userAgentHeader
200+
}
200201

201-
if (params.authtoken) {
202-
requiredHeaders.authtoken = params.authtoken
203-
}
204-
if (params.authorization) {
205-
requiredHeaders.authorization = params.authorization
206-
}
207-
if (params.early_access) {
208-
requiredHeaders.early_access = params.early_access.join(',')
209-
}
210-
params = {
211-
...defaultParameter,
212-
...clonedeep(params)
213-
}
202+
if (params.authtoken) {
203+
requiredHeaders.authtoken = params.authtoken
204+
}
205+
if (params.authorization) {
206+
requiredHeaders.authorization = params.authorization
207+
}
208+
if (params.early_access) {
209+
requiredHeaders.early_access = params.early_access.join(',')
210+
}
211+
params = {
212+
...defaultParameter,
213+
...clonedeep(params)
214+
}
214215

215-
params.headers = {
216-
...params.headers,
217-
...requiredHeaders
218-
}
219-
const http = httpClient(params)
220-
return contentstackClient({
221-
http: http
222-
})
216+
params.headers = {
217+
...params.headers,
218+
...requiredHeaders
219+
}
220+
const http = httpClient(params)
221+
return contentstackClient({
222+
http: http
223+
})
223224
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/management",
3-
"version": "1.21.7",
3+
"version": "1.22.0",
44
"description": "The Content Management API is used to manage the content of your Contentstack account",
55
"main": "./dist/node/contentstack-management.js",
66
"browser": "./dist/web/contentstack-management.js",

0 commit comments

Comments
 (0)