@tigrisdata/cli 3.1.0 → 3.3.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.
package/README.md CHANGED
@@ -222,6 +222,8 @@ tigris mk <path> [flags]
222
222
  | `-a, --access` | Access level (only applies when creating a bucket) (default: private) |
223
223
  | `--public` | Shorthand for --access public (only applies when creating a bucket) |
224
224
  | `-s, --enable-snapshots` | Enable snapshots for the bucket (only applies when creating a bucket) (default: false) |
225
+ | `--allow-object-acl` | Allow per-object ACLs on the bucket (only applies when creating a bucket) (default: false) |
226
+ | `--enable-directory-listing` | Enable directory listing, relevant for public buckets (only applies when creating a bucket) (default: false) |
225
227
  | `-t, --default-tier` | Default storage tier (only applies when creating a bucket) (default: STANDARD) |
226
228
  | `-l, --locations` | Location for the bucket (only applies when creating a bucket) (default: global) |
227
229
  | `-fork, --fork-of` | Create this bucket as a fork (copy-on-write clone) of the named source bucket |
@@ -231,6 +233,8 @@ tigris mk <path> [flags]
231
233
  ```bash
232
234
  tigris mk my-bucket
233
235
  tigris mk my-bucket --access public --region iad
236
+ tigris mk my-bucket --allow-object-acl
237
+ tigris mk my-bucket --public --enable-directory-listing
234
238
  tigris mk my-bucket/images/
235
239
  tigris mk t3://my-bucket
236
240
  tigris mk my-fork --fork-of my-bucket
@@ -287,6 +291,7 @@ tigris presign <path> [flags]
287
291
  | `--access-key` | Access key ID to use for signing. If not provided, resolved from credentials or auto-selected |
288
292
  | `--select` | Interactively select an access key (OAuth only) |
289
293
  | `--format` | Output format (default: url) |
294
+ | `-snapshot, --snapshot-version` | Read from a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464). Only supported for GET requests. |
290
295
 
291
296
  **Examples:**
292
297
  ```bash
@@ -307,10 +312,12 @@ tigris cp <src> <dest> [flags]
307
312
  | Flag | Description |
308
313
  |------|-------------|
309
314
  | `-r, --recursive` | Copy directories recursively |
315
+ | `-a, --access` | Access level for uploaded objects (only applies to local-to-remote uploads) |
310
316
 
311
317
  **Examples:**
312
318
  ```bash
313
319
  tigris cp ./file.txt t3://my-bucket/file.txt
320
+ tigris cp ./logo.png t3://my-bucket/logo.png --access public
314
321
  tigris cp t3://my-bucket/file.txt ./local-copy.txt
315
322
  tigris cp t3://my-bucket/src/ t3://my-bucket/dest/ -r
316
323
  tigris cp ./images/ t3://my-bucket/images/ -r
@@ -445,7 +452,10 @@ Create, inspect, update, and delete buckets. Buckets are top-level containers th
445
452
  | `tigris buckets create` (c) | Create a new bucket with optional access, tier, and location settings |
446
453
  | `tigris buckets get` (g) | Show details for a bucket including access level, region, tier, and custom domain |
447
454
  | `tigris buckets delete` (d) | Delete one or more buckets by name. The bucket must be empty or delete-protection must be off |
455
+ | `tigris buckets restore` | Restore a soft-deleted bucket within its retention window. List recoverable buckets with "tigris buckets list --deleted" |
448
456
  | `tigris buckets set` (s) | Update settings on an existing bucket such as access level, location, caching, or custom domain |
457
+ | `tigris buckets enable-snapshots` | Enable snapshots on an existing bucket, converting it to a snapshot bucket |
458
+ | `tigris buckets disable-snapshots` | Disable snapshots on an existing bucket, converting it back to a regular bucket. Rejected while the bucket has dependent forks |
449
459
  | `tigris buckets set-locations` | Set the data locations for a bucket |
450
460
  | `tigris buckets set-migration` | Configure data migration from an external S3-compatible source bucket. Tigris will pull objects on demand from the source |
451
461
  | `tigris buckets migrate` | Actively migrate all objects from a shadow bucket to Tigris by scheduling server-side migration for unmigrated objects |
@@ -465,6 +475,7 @@ tigris buckets list [flags]
465
475
  |------|-------------|
466
476
  | `--format` | Output format (default: table) |
467
477
  | `--forks-of` | Only list buckets that are forks of the named source bucket |
478
+ | `--deleted` | Only list soft-deleted buckets |
468
479
  | `--limit` | Maximum number of items to return per page |
469
480
  | `-pt, --page-token` | Pagination token from a previous request to fetch the next page |
470
481
 
@@ -473,6 +484,7 @@ tigris buckets list [flags]
473
484
  tigris buckets list
474
485
  tigris buckets list --format json
475
486
  tigris buckets list --forks-of my-bucket
487
+ tigris buckets list --deleted
476
488
  ```
477
489
 
478
490
  #### `tigris buckets create` (c)
@@ -488,6 +500,8 @@ tigris buckets create [name] [flags]
488
500
  | `-a, --access` | Access level (default: private) |
489
501
  | `--public` | Shorthand for --access public |
490
502
  | `-s, --enable-snapshots` | Enable snapshots for the bucket (default: false) |
503
+ | `--allow-object-acl` | Allow per-object ACLs on the bucket (default: false) |
504
+ | `--enable-directory-listing` | Enable directory listing, relevant for public buckets (default: false) |
491
505
  | `-t, --default-tier` | Choose the default tier for the bucket (default: STANDARD) |
492
506
  | `-l, --locations` | Location for the bucket (default: global) |
493
507
  | `-fork, --fork-of` | Create this bucket as a fork (copy-on-write clone) of the named source bucket |
@@ -498,6 +512,8 @@ tigris buckets create [name] [flags]
498
512
  tigris buckets create my-bucket
499
513
  tigris buckets create my-bucket --access public --locations iad
500
514
  tigris buckets create my-bucket --enable-snapshots --default-tier STANDARD_IA
515
+ tigris buckets create my-bucket --allow-object-acl
516
+ tigris buckets create my-bucket --public --enable-directory-listing
501
517
  tigris buckets create my-fork --fork-of my-bucket
502
518
  tigris buckets create my-fork --fork-of my-bucket --source-snapshot 1765889000501544464
503
519
  ```
@@ -537,6 +553,19 @@ tigris buckets delete my-bucket --yes
537
553
  tigris buckets delete bucket-a,bucket-b --yes
538
554
  ```
539
555
 
556
+ #### `tigris buckets restore`
557
+
558
+ Restore a soft-deleted bucket within its retention window. List recoverable buckets with "tigris buckets list --deleted"
559
+
560
+ ```
561
+ tigris buckets restore <name>
562
+ ```
563
+
564
+ **Examples:**
565
+ ```bash
566
+ tigris buckets restore my-bucket
567
+ ```
568
+
540
569
  #### `tigris buckets set` (s)
541
570
 
542
571
  Update settings on an existing bucket such as access level, location, caching, or custom domain
@@ -554,6 +583,8 @@ tigris buckets set <name> [flags]
554
583
  | `--cache-control` | Default cache-control header value |
555
584
  | `--custom-domain` | Custom domain for the bucket |
556
585
  | `--enable-delete-protection` | Enable delete protection |
586
+ | `--soft-delete` | Enable or disable soft delete (recoverable deletes). Requires --retention-days when enabling |
587
+ | `--retention-days` | Number of days to retain soft-deleted objects (required when enabling --soft-delete) |
557
588
  | `--enable-additional-headers` | Enable additional HTTP headers (X-Content-Type-Options nosniff) |
558
589
 
559
590
  **Examples:**
@@ -561,6 +592,34 @@ tigris buckets set <name> [flags]
561
592
  tigris buckets set my-bucket --access public
562
593
  tigris buckets set my-bucket --locations iad,fra --cache-control 'max-age=3600'
563
594
  tigris buckets set my-bucket --custom-domain assets.example.com
595
+ tigris buckets set my-bucket --soft-delete enable --retention-days 30
596
+ tigris buckets set my-bucket --soft-delete disable
597
+ ```
598
+
599
+ #### `tigris buckets enable-snapshots`
600
+
601
+ Enable snapshots on an existing bucket, converting it to a snapshot bucket
602
+
603
+ ```
604
+ tigris buckets enable-snapshots <name>
605
+ ```
606
+
607
+ **Examples:**
608
+ ```bash
609
+ tigris buckets enable-snapshots my-bucket
610
+ ```
611
+
612
+ #### `tigris buckets disable-snapshots`
613
+
614
+ Disable snapshots on an existing bucket, converting it back to a regular bucket. Rejected while the bucket has dependent forks
615
+
616
+ ```
617
+ tigris buckets disable-snapshots <name>
618
+ ```
619
+
620
+ **Examples:**
621
+ ```bash
622
+ tigris buckets disable-snapshots my-bucket
564
623
  ```
565
624
 
566
625
  #### `tigris buckets set-locations`
@@ -815,6 +874,8 @@ Low-level object operations for listing, downloading, uploading, and deleting in
815
874
  | `tigris objects set` (s) | (Deprecated) Update settings on an existing object such as access level. Use `tigris objects set-access` for ACL changes and `tigris mv` to rename |
816
875
  | `tigris objects set-access` (sa) | Set the access level (public or private) on an existing object |
817
876
  | `tigris objects info` (i) | Show metadata for an object (content type, size, modified date) |
877
+ | `tigris objects restore` (rs) | Restore an archived object (e.g. one in the GLACIER tier) into an actively-readable copy for a number of days |
878
+ | `tigris objects restore-info` (ri) | Show the restore state of an archived object (archived, in-progress, or restored) |
818
879
 
819
880
  #### `tigris objects list` (l)
820
881
 
@@ -993,6 +1054,46 @@ tigris objects info my-bucket report.pdf --format json
993
1054
  tigris objects info my-bucket report.pdf --version-id abc123
994
1055
  ```
