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
27 changes: 2 additions & 25 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
fileignoreconfig:
- filename: .github/workflows/secrets-scan.yml
ignore_detectors:
- filecontent
- filename: package-lock.json
checksum: 9d0340f9359927d477fe8ab4650642c068c592be63fb817651d866849e0dbbc2
- filename: .husky/pre-commit
checksum: 5baabd7d2c391648163f9371f0e5e9484f8fb90fa2284cfc378732ec3192c193
- filename: test/sanity-check/api/user-test.js
checksum: c82c76ef1a4d175044b9a30a82ed20f004320ec297ea37f27fdbd5c3fec9ff34
version: ""
fileignoreconfig:
- filename: test/unit/globalField-test.js
checksum: 25185e3400a12e10a043dc47502d8f30b7e1c4f2b6b4d3b8b55cdc19850c48bf
version: "1.0"
fileignoreconfig:
- filename: lib/stack/index.js
checksum: 6aab5edf85efb17951418b4dc4402889cd24c8d786c671185074aeb4d50f0242
- filename: test/sanity-check/api/stack-test.js
checksum: 198d5cf7ead33b079249dc3ecdee61a9c57453e93f1073ed0341400983e5aa53
version: "1.0"
fileignoreconfig:
- filename: test/sanity-check/api/previewToken-test.js
checksum: 9a42e079b7c71f76932896a0d2390d86ac626678ab20d36821dcf962820a886c
- filename: lib/stack/deliveryToken/index.js
checksum: 51ae00f07f4cc75c1cd832b311c2e2482f04a8467a0139da6013ceb88fbdda2f
- filename: lib/stack/deliveryToken/previewToken/index.js
checksum: b506f33bffdd20dfc701f964370707f5d7b28a2c05c70665f0edb7b3c53c165b
version: "1.0"
105 changes: 53 additions & 52 deletions lib/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import contentstackClient from './contentstackClient.js'
import httpClient from './core/contentstackHTTPClient.js'
const regionHostMap = {
NA: 'api.contentstack.io',
EU: 'eu-api.contentstack.com',
AZURE_NA: 'azure-na-api.contentstack.com',
AZURE_EU: 'azure-eu-api.contentstack.com',
GCP_NA: 'gcp-na-api.contentstack.com',
GCP_EU: 'gcp-eu-api.contentstack.com'
NA: 'api.contentstack.io',

Check failure on line 11 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
EU: 'eu-api.contentstack.com',

Check failure on line 12 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
AU: 'au-api.contentstack.com',

Check failure on line 13 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
AZURE_NA: 'azure-na-api.contentstack.com',

Check failure on line 14 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
AZURE_EU: 'azure-eu-api.contentstack.com',

Check failure on line 15 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
GCP_NA: 'gcp-na-api.contentstack.com',

Check failure on line 16 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
GCP_EU: 'gcp-eu-api.contentstack.com'

Check failure on line 17 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
}

/**
Expand Down Expand Up @@ -168,56 +169,56 @@
* @prop {string=} params.integration - Integration name and version e.g react/version
* @returns Contentstack.Client
*/
export function client (params = {}) {
let defaultHostName
export function client(params = {}) {

Check failure on line 172 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Missing space before function parentheses
let defaultHostName

Check failure on line 173 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4

if (params.region) {
const region = params.region.toUpperCase()
if (!regionHostMap[region]) {
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
if (params.region) {

Check failure on line 175 in lib/contentstack.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 2 spaces but found 4
const region = params.region.toUpperCase()
if (!regionHostMap[region]) {
throw new Error(`Invalid region '${params.region}' provided. Allowed regions are: ${Object.keys(regionHostMap).join(', ')}`)
}
defaultHostName = regionHostMap[region]
} else if (params.host) {
defaultHostName = params.host
} else {
defaultHostName = regionHostMap['NA']
}
defaultHostName = regionHostMap[region]
} else if (params.host) {
defaultHostName = params.host
} else {
defaultHostName = regionHostMap['NA']
}

const defaultParameter = {
defaultHostName: defaultHostName
}
const defaultParameter = {
defaultHostName: defaultHostName
}

const sdkAgent = `contentstack-management-javascript/${packages.version}`
const userAgentHeader = getUserAgent(sdkAgent,
params.application,
params.integration,
params.feature
)
const requiredHeaders = {
'X-User-Agent': sdkAgent,
'User-Agent': userAgentHeader
}
const sdkAgent = `contentstack-management-javascript/${packages.version}`
const userAgentHeader = getUserAgent(sdkAgent,
params.application,
params.integration,
params.feature
)
const requiredHeaders = {
'X-User-Agent': sdkAgent,
'User-Agent': userAgentHeader
}

if (params.authtoken) {
requiredHeaders.authtoken = params.authtoken
}
if (params.authorization) {
requiredHeaders.authorization = params.authorization
}
if (params.early_access) {
requiredHeaders.early_access = params.early_access.join(',')
}
params = {
...defaultParameter,
...clonedeep(params)
}
if (params.authtoken) {
requiredHeaders.authtoken = params.authtoken
}
if (params.authorization) {
requiredHeaders.authorization = params.authorization
}
if (params.early_access) {
requiredHeaders.early_access = params.early_access.join(',')
}
params = {
...defaultParameter,
...clonedeep(params)
}

params.headers = {
...params.headers,
...requiredHeaders
}
const http = httpClient(params)
return contentstackClient({
http: http
})
params.headers = {
...params.headers,
...requiredHeaders
}
const http = httpClient(params)
return contentstackClient({
http: http
})
}
4 changes: 2 additions & 2 deletions 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/management",
"version": "1.21.7",
"version": "1.22.0",
"description": "The Content Management API is used to manage the content of your Contentstack account",
"main": "./dist/node/contentstack-management.js",
"browser": "./dist/web/contentstack-management.js",
Expand Down
Loading
Loading