@helia/delegated-routing-v1-http-api-client 5.2.1 → 6.0.0

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.
@@ -6,12 +6,17 @@
6
6
  * @example
7
7
  *
8
8
  * ```typescript
9
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
9
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
10
10
  * import { CID } from 'multiformats/cid'
11
+ * import { defaultLogger } from '@libp2p/logger'
11
12
  *
12
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
13
+ * const client = delegatedRoutingV1HttpApiClient({
14
+ * url: 'https://example.org'
15
+ * })({
16
+ * logger: defaultLogger()
17
+ * })
13
18
  *
14
- * for await (const prov of getProviders(CID.parse('QmFoo'))) {
19
+ * for await (const prov of client.getProviders(CID.parse('QmFoo'))) {
15
20
  * // ...
16
21
  * }
17
22
  * ```
@@ -23,15 +28,16 @@
23
28
  * @example
24
29
  *
25
30
  * ```typescript
26
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
31
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
27
32
  * import { createLibp2p } from 'libp2p'
28
33
  * import { peerIdFromString } from '@libp2p/peer-id'
29
34
  *
30
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
31
35
  * const libp2p = await createLibp2p({
32
36
  * // other config here
33
37
  * services: {
34
- * delegatedRouting: client
38
+ * delegatedRouting: delegatedRoutingV1HttpApiClient({
39
+ * url: 'https://example.org'
40
+ * })
35
41
  * }
36
42
  * })
37
43
  *
@@ -50,7 +56,12 @@
50
56
  *
51
57
  * ```typescript
52
58
  * // disable caching
53
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org', { cacheTTL: 0 })
59
+ * const client = delegatedRoutingV1HttpApiClient({
60
+ * url: 'https://example.org'
61
+ * cacheTTL: 0
62
+ * })({
63
+ * logger: defaultLogger()
64
+ * })
54
65
  * ```
55
66
  *
56
67
  * ### Filtering with IPIP-484
@@ -63,18 +74,22 @@
63
74
  * @example
64
75
  *
65
76
  * ```typescript
66
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
77
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
67
78
  * import { createLibp2p } from 'libp2p'
68
79
  * import { peerIdFromString } from '@libp2p/peer-id'
80
+ * import { defaultLogger } from '@libp2p/logger'
69
81
  *
70
82
  * // globally set filter options
71
- * const client = createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', {
83
+ * const client = delegatedRoutingV1HttpApiClient({
84
+ * url: 'https://delegated-ipfs.dev',
72
85
  * filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
73
86
  * filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
87
+ * })({
88
+ * logger: defaultLogger()
74
89
  * })
75
90
  *
76
91
  * // per-request filter options