995
1056
 
1057
+ #### `tigris objects restore` (rs)
1058
+
1059
+ Restore an archived object (e.g. one in the GLACIER tier) into an actively-readable copy for a number of days
1060
+
1061
+ ```
1062
+ tigris objects restore <bucket> [key] [flags]
1063
+ ```
1064
+
1065
+ | Flag | Description |
1066
+ |------|-------------|
1067
+ | `-d, --days` | How many days the restored copy stays available before reverting to its archived tier (default: 1) |
1068
+ | `--version-id` | Restore a specific object version (requires bucket versioning). Omit to restore the current version |
1069
+ | `--format` | Output format (default: table) |
1070
+
1071
+ **Examples:**
1072
+ ```bash
1073
+ tigris objects restore my-bucket archived.bin
1074
+ tigris objects restore my-bucket archived.bin --days 3
1075
+ tigris objects restore t3://my-bucket/archived.bin --days 7
1076
+ ```
1077
+
1078
+ #### `tigris objects restore-info` (ri)
1079
+
1080
+ Show the restore state of an archived object (archived, in-progress, or restored)
1081
+
1082
+ ```
1083
+ tigris objects restore-info <bucket> [key] [flags]
1084
+ ```
1085
+
1086
+ | Flag | Description |
1087
+ |------|-------------|
1088
+ | `--version-id` | Inspect a specific object version (requires bucket versioning). Omit to read the current version |
1089
+ | `--format` | Output format (default: table) |
1090
+
1091
+ **Examples:**
1092
+ ```bash
1093
+ tigris objects restore-info my-bucket archived.bin
1094
+ tigris objects restore-info t3://my-bucket/archived.bin --format json
1095
+ ```
1096
+
996
1097
  ### `tigris access-keys` (keys)
997
1098
 
998
1099
  Create, list, inspect, delete, and assign roles to access keys. Access keys are credentials used for programmatic API access
@@ -1175,6 +1276,7 @@ Identity and Access Management - manage policies, users, and permissions
1175
1276
  |---------|-------------|
1176
1277
  | `tigris iam policies` (p) | Manage IAM policies. Policies define permissions for access keys |
1177
1278
  | `tigris iam users` (u) | Manage organization users and invitations |
1279
+ | `tigris iam teams` (t) | Manage organization teams |
1178
1280
 
1179
1281
  #### `tigris iam policies` (p)
1180
1282
 
@@ -1448,6 +1550,75 @@ tigris iam users remove user@example.com --yes
1448
1550
  tigris iam users remove user@example.com,user@example.net --yes
