@commercetools/ts-client 0.0.0-beta.3 → 0.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -470,6 +470,7 @@ async function executeRequest$1({
470
470
  if (response.statusCode >= 200 && response.statusCode < 300) {
471
471
  if (clientOptions.method == 'HEAD') {
472
472
  return {
473
+ body: null,
473
474
  statusCode: response.statusCode,
474
475
  headers: getHeaders(response.headers)
475
476
  };
@@ -488,7 +489,10 @@ async function executeRequest$1({
488
489
 
489
490
 
490
491
  return {
492
+ body: null,
493
+ ...response,
491
494
  error: {
495
+ statusCode: response.statusCode | response.data.statusCode,
492
496
  message: response.message || response.data.message,
493
497
  method: clientOptions.method,
494
498
  ...response
@@ -497,6 +501,7 @@ async function executeRequest$1({
497
501
  } catch (error) {
498
502
  return {
499
503
  // We know that this is a network error
504
+ body: null,
500
505
  error
501
506
  };
502
507
  } finally {
@@ -728,7 +733,7 @@ function createLoggerMiddleware$1(options) {
728
733
 
729
734
  var packageJson = {
730
735
  name: "@commercetools/ts-client",
731
- version: "0.0.0-beta.2",
736
+ version: "0.0.0-beta.4",
732
737
  engines: {
733
738
  node: ">=14"
734
739
  },
@@ -1109,6 +1114,7 @@ async function executeRequest(options) {
1109
1114
  headers: { ...request.headers
1110
1115
  },
1111
1116
  response: {
1117
+ body: null,
1112
1118
  statusCode: error.statusCode || 0,
1113
1119
  error: { ...response,
1114
1120
  error,
@@ -460,6 +460,7 @@ async function executeRequest$1({
460
460
  if (response.statusCode >= 200 && response.statusCode < 300) {
461
461
  if (clientOptions.method == 'HEAD') {
462
462
  return {
463
+ body: null,
463
464
  statusCode: response.statusCode,
464
465
  headers: getHeaders(response.headers)
465
466
  };
@@ -478,7 +479,10 @@ async function executeRequest$1({
478
479
 
479
480
 
480
481
  return {
482
+ body: null,
483
+ ...response,
481
484
  error: {
485
+ statusCode: response.statusCode | response.data.statusCode,
482
486
  message: response.message || response.data.message,
483
487
  method: clientOptions.method,
484
488
  ...response
@@ -487,6 +491,7 @@ async function executeRequest$1({
487
491
  } catch (error) {
488
492
  return {
489
493
  // We know that this is a network error
494
+ body: null,
490
495
  error
491
496
  };
492
497
  } finally {
@@ -718,7 +723,7 @@ function createLoggerMiddleware$1(options) {
718
723
 
719
724
  var packageJson = {
720
725
  name: "@commercetools/ts-client",
721
- version: "0.0.0-beta.2",
726
+ version: "0.0.0-beta.4",
722
727
  engines: {
723
728
  node: ">=14"
724
729
  },
@@ -1099,6 +1104,7 @@ async function executeRequest(options) {
1099
1104
  headers: { ...request.headers
1100
1105
  },
1101
1106
  response: {
1107
+ body: null,
1102
1108
  statusCode: error.statusCode || 0,
1103
1109
  error: { ...response,
1104
1110
  error,
@@ -470,6 +470,7 @@ async function executeRequest$1({
470
470
  if (response.statusCode >= 200 && response.statusCode < 300) {
471
471
  if (clientOptions.method == 'HEAD') {
472
472
  return {
473
+ body: null,
473
474
  statusCode: response.statusCode,
474
475
  headers: getHeaders(response.headers)
475
476
  };
@@ -488,7 +489,10 @@ async function executeRequest$1({
488
489
 
489
490
 
490
491
  return {
492
+ body: null,
493
+ ...response,
491
494
  error: {
495
+ statusCode: response.statusCode | response.data.statusCode,
492
496
  message: response.message || response.data.message,
493
497
  method: clientOptions.method,
494
498
  ...response
@@ -497,6 +501,7 @@ async function executeRequest$1({
497
501
  } catch (error) {
498
502
  return {
499
503
  // We know that this is a network error
504
+ body: null,
500
505
  error
501
506
  };
502
507
  } finally {
@@ -728,7 +733,7 @@ function createLoggerMiddleware$1(options) {
728
733
 
729
734
  var packageJson = {
730
735
  name: "@commercetools/ts-client",
731
- version: "0.0.0-beta.2",
736
+ version: "0.0.0-beta.4",
732
737
  engines: {
733
738
  node: ">=14"
734
739
  },
@@ -1109,6 +1114,7 @@ async function executeRequest(options) {
1109
1114
  headers: { ...request.headers
1110
1115
  },
1111
1116
  response: {
1117
+ body: null,
1112
1118
  statusCode: error.statusCode || 0,
1113
1119
  error: { ...response,
1114
1120
  error,
@@ -470,6 +470,7 @@ async function executeRequest$1({
470
470
  if (response.statusCode >= 200 && response.statusCode < 300) {
471
471
  if (clientOptions.method == 'HEAD') {
472
472
  return {
473
+ body: null,
473
474
  statusCode: response.statusCode,
474
475
  headers: getHeaders(response.headers)
475
476
  };
@@ -488,7 +489,10 @@ async function executeRequest$1({
488
489
 
489
490
 
490
491
  return {
492
+ body: null,
493
+ ...response,
491
494
  error: {
495
+ statusCode: response.statusCode | response.data.statusCode,
492
496
  message: response.message || response.data.message,
493
497
  method: clientOptions.method,
494
498
  ...response
@@ -497,6 +501,7 @@ async function executeRequest$1({
497
501
  } catch (error) {
498
502
  return {
499
503
  // We know that this is a network error
504
+ body: null,
500
505
  error
501
506
  };
502
507
  } finally {
@@ -728,7 +733,7 @@ function createLoggerMiddleware$1(options) {
728
733
 
729
734
  var packageJson = {
730
735
  name: "@commercetools/ts-client",
731
- version: "0.0.0-beta.2",
736
+ version: "0.0.0-beta.4",
732
737
  engines: {
733
738
  node: ">=14"
734
739
  },
@@ -1109,6 +1114,7 @@ async function executeRequest(options) {
1109
1114
  headers: { ...request.headers
1110
1115
  },
1111
1116
  response: {
1117
+ body: null,
1112
1118
  statusCode: error.statusCode || 0,
1113
1119
  error: { ...response,
1114
1120
  error,
@@ -460,6 +460,7 @@ async function executeRequest$1({
460
460
  if (response.statusCode >= 200 && response.statusCode < 300) {
461
461
  if (clientOptions.method == 'HEAD') {
462
462
  return {
463
+ body: null,
463
464
  statusCode: response.statusCode,
464
465
  headers: getHeaders(response.headers)
465
466
  };
@@ -478,7 +479,10 @@ async function executeRequest$1({
478
479
 
479
480
 
480
481
  return {
482
+ body: null,
483
+ ...response,
481
484
  error: {
485
+ statusCode: response.statusCode | response.data.statusCode,
482
486
  message: response.message || response.data.message,
483
487
  method: clientOptions.method,
484
488
  ...response
@@ -487,6 +491,7 @@ async function executeRequest$1({
487
491
  } catch (error) {
488
492
  return {
489
493
  // We know that this is a network error
494
+ body: null,
490
495
  error
491
496
  };
492
497
  } finally {
@@ -718,7 +723,7 @@ function createLoggerMiddleware$1(options) {
718
723
 
719
724
  var packageJson = {
720
725
  name: "@commercetools/ts-client",
721
- version: "0.0.0-beta.2",
726
+ version: "0.0.0-beta.4",
722
727
  engines: {
723
728
  node: ">=14"
724
729
  },
@@ -1099,6 +1104,7 @@ async function executeRequest(options) {
1099
1104
  headers: { ...request.headers
1100
1105
  },
1101
1106
  response: {
1107
+ body: null,
1102
1108
  statusCode: error.statusCode || 0,
1103
1109
  error: { ...response,
1104
1110
  error,
@@ -1,16 +1,16 @@
1
1
  import { Buffer } from 'buffer/'
2
- import fetch from 'node-fetch'
3
2
 
4
3
  export type Nullable<T> = T | null
4
+ export type Keys = string | number | symbol
5
5
  export type JsonObject<T = unknown> = { [key: string]: T }
6
6
  export type MiddlewareRequest = ClientRequest
7
7
 
8
8
  export type Middleware = (next: Next) => (request: MiddlewareRequest) => Promise<MiddlewareResponse>
9
9
 
10
- export type MiddlewareResponse = {
11
- resolve(response: JsonObject): void;
12
- reject(error: JsonObject): void;
13
- body?: JsonObject;
10
+ export type MiddlewareResponse<T = Record<string, any>> = {
11
+ resolve: Function;
12
+ reject: Function;
13
+ body: T;
14
14
  error?: HttpErrorType;
15
15
  statusCode: number;
16
16
  // headers?: JsonObject<string>;
@@ -44,8 +44,8 @@ export interface ClientRequest {
44
44
  queryParams?: VariableMap
45
45
  body?: string | Buffer
46
46
  response?: ClientResponse
47
- resolve?: (response: JsonObject) => void;
48
- reject?: (error: JsonObject) => void;
47
+ resolve?: Function;
48
+ reject?: Function;
49
49
  [key: string]: any
50
50
  }
51
51
 
@@ -76,7 +76,7 @@ export type VariableMap = {
76
76
  }
77
77
 
78
78
  export type ClientResponse<T = any> = {
79
- body?: T
79
+ body: T
80
80
  statusCode?: number
81
81
  // headers?: JsonObject<string>
82
82
  headers?: Record<string, any>
@@ -100,7 +100,7 @@ export type AuthMiddlewareOptions = {
100
100
  scopes?: Array<string>
101
101
  // For internal usage only
102
102
  oauthUri?: string
103
- httpClient?: fetch | Function
103
+ httpClient?: Function
104
104
  tokenCache?: TokenCache
105
105
  }
106
106
 
@@ -140,7 +140,7 @@ export type RefreshAuthMiddlewareOptions = {
140
140
  tokenCache?: TokenCache,
141
141
  // For internal usage only
142
142
  oauthUri?: string
143
- httpClient?: any
143
+ httpClient?: Function
144
144
  }
145
145
 
146
146
  export type RequestStateStore = {
@@ -162,13 +162,13 @@ type requestBaseOptions = {
162
162
 
163
163
  export type executeRequestOptions = requestBaseOptions & {
164
164
  next: Next
165
- httpClient: any
165
+ httpClient: Function
166
166
  userOption?: AuthMiddlewareOptions | PasswordAuthMiddlewareOptions
167
167
  }
168
168
 
169
169
  export type AuthMiddlewareBaseOptions = requestBaseOptions & {
170
170
  request: MiddlewareRequest
171
- httpClient?: any
171
+ httpClient?: Function
172
172
  }
173
173
 
174
174
  export type RequestState = boolean
@@ -195,7 +195,7 @@ export type PasswordAuthMiddlewareOptions = {
195
195
  tokenCache?: TokenCache,
196
196
  // For internal usage only
197
197
  oauthUri?: string
198
- httpClient?: any
198
+ httpClient?: Function
199
199
  }
200
200
 
201
201
  export type TokenInfo = {
@@ -236,7 +236,7 @@ export type HttpMiddlewareOptions = {
236
236
  export type HttpOptions = {
237
237
  url: string
238
238
  clientOptions: IClientOptions
239
- httpClient: any
239
+ httpClient: Function
240
240
  }
241
241
 
242
242
  export type LogLevel = 'INFO' | 'ERROR'
@@ -289,7 +289,7 @@ export type IClientOptions = {
289
289
  body?: string | Buffer
290
290
  timeout?: number
291
291
  abortController?: AbortController
292
- [k: string | number | symbol]: unknown
292
+ [k: string | number]: unknown
293
293
  }
294
294
 
295
295
  export type HttpClientConfig = IClientOptions & {
@@ -298,17 +298,7 @@ export type HttpClientConfig = IClientOptions & {
298
298
  }
299
299
 
300
300
  export type TResponse = {
301
- statusCode: number
302
- // headers: JsonObject<QueryParam>
303
- headers: Record<string, any>
304
- data: {
305
- statusCode?: number
306
- errors?: any
307
- error?: string
308
- message: string
309
- [k: string | number | symbol]: any
310
- }
311
- [k: string | number | symbol]: any
301
+ [k in Keys]: any
312
302
  }
313
303
 
314
304
  export type Client = {
@@ -325,7 +315,7 @@ export type ProcessOptions = { accumulate?: boolean; total?: number }
325
315
  export type ErrorMiddlewareOptions = {}
326
316
  export type SuccessResult = {
327
317
  body: {
328
- results: Record<string | number | symbol, Record<string, any>>;
318
+ results: Record<string | number, Record<string, any>>;
329
319
  count: number;
330
320
  };
331
321
  statusCode: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/ts-client",
3
- "version": "0.0.0-beta.3",
3
+ "version": "0.0.0-beta.5",
4
4
  "engines": {
5
5
  "node": ">=14"
6
6
  },