@tigrisdata/cli 2.10.0 → 2.11.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.
Files changed (61) hide show
  1. package/README.md +240 -1
  2. package/dist/auth/s3-client.js +1 -1
  3. package/dist/chunk-Q4KOY3VK.js +1 -0
  4. package/dist/{chunk-SJCYBKF2.js → chunk-RAGPUVH2.js} +1 -1
  5. package/dist/chunk-SAAGVLRE.js +1 -0
  6. package/dist/{chunk-N7F2D3XT.js → chunk-YSHC5EJY.js} +1 -1
  7. package/dist/cli.js +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/lib/access-keys/assign.js +1 -1
  10. package/dist/lib/access-keys/create.js +1 -1
  11. package/dist/lib/access-keys/delete.js +1 -1
  12. package/dist/lib/access-keys/get.js +1 -1
  13. package/dist/lib/access-keys/list.js +1 -1
  14. package/dist/lib/buckets/create.js +1 -1
  15. package/dist/lib/buckets/delete.js +1 -1
  16. package/dist/lib/buckets/get.js +1 -1
  17. package/dist/lib/buckets/list.js +1 -1
  18. package/dist/lib/buckets/set-cors.js +1 -0
  19. package/dist/lib/buckets/set-migration.js +1 -0
  20. package/dist/lib/buckets/set-notifications.js +1 -0
  21. package/dist/lib/buckets/set-transition.js +1 -0
  22. package/dist/lib/buckets/set-ttl.js +1 -0
  23. package/dist/lib/buckets/set.js +1 -1
  24. package/dist/lib/cp.js +1 -1
  25. package/dist/lib/credentials/test.js +1 -1
  26. package/dist/lib/forks/create.js +1 -1
  27. package/dist/lib/forks/list.js +1 -1
  28. package/dist/lib/iam/policies/create.js +1 -1
  29. package/dist/lib/iam/policies/delete.js +1 -1
  30. package/dist/lib/iam/policies/edit.js +1 -1
  31. package/dist/lib/iam/policies/get.js +1 -1
  32. package/dist/lib/iam/policies/list.js +1 -1
  33. package/dist/lib/iam/users/invite.js +1 -1
  34. package/dist/lib/iam/users/list.js +1 -1
  35. package/dist/lib/iam/users/remove.js +1 -1
  36. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  37. package/dist/lib/iam/users/update-role.js +1 -1
  38. package/dist/lib/login/select.js +1 -1
  39. package/dist/lib/ls.js +1 -1
  40. package/dist/lib/mk.js +1 -1
  41. package/dist/lib/mv.js +1 -1
  42. package/dist/lib/objects/delete.js +1 -1
  43. package/dist/lib/objects/get.js +1 -1
  44. package/dist/lib/objects/list.js +1 -1
  45. package/dist/lib/objects/put.js +1 -1
  46. package/dist/lib/objects/set.js +1 -1
  47. package/dist/lib/organizations/create.js +1 -1
  48. package/dist/lib/organizations/list.js +1 -1
  49. package/dist/lib/organizations/select.js +1 -1
  50. package/dist/lib/rm.js +1 -1
  51. package/dist/lib/snapshots/list.js +1 -1
  52. package/dist/lib/snapshots/take.js +1 -1
  53. package/dist/lib/stat.js +1 -1
  54. package/dist/lib/touch.js +1 -1
  55. package/dist/lib/whoami.js +1 -1
  56. package/dist/specs.yaml +254 -8
  57. package/dist/utils/concurrency.js +1 -0
  58. package/dist/utils/locations.js +1 -0
  59. package/dist/utils/update-check.js +1 -1
  60. package/package.json +2 -2
  61. /package/dist/{chunk-USCKVLDO.js → chunk-YEF2ZFBJ.js} +0 -0
package/README.md CHANGED
@@ -24,6 +24,7 @@ Run `tigris help` to see all available commands, or `tigris <command> help` for
24
24
  - `tigris cp <src> <dest>` - Copy files between local filesystem and Tigris, or between paths within Tigris. At least one side must be a remote t3:// path
25
25
  - `tigris mv <src> <dest>` - Move (rename) objects within Tigris. Both source and destination must be remote t3:// paths
26
26
  - `tigris rm <path>` - Remove a bucket, folder, or object from Tigris. A bare bucket name deletes the bucket itself
27
+ - `tigris stat [path]` - Show storage stats (no args), bucket info, or object metadata
27
28
 
28
29
  ### Authentication
29
30
 
@@ -41,6 +42,7 @@ Run `tigris help` to see all available commands, or `tigris <command> help` for
41
42
  - `tigris forks` - List and create forks. A fork is a writable copy-on-write clone of a bucket, useful for testing or branching data
42
43
  - `tigris snapshots` - List and take snapshots. A snapshot is a point-in-time, read-only copy of a bucket's state
43
44
  - `tigris objects` - Low-level object operations for listing, downloading, uploading, and deleting individual objects in a bucket
45
+ - `tigris iam` - Identity and Access Management - manage policies, users, and permissions
44
46
 
45
47
  ---
46
48
 
@@ -67,12 +69,22 @@ tigris ls t3://my-bucket/prefix/
67
69
  Create a bucket (bare name) or a folder inside a bucket (bucket/folder/ with trailing slash)
68
70
 
69
71
  ```
70
- tigris mk <path>
72
+ tigris mk <path> [flags]
71
73
  ```
72
74
 
75
+ | Flag | Description |
76
+ |------|-------------|
77
+ | `-a, --access` | Access level (only applies when creating a bucket) |
78
+ | `--public` | Shorthand for --access public (only applies when creating a bucket) |
79
+ | `-s, --enable-snapshots` | Enable snapshots for the bucket (only applies when creating a bucket) |
80
+ | `-t, --default-tier` | Default storage tier (only applies when creating a bucket) |
81
+ | `-c, --consistency` | Consistency level (only applies when creating a bucket) |
82
+ | `-r, --region` | Region (only applies when creating a bucket) |
83
+
73
84
  **Examples:**
74
85
  ```bash
75
86
  tigris mk my-bucket
87
+ tigris mk my-bucket --access public --region iad
76
88
  tigris mk my-bucket/images/
77
89
  tigris mk t3://my-bucket
78
90
  ```
@@ -152,6 +164,25 @@ tigris rm t3://my-bucket -f
152
164
  tigris rm "t3://my-bucket/logs/*.tmp" -f
153
165
  ```
154
166
 
167
+ ### `stat`
168
+
169
+ Show storage stats (no args), bucket info, or object metadata
170
+
171
+ ```
172
+ tigris stat [path] [flags]
173
+ ```
174
+
175
+ | Flag | Description |
176
+ |------|-------------|
177
+ | `-f, --format` | Output format |
178
+
179
+ **Examples:**
180
+ ```bash
181
+ tigris stat
182
+ tigris stat t3://my-bucket
183
+ tigris stat t3://my-bucket/my-object.json
184
+ ```
185
+
155
186
  ## Authentication
156
187
 
157
188
  ### `login` | `l`
@@ -437,6 +468,7 @@ tigris buckets create [name] [flags]
437
468
  | Flag | Description |
438
469
  |------|-------------|
439
470
  | `-a, --access` | Access level (default: private) |
471
+ | `--public` | Shorthand for --access public |
440
472
  | `-s, --enable-snapshots` | Enable snapshots for the bucket (default: false) |
441
473
  | `-t, --default-tier` | Choose the default tier for the bucket (default: STANDARD) |
442
474
  | `-c, --consistency` | Choose the consistency level for the bucket (default: default) |
@@ -583,6 +615,7 @@ Low-level object operations for listing, downloading, uploading, and deleting in
583
615
  | `objects get` (g) | Download an object by key. Prints to stdout by default, or saves to a file with --output |
584
616
  | `objects put` (p) | Upload a local file as an object. Content-type is auto-detected from extension unless overridden |
585
617
  | `objects delete` (d) | Delete one or more objects by key from the given bucket |
618
+ | `objects set` (s) | Update settings on an existing object such as access level |
586
619
 
587
620
  #### `objects list`
588
621
 
@@ -649,6 +682,212 @@ tigris objects delete my-bucket old-file.txt
649
682
  tigris objects delete my-bucket file-a.txt,file-b.txt
650
683
  ```
651
684
 
