@ardrive/turbo-sdk 1.13.0 → 1.14.0-alpha.1

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
@@ -69,6 +69,7 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
69
69
  - [`balance`](#balance)
70
70
  - [`top-up`](#top-up)
71
71
  - [`crypto-fund`](#crypto-fund)
72
+ - [`upload-folder`](#upload-folder)
72
73
  - [Developers](#developers)
73
74
  - [Requirements](#requirements)
74
75
  - [Setup & Build](#setup--build)
@@ -737,6 +738,24 @@ e.g:
737
738
  turbo crypto-fund --value 0.0001 --token kyve --private-key 'b27...45c'
738
739
  ```
739
740
 
741
+ ##### `upload-folder`
742
+
743
+ Upload a folder of files and create and upload a manifest file for the folder upload to the Turbo Upload Service.
744
+
745
+ Command Options:
746
+
747
+ - `-f, --folder-path <folderPath>` - Path to the folder to upload
748
+ - `--index-file <indexFile>` - File to use for the "index" path in the resulting manifest
749
+ - `--fallback-file <fallbackFile>` - File to use for the "fallback" path in the resulting manifest
750
+ - `--no-manifest` - Disable manifest creation
751
+ - `--max-concurrency <maxConcurrency>` - Maximum number of concurrent uploads
752
+
753
+ e.g:
754
+
755
+ ```shell
756
+ turbo upload-folder --folder-path '../path/to/my/folder' --token solana --wallet-file ../path/to/sol/sec/key.json
757
+ ```
758
+
740
759
  ## Developers
741
760
 
742
761
  ### Requirements
@@ -312251,7 +312251,7 @@ var import_winston = __toESM(require_winston(), 1);
312251
312251
  init_dirname();
312252
312252
  init_buffer2();
312253
312253
  init_process2();
312254
- var version16 = "1.13.0-alpha.2";
312254
+ var version16 = "1.13.0";
312255
312255
 
312256
312256
  // src/common/logger.ts
312257
312257
  var TurboWinstonLogger = class _TurboWinstonLogger {
@@ -21,38 +21,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const commander_1 = require("commander");
22
22
  const version_js_1 = require("../version.js");
23
23
  const commands_js_1 = require("./commands.js");
24
+ const options_js_1 = require("./options.js");
24
25
  const utils_js_1 = require("./utils.js");
25
26
  (0, utils_js_1.applyOptions)(commander_1.program
26
27
  .name('turbo')
27
28
  .version(version_js_1.version)
28
29
  .description('Turbo CLI')
29
- .helpCommand(true), utils_js_1.globalOptions);
30
- function exitWithErrorLog(error) {
31
- console.error(error instanceof Error ? error.message : error);
32
- process.exit(1);
33
- }
34
- (0, utils_js_1.applyOptions)(commander_1.program.command('balance').description('Get balance of a Turbo address'), [utils_js_1.optionMap.address, ...utils_js_1.walletOptions]).action(async (_commandOptions, command) => {
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- const options = command.optsWithGlobals();
37
- try {
38
- await (0, commands_js_1.getBalance)(options);
39
- process.exit(0);
40
- }
41
- catch (error) {
42
- exitWithErrorLog(error);
43
- }
30
+ .helpCommand(true), options_js_1.globalOptions);
31
+ (0, utils_js_1.applyOptions)(commander_1.program.command('balance').description('Get balance of a Turbo address'), [options_js_1.optionMap.address, ...options_js_1.walletOptions]).action(async (_commandOptions, command) => {
32
+ await (0, utils_js_1.runCommand)(command, commands_js_1.getBalance);
44
33
  });
45
- (0, utils_js_1.applyOptions)(commander_1.program.command('top-up').description('Top up a Turbo address with Fiat'), [...utils_js_1.walletOptions, utils_js_1.optionMap.address, utils_js_1.optionMap.value, utils_js_1.optionMap.currency]).action(async (_commandOptions, command) => {
46
- const options = command.optsWithGlobals();
47
- try {
48
- await (0, commands_js_1.topUp)(options);
49
- process.exit(0);
50
- }
51
- catch (error) {
52
- exitWithErrorLog(error);
53
- }
34
+ (0, utils_js_1.applyOptions)(commander_1.program.command('top-up').description('Top up a Turbo address with Fiat'), [...options_js_1.walletOptions, options_js_1.optionMap.address, options_js_1.optionMap.value, options_js_1.optionMap.currency]).action(async (_commandOptions, command) => {
35
+ await (0, utils_js_1.runCommand)(command, commands_js_1.topUp);
54
36
  });
55
- (0, utils_js_1.applyOptions)(commander_1.program.command('crypto-fund').description('Top up a wallet with crypto'), [...utils_js_1.walletOptions, utils_js_1.optionMap.value]).action(async (_commandOptions, command) => {
37
+ (0, utils_js_1.applyOptions)(commander_1.program.command('crypto-fund').description('Top up a wallet with crypto'), [...options_js_1.walletOptions, options_js_1.optionMap.value]).action(async (_commandOptions, command) => {
56
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
39
  const options = command.optsWithGlobals();
58
40
  const token = (0, utils_js_1.tokenFromOptions)(options);
@@ -64,14 +46,11 @@ function exitWithErrorLog(error) {
64
46
  process.exit(0);
65
47
  }
66
48
  catch (error) {
67
- exitWithErrorLog(error);
49
+ (0, utils_js_1.exitWithErrorLog)(error);
68
50
  }
69
51
  });
70
- (0, utils_js_1.applyOptions)(commander_1.program
71
- .command('upload-folder')
72
- .description('Upload a folder to a Turbo address')
73
- .argument('<folderPath>', 'Directory to upload'), [...utils_js_1.walletOptions, utils_js_1.optionMap.token]).action((directory, options) => {
74
- console.log('upload-folder TODO', directory, options);
52
+ (0, utils_js_1.applyOptions)(commander_1.program.command('upload-folder').description('Upload a folder using Turbo'), options_js_1.uploadFolderOptions).action(async (_commandOptions, command) => {
53
+ await (0, utils_js_1.runCommand)(command, commands_js_1.uploadFolder);
75
54
  });
76
55
  if (process.argv[1].includes('bin/turbo') || // Running from global .bin
77
56
  process.argv[1].includes('cli/cli') // Running from source
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addressOrPrivateKeyFromOptions = addressOrPrivateKeyFromOptions;
4
3
  exports.getBalance = getBalance;
5
4
  exports.cryptoFund = cryptoFund;
6
5
  exports.topUp = topUp;
7
6
  exports.openUrl = openUrl;
7
+ exports.uploadFolder = uploadFolder;
8
8
  /**
9
9
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
10
10
  *
@@ -24,19 +24,11 @@ exports.openUrl = openUrl;
24
24
  const node_child_process_1 = require("node:child_process");
25
25
  const index_js_1 = require("../node/index.js");
26
26
  const common_js_1 = require("../utils/common.js");
27
+ const version_js_1 = require("../version.js");
27
28
  const utils_js_1 = require("./utils.js");
28
- async function addressOrPrivateKeyFromOptions(options) {
29
- if (options.address !== undefined) {
30
- return { address: options.address, privateKey: undefined };
31
- }
32
- return {
33
- address: undefined,
34
- privateKey: await (0, utils_js_1.optionalPrivateKeyFromOptions)(options),
35
- };
36
- }
37
29
  async function getBalance(options) {
38
30
  const config = (0, utils_js_1.configFromOptions)(options);
39
- const { address, privateKey } = await addressOrPrivateKeyFromOptions(options);
31
+ const { address, privateKey } = await (0, utils_js_1.addressOrPrivateKeyFromOptions)(options);
40
32
  if (address !== undefined) {
41
33
  const turbo = index_js_1.TurboFactory.unauthenticated(config);
42
34
  const { winc } = await turbo.getBalance(address);
@@ -67,7 +59,7 @@ async function cryptoFund({ value, privateKey, token, config, }) {
67
59
  }
68
60
  async function topUp(options) {
69
61
  const config = (0, utils_js_1.configFromOptions)(options);
70
- const { address, privateKey } = await addressOrPrivateKeyFromOptions(options);
62
+ const { address, privateKey } = await (0, utils_js_1.addressOrPrivateKeyFromOptions)(options);
71
63
  const value = options.value;
72
64
  if (value === undefined) {
73
65
  throw new Error('Must provide a --value to top up');
@@ -120,3 +112,27 @@ function openUrl(url) {
120
112
  open(url);
121
113
  }
122
114
  }
115
+ const turboCliTags = [
116
+ { name: 'App-Name', value: 'Turbo-CLI' },
117
+ { name: 'App-Version', value: version_js_1.version },
118
+ { name: 'App-Platform', value: process.platform },
119
+ ];
120
+ async function uploadFolder(options) {
121
+ const privateKey = await (0, utils_js_1.privateKeyFromOptions)(options);
122
+ const turbo = index_js_1.TurboFactory.authenticated({
123
+ ...(0, utils_js_1.configFromOptions)(options),
124
+ privateKey,
125
+ });
126
+ const { disableManifest, fallbackFile, folderPath, indexFile, maxConcurrentUploads, } = (0, utils_js_1.getUploadFolderOptions)(options);
127
+ const result = await turbo.uploadFolder({
128
+ folderPath: folderPath,
129
+ dataItemOpts: { tags: [...turboCliTags] }, // TODO: Inject user tags
130
+ manifestOptions: {
131
+ disableManifest,
132
+ indexFile,
133
+ fallbackFile,
134
+ },
135
+ maxConcurrentUploads,
136
+ });
137
+ console.log('Uploaded folder:', JSON.stringify(result, null, 2));
138
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.uploadFolderOptions = exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
20
+ exports.optionMap = {
21
+ token: {
22
+ alias: '-t, --token <type>',
23
+ description: 'Crypto token type for wallet or action',
24
+ default: 'arweave',
25
+ },
26
+ currency: {
27
+ alias: '-c, --currency <currency>',
28
+ description: 'Fiat currency type to use for the action',
29
+ default: 'usd',
30
+ },
31
+ address: {
32
+ alias: '-a, --address <nativeAddress>',
33
+ description: 'Native address to use for action',
34
+ },
35
+ value: {
36
+ alias: '-v, --value <value>',
37
+ description: 'Value of fiat currency or crypto token for action. e.g: 10.50 for $10.50 USD or 0.0001 for 0.0001 AR',
38
+ },
39
+ walletFile: {
40
+ alias: '-w, --wallet-file <filePath>',
41
+ description: 'Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array',
42
+ },
43
+ mnemonic: {
44
+ alias: '-m, --mnemonic <phrase>',
45
+ description: 'Mnemonic to use with the action',
46
+ },
47
+ privateKey: {
48
+ alias: '-p, --private-key <key>',
49
+ description: 'Private key to use with the action',
50
+ },
51
+ gateway: {
52
+ alias: '-g, --gateway <url>',
53
+ description: 'Set a custom crypto gateway URL',
54
+ default: undefined,
55
+ },
56
+ dev: {
57
+ alias: '--dev',
58
+ description: 'Enable development endpoints',
59
+ default: false,
60
+ },
61
+ debug: {
62
+ // TODO: Implement
63
+ alias: '--debug',
64
+ description: 'Enable verbose logging',
65
+ default: false,
66
+ },
67
+ quiet: {
68
+ // TODO: Implement
69
+ alias: '--quiet',
70
+ description: 'Disable logging',
71
+ default: false,
72
+ },
73
+ folderPath: {
74
+ alias: '-f, --folder-path <folderPath>',
75
+ description: 'Directory to upload',
76
+ },
77
+ indexFile: {
78
+ alias: '--index-file <indexFile>',
79
+ description: 'Index file to use in the manifest created for folder upload',
80
+ },
81
+ fallbackFile: {
82
+ alias: '--fallback-file <fallbackFile>',
83
+ description: 'Fallback file to use in the manifest created for folder upload',
84
+ },
85
+ manifest: {
86
+ alias: '--no-manifest',
87
+ description: 'Disable manifest creation with --no-manifest',
88
+ default: false,
89
+ },
90
+ maxConcurrency: {
91
+ alias: '--max-concurrency <maxConcurrency>',
92
+ description: 'Maximum number of concurrent uploads',
93
+ },
94
+ };
95
+ exports.walletOptions = [
96
+ exports.optionMap.walletFile,
97
+ exports.optionMap.mnemonic,
98
+ exports.optionMap.privateKey,
99
+ ];
100
+ exports.globalOptions = [
101
+ exports.optionMap.dev,
102
+ exports.optionMap.gateway,
103
+ exports.optionMap.debug,
104
+ exports.optionMap.quiet,
105
+ exports.optionMap.token,
106
+ ];
107
+ exports.uploadFolderOptions = [
108
+ ...exports.walletOptions,
109
+ exports.optionMap.folderPath,
110
+ exports.optionMap.indexFile,
111
+ exports.optionMap.fallbackFile,
112
+ exports.optionMap.manifest,
113
+ exports.optionMap.maxConcurrency,
114
+ ];
@@ -3,13 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
6
+ exports.exitWithErrorLog = exitWithErrorLog;
7
+ exports.runCommand = runCommand;
7
8
  exports.applyOptions = applyOptions;
8
9
  exports.tokenFromOptions = tokenFromOptions;
9
10
  exports.valueFromOptions = valueFromOptions;
11
+ exports.getFolderPathFromOptions = getFolderPathFromOptions;
12
+ exports.addressOrPrivateKeyFromOptions = addressOrPrivateKeyFromOptions;
10
13
  exports.optionalPrivateKeyFromOptions = optionalPrivateKeyFromOptions;
11
14
  exports.privateKeyFromOptions = privateKeyFromOptions;
12
15
  exports.configFromOptions = configFromOptions;
16
+ exports.getUploadFolderOptions = getUploadFolderOptions;
13
17
  /**
14
18
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
15
19
  *
@@ -30,72 +34,20 @@ const bs58_1 = __importDefault(require("bs58"));
30
34
  const fs_1 = require("fs");
31
35
  const index_js_1 = require("../node/index.js");
32
36
  const errors_js_1 = require("./errors.js");
33
- exports.optionMap = {
34
- token: {
35
- alias: '-t, --token <type>',
36
- description: 'Crypto token type for wallet or action',
37
- default: 'arweave',
38
- },
39
- currency: {
40
- alias: '-c, --currency <currency>',
41
- description: 'Fiat currency type to use for the action',
42
- default: 'usd',
43
- },
44
- address: {
45
- alias: '-a, --address <nativeAddress>',
46
- description: 'Native address to use for action',
47
- },
48
- value: {
49
- alias: '-v, --value <value>',
50
- description: 'Value of fiat currency or crypto token for action. e.g: 10.50 for $10.50 USD or 0.0001 for 0.0001 AR',
51
- },
52
- walletFile: {
53
- alias: '-w, --wallet-file <filePath>',
54
- description: 'Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array',
55
- },
56
- mnemonic: {
57
- alias: '-m, --mnemonic <phrase>',
58
- description: 'Mnemonic to use with the action',
59
- },
60
- privateKey: {
61
- alias: '-p, --private-key <key>',
62
- description: 'Private key to use with the action',
63
- },
64
- gateway: {
65
- alias: '-g, --gateway <url>',
66
- description: 'Set a custom crypto gateway URL',
67
- default: undefined,
68
- },
69
- dev: {
70
- alias: '--dev',
71
- description: 'Enable development endpoints',
72
- default: false,
73
- },
74
- debug: {
75
- // TODO: Implement
76
- alias: '--debug',
77
- description: 'Enable verbose logging',
78
- default: false,
79
- },
80
- quiet: {
81
- // TODO: Implement
82
- alias: '--quiet',
83
- description: 'Disable logging',
84
- default: false,
85
- },
86
- };
87
- exports.walletOptions = [
88
- exports.optionMap.walletFile,
89
- exports.optionMap.mnemonic,
90
- exports.optionMap.privateKey,
91
- ];
92
- exports.globalOptions = [
93
- exports.optionMap.dev,
94
- exports.optionMap.gateway,
95
- exports.optionMap.debug,
96
- exports.optionMap.quiet,
97
- exports.optionMap.token,
98
- ];
37
+ function exitWithErrorLog(error) {
38
+ console.error(error instanceof Error ? error.message : error);
39
+ process.exit(1);
40
+ }
41
+ async function runCommand(command, action) {
42
+ const options = command.optsWithGlobals();
43
+ try {
44
+ await action(options);
45
+ process.exit(0);
46
+ }
47
+ catch (error) {
48
+ exitWithErrorLog(error);
49
+ }
50
+ }
99
51
  function applyOptions(command, options) {
100
52
  [...options].forEach((option) => {
101
53
  command.option(option.alias, option.description, option.default);
@@ -119,6 +71,27 @@ function valueFromOptions(options) {
119
71
  }
120
72
  return value;
121
73
  }
74
+ function getFolderPathFromOptions(options) {
75
+ const folderPath = options.folderPath;
76
+ if (folderPath === undefined) {
77
+ throw new Error('Folder path is required. Use --folderPath <path>');
78
+ }
79
+ // Check if path exists and is a directory
80
+ const stats = (0, fs_1.statSync)(folderPath);
81
+ if (!stats.isDirectory()) {
82
+ throw new Error('Folder path is not a directory');
83
+ }
84
+ return folderPath;
85
+ }
86
+ async function addressOrPrivateKeyFromOptions(options) {
87
+ if (options.address !== undefined) {
88
+ return { address: options.address, privateKey: undefined };
89
+ }
90
+ return {
91
+ address: undefined,
92
+ privateKey: await optionalPrivateKeyFromOptions(options),
93
+ };
94
+ }
122
95
  async function optionalPrivateKeyFromOptions(options) {
123
96
  try {
124
97
  const key = await privateKeyFromOptions(options);
@@ -157,6 +130,7 @@ const tokenToDevGatewayMap = {
157
130
  solana: 'https://api.devnet.solana.com',
158
131
  ethereum: 'https://ethereum-holesky-rpc.publicnode.com',
159
132
  kyve: 'https://api.korellia.kyve.network',
133
+ // matic: 'https://rpc-amoy.polygon.technology',
160
134
  };
161
135
  function configFromOptions({ gateway, dev, token, }) {
162
136
  let config = {};
@@ -174,3 +148,12 @@ function configFromOptions({ gateway, dev, token, }) {
174
148
  config.token = token;
175
149
  return config;
176
150
  }
151
+ function getUploadFolderOptions(options) {
152
+ return {
153
+ folderPath: options.folderPath,
154
+ indexFile: options.indexFile,
155
+ fallbackFile: options.fallbackFile,
156
+ disableManifest: !options.manifest,
157
+ maxConcurrentUploads: +(options.maxConcurrency ?? 1),
158
+ };
159
+ }
@@ -32,6 +32,9 @@ class TurboAuthenticatedUploadService extends upload_js_1.TurboAuthenticatedBase
32
32
  // Walk the directory and add all file paths to the array
33
33
  const files = await fs_1.promises.readdir(folderPath);
34
34
  for (const file of files) {
35
+ if (file === '.DS_Store') {
36
+ continue;
37
+ }
35
38
  const absoluteFilePath = (0, path_1.join)(folderPath, file);
36
39
  const stat = await fs_1.promises.stat(absoluteFilePath);
37
40
  if (stat.isDirectory()) {
@@ -18,4 +18,4 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.version = void 0;
20
20
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
21
- exports.version = '1.13.0';
21
+ exports.version = '1.14.0-alpha.1';
@@ -18,37 +18,19 @@
18
18
  // eslint-disable-next-line header/header -- This is a CLI file
19
19
  import { program } from 'commander';
20
20
  import { version } from '../version.js';
21
- import { cryptoFund, getBalance, topUp } from './commands.js';
22
- import { applyOptions, configFromOptions, globalOptions, optionMap, privateKeyFromOptions, tokenFromOptions, valueFromOptions, walletOptions, } from './utils.js';
21
+ import { cryptoFund, getBalance, topUp, uploadFolder } from './commands.js';
22
+ import { globalOptions, optionMap, uploadFolderOptions, walletOptions, } from './options.js';
23
+ import { applyOptions, configFromOptions, exitWithErrorLog, privateKeyFromOptions, runCommand, tokenFromOptions, valueFromOptions, } from './utils.js';
23
24
  applyOptions(program
24
25
  .name('turbo')
25
26
  .version(version)
26
27
  .description('Turbo CLI')
27
28
  .helpCommand(true), globalOptions);
28
- function exitWithErrorLog(error) {
29
- console.error(error instanceof Error ? error.message : error);
30
- process.exit(1);
31
- }
32
29
  applyOptions(program.command('balance').description('Get balance of a Turbo address'), [optionMap.address, ...walletOptions]).action(async (_commandOptions, command) => {
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- const options = command.optsWithGlobals();
35
- try {
36
- await getBalance(options);
37
- process.exit(0);
38
- }
39
- catch (error) {
40
- exitWithErrorLog(error);
41
- }
30
+ await runCommand(command, getBalance);
42
31
  });
43
32
  applyOptions(program.command('top-up').description('Top up a Turbo address with Fiat'), [...walletOptions, optionMap.address, optionMap.value, optionMap.currency]).action(async (_commandOptions, command) => {
44
- const options = command.optsWithGlobals();
45
- try {
46
- await topUp(options);
47
- process.exit(0);
48
- }
49
- catch (error) {
50
- exitWithErrorLog(error);
51
- }
33
+ await runCommand(command, topUp);
52
34
  });
53
35
  applyOptions(program.command('crypto-fund').description('Top up a wallet with crypto'), [...walletOptions, optionMap.value]).action(async (_commandOptions, command) => {
54
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -65,11 +47,8 @@ applyOptions(program.command('crypto-fund').description('Top up a wallet with cr
65
47
  exitWithErrorLog(error);
66
48
  }
67
49
  });
68
- applyOptions(program
69
- .command('upload-folder')
70
- .description('Upload a folder to a Turbo address')
71
- .argument('<folderPath>', 'Directory to upload'), [...walletOptions, optionMap.token]).action((directory, options) => {
72
- console.log('upload-folder TODO', directory, options);
50
+ applyOptions(program.command('upload-folder').description('Upload a folder using Turbo'), uploadFolderOptions).action(async (_commandOptions, command) => {
51
+ await runCommand(command, uploadFolder);
73
52
  });
74
53
  if (process.argv[1].includes('bin/turbo') || // Running from global .bin
75
54
  process.argv[1].includes('cli/cli') // Running from source
@@ -17,16 +17,8 @@
17
17
  import { exec } from 'node:child_process';
18
18
  import { TurboFactory, currencyMap, fiatCurrencyTypes, isCurrency, tokenToBaseMap, } from '../node/index.js';
19
19
  import { sleep } from '../utils/common.js';
20
- import { configFromOptions, optionalPrivateKeyFromOptions } from './utils.js';
21
- export async function addressOrPrivateKeyFromOptions(options) {
22
- if (options.address !== undefined) {
23
- return { address: options.address, privateKey: undefined };
24
- }
25
- return {
26
- address: undefined,
27
- privateKey: await optionalPrivateKeyFromOptions(options),
28
- };
29
- }
20
+ import { version } from '../version.js';
21
+ import { addressOrPrivateKeyFromOptions, configFromOptions, getUploadFolderOptions, privateKeyFromOptions, } from './utils.js';
30
22
  export async function getBalance(options) {
31
23
  const config = configFromOptions(options);
32
24
  const { address, privateKey } = await addressOrPrivateKeyFromOptions(options);
@@ -113,3 +105,27 @@ export function openUrl(url) {
113
105
  open(url);
114
106
  }
115
107
  }
108
+ const turboCliTags = [
109
+ { name: 'App-Name', value: 'Turbo-CLI' },
110
+ { name: 'App-Version', value: version },
111
+ { name: 'App-Platform', value: process.platform },
112
+ ];
113
+ export async function uploadFolder(options) {
114
+ const privateKey = await privateKeyFromOptions(options);
115
+ const turbo = TurboFactory.authenticated({
116
+ ...configFromOptions(options),
117
+ privateKey,
118
+ });
119
+ const { disableManifest, fallbackFile, folderPath, indexFile, maxConcurrentUploads, } = getUploadFolderOptions(options);
120
+ const result = await turbo.uploadFolder({
121
+ folderPath: folderPath,
122
+ dataItemOpts: { tags: [...turboCliTags] }, // TODO: Inject user tags
123
+ manifestOptions: {
124
+ disableManifest,
125
+ indexFile,
126
+ fallbackFile,
127
+ },
128
+ maxConcurrentUploads,
129
+ });
130
+ console.log('Uploaded folder:', JSON.stringify(result, null, 2));
131
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Affero General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ export const optionMap = {
18
+ token: {
19
+ alias: '-t, --token <type>',
20
+ description: 'Crypto token type for wallet or action',
21
+ default: 'arweave',
22
+ },
23
+ currency: {
24
+ alias: '-c, --currency <currency>',
25
+ description: 'Fiat currency type to use for the action',
26
+ default: 'usd',
27
+ },
28
+ address: {
29
+ alias: '-a, --address <nativeAddress>',
30
+ description: 'Native address to use for action',
31
+ },
32
+ value: {
33
+ alias: '-v, --value <value>',
34
+ description: 'Value of fiat currency or crypto token for action. e.g: 10.50 for $10.50 USD or 0.0001 for 0.0001 AR',
35
+ },
36
+ walletFile: {
37
+ alias: '-w, --wallet-file <filePath>',
38
+ description: 'Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array',
39
+ },
40
+ mnemonic: {
41
+ alias: '-m, --mnemonic <phrase>',
42
+ description: 'Mnemonic to use with the action',
43
+ },
44
+ privateKey: {
45
+ alias: '-p, --private-key <key>',
46
+ description: 'Private key to use with the action',
47
+ },
48
+ gateway: {
49
+ alias: '-g, --gateway <url>',
50
+ description: 'Set a custom crypto gateway URL',
51
+ default: undefined,
52
+ },
53
+ dev: {
54
+ alias: '--dev',
55
+ description: 'Enable development endpoints',
56
+ default: false,
57
+ },
58
+ debug: {
59
+ // TODO: Implement
60
+ alias: '--debug',
61
+ description: 'Enable verbose logging',
62
+ default: false,
63
+ },
64
+ quiet: {
65
+ // TODO: Implement
66
+ alias: '--quiet',
67
+ description: 'Disable logging',
68
+ default: false,
69
+ },
70
+ folderPath: {
71
+ alias: '-f, --folder-path <folderPath>',
72
+ description: 'Directory to upload',
73
+ },
74
+ indexFile: {
75
+ alias: '--index-file <indexFile>',
76
+ description: 'Index file to use in the manifest created for folder upload',
77
+ },
78
+ fallbackFile: {
79
+ alias: '--fallback-file <fallbackFile>',
80
+ description: 'Fallback file to use in the manifest created for folder upload',
81
+ },
82
+ manifest: {
83
+ alias: '--no-manifest',
84
+ description: 'Disable manifest creation with --no-manifest',
85
+ default: false,
86
+ },
87
+ maxConcurrency: {
88
+ alias: '--max-concurrency <maxConcurrency>',
89
+ description: 'Maximum number of concurrent uploads',
90
+ },
91
+ };
92
+ export const walletOptions = [
93
+ optionMap.walletFile,
94
+ optionMap.mnemonic,
95
+ optionMap.privateKey,
96
+ ];
97
+ export const globalOptions = [
98
+ optionMap.dev,
99
+ optionMap.gateway,
100
+ optionMap.debug,
101
+ optionMap.quiet,
102
+ optionMap.token,
103
+ ];
104
+ export const uploadFolderOptions = [
105
+ ...walletOptions,
106
+ optionMap.folderPath,
107
+ optionMap.indexFile,
108
+ optionMap.fallbackFile,
109
+ optionMap.manifest,
110
+ optionMap.maxConcurrency,
111
+ ];
@@ -15,75 +15,23 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  import bs58 from 'bs58';
18
- import { readFileSync } from 'fs';
18
+ import { readFileSync, statSync } from 'fs';
19
19
  import { defaultTurboConfiguration, developmentTurboConfiguration, isTokenType, privateKeyFromKyveMnemonic, } from '../node/index.js';
20
20
  import { NoWalletProvidedError } from './errors.js';
21
- export const optionMap = {
22
- token: {
23
- alias: '-t, --token <type>',
24
- description: 'Crypto token type for wallet or action',
25
- default: 'arweave',
26
- },
27
- currency: {
28
- alias: '-c, --currency <currency>',
29
- description: 'Fiat currency type to use for the action',
30
- default: 'usd',
31
- },
32
- address: {
33
- alias: '-a, --address <nativeAddress>',
34
- description: 'Native address to use for action',
35
- },
36
- value: {
37
- alias: '-v, --value <value>',
38
- description: 'Value of fiat currency or crypto token for action. e.g: 10.50 for $10.50 USD or 0.0001 for 0.0001 AR',
39
- },
40
- walletFile: {
41
- alias: '-w, --wallet-file <filePath>',
42
- description: 'Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array',
43
- },
44
- mnemonic: {
45
- alias: '-m, --mnemonic <phrase>',
46
- description: 'Mnemonic to use with the action',
47
- },
48
- privateKey: {
49
- alias: '-p, --private-key <key>',
50
- description: 'Private key to use with the action',
51
- },
52
- gateway: {
53
- alias: '-g, --gateway <url>',
54
- description: 'Set a custom crypto gateway URL',
55
- default: undefined,
56
- },
57
- dev: {
58
- alias: '--dev',
59
- description: 'Enable development endpoints',
60
- default: false,
61
- },
62
- debug: {
63
- // TODO: Implement
64
- alias: '--debug',
65
- description: 'Enable verbose logging',
66
- default: false,
67
- },
68
- quiet: {
69
- // TODO: Implement
70
- alias: '--quiet',
71
- description: 'Disable logging',
72
- default: false,
73
- },
74
- };
75
- export const walletOptions = [
76
- optionMap.walletFile,
77
- optionMap.mnemonic,
78
- optionMap.privateKey,
79
- ];
80
- export const globalOptions = [
81
- optionMap.dev,
82
- optionMap.gateway,
83
- optionMap.debug,
84
- optionMap.quiet,
85
- optionMap.token,
86
- ];
21
+ export function exitWithErrorLog(error) {
22
+ console.error(error instanceof Error ? error.message : error);
23
+ process.exit(1);
24
+ }
25
+ export async function runCommand(command, action) {
26
+ const options = command.optsWithGlobals();
27
+ try {
28
+ await action(options);
29
+ process.exit(0);
30
+ }
31
+ catch (error) {
32
+ exitWithErrorLog(error);
33
+ }
34
+ }
87
35
  export function applyOptions(command, options) {
88
36
  [...options].forEach((option) => {
89
37
  command.option(option.alias, option.description, option.default);
@@ -107,6 +55,27 @@ export function valueFromOptions(options) {
107
55
  }
108
56
  return value;
109
57
  }
58
+ export function getFolderPathFromOptions(options) {
59
+ const folderPath = options.folderPath;
60
+ if (folderPath === undefined) {
61
+ throw new Error('Folder path is required. Use --folderPath <path>');
62
+ }
63
+ // Check if path exists and is a directory
64
+ const stats = statSync(folderPath);
65
+ if (!stats.isDirectory()) {
66
+ throw new Error('Folder path is not a directory');
67
+ }
68
+ return folderPath;
69
+ }
70
+ export async function addressOrPrivateKeyFromOptions(options) {
71
+ if (options.address !== undefined) {
72
+ return { address: options.address, privateKey: undefined };
73
+ }
74
+ return {
75
+ address: undefined,
76
+ privateKey: await optionalPrivateKeyFromOptions(options),
77
+ };
78
+ }
110
79
  export async function optionalPrivateKeyFromOptions(options) {
111
80
  try {
112
81
  const key = await privateKeyFromOptions(options);
@@ -145,6 +114,7 @@ const tokenToDevGatewayMap = {
145
114
  solana: 'https://api.devnet.solana.com',
146
115
  ethereum: 'https://ethereum-holesky-rpc.publicnode.com',
147
116
  kyve: 'https://api.korellia.kyve.network',
117
+ // matic: 'https://rpc-amoy.polygon.technology',
148
118
  };
149
119
  export function configFromOptions({ gateway, dev, token, }) {
150
120
  let config = {};
@@ -162,3 +132,12 @@ export function configFromOptions({ gateway, dev, token, }) {
162
132
  config.token = token;
163
133
  return config;
164
134
  }
135
+ export function getUploadFolderOptions(options) {
136
+ return {
137
+ folderPath: options.folderPath,
138
+ indexFile: options.indexFile,
139
+ fallbackFile: options.fallbackFile,
140
+ disableManifest: !options.manifest,
141
+ maxConcurrentUploads: +(options.maxConcurrency ?? 1),
142
+ };
143
+ }
@@ -29,6 +29,9 @@ export class TurboAuthenticatedUploadService extends TurboAuthenticatedBaseUploa
29
29
  // Walk the directory and add all file paths to the array
30
30
  const files = await promises.readdir(folderPath);
31
31
  for (const file of files) {
32
+ if (file === '.DS_Store') {
33
+ continue;
34
+ }
32
35
  const absoluteFilePath = join(folderPath, file);
33
36
  const stat = await promises.stat(absoluteFilePath);
34
37
  if (stat.isDirectory()) {
@@ -15,4 +15,4 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
18
- export const version = '1.13.0';
18
+ export const version = '1.14.0-alpha.1';
@@ -1,9 +1,5 @@
1
1
  import { TokenType, TurboUnauthenticatedConfiguration, TurboWallet } from '../node/index.js';
2
- import { AddressOptions, TopUpOptions } from './types.js';
3
- export declare function addressOrPrivateKeyFromOptions(options: AddressOptions): Promise<{
4
- address: string | undefined;
5
- privateKey: string | undefined;
6
- }>;
2
+ import { AddressOptions, TopUpOptions, UploadFolderOptions } from './types.js';
7
3
  export declare function getBalance(options: AddressOptions): Promise<void>;
8
4
  export interface CryptoFundParams {
9
5
  token: TokenType;
@@ -15,4 +11,5 @@ export interface CryptoFundParams {
15
11
  export declare function cryptoFund({ value, privateKey, token, config, }: CryptoFundParams): Promise<void>;
16
12
  export declare function topUp(options: TopUpOptions): Promise<void>;
17
13
  export declare function openUrl(url: string): void;
14
+ export declare function uploadFolder(options: UploadFolderOptions): Promise<void>;
18
15
  //# sourceMappingURL=commands.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,SAAS,EAET,iCAAiC,EACjC,WAAW,EAKZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1D,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC,CASD;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,cAAc,iBAgCvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,WAAW,CAAC;IACxB,MAAM,EAAE,iCAAiC,CAAC;CAC3C;AACD,4CAA4C;AAC5C,wBAAsB,UAAU,CAAC,EAC/B,KAAK,EACL,UAAU,EACV,KAAK,EACL,MAAM,GACP,EAAE,gBAAgB,iBAelB;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBA4DhD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,QAWlC"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,SAAS,EAET,iCAAiC,EACjC,WAAW,EAKZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAQ/E,wBAAsB,UAAU,CAAC,OAAO,EAAE,cAAc,iBAgCvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,WAAW,CAAC;IACxB,MAAM,EAAE,iCAAiC,CAAC;CAC3C;AACD,4CAA4C;AAC5C,wBAAsB,UAAU,CAAC,EAC/B,KAAK,EACL,UAAU,EACV,KAAK,EACL,MAAM,GACP,EAAE,gBAAgB,iBAelB;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBA4DhD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,QAWlC;AAQD,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc. All Rights Reserved.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Affero General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ export declare const optionMap: {
18
+ readonly token: {
19
+ readonly alias: "-t, --token <type>";
20
+ readonly description: "Crypto token type for wallet or action";
21
+ readonly default: "arweave";
22
+ };
23
+ readonly currency: {
24
+ readonly alias: "-c, --currency <currency>";
25
+ readonly description: "Fiat currency type to use for the action";
26
+ readonly default: "usd";
27
+ };
28
+ readonly address: {
29
+ readonly alias: "-a, --address <nativeAddress>";
30
+ readonly description: "Native address to use for action";
31
+ };
32
+ readonly value: {
33
+ readonly alias: "-v, --value <value>";
34
+ readonly description: "Value of fiat currency or crypto token for action. e.g: 10.50 for $10.50 USD or 0.0001 for 0.0001 AR";
35
+ };
36
+ readonly walletFile: {
37
+ readonly alias: "-w, --wallet-file <filePath>";
38
+ readonly description: "Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array";
39
+ };
40
+ readonly mnemonic: {
41
+ readonly alias: "-m, --mnemonic <phrase>";
42
+ readonly description: "Mnemonic to use with the action";
43
+ };
44
+ readonly privateKey: {
45
+ readonly alias: "-p, --private-key <key>";
46
+ readonly description: "Private key to use with the action";
47
+ };
48
+ readonly gateway: {
49
+ readonly alias: "-g, --gateway <url>";
50
+ readonly description: "Set a custom crypto gateway URL";
51
+ readonly default: undefined;
52
+ };
53
+ readonly dev: {
54
+ readonly alias: "--dev";
55
+ readonly description: "Enable development endpoints";
56
+ readonly default: false;
57
+ };
58
+ readonly debug: {
59
+ readonly alias: "--debug";
60
+ readonly description: "Enable verbose logging";
61
+ readonly default: false;
62
+ };
63
+ readonly quiet: {
64
+ readonly alias: "--quiet";
65
+ readonly description: "Disable logging";
66
+ readonly default: false;
67
+ };
68
+ readonly folderPath: {
69
+ readonly alias: "-f, --folder-path <folderPath>";
70
+ readonly description: "Directory to upload";
71
+ };
72
+ readonly indexFile: {
73
+ readonly alias: "--index-file <indexFile>";
74
+ readonly description: "Index file to use in the manifest created for folder upload";
75
+ };
76
+ readonly fallbackFile: {
77
+ readonly alias: "--fallback-file <fallbackFile>";
78
+ readonly description: "Fallback file to use in the manifest created for folder upload";
79
+ };
80
+ readonly manifest: {
81
+ readonly alias: "--no-manifest";
82
+ readonly description: "Disable manifest creation with --no-manifest";
83
+ readonly default: false;
84
+ };
85
+ readonly maxConcurrency: {
86
+ readonly alias: "--max-concurrency <maxConcurrency>";
87
+ readonly description: "Maximum number of concurrent uploads";
88
+ };
89
+ };
90
+ export declare const walletOptions: ({
91
+ readonly alias: "-w, --wallet-file <filePath>";
92
+ readonly description: "Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array";
93
+ } | {
94
+ readonly alias: "-m, --mnemonic <phrase>";
95
+ readonly description: "Mnemonic to use with the action";
96
+ } | {
97
+ readonly alias: "-p, --private-key <key>";
98
+ readonly description: "Private key to use with the action";
99
+ })[];
100
+ export declare const globalOptions: ({
101
+ readonly alias: "-t, --token <type>";
102
+ readonly description: "Crypto token type for wallet or action";
103
+ readonly default: "arweave";
104
+ } | {
105
+ readonly alias: "-g, --gateway <url>";
106
+ readonly description: "Set a custom crypto gateway URL";
107
+ readonly default: undefined;
108
+ } | {
109
+ readonly alias: "--dev";
110
+ readonly description: "Enable development endpoints";
111
+ readonly default: false;
112
+ } | {
113
+ readonly alias: "--debug";
114
+ readonly description: "Enable verbose logging";
115
+ readonly default: false;
116
+ } | {
117
+ readonly alias: "--quiet";
118
+ readonly description: "Disable logging";
119
+ readonly default: false;
120
+ })[];
121
+ export declare const uploadFolderOptions: ({
122
+ readonly alias: "-w, --wallet-file <filePath>";
123
+ readonly description: "Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array";
124
+ } | {
125
+ readonly alias: "-m, --mnemonic <phrase>";
126
+ readonly description: "Mnemonic to use with the action";
127
+ } | {
128
+ readonly alias: "-p, --private-key <key>";
129
+ readonly description: "Private key to use with the action";
130
+ } | {
131
+ readonly alias: "-f, --folder-path <folderPath>";
132
+ readonly description: "Directory to upload";
133
+ } | {
134
+ readonly alias: "--index-file <indexFile>";
135
+ readonly description: "Index file to use in the manifest created for folder upload";
136
+ } | {
137
+ readonly alias: "--fallback-file <fallbackFile>";
138
+ readonly description: "Fallback file to use in the manifest created for folder upload";
139
+ } | {
140
+ readonly alias: "--no-manifest";
141
+ readonly description: "Disable manifest creation with --no-manifest";
142
+ readonly default: false;
143
+ } | {
144
+ readonly alias: "--max-concurrency <maxConcurrency>";
145
+ readonly description: "Maximum number of concurrent uploads";
146
+ })[];
147
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cli/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EZ,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;;IAIzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;IAMzB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;IAO/B,CAAC"}
@@ -34,4 +34,11 @@ export type TopUpOptions = AddressOptions & {
34
34
  value: string | undefined;
35
35
  currency: string | undefined;
36
36
  };
37
+ export type UploadFolderOptions = WalletOptions & {
38
+ folderPath: string;
39
+ indexFile: string | undefined;
40
+ fallbackFile: string | undefined;
41
+ manifest: boolean;
42
+ maxConcurrency: number | undefined;
43
+ };
37
44
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cli/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG;IAC1C,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cli/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG;IAC1C,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,CAAC"}
@@ -1,99 +1,30 @@
1
- import { Command } from 'commander';
1
+ import { Command, OptionValues } from 'commander';
2
2
  import { TokenType, TurboUnauthenticatedConfiguration } from '../node/index.js';
3
- import { GlobalOptions, WalletOptions } from './types.js';
3
+ import { AddressOptions, GlobalOptions, UploadFolderOptions, WalletOptions } from './types.js';
4
+ export declare function exitWithErrorLog(error: unknown): void;
5
+ export declare function runCommand<O extends OptionValues>(command: Command, action: (options: O) => Promise<void>): Promise<void>;
4
6
  interface CommanderOption {
5
7
  alias: string;
6
8
  description: string;
7
9
  default?: string | boolean;
8
10
  }
9
- export declare const optionMap: {
10
- readonly token: {
11
- readonly alias: "-t, --token <type>";
12
- readonly description: "Crypto token type for wallet or action";
13
- readonly default: "arweave";
14
- };
15
- readonly currency: {
16
- readonly alias: "-c, --currency <currency>";
17
- readonly description: "Fiat currency type to use for the action";
18
- readonly default: "usd";
19
- };
20
- readonly address: {
21
- readonly alias: "-a, --address <nativeAddress>";
22
- readonly description: "Native address to use for action";
23
- };
24
- readonly value: {
25
- readonly alias: "-v, --value <value>";
26
- readonly description: "Value of fiat currency or crypto token for action. e.g: 10.50 for $10.50 USD or 0.0001 for 0.0001 AR";
27
- };
28
- readonly walletFile: {
29
- readonly alias: "-w, --wallet-file <filePath>";
30
- readonly description: "Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array";
31
- };
32
- readonly mnemonic: {
33
- readonly alias: "-m, --mnemonic <phrase>";
34
- readonly description: "Mnemonic to use with the action";
35
- };
36
- readonly privateKey: {
37
- readonly alias: "-p, --private-key <key>";
38
- readonly description: "Private key to use with the action";
39
- };
40
- readonly gateway: {
41
- readonly alias: "-g, --gateway <url>";
42
- readonly description: "Set a custom crypto gateway URL";
43
- readonly default: undefined;
44
- };
45
- readonly dev: {
46
- readonly alias: "--dev";
47
- readonly description: "Enable development endpoints";
48
- readonly default: false;
49
- };
50
- readonly debug: {
51
- readonly alias: "--debug";
52
- readonly description: "Enable verbose logging";
53
- readonly default: false;
54
- };
55
- readonly quiet: {
56
- readonly alias: "--quiet";
57
- readonly description: "Disable logging";
58
- readonly default: false;
59
- };
60
- };
61
- export declare const walletOptions: ({
62
- readonly alias: "-w, --wallet-file <filePath>";
63
- readonly description: "Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array";
64
- } | {
65
- readonly alias: "-m, --mnemonic <phrase>";
66
- readonly description: "Mnemonic to use with the action";
67
- } | {
68
- readonly alias: "-p, --private-key <key>";
69
- readonly description: "Private key to use with the action";
70
- })[];
71
- export declare const globalOptions: ({
72
- readonly alias: "-t, --token <type>";
73
- readonly description: "Crypto token type for wallet or action";
74
- readonly default: "arweave";
75
- } | {
76
- readonly alias: "-g, --gateway <url>";
77
- readonly description: "Set a custom crypto gateway URL";
78
- readonly default: undefined;
79
- } | {
80
- readonly alias: "--dev";
81
- readonly description: "Enable development endpoints";
82
- readonly default: false;
83
- } | {
84
- readonly alias: "--debug";
85
- readonly description: "Enable verbose logging";
86
- readonly default: false;
87
- } | {
88
- readonly alias: "--quiet";
89
- readonly description: "Disable logging";
90
- readonly default: false;
91
- })[];
92
11
  export declare function applyOptions(command: Command, options: CommanderOption[]): Command;
93
12
  export declare function tokenFromOptions(options: unknown): TokenType;
94
13
  export declare function valueFromOptions(options: unknown): string;
14
+ export declare function getFolderPathFromOptions(options: unknown): string;
15
+ export declare function addressOrPrivateKeyFromOptions(options: AddressOptions): Promise<{
16
+ address: string | undefined;
17
+ privateKey: string | undefined;
18
+ }>;
95
19
  export declare function optionalPrivateKeyFromOptions(options: WalletOptions): Promise<string | undefined>;
96
20
  export declare function privateKeyFromOptions({ mnemonic, privateKey, walletFile, token, }: WalletOptions): Promise<string>;
97
21
  export declare function configFromOptions({ gateway, dev, token, }: GlobalOptions): TurboUnauthenticatedConfiguration;
22
+ export declare function getUploadFolderOptions(options: UploadFolderOptions): {
23
+ folderPath: string;
24
+ indexFile: string | undefined;
25
+ fallbackFile: string | undefined;
26
+ disableManifest: boolean;
27
+ maxConcurrentUploads: number;
28
+ };
98
29
  export {};
99
30
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cli/utils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,SAAS,EACT,iCAAiC,EAKlC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1D,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDZ,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;;IAIzB,CAAC;AAEF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AAI,EAAE,MAAM,GAAG,MAAM;IAKzC,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ;CAGvD"}
@@ -14,5 +14,5 @@
14
14
  * You should have received a copy of the GNU Affero General Public License
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
- export declare const version = "1.13.0-alpha.2";
17
+ export declare const version = "1.13.0";
18
18
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.13.0",
3
+ "version": "1.14.0-alpha.1",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",