1449
1551
  ```
1450
1552
 
1553
+ #### `tigris iam teams` (t)
1554
+
1555
+ Manage organization teams
1556
+
1557
+ | Command | Description |
1558
+ |---------|-------------|
1559
+ | `tigris iam teams list` (l) | List all teams in the organization |
1560
+ | `tigris iam teams create` (c) | Create a new team in the organization |
1561
+ | `tigris iam teams edit` (e) | Update a team's name, description, or members. Members are replaced with the provided list |
1562
+
1563
+ ##### `tigris iam teams list` (l)
1564
+
1565
+ List all teams in the organization
1566
+
1567
+ ```
1568
+ tigris iam teams list [flags]
1569
+ ```
1570
+
1571
+ | Flag | Description |
1572
+ |------|-------------|
1573
+ | `--format` | Output format (default: table) |
1574
+
1575
+ **Examples:**
1576
+ ```bash
1577
+ tigris iam teams list
1578
+ tigris iam teams list --format json
1579
+ ```
1580
+
1581
+ ##### `tigris iam teams create` (c)
1582
+
1583
+ Create a new team in the organization
1584
+
1585
+ ```
1586
+ tigris iam teams create <name> [flags]
1587
+ ```
1588
+
1589
+ | Flag | Description |
1590
+ |------|-------------|
1591
+ | `-d, --description` | Description for the team |
1592
+ | `-m, --members` | Member email address(es) to add (comma-separated for multiple) |
1593
+
1594
+ **Examples:**
1595
+ ```bash
1596
+ tigris iam teams create engineering
1597
+ tigris iam teams create engineering --description 'Engineering team'
1598
+ tigris iam teams create engineering --members a@example.com,b@example.com
1599
+ ```
1600
+
1601
+ ##### `tigris iam teams edit` (e)
1602
+
1603
+ Update a team's name, description, or members. Members are replaced with the provided list
1604
+
1605
+ ```
1606
+ tigris iam teams edit <id> [flags]
1607
+ ```
1608
+
1609
+ | Flag | Description |
1610
+ |------|-------------|
1611
+ | `-n, --name` | New name for the team |
1612
+ | `-d, --description` | New description for the team |
1613
+ | `-m, --members` | Replace the team's members with these email address(es) (comma-separated for multiple) |
1614
+
1615
+ **Examples:**
1616
+ ```bash
1617
+ tigris iam teams edit team_id --name platform
1618
+ tigris iam teams edit team_id --description 'Platform team'
1619
+ tigris iam teams edit team_id --members a@example.com,b@example.com
1620
+ ```
1621
+
1451
1622
  ## License
1452
1623
 
1453
1624
  MIT
@@ -0,0 +1 @@
1
+ import{b as n}from"./chunk-UBANDLB4.js";function o(s,e){if(e===void 0)return;let t=(Array.isArray(e)?e:[e]).map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0);return t.length===0&&n(s,"--members requires at least one email address"),t}export{o as a};
@@ -1,4 +1,4 @@
1
- import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{mkdirSync as w,readFileSync as _,realpathSync as E,writeFileSync as I}from"fs";import x from"https";import{homedir as g}from"os";import{join as h}from"path";var u="3.1.0";var b=h(g(),".tigris","update-check.json");function y(){try{let e=_(b,"utf-8"),n=JSON.parse(e);return typeof n.latestVersion=="string"&&typeof n.lastChecked=="number"?n:null}catch{return null}}function v(e){try{w(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function T(e,n){let a=i=>{let s=i.startsWith("v")?i.slice(1):i,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(e),t=a(n);return!r||!t?!1:t.major>r.major?!0:t.major<r.major?!1:t.minor>r.minor?!0:t.minor<r.minor?!1:t.patch>r.patch?!0:t.patch<r.patch?!1:r.prerelease&&!t.prerelease?!0:(!r.prerelease&&t.prerelease,!1)}function N(){if(process.platform==="win32")return!1;try{let e=E(process.execPath);return e.includes("/Cellar/")||e.includes("/Caskroom/")}catch{return!1}}function M(){return globalThis.__TIGRIS_BINARY===!0?N()?"brew upgrade tigris":process.platform==="win32"?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function k(e={}){return new Promise((n,a)=>{let r=x.get(m,{timeout:1e4},t=>{let i="";t.on("data",s=>{i+=s}),t.on("end",()=>{try{let s=JSON.parse(i);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),n(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",t=>{a(t)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),e.unref&&r.on("socket",t=>{t.unref()}),r.end()})}function j(){k({unref:!0}).catch(()=>{})}function O(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),n=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(e&&T(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>n)){let r=`Update available: ${u} \u2192 ${e.latestVersion}`,t='Run "tigris update" to upgrade.',i=Math.max(r.length,t.length)+4,s="\u250C"+"\u2500".repeat(i-2)+"\u2510",l="\u2514"+"\u2500".repeat(i-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(i-4)+" \u2502";console.log(`
1
+ import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{mkdirSync as w,readFileSync as _,realpathSync as E,writeFileSync as I}from"fs";import x from"https";import{homedir as g}from"os";import{join as h}from"path";var u="3.3.0";var b=h(g(),".tigris","update-check.json");function y(){try{let e=_(b,"utf-8"),n=JSON.parse(e);return typeof n.latestVersion=="string"&&typeof n.lastChecked=="number"?n:null}catch{return null}}function v(e){try{w(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function T(e,n){let a=i=>{let s=i.startsWith("v")?i.slice(1):i,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(e),t=a(n);return!r||!t?!1:t.major>r.major?!0:t.major<r.major?!1:t.minor>r.minor?!0:t.minor<r.minor?!1:t.patch>r.patch?!0:t.patch<r.patch?!1:r.prerelease&&!t.prerelease?!0:(!r.prerelease&&t.prerelease,!1)}function N(){if(process.platform==="win32")return!1;try{let e=E(process.execPath);return e.includes("/Cellar/")||e.includes("/Caskroom/")}catch{return!1}}function M(){return globalThis.__TIGRIS_BINARY===!0?N()?"brew upgrade tigris":process.platform==="win32"?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function k(e={}){return new Promise((n,a)=>{let r=x.get(m,{timeout:1e4},t=>{let i="";t.on("data",s=>{i+=s}),t.on("end",()=>{try{let s=JSON.parse(i);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),n(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",t=>{a(t)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),e.unref&&r.on("socket",t=>{t.unref()}),r.end()})}function j(){k({unref:!0}).catch(()=>{})}function O(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),n=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(e&&T(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>n)){let r=`Update available: ${u} \u2192 ${e.latestVersion}`,t='Run "tigris update" to upgrade.',i=Math.max(r.length,t.length)+4,s="\u250C"+"\u2500".repeat(i-2)+"\u2510",l="\u2514"+"\u2500".repeat(i-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(i-4)+" \u2502";console.log(`
2
2
  ${s}
3
3
  ${o("")}
4
4
  ${o(r)}
@@ -1 +1 @@
1
- import{a as s,f as l}from"./chunk-GLKOUVFH.js";import{a as i,k as m}from"./chunk-G4DHMSCQ.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
1
+ import{a as s,f as l}from"./chunk-BVSVEXGE.js";import{a as i,k as m}from"./chunk-G4DHMSCQ.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-WE7KHYIP.js";import"./chunk-GLKOUVFH.js";import"./chunk-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
2
+ import"./chunk-JW6HI5E4.js";import"./chunk-BVSVEXGE.js";import"./chunk-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-WE7KHYIP.js";import"./chunk-GLKOUVFH.js";import"./chunk-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
1
+ import"./chunk-JW6HI5E4.js";import"./chunk-BVSVEXGE.js";import"./chunk-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
@@ -1 +1 @@
1
- import{a as D,c as N}from"../../chunk-N3Y6RFSK.js";import{a as C}from"../../chunk-S77OAN6Y.js";import{d as q}from"../../chunk-YN2TKPPT.js";import{a as t,b as L}from"../../chunk-S6KFKBMY.js";import{b as i,c as T,d as w}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as y,j as B}from"../../chunk-7ZUCJBD5.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as R}from"@tigrisdata/storage";import E from"enquirer";var{prompt:j}=E,a=B("buckets","create");async function F(e){x(a);let O=L(e),s=t(e,["name"]),d=t(e,["public"])?"public":t(e,["access","a","A"]),b=t(e,["enable-snapshots","s","S"]),h=t(e,["default-tier","t","T"]),P=t(e,["locations","l","L"]),o=t(e,["fork-of","forkOf","fork"]),l=t(e,["source-snapshot","sourceSnapshot","source-snap"]),I=!s,S;if(I){C("Provide --name to skip interactive mode");let n=p("buckets","access","create"),r=g(n),f=r?.findIndex(c=>c.value===n?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(c=>c.value===v?.default),u=await j([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:r||[],initial:f!==void 0&&f>=0?f:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,d=u.access,h=u.defaultTier,b=u.enableSnapshots;try{S=await D()}catch(c){i(a,c)}}s||i(a,"Bucket name is required"),l&&!o&&i(a,"--source-snapshot requires --fork-of");let{error:k}=await R(s,{defaultTier:h??"STANDARD",enableSnapshot:b===!0,access:d??"private",locations:S??N(P??"global"),...o?{sourceBucketName:o}:{},...l?{sourceBucketSnapshot:l}:{},config:await q()});if(k&&i(a,k),O==="json"){let n=T(a,{name:s}),r={action:"created",name:s,...o?{forkOf:o}:{}};n.length>0&&(r.nextActions=n),console.log(JSON.stringify(r))}y(a,{name:s}),w(a,{name:s})}export{F as default};
1
+ import{a as C,c as j}from"../../chunk-N3Y6RFSK.js";import{a as B}from"../../chunk-S77OAN6Y.js";import{d as T}from"../../chunk-YN2TKPPT.js";import{a as t,b as O}from"../../chunk-S6KFKBMY.js";import{b as i,c as x,d as D}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as v,j as L}from"../../chunk-7ZUCJBD5.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as E}from"@tigrisdata/storage";import F from"enquirer";var{prompt:J}=F,a=L("buckets","create");async function W(e){w(a);let q=O(e),s=t(e,["name"]),d=t(e,["public"])?"public":t(e,["access","a","A"]),b=t(e,["enable-snapshots","s","S"]),N=t(e,["allow-object-acl","allowObjectAcl"]),P=t(e,["enable-directory-listing","enableDirectoryListing"]),h=t(e,["default-tier","t","T"]),I=t(e,["locations","l","L"]),c=t(e,["fork-of","forkOf","fork"]),u=t(e,["source-snapshot","sourceSnapshot","source-snap"]),R=!s,S;if(R){B("Provide --name to skip interactive mode");let o=p("buckets","access","create"),n=g(o),f=n?.findIndex(r=>r.value===o?.default),y=p("buckets","default-tier","create"),A=g(y),m=A?.findIndex(r=>r.value===y?.default),l=await J([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:n||[],initial:f!==void 0&&f>=0?f:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=l.name,d=l.access,h=l.defaultTier,b=l.enableSnapshots;try{S=await C()}catch(r){i(a,r)}}s||i(a,"Bucket name is required"),u&&!c&&i(a,"--source-snapshot requires --fork-of");let{error:k}=await E(s,{defaultTier:h??"STANDARD",enableSnapshot:b===!0,allowObjectAcl:N===!0,enableDirectoryListing:P===!0,access:d??"private",locations:S??j(I??"global"),...c?{sourceBucketName:c}:{},...u?{sourceBucketSnapshot:u}:{},config:await T()});if(k&&i(a,k),q==="json"){let o=x(a,{name:s}),n={action:"created",name:s,...c?{forkOf:c}:{}};o.length>0&&(n.nextActions=o),console.log(JSON.stringify(n))}v(a,{name:s}),D(a,{name:s})}export{W as default};
@@ -0,0 +1 @@
1
+ import{e as m}from"../../chunk-YN2TKPPT.js";import{a as f,b as c}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as a,j as e}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{disableSnapshot as l}from"@tigrisdata/storage";var o=e("buckets","disable-snapshots");async function d(n){s(o);let g=c(n),t=f(n,["name"]);t||i(o,"Bucket name is required");let p=await m(),{error:r}=await l(t,{config:p});r&&i(o,r),g==="json"&&console.log(JSON.stringify({action:"snapshots-disabled",name:t})),a(o,{name:t})}export{d as default};
@@ -0,0 +1 @@
1
+ import{e as m}from"../../chunk-YN2TKPPT.js";import{a as f,b as c}from"../../chunk-S6KFKBMY.js";import{b as n}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as e,c as a,j as s}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{enableSnapshot as l}from"@tigrisdata/storage";var o=s("buckets","enable-snapshots");async function u(r){e(o);let g=c(r),t=f(r,["name"]);t||n(o,"Bucket name is required");let p=await m(),{error:i}=await l(t,{config:p});i&&n(o,i),g==="json"&&console.log(JSON.stringify({action:"snapshots-enabled",name:t})),a(o,{name:t})}export{u as default};
@@ -1 +1 @@
1
- import{f as D,g as E}from"../../chunk-IRDNZN7R.js";import{d as C}from"../../chunk-YN2TKPPT.js";import{a as u,b as T,c as x}from"../../chunk-S6KFKBMY.js";import{b as d}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as y,c as f,e as c,i as O,j as P}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listBuckets as A,listForks as B}from"@tigrisdata/storage";var t=P("buckets","list");async function H(o){y(t);let n=T(o),r=u(o,["forks-of","forksOf"]),i=u(o,["deleted"]),{limit:k,pageToken:m,isPaginated:S}=x(o),g=await C();if(r&&S&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)"),r&&i&&console.warn("\u26A0 --deleted is ignored when --forks-of is used; use --deleted on its own to list soft-deleted buckets"),r){let{data:e,error:b}=await B(r,{config:g});if(b&&d(t,b),!e.forks||e.forks.length===0){c(t);return}let s=[];for(let w of e.forks)s.push({name:w.name,created:w.creationDate});let j=D(s,n,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(j),f(t,{count:s.length});return}let{data:a,error:l}=await A({...k!==void 0?{limit:k}:{},...m?{paginationToken:m}:{},...i?{deleted:i}:{},config:g});if(l&&d(t,l),!a.buckets||a.buckets.length===0){c(t);return}let p=a.buckets.map(e=>({name:e.name,created:e.creationDate})),F=[{key:"name",header:"Name"},{key:"created",header:"Created"}],h=a.paginationToken||void 0,N=E(p,n,"buckets","bucket",F,{paginationToken:h});console.log(N),n!=="json"&&n!=="xml"&&O(h),f(t,{count:p.length})}export{H as default};
1
+ import{g as l}from"../../chunk-IRDNZN7R.js";import{d as j}from"../../chunk-YN2TKPPT.js";import{a as g,b as P,c as S}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as D,c as d,e as k,i as u,j as E}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listBuckets as A,listForks as B}from"@tigrisdata/storage";var e=E("buckets","list");async function H(o){D(e);let n=P(o),s=g(o,["forks-of","forksOf"]),c=g(o,["deleted"]),{limit:r,pageToken:i}=S(o),p=await j();s&&c&&console.warn("\u26A0 --deleted is ignored when --forks-of is used; use --deleted on its own to list soft-deleted buckets");let b=[{key:"name",header:"Name"},{key:"created",header:"Created"}];if(s){let{data:t,error:x}=await B(s,{...r!==void 0?{limit:r}:{},...i?{paginationToken:i}:{},config:p});if(x&&m(e,x),!t.forks||t.forks.length===0){k(e);return}let f=[];for(let O of t.forks)f.push({name:O.name,created:O.creationDate});let y=t.paginationToken||void 0,F=l(f,n,"forks","fork",b,{paginationToken:y});console.log(F),n!=="json"&&n!=="xml"&&u(y),d(e,{count:f.length});return}let{data:a,error:h}=await A({...r!==void 0?{limit:r}:{},...i?{paginationToken:i}:{},...c?{deleted:c}:{},config:p});if(h&&m(e,h),!a.buckets||a.buckets.length===0){k(e);return}let T=a.buckets.map(t=>({name:t.name,created:t.creationDate})),w=a.paginationToken||void 0,C=l(T,n,"buckets","bucket",b,{paginationToken:w});console.log(C),n!=="json"&&n!=="xml"&&u(w),d(e,{count:T.length})}export{H as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as G}from"../chunk-EKW6XTGL.js";import{a as D}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-IRDNZN7R.js";import{a as U,b as v,d as C,f as O,g as J,i as j}from"../chunk-RXNG56FL.js";import{d as K}from"../chunk-YN2TKPPT.js";import{a as x,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as P,get as tt,head as et,list as ot,put as V}from"@tigrisdata/storage";import{createReadStream as it,createWriteStream as nt,existsSync as X,mkdirSync as rt,readdirSync as A,statSync as z}from"fs";import{homedir as at}from"os";import{basename as E,dirname as L,join as N,relative as _,resolve as H}from"path";import{Readable as Y}from"stream";import{pipeline as lt}from"stream/promises";var h=!1;function ct(i,t){let e=U(i),r=U(t);return!e&&!r&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&r?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(at(),i.slice(2)):H(i)}function st(i){return A(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let r=e.parentPath??e.path;return N(r,e.name)})}function pt(i,t){let e=L(i),r=E(i),c=O(r);return X(e)?t?A(e,{recursive:!0,withFileTypes:!0}).filter(a=>a.isFile()&&c.test(a.name)).map(a=>{let o=a.parentPath??a.path;return N(o,a.name)}):A(e,{withFileTypes:!0}).filter(o=>o.isFile()&&c.test(o.name)).map(o=>N(e,o.name)):[]}async function B(i,t,e,r,c=!1){let p;try{p=z(i).size}catch{return{error:`File not found: ${i}`}}let a=it(i),o=Y.toWeb(a),n=q(i),{error:l}=await V(e,o,{...G(p),...n?{contentType:n}:{},onUploadProgress:c?({loaded:u})=>{if(p!==void 0&&p>0){let s=Math.round(u/p*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(p)} (${s}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...r,bucket:t}});return c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),l?{error:l.message}:{}}async function Q(i,t,e,r,c=!1){let p;if(c){let{data:s}=await et(t,{config:{...r,bucket:i}});p=s?.size}let{data:a,error:o}=await tt(t,"stream",{config:{...r,bucket:i}});if(o)return{error:o.message};let n=L(e);X(n)||rt(n,{recursive:!0});let l=nt(e),u=Y.fromWeb(a);if(c&&p!==void 0&&p>0){let s=0;u.on("data",m=>{s+=m.length;let d=Math.round(s/p*100);process.stdout.write(`\rDownloading: ${R(s)} / ${R(p)} (${d}%)`)})}return await lt(u,l),c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function I(i,t,e,r,c){if(e.endsWith("/")){let{error:a}=await V(c,"",{config:{...i,bucket:r}});return a?{error:a.message}:{}}let{error:p}=await P(e,c,{srcBucket:t,destBucket:r,config:{...i,bucket:r}});return p?{error:p.message}:{}}async function ut(i,t,e,r){let c=Z(i);if(i.includes("*")){let o=pt(c,r);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let n=L(c),l=o.map(m=>async()=>{let d=_(n,m),w=t.path?`${t.path.replace(/\/$/,"")}/${d}`:d,y=await B(m,t.bucket,w,e);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${w}`),!0)}),s=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:s}):`Uploaded ${s} file(s)`);return}let a;try{a=z(c)}catch{f(`Source not found: ${i}`)}if(a.isDirectory()){r||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let o=st(c);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let n=i.endsWith("/")?"":E(c),l=o.map(m=>async()=>{let d=_(c,m),y=[t.path?.replace(/\/$/,""),n,d].filter(Boolean).join("/"),F=await B(m,t.bucket,y,e);return F.error?(console.error(`Failed to upload ${m}: ${F.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${y}`),!0)}),s=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:s}):`Uploaded ${s} file(s)`)}else{let o=E(c),n;t.path?i.endsWith("/")||t.path.endsWith("/")?n=`${t.path.replace(/\/$/,"")}/${o}`:await C(t.bucket,t.path,e)?n=`${t.path}/${o}`:n=t.path:n=o;let l=await B(c,t.bucket,n,e,!h);l.error&&f(l.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${n}`}):`Uploaded ${i} -> t3://${t.bucket}/${n}`)}}async function ft(i,t,e,r,c){let p=i.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=Z(e),o=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&p;if(!o&&!n&&(n=await C(t.bucket,t.path,r)),n&&!o&&!c&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||n){let l=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",u=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:s,error:m}=await j(t.bucket,l||void 0,r);m&&f(m);let d=s.filter($=>!$.name.endsWith("/"));if(o){let $=t.path.split("/").pop(),b=O($);d=d.filter(k=>{let g=l?k.name.slice(l.length):k.name;return!c&&g.includes("/")?!1:b.test(g.split("/").pop())})}if(d.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=d.map($=>async()=>{let b=l?$.name.slice(l.length):$.name,k=u?N(a,u,b):N(a,b),g=await Q(t.bucket,$.name,k,r);return g.error?(console.error(`Failed to download ${$.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${$.name} -> ${k}`),!0)}),F=(await D(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:F}):`Downloaded ${F} file(s)`)}else{let l=t.path.split("/").pop(),u,s=!1;try{s=z(a).isDirectory()}catch{}s||e.endsWith("/")?u=N(a,l):u=a;let m=await Q(t.bucket,t.path,u,r,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:u}):`Downloaded t3://${t.bucket}/${t.path} -> ${u}`)}}async function mt(i,t,e,r,c){let p=i.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=i.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!a&&!o&&t.path&&(o=await C(t.bucket,t.path,r)),o&&!a&&!c&&f("Source is a remote folder (not copied). Use -r to copy recursively."),a||o){let n=a?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",l=!a&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",s=[e.path?.replace(/\/$/,"")||"",l].filter(Boolean).join("/"),m=s?`${s}/`:"";t.bucket===e.bucket&&n===m&&f("Source and destination are the same");let{items:d,error:w}=await j(t.bucket,n||void 0,r);w&&f(w);let y=d.filter(g=>g.name!==n);if(a){let g=t.path.split("/").pop(),S=O(g);y=y.filter(W=>{let T=n?W.name.slice(n.length):W.name;return!c&&T.includes("/")?!1:S.test(T.split("/").pop())})}let F=y.map(g=>async()=>{let S=n?g.name.slice(n.length):g.name,W=s?`${s}/${S}`:S,T=await I(r,t.bucket,g.name,e.bucket,W);return T.error?(console.error(`Failed to copy ${g.name}: ${T.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${W}`),!0)}),b=(await D(F,8)).filter(Boolean).length,k=!1;if(s&&n){let{data:g}=await ot({prefix:n,limit:1,config:{...r,bucket:t.bucket}});if(g?.items?.some(S=>S.name===n)){let S=`${s}/`,W=await I(r,t.bucket,n,e.bucket,S);W.error?console.error(`Failed to copy folder marker: ${W.error}`):k=!0}}if(b===0&&k&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let n=t.path.split("/").pop(),l;e.path?e.path.endsWith("/")?l=`${e.path}${n}`:await C(e.bucket,e.path,r)?l=`${e.path}/${n}`:l=e.path:l=n,t.bucket===e.bucket&&t.path===l&&f("Source and destination are the same");let u=await I(r,t.bucket,t.path,e.bucket,l);u.error&&f(u.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${l}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${l}`)}}async function ht(i){let t=x(i,["src"]),e=x(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let r=!!x(i,["recursive","r"]);h=M(i)==="json";let p=ct(t,e),a=await K({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=v(e);o.bucket||f("Invalid destination path"),await ut(t,o,a,r);break}case"remote-to-local":{let o=v(t);o.bucket||f("Invalid source path"),await ft(t,o,e,a,r);break}case"remote-to-remote":{let o=v(t),n=v(e);o.bucket||f("Invalid source path"),n.bucket||f("Invalid destination path"),await mt(t,o,n,a,r);break}}process.exit(0)}export{ht as default};
1
+ import{a as G}from"../chunk-EKW6XTGL.js";import{a as x}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-IRDNZN7R.js";import{a as U,b as C,d as D,f as O,g as j,i as A}from"../chunk-RXNG56FL.js";import{d as K}from"../chunk-YN2TKPPT.js";import{a as T,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as P,get as tt,head as et,list as ot,put as V}from"@tigrisdata/storage";import{createReadStream as it,createWriteStream as nt,existsSync as X,mkdirSync as rt,readdirSync as I,statSync as z}from"fs";import{homedir as at}from"os";import{basename as E,dirname as L,join as v,relative as _,resolve as H}from"path";import{Readable as Y}from"stream";import{pipeline as lt}from"stream/promises";var h=!1;function ct(i,t){let e=U(i),a=U(t);return!e&&!a&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&a?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(at(),i.slice(2)):H(i)}function st(i){return I(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let a=e.parentPath??e.path;return v(a,e.name)})}function pt(i,t){let e=L(i),a=E(i),p=O(a);return X(e)?t?I(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&p.test(r.name)).map(r=>{let l=r.parentPath??r.path;return v(l,r.name)}):I(e,{withFileTypes:!0}).filter(l=>l.isFile()&&p.test(l.name)).map(l=>v(e,l.name)):[]}async function J(i,t,e,a,p=!1,c){let r;try{r=z(i).size}catch{return{error:`File not found: ${i}`}}let l=it(i),n=Y.toWeb(l),o=q(i),{error:s}=await V(e,n,{...G(r),...o?{contentType:o}:{},...c?{access:c}:{},onUploadProgress:p?({loaded:u})=>{if(r!==void 0&&r>0){let d=Math.round(u/r*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(r)} (${d}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...a,bucket:t}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),s?{error:s.message}:{}}async function Q(i,t,e,a,p=!1){let c;if(p){let{data:u}=await et(t,{config:{...a,bucket:i}});c=u?.size}let{data:r,error:l}=await tt(t,"stream",{config:{...a,bucket:i}});if(l)return{error:l.message};let n=L(e);X(n)||rt(n,{recursive:!0});let o=nt(e),s=Y.fromWeb(r);if(p&&c!==void 0&&c>0){let u=0;s.on("data",d=>{u+=d.length;let m=Math.round(u/c*100);process.stdout.write(`\rDownloading: ${R(u)} / ${R(c)} (${m}%)`)})}return await lt(s,o),p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function B(i,t,e,a,p){if(e.endsWith("/")){let{error:r}=await V(p,"",{config:{...i,bucket:a}});return r?{error:r.message}:{}}let{error:c}=await P(e,p,{srcBucket:t,destBucket:a,config:{...i,bucket:a}});return c?{error:c.message}:{}}async function ut(i,t,e,a,p){let c=Z(i);if(i.includes("*")){let n=pt(c,a);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let o=L(c),s=n.map(m=>async()=>{let w=_(o,m),k=t.path?`${t.path.replace(/\/$/,"")}/${w}`:w,b=await J(m,t.bucket,k,e,!1,p);return b.error?(console.error(`Failed to upload ${m}: ${b.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`);return}let l;try{l=z(c)}catch{f(`Source not found: ${i}`)}if(l.isDirectory()){a||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let n=st(c);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let o=i.endsWith("/")?"":E(c),s=n.map(m=>async()=>{let w=_(c,m),b=[t.path?.replace(/\/$/,""),o,w].filter(Boolean).join("/"),y=await J(m,t.bucket,b,e,!1,p);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${b}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`)}else{let n=E(c),o;t.path?i.endsWith("/")||t.path.endsWith("/")?o=`${t.path.replace(/\/$/,"")}/${n}`:await D(t.bucket,t.path,e)?o=`${t.path}/${n}`:o=t.path:o=n;let s=await J(c,t.bucket,o,e,!h,p);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${o}`}):`Uploaded ${i} -> t3://${t.bucket}/${o}`)}}async function ft(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=Z(e),l=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&c;if(!l&&!n&&(n=await D(t.bucket,t.path,a)),n&&!l&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),l||n){let o=l?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",s=!l&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:d}=await A(t.bucket,o||void 0,a);d&&f(d);let m=u.filter(y=>!y.name.endsWith("/"));if(l){let y=t.path.split("/").pop(),$=O(y);m=m.filter(S=>{let g=o?S.name.slice(o.length):S.name;return!p&&g.includes("/")?!1:$.test(g.split("/").pop())})}if(m.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=m.map(y=>async()=>{let $=o?y.name.slice(o.length):y.name,S=s?v(r,s,$):v(r,$),g=await Q(t.bucket,y.name,S,a);return g.error?(console.error(`Failed to download ${y.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),b=(await x(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:b}):`Downloaded ${b} file(s)`)}else{let o=t.path.split("/").pop(),s,u=!1;try{u=z(r).isDirectory()}catch{}u||e.endsWith("/")?s=v(r,o):s=r;let d=await Q(t.bucket,t.path,s,a,!h);d.error&&f(d.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:s}):`Downloaded t3://${t.bucket}/${t.path} -> ${s}`)}}async function mt(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=i.includes("*"),l=t.path.endsWith("/")||!t.path&&c;if(!r&&!l&&t.path&&(l=await D(t.bucket,t.path,a)),l&&!r&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||l){let n=r?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",o=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),d=u?`${u}/`:"";t.bucket===e.bucket&&n===d&&f("Source and destination are the same");let{items:m,error:w}=await A(t.bucket,n||void 0,a);w&&f(w);let k=m.filter(g=>g.name!==n);if(r){let g=t.path.split("/").pop(),W=O(g);k=k.filter(F=>{let N=n?F.name.slice(n.length):F.name;return!p&&N.includes("/")?!1:W.test(N.split("/").pop())})}let b=k.map(g=>async()=>{let W=n?g.name.slice(n.length):g.name,F=u?`${u}/${W}`:W,N=await B(a,t.bucket,g.name,e.bucket,F);return N.error?(console.error(`Failed to copy ${g.name}: ${N.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${F}`),!0)}),$=(await x(b,8)).filter(Boolean).length,S=!1;if(u&&n){let{data:g}=await ot({prefix:n,limit:1,config:{...a,bucket:t.bucket}});if(g?.items?.some(W=>W.name===n)){let W=`${u}/`,F=await B(a,t.bucket,n,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if($===0&&S&&($=1),$===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:$}):`Copied ${$} object(s)`)}else{let n=t.path.split("/").pop(),o;e.path?e.path.endsWith("/")?o=`${e.path}${n}`:await D(e.bucket,e.path,a)?o=`${e.path}/${n}`:o=e.path:o=n,t.bucket===e.bucket&&t.path===o&&f("Source and destination are the same");let s=await B(a,t.bucket,t.path,e.bucket,o);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${o}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${o}`)}}async function ht(i){let t=T(i,["src"]),e=T(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let a=!!T(i,["recursive","r"]),p=T(i,["access","a","A"]);h=M(i)==="json";let r;p===void 0?r=void 0:p==="public"||p==="private"?r=p:f('Access level must be either "public" or "private"');let l=ct(t,e);r!==void 0&&l!=="local-to-remote"&&f('--access only applies to local-to-remote uploads. Use "tigris objects set-access" to change access on existing objects.');let n=await K({withCredentialProvider:!0});switch(l){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await ut(t,o,n,a,r);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await ft(t,o,e,n,a);break}case"remote-to-remote":{let o=C(t),s=C(e);o.bucket||f("Invalid source path"),s.bucket||f("Invalid destination path"),await mt(t,o,s,n,a);break}}process.exit(0)}export{ht as default};
@@ -1 +1 @@
1
- import{a as J}from"../../../chunk-S7EO4QWK.js";import{a}from"../../../chunk-TUDALPGD.js";import{a as h}from"../../../chunk-EFPPY2JQ.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YN2TKPPT.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
1
+ import{a}from"../../../chunk-TUDALPGD.js";import{a as J}from"../../../chunk-S7EO4QWK.js";import{a as h}from"../../../chunk-EFPPY2JQ.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YN2TKPPT.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
@@ -0,0 +1 @@
1
+ import{a as b}from"../../../chunk-2ITYREA5.js";import{a as l}from"../../../chunk-EFPPY2JQ.js";import"../../../chunk-YN2TKPPT.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as g,j as d}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as p}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{createTeam as y}from"@tigrisdata/iam";var t=d("iam teams","create");async function O(e){f(t);let I=u(e);if(p("Team management"))return;let r=n(e,["name"]),i=n(e,["description","d"]),a=typeof i=="string"?i:void 0,m=b(t,n(e,["members","m"]));r||o(t,"Team name is required");let w=await l(t),{data:s,error:c}=await y({name:r,...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:w});if(c&&o(t,c),I==="json"){console.log(JSON.stringify({action:"created",teamId:s.teamId,name:r}));return}g(t,{name:r}),console.log(`Team ID: ${s.teamId}`)}export{O as default};
@@ -0,0 +1 @@
1
+ import{a as w}from"../../../chunk-2ITYREA5.js";import{a as b}from"../../../chunk-EFPPY2JQ.js";import"../../../chunk-YN2TKPPT.js";import{a as t,b as l}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as g,j as u}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as p}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{editTeam as I}from"@tigrisdata/iam";var e=u("iam teams","edit");async function R(n){c(e);let y=l(n);if(p("Team management"))return;let i=t(n,["id"]);i||o(e,"Team ID is required");let s=t(n,["name","n"]),r=typeof s=="string"?s:void 0,d=t(n,["description","d"]),a=typeof d=="string"?d:void 0,m=w(e,t(n,["members","m"]));r===void 0&&a===void 0&&m===void 0&&o(e,"Provide at least one of --name, --description, or --members to update");let O=await b(e),{error:f}=await I(i,{...r!==void 0?{name:r}:{},...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:O});f&&o(e,f),y==="json"&&console.log(JSON.stringify({action:"updated",teamId:i})),g(e,{id:i})}export{R as default};
@@ -0,0 +1 @@
1
+ import{a as p}from"../../../chunk-EFPPY2JQ.js";import{b as g,d as u,e as h}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-YN2TKPPT.js";import{b as d}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,e as s,j as c}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as f}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{listTeams as k}from"@tigrisdata/iam";var t=c("iam teams","list");async function C(y){a(t);let r=d(y);if(f("Team management"))return;let b=await p(t),{data:o,error:m}=await k({config:b});if(m&&l(t,m),o.teams.length===0){s(t);return}let n=o.teams.map(e=>({id:e.id,name:e.name,description:e.description||"-",members:e.members.length,created:e.createdAt}));console.log(r==="json"?g({teams:o.teams}):r==="xml"?u(n,"teams","team"):h(n,[{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"members",header:"Members"},{key:"created",header:"Created"}])),i(t,{count:o.teams.length})}export{C as default};
@@ -0,0 +1 @@
1
+ import{a}from"../../../chunk-2ITYREA5.js";import"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";export{a as parseMembers};
package/dist/lib/mk.js CHANGED
@@ -1 +1 @@
1
- import{c as d}from"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import{e as m}from"../chunk-RXNG56FL.js";import{d as h}from"../chunk-YN2TKPPT.js";import{a as e,b as g}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{createBucket as y,put as O}from"@tigrisdata/storage";async function T(t){let l=e(t,["path"]);l||s("path argument is required");let{bucket:o,path:r}=m(l);o||s("Invalid path");let f=await h(),u=g(t);if(r){let a=r.endsWith("/")?r:`${r}/`,{error:c}=await O(a,"",{config:{...f,bucket:o}});c&&s(c),console.log(u==="json"?JSON.stringify({action:"created",type:"folder",bucket:o,path:a}):`Folder '${o}/${a}' created`),process.exit(0)}else{let c=e(t,["public"])?"public":e(t,["access","a","A"]),b=e(t,["enableSnapshots","enable-snapshots","s","S"]),S=e(t,["defaultTier","default-tier","t","T"]),k=e(t,["locations","l","L"]),n=e(t,["fork-of","forkOf","fork"]),i=e(t,["source-snapshot","sourceSnapshot","source-snap"]);i&&!n&&s("--source-snapshot requires --fork-of");let{error:p}=await y(o,{defaultTier:S??"STANDARD",enableSnapshot:b===!0,access:c??"private",locations:d(k??"global"),...n?{sourceBucketName:n}:{},...i?{sourceBucketSnapshot:i}:{},config:f});p&&s(p),console.log(u==="json"?JSON.stringify({action:"created",type:"bucket",name:o}):`Bucket '${o}' created`),process.exit(0)}}export{T as default};
1
+ import{c as m}from"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import{e as h}from"../chunk-RXNG56FL.js";import{d as b}from"../chunk-YN2TKPPT.js";import{a as t,b as p}from"../chunk-S6KFKBMY.js";import{a as r}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{createBucket as O,put as A}from"@tigrisdata/storage";async function j(e){let l=t(e,["path"]);l||r("path argument is required");let{bucket:o,path:a}=h(l);o||r("Invalid path");let f=await b(),u=p(e);if(a){let s=a.endsWith("/")?a:`${a}/`,{error:c}=await A(s,"",{config:{...f,bucket:o}});c&&r(c),console.log(u==="json"?JSON.stringify({action:"created",type:"folder",bucket:o,path:s}):`Folder '${o}/${s}' created`),process.exit(0)}else{let c=t(e,["public"])?"public":t(e,["access","a","A"]),d=t(e,["enableSnapshots","enable-snapshots","s","S"]),S=t(e,["allow-object-acl","allowObjectAcl"]),k=t(e,["enable-directory-listing","enableDirectoryListing"]),y=t(e,["defaultTier","default-tier","t","T"]),w=t(e,["locations","l","L"]),n=t(e,["fork-of","forkOf","fork"]),i=t(e,["source-snapshot","sourceSnapshot","source-snap"]);i&&!n&&r("--source-snapshot requires --fork-of");let{error:g}=await O(o,{defaultTier:y??"STANDARD",enableSnapshot:d===!0,allowObjectAcl:S===!0,enableDirectoryListing:k===!0,access:c??"private",locations:m(w??"global"),...n?{sourceBucketName:n}:{},...i?{sourceBucketSnapshot:i}:{},config:f});g&&r(g),console.log(u==="json"?JSON.stringify({action:"created",type:"bucket",name:o}):`Bucket '${o}' created`),process.exit(0)}}export{j as default};
@@ -0,0 +1 @@
1
+ import{f as v}from"../../chunk-IRDNZN7R.js";import{h as y}from"../../chunk-RXNG56FL.js";import{d}from"../../chunk-YN2TKPPT.js";import{a as n,b as k}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as g,e as p,j as l}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{getRestoreInfo as x}from"@tigrisdata/storage";var t=l("objects","restore-info");async function A(r){u(t);let s=k(r),c=n(r,["bucket"]),S=n(r,["key"]),a=n(r,["version-id","versionId"]);c||i(t,"Bucket name or path is required");let{bucket:f,key:e}=y(c,S);e||i(t,"Object key is required");let b=await d(),{data:o,error:m}=await x(e,{...a?{versionId:a}:{},config:{...b,bucket:f}});if(m&&i(t,m),!o){s==="json"?console.log(JSON.stringify({status:null})):p(t);return}let O=[{metric:"Path",value:e},{metric:"Status",value:o.status},...o.expiresAt?[{metric:"Expires",value:o.expiresAt.toISOString()}]:[]],h=v(O,s,"restore-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(h),g(t,{bucket:f,key:e})}export{A as default};
@@ -0,0 +1 @@
1
+ import{h as k}from"../../chunk-RXNG56FL.js";import{d as y}from"../../chunk-YN2TKPPT.js";import{a as i,b}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as d,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{restoreObject as v}from"@tigrisdata/storage";var r=u("objects","restore");async function O(t){a(r);let p=b(t),c=i(t,["bucket"]),l=i(t,["key"]),f=i(t,["version-id","versionId"]),g=i(t,["days","d"]);c||o(r,"Bucket name or path is required");let{bucket:s,key:n}=k(c,l);n||o(r,"Object key is required");let e;g!==void 0&&(e=Number(g),(!Number.isInteger(e)||e<1)&&o(r,"--days must be a positive integer"));let j=await y(),{error:m}=await v(n,{...e!==void 0?{days:e}:{},...f?{versionId:f}:{},config:{...j,bucket:s}});m&&o(r,m),p==="json"&&console.log(JSON.stringify({action:"restore-requested",bucket:s,key:n,days:e??1})),d(r,{key:n,bucket:s})}export{O as default};
@@ -1,3 +1,3 @@
1
- import{b as A}from"../chunk-IRDNZN7R.js";import{e as w}from"../chunk-RXNG56FL.js";import{a as k,d as K}from"../chunk-YN2TKPPT.js";import{a as g,b as h}from"../chunk-S6KFKBMY.js";import{a as n}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{c as p}from"../chunk-3EAZ2L6H.js";import{i as y,p as u}from"../chunk-OHGCOC5Q.js";import{listAccessKeys as C}from"@tigrisdata/iam";import{getPresignedUrl as P}from"@tigrisdata/storage";import $ from"enquirer";var{prompt:b}=$;async function T(s){let r=g(s,["path"]);r||n("path argument is required");let{bucket:c,path:e}=w(r);c||n("Invalid path"),e||n("Object key is required");let i=g(s,["method","m"])??"get",t=parseInt(g(s,["expires-in","expiresIn","e"])??"3600",10),l=h(s,"url"),o=g(s,["access-key","accessKey"]),x=g(s,["select"]),f=await K(),a;o?a=o:f.accessKeyId?a=f.accessKeyId:(u()!=="oauth"&&n("Presigning requires an access key. Pass --access-key or configure credentials."),x?a=await E(c,i):a=await q(c,i)),a||n("Presigning requires an access key. Pass --access-key or configure credentials.");let{data:d,error:m}=await P(e,{method:i,expiresIn:t,accessKeyId:a,config:{...f,bucket:c}});m&&n(m),console.log(l==="json"?A({url:d.url,expiresIn:d.expiresIn,method:i,bucket:c,key:e}):d.url),process.exit(0)}async function v(){let r=await p().getAccessToken(),c=y(),e=k(),{data:i,error:t}=await C({config:{sessionToken:r,organizationId:c??void 0,iamEndpoint:e.iamEndpoint}});return t&&n(t),(!i.accessKeys||i.accessKeys.length===0)&&n('No access keys found. Create one with "tigris access-keys create <name>"'),i.accessKeys}function I(s,r,c){return s.roles?s.roles.some(e=>e.role==="NamespaceAdmin"?!0:e.bucket!==r&&e.bucket!=="*"?!1:c==="put"?e.role==="Editor":e.role==="Editor"||e.role==="ReadOnly"):!1}async function q(s,r){let e=(await v()).filter(t=>t.status==="active");e.length===0&&n('No active access keys found. Create one with "tigris access-keys create <name>"');let i=e.find(t=>I(t,s,r));return i||n(`No access key with ${r==="put"?"Editor":"Editor or ReadOnly"} access to bucket "${s}" found.
1
+ import{b as A}from"../chunk-IRDNZN7R.js";import{e as v}from"../chunk-RXNG56FL.js";import{a as K,d as w}from"../chunk-YN2TKPPT.js";import{a,b as k}from"../chunk-S6KFKBMY.js";import{a as n}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{c as h}from"../chunk-3EAZ2L6H.js";import{i as m,p}from"../chunk-OHGCOC5Q.js";import{listAccessKeys as P}from"@tigrisdata/iam";import{getPresignedUrl as T}from"@tigrisdata/storage";import $ from"enquirer";var{prompt:b}=$;async function q(s){let r=a(s,["path"]);r||n("path argument is required");let{bucket:o,path:e}=v(r);o||n("Invalid path"),e||n("Object key is required");let t=a(s,["method","m"])??"get",i=parseInt(a(s,["expires-in","expiresIn","e"])??"3600",10),l=k(s,"url"),c=a(s,["access-key","accessKey"]),C=a(s,["select"]),f=a(s,["snapshot-version","snapshotVersion","snapshot"]);f&&t!=="get"&&n("Snapshot version is only supported for GET requests");let d=await w(),g;c?g=c:d.accessKeyId?g=d.accessKeyId:(p()!=="oauth"&&n("Presigning requires an access key. Pass --access-key or configure credentials."),C?g=await O(o,t):g=await E(o,t)),g||n("Presigning requires an access key. Pass --access-key or configure credentials.");let{data:u,error:y}=await T(e,{method:t,expiresIn:i,accessKeyId:g,...f?{snapshotVersion:f}:{},config:{...d,bucket:o}});y&&n(y),console.log(l==="json"?A({url:u.url,expiresIn:u.expiresIn,method:t,bucket:o,key:e}):u.url),process.exit(0)}async function I(){let r=await h().getAccessToken(),o=m(),e=K(),{data:t,error:i}=await P({config:{sessionToken:r,organizationId:o??void 0,iamEndpoint:e.iamEndpoint}});return i&&n(i),(!t.accessKeys||t.accessKeys.length===0)&&n('No access keys found. Create one with "tigris access-keys create <name>"'),t.accessKeys}function x(s,r,o){return s.roles?s.roles.some(e=>e.role==="NamespaceAdmin"?!0:e.bucket!==r&&e.bucket!=="*"?!1:o==="put"?e.role==="Editor":e.role==="Editor"||e.role==="ReadOnly"):!1}async function E(s,r){let e=(await I()).filter(i=>i.status==="active");e.length===0&&n('No active access keys found. Create one with "tigris access-keys create <name>"');let t=e.find(i=>x(i,s,r));return t||n(`No access key with ${r==="put"?"Editor":"Editor or ReadOnly"} access to bucket "${s}" found.
2
2
  Create one: tigris access-keys create <name>
3
- Then assign: tigris access-keys assign <id> --bucket ${s} --role Editor`),console.error(`Using access key: ${i.name} (${i.id})`),i.id}async function E(s,r){process.stdin.isTTY||n("Interactive selection requires a TTY. Omit --select to auto-resolve, or pass --access-key tid_...");let e=(await v()).filter(o=>o.status==="active");e.length===0&&n('No active access keys found. Create one with "tigris access-keys create <name>"');let i=e.filter(o=>I(o,s,r)),t;if(i.length>0?t=i:(console.error(`No access keys with explicit access to bucket "${s}" found. Showing all active keys.`),t=e),t.length===1)return console.error(`Using access key: ${t[0].name} (${t[0].id})`),t[0].id;let{selectedKey:l}=await b({type:"select",name:"selectedKey",message:"Select an access key for presigning:",choices:t.map(o=>({name:o.id,message:`${o.name} (${o.id})`}))});return l}export{T as default,I as keyMatchesOperation};
3
+ Then assign: tigris access-keys assign <id> --bucket ${s} --role Editor`),console.error(`Using access key: ${t.name} (${t.id})`),t.id}async function O(s,r){process.stdin.isTTY||n("Interactive selection requires a TTY. Omit --select to auto-resolve, or pass --access-key tid_...");let e=(await I()).filter(c=>c.status==="active");e.length===0&&n('No active access keys found. Create one with "tigris access-keys create <name>"');let t=e.filter(c=>x(c,s,r)),i;if(t.length>0?i=t:(console.error(`No access keys with explicit access to bucket "${s}" found. Showing all active keys.`),i=e),i.length===1)return console.error(`Using access key: ${i[0].name} (${i[0].id})`),i[0].id;let{selectedKey:l}=await b({type:"select",name:"selectedKey",message:"Select an access key for presigning:",choices:i.map(c=>({name:c.id,message:`${c.name} (${c.id})`}))});return l}export{q as default,x as keyMatchesOperation};
@@ -1 +1 @@
1
- import{b as d}from"../chunk-S6KFKBMY.js";import{a as t,c as l,d as p,e as f}from"../chunk-GLKOUVFH.js";import{b as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as s,c as i,f as a,j as c}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{execSync as h}from"child_process";var r=c("update");async function v(u={}){let g=d(u);s(r);try{let o=await f(),e=l(t,o),n=p();if(g==="json"){console.log(JSON.stringify({currentVersion:t,latestVersion:o,updateAvailable:e,updateCommand:n}));return}console.log(`Current version: ${t}`),e?(console.log(`Latest version: ${o}`),console.log("Updating..."),h(n,{stdio:"inherit",...process.platform==="win32"?{shell:"powershell.exe"}:{}}),i(r,{latestVersion:o})):a(r,{currentVersion:t})}catch(o){m(r,o)}}export{v as default};
1
+ import{b as d}from"../chunk-S6KFKBMY.js";import{a as t,c as l,d as p,e as f}from"../chunk-BVSVEXGE.js";import{b as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as s,c as i,f as a,j as c}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{execSync as h}from"child_process";var r=c("update");async function v(u={}){let g=d(u);s(r);try{let o=await f(),e=l(t,o),n=p();if(g==="json"){console.log(JSON.stringify({currentVersion:t,latestVersion:o,updateAvailable:e,updateCommand:n}));return}console.log(`Current version: ${t}`),e?(console.log(`Latest version: ${o}`),console.log("Updating..."),h(n,{stdio:"inherit",...process.platform==="win32"?{shell:"powershell.exe"}:{}}),i(r,{latestVersion:o})):a(r,{currentVersion:t})}catch(o){m(r,o)}}export{v as default};
package/dist/specs.yaml CHANGED
@@ -298,6 +298,8 @@ commands:
298
298
  examples:
299
299
  - "tigris mk my-bucket"
300
300
  - "tigris mk my-bucket --access public --region iad"
301
+ - "tigris mk my-bucket --allow-object-acl"
302
+ - "tigris mk my-bucket --public --enable-directory-listing"
301
303
  - "tigris mk my-bucket/images/"
302
304
  - "tigris mk t3://my-bucket"
303
305
  - "tigris mk my-fork --fork-of my-bucket"
@@ -327,6 +329,14 @@ commands:
327
329
  alias: s
328
330
  type: flag
329
331
  default: false
332
+ - name: allow-object-acl
333
+ description: Allow per-object ACLs on the bucket (only applies when creating a bucket)
334
+ type: flag
335
+ default: false
336
+ - name: enable-directory-listing
337
+ description: Enable directory listing, relevant for public buckets (only applies when creating a bucket)
338
+ type: flag
339
+ default: false
330
340
  - name: default-tier
331
341
  description: Default storage tier (only applies when creating a bucket)
332
342
  alias: t
@@ -437,6 +447,9 @@ commands:
437
447
  description: Output format
438
448
  options: [url, json]
439
449
  default: url
450
+ - name: snapshot-version
451
+ description: Read from a specific bucket snapshot. Accepts a snapshot version string or any UNIX nanosecond-precision timestamp (e.g. 1765889000501544464). Only supported for GET requests.
452
+ alias: snapshot
440
453
 
441
454
  # cp
442
455
  - name: cp
@@ -444,6 +457,7 @@ commands:
444
457
  alias: copy
445
458
  examples:
446
459
  - "tigris cp ./file.txt t3://my-bucket/file.txt"
460
+ - "tigris cp ./logo.png t3://my-bucket/logo.png --access public"
447
461
  - "tigris cp t3://my-bucket/file.txt ./local-copy.txt"
448
462
  - "tigris cp t3://my-bucket/src/ t3://my-bucket/dest/ -r"
449
463
  - "tigris cp ./images/ t3://my-bucket/images/ -r"
@@ -473,6 +487,10 @@ commands:
473
487
  type: flag
474
488
  alias: r
475
489
  description: Copy directories recursively
490
+ - name: access
491
+ description: Access level for uploaded objects (only applies to local-to-remote uploads)
492
+ alias: a
493
+ options: *access_options
476
494
 
477
495
  # mv
478
496
  - name: mv
@@ -696,6 +714,8 @@ commands:
696
714
  - "tigris buckets create my-bucket"
697
715
  - "tigris buckets create my-bucket --access public --locations iad"
698
716
  - "tigris buckets create my-bucket --enable-snapshots --default-tier STANDARD_IA"
717
+ - "tigris buckets create my-bucket --allow-object-acl"
718
+ - "tigris buckets create my-bucket --public --enable-directory-listing"
699
719
  - "tigris buckets create my-fork --fork-of my-bucket"
700
720
  - "tigris buckets create my-fork --fork-of my-bucket --source-snapshot 1765889000501544464"
701
721
  messages:
@@ -727,6 +747,14 @@ commands:
727
747
  alias: s
728
748
  type: flag
729
749
  default: false
750
+ - name: allow-object-acl
751
+ description: Allow per-object ACLs on the bucket
752
+ type: flag
753
+ default: false
754
+ - name: enable-directory-listing
755
+ description: Enable directory listing, relevant for public buckets
756
+ type: flag
757
+ default: false
730
758
  - name: default-tier
731
759
  description: Choose the default tier for the bucket
732
760
  alias: t
@@ -870,6 +898,38 @@ commands:
870
898
  - name: enable-additional-headers
871
899
  description: Enable additional HTTP headers (X-Content-Type-Options nosniff)
872
900
  type: boolean
901
+ # enable-snapshots
902
+ - name: enable-snapshots
903
+ description: Enable snapshots on an existing bucket, converting it to a snapshot bucket
904
+ examples:
905
+ - "tigris buckets enable-snapshots my-bucket"
906
+ messages:
907
+ onStart: 'Enabling snapshots...'
908
+ onSuccess: 'Snapshots enabled for bucket {{name}}'
909
+ onFailure: 'Failed to enable snapshots'
910
+ arguments:
911
+ - name: name
912
+ description: Name of the bucket
913
+ type: positional
914
+ required: true
915
+ examples:
916
+ - my-bucket
917
+ # disable-snapshots
918
+ - name: disable-snapshots
919
+ description: Disable snapshots on an existing bucket, converting it back to a regular bucket. Rejected while the bucket has dependent forks
920
+ examples:
921
+ - "tigris buckets disable-snapshots my-bucket"
922
+ messages:
923
+ onStart: 'Disabling snapshots...'
924
+ onSuccess: 'Snapshots disabled for bucket {{name}}'
925
+ onFailure: 'Failed to disable snapshots'
926
+ arguments:
927
+ - name: name
928
+ description: Name of the bucket
929
+ type: positional
930
+ required: true
931
+ examples:
932
+ - my-bucket
873
933
  # set-ttl
874
934
  - name: set-ttl
875
935
  removed: true
@@ -1528,6 +1588,62 @@ commands:
1528
1588
  alias: snapshot
1529
1589
  - name: version-id
1530
1590
  description: Object version id (requires bucket versioning). Omit to read the latest version
1591
+ # restore
1592
+ - name: restore
1593
+ description: Restore an archived object (e.g. one in the GLACIER tier) into an actively-readable copy for a number of days
1594
+ alias: rs
1595
+ examples:
1596
+ - "tigris objects restore my-bucket archived.bin"
1597
+ - "tigris objects restore my-bucket archived.bin --days 3"
1598
+ - "tigris objects restore t3://my-bucket/archived.bin --days 7"
1599
+ messages:
1600
+ onStart: 'Requesting restore...'
1601
+ onSuccess: "Restore requested for '{{key}}'"
1602
+ onFailure: 'Failed to restore object'
1603
+ arguments:
1604
+ - name: bucket
1605
+ type: positional
1606
+ required: true
1607
+ description: Name of the bucket, or a full path (t3://bucket/key)
1608
+ - name: key
1609
+ type: positional
1610
+ description: Key of the object (omit if bucket contains the full path)
1611
+ - name: days
1612
+ description: How many days the restored copy stays available before reverting to its archived tier
1613
+ alias: d
1614
+ default: 1
1615
+ - name: version-id
1616
+ description: Restore a specific object version (requires bucket versioning). Omit to restore the current version
1617
+ - name: format
1618
+ description: Output format
1619
+ options: [json, table, xml]
1620
+ default: table
1621
+ # restore-info
1622
+ - name: restore-info
1623
+ description: Show the restore state of an archived object (archived, in-progress, or restored)
1624
+ alias: ri
1625
+ examples:
1626
+ - "tigris objects restore-info my-bucket archived.bin"
1627
+ - "tigris objects restore-info t3://my-bucket/archived.bin --format json"
1628
+ messages:
1629
+ onStart: ''
1630
+ onSuccess: ''
1631
+ onFailure: 'Failed to get restore info'
1632
+ onEmpty: 'No restore information for this object (it is not archived)'
1633
+ arguments:
1634
+ - name: bucket
1635
+ type: positional
1636
+ required: true
1637
+ description: Name of the bucket, or a full path (t3://bucket/key)
1638
+ - name: key
1639
+ type: positional
1640
+ description: Key of the object (omit if bucket contains the full path)
1641
+ - name: version-id
1642
+ description: Inspect a specific object version (requires bucket versioning). Omit to read the current version
1643
+ - name: format
1644
+ description: Output format
1645
+ options: [json, table, xml]
1646
+ default: table
1531
1647
 
1532
1648
  #########################
1533
1649
  # Manage access keys
@@ -2064,3 +2180,78 @@ commands:
2064
2180
  - name: force
2065
2181
  type: flag
2066
2182
  description: Skip confirmation prompts (alias for --yes)
2183
+ - name: teams
2184
+ description: Manage organization teams
2185
+ alias: t
2186
+ examples:
2187
+ - "tigris iam teams list"
2188
+ - "tigris iam teams create engineering --members user@example.com"
2189
+ - "tigris iam teams edit team_id --name platform"
2190
+ commands:
2191
+ - name: list
2192
+ description: List all teams in the organization
2193
+ alias: l
2194
+ examples:
2195
+ - "tigris iam teams list"
2196
+ - "tigris iam teams list --format json"
2197
+ messages:
2198
+ onStart: ''
2199
+ onSuccess: ''
2200
+ onFailure: 'Failed to list teams'
2201
+ onEmpty: 'No teams found in this organization'
2202
+ arguments:
2203
+ - name: format
2204
+ description: Output format
2205
+ options: [json, table, xml]
2206
+ default: table
2207
+ - name: create
2208
+ description: Create a new team in the organization
2209
+ alias: c
2210
+ examples:
2211
+ - "tigris iam teams create engineering"
2212
+ - "tigris iam teams create engineering --description 'Engineering team'"
2213
+ - "tigris iam teams create engineering --members a@example.com,b@example.com"
2214
+ messages:
2215
+ onStart: 'Creating team...'
2216
+ onSuccess: "Team '{{name}}' created"
2217
+ onFailure: 'Failed to create team'
2218
+ arguments:
2219
+ - name: name
2220
+ description: Name of the team
2221
+ type: positional
2222
+ required: true
2223
+ examples:
2224
+ - engineering
2225
+ - name: description
2226
+ description: Description for the team
2227
+ alias: d
2228
+ - name: members
2229
+ description: Member email address(es) to add (comma-separated for multiple)
2230
+ alias: m
2231
+ multiple: true
2232
+ - name: edit
2233
+ description: Update a team's name, description, or members. Members are replaced with the provided list
2234
+ alias: e
2235
+ examples:
2236
+ - "tigris iam teams edit team_id --name platform"
2237
+ - "tigris iam teams edit team_id --description 'Platform team'"
2238
+ - "tigris iam teams edit team_id --members a@example.com,b@example.com"
2239
+ messages:
2240
+ onStart: 'Updating team...'
2241
+ onSuccess: "Team updated"
2242
+ onFailure: 'Failed to update team'
2243
+ arguments:
2244
+ - name: id
2245
+ description: ID of the team to edit
2246
+ type: positional
2247
+ required: true
2248
+ - name: name
2249
+ description: New name for the team
2250
+ alias: n
2251
+ - name: description
2252
+ description: New description for the team
2253
+ alias: d
2254
+ - name: members
2255
+ description: Replace the team's members with these email address(es) (comma-separated for multiple)
2256
+ alias: m
2257
+ multiple: true
@@ -1 +1 @@
1
- import{b as a,c as b,d as c,e as d,f as e}from"../chunk-GLKOUVFH.js";import"../chunk-ATBINUDP.js";export{e as checkForUpdates,d as fetchLatestVersion,c as getUpdateCommand,b as isNewerVersion,a as readUpdateCache};
1
+ import{b as a,c as b,d as c,e as d,f as e}from"../chunk-BVSVEXGE.js";import"../chunk-ATBINUDP.js";export{e as checkForUpdates,d as fetchLatestVersion,c as getUpdateCommand,b as isNewerVersion,a as readUpdateCache};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigrisdata/cli",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Command line interface for Tigris object storage",
5
5
  "type": "module",
6
6
  "exports": {
@@ -102,8 +102,8 @@
102
102
  "dependencies": {
103
103
  "@aws-sdk/credential-providers": "^3.1038.0",
104
104
  "@smithy/shared-ini-file-loader": "^4.4.9",
105
- "@tigrisdata/iam": "^2.1.1",
106
- "@tigrisdata/storage": "^3.12.0",
105
+ "@tigrisdata/iam": "^2.2.0",
106
+ "@tigrisdata/storage": "^3.16.0",
107
107
  "commander": "^14.0.3",
108
108
  "enquirer": "^2.4.1",
109
109
  "jose": "^6.2.3",