Skip to content

Commit

Permalink
Merge pull request #1926 from contentful/feat/support-delivery-proxy
Browse files Browse the repository at this point in the history
feat: support all sdk config options when using CDA
  • Loading branch information
t-col authored Dec 2, 2024
2 parents 58679dc + cebd5d0 commit aeb4e03
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/parseOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function parseOptions (params) {
}

const configFile = params.config
// eslint-disable-next-line @typescript-eslint/no-require-imports
? require(resolve(process.cwd(), params.config))
: {}

Expand Down
3 changes: 2 additions & 1 deletion lib/tasks/init-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ export default function initClient (opts, useCda = false) {
}
if (useCda) {
const cdaConfig = {
...config,
space: config.spaceId,
accessToken: config.deliveryToken,
environment: config.environmentId,
host: config.hostDelivery,
host: config.hostDelivery
}
return createCdaClient(cdaConfig).withoutLinkResolution
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build:watch": "babel lib --out-dir dist --watch",
"clean": "rimraf dist && rimraf coverage",
"lint": "eslint lib bin/* types.d.ts",
"lint:fix": "npm run lint -- --fix",
"pretest": "npm run lint && npm run build && rimraf ./test/integration/tmp",
"test": "npm run test:unit && npm run test:integration",
"test:unit": "jest --testPathPattern=test/unit --coverage",
Expand Down
12 changes: 11 additions & 1 deletion test/unit/tasks/init-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ test('does create both clients when deliveryToken is set', () => {
proxy: 'proxy',
accessToken: 'accessToken',
spaceId: 'spaceId',
deliveryToken: 'deliveryToken'
deliveryToken: 'deliveryToken',
hostDelivery: 'hostDelivery'
}

initClient(opts, true)
Expand All @@ -98,6 +99,15 @@ test('does create both clients when deliveryToken is set', () => {
expect(contentful.createClient.mock.calls[0][0]).toMatchObject({
space: opts.spaceId,
accessToken: opts.deliveryToken,
host: opts.hostDelivery,
port: opts.port,
headers: opts.headers,
insecure: opts.insecure,
proxy: opts.proxy,
httpAgent: opts.httpAgent,
httpsAgent: opts.httpsAgent,
application: opts.application,
integration: opts.integration
})
expect(contentfulManagement.createClient.mock.calls).toHaveLength(1)
expect(contentful.createClient.mock.calls).toHaveLength(1)
Expand Down

0 comments on commit aeb4e03

Please sign in to comment.