77
- * for await (const prov of getProviders(CID.parse('bafy'), {
92
+ * for await (const prov of client.getProviders(CID.parse('bafy'), {
78
93
  * filterProtocols: ['transport-ipfs-gateway-http'],
79
94
  * filterAddrs: ['!p2p-circuit']
80
95
  * })) {
@@ -122,6 +137,10 @@ export interface FilterOptions {
122
137
  filterAddrs?: string[];
123
138
  }
124
139
  export interface DelegatedRoutingV1HttpApiClientInit extends FilterOptions {
140
+ /**
141
+ * The endpoint to which requests will be sent
142
+ */
143
+ url: string | URL;
125
144
  /**
126
145
  * A concurrency limit to avoid request flood in web browser (default: 4)
127
146
  *
@@ -202,16 +221,6 @@ export interface DelegatedRoutingV1HttpApiClient {
202
221
  }
203
222
  /**
204
223
  * Create and return a client to use with a Routing V1 HTTP API server
205
- *
206
- * @deprecated use `delegatedRoutingV1HttpApiClient` instead - this function will be removed in a future release
207
224
  */
208
- export declare function createDelegatedRoutingV1HttpApiClient(url: URL | string, init?: Omit<DelegatedRoutingV1HttpApiClientInit, 'url'>): DelegatedRoutingV1HttpApiClient;
209
- /**
210
- * Create and return a client to use with a Routing V1 HTTP API server
211
- *
212
- * TODO: add `url` to `DelegatedRoutingV1HttpApiClientInit` interface and release as breaking change
213
- */
214
- export declare function delegatedRoutingV1HttpApiClient(init: DelegatedRoutingV1HttpApiClientInit & {
215
- url: string | URL;
216
- }): (components: DelegatedRoutingV1HttpApiClientComponents) => DelegatedRoutingV1HttpApiClient;
225
+ export declare function delegatedRoutingV1HttpApiClient(init: DelegatedRoutingV1HttpApiClientInit): (components: DelegatedRoutingV1HttpApiClientComponents) => DelegatedRoutingV1HttpApiClient;
217
226
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AACD,MAAM,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G;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAErG;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjH;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAE,IAAI,EAAE,mCAAmC,GAAG,CAAC,UAAU,EAAE,yCAAyC,KAAK,+BAA+B,CAEtL"}
package/dist/src/index.js CHANGED
@@ -6,12 +6,17 @@
6
6
  * @example
7
7
  *
8
8
  * ```typescript
9
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
9
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
10
10
  * import { CID } from 'multiformats/cid'
11
+ * import { defaultLogger } from '@libp2p/logger'
11
12
  *
12
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
13
+ * const client = delegatedRoutingV1HttpApiClient({
14
+ * url: 'https://example.org'
15
+ * })({
16
+ * logger: defaultLogger()
17
+ * })
13
18
  *
14
- * for await (const prov of getProviders(CID.parse('QmFoo'))) {
19
+ * for await (const prov of client.getProviders(CID.parse('QmFoo'))) {
15
20
  * // ...
16
21
  * }
17
22
  * ```
@@ -23,15 +28,16 @@
23
28
  * @example
24
29
  *
25
30
  * ```typescript
26
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
31
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
27
32
  * import { createLibp2p } from 'libp2p'
28
33
  * import { peerIdFromString } from '@libp2p/peer-id'
29
34
  *
30
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
31
35
  * const libp2p = await createLibp2p({
32
36
  * // other config here
33
37
  * services: {
34
- * delegatedRouting: client
38
+ * delegatedRouting: delegatedRoutingV1HttpApiClient({
39
+ * url: 'https://example.org'
40
+ * })
35
41
  * }
36
42
  * })
37
43
  *
@@ -50,7 +56,12 @@
50
56
  *
51
57
  * ```typescript
52
58
  * // disable caching
53
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org', { cacheTTL: 0 })
59
+ * const client = delegatedRoutingV1HttpApiClient({
60
+ * url: 'https://example.org'
61
+ * cacheTTL: 0
62
+ * })({
63
+ * logger: defaultLogger()
64
+ * })
54
65
  * ```
55
66
  *
56
67
  * ### Filtering with IPIP-484
@@ -63,18 +74,22 @@
63
74
  * @example
64
75
  *
65
76
  * ```typescript
66
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
77
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
67
78
  * import { createLibp2p } from 'libp2p'
68
79
  * import { peerIdFromString } from '@libp2p/peer-id'
80
+ * import { defaultLogger } from '@libp2p/logger'
69
81
  *
70
82
  * // globally set filter options
71
- * const client = createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', {
83
+ * const client = delegatedRoutingV1HttpApiClient({
84
+ * url: 'https://delegated-ipfs.dev',
72
85
  * filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
73
86
  * filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
87
+ * })({
88
+ * logger: defaultLogger()
74
89
  * })
75
90
  *
76
91
  * // per-request filter options
77
- * for await (const prov of getProviders(CID.parse('bafy'), {
92
+ * for await (const prov of client.getProviders(CID.parse('bafy'), {
78
93
  * filterProtocols: ['transport-ipfs-gateway-http'],
79
94
  * filterAddrs: ['!p2p-circuit']
80
95
  * })) {
@@ -82,25 +97,9 @@
82
97
  * }
83
98
  * ```
84
99
  */
85
- import { defaultLogger } from '@libp2p/logger';
86
100
  import { DelegatedRoutingV1HttpApiClient as DelegatedRoutingV1HttpApiClientClass } from './client.js';
87
101
  /**
88
102
  * Create and return a client to use with a Routing V1 HTTP API server
89
- *
90
- * @deprecated use `delegatedRoutingV1HttpApiClient` instead - this function will be removed in a future release
91
- */
92
- export function createDelegatedRoutingV1HttpApiClient(url, init = {}) {
93
- return new DelegatedRoutingV1HttpApiClientClass({
94
- logger: defaultLogger()
95
- }, {
96
- ...init,
97
- url: new URL(url)
98
- });
99
- }
100
- /**
101
- * Create and return a client to use with a Routing V1 HTTP API server
102
- *
103
- * TODO: add `url` to `DelegatedRoutingV1HttpApiClientInit` interface and release as breaking change
104
103
  */
105
104
  export function delegatedRoutingV1HttpApiClient(init) {
106
105
  return (components) => new DelegatedRoutingV1HttpApiClientClass(components, init);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,+BAA+B,IAAI,oCAAoC,EAAE,MAAM,aAAa,CAAA;AAyIrG;;;;GAIG;AACH,MAAM,UAAU,qCAAqC,CAAE,GAAiB,EAAE,OAAyD,EAAE;IACnI,OAAO,IAAI,oCAAoC,CAAC;QAC9C,MAAM,EAAE,aAAa,EAAE;KACxB,EAAE;QACD,GAAG,IAAI;QACP,GAAG,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC;KAClB,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAE,IAAiE;IAChH,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,oCAAoC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACnF,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AAEH,OAAO,EAAE,+BAA+B,IAAI,oCAAoC,EAAE,MAAM,aAAa,CAAA;AA8IrG;;GAEG;AACH,MAAM,UAAU,+BAA+B,CAAE,IAAyC;IACxF,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,oCAAoC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACnF,CAAC"}
@@ -17,8 +17,6 @@
17
17
  ".:GetPeersOptions": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/types/_helia_delegated-routing-v1-http-api-client.GetPeersOptions.html",
18
18
  "GetProvidersOptions": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/types/_helia_delegated-routing-v1-http-api-client.GetProvidersOptions.html",
19
19
  ".:GetProvidersOptions": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/types/_helia_delegated-routing-v1-http-api-client.GetProvidersOptions.html",
20
- "createDelegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/functions/_helia_delegated-routing-v1-http-api-client.createDelegatedRoutingV1HttpApiClient.html",
21
- ".:createDelegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/functions/_helia_delegated-routing-v1-http-api-client.createDelegatedRoutingV1HttpApiClient.html",
22
20
  "delegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/functions/_helia_delegated-routing-v1-http-api-client.delegatedRoutingV1HttpApiClient.html",
23
21
  ".:delegatedRoutingV1HttpApiClient": "https://ipfs.github.io/helia-delegated-routing-v1-http-api/functions/_helia_delegated-routing-v1-http-api-client.delegatedRoutingV1HttpApiClient.html"
24
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/delegated-routing-v1-http-api-client",
3
- "version": "5.2.1",
3
+ "version": "6.0.0",
4
4
  "description": "A Delegated Routing V1 HTTP API client",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia-delegated-routing-v1-http-api/tree/main/packages/client#readme",
@@ -140,7 +140,6 @@
140
140
  },
141
141
  "dependencies": {
142
142
  "@libp2p/interface": "^3.0.2",
143
- "@libp2p/logger": "^6.0.5",
144
143
  "@libp2p/peer-id": "^6.0.3",
145
144
  "@multiformats/multiaddr": "^13.0.1",
146
145
  "any-signal": "^4.1.1",
@@ -156,6 +155,7 @@
156
155
  },
157
156
  "devDependencies": {
158
157
  "@libp2p/crypto": "^5.1.3",
158
+ "@libp2p/logger": "^6.0.5",
159
159
  "aegir": "^47.0.10",
160
160
  "body-parser": "^2.2.0",
161
161
  "it-all": "^3.0.8",
package/src/index.ts CHANGED
@@ -6,12 +6,17 @@
6
6
  * @example
7
7
  *
8
8
  * ```typescript
9
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
9
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
10
10
  * import { CID } from 'multiformats/cid'
11
+ * import { defaultLogger } from '@libp2p/logger'
11
12
  *
12
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
13
+ * const client = delegatedRoutingV1HttpApiClient({
14
+ * url: 'https://example.org'
15
+ * })({
16
+ * logger: defaultLogger()
17
+ * })
13
18
  *
14
- * for await (const prov of getProviders(CID.parse('QmFoo'))) {
19
+ * for await (const prov of client.getProviders(CID.parse('QmFoo'))) {
15
20
  * // ...
16
21
  * }
17
22
  * ```
@@ -23,15 +28,16 @@
23
28
  * @example
24
29
  *
25
30
  * ```typescript
26
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
31
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
27
32
  * import { createLibp2p } from 'libp2p'
28
33
  * import { peerIdFromString } from '@libp2p/peer-id'
29
34
  *
30
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
31
35
  * const libp2p = await createLibp2p({
32
36
  * // other config here
33
37
  * services: {
34
- * delegatedRouting: client
38
+ * delegatedRouting: delegatedRoutingV1HttpApiClient({
39
+ * url: 'https://example.org'
40
+ * })
35
41
  * }
36
42
  * })
37
43
  *
@@ -50,7 +56,12 @@
50
56
  *
51
57
  * ```typescript
52
58
  * // disable caching
53
- * const client = createDelegatedRoutingV1HttpApiClient('https://example.org', { cacheTTL: 0 })
59
+ * const client = delegatedRoutingV1HttpApiClient({
60
+ * url: 'https://example.org'
61
+ * cacheTTL: 0
62
+ * })({
63
+ * logger: defaultLogger()
64
+ * })
54
65
  * ```
55
66
  *
56
67
  * ### Filtering with IPIP-484
@@ -63,18 +74,22 @@
63
74
  * @example
64
75
  *
65
76
  * ```typescript
66
- * import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
77
+ * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
67
78
  * import { createLibp2p } from 'libp2p'
68
79
  * import { peerIdFromString } from '@libp2p/peer-id'
80
+ * import { defaultLogger } from '@libp2p/logger'
69
81
  *
70
82
  * // globally set filter options
71
- * const client = createDelegatedRoutingV1HttpApiClient('https://delegated-ipfs.dev', {
83
+ * const client = delegatedRoutingV1HttpApiClient({
84
+ * url: 'https://delegated-ipfs.dev',
72
85
  * filterProtocols: ['transport-bitswap', 'unknown', 'transport-ipfs-gateway-http'],
73
86
  * filterAddrs: ['webtransport', 'webrtc-direct', 'wss']
87
+ * })({
88
+ * logger: defaultLogger()
74
89
  * })
75
90
  *
76
91
  * // per-request filter options
77
- * for await (const prov of getProviders(CID.parse('bafy'), {
92
+ * for await (const prov of client.getProviders(CID.parse('bafy'), {
78
93
  * filterProtocols: ['transport-ipfs-gateway-http'],
79
94
  * filterAddrs: ['!p2p-circuit']
80
95
  * })) {
@@ -83,7 +98,6 @@
83
98
  * ```
84
99
  */
85
100
 
86
- import { defaultLogger } from '@libp2p/logger'
87
101
  import { DelegatedRoutingV1HttpApiClient as DelegatedRoutingV1HttpApiClientClass } from './client.js'
88
102
  import type { AbortOptions, ComponentLogger, PeerId } from '@libp2p/interface'
89
103
  import type { Multiaddr } from '@multiformats/multiaddr'
@@ -128,6 +142,11 @@ export interface FilterOptions {
128
142
  filterAddrs?: string[]
129
143
  }
130
144
  export interface DelegatedRoutingV1HttpApiClientInit extends FilterOptions {
145
+ /**
146
+ * The endpoint to which requests will be sent
147
+ */
148
+ url: string | URL
149
+
131
150
  /**
132
151
  * A concurrency limit to avoid request flood in web browser (default: 4)
133
152
  *
@@ -223,23 +242,7 @@ export interface DelegatedRoutingV1HttpApiClient {
223
242
 
224
243
  /**
225
244
  * Create and return a client to use with a Routing V1 HTTP API server
226
- *
227
- * @deprecated use `delegatedRoutingV1HttpApiClient` instead - this function will be removed in a future release
228
- */
229
- export function createDelegatedRoutingV1HttpApiClient (url: URL | string, init: Omit<DelegatedRoutingV1HttpApiClientInit, 'url'> = {}): DelegatedRoutingV1HttpApiClient {
230
- return new DelegatedRoutingV1HttpApiClientClass({
231
- logger: defaultLogger()
232
- }, {
233
- ...init,
234
- url: new URL(url)
235
- })
236
- }
237
-
238
- /**
239
- * Create and return a client to use with a Routing V1 HTTP API server
240
- *
241
- * TODO: add `url` to `DelegatedRoutingV1HttpApiClientInit` interface and release as breaking change
242
245
  */
243
- export function delegatedRoutingV1HttpApiClient (init: DelegatedRoutingV1HttpApiClientInit & { url: string | URL }): (components: DelegatedRoutingV1HttpApiClientComponents) => DelegatedRoutingV1HttpApiClient {
246
+ export function delegatedRoutingV1HttpApiClient (init: DelegatedRoutingV1HttpApiClientInit): (components: DelegatedRoutingV1HttpApiClientComponents) => DelegatedRoutingV1HttpApiClient {
244
247
  return (components) => new DelegatedRoutingV1HttpApiClientClass(components, init)
245
248
  }