685
+ #### `objects set`
686
+
687
+ ```
688
+ tigris objects set <bucket> <key> [flags]
689
+ ```
690
+
691
+ | Flag | Description |
692
+ |------|-------------|
693
+ | `-a, --access` | Access level |
694
+ | `-n, --new-key` | Rename the object to a new key |
695
+
696
+ **Examples:**
697
+ ```bash
698
+ tigris objects set my-bucket my-file.txt --access public
699
+ tigris objects set my-bucket my-file.txt --access private
700
+ ```
701
+
702
+ ### `iam`
703
+
704
+ Identity and Access Management - manage policies, users, and permissions
705
+
706
+ | Command | Description |
707
+ |---------|-------------|
708
+ | `iam policies` (p) | Manage IAM policies. Policies define permissions for access keys |
709
+ | `iam users` (u) | Manage organization users and invitations |
710
+
711
+ #### `iam policies` | `p`
712
+
713
+ Manage IAM policies. Policies define permissions for access keys
714
+
715
+ | Command | Description |
716
+ |---------|-------------|
717
+ | `iam policies list` (l) | List all policies in the current organization |
718
+ | `iam policies get` (g) | Show details for a policy including its document and attached users. If no ARN provided, shows interactive selection |
719
+ | `iam policies create` (c) | Create a new policy with the given name and policy document. Document can be provided via file, inline JSON, or stdin |
720
+ | `iam policies edit` (e) | Update an existing policy's document. Document can be provided via file, inline JSON, or stdin. If no ARN provided, shows interactive selection |
721
+ | `iam policies delete` (d) | Delete a policy. If no ARN provided, shows interactive selection |
722
+
723
+ ##### `iam policies list`
724
+
725
+ ```
726
+ tigris iam policies list [flags]
727
+ ```
728
+
729
+ | Flag | Description |
730
+ |------|-------------|
731
+ | `-f, --format` | Output format (default: table) |
732
+
733
+ **Examples:**
734
+ ```bash
735
+ tigris iam policies list
736
+ ```
737
+
738
+ ##### `iam policies get`
739
+
740
+ ```
741
+ tigris iam policies get [resource] [flags]
742
+ ```
743
+
744
+ | Flag | Description |
745
+ |------|-------------|
746
+ | `-f, --format` | Output format (default: table) |
747
+
748
+ **Examples:**
749
+ ```bash
750
+ tigris iam policies get
751
+ tigris iam policies get arn:aws:iam::org_id:policy/my-policy
752
+ ```
753
+
754
+ ##### `iam policies create`
755
+
756
+ ```
757
+ tigris iam policies create <name> [flags]
758
+ ```
759
+
760
+ | Flag | Description |
761
+ |------|-------------|
762
+ | `-d, --document` | Policy document (JSON file path or inline JSON). If omitted, reads from stdin |
763
+ | `--description` | Policy description |
764
+
765
+ **Examples:**
766
+ ```bash
767
+ tigris iam policies create my-policy --document policy.json
768
+ tigris iam policies create my-policy --document '{"Version":"2012-10-17","Statement":[...]}'
769
+ cat policy.json | tigris iam policies create my-policy
770
+ ```
771
+
772
+ ##### `iam policies edit`
773
+
774
+ ```
775
+ tigris iam policies edit [resource] [flags]
776
+ ```
777
+
778
+ | Flag | Description |
779
+ |------|-------------|
780
+ | `-d, --document` | New policy document (JSON file path or inline JSON). If omitted, reads from stdin |
781
+ | `--description` | Update policy description |
782
+
783
+ **Examples:**
784
+ ```bash
785
+ tigris iam policies edit --document policy.json
786
+ tigris iam policies edit arn:aws:iam::org_id:policy/my-policy --document policy.json
787
+ cat policy.json | tigris iam policies edit arn:aws:iam::org_id:policy/my-policy
788
+ ```
789
+
790
+ ##### `iam policies delete`
791
+
792
+ ```
793
+ tigris iam policies delete [resource]
794
+ ```
795
+
796
+ **Examples:**
797
+ ```bash
798
+ tigris iam policies delete
799
+ tigris iam policies delete arn:aws:iam::org_id:policy/my-policy
800
+ ```
801
+
802
+ #### `iam users` | `u`
803
+
804
+ Manage organization users and invitations
805
+
806
+ | Command | Description |
807
+ |---------|-------------|
808
+ | `iam users list` (l) | List all users and pending invitations in the organization |
809
+ | `iam users invite` (i) | Invite users to the organization by email |
810
+ | `iam users revoke-invitation` (ri) | Revoke pending invitations. If no invitation ID provided, shows interactive selection |
811
+ | `iam users update-role` (ur) | Update user roles in the organization. If no user ID provided, shows interactive selection |
812
+ | `iam users remove` (rm) | Remove users from the organization. If no user ID provided, shows interactive selection |
813
+
814
+ ##### `iam users list`
815
+
816
+ ```
817
+ tigris iam users list [flags]
818
+ ```
819
+
820
+ | Flag | Description |
821
+ |------|-------------|
822
+ | `-f, --format` | Output format (default: table) |
823
+
824
+ **Examples:**
825
+ ```bash
826
+ tigris iam users list
827
+ tigris iam users list --format json
828
+ ```
829
+
830
+ ##### `iam users invite`
831
+
832
+ ```
833
+ tigris iam users invite <email> [flags]
834
+ ```
835
+
836
+ | Flag | Description |
837
+ |------|-------------|
838
+ | `-r, --role` | Role to assign to the invited user(s) (default: member) |
839
+
840
+ **Examples:**
841
+ ```bash
842
+ tigris iam users invite user@example.com
843
+ tigris iam users invite user@example.com --role admin
844
+ tigris iam users invite user1@example.com,user2@example.com
845
+ ```
846
+
847
+ ##### `iam users revoke-invitation`
848
+
849
+ ```
850
+ tigris iam users revoke-invitation [resource]
851
+ ```
852
+
853
+ **Examples:**
854
+ ```bash
855
+ tigris iam users revoke-invitation
856
+ tigris iam users revoke-invitation invitation_id
857
+ tigris iam users revoke-invitation id1,id2,id3
858
+ ```
859
+
860
+ ##### `iam users update-role`
861
+
862
+ ```
863
+ tigris iam users update-role [resource] [flags]
864
+ ```
865
+
866
+ | Flag | Description |
867
+ |------|-------------|
868
+ | `-r, --role` | Role(s) to assign (comma-separated). Each role pairs with the corresponding user ID. If one role is given, it applies to all users |
869
+
870
+ **Examples:**
871
+ ```bash
872
+ tigris iam users update-role --role admin
873
+ tigris iam users update-role user_id --role member
874
+ tigris iam users update-role id1,id2 --role admin
875
+ tigris iam users update-role id1,id2 --role admin,member
876
+ ```
877
+
878
+ ##### `iam users remove`
879
+
880
+ ```
881
+ tigris iam users remove [resource]
882
+ ```
883
+
884
+ **Examples:**
885
+ ```bash
886
+ tigris iam users remove
887
+ tigris iam users remove user@example.com
888
+ tigris iam users remove user@example.com,user@example.net
889
+ ```
890
+
652
891
  ## License
653
892
 
