@genobank/biofs 1.6.0 → 1.6.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.
@@ -1,417 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const login_1 = require("./commands/login");
10
- const logout_1 = require("./commands/logout");
11
- const whoami_1 = require("./commands/whoami");
12
- const files_1 = require("./commands/files");
13
- const download_with_consent_1 = require("./commands/download-with-consent");
14
- const upload_1 = require("./commands/upload");
15
- const mount_1 = require("./commands/mount");
16
- const tokenize_1 = require("./commands/tokenize");
17
- const request_1 = require("./commands/access/request");
18
- const grant_1 = require("./commands/access/grant");
19
- const revoke_1 = require("./commands/access/revoke");
20
- const list_1 = require("./commands/access/list");
21
- const check_1 = require("./commands/access/check");
22
- const revoke_consent_1 = require("./commands/access/revoke-consent");
23
- const create_1 = require("./commands/job/create");
24
- const status_1 = require("./commands/job/status");
25
- const results_1 = require("./commands/job/results");
26
- const list_2 = require("./commands/job/list");
27
- const pipelines_1 = require("./commands/job/pipelines");
28
- const logger_1 = require("./lib/utils/logger");
29
- const program = new commander_1.Command();
30
- // Set up the CLI
31
- program
32
- .name('biofs')
33
- .description('BioFS by GenoBank.io - BioNFT-Gated S3 CLI for genomic data')
34
- .version('1.5.2')
35
- .option('--debug', 'Enable debug output')
36
- .hook('preAction', (thisCommand) => {
37
- // Set global debug flag if --debug is passed
38
- const opts = thisCommand.opts();
39
- if (opts.debug) {
40
- process.env.DEBUG = '1';
41
- }
42
- });
43
- // Login command
44
- program
45
- .command('login')
46
- .description('Authenticate with GenoBank.io using Web3 signature')
47
- .option('--port <number>', 'Callback server port', parseInt)
48
- .option('--no-browser', "Don't auto-open browser")
49
- .option('--timeout <seconds>', 'Auth timeout in seconds', parseInt)
50
- .action(async (options) => {
51
- try {
52
- await (0, login_1.loginCommand)(options);
53
- }
54
- catch (error) {
55
- logger_1.Logger.error(`Login failed: ${error}`);
56
- process.exit(1);
57
- }
58
- });
59
- // Logout command
60
- program
61
- .command('logout')
62
- .description('Clear stored credentials')
63
- .action(async () => {
64
- try {
65
- await (0, logout_1.logoutCommand)();
66
- }
67
- catch (error) {
68
- logger_1.Logger.error(`Logout failed: ${error}`);
69
- process.exit(1);
70
- }
71
- });
72
- // Whoami command
73
- program
74
- .command('whoami')
75
- .description('Show current authenticated wallet')
76
- .option('--json', 'Output as JSON')
77
- .option('--verify', 'Verify signature validity')
78
- .option('--check <wallet>', 'Check against specific wallet address (e.g., Dra. Claudia: 0xb3c3a584491b8ca4df45116a1e250098a0d6192d)')
79
- .action(async (options) => {
80
- try {
81
- await (0, whoami_1.whoamiCommand)(options);
82
- }
83
- catch (error) {
84
- logger_1.Logger.error(`Error: ${error}`);
85
- process.exit(1);
86
- }
87
- });
88
- // Files command
89
- program
90
- .command('files')
91
- .alias('ls')
92
- .description('List your BioFiles from all sources')
93
- .option('--filter <type>', 'Filter by file type (vcf, fastq, bam, pdf, etc.)')
94
- .option('--source <source>', 'Filter by source (s3, ipfs, story)')
95
- .option('--json', 'Output as JSON')
96
- .option('--refresh', 'Clear cache and fetch fresh data')
97
- .option('--verbose', 'Show debug information')
98
- .action(async (options) => {
99
- try {
100
- await (0, files_1.filesCommand)(options);
101
- }
102
- catch (error) {
103
- logger_1.Logger.error(`Error listing files: ${error}`);
104
- process.exit(1);
105
- }
106
- });
107
- // Download command (with GDPR consent for genomic data)
108
- program
109
- .command('download <biocid_or_filename> [destination]')
110
- .alias('get')
111
- .description('Download a file (with GDPR consent for genomic data)')
112
- .option('--output <path>', 'Output file path')
113
- .option('--stream', 'Stream large files (>100MB)')
114
- .option('--quiet', 'No progress bar')
115
- .option('--skip-consent', 'Skip GDPR consent (for automation)')
116
- .action(async (biocidOrFilename, destination, options) => {
117
- try {
118
- await (0, download_with_consent_1.downloadCommandWithConsent)(biocidOrFilename, destination, options);
119
- }
120
- catch (error) {
121
- logger_1.Logger.error(`Download failed: ${error}`);
122
- process.exit(1);
123
- }
124
- });
125
- // Upload command
126
- program
127
- .command('upload <file>')
128
- .alias('put')
129
- .description('Upload a file to GenoBank')
130
- .option('--type <type>', 'File type (vcf, fastq, bam, pdf)')
131
- .option('--tokenize', 'Mint as NFT after upload')
132
- .option('--share-with <lab>', 'Share with lab after upload')
133
- .option('--public', 'Make publicly discoverable')
134
- .option('--quiet', 'No progress output')
135
- .action(async (filePath, options) => {
136
- try {
137
- await (0, upload_1.uploadCommand)(filePath, options);
138
- }
139
- catch (error) {
140
- logger_1.Logger.error(`Upload failed: ${error}`);
141
- process.exit(1);
142
- }
143
- });
144
- // Mount command (mount all granted BioFiles with GDPR consent)
145
- program
146
- .command('mount <mount_point>')
147
- .description('Mount all granted BioFiles to local directory (with GDPR consent)')
148
- .option('--read-only', 'Mount as read-only')
149
- .option('--quiet', 'Suppress output')
150
- .option('--skip-consent', 'Skip GDPR consent (for automation)')
151
- .action(async (mountPoint, options) => {
152
- try {
153
- await (0, mount_1.mountCommand)(mountPoint, options);
154
- }
155
- catch (error) {
156
- logger_1.Logger.error(`Mount failed: ${error}`);
157
- process.exit(1);
158
- }
159
- });
160
- // Tokenize command
161
- program
162
- .command('tokenize <file>')
163
- .description('Tokenize a genomic dataset as BioIP NFT on Story Protocol')
164
- .option('--title <string>', 'Custom title for the NFT')
165
- .option('--description <string>', 'Custom description (uses AI if not provided)')
166
- .option('--license <type>', 'License type: commercial, non-commercial', 'non-commercial')
167
- .option('--collection <address>', 'Manual collection address override')
168
- .option('--network <network>', 'Story Protocol network: mainnet, testnet', 'mainnet')
169
- .option('--no-ai', 'Skip AI classification')
170
- .option('--dryrun', 'Test validation and preview metadata without tokenizing')
171
- .option('--quiet', 'No interactive prompts')
172
- .option('--yes', 'Auto-confirm all prompts')
173
- .action(async (file, options) => {
174
- try {
175
- await (0, tokenize_1.tokenizeCommand)(file, options);
176
- }
177
- catch (error) {
178
- logger_1.Logger.error(`Tokenization failed: ${error}`);
179
- process.exit(1);
180
- }
181
- });
182
- // Access control commands (v1.2.0)
183
- const accessCmd = program
184
- .command('access')
185
- .description('Manage BioNFT access control and permissions');
186
- // access request
187
- accessCmd
188
- .command('request <biocid_or_ip_id>')
189
- .description('Request access to a BioNFT asset')
190
- .option('--message <string>', 'Optional message to asset owner')
191
- .action(async (biocidOrIpId, options) => {
192
- try {
193
- await (0, request_1.accessRequestCommand)(biocidOrIpId, options);
194
- }
195
- catch (error) {
196
- logger_1.Logger.error(`Access request failed: ${error}`);
197
- process.exit(1);
198
- }
199
- });
200
- // access grant
201
- accessCmd
202
- .command('grant <biocid_or_ip_id> <wallet_address>')
203
- .description('Grant access to a wallet address (owner only)')
204
- .option('--expires-in <duration>', 'Access expiry duration (e.g., 30d, 90d)')
205
- .action(async (biocidOrIpId, walletAddress, options) => {
206
- try {
207
- await (0, grant_1.accessGrantCommand)(biocidOrIpId, walletAddress, options);
208
- }
209
- catch (error) {
210
- logger_1.Logger.error(`Access grant failed: ${error}`);
211
- process.exit(1);
212
- }
213
- });
214
- // access revoke
215
- accessCmd
216
- .command('revoke <biocid_or_ip_id> <wallet_address>')
217
- .description('Revoke access from a wallet address (owner only)')
218
- .option('--yes', 'Skip confirmation prompt')
219
- .action(async (biocidOrIpId, walletAddress, options) => {
220
- try {
221
- await (0, revoke_1.accessRevokeCommand)(biocidOrIpId, walletAddress, options);
222
- }
223
- catch (error) {
224
- logger_1.Logger.error(`Access revocation failed: ${error}`);
225
- process.exit(1);
226
- }
227
- });
228
- // access list
229
- accessCmd
230
- .command('list [biocid_or_ip_id]')
231
- .description('List permittees for an asset, or assets you can access')
232
- .option('--mine', 'List assets you have permission to access')
233
- .option('--status <status>', 'Filter by status: active, pending, revoked')
234
- .option('--json', 'Output as JSON')
235
- .action(async (biocidOrIpId, options) => {
236
- try {
237
- await (0, list_1.accessListCommand)(biocidOrIpId, options);
238
- }
239
- catch (error) {
240
- logger_1.Logger.error(`List failed: ${error}`);
241
- process.exit(1);
242
- }
243
- });
244
- // access check
245
- accessCmd
246
- .command('check <biocid_or_ip_id>')
247
- .description('Check your access level to a BioNFT asset')
248
- .action(async (biocidOrIpId) => {
249
- try {
250
- await (0, check_1.accessCheckCommand)(biocidOrIpId);
251
- }
252
- catch (error) {
253
- logger_1.Logger.error(`Access check failed: ${error}`);
254
- process.exit(1);
255
- }
256
- });
257
- // access revoke-consent (user withdraws their own consent - GDPR)
258
- accessCmd
259
- .command('revoke-consent [ip_id]')
260
- .description('Revoke your consent for genomic data access (GDPR right to withdraw)')
261
- .option('--all', 'Revoke all consents')
262
- .option('--force', 'Skip confirmation')
263
- .action(async (ipId, options) => {
264
- try {
265
- await (0, revoke_consent_1.revokeConsentCommand)(ipId, options);
266
- }
267
- catch (error) {
268
- logger_1.Logger.error(`Consent revocation failed: ${error}`);
269
- process.exit(1);
270
- }
271
- });
272
- // Job management commands (BioOS)
273
- const jobCmd = program
274
- .command('job')
275
- .description('Manage research jobs (BioOS)');
276
- // job create
277
- jobCmd
278
- .command('create <prompt> <file>')
279
- .description('Create a research job from natural language prompt')
280
- .option('--pipeline <template>', 'Use predefined pipeline template')
281
- .option('--json', 'Output as JSON')
282
- .action(async (prompt, fileRef, options) => {
283
- try {
284
- await (0, create_1.jobCreateCommand)(prompt, fileRef, options);
285
- }
286
- catch (error) {
287
- logger_1.Logger.error(`Job creation failed: ${error}`);
288
- process.exit(1);
289
- }
290
- });
291
- // job status
292
- jobCmd
293
- .command('status <job_id>')
294
- .description('Check job execution status')
295
- .option('--json', 'Output as JSON')
296
- .option('--watch', 'Watch mode (refresh every 5 seconds)')
297
- .action(async (jobId, options) => {
298
- try {
299
- await (0, status_1.jobStatusCommand)(jobId, options);
300
- }
301
- catch (error) {
302
- logger_1.Logger.error(`Status check failed: ${error}`);
303
- process.exit(1);
304
- }
305
- });
306
- // job results
307
- jobCmd
308
- .command('results <job_id>')
309
- .description('Get job results with download URLs')
310
- .option('--json', 'Output as JSON')
311
- .option('--step <number>', 'Download specific step only', parseInt)
312
- .action(async (jobId, options) => {
313
- try {
314
- await (0, results_1.jobResultsCommand)(jobId, options);
315
- }
316
- catch (error) {
317
- logger_1.Logger.error(`Failed to get results: ${error}`);
318
- process.exit(1);
319
- }
320
- });
321
- // job list
322
- jobCmd
323
- .command('list')
324
- .description('List all your research jobs')
325
- .option('--json', 'Output as JSON')
326
- .option('--status <status>', 'Filter by status (pending, running, completed, failed)')
327
- .option('--limit <number>', 'Limit number of results', parseInt)
328
- .action(async (options) => {
329
- try {
330
- await (0, list_2.jobListCommand)(options);
331
- }
332
- catch (error) {
333
- logger_1.Logger.error(`Failed to list jobs: ${error}`);
334
- process.exit(1);
335
- }
336
- });
337
- // job pipelines
338
- jobCmd
339
- .command('pipelines')
340
- .alias('templates')
341
- .description('List available pipeline templates')
342
- .option('--json', 'Output as JSON')
343
- .action(async (options) => {
344
- try {
345
- await (0, pipelines_1.pipelinesCommand)(options);
346
- }
347
- catch (error) {
348
- logger_1.Logger.error(`Failed to list pipelines: ${error}`);
349
- process.exit(1);
350
- }
351
- });
352
- // Help command
353
- program
354
- .command('help [command]')
355
- .description('Display help for a command')
356
- .action((cmd) => {
357
- if (cmd) {
358
- const command = program.commands.find(c => c.name() === cmd);
359
- if (command) {
360
- command.outputHelp();
361
- }
362
- else {
363
- logger_1.Logger.error(`Unknown command: ${cmd}`);
364
- }
365
- }
366
- else {
367
- program.outputHelp();
368
- }
369
- });
370
- // Show welcome message if no command
371
- if (process.argv.length === 2) {
372
- console.log(chalk_1.default.cyan('\n╔════════════════════════════════════╗'));
373
- console.log(chalk_1.default.cyan('║ BioFS CLI v1.5.2 ║'));
374
- console.log(chalk_1.default.cyan('║ BioNFT-Gated S3 CLI ║'));
375
- console.log(chalk_1.default.cyan('╚════════════════════════════════════╝\n'));
376
- console.log('Available commands:');
377
- console.log(` ${chalk_1.default.green('login')} - Authenticate with Web3 wallet`);
378
- console.log(` ${chalk_1.default.green('logout')} - Clear credentials`);
379
- console.log(` ${chalk_1.default.green('whoami')} - Show current wallet`);
380
- console.log(` ${chalk_1.default.green('files')} - List your BioFiles`);
381
- console.log(` ${chalk_1.default.green('download')} - Download files (GDPR consent)`);
382
- console.log(` ${chalk_1.default.green('mount')} - Mount all files (GDPR consent)`);
383
- console.log(` ${chalk_1.default.green('upload')} - Upload files`);
384
- console.log(` ${chalk_1.default.green('tokenize')} - Tokenize as BioIP NFT`);
385
- console.log(` ${chalk_1.default.green('access')} - Manage BioNFT access control`);
386
- console.log(` ${chalk_1.default.green('job')} - Manage research jobs (BioOS)`);
387
- console.log(` ${chalk_1.default.green('help')} - Show help\n`);
388
- console.log('Access control subcommands:');
389
- console.log(` ${chalk_1.default.cyan('access request')} <biocid> - Request access to asset`);
390
- console.log(` ${chalk_1.default.cyan('access grant')} <biocid> <wallet> - Grant access (owner)`);
391
- console.log(` ${chalk_1.default.cyan('access revoke')} <biocid> <wallet> - Revoke access (owner)`);
392
- console.log(` ${chalk_1.default.cyan('access list')} [biocid] - List permittees or permissions`);
393
- console.log(` ${chalk_1.default.cyan('access check')} <biocid> - Check your access level`);
394
- console.log(` ${chalk_1.default.cyan('access revoke-consent')} [ip_id] - Revoke YOUR consent (GDPR)\n`);
395
- console.log('Research job subcommands (BioOS):');
396
- console.log(` ${chalk_1.default.cyan('job create')} "<prompt>" <file> - Create research job`);
397
- console.log(` ${chalk_1.default.cyan('job status')} <job_id> - Check job status`);
398
- console.log(` ${chalk_1.default.cyan('job results')} <job_id> - Get job results`);
399
- console.log(` ${chalk_1.default.cyan('job list')} - List all jobs`);
400
- console.log(` ${chalk_1.default.cyan('job pipelines')} - List pipeline templates\n`);
401
- console.log(`Run ${chalk_1.default.cyan('biofs help <command>')} for detailed usage.\n`);
402
- }
403
- else {
404
- // Parse command line arguments
405
- program.parse(process.argv);
406
- }
407
- // Handle uncaught errors
408
- process.on('unhandledRejection', (error) => {
409
- logger_1.Logger.error(`Unexpected error: ${error}`);
410
- process.exit(1);
411
- });
412
- process.on('SIGINT', () => {
413
- console.log('\n\nInterrupted. Goodbye!');
414
- // Give inquirer time to clean up before exiting
415
- setTimeout(() => process.exit(0), 100);
416
- });
417
- //# sourceMappingURL=index.js.map