@commercetools/ts-client 0.0.0-beta.2 → 0.0.0-beta.4

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.
package/README.md CHANGED
@@ -16,14 +16,13 @@ yarn add @commercetools/platform-sdk
16
16
 
17
17
  ```ts
18
18
  import {
19
- type Next
19
+ type Next,
20
20
  type HttpMiddlewareOptions,
21
- type AuthMiddlewareBaseOptions
21
+ type AuthMiddlewareBaseOptions,
22
22
  type ClientRequest,
23
23
  type MiddlewareRequest,
24
24
  type MiddlewareResponse,
25
- type Client
26
-
25
+ type Client,
27
26
  ClientBuilder,
28
27
  } from '@commercetools/ts-client'
29
28
  import { createApiBuilderFromCtpClient } from '@commercetools/platform-sdk'
@@ -51,7 +50,7 @@ const retryOptions = {
51
50
  maxRetries: 3,
52
51
  retryDelay: 200,
53
52
  backoff: true,
54
- retryCodes: [200]
53
+ retryCodes: [200],
55
54
  }
56
55
 
57
56
  // custom middleware
@@ -69,8 +68,13 @@ function middleware(options) {
69
68
 
70
69
  const client: Client = new ClientBuilder()
71
70
  .withPasswordFlow(authMiddlewareOptions)
72
- .withLoggerMiddleware({ includeOriginalRequest: false, includeResponseHeaders: false })
73
- .withCorrelationIdMiddleware({ generate: () => 'fake-correlation-id' + Math.floor(Math.random() + 2) })
71
+ .withLoggerMiddleware({
72
+ includeOriginalRequest: false,
73
+ includeResponseHeaders: false,
74
+ })
75
+ .withCorrelationIdMiddleware({
76
+ generate: () => 'fake-correlation-id' + Math.floor(Math.random() + 2),
77
+ })
74
78
  .withHttpMiddleware(httpMiddlewareOptions)
75
79
  .withRetryMiddleware(retryOptions)
76
80
  .withMiddleware(middleware({})) // <<<------------------- add the custom middleware here
@@ -728,7 +728,7 @@ function createLoggerMiddleware$1(options) {
728
728
 
729
729
  var packageJson = {
730
730
  name: "@commercetools/ts-client",
731
- version: "0.0.0-beta.1",
731
+ version: "0.0.0-beta.3",
732
732
  engines: {
733
733
  node: ">=14"
734
734
  },
@@ -761,7 +761,6 @@ var packageJson = {
761
761
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
762
762
  },
763
763
  dependencies: {
764
- axios: "^1.2.0",
765
764
  buffer: "^6.0.3",
766
765
  "node-fetch": "^2.6.1",
767
766
  querystring: "^0.2.1"
@@ -718,7 +718,7 @@ function createLoggerMiddleware$1(options) {
718
718
 
719
719
  var packageJson = {
720
720
  name: "@commercetools/ts-client",
721
- version: "0.0.0-beta.1",
721
+ version: "0.0.0-beta.3",
722
722
  engines: {
723
723
  node: ">=14"
724
724
  },
@@ -751,7 +751,6 @@ var packageJson = {
751
751
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
752
752
  },
753
753
  dependencies: {
754
- axios: "^1.2.0",
755
754
  buffer: "^6.0.3",
756
755
  "node-fetch": "^2.6.1",
757
756
  querystring: "^0.2.1"
@@ -728,7 +728,7 @@ function createLoggerMiddleware$1(options) {
728
728
 
729
729
  var packageJson = {
730
730
  name: "@commercetools/ts-client",
731
- version: "0.0.0-beta.1",
731
+ version: "0.0.0-beta.3",
732
732
  engines: {
733
733
  node: ">=14"
734
734
  },
@@ -761,7 +761,6 @@ var packageJson = {
761
761
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
762
762
  },
763
763
  dependencies: {
764
- axios: "^1.2.0",
765
764
  buffer: "^6.0.3",
766
765
  "node-fetch": "^2.6.1",
767
766
  querystring: "^0.2.1"
@@ -728,7 +728,7 @@ function createLoggerMiddleware$1(options) {
728
728
 
729
729
  var packageJson = {
730
730
  name: "@commercetools/ts-client",
731
- version: "0.0.0-beta.1",
731
+ version: "0.0.0-beta.3",
732
732
  engines: {
733
733
  node: ">=14"
734
734
  },
@@ -761,7 +761,6 @@ var packageJson = {
761
761
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
762
762
  },
763
763
  dependencies: {
764
- axios: "^1.2.0",
765
764
  buffer: "^6.0.3",
766
765
  "node-fetch": "^2.6.1",
767
766
  querystring: "^0.2.1"
@@ -718,7 +718,7 @@ function createLoggerMiddleware$1(options) {
718
718
 
719
719
  var packageJson = {
720
720
  name: "@commercetools/ts-client",
721
- version: "0.0.0-beta.1",
721
+ version: "0.0.0-beta.3",
722
722
  engines: {
723
723
  node: ">=14"
724
724
  },
@@ -751,7 +751,6 @@ var packageJson = {
751
751
  url: "https://github.com/commercetools/commercetools-sdk-typescript/issues"
752
752
  },
753
753
  dependencies: {
754
- axios: "^1.2.0",
755
754
  buffer: "^6.0.3",
756
755
  "node-fetch": "^2.6.1",
757
756
  querystring: "^0.2.1"
@@ -1,6 +1,4 @@
1
1
  import { Buffer } from 'buffer/'
2
- import fetch from 'node-fetch'
3
- import axios from 'axios'
4
2
 
5
3
  export type Nullable<T> = T | null
6
4
  export type JsonObject<T = unknown> = { [key: string]: T }
@@ -9,8 +7,8 @@ export type MiddlewareRequest = ClientRequest
9
7
  export type Middleware = (next: Next) => (request: MiddlewareRequest) => Promise<MiddlewareResponse>
10
8
 
11
9
  export type MiddlewareResponse = {
12
- resolve(response: JsonObject): void;
13
- reject(error: JsonObject): void;
10
+ resolve: Function;
11
+ reject: Function;
14
12
  body?: JsonObject;
15
13
  error?: HttpErrorType;
16
14
  statusCode: number;
@@ -45,8 +43,8 @@ export interface ClientRequest {
45
43
  queryParams?: VariableMap
46
44
  body?: string | Buffer
47
45
  response?: ClientResponse
48
- resolve?: (response: JsonObject) => void;
49
- reject?: (error: JsonObject) => void;
46
+ resolve?: Function;
47
+ reject?: Function;
50
48
  [key: string]: any
51
49
  }
52
50
 
@@ -101,7 +99,7 @@ export type AuthMiddlewareOptions = {
101
99
  scopes?: Array<string>
102
100
  // For internal usage only
103
101
  oauthUri?: string
104
- httpClient?: fetch | typeof axios
102
+ httpClient?: Function
105
103
  tokenCache?: TokenCache
106
104
  }
107
105
 
@@ -141,7 +139,7 @@ export type RefreshAuthMiddlewareOptions = {
141
139
  tokenCache?: TokenCache,
142
140
  // For internal usage only
143
141
  oauthUri?: string
144
- httpClient?: any
142
+ httpClient?: Function
145
143
  }
146
144
 
147
145
  export type RequestStateStore = {
@@ -163,13 +161,13 @@ type requestBaseOptions = {
163
161
 
164
162
  export type executeRequestOptions = requestBaseOptions & {
165
163
  next: Next
166
- httpClient: any
164
+ httpClient: Function
167
165
  userOption?: AuthMiddlewareOptions | PasswordAuthMiddlewareOptions
168
166
  }
169
167
 
170
168
  export type AuthMiddlewareBaseOptions = requestBaseOptions & {
171
169
  request: MiddlewareRequest
172
- httpClient?: any
170
+ httpClient?: Function
173
171
  }
174
172
 
175
173
  export type RequestState = boolean
@@ -196,7 +194,7 @@ export type PasswordAuthMiddlewareOptions = {
196
194
  tokenCache?: TokenCache,
197
195
  // For internal usage only
198
196
  oauthUri?: string
199
- httpClient?: any
197
+ httpClient?: Function
200
198
  }
201
199
 
202
200
  export type TokenInfo = {
@@ -237,7 +235,7 @@ export type HttpMiddlewareOptions = {
237
235
  export type HttpOptions = {
238
236
  url: string
239
237
  clientOptions: IClientOptions
240
- httpClient: any
238
+ httpClient: Function
241
239
  }
242
240
 
243
241
  export type LogLevel = 'INFO' | 'ERROR'
@@ -290,7 +288,7 @@ export type IClientOptions = {
290
288
  body?: string | Buffer
291
289
  timeout?: number
292
290
  abortController?: AbortController
293
- [k: string | number | symbol]: unknown
291
+ [k: string | number]: unknown
294
292
  }
295
293
 
296
294
  export type HttpClientConfig = IClientOptions & {
@@ -307,9 +305,9 @@ export type TResponse = {
307
305
  errors?: any
308
306
  error?: string
309
307
  message: string
310
- [k: string | number | symbol]: any
308
+ [k: string | number]: any
311
309
  }
312
- [k: string | number | symbol]: any
310
+ [k: string | number]: any
313
311
  }
314
312
 
315
313
  export type Client = {
@@ -326,7 +324,7 @@ export type ProcessOptions = { accumulate?: boolean; total?: number }
326
324
  export type ErrorMiddlewareOptions = {}
327
325
  export type SuccessResult = {
328
326
  body: {
329
- results: Record<string | number | symbol, Record<string, any>>;
327
+ results: Record<string | number, Record<string, any>>;
330
328
  count: number;
331
329
  };
332
330
  statusCode: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/ts-client",
3
- "version": "0.0.0-beta.2",
3
+ "version": "0.0.0-beta.4",
4
4
  "engines": {
5
5
  "node": ">=14"
6
6
  },
@@ -37,7 +37,10 @@
37
37
  "node-fetch": "^2.6.1",
38
38
  "querystring": "^0.2.1"
39
39
  },
40
- "files": ["dist", "CHANGELOG.md"],
40
+ "files": [
41
+ "dist",
42
+ "CHANGELOG.md"
43
+ ],
41
44
  "author": "Chukwuemeka Ajima <meeky.ae@gmail.com>",
42
45
  "main": "dist/commercetools-ts-client.cjs.js",
43
46
  "module": "dist/commercetools-ts-client.esm.js",