654
893
  MIT
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-USCKVLDO.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";export{a as getLoginMethod,c as getS3Client,b as getStorageConfig,d as isAuthenticated};
1
+ import{a,b,c,d}from"../chunk-YEF2ZFBJ.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";export{a as getLoginMethod,c as getS3Client,b as getStorageConfig,d as isAuthenticated};
@@ -0,0 +1 @@
1
+ var n=["usa","eur"],l=[{name:"USA",value:"usa"},{name:"Europe",value:"eur"}],i=[{name:"Amsterdam, Netherlands",value:"ams"},{name:"Frankfurt, Germany",value:"fra"},{name:"Sao Paulo, Brazil",value:"gru"},{name:"Ashburn, Virginia (US)",value:"iad"},{name:"Johannesburg, South Africa",value:"jnb"},{name:"London, United Kingdom",value:"lhr"},{name:"Tokyo, Japan",value:"nrt"},{name:"Chicago, Illinois (US)",value:"ord"},{name:"Singapore, Singapore",value:"sin"},{name:"San Jose, California (US)",value:"sjc"},{name:"Sydney, Australia",value:"syd"}];function u(t){let a=(Array.isArray(t)?t:[t]).flatMap(e=>e.split(",")).map(e=>e.trim()).filter(e=>e.length>0);if(a.length===0||a.length===1&&a[0]==="global")return{type:"global"};if(a.length===1){let e=a[0];return n.includes(e)?{type:"multi",values:e}:{type:"single",values:e}}return{type:"dual",values:a}}export{l as a,i as b,u as c};
@@ -1,4 +1,4 @@
1
- import{d as m,e as d,f}from"./chunk-2XAO2OYD.js";import{readFileSync as T,writeFileSync as I,mkdirSync as N}from"fs";import{join as g}from"path";import{homedir as h}from"os";import k from"https";var u="2.10.0";var b=g(h(),".tigris","update-check.json");function y(){try{let e=T(b,"utf-8"),s=JSON.parse(e);return typeof s.latestVersion=="string"&&typeof s.lastChecked=="number"?s:null}catch{return null}}function v(e){try{N(g(h(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function j(e,s){let a=o=>{let r=o.startsWith("v")?o.slice(1):o,c=null,l=r.indexOf("-");l!==-1&&(c=r.slice(l+1),r=r.slice(0,l));let p=r.split(".");if(p.length!==3)return null;let n=p.map(Number);return n.some(isNaN)?null:{major:n[0],minor:n[1],patch:n[2],prerelease:c}},t=a(e),i=a(s);return!t||!i?!1:i.major>t.major?!0:i.major<t.major?!1:i.minor>t.minor?!0:i.minor<t.minor?!1:i.patch>t.patch?!0:i.patch<t.patch?!1:t.prerelease&&!i.prerelease?!0:(!t.prerelease&&i.prerelease,!1)}function x(){try{let e=k.get(m,{timeout:5e3},s=>{let a="";s.on("data",t=>{a+=t}),s.on("end",()=>{try{let t=JSON.parse(a);if(typeof t.version=="string"){let i=y();v({...i,latestVersion:t.version,lastChecked:Date.now()})}}catch{}})});e.on("error",()=>{}),e.on("timeout",()=>{e.destroy()}),e.end(),e.on("socket",s=>{s.unref()})}catch{}}function V(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),s=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||216e5;if(e&&j(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>s)){let t=globalThis.__TIGRIS_BINARY===!0,i=process.platform==="win32",o=`Update available: ${u} \u2192 ${e.latestVersion}`,r;t?i?r="Run `irm https://raw.githubusercontent.com/tigrisdata/cli/main/scripts/install.ps1 | iex`":r="Run `curl -fsSL https://raw.githubusercontent.com/tigrisdata/cli/main/scripts/install.sh | sh`":r="Run `npm install -g @tigrisdata/cli` to upgrade.";let c=Math.max(o.length,r.length)+4,l="\u250C"+"\u2500".repeat(c-2)+"\u2510",p="\u2514"+"\u2500".repeat(c-2)+"\u2518",n=_=>"\u2502 "+_.padEnd(c-4)+" \u2502";console.log(`
1
+ import{d as m,e as d,f}from"./chunk-2XAO2OYD.js";import{readFileSync as T,writeFileSync as I,mkdirSync as N}from"fs";import{join as g}from"path";import{homedir as h}from"os";import k from"https";var u="2.11.0";var b=g(h(),".tigris","update-check.json");function y(){try{let e=T(b,"utf-8"),s=JSON.parse(e);return typeof s.latestVersion=="string"&&typeof s.lastChecked=="number"?s:null}catch{return null}}function v(e){try{N(g(h(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function j(e,s){let a=o=>{let r=o.startsWith("v")?o.slice(1):o,c=null,l=r.indexOf("-");l!==-1&&(c=r.slice(l+1),r=r.slice(0,l));let p=r.split(".");if(p.length!==3)return null;let n=p.map(Number);return n.some(isNaN)?null:{major:n[0],minor:n[1],patch:n[2],prerelease:c}},t=a(e),i=a(s);return!t||!i?!1:i.major>t.major?!0:i.major<t.major?!1:i.minor>t.minor?!0:i.minor<t.minor?!1:i.patch>t.patch?!0:i.patch<t.patch?!1:t.prerelease&&!i.prerelease?!0:(!t.prerelease&&i.prerelease,!1)}function x(){try{let e=k.get(m,{timeout:5e3},s=>{let a="";s.on("data",t=>{a+=t}),s.on("end",()=>{try{let t=JSON.parse(a);if(typeof t.version=="string"){let i=y();v({...i,latestVersion:t.version,lastChecked:Date.now()})}}catch{}})});e.on("error",()=>{}),e.on("timeout",()=>{e.destroy()}),e.end(),e.on("socket",s=>{s.unref()})}catch{}}function V(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),s=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||216e5;if(e&&j(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>s)){let t=globalThis.__TIGRIS_BINARY===!0,i=process.platform==="win32",o=`Update available: ${u} \u2192 ${e.latestVersion}`,r;t?i?r="Run `irm https://raw.githubusercontent.com/tigrisdata/cli/main/scripts/install.ps1 | iex`":r="Run `curl -fsSL https://raw.githubusercontent.com/tigrisdata/cli/main/scripts/install.sh | sh`":r="Run `npm install -g @tigrisdata/cli` to upgrade.";let c=Math.max(o.length,r.length)+4,l="\u250C"+"\u2500".repeat(c-2)+"\u2510",p="\u2514"+"\u2500".repeat(c-2)+"\u2518",n=_=>"\u2502 "+_.padEnd(c-4)+" \u2502";console.log(`
2
2
  ${l}
3
3
  ${n("")}
4
4
  ${n(o)}
@@ -0,0 +1 @@
1
+ async function h(e,o){if(e.length===0)return[];let i=Math.max(1,Math.floor(o)),n=new Array(e.length),r=0;async function c(){for(;r<e.length;){let t=r++;n[t]=await e[t]()}}let l=Array.from({length:Math.min(i,e.length)},()=>c());return await Promise.all(l),n}export{h as a};
@@ -1 +1 @@
1
- import{a as s,c as l}from"./chunk-SJCYBKF2.js";import{b as m}from"./chunk-BETAO4PB.js";import{a as t,k as i}from"./chunk-4V35SYMM.js";import{existsSync as c}from"fs";import{join as a,dirname as u}from"path";import{fileURLToPath as f}from"url";t();var j=f(import.meta.url),d=u(j),h=m(),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=i({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
1
+ import{a as s,c as l}from"./chunk-RAGPUVH2.js";import{b as m}from"./chunk-BETAO4PB.js";import{a as t,k as i}from"./chunk-4V35SYMM.js";import{existsSync as c}from"fs";import{join as a,dirname as u}from"path";import{fileURLToPath as f}from"url";t();var j=f(import.meta.url),d=u(j),h=m(),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=i({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-N7F2D3XT.js";import"./chunk-SJCYBKF2.js";import"./chunk-BETAO4PB.js";import"./chunk-4V35SYMM.js";import"./chunk-2XAO2OYD.js";
2
+ import"./chunk-YSHC5EJY.js";import"./chunk-RAGPUVH2.js";import"./chunk-BETAO4PB.js";import"./chunk-4V35SYMM.js";import"./chunk-2XAO2OYD.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-N7F2D3XT.js";import"./chunk-SJCYBKF2.js";import"./chunk-BETAO4PB.js";import"./chunk-4V35SYMM.js";import"./chunk-2XAO2OYD.js";
1
+ import"./chunk-YSHC5EJY.js";import"./chunk-RAGPUVH2.js";import"./chunk-BETAO4PB.js";import"./chunk-4V35SYMM.js";import"./chunk-2XAO2OYD.js";
@@ -1,2 +1,2 @@
1
- import{a as A,b as l,c as t,g as R}from"../../chunk-SYGTCM6P.js";import{a as n}from"../../chunk-JRALYIRA.js";import{a as b}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import{b as k}from"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import{c as p}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{assignBucketRoles as C,revokeAllBucketRoles as N}from"@tigrisdata/iam";var e=R("access-keys","assign"),x=["Editor","ReadOnly","NamespaceAdmin"];function y(o){return o?Array.isArray(o)?o:[o]:[]}async function E(o){A(e);let c=n(o,["id"]),g=n(o,["admin"]),d=n(o,["revokeRoles","revoke-roles"]),r=y(n(o,["bucket","b"])),s=y(n(o,["role","r"]));c||(t(e,"Access key ID is required"),process.exit(1)),g&&d&&(t(e,"Cannot use --admin and --revoke-roles together"),process.exit(1)),await b()!=="oauth"&&(t(e,`Bucket roles can only be managed when logged in via OAuth.
1
+ import{a as A,b as l,c as t,g as R}from"../../chunk-SYGTCM6P.js";import{a as n}from"../../chunk-JRALYIRA.js";import{a as b}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import{b as k}from"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import{c as p}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{assignBucketRoles as C,revokeAllBucketRoles as N}from"@tigrisdata/iam";var e=R("access-keys","assign"),x=["Editor","ReadOnly","NamespaceAdmin"];function y(o){return o?Array.isArray(o)?o:[o]:[]}async function E(o){A(e);let c=n(o,["id"]),g=n(o,["admin"]),d=n(o,["revokeRoles","revoke-roles"]),r=y(n(o,["bucket","b"])),s=y(n(o,["role","r"]));c||(t(e,"Access key ID is required"),process.exit(1)),g&&d&&(t(e,"Cannot use --admin and --revoke-roles together"),process.exit(1)),await b()!=="oauth"&&(t(e,`Bucket roles can only be managed when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let m=k();await m.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let T=await m.getAccessToken(),v=h(),w=p(),u={sessionToken:T,organizationId:v??void 0,iamEndpoint:w.iamEndpoint};if(d){let{error:i}=await N(c,{config:u});i&&(t(e,i.message),process.exit(1)),l(e);return}let a;if(g)a=[{bucket:"*",role:"NamespaceAdmin"}];else{r.length===0&&(t(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),process.exit(1)),s.length===0&&(t(e,"At least one role is required (or use --admin or --revoke-roles)"),process.exit(1));for(let i of s)x.includes(i)||(t(e,`Invalid role "${i}". Valid roles are: ${x.join(", ")}`),process.exit(1));s.length===1?a=r.map(i=>({bucket:i,role:s[0]})):s.length===r.length?a=r.map((i,O)=>({bucket:i,role:s[O]})):(t(e,`Number of roles (${s.length}) must be 1 or match number of buckets (${r.length})`),process.exit(1))}let{error:f}=await C(c,a,{config:u});f&&(t(e,f.message),process.exit(1)),l(e)}export{E as default};
@@ -1,2 +1,2 @@
1
- import{a as g,b as l,c as t,g as m}from"../../chunk-SYGTCM6P.js";import{a as u}from"../../chunk-JRALYIRA.js";import{a as d}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import{b as a}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createAccessKey as y}from"@tigrisdata/iam";var e=m("access-keys","create");async function w(f){g(e);let i=u(f,["name"]);i||(t(e,"Access key name is required"),process.exit(1)),await d()!=="oauth"&&(t(e,`Access keys can only be created when logged in via OAuth.
1
+ import{a as g,b as l,c as t,g as m}from"../../chunk-SYGTCM6P.js";import{a as u}from"../../chunk-JRALYIRA.js";import{a as d}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import{b as a}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createAccessKey as y}from"@tigrisdata/iam";var e=m("access-keys","create");async function w(f){g(e);let i=u(f,["name"]);i||(t(e,"Access key name is required"),process.exit(1)),await d()!=="oauth"&&(t(e,`Access keys can only be created when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let n=a();await n.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let p=await n.getAccessToken(),h=r(),A=c(),{data:o,error:s}=await y(i,{config:{sessionToken:p,organizationId:h??void 0,iamEndpoint:A.iamEndpoint}});s&&(t(e,s.message),process.exit(1)),console.log(` Name: ${o.name}`),console.log(` Access Key ID: ${o.id}`),console.log(` Secret Access Key: ${o.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again."),l(e)}export{w as default};
@@ -1,2 +1,2 @@
1
- import{a,b as g,c as e,g as d}from"../../chunk-SYGTCM6P.js";import{a as f}from"../../chunk-JRALYIRA.js";import{a as m}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import{b as c}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c as s}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeAccessKey as A}from"@tigrisdata/iam";var t=d("access-keys","delete");async function k(u){a(t);let i=f(u,["id"]);i||(e(t,"Access key ID is required"),process.exit(1)),await m()!=="oauth"&&(e(t,`Access keys can only be deleted when logged in via OAuth.
1
+ import{a,b as g,c as e,g as d}from"../../chunk-SYGTCM6P.js";import{a as f}from"../../chunk-JRALYIRA.js";import{a as m}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import{b as c}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c as s}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeAccessKey as A}from"@tigrisdata/iam";var t=d("access-keys","delete");async function k(u){a(t);let i=f(u,["id"]);i||(e(t,"Access key ID is required"),process.exit(1)),await m()!=="oauth"&&(e(t,`Access keys can only be deleted when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let o=c();await o.isAuthenticated()||(e(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let p=await o.getAccessToken(),h=r(),l=s(),{error:n}=await A(i,{config:{sessionToken:p,organizationId:h??void 0,iamEndpoint:l.iamEndpoint}});n&&(e(t,n.message),process.exit(1)),g(t)}export{k as default};
@@ -1,2 +1,2 @@
1
- import{a as l,b as d,c as t,g as f}from"../../chunk-SYGTCM6P.js";import{a as m}from"../../chunk-JRALYIRA.js";import{a as u}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import{b as g}from"../../chunk-E4MLGABW.js";import{g as a}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getAccessKey as $}from"@tigrisdata/iam";var e=f("access-keys","get");async function w(p){l(e);let i=m(p,["id"]);i||(t(e,"Access key ID is required"),process.exit(1)),await u()!=="oauth"&&(t(e,`Access keys can only be retrieved when logged in via OAuth.
1
+ import{a as l,b as d,c as t,g as f}from"../../chunk-SYGTCM6P.js";import{a as m}from"../../chunk-JRALYIRA.js";import{a as u}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import{b as g}from"../../chunk-E4MLGABW.js";import{g as a}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getAccessKey as $}from"@tigrisdata/iam";var e=f("access-keys","get");async function w(p){l(e);let i=m(p,["id"]);i||(t(e,"Access key ID is required"),process.exit(1)),await u()!=="oauth"&&(t(e,`Access keys can only be retrieved when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let n=g();await n.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let h=await n.getAccessToken(),A=a(),k=c(),{data:o,error:s}=await $(i,{config:{sessionToken:h,organizationId:A??void 0,iamEndpoint:k.iamEndpoint}});if(s&&(t(e,s.message),process.exit(1)),console.log(` Name: ${o.name}`),console.log(` ID: ${o.id}`),console.log(` Status: ${o.status}`),console.log(` Created: ${o.createdAt}`),console.log(` Organization: ${o.organizationId}`),o.roles&&o.roles.length>0){console.log(" Roles:");for(let r of o.roles)console.log(` - ${r.bucket}: ${r.role}`)}else console.log(" Roles: None");d(e)}export{w as default};
@@ -1,2 +1,2 @@
1
- import{a as g,b as u,c as s,d as m,g as l}from"../../chunk-SYGTCM6P.js";import{f}from"../../chunk-CQCBYE3X.js";import{a as p}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import{b as d}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listAccessKeys as w}from"@tigrisdata/iam";var t=l("access-keys","list");async function x(){g(t),await p()!=="oauth"&&(s(t,`Access keys can only be listed when logged in via OAuth.
1
+ import{a as g,b as u,c as s,d as m,g as l}from"../../chunk-SYGTCM6P.js";import{f}from"../../chunk-CQCBYE3X.js";import{a as p}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import{b as d}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listAccessKeys as w}from"@tigrisdata/iam";var t=l("access-keys","list");async function x(){g(t),await p()!=="oauth"&&(s(t,`Access keys can only be listed when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let o=d();await o.isAuthenticated()||(s(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let h=await o.getAccessToken(),y=r(),k=c(),{data:i,error:n}=await w({config:{sessionToken:h,organizationId:y??void 0,iamEndpoint:k.iamEndpoint}});if(n&&(s(t,n.message),process.exit(1)),!i.accessKeys||i.accessKeys.length===0){m(t);return}let a=i.accessKeys.map(e=>({name:e.name,id:e.id,status:e.status,created:e.createdAt})),A=f(a,"table","keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}]);console.log(A),u(t,{count:a.length})}export{x as default};
@@ -1 +1 @@
1
- import{a as S,b as x,c as b,g as k}from"../../chunk-SYGTCM6P.js";import{a as c}from"../../chunk-JRALYIRA.js";import{b as v}from"../../chunk-USCKVLDO.js";import{d,e as f}from"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import A from"enquirer";import{createBucket as I}from"@tigrisdata/storage";var{prompt:T}=A,h=k("buckets","create");async function C(a){S(h);let t=!c(a,["name"]),u=c(a,["name"]),g=t?void 0:c(a,["access","a","A"]),l=t?void 0:c(a,["enable-snapshots","s","S"]),m=t?void 0:c(a,["default-tier","t","T"]),p=t?void 0:c(a,["consistency","c","C"]),r=t?void 0:c(a,["region","r","R"]),i=[];if((!u||t)&&i.push({type:"input",name:"name",message:"Bucket name:",required:!0}),!g||t){let e=d("buckets","access","create"),s=f(e),n=s?.findIndex(o=>o.value===e?.default);i.push({type:"select",name:"access",message:"Access level:",choices:s||[],initial:n!==void 0&&n>=0?n:0})}if(!m||t){let e=d("buckets","default-tier","create"),s=f(e),n=s?.findIndex(o=>o.value===e?.default);i.push({type:"select",name:"defaultTier",message:"Default storage tier:",choices:s||[],initial:n!==void 0&&n>=0?n:0})}if(!p||t){let e=d("buckets","consistency","create"),s=f(e),n=s?.findIndex(o=>o.value===e?.default);i.push({type:"select",name:"consistency",message:"Consistency level:",choices:s||[],initial:n!==void 0&&n>=0?n:0})}if(!r||t){let e=d("buckets","region","create"),s=f(e),n=s?.findIndex(o=>o.value===e?.default);i.push({type:"select",name:"region",message:"Region:",choices:s||[],initial:n!==void 0&&n>=0?n:0})}if((l===void 0||t)&&i.push({type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}),i.length>0){let e=await T(i);u=u||e.name,g=g||e.access,l=l!==void 0?l:e.enableSnapshots,m=m||e.defaultTier,p=p||e.consistency,r=r!==void 0?r:e.region}u||(b(h,"Bucket name is required"),process.exit(1));let{error:y}=await I(u,{defaultTier:m??"STANDARD",consistency:p==="strict"?"strict":"default",enableSnapshot:l===!0,access:g,region:r!=="global"&&r!==void 0?r.split(","):void 0,config:await v()});y&&(b(h,y.message),process.exit(1)),x(h,{name:u})}export{C as default};
1
+ import{a as R,b as A,c as g,g as L}from"../../chunk-SYGTCM6P.js";import{a as P,b as h,c as o}from"../../chunk-Q4KOY3VK.js";import{a as s}from"../../chunk-JRALYIRA.js";import{b as B}from"../../chunk-YEF2ZFBJ.js";import{d as f,e as b}from"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import I from"enquirer";import{createBucket as M}from"@tigrisdata/storage";var{prompt:c}=I,r=L("buckets","create");async function W(t){R(r);let n=s(t,["name"]),y=s(t,["public"])?"public":s(t,["access","a","A"]),S=s(t,["enable-snapshots","s","S"]),w=s(t,["default-tier","t","T"]),m=s(t,["locations","l","L"]),k=s(t,["region","r","R"]),q=s(t,["consistency","c","C"]);k!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),m===void 0&&(m=k)),q!==void 0&&console.warn("Warning: --consistency is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/");let E=!n,i;if(E){let T=f("buckets","access","create"),v=b(T),u=v?.findIndex(e=>e.value===T?.default),x=f("buckets","default-tier","create"),D=b(x),p=D?.findIndex(e=>e.value===x?.default),l=await c([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:v||[],initial:u!==void 0&&u>=0?u:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:D||[],initial:p!==void 0&&p>=0?p:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);n=l.name,y=l.access,w=l.defaultTier,S=l.enableSnapshots;let{locationType:d}=await c({type:"select",name:"locationType",message:"Location type:",choices:[{name:"global",message:"Global"},{name:"multi",message:"Multi-region (USA or Europe)"},{name:"dual",message:"Dual region"},{name:"single",message:"Single region"}]});if(d==="global")i={type:"global"};else if(d==="multi"){let{region:e}=await c({type:"select",name:"region",message:"Multi-region:",choices:P.map(a=>({name:a.value,message:a.name}))});i=o(e)}else if(d==="single"){let{region:e}=await c({type:"select",name:"region",message:"Region:",choices:h.map(a=>({name:a.value,message:a.name}))});i=o(e)}else{let{regions:e}=await c({type:"multiselect",name:"regions",message:"Press space key to select regions (multiple supported) and enter to confirm:",choices:h.map(a=>({name:a.value,message:a.name}))});e.length<2&&(g(r,"Dual region requires at least two regions"),process.exit(1)),i=o(e)}}n||(g(r,"Bucket name is required"),process.exit(1));let{error:C}=await M(n,{defaultTier:w??"STANDARD",enableSnapshot:S===!0,access:y??"private",locations:i??o(m??"global"),config:await B()});C&&(g(r,C.message),process.exit(1)),A(r,{name:n})}export{W as default};
@@ -1 +1 @@
1
- import{a as i,b as s,c as o,g as c}from"../../chunk-SYGTCM6P.js";import{a as m}from"../../chunk-JRALYIRA.js";import{b as a}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeBucket as g}from"@tigrisdata/storage";var e=c("buckets","delete");async function k(f){i(e);let t=m(f,["name"]);t||(o(e,"Bucket name is required"),process.exit(1));let p=Array.isArray(t)?t:[t],u=await a();for(let r of p){let{error:n}=await g(r,{config:u});n&&(o(e,n.message,{name:r}),process.exit(1)),s(e,{name:r})}}export{k as default};
1
+ import{a as i,b as s,c as o,g as c}from"../../chunk-SYGTCM6P.js";import{a as m}from"../../chunk-JRALYIRA.js";import{b as a}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeBucket as g}from"@tigrisdata/storage";var e=c("buckets","delete");async function k(f){i(e);let t=m(f,["name"]);t||(o(e,"Bucket name is required"),process.exit(1));let p=Array.isArray(t)?t:[t],u=await a();for(let r of p){let{error:n}=await g(r,{config:u});n&&(o(e,n.message,{name:r}),process.exit(1)),s(e,{name:r})}}export{k as default};
@@ -1 +1 @@
1
- import{a as s,b as p,c as r,g as n}from"../../chunk-SYGTCM6P.js";import{f as i}from"../../chunk-CQCBYE3X.js";import{a as c}from"../../chunk-JRALYIRA.js";import{b as u}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getBucketInfo as l}from"@tigrisdata/storage";var t=n("buckets","get");async function g(m){s(t);let o=c(m,["name"]);o||(r(t,"Bucket name is required"),process.exit(1));let{data:e,error:a}=await l(o,{config:await u()});a&&(r(t,a.message),process.exit(1));let f=[{property:"Name",value:o},{property:"Snapshots Enabled",value:e.isSnapshotEnabled?"Yes":"No"},{property:"Has Forks",value:e.hasForks?"Yes":"No"},...e.sourceBucketName?[{property:"Source Bucket",value:e.sourceBucketName}]:[],...e.sourceBucketSnapshot?[{property:"Source Snapshot",value:e.sourceBucketSnapshot}]:[]],k=i(f,"table","bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(k),p(t)}export{g as default};
1
+ import{a as s,b as p,c as r,g as n}from"../../chunk-SYGTCM6P.js";import{f as i}from"../../chunk-CQCBYE3X.js";import{a as c}from"../../chunk-JRALYIRA.js";import{b as u}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getBucketInfo as l}from"@tigrisdata/storage";var t=n("buckets","get");async function g(m){s(t);let o=c(m,["name"]);o||(r(t,"Bucket name is required"),process.exit(1));let{data:e,error:a}=await l(o,{config:await u()});a&&(r(t,a.message),process.exit(1));let f=[{property:"Name",value:o},{property:"Snapshots Enabled",value:e.isSnapshotEnabled?"Yes":"No"},{property:"Has Forks",value:e.hasForks?"Yes":"No"},...e.sourceBucketName?[{property:"Source Bucket",value:e.sourceBucketName}]:[],...e.sourceBucketSnapshot?[{property:"Source Snapshot",value:e.sourceBucketSnapshot}]:[]],k=i(f,"table","bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(k),p(t)}export{g as default};
@@ -1 +1 @@
1
- import{a as c,b as i,c as r,d as m,g as u}from"../../chunk-SYGTCM6P.js";import{f as g}from"../../chunk-CQCBYE3X.js";import{a as f}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as d}from"@tigrisdata/storage";var t=u("buckets","list");async function b(k){c(t);try{let e=f(k,["format","F"],"table"),{data:o,error:n}=await d({config:await p()});if(n&&(r(t,n.message),process.exit(1)),!o.buckets||o.buckets.length===0){m(t);return}let s=o.buckets.map(a=>({name:a.name,created:a.creationDate})),l=g(s,e,"buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(l),i(t,{count:s.length})}catch(e){e instanceof Error?r(t,e.message):r(t,"An unknown error occurred"),process.exit(1)}}export{b as default};
1
+ import{a as c,b as i,c as r,d as m,g as u}from"../../chunk-SYGTCM6P.js";import{f as g}from"../../chunk-CQCBYE3X.js";import{a as f}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as d}from"@tigrisdata/storage";var t=u("buckets","list");async function b(k){c(t);try{let e=f(k,["format","F"],"table"),{data:o,error:n}=await d({config:await p()});if(n&&(r(t,n.message),process.exit(1)),!o.buckets||o.buckets.length===0){m(t);return}let s=o.buckets.map(a=>({name:a.name,created:a.creationDate})),l=g(s,e,"buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(l),i(t,{count:s.length})}catch(e){e instanceof Error?r(t,e.message):r(t,"An unknown error occurred"),process.exit(1)}}export{b as default};
@@ -0,0 +1 @@
1
+ import{a as p,b,c as t,g as h}from"../../chunk-SYGTCM6P.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as w}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as x}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketCors as C}from"@tigrisdata/storage";var n=h("buckets","set-cors");async function N(r){p(n);let i=e(r,["name"]),o=e(r,["origins"]),d=e(r,["methods"]),a=e(r,["headers"]),c=e(r,["expose-headers","exposeHeaders"]),s=e(r,["max-age","maxAge"]),f=e(r,["override"]),g=e(r,["reset"]);i||(t(n,"Bucket name is required"),process.exit(1)),g&&(o!==void 0||d!==void 0||a!==void 0||c!==void 0||s!==void 0||f)&&(t(n,"Cannot use --reset with other options"),process.exit(1)),!g&&!o&&(t(n,"Provide --origins or --reset"),process.exit(1)),s!==void 0&&(isNaN(Number(s))||Number(s)<=0)&&(t(n,"--max-age must be a positive number"),process.exit(1));let m=await w(),u=x(),v={...m,...u&&!m.organizationId?{organizationId:u}:{}},{error:l}=await C(i,{rules:g?[]:[{allowedOrigins:o,...d!==void 0?{allowedMethods:d}:{},...a!==void 0?{allowedHeaders:a}:{},...c!==void 0?{exposeHeaders:c}:{},maxAge:s!==void 0?Number(s):3600}],override:f??!1,config:v});l&&(t(n,l.message),process.exit(1)),b(n,{name:i})}export{N as default};
@@ -0,0 +1 @@
1
+ import{a as w,b as d,c as i,g as y}from"../../chunk-SYGTCM6P.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as x}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketMigration as K}from"@tigrisdata/storage";var n=y("buckets","set-migration");async function M(t){w(n);let r=e(t,["name"]),o=e(t,["bucket"]),s=e(t,["endpoint"]),a=e(t,["region"]),c=e(t,["access-key","accessKey"]),g=e(t,["secret-key","secretKey"]),f=e(t,["write-through","writeThrough"]),u=e(t,["disable"]);r||(i(n,"Bucket name is required"),process.exit(1)),u&&(o!==void 0||s!==void 0||a!==void 0||c!==void 0||g!==void 0||f!==void 0)&&(i(n,"Cannot use --disable with other migration options"),process.exit(1));let m=await x(),l=h(),p={...m,...l&&!m.organizationId?{organizationId:l}:{}};if(u){let{error:k}=await K(r,{dataMigration:{enabled:!1},config:p});k&&(i(n,k.message),process.exit(1)),d(n,{name:r});return}(!o||!s||!a||!c||!g)&&(i(n,"Required: --bucket, --endpoint, --region, --access-key, --secret-key"),process.exit(1));let{error:b}=await K(r,{dataMigration:{enabled:!0,accessKey:c,secretKey:g,region:a,name:o,endpoint:s,writeThrough:f??!1},config:p});b&&(i(n,b.message),process.exit(1)),d(n,{name:r})}export{M as default};
@@ -0,0 +1 @@
1
+ import{a as k,b as w,c as i,g as x}from"../../chunk-SYGTCM6P.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as C}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketNotifications as N}from"@tigrisdata/storage";var t=x("buckets","set-notifications");async function O(n){k(t);let c=e(n,["name"]),d=e(n,["url"]),f=e(n,["filter"]),a=e(n,["token"]),o=e(n,["username"]),s=e(n,["password"]),l=e(n,["enable"]),g=e(n,["disable"]),u=e(n,["reset"]);c||(i(t,"Bucket name is required"),process.exit(1)),[l,g,u].filter(Boolean).length>1&&(i(t,"Only one of --enable, --disable, or --reset can be used"),process.exit(1)),u&&(d!==void 0||f!==void 0||a!==void 0||o!==void 0||s!==void 0)&&(i(t,"Cannot use --reset with other options"),process.exit(1)),!l&&!g&&!u&&d===void 0&&f===void 0&&a===void 0&&o===void 0&&s===void 0&&(i(t,"Provide at least one option"),process.exit(1)),a&&(o!==void 0||s!==void 0)&&(i(t,"Cannot use --token with --username/--password. Choose one auth method"),process.exit(1)),(o!==void 0&&s===void 0||o===void 0&&s!==void 0)&&(i(t,"Both --username and --password are required"),process.exit(1));let m=await C(),p=h(),B={...m,...p&&!m.organizationId?{organizationId:p}:{}},r;u?r={}:(r={...l?{enabled:!0}:{},...g?{enabled:!1}:{},...d!==void 0?{url:d}:{},...f!==void 0?{filter:f}:{}},a?r={...r,auth:{token:a}}:o&&s&&(r={...r,auth:{username:o,password:s}}));let{error:b}=await N(c,{notificationConfig:r,config:B});b&&(i(t,b.message),process.exit(1)),w(t,{name:c})}export{O as default};
@@ -0,0 +1 @@
1
+ import{a as m,b,c as s,g as p}from"../../chunk-SYGTCM6P.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as x}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketLifecycle as A}from"@tigrisdata/storage";var e=p("buckets","set-transition"),y=["STANDARD_IA","GLACIER","GLACIER_IR"];async function I(a){m(e);let d=i(a,["name"]),o=i(a,["storage-class","storageClass"]),n=i(a,["days"]),t=i(a,["date"]),c=i(a,["enable"]),r=i(a,["disable"]);d||(s(e,"Bucket name is required"),process.exit(1)),c&&r&&(s(e,"Cannot use both --enable and --disable"),process.exit(1)),r&&(n!==void 0||t!==void 0||o!==void 0)&&(s(e,"Cannot use --disable with --days, --date, or --storage-class"),process.exit(1)),!c&&!r&&n===void 0&&t===void 0&&(s(e,"Provide --days, --date, --enable, or --disable"),process.exit(1)),(n!==void 0||t!==void 0)&&!o&&(s(e,"--storage-class is required when setting --days or --date"),process.exit(1)),o&&!y.includes(o)&&(s(e,`--storage-class must be one of: ${y.join(", ")} (STANDARD is not a valid transition target)`),process.exit(1)),n!==void 0&&(isNaN(Number(n))||Number(n)<=0)&&(s(e,"--days must be a positive number"),process.exit(1)),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&(s(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)"),process.exit(1));let f=await x(),u=g(),N={...f,...u&&!f.organizationId?{organizationId:u}:{}},S={...c?{enabled:!0}:{},...r?{enabled:!1}:{},...o?{storageClass:o}:{},...n!==void 0?{days:Number(n)}:{},...t!==void 0?{date:t}:{}},{error:l}=await A(d,{lifecycleRules:[S],config:N});l&&(s(e,l.message),process.exit(1)),b(e,{name:d})}export{I as default};
@@ -0,0 +1 @@
1
+ import{a as g,b as m,c as n,g as b}from"../../chunk-SYGTCM6P.js";import{a as s}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as l}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketTtl as N}from"@tigrisdata/storage";var e=b("buckets","set-ttl");async function w(a){g(e);let d=s(a,["name"]),i=s(a,["days"]),t=s(a,["date"]),r=s(a,["enable"]),o=s(a,["disable"]);d||(n(e,"Bucket name is required"),process.exit(1)),r&&o&&(n(e,"Cannot use both --enable and --disable"),process.exit(1)),o&&(i!==void 0||t!==void 0)&&(n(e,"Cannot use --disable with --days or --date"),process.exit(1)),!r&&!o&&i===void 0&&t===void 0&&(n(e,"Provide --days, --date, --enable, or --disable"),process.exit(1)),i!==void 0&&(isNaN(Number(i))||Number(i)<=0)&&(n(e,"--days must be a positive number"),process.exit(1)),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&(n(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)"),process.exit(1));let c=await p(),f=l(),x={...c,...f&&!c.organizationId?{organizationId:f}:{}},y={...r?{enabled:!0}:{},...o?{enabled:!1}:{},...i!==void 0?{days:Number(i)}:{},...t!==void 0?{date:t}:{}},{error:u}=await N(d,{ttlConfig:y,config:x});u&&(n(e,u.message),process.exit(1)),m(e,{name:d})}export{w as default};
@@ -1 +1 @@
1
- import{a as O,b as y,c,g as w}from"../../chunk-SYGTCM6P.js";import{a as e,b as r}from"../../chunk-JRALYIRA.js";import{b as k}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as D}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{updateBucket as x}from"@tigrisdata/storage";var o=w("buckets","set");async function B(n){O(o);let s=e(n,["name"]),a=e(n,["access"]),i=e(n,["region"]),d=e(n,["allow-object-acl","allowObjectAcl"]),l=e(n,["disable-directory-listing","disableDirectoryListing"]),f=e(n,["cache-control","cacheControl"]),u=e(n,["custom-domain","customDomain"]),g=e(n,["enable-delete-protection","enableDeleteProtection"]);s||(c(o,"Bucket name is required"),process.exit(1)),a===void 0&&i===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&(c(o,"At least one setting is required"),process.exit(1));let m=await k(),t={};a!==void 0&&(t.access=a),i!==void 0&&(t.regions=Array.isArray(i)?i:[i]),d!==void 0&&(t.allowObjectAcl=r(d)),l!==void 0&&(t.disableDirectoryListing=r(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=r(g));let p=D(),A={...m,...p&&!m.organizationId?{organizationId:p}:{}},{error:b}=await x(s,{...t,config:A});b&&(c(o,b.message),process.exit(1)),y(o,{name:s})}export{B as default};
1
+ import{a as k,b as A,c,g as h}from"../../chunk-SYGTCM6P.js";import{c as x}from"../../chunk-Q4KOY3VK.js";import{a as e,b as o}from"../../chunk-JRALYIRA.js";import{b as y}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as O}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{updateBucket as C}from"@tigrisdata/storage";var a=h("buckets","set");async function S(n){k(a);let s=e(n,["name"]),r=e(n,["access"]),i=e(n,["locations"]),b=e(n,["region"]);b!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),i===void 0&&(i=b));let d=e(n,["allow-object-acl","allowObjectAcl"]),l=e(n,["disable-directory-listing","disableDirectoryListing"]),f=e(n,["cache-control","cacheControl"]),u=e(n,["custom-domain","customDomain"]),g=e(n,["enable-delete-protection","enableDeleteProtection"]),m=e(n,["enable-additional-headers","enableAdditionalHeaders"]);s||(c(a,"Bucket name is required"),process.exit(1)),r===void 0&&i===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&(c(a,"At least one setting is required"),process.exit(1));let p=await y(),t={};r!==void 0&&(t.access=r),i!==void 0&&(t.locations=x(i)),d!==void 0&&(t.allowObjectAcl=o(d)),l!==void 0&&(t.disableDirectoryListing=o(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=o(g)),m!==void 0&&(t.enableAdditionalHeaders=o(m));let w=O(),B={...p,...w&&!p.organizationId?{organizationId:w}:{}},{error:D}=await C(s,{...t,config:B});D&&(c(a,D.message),process.exit(1)),A(a,{name:s})}export{S as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as $}from"../chunk-CQCBYE3X.js";import{a as v}from"../chunk-JRALYIRA.js";import{a as D,b as W,d as S,g as R,h as C,i as T}from"../chunk-LCWHZUZZ.js";import{b as M}from"../chunk-USCKVLDO.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";import{createReadStream as Q,createWriteStream as V,statSync as z,readdirSync as N,mkdirSync as X,existsSync as O}from"fs";import{resolve as B,dirname as E,basename as j,join as x,relative as L}from"path";import{homedir as Y}from"os";import{Readable as q}from"stream";import{pipeline as Z}from"stream/promises";import{get as G,put as A,list as _,head as H}from"@tigrisdata/storage";function P(r,e){let t=D(r),a=D(e);return!t&&!a&&(console.error("At least one path must be a remote Tigris path (t3:// or tigris://)"),process.exit(1)),t&&a?"remote-to-remote":t?"remote-to-local":"local-to-remote"}function J(r){return r==="~"||r.startsWith("~/")?B(Y(),r.slice(2)):B(r)}function ee(r){return N(r,{recursive:!0,withFileTypes:!0}).filter(t=>t.isFile()).map(t=>{let a=t.parentPath??t.path;return x(a,t.name)})}function te(r,e){let t=E(r),a=j(r),p=R(a);return O(t)?e?N(t,{recursive:!0,withFileTypes:!0}).filter(o=>o.isFile()&&p.test(o.name)).map(o=>{let n=o.parentPath??o.path;return x(n,o.name)}):N(t,{withFileTypes:!0}).filter(n=>n.isFile()&&p.test(n.name)).map(n=>x(t,n.name)):[]}async function U(r,e,t,a,p=!1){let u;try{u=z(r).size}catch{return{error:`File not found: ${r}`}}let o=Q(r),n=q.toWeb(o),i=u!==void 0&&u>100*1024*1024,{error:l}=await A(t,n,{multipart:i,onUploadProgress:p?({loaded:c})=>{if(u!==void 0&&u>0){let s=Math.round(c/u*100);process.stdout.write(`\rUploading: ${$(c)} / ${$(u)} (${s}%)`)}else process.stdout.write(`\rUploading: ${$(c)}`)}:void 0,config:{...a,bucket:e}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),l?{error:l.message}:{}}async function K(r,e,t,a,p=!1){let u;if(p){let{data:s}=await H(e,{config:{...a,bucket:r}});u=s?.size}let{data:o,error:n}=await G(e,"stream",{config:{...a,bucket:r}});if(n)return{error:n.message};let i=E(t);O(i)||X(i,{recursive:!0});let l=V(t),c=q.fromWeb(o);if(p&&u!==void 0&&u>0){let s=0;c.on("data",h=>{s+=h.length;let m=Math.round(s/u*100);process.stdout.write(`\rDownloading: ${$(s)} / ${$(u)} (${m}%)`)})}return await Z(c,l),p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function I(r,e,t,a,p,u=!1){if(t.endsWith("/")){let{error:s}=await A(p,"",{config:{...r,bucket:a}});return s?{error:s.message}:{}}let o;if(u){let{data:s}=await H(t,{config:{...r,bucket:e}});o=s?.size}let{data:n,error:i}=await G(t,"stream",{config:{...r,bucket:e}});if(i)return{error:i.message};let l=o!==void 0&&o>100*1024*1024,{error:c}=await A(p,n,{multipart:l,onUploadProgress:u?({loaded:s})=>{if(o!==void 0&&o>0){let h=Math.round(s/o*100);process.stdout.write(`\rCopying: ${$(s)} / ${$(o)} (${h}%)`)}else process.stdout.write(`\rCopying: ${$(s)}`)}:void 0,config:{...r,bucket:a}});return u&&process.stdout.write("\r"+" ".repeat(60)+"\r"),c?{error:c.message}:{}}async function oe(r,e,t,a){let p=J(r);if(r.includes("*")){let n=te(p,a);if(n.length===0){console.log("No files matching pattern");return}let i=E(p),l=0;for(let c of n){let s=L(i,c),h=e.path?`${e.path.replace(/\/$/,"")}/${s}`:s,m=await U(c,e.bucket,h,t);m.error?console.error(`Failed to upload ${c}: ${m.error}`):(console.log(`Uploaded ${c} -> t3://${e.bucket}/${h}`),l++)}console.log(`Uploaded ${l} file(s)`);return}let o;try{o=z(p)}catch{console.error(`Source not found: ${r}`),process.exit(1)}if(o.isDirectory()){a||(console.error(`${r} is a directory (not copied). Use -r to copy recursively.`),process.exit(1));let n=ee(p);if(n.length===0){console.log("No files to upload");return}let i=r.endsWith("/")?"":j(p),l=0;for(let c of n){let s=L(p,c),m=[e.path?.replace(/\/$/,""),i,s].filter(Boolean).join("/"),b=await U(c,e.bucket,m,t);b.error?console.error(`Failed to upload ${c}: ${b.error}`):(console.log(`Uploaded ${c} -> t3://${e.bucket}/${m}`),l++)}console.log(`Uploaded ${l} file(s)`)}else{let n=j(p),i;e.path?r.endsWith("/")||e.path.endsWith("/")?i=`${e.path.replace(/\/$/,"")}/${n}`:await S(e.bucket,e.path,t)?i=`${e.path}/${n}`:i=e.path:i=n;let l=await U(p,e.bucket,i,t,!0);l.error&&(console.error(l.error),process.exit(1)),console.log(`Uploaded ${r} -> t3://${e.bucket}/${i}`)}}async function re(r,e,t,a,p){let u=r.endsWith("/");!e.path&&!u&&(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let o=J(t),n=e.path.includes("*"),i=e.path.endsWith("/")||!e.path&&u;if(!n&&!i&&(i=await S(e.bucket,e.path,a)),i&&!n&&!p&&(console.error("Source is a remote folder (not copied). Use -r to copy recursively."),process.exit(1)),n||i){let l=n?C(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",c=!n&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",{items:s,error:h}=await T(e.bucket,l||void 0,a);h&&(console.error(h.message),process.exit(1));let m=s.filter(d=>!d.name.endsWith("/"));if(n){let d=e.path.split("/").pop(),g=R(d);m=m.filter(w=>{let f=l?w.name.slice(l.length):w.name;return!p&&f.includes("/")?!1:g.test(f.split("/").pop())})}if(m.length===0){console.log("No objects to download");return}let b=0;for(let d of m){let g=l?d.name.slice(l.length):d.name,w=c?x(o,c,g):x(o,g),f=await K(e.bucket,d.name,w,a);f.error?console.error(`Failed to download ${d.name}: ${f.error}`):(console.log(`Downloaded t3://${e.bucket}/${d.name} -> ${w}`),b++)}console.log(`Downloaded ${b} file(s)`)}else{let l=e.path.split("/").pop(),c,s=!1;try{s=z(o).isDirectory()}catch{}s||t.endsWith("/")?c=x(o,l):c=o;let h=await K(e.bucket,e.path,c,a,!0);h.error&&(console.error(h.error),process.exit(1)),console.log(`Downloaded t3://${e.bucket}/${e.path} -> ${c}`)}}async function ie(r,e,t,a,p){let u=r.endsWith("/");!e.path&&!u&&(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let o=r.includes("*"),n=e.path.endsWith("/")||!e.path&&u;if(!o&&!n&&e.path&&(n=await S(e.bucket,e.path,a)),n&&!o&&!p&&(console.error("Source is a remote folder (not copied). Use -r to copy recursively."),process.exit(1)),o||n){let i=o?C(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",l=!o&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",s=[t.path?.replace(/\/$/,"")||"",l].filter(Boolean).join("/"),h=s?`${s}/`:"";e.bucket===t.bucket&&i===h&&(console.error("Source and destination are the same"),process.exit(1));let{items:m,error:b}=await T(e.bucket,i||void 0,a);b&&(console.error(b.message),process.exit(1));let d=m.filter(f=>f.name!==i);if(o){let f=e.path.split("/").pop(),y=R(f);d=d.filter(k=>{let F=i?k.name.slice(i.length):k.name;return!p&&F.includes("/")?!1:y.test(F.split("/").pop())})}let g=0;for(let f of d){let y=i?f.name.slice(i.length):f.name,k=s?`${s}/${y}`:y,F=await I(a,e.bucket,f.name,t.bucket,k);F.error?console.error(`Failed to copy ${f.name}: ${F.error}`):(console.log(`Copied t3://${e.bucket}/${f.name} -> t3://${t.bucket}/${k}`),g++)}let w=!1;if(s&&i){let{data:f}=await _({prefix:i,limit:1,config:{...a,bucket:e.bucket}});if(f?.items?.some(y=>y.name===i)){let y=`${s}/`,k=await I(a,e.bucket,i,t.bucket,y);k.error?console.error(`Failed to copy folder marker: ${k.error}`):w=!0}}if(g===0&&w&&(g=1),g===0){console.log("No objects to copy");return}console.log(`Copied ${g} object(s)`)}else{let i=e.path.split("/").pop(),l;t.path?t.path.endsWith("/")?l=`${t.path}${i}`:await S(t.bucket,t.path,a)?l=`${t.path}/${i}`:l=t.path:l=i,e.bucket===t.bucket&&e.path===l&&(console.error("Source and destination are the same"),process.exit(1));let c=await I(a,e.bucket,e.path,t.bucket,l,!0);c.error&&(console.error(c.error),process.exit(1)),console.log(`Copied t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${l}`)}}async function ne(r){let e=v(r,["src"]),t=v(r,["dest"]);(!e||!t)&&(console.error("Both src and dest arguments are required"),process.exit(1));let a=!!v(r,["recursive","r"]),p=P(e,t),u=await M();switch(p){case"local-to-remote":{let o=W(t);o.bucket||(console.error("Invalid destination path"),process.exit(1)),await oe(e,o,u,a);break}case"remote-to-local":{let o=W(e);o.bucket||(console.error("Invalid source path"),process.exit(1)),await re(e,o,t,u,a);break}case"remote-to-remote":{let o=W(e),n=W(t);o.bucket||(console.error("Invalid source path"),process.exit(1)),n.bucket||(console.error("Invalid destination path"),process.exit(1)),await ie(e,o,n,u,a);break}}process.exit(0)}export{ne as default};
1
+ import{a as T}from"../chunk-SAAGVLRE.js";import{a as b}from"../chunk-CQCBYE3X.js";import{a as D}from"../chunk-JRALYIRA.js";import{a as U,b as R,d as v,g as C,h as z,i as B}from"../chunk-LCWHZUZZ.js";import{b as q}from"../chunk-YEF2ZFBJ.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";import{createReadStream as Y,createWriteStream as Z,statSync as M,readdirSync as j,mkdirSync as _,existsSync as H}from"fs";import{resolve as K,dirname as L,basename as A,join as W,relative as O}from"path";import{homedir as P}from"os";import{Readable as J}from"stream";import{pipeline as ee}from"stream/promises";import{get as Q,put as E,list as te,head as V}from"@tigrisdata/storage";function oe(n,e){let t=U(n),a=U(e);return!t&&!a&&(console.error("At least one path must be a remote Tigris path (t3:// or tigris://)"),process.exit(1)),t&&a?"remote-to-remote":t?"remote-to-local":"local-to-remote"}function X(n){return n==="~"||n.startsWith("~/")?K(P(),n.slice(2)):K(n)}function re(n){return j(n,{recursive:!0,withFileTypes:!0}).filter(t=>t.isFile()).map(t=>{let a=t.parentPath??t.path;return W(a,t.name)})}function ne(n,e){let t=L(n),a=A(n),c=C(a);return H(t)?e?j(t,{recursive:!0,withFileTypes:!0}).filter(o=>o.isFile()&&c.test(o.name)).map(o=>{let i=o.parentPath??o.path;return W(i,o.name)}):j(t,{withFileTypes:!0}).filter(i=>i.isFile()&&c.test(i.name)).map(i=>W(t,i.name)):[]}async function I(n,e,t,a,c=!1){let p;try{p=M(n).size}catch{return{error:`File not found: ${n}`}}let o=Y(n),i=J.toWeb(o),r=p!==void 0&&p>16*1024*1024,{error:s}=await E(t,i,{multipart:r,partSize:r?16*1024*1024:void 0,queueSize:r?8:void 0,onUploadProgress:c?({loaded:u})=>{if(p!==void 0&&p>0){let l=Math.round(u/p*100);process.stdout.write(`\rUploading: ${b(u)} / ${b(p)} (${l}%)`)}else process.stdout.write(`\rUploading: ${b(u)}`)}:void 0,config:{...a,bucket:e}});return c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),s?{error:s.message}:{}}async function G(n,e,t,a,c=!1){let p;if(c){let{data:l}=await V(e,{config:{...a,bucket:n}});p=l?.size}let{data:o,error:i}=await Q(e,"stream",{config:{...a,bucket:n}});if(i)return{error:i.message};let r=L(t);H(r)||_(r,{recursive:!0});let s=Z(t),u=J.fromWeb(o);if(c&&p!==void 0&&p>0){let l=0;u.on("data",f=>{l+=f.length;let m=Math.round(l/p*100);process.stdout.write(`\rDownloading: ${b(l)} / ${b(p)} (${m}%)`)})}return await ee(u,s),c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function N(n,e,t,a,c,p=!1){if(t.endsWith("/")){let{error:l}=await E(c,"",{config:{...n,bucket:a}});return l?{error:l.message}:{}}let o;if(p){let{data:l}=await V(t,{config:{...n,bucket:e}});o=l?.size}let{data:i,error:r}=await Q(t,"stream",{config:{...n,bucket:e}});if(r)return{error:r.message};let s=o!==void 0&&o>16*1024*1024,{error:u}=await E(c,i,{multipart:s,partSize:s?16*1024*1024:void 0,queueSize:s?8:void 0,onUploadProgress:p?({loaded:l})=>{if(o!==void 0&&o>0){let f=Math.round(l/o*100);process.stdout.write(`\rCopying: ${b(l)} / ${b(o)} (${f}%)`)}else process.stdout.write(`\rCopying: ${b(l)}`)}:void 0,config:{...n,bucket:a}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),u?{error:u.message}:{}}async function ie(n,e,t,a){let c=X(n);if(n.includes("*")){let i=ne(c,a);if(i.length===0){console.log("No files matching pattern");return}let r=L(c),s=i.map(f=>async()=>{let m=O(r,f),w=e.path?`${e.path.replace(/\/$/,"")}/${m}`:m,d=await I(f,e.bucket,w,t);return d.error?(console.error(`Failed to upload ${f}: ${d.error}`),!1):(console.log(`Uploaded ${f} -> t3://${e.bucket}/${w}`),!0)}),l=(await T(s,8)).filter(Boolean).length;console.log(`Uploaded ${l} file(s)`);return}let o;try{o=M(c)}catch{console.error(`Source not found: ${n}`),process.exit(1)}if(o.isDirectory()){a||(console.error(`${n} is a directory (not copied). Use -r to copy recursively.`),process.exit(1));let i=re(c);if(i.length===0){console.log("No files to upload");return}let r=n.endsWith("/")?"":A(c),s=i.map(f=>async()=>{let m=O(c,f),d=[e.path?.replace(/\/$/,""),r,m].filter(Boolean).join("/"),S=await I(f,e.bucket,d,t);return S.error?(console.error(`Failed to upload ${f}: ${S.error}`),!1):(console.log(`Uploaded ${f} -> t3://${e.bucket}/${d}`),!0)}),l=(await T(s,8)).filter(Boolean).length;console.log(`Uploaded ${l} file(s)`)}else{let i=A(c),r;e.path?n.endsWith("/")||e.path.endsWith("/")?r=`${e.path.replace(/\/$/,"")}/${i}`:await v(e.bucket,e.path,t)?r=`${e.path}/${i}`:r=e.path:r=i;let s=await I(c,e.bucket,r,t,!0);s.error&&(console.error(s.error),process.exit(1)),console.log(`Uploaded ${n} -> t3://${e.bucket}/${r}`)}}async function ae(n,e,t,a,c){let p=n.endsWith("/");!e.path&&!p&&(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let o=X(t),i=e.path.includes("*"),r=e.path.endsWith("/")||!e.path&&p;if(!i&&!r&&(r=await v(e.bucket,e.path,a)),r&&!i&&!c&&(console.error("Source is a remote folder (not copied). Use -r to copy recursively."),process.exit(1)),i||r){let s=i?z(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",u=!i&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",{items:l,error:f}=await B(e.bucket,s||void 0,a);f&&(console.error(f.message),process.exit(1));let m=l.filter(g=>!g.name.endsWith("/"));if(i){let g=e.path.split("/").pop(),$=C(g);m=m.filter(y=>{let h=s?y.name.slice(s.length):y.name;return!c&&h.includes("/")?!1:$.test(h.split("/").pop())})}if(m.length===0){console.log("No objects to download");return}let w=m.map(g=>async()=>{let $=s?g.name.slice(s.length):g.name,y=u?W(o,u,$):W(o,$),h=await G(e.bucket,g.name,y,a);return h.error?(console.error(`Failed to download ${g.name}: ${h.error}`),!1):(console.log(`Downloaded t3://${e.bucket}/${g.name} -> ${y}`),!0)}),S=(await T(w,8)).filter(Boolean).length;console.log(`Downloaded ${S} file(s)`)}else{let s=e.path.split("/").pop(),u,l=!1;try{l=M(o).isDirectory()}catch{}l||t.endsWith("/")?u=W(o,s):u=o;let f=await G(e.bucket,e.path,u,a,!0);f.error&&(console.error(f.error),process.exit(1)),console.log(`Downloaded t3://${e.bucket}/${e.path} -> ${u}`)}}async function se(n,e,t,a,c){let p=n.endsWith("/");!e.path&&!p&&(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let o=n.includes("*"),i=e.path.endsWith("/")||!e.path&&p;if(!o&&!i&&e.path&&(i=await v(e.bucket,e.path,a)),i&&!o&&!c&&(console.error("Source is a remote folder (not copied). Use -r to copy recursively."),process.exit(1)),o||i){let r=o?z(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",s=!o&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",l=[t.path?.replace(/\/$/,"")||"",s].filter(Boolean).join("/"),f=l?`${l}/`:"";e.bucket===t.bucket&&r===f&&(console.error("Source and destination are the same"),process.exit(1));let{items:m,error:w}=await B(e.bucket,r||void 0,a);w&&(console.error(w.message),process.exit(1));let d=m.filter(h=>h.name!==r);if(o){let h=e.path.split("/").pop(),k=C(h);d=d.filter(x=>{let F=r?x.name.slice(r.length):x.name;return!c&&F.includes("/")?!1:k.test(F.split("/").pop())})}let S=d.map(h=>async()=>{let k=r?h.name.slice(r.length):h.name,x=l?`${l}/${k}`:k,F=await N(a,e.bucket,h.name,t.bucket,x);return F.error?(console.error(`Failed to copy ${h.name}: ${F.error}`),!1):(console.log(`Copied t3://${e.bucket}/${h.name} -> t3://${t.bucket}/${x}`),!0)}),$=(await T(S,8)).filter(Boolean).length,y=!1;if(l&&r){let{data:h}=await te({prefix:r,limit:1,config:{...a,bucket:e.bucket}});if(h?.items?.some(k=>k.name===r)){let k=`${l}/`,x=await N(a,e.bucket,r,t.bucket,k);x.error?console.error(`Failed to copy folder marker: ${x.error}`):y=!0}}if($===0&&y&&($=1),$===0){console.log("No objects to copy");return}console.log(`Copied ${$} object(s)`)}else{let r=e.path.split("/").pop(),s;t.path?t.path.endsWith("/")?s=`${t.path}${r}`:await v(t.bucket,t.path,a)?s=`${t.path}/${r}`:s=t.path:s=r,e.bucket===t.bucket&&e.path===s&&(console.error("Source and destination are the same"),process.exit(1));let u=await N(a,e.bucket,e.path,t.bucket,s,!0);u.error&&(console.error(u.error),process.exit(1)),console.log(`Copied t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${s}`)}}async function le(n){let e=D(n,["src"]),t=D(n,["dest"]);(!e||!t)&&(console.error("Both src and dest arguments are required"),process.exit(1));let a=!!D(n,["recursive","r"]),c=oe(e,t),p=await q();switch(c){case"local-to-remote":{let o=R(t);o.bucket||(console.error("Invalid destination path"),process.exit(1)),await ie(e,o,p,a);break}case"remote-to-local":{let o=R(e);o.bucket||(console.error("Invalid source path"),process.exit(1)),await ae(e,o,t,p,a);break}case"remote-to-remote":{let o=R(e),i=R(t);o.bucket||(console.error("Invalid source path"),process.exit(1)),i.bucket||(console.error("Invalid destination path"),process.exit(1)),await se(e,o,i,p,a);break}}process.exit(0)}export{le as default};
@@ -1 +1 @@
1
- import{a as f,b as g,c as n,g as u}from"../../chunk-SYGTCM6P.js";import{a as d}from"../../chunk-JRALYIRA.js";import{b as l}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as a}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as m,getBucketInfo as p}from"@tigrisdata/storage";var e=u("credentials","test");async function b(k){f(e);let t=d(k,["bucket","b"]),o=await l();!o.accessKeyId&&!o.sessionToken&&(n(e,'No credentials found. Run "tigris configure" or "tigris login" first.'),process.exit(1));let c=a(),r={...o,...c&&!o.organizationId?{organizationId:c}:{}};if(t){let{data:i,error:s}=await p(t,{config:r});s&&(n(e,`Current credentials don't have access to bucket "${t}"`),process.exit(1)),console.log(` Bucket: ${t}`),console.log(" Access verified."),i.sourceBucketName&&console.log(` Fork of: ${i.sourceBucketName}`)}else{let{data:i,error:s}=await m({config:r});s&&(n(e,"Current credentials don't have sufficient access"),process.exit(1)),console.log(` Access verified. Found ${i.buckets.length} bucket(s).`)}g(e)}export{b as default};
1
+ import{a as f,b as g,c as n,g as u}from"../../chunk-SYGTCM6P.js";import{a as d}from"../../chunk-JRALYIRA.js";import{b as l}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as a}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as m,getBucketInfo as p}from"@tigrisdata/storage";var e=u("credentials","test");async function b(k){f(e);let t=d(k,["bucket","b"]),o=await l();!o.accessKeyId&&!o.sessionToken&&(n(e,'No credentials found. Run "tigris configure" or "tigris login" first.'),process.exit(1));let c=a(),r={...o,...c&&!o.organizationId?{organizationId:c}:{}};if(t){let{data:i,error:s}=await p(t,{config:r});s&&(n(e,`Current credentials don't have access to bucket "${t}"`),process.exit(1)),console.log(` Bucket: ${t}`),console.log(" Access verified."),i.sourceBucketName&&console.log(` Fork of: ${i.sourceBucketName}`)}else{let{data:i,error:s}=await m({config:r});s&&(n(e,"Current credentials don't have sufficient access"),process.exit(1)),console.log(` Access verified. Found ${i.buckets.length} bucket(s).`)}g(e)}export{b as default};
@@ -1 +1 @@
1
- import{a as c,b as a,c as r,g as m}from"../../chunk-SYGTCM6P.js";import{a as t}from"../../chunk-JRALYIRA.js";import{b as f}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createBucket as p}from"@tigrisdata/storage";var e=m("forks","create");async function g(o){c(e);let s=t(o,["name"]),n=t(o,["fork-name","forkName"]),u=t(o,["snapshot","s","S"]);s||(r(e,"Source bucket name is required"),process.exit(1)),n||(r(e,"Fork name is required"),process.exit(1));let{error:i}=await p(n,{sourceBucketName:s,sourceBucketSnapshot:u,config:await f()});i&&(r(e,i.message),process.exit(1)),a(e,{name:s,forkName:n})}export{g as default};
1
+ import{a as c,b as a,c as r,g as m}from"../../chunk-SYGTCM6P.js";import{a as t}from"../../chunk-JRALYIRA.js";import{b as f}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createBucket as p}from"@tigrisdata/storage";var e=m("forks","create");async function g(o){c(e);let s=t(o,["name"]),n=t(o,["fork-name","forkName"]),u=t(o,["snapshot","s","S"]);s||(r(e,"Source bucket name is required"),process.exit(1)),n||(r(e,"Fork name is required"),process.exit(1));let{error:i}=await p(n,{sourceBucketName:s,sourceBucketSnapshot:u,config:await f()});i&&(r(e,i.message),process.exit(1)),a(e,{name:s,forkName:n})}export{g as default};
@@ -1 +1 @@
1
- import{a as u,b as p,c as n,d as s,g}from"../../chunk-SYGTCM6P.js";import{f as d}from"../../chunk-CQCBYE3X.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as k}from"../../chunk-USCKVLDO.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as S,getBucketInfo as l}from"@tigrisdata/storage";var t=g("forks","list");async function B(c){u(t);let e=i(c,["name"]),h=i(c,["format","f","F"],"table");e||(n(t,"Source bucket name is required"),process.exit(1));let a=await k(),{data:b,error:f}=await l(e,{config:a});if(f&&(n(t,f.message),process.exit(1)),!b.hasForks){s(t);return}let{data:w,error:m}=await S({config:a});m&&(n(t,m.message),process.exit(1));let r=[];for(let o of w.buckets){if(o.name===e)continue;let{data:y}=await l(o.name,{config:a});y?.sourceBucketName===e&&r.push({name:o.name,created:o.creationDate})}if(r.length===0){s(t);return}let x=d(r,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(x),p(t,{count:r.length})}export{B as default};
1
+ import{a as u,b as p,c as n,d as s,g}from"../../chunk-SYGTCM6P.js";import{f as d}from"../../chunk-CQCBYE3X.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as k}from"../../chunk-YEF2ZFBJ.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as S,getBucketInfo as l}from"@tigrisdata/storage";var t=g("forks","list");async function B(c){u(t);let e=i(c,["name"]),h=i(c,["format","f","F"],"table");e||(n(t,"Source bucket name is required"),process.exit(1));let a=await k(),{data:b,error:f}=await l(e,{config:a});if(f&&(n(t,f.message),process.exit(1)),!b.hasForks){s(t);return}let{data:w,error:m}=await S({config:a});m&&(n(t,m.message),process.exit(1));let r=[];for(let o of w.buckets){if(o.name===e)continue;let{data:y}=await l(o.name,{config:a});y?.sourceBucketName===e&&r.push({name:o.name,created:o.creationDate})}if(r.length===0){s(t);return}let x=d(r,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(x),p(t,{count:r.length})}export{B as default};
@@ -1,2 +1,2 @@
1
- import{a as x,b as P}from"../../../chunk-Y7MJZRR4.js";import{a as p,b as f,c as e,g as h}from"../../../chunk-SYGTCM6P.js";import{a as n}from"../../../chunk-JRALYIRA.js";import{a as y}from"../../../chunk-USCKVLDO.js";import"../../../chunk-BETAO4PB.js";import{b as g}from"../../../chunk-E4MLGABW.js";import{g as u}from"../../../chunk-DOUR5YEY.js";import{c as l}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import{existsSync as T,readFileSync as C}from"fs";import{addPolicy as k}from"@tigrisdata/iam";var t=h("iam policies","create");async function N(s){p(t);let r=n(s,["name"]),i=n(s,["document","d"]),w=n(s,["description"])??"";r||(e(t,"Policy name is required"),process.exit(1)),/^[a-zA-Z0-9=,.@_-]+$/.test(r)||(e(t,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed."),process.exit(1)),await y()!=="oauth"&&(e(t,`Policies can only be created when logged in via OAuth.
1
+ import{a as x,b as P}from"../../../chunk-Y7MJZRR4.js";import{a as p,b as f,c as e,g as h}from"../../../chunk-SYGTCM6P.js";import{a as n}from"../../../chunk-JRALYIRA.js";import{a as y}from"../../../chunk-YEF2ZFBJ.js";import"../../../chunk-BETAO4PB.js";import{b as g}from"../../../chunk-E4MLGABW.js";import{g as u}from"../../../chunk-DOUR5YEY.js";import{c as l}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import{existsSync as T,readFileSync as C}from"fs";import{addPolicy as k}from"@tigrisdata/iam";var t=h("iam policies","create");async function N(s){p(t);let r=n(s,["name"]),i=n(s,["document","d"]),w=n(s,["description"])??"";r||(e(t,"Policy name is required"),process.exit(1)),/^[a-zA-Z0-9=,.@_-]+$/.test(r)||(e(t,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed."),process.exit(1)),await y()!=="oauth"&&(e(t,`Policies can only be created when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let c=g();await c.isAuthenticated()||(e(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let A=await c.getAccessToken(),v=u(),S=l(),O={sessionToken:A,organizationId:v??void 0,iamEndpoint:S.iamEndpoint},o;i?T(i)?o=C(i,"utf-8"):o=i:process.stdin.isTTY?(e(t,"Policy document is required. Provide via --document or pipe to stdin."),process.exit(1)):o=await x();let a;try{a=P(o)}catch{e(t,"Invalid JSON in policy document"),process.exit(1)}let{data:d,error:m}=await k(r,{document:a,description:w,config:O});m&&(e(t,m.message),process.exit(1)),f(t,{name:d.name}),console.log(`Resource: ${d.resource}`)}export{N as default};
@@ -1,2 +1,2 @@
1
- import{a as p,b as d,c as t,d as f,g as u}from"../../../chunk-SYGTCM6P.js";import{a as w}from"../../../chunk-JRALYIRA.js";import{a as h}from"../../../chunk-USCKVLDO.js";import"../../../chunk-BETAO4PB.js";import{b as m}from"../../../chunk-E4MLGABW.js";import{g}from"../../../chunk-DOUR5YEY.js";import{c as l}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import E from"enquirer";import{deletePolicy as S,listPolicies as T}from"@tigrisdata/iam";var{prompt:O}=E,e=u("iam policies","delete");async function M(x){p(e);let i=w(x,["resource"]);await h()!=="oauth"&&(t(e,`Policies can only be deleted when logged in via OAuth.
1
+ import{a as p,b as d,c as t,d as f,g as u}from"../../../chunk-SYGTCM6P.js";import{a as w}from"../../../chunk-JRALYIRA.js";import{a as h}from"../../../chunk-YEF2ZFBJ.js";import"../../../chunk-BETAO4PB.js";import{b as m}from"../../../chunk-E4MLGABW.js";import{g}from"../../../chunk-DOUR5YEY.js";import{c as l}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import E from"enquirer";import{deletePolicy as S,listPolicies as T}from"@tigrisdata/iam";var{prompt:O}=E,e=u("iam policies","delete");async function M(x){p(e);let i=w(x,["resource"]);await h()!=="oauth"&&(t(e,`Policies can only be deleted when logged in via OAuth.
2
2
  Run "tigris login oauth" first.`),process.exit(1));let s=m();await s.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let y=await s.getAccessToken(),A=g(),C=l(),r={sessionToken:y,organizationId:A??void 0,iamEndpoint:C.iamEndpoint};if(!i){let{data:o,error:a}=await T({config:r});if(a&&(t(e,a.message),process.exit(1)),!o.policies||o.policies.length===0){f(e);return}let{selected:k}=await O({type:"select",name:"selected",message:"Select a policy to delete:",choices:o.policies.map(n=>({name:n.resource,message:`${n.name} (${n.resource})`}))});i=k}let{error:c}=await S(i,{config:r});c&&(t(e,c.message),process.exit(1)),d(e,{resource:i})}export{M as default};