Skip to content

Commit

Permalink
Merge branch 'main' into sdk-update
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Dec 13, 2023
2 parents 3ae4b0c + f0b5ef2 commit 83b5370
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [5.23.3](https://github.com/commercelayer/commercelayer-sdk/compare/v5.23.2...v5.23.3) (2023-12-13)


### Bug Fixes

* remove default custom user agent ([750f695](https://github.com/commercelayer/commercelayer-sdk/commit/750f695dc7ec29b9a696a47b39f29bf7df31a1e4))

## [5.23.2](https://github.com/commercelayer/commercelayer-sdk/compare/v5.23.1...v5.23.2) (2023-11-30)


### Bug Fixes

* resource list can be sorted ([702fefa](https://github.com/commercelayer/commercelayer-sdk/commit/702fefa041fbf14b904348cddcea61ab3c8667e3))

## [5.23.1](https://github.com/commercelayer/commercelayer-sdk/compare/v5.23.0...v5.23.1) (2023-11-30)


### Bug Fixes

* update resources to schema v4.21.0 ([5f63700](https://github.com/commercelayer/commercelayer-sdk/commit/5f63700393efcf2d2e7f2457dc897d658a4d9665))

# [5.23.0](https://github.com/commercelayer/commercelayer-sdk/compare/v5.22.1...v5.23.0) (2023-11-29)


Expand Down
1 change: 0 additions & 1 deletion gen/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ type Resource = {
operations: OperationMap
}


type ResourceMap = {
[resource: string]: Resource
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@commercelayer/sdk",
"version": "5.23.0",
"version": "5.23.3",
"main": "lib/cjs/index.js",
"types": "lib/cjs/index.d.ts",
"module": "lib/esm/index.js",
Expand Down
24 changes: 14 additions & 10 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,25 @@ class ApiClient {
// Set custom headers
const customHeaders = this.customHeaders(options.headers)

// Set headers
const headers: any = {
...customHeaders,
'Accept': 'application/vnd.api+json',
'Content-Type': 'application/vnd.api+json',
'Authorization': 'Bearer ' + this.#accessToken
}

// Set User-Agent
// const userAgentData = packageInfo(['version', 'dependencies.axios'], { nestedName: true })
let userAgent = options.userAgent || `SDK-core axios/${axios.VERSION}`
if (!userAgent.includes('axios/')) userAgent += ` axios/${axios.VERSION}`
let userAgent = options.userAgent // || `SDK-core axios/${axios.VERSION}`
if (userAgent) {
if (!userAgent.includes('axios/')) userAgent += ` axios/${axios.VERSION}`
headers['User-Agent'] = userAgent
}

const axiosOptions: CreateAxiosDefaults = {
baseURL: this.baseUrl,
timeout: config.client.timeout,
headers: {
...customHeaders,
'Accept': 'application/vnd.api+json',
'Content-Type': 'application/vnd.api+json',
'Authorization': 'Bearer ' + this.#accessToken,
'User-Agent': userAgent
},
headers,
...axiosConfig
}

Expand Down
4 changes: 2 additions & 2 deletions src/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { CommerceLayerClient, CommerceLayerInitConfig } from './commercelay
/* Static functions */
export const CommerceLayerStatic = {

resources: (): readonly string[] => {
return api.resourceList
resources: (sort?: boolean): readonly string[] => {
return sort? [ ...api.resourceList ].sort() : api.resourceList
},

isSdkError: (error: unknown): error is SdkError => {
Expand Down

0 comments on commit 83b5370

Please sign in to comment.