@ar.io/sdk 3.11.0-alpha.1 → 3.11.0-alpha.3

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.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ const commander_1 = require("commander");
19
+ const version_js_1 = require("../version.js");
20
+ const options_js_1 = require("./options.js");
21
+ const utils_js_1 = require("./utils.js");
22
+ (0, utils_js_1.applyOptions)(commander_1.program
23
+ .name('ar.io')
24
+ .version(version_js_1.version)
25
+ .description('AR.IO Network CLI')
26
+ .helpCommand(true), options_js_1.globalOptions);
27
+ (0, utils_js_1.makeCommand)({
28
+ name: '',
29
+ description: 'Get network info',
30
+ action: () => {
31
+ console.log('wayfinder');
32
+ return Promise.resolve({});
33
+ },
34
+ });
@@ -34,3 +34,5 @@ __exportStar(require("./wayfinder.js"), exports);
34
34
  __exportStar(require("./routers/random.js"), exports);
35
35
  __exportStar(require("./routers/priority.js"), exports);
36
36
  __exportStar(require("./routers/fixed.js"), exports);
37
+ // gateways providers
38
+ __exportStar(require("./gateways.js"), exports);
@@ -69,7 +69,7 @@ const createWayfinderClient = ({ httpClient, resolveUrl, }) => {
69
69
  // support direct calls: fetch('ar://…', options)
70
70
  // axios() or got()
71
71
  apply: (_target, _thisArg, argArray) => wayfinderRedirect(httpClient, argArray),
72
- // support http clients that use methods like `got.get`, `got.post`, `axios.get`, etc. while still using the wayfinder redirect function
72
+ // support http clients that use functions like `got.get`, `got.post`, `axios.get`, etc. while still using the wayfinder redirect function
73
73
  get: (target, prop, receiver) => {
74
74
  const value = Reflect.get(target, prop, receiver);
75
75
  if (typeof value === 'function') {
@@ -92,7 +92,9 @@ class Wayfinder {
92
92
  *
93
93
  * @example
94
94
  * const wayfinder = new Wayfinder({
95
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
95
+ * router: new RandomGatewayRouter({
96
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
97
+ * }),
96
98
  * });
97
99
  */
98
100
  router;
@@ -101,7 +103,9 @@ class Wayfinder {
101
103
  *
102
104
  * @example
103
105
  * const wayfinder = new Wayfinder({
104
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
106
+ * router: new RandomGatewayRouter({
107
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
108
+ * }),
105
109
  * httpClient: axios,
106
110
  * });
107
111
  */
@@ -111,7 +115,9 @@ class Wayfinder {
111
115
  *
112
116
  * @example
113
117
  * const wayfinder = new Wayfinder({
114
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
118
+ * router: new RandomGatewayRouter({
119
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
120
+ * }),
115
121
  * httpClient: axios,
116
122
  * });
117
123
  *
@@ -123,12 +129,13 @@ class Wayfinder {
123
129
  *
124
130
  * @example
125
131
  * const { request: wayfind } = new Wayfinder({
126
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
132
+ * router: new RandomGatewayRouter({
133
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
134
+ * }),
127
135
  * httpClient: axios,
128
136
  * });;
129
137
  *
130
- * TODO: consider a top level function that supports wayfinder routing under the hood
131
- * const response = await wayfind('ar://', {
138
+ * const response = await wayfind('ar://example', {
132
139
  * method: 'POST',
133
140
  * data: {
134
141
  * name: 'John Doe',
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '3.11.0-alpha.1';
20
+ exports.version = '3.11.0-alpha.3';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { program } from 'commander';
17
+ import { version } from '../version.js';
18
+ import { globalOptions } from './options.js';
19
+ import { applyOptions, makeCommand } from './utils.js';
20
+ applyOptions(program
21
+ .name('ar.io')
22
+ .version(version)
23
+ .description('AR.IO Network CLI')
24
+ .helpCommand(true), globalOptions);
25
+ makeCommand({
26
+ name: '',
27
+ description: 'Get network info',
28
+ action: () => {
29
+ console.log('wayfinder');
30
+ return Promise.resolve({});
31
+ },
32
+ });
@@ -18,3 +18,5 @@ export * from './wayfinder.js';
18
18
  export * from './routers/random.js';
19
19
  export * from './routers/priority.js';
20
20
  export * from './routers/fixed.js';
21
+ // gateways providers
22
+ export * from './gateways.js';
@@ -65,7 +65,7 @@ export const createWayfinderClient = ({ httpClient, resolveUrl, }) => {
65
65
  // support direct calls: fetch('ar://…', options)
66
66
  // axios() or got()
67
67
  apply: (_target, _thisArg, argArray) => wayfinderRedirect(httpClient, argArray),
68
- // support http clients that use methods like `got.get`, `got.post`, `axios.get`, etc. while still using the wayfinder redirect function
68
+ // support http clients that use functions like `got.get`, `got.post`, `axios.get`, etc. while still using the wayfinder redirect function
69
69
  get: (target, prop, receiver) => {
70
70
  const value = Reflect.get(target, prop, receiver);
71
71
  if (typeof value === 'function') {
@@ -87,7 +87,9 @@ export class Wayfinder {
87
87
  *
88
88
  * @example
89
89
  * const wayfinder = new Wayfinder({
90
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
90
+ * router: new RandomGatewayRouter({
91
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
92
+ * }),
91
93
  * });
92
94
  */
93
95
  router;
@@ -96,7 +98,9 @@ export class Wayfinder {
96
98
  *
97
99
  * @example
98
100
  * const wayfinder = new Wayfinder({
99
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
101
+ * router: new RandomGatewayRouter({
102
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
103
+ * }),
100
104
  * httpClient: axios,
101
105
  * });
102
106
  */
@@ -106,7 +110,9 @@ export class Wayfinder {
106
110
  *
107
111
  * @example
108
112
  * const wayfinder = new Wayfinder({
109
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
113
+ * router: new RandomGatewayRouter({
114
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
115
+ * }),
110
116
  * httpClient: axios,
111
117
  * });
112
118
  *
@@ -118,12 +124,13 @@ export class Wayfinder {
118
124
  *
119
125
  * @example
120
126
  * const { request: wayfind } = new Wayfinder({
121
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
127
+ * router: new RandomGatewayRouter({
128
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
129
+ * }),
122
130
  * httpClient: axios,
123
131
  * });;
124
132
  *
125
- * TODO: consider a top level function that supports wayfinder routing under the hood
126
- * const response = await wayfind('ar://', {
133
+ * const response = await wayfind('ar://example', {
127
134
  * method: 'POST',
128
135
  * data: {
129
136
  * name: 'John Doe',
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.11.0-alpha.1';
17
+ export const version = '3.11.0-alpha.3';
@@ -0,0 +1 @@
1
+ export {};
@@ -17,3 +17,4 @@ export * from './wayfinder.js';
17
17
  export * from './routers/random.js';
18
18
  export * from './routers/priority.js';
19
19
  export * from './routers/fixed.js';
20
+ export * from './gateways.js';
@@ -14,8 +14,9 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { WayfinderRouter } from '../../types/wayfinder.js';
17
- type AnyFunction = (...args: [string, ...unknown[]]) => unknown;
18
- type WayfinderHttpClient<T extends AnyFunction> = T;
17
+ type HttpClientArgs = [string | URL, ...unknown[]];
18
+ type HttpClientFunction = (...args: HttpClientArgs) => unknown;
19
+ type WayfinderHttpClient<T extends HttpClientFunction> = T;
19
20
  export declare const arnsRegex: RegExp;
20
21
  export declare const txIdRegex: RegExp;
21
22
  /**
@@ -41,7 +42,7 @@ export declare const resolveWayfinderUrl: ({ originalUrl, targetGateway, }: {
41
42
  * @param resolveUrl - the function to construct the redirect url for ar:// requests
42
43
  * @returns a wrapped http client that supports ar:// protocol
43
44
  */
44
- export declare const createWayfinderClient: <T extends AnyFunction>({ httpClient, resolveUrl, }: {
45
+ export declare const createWayfinderClient: <T extends HttpClientFunction>({ httpClient, resolveUrl, }: {
45
46
  httpClient: T;
46
47
  resolveUrl: (params: {
47
48
  originalUrl: string | URL;
@@ -53,13 +54,15 @@ export declare const createWayfinderClient: <T extends AnyFunction>({ httpClient
53
54
  * @param httpClient - the http client to use for requests
54
55
  * @param blocklist - the blocklist of gateways to avoid
55
56
  */
56
- export declare class Wayfinder<T extends AnyFunction> {
57
+ export declare class Wayfinder<T extends HttpClientFunction> {
57
58
  /**
58
59
  * The router to use for requests
59
60
  *
60
61
  * @example
61
62
  * const wayfinder = new Wayfinder({
62
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
63
+ * router: new RandomGatewayRouter({
64
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
65
+ * }),
63
66
  * });
64
67
  */
65
68
  readonly router: WayfinderRouter;
@@ -68,7 +71,9 @@ export declare class Wayfinder<T extends AnyFunction> {
68
71
  *
69
72
  * @example
70
73
  * const wayfinder = new Wayfinder({
71
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
74
+ * router: new RandomGatewayRouter({
75
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
76
+ * }),
72
77
  * httpClient: axios,
73
78
  * });
74
79
  */
@@ -78,7 +83,9 @@ export declare class Wayfinder<T extends AnyFunction> {
78
83
  *
79
84
  * @example
80
85
  * const wayfinder = new Wayfinder({
81
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
86
+ * router: new RandomGatewayRouter({
87
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
88
+ * }),
82
89
  * httpClient: axios,
83
90
  * });
84
91
  *
@@ -92,12 +99,13 @@ export declare class Wayfinder<T extends AnyFunction> {
92
99
  *
93
100
  * @example
94
101
  * const { request: wayfind } = new Wayfinder({
95
- * router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
102
+ * router: new RandomGatewayRouter({
103
+ * gatewaysProvider: new ARIOGatewaysProvider({ ario: ARIO.mainnet() })
104
+ * }),
96
105
  * httpClient: axios,
97
106
  * });;
98
107
  *
99
- * TODO: consider a top level function that supports wayfinder routing under the hood
100
- * const response = await wayfind('ar://', {
108
+ * const response = await wayfind('ar://example', {
101
109
  * method: 'POST',
102
110
  * data: {
103
111
  * name: 'John Doe',
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.10.0";
16
+ export declare const version = "3.11.0-alpha.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.11.0-alpha.1",
3
+ "version": "3.11.0-alpha.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"