Skip to content

Commit b8c5442

Browse files
committed
fix: support pkg builds again
1 parent 2a0deee commit b8c5442

File tree

6 files changed

+40
-50
lines changed

6 files changed

+40
-50
lines changed

.changeset/chilled-rivers-sell.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@smartthings/core-sdk": major
3+
---
4+
5+
back off axios version to last non-ESM version so library will still work with pkg tool
6+
7+
NOTE: Dependents which use axios will also need to downgrade to version 0.27.2.

package-lock.json

Lines changed: 11 additions & 23 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
@@ -20,7 +20,7 @@
2020
],
2121
"dependencies": {
2222
"async-mutex": "^0.4.0",
23-
"axios": "^1.3.4",
23+
"axios": "^0.27.2",
2424
"http-signature": "^1.3.6",
2525
"lodash.isdate": "^4.0.1",
2626
"lodash.isstring": "^4.0.1",

src/endpoint-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export class EndpointClient {
180180
headers: options?.headerOverrides ? { ...headers, ...options.headerOverrides } : headers,
181181
params,
182182
data,
183-
paramsSerializer: { serialize: params => qs.stringify(params, { indices: false }) },
183+
paramsSerializer: params => qs.stringify(params, { indices: false }),
184184
}
185185

186186
axiosConfig = await this.config.authenticator.authenticate(axiosConfig)

test/unit/endpoint-client.test.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Mutex } from 'async-mutex'
2-
import axios, { AxiosRequestConfig, AxiosResponse, CustomParamsSerializer, ParamsSerializerOptions } from 'axios'
2+
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'
33
import qs from 'qs'
44

55
import { AuthData, Authenticator, BearerTokenAuthenticator, NoOpAuthenticator, RefreshData,
@@ -150,18 +150,17 @@ describe('EndpointClient', () => {
150150
},
151151
data: undefined,
152152
params: undefined,
153-
paramsSerializer: expect.any(Object),
153+
paramsSerializer: expect.any(Function),
154154
})
155155
expect(response.status).toBe('ok')
156156

157157
const stringifyMock = (qs.stringify as jest.Mock<string, [unknown]>)
158158
.mockReturnValue('stringified parameters')
159159
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160-
const serialize = (mockRequest.mock.calls[0][0].paramsSerializer as ParamsSerializerOptions)
161-
?.serialize as CustomParamsSerializer
160+
const paramsSerializer = mockRequest.mock.calls[0][0].paramsSerializer as (params: any) => string
162161

163-
expect(serialize).toBeDefined()
164-
expect(serialize({ param: 'value' })).toBe('stringified parameters')
162+
expect(paramsSerializer).toBeDefined()
163+
expect(paramsSerializer({ param: 'value' })).toBe('stringified parameters')
165164

166165
expect(stringifyMock).toHaveBeenCalledTimes(1)
167166
expect(stringifyMock).toHaveBeenCalledWith({ param: 'value' }, { indices: false })
@@ -185,7 +184,7 @@ describe('EndpointClient', () => {
185184
},
186185
data: undefined,
187186
params: undefined,
188-
paramsSerializer: expect.any(Object),
187+
paramsSerializer: expect.any(Function),
189188
})
190189
expect(response.status).toBe('ok')
191190
})
@@ -204,7 +203,7 @@ describe('EndpointClient', () => {
204203
},
205204
data: undefined,
206205
params: undefined,
207-
paramsSerializer: expect.any(Object),
206+
paramsSerializer: expect.any(Function),
208207
})
209208
expect(response.status).toBe('ok')
210209
})
@@ -227,7 +226,7 @@ describe('EndpointClient', () => {
227226
},
228227
data: { name: 'Bob' },
229228
params: undefined,
230-
paramsSerializer: expect.any(Object),
229+
paramsSerializer: expect.any(Function),
231230
})
232231
expect(response.status).toBe('ok')
233232
})
@@ -245,7 +244,7 @@ describe('EndpointClient', () => {
245244
},
246245
data: undefined,
247246
params: undefined,
248-
paramsSerializer: expect.any(Object),
247+
paramsSerializer: expect.any(Function),
249248
})
250249
expect(response.status).toBe('ok')
251250
})
@@ -268,7 +267,7 @@ describe('EndpointClient', () => {
268267
},
269268
data: undefined,
270269
params: undefined,
271-
paramsSerializer: expect.any(Object),
270+
paramsSerializer: expect.any(Function),
272271
})
273272
expect(response.status).toBe('ok')
274273

@@ -321,7 +320,7 @@ describe('EndpointClient', () => {
321320
},
322321
data: undefined,
323322
params: undefined,
324-
paramsSerializer: expect.any(Object),
323+
paramsSerializer: expect.any(Function),
325324
})
326325
expect(response.status).toBe('ok')
327326
})
@@ -340,7 +339,7 @@ describe('EndpointClient', () => {
340339
params: {
341340
locationId: 'XXX',
342341
},
343-
paramsSerializer: expect.any(Object),
342+
paramsSerializer: expect.any(Function),
344343
})
345344
expect(response.status).toBe('ok')
346345
})
@@ -357,7 +356,7 @@ describe('EndpointClient', () => {
357356
},
358357
data: undefined,
359358
params: undefined,
360-
paramsSerializer: expect.any(Object),
359+
paramsSerializer: expect.any(Function),
361360
})
362361
expect(response.status).toBe('ok')
363362
})
@@ -374,7 +373,7 @@ describe('EndpointClient', () => {
374373
},
375374
data: undefined,
376375
params: undefined,
377-
paramsSerializer: expect.any(Object),
376+
paramsSerializer: expect.any(Function),
378377
})
379378
expect(response.status).toBe('ok')
380379
})
@@ -394,7 +393,7 @@ describe('EndpointClient', () => {
394393
name: 'Bill',
395394
},
396395
params: undefined,
397-
paramsSerializer: expect.any(Object),
396+
paramsSerializer: expect.any(Function),
398397
})
399398
expect(response.status).toBe('ok')
400399
})
@@ -413,7 +412,7 @@ describe('EndpointClient', () => {
413412
name: 'Bill',
414413
},
415414
params: undefined,
416-
paramsSerializer: expect.any(Object),
415+
paramsSerializer: expect.any(Function),
417416
})
418417
expect(response.status).toBe('ok')
419418
})
@@ -432,7 +431,7 @@ describe('EndpointClient', () => {
432431
name: 'Joe',
433432
},
434433
params: undefined,
435-
paramsSerializer: expect.any(Object),
434+
paramsSerializer: expect.any(Function),
436435
})
437436
expect(response.status).toBe('ok')
438437
})
@@ -449,7 +448,7 @@ describe('EndpointClient', () => {
449448
},
450449
data: undefined,
451450
params: undefined,
452-
paramsSerializer: expect.any(Object),
451+
paramsSerializer: expect.any(Function),
453452
})
454453
expect(response.status).toBe('ok')
455454
})

test/unit/helpers/utils.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export function expectedRequest(config: any): any {
44
data: undefined,
55
params: undefined,
66
...config,
7-
paramsSerializer: expect.objectContaining({
8-
serialize: expect.any(Function),
9-
}),
7+
paramsSerializer: expect.any(Function),
108
}
119
}
1210

@@ -21,8 +19,6 @@ export function buildRequest(path?: string, params?: any, data?: any, method = '
2119
},
2220
data: data,
2321
params: params,
24-
paramsSerializer: expect.objectContaining({
25-
serialize: expect.any(Function),
26-
}),
22+
paramsSerializer: expect.any(Function),
2723
}
2824
}

0 commit comments

Comments
 (0)