@tigrisdata/cli 2.6.1 → 2.6.2

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 (60) hide show
  1. package/README.md +22 -13
  2. package/dist/auth/client.js +1 -1
  3. package/dist/auth/config.js +1 -1
  4. package/dist/auth/s3-client.js +1 -1
  5. package/dist/auth/storage.js +1 -1
  6. package/dist/{chunk-NYAHHQ3A.js → chunk-6U4U4JM6.js} +1 -1
  7. package/dist/chunk-D63SZLT5.js +1 -0
  8. package/dist/{chunk-IACJQZUD.js → chunk-DJIPPZGR.js} +1 -1
  9. package/dist/{chunk-TQWT7ROJ.js → chunk-ESJWTUFN.js} +1 -1
  10. package/dist/{chunk-DYTBLGO7.js → chunk-HE7E7ZMA.js} +1 -1
  11. package/dist/{chunk-PKWQDQLT.js → chunk-JVB3Y42V.js} +1 -1
  12. package/dist/chunk-LCWHZUZZ.js +1 -0
  13. package/dist/{chunk-WE6NZ2ZK.js → chunk-QZXBLNMQ.js} +1 -1
  14. package/dist/chunk-TPUZYSCZ.js +12 -0
  15. package/dist/chunk-TUJTXB5G.js +8 -0
  16. package/dist/cli.js +1 -1
  17. package/dist/constants.js +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/lib/_stat.js +1 -1
  20. package/dist/lib/access-keys/assign.js +1 -1
  21. package/dist/lib/access-keys/create.js +1 -1
  22. package/dist/lib/access-keys/delete.js +1 -1
  23. package/dist/lib/access-keys/get.js +1 -1
  24. package/dist/lib/access-keys/list.js +1 -1
  25. package/dist/lib/buckets/create.js +1 -1
  26. package/dist/lib/buckets/delete.js +1 -1
  27. package/dist/lib/buckets/get.js +1 -1
  28. package/dist/lib/buckets/list.js +1 -1
  29. package/dist/lib/buckets/set.js +1 -1
  30. package/dist/lib/configure/index.js +1 -1
  31. package/dist/lib/cp.js +1 -1
  32. package/dist/lib/credentials/test.js +1 -1
  33. package/dist/lib/forks/create.js +1 -1
  34. package/dist/lib/forks/list.js +1 -1
  35. package/dist/lib/login/credentials.js +1 -1
  36. package/dist/lib/login/oauth.js +1 -1
  37. package/dist/lib/login/select.js +1 -1
  38. package/dist/lib/logout.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/organizations/create.js +1 -1
  47. package/dist/lib/organizations/list.js +1 -1
  48. package/dist/lib/organizations/select.js +1 -1
  49. package/dist/lib/rm.js +1 -1
  50. package/dist/lib/snapshots/list.js +1 -1
  51. package/dist/lib/snapshots/take.js +1 -1
  52. package/dist/lib/touch.js +1 -1
  53. package/dist/lib/whoami.js +1 -1
  54. package/dist/specs.yaml +49 -28
  55. package/dist/utils/path.js +1 -1
  56. package/dist/utils/update-check.js +1 -0
  57. package/package.json +1 -1
  58. package/dist/chunk-4BZ377KV.js +0 -1
  59. package/dist/chunk-I3FOSZPG.js +0 -1
  60. package/dist/chunk-IY46B353.js +0 -12
package/README.md CHANGED
@@ -21,16 +21,16 @@ Run `tigris help` to see all available commands, or `tigris <command> help` for
21
21
  - `tigris ls [path]` - List buckets or objects in a bucket or path
22
22
  - `tigris mk <path>` - Create a bucket or a folder in a bucket
23
23
  - `tigris touch <path>` - Create an empty object in a bucket
24
- - `tigris cp <src> <dest>` - Copy a folder or an object
25
- - `tigris mv <src> <dest>` - Move a folder or an object
26
- - `tigris rm <path>` - Remove a bucket or a folder in a bucket or an object in a bucket or path
24
+ - `tigris cp <src> <dest>` - Copy files between local filesystem and Tigris, or within Tigris
25
+ - `tigris mv <src> <dest>` - Move objects within Tigris
26
+ - `tigris rm <path>` - Remove a bucket, folder, or object from Tigris
27
27
 
28
28
  ### Authentication
29
29
 
30
30
  - `tigris login` - Start a session. Use OAuth (default) or temporary credentials that override your saved config
31
31
  - `tigris logout` - End your session. Clears login state but keeps credentials from 'configure'
32
32
  - `tigris whoami` - Show information about the current user
33
- - `tigris configure` - Save credentials permanently. After running this, all commands work automatically
33
+ - `tigris configure` - Save credentials permanently. After running this, all commands uses these credentials.
34
34
 
35
35
  ### Resources
36
36
 
@@ -58,6 +58,7 @@ tigris ls [path]
58
58
  ```bash
59
59
  tigris ls my-bucket
60
60
  tigris ls my-bucket/my-path
61
+ tigris ls t3://my-bucket
61
62
  ```
62
63
 
63
64
  ### `mk` | `create`
@@ -72,6 +73,7 @@ tigris mk <path>
72
73
  ```bash
73
74
  tigris mk my-bucket
74
75
  tigris mk my-bucket/my-path
76
+ tigris mk t3://my-bucket
75
77
  ```
76
78
 
77
79
  ### `touch`
@@ -85,16 +87,21 @@ tigris touch <path>
85
87
  **Examples:**
86
88
  ```bash
87
89
  tigris touch my-bucket/my-file.txt
90
+ tigris touch t3://my-bucket/my-file.txt
88
91
  ```
89
92
 
90
93
  ### `cp` | `copy`
91
94
 
92
- Copy a folder or an object
95
+ Copy files between local filesystem and Tigris, or within Tigris
93
96
 
94
97
  ```
95
- tigris cp <src> <dest>
98
+ tigris cp <src> <dest> [flags]
96
99
  ```
97
100
 
101
+ | Flag | Description |
102
+ |------|-------------|
103
+ | `-r, --recursive` | copy directories recursively |
104
+
98
105
  **Examples:**
99
106
  ```bash
100
107
  tigris cp bucket/file.txt bucket/copy.txt
@@ -103,7 +110,7 @@ tigris cp bucket/folder/ other-bucket/folder/
103
110
 
104
111
  ### `mv` | `move`
105
112
 
106
- Move a folder or an object
113
+ Move objects within Tigris
107
114
 
108
115
  ```
109
116
  tigris mv <src> <dest> [flags]
@@ -111,6 +118,7 @@ tigris mv <src> <dest> [flags]
111
118
 
112
119
  | Flag | Description |
113
120
  |------|-------------|
121
+ | `-r, --recursive` | move directories recursively |
114
122
  | `-f, --force` | Skip confirmation prompt |
115
123
 
116
124
  **Examples:**
@@ -121,7 +129,7 @@ tigris mv bucket/folder/ other-bucket/folder/
121
129
 
122
130
  ### `rm` | `remove`
123
131
 
124
- Remove a bucket or a folder in a bucket or an object in a bucket or path
132
+ Remove a bucket, folder, or object from Tigris
125
133
 
126
134
  ```
127
135
  tigris rm <path> [flags]
@@ -129,13 +137,14 @@ tigris rm <path> [flags]
129
137
 
130
138
  | Flag | Description |
131
139
  |------|-------------|
140
+ | `-r, --recursive` | remove directories recursively |
132
141
  | `-f, --force` | Skip confirmation prompt |
133
142
 
134
143
  **Examples:**
135
144
  ```bash
136
- tigris rm my-bucket
137
- tigris rm my-bucket/my-path
138
- tigris rm my-bucket/my-path/*
145
+ tigris rm t3://my-bucket
146
+ tigris rm t3://my-bucket/my-path/my-object.json
147
+ tigris rm t3://my-bucket/my-path/
139
148
  ```
140
149
 
141
150
  ## Authentication
@@ -191,7 +200,7 @@ tigris whoami
191
200
 
192
201
  ### `configure` | `c`
193
202
 
194
- Save credentials permanently. After running this, all commands work automatically
203
+ Save credentials permanently. After running this, all commands uses these credentials.
195
204
 
196
205
  ```
197
206
  tigris configure [flags]
@@ -463,7 +472,7 @@ tigris objects get <bucket> <key> [flags]
463
472
  #### `objects put`
464
473
 
465
474
  ```
466
- tigris objects put <bucket> <key> <file> [flags]
475
+ tigris objects put <bucket> <key> [file] [flags]
467
476
  ```
468
477
 
469
478
  | Flag | Description |
@@ -1 +1 @@
1
- import{a,b}from"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";export{a as TigrisAuthClient,b as getAuthClient};
1
+ import{a,b}from"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";export{a as TigrisAuthClient,b as getAuthClient};
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-NYAHHQ3A.js";import"../chunk-4BZ377KV.js";export{b as TIGRIS_CLAIMS_NAMESPACE,a as getAuth0Config,c as getTigrisConfig};
1
+ import{a,b,c}from"../chunk-6U4U4JM6.js";import"../chunk-D63SZLT5.js";export{b as TIGRIS_CLAIMS_NAMESPACE,a as getAuth0Config,c as getTigrisConfig};
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";export{a as getLoginMethod,c as getS3Client,b as getStorageConfig,d as isAuthenticated};
1
+ import{a,b,c,d}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";export{a as getLoginMethod,c as getS3Client,b as getStorageConfig,d as isAuthenticated};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t}from"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";export{t as clearAllData,q as clearCredentials,p as clearTemporaryCredentials,c as clearTokens,j as getAwsProfileConfig,k as getCredentials,h as getEnvCredentials,s as getLoginMethod,e as getOrganizations,m as getSavedCredentials,g as getSelectedOrganization,l as getStoredCredentials,b as getTokens,i as hasAwsProfile,n as storeCredentials,r as storeLoginMethod,d as storeOrganizations,f as storeSelectedOrganization,o as storeTemporaryCredentials,a as storeTokens};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t}from"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";export{t as clearAllData,q as clearCredentials,p as clearTemporaryCredentials,c as clearTokens,j as getAwsProfileConfig,k as getCredentials,h as getEnvCredentials,s as getLoginMethod,e as getOrganizations,m as getSavedCredentials,g as getSelectedOrganization,l as getStoredCredentials,b as getTokens,i as hasAwsProfile,n as storeCredentials,r as storeLoginMethod,d as storeOrganizations,f as storeSelectedOrganization,o as storeTemporaryCredentials,a as storeTokens};
@@ -1 +1 @@
1
- import{a as n,b as i}from"./chunk-4BZ377KV.js";function I(){let e=process.env.TIGRIS_ENV==="development",t=e?"auth-dev.tigris.dev":process.env.AUTH0_DOMAIN??"auth.tigris.dev",s=e?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":process.env.AUTH0_CLIENT_ID??"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",o=e?"https://tigris-api-dev":process.env.AUTH0_AUDIENCE??"https://tigris-os-api";return{domain:t,clientId:s,audience:o}}var p=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function T(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||n,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||i}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||n,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||i}}export{I as a,p as b,T as c};
1
+ import{a as n,b as i}from"./chunk-D63SZLT5.js";function I(){let e=process.env.TIGRIS_ENV==="development",t=e?"auth-dev.tigris.dev":process.env.AUTH0_DOMAIN??"auth.tigris.dev",s=e?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":process.env.AUTH0_CLIENT_ID??"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",o=e?"https://tigris-api-dev":process.env.AUTH0_AUDIENCE??"https://tigris-os-api";return{domain:t,clientId:s,audience:o}}var p=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function T(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||n,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||i}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||n,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||i}}export{I as a,p as b,T as c};
@@ -0,0 +1 @@
1
+ var t="https://t3.storage.dev",s="https://iam.storageapi.dev",o="https://registry.npmjs.org/@tigrisdata/cli/latest",e=864e5;export{t as a,s as b,o as c,e as d};
@@ -1,4 +1,4 @@
1
- import{a as s,b as e,c,e as g,f as l,g as u}from"./chunk-A3TXP5Y2.js";import{b as a}from"./chunk-WE6NZ2ZK.js";import{f as r}from"./chunk-PKWQDQLT.js";var t=u("login","oauth");async function f(){s(t);try{let n=a();if(await n.isAuthenticated()){g(t);return}await n.login({onDeviceCode:(o,p)=>{console.log(`
1
+ import{a as s,b as e,c,e as g,f as l,g as u}from"./chunk-A3TXP5Y2.js";import{b as a}from"./chunk-QZXBLNMQ.js";import{f as r}from"./chunk-JVB3Y42V.js";var t=u("login","oauth");async function f(){s(t);try{let n=a();if(await n.isAuthenticated()){g(t);return}await n.login({onDeviceCode:(o,p)=>{console.log(`
2
2
  Your confirmation code: ${o}
3
3
  `),console.log(`If browser doesn't open, visit: ${p}`)},onWaiting:()=>console.log(`
4
4
  Waiting for authentication...`)});let i=await n.getOrganizations();if(i.length>0){let o=i[0];await r(o.id),e(t,{org:o.displayName||o.name}),i.length>1&&l(t,{count:i.length})}else e(t,{org:"none"})}catch{c(t),process.exit(1)}}var A=f;export{f as a,A as b};
@@ -1 +1 @@
1
- import{b as f}from"./chunk-WE6NZ2ZK.js";import{a as A,c as w}from"./chunk-NYAHHQ3A.js";import{g as d,h as g,i as l,j as p,l as o,s as h}from"./chunk-PKWQDQLT.js";import{a as u}from"./chunk-4BZ377KV.js";import{S3Client as a}from"@aws-sdk/client-s3";import{fromIni as C}from"@aws-sdk/credential-providers";var r=w(),T=A();async function y(){return h()}async function O(){if(l()){let e=process.env.AWS_PROFILE||"default",s=await p(e),i=await C({profile:e})();return{accessKeyId:i.accessKeyId,secretAccessKey:i.secretAccessKey,endpoint:s.endpoint||r.endpoint||u,iamEndpoint:s.iamEndpoint||r.iamEndpoint}}let c=await y();if(c==="oauth"){let s=await f().getAccessToken();if(!d())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:s,accessKeyId:"",secretAccessKey:"",endpoint:r.endpoint,organizationId:d()??void 0,iamEndpoint:r.iamEndpoint,authDomain:T.domain}}if(c==="credentials"){let e=o();if(e)return{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,endpoint:e.endpoint}}let t=g();if(t)return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint};let n=o();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}async function v(){if(l()){let e=process.env.AWS_PROFILE||"default",s=await p(e);return new a({region:"auto",endpoint:s.endpoint||r.endpoint||u,credentials:C({profile:e})})}let c=await y();if(c==="oauth"){let s=await f().getAccessToken(),i=d();if(!i)throw new Error('No organization selected. Please run "tigris orgs select" first.');let K=new a({region:"auto",endpoint:r.endpoint,credentials:{sessionToken:s,accessKeyId:"",secretAccessKey:""}});return K.middlewareStack.add(I=>async m=>{let E=m.request;return E.headers["x-Tigris-Namespace"]=i,await I(m)},{name:"x-Tigris-Namespace-Middleware",step:"build",override:!0}),K}if(c==="credentials"){let e=o();if(e)return new a({region:"auto",endpoint:e.endpoint,credentials:{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey}})}let t=g();if(t)return new a({region:"auto",endpoint:t.endpoint,credentials:{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey}});let n=o();if(n)return new a({region:"auto",endpoint:n.endpoint,credentials:{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey}});throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}async function z(){return l()||await y()!==null||g()!==null||o()!==null}export{y as a,O as b,v as c,z as d};
1
+ import{b as f}from"./chunk-QZXBLNMQ.js";import{a as A,c as w}from"./chunk-6U4U4JM6.js";import{g as d,h as g,i as l,j as p,l as o,s as h}from"./chunk-JVB3Y42V.js";import{a as u}from"./chunk-D63SZLT5.js";import{S3Client as a}from"@aws-sdk/client-s3";import{fromIni as C}from"@aws-sdk/credential-providers";var r=w(),T=A();async function y(){return h()}async function O(){if(l()){let e=process.env.AWS_PROFILE||"default",s=await p(e),i=await C({profile:e})();return{accessKeyId:i.accessKeyId,secretAccessKey:i.secretAccessKey,endpoint:s.endpoint||r.endpoint||u,iamEndpoint:s.iamEndpoint||r.iamEndpoint}}let c=await y();if(c==="oauth"){let s=await f().getAccessToken();if(!d())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:s,accessKeyId:"",secretAccessKey:"",endpoint:r.endpoint,organizationId:d()??void 0,iamEndpoint:r.iamEndpoint,authDomain:T.domain}}if(c==="credentials"){let e=o();if(e)return{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,endpoint:e.endpoint}}let t=g();if(t)return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint};let n=o();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}async function v(){if(l()){let e=process.env.AWS_PROFILE||"default",s=await p(e);return new a({region:"auto",endpoint:s.endpoint||r.endpoint||u,credentials:C({profile:e})})}let c=await y();if(c==="oauth"){let s=await f().getAccessToken(),i=d();if(!i)throw new Error('No organization selected. Please run "tigris orgs select" first.');let K=new a({region:"auto",endpoint:r.endpoint,credentials:{sessionToken:s,accessKeyId:"",secretAccessKey:""}});return K.middlewareStack.add(I=>async m=>{let E=m.request;return E.headers["x-Tigris-Namespace"]=i,await I(m)},{name:"x-Tigris-Namespace-Middleware",step:"build",override:!0}),K}if(c==="credentials"){let e=o();if(e)return new a({region:"auto",endpoint:e.endpoint,credentials:{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey}})}let t=g();if(t)return new a({region:"auto",endpoint:t.endpoint,credentials:{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey}});let n=o();if(n)return new a({region:"auto",endpoint:n.endpoint,credentials:{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey}});throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}async function z(){return l()||await y()!==null||g()!==null||o()!==null}export{y as a,O as b,v as c,z as d};
@@ -1 +1 @@
1
- import{a as u,b as o,c as m,g}from"./chunk-A3TXP5Y2.js";import{m as i,o as d,r as y}from"./chunk-PKWQDQLT.js";import{a as n}from"./chunk-4BZ377KV.js";import p from"enquirer";var{prompt:S}=p,t=g("login","credentials");async function l(e){u(t);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,c=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!c){let r=[];s||r.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),c||r.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0});let a=await S(r);s=s||a.accessKey,c=c||a.accessSecret}(!s||!c)&&(m(t,"Access key and secret are required"),process.exit(1));let f=i()?.endpoint||n;await d({accessKeyId:s,secretAccessKey:c,endpoint:f}),await y("credentials"),o(t)}export{l as a};
1
+ import{a as u,b as o,c as m,g}from"./chunk-A3TXP5Y2.js";import{m as i,o as d,r as y}from"./chunk-JVB3Y42V.js";import{a as n}from"./chunk-D63SZLT5.js";import p from"enquirer";var{prompt:S}=p,t=g("login","credentials");async function l(e){u(t);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,c=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!c){let r=[];s||r.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),c||r.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0});let a=await S(r);s=s||a.accessKey,c=c||a.accessSecret}(!s||!c)&&(m(t,"Access key and secret are required"),process.exit(1));let f=i()?.endpoint||n;await d({accessKeyId:s,secretAccessKey:c,endpoint:f}),await y("credentials"),o(t)}export{l as a};
@@ -1 +1 @@
1
- import{a as l}from"./chunk-4BZ377KV.js";import{homedir as d,platform as C}from"os";import{join as r}from"path";import{readFileSync as m,writeFileSync as S,existsSync as c,mkdirSync as y,chmodSync as _}from"fs";import{execFileSync as E}from"child_process";import{loadSharedConfigFiles as I}from"@smithy/shared-ini-file-loader";var s=r(d(),".tigris"),a=r(s,"config.json");function u(n,e){if(C()==="win32")try{let i=process.env.USERNAME;i&&E("icacls",[n,"/inheritance:r","/grant:r",`${i}:F`],{stdio:"ignore"})}catch{console.warn(`Warning: Could not set restrictive permissions on ${n}. It may be accessible to other users.`)}else try{_(n,e)}catch{console.warn(`Warning: Could not set restrictive permissions on ${n}. It may be accessible to other users.`)}}function T(){c(s)||(y(s,{recursive:!0,mode:448}),u(s,448))}function o(){if(c(a))try{let n=m(a,"utf8");return JSON.parse(n)}catch{return{}}return{}}async function t(n){T(),S(a,JSON.stringify(n,null,2),{mode:384}),u(a,384)}async function h(n){let e=o();e.tokens=n,await t(e)}async function z(){return o().tokens||null}async function G(){let n=o();delete n.tokens,await t(n)}async function k(n){let e=o();e.organizations=n,await t(e)}function K(){return o().organizations||[]}async function D(n){let e=o();e.selectedOrganization=n,await t(e)}function F(){return o().selectedOrganization||null}function v(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let f=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,g=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!f||!g)return null;let p=process.env.TIGRIS_STORAGE_ENDPOINT||l;return{accessKeyId:f,secretAccessKey:g,endpoint:p}}let n=process.env.AWS_ACCESS_KEY_ID,e=process.env.AWS_SECRET_ACCESS_KEY;if(!n||!e)return null;let i=process.env.AWS_ENDPOINT_URL_S3||l;return{accessKeyId:n,secretAccessKey:e,endpoint:i}}function N(){if(!process.env.AWS_PROFILE)return!1;let n=r(d(),".aws");return c(r(n,"credentials"))||c(r(n,"config"))}async function b(n){try{let{configFile:e}=await I(),i=e[n];return i?{endpoint:i.endpoint_url_s3||i.endpoint_url,iamEndpoint:i.endpoint_url_iam,region:i.region}:{}}catch{return{}}}function L(){let n=o();return v()||n.temporaryCredentials||n.credentials||null}function M(){let n=o();return n.temporaryCredentials||n.credentials||null}function W(){return o().credentials||null}async function Y(n){let e=o();e.credentials=n,await t(e)}async function j(n){let e=o();e.temporaryCredentials=n,await t(e)}async function U(){let n=o();delete n.temporaryCredentials,await t(n)}async function $(){let n=o();delete n.credentials,await t(n)}async function J(n){let e=o();e.loginMethod=n,await t(e)}function q(){return o().loginMethod||null}async function B(){let e=o().credentials;await t({credentials:e})}export{h as a,z as b,G as c,k as d,K as e,D as f,F as g,v as h,N as i,b as j,L as k,M as l,W as m,Y as n,j as o,U as p,$ as q,J as r,q as s,B as t};
1
+ import{a as l}from"./chunk-D63SZLT5.js";import{homedir as d,platform as C}from"os";import{join as r}from"path";import{readFileSync as m,writeFileSync as S,existsSync as c,mkdirSync as y,chmodSync as _}from"fs";import{execFileSync as E}from"child_process";import{loadSharedConfigFiles as I}from"@smithy/shared-ini-file-loader";var s=r(d(),".tigris"),a=r(s,"config.json");function u(n,e){if(C()==="win32")try{let i=process.env.USERNAME;i&&E("icacls",[n,"/inheritance:r","/grant:r",`${i}:F`],{stdio:"ignore"})}catch{console.warn(`Warning: Could not set restrictive permissions on ${n}. It may be accessible to other users.`)}else try{_(n,e)}catch{console.warn(`Warning: Could not set restrictive permissions on ${n}. It may be accessible to other users.`)}}function T(){c(s)||(y(s,{recursive:!0,mode:448}),u(s,448))}function o(){if(c(a))try{let n=m(a,"utf8");return JSON.parse(n)}catch{return{}}return{}}async function t(n){T(),S(a,JSON.stringify(n,null,2),{mode:384}),u(a,384)}async function h(n){let e=o();e.tokens=n,await t(e)}async function z(){return o().tokens||null}async function G(){let n=o();delete n.tokens,await t(n)}async function k(n){let e=o();e.organizations=n,await t(e)}function K(){return o().organizations||[]}async function D(n){let e=o();e.selectedOrganization=n,await t(e)}function F(){return o().selectedOrganization||null}function v(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let f=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,g=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!f||!g)return null;let p=process.env.TIGRIS_STORAGE_ENDPOINT||l;return{accessKeyId:f,secretAccessKey:g,endpoint:p}}let n=process.env.AWS_ACCESS_KEY_ID,e=process.env.AWS_SECRET_ACCESS_KEY;if(!n||!e)return null;let i=process.env.AWS_ENDPOINT_URL_S3||l;return{accessKeyId:n,secretAccessKey:e,endpoint:i}}function N(){if(!process.env.AWS_PROFILE)return!1;let n=r(d(),".aws");return c(r(n,"credentials"))||c(r(n,"config"))}async function b(n){try{let{configFile:e}=await I(),i=e[n];return i?{endpoint:i.endpoint_url_s3||i.endpoint_url,iamEndpoint:i.endpoint_url_iam,region:i.region}:{}}catch{return{}}}function L(){let n=o();return v()||n.temporaryCredentials||n.credentials||null}function M(){let n=o();return n.temporaryCredentials||n.credentials||null}function W(){return o().credentials||null}async function Y(n){let e=o();e.credentials=n,await t(e)}async function j(n){let e=o();e.temporaryCredentials=n,await t(e)}async function U(){let n=o();delete n.temporaryCredentials,await t(n)}async function $(){let n=o();delete n.credentials,await t(n)}async function J(n){let e=o();e.loginMethod=n,await t(e)}function q(){return o().loginMethod||null}async function B(){let e=o().credentials;await t({credentials:e})}export{h as a,z as b,G as c,k as d,K as e,D as f,F as g,v as h,N as i,b as j,L as k,M as l,W as m,Y as n,j as o,U as p,$ as q,J as r,q as s,B as t};
@@ -0,0 +1 @@
1
+ import{list as g}from"@tigrisdata/storage";var f=["t3://","tigris://"];function p(t){return f.some(e=>t.startsWith(e))}function c(t){let e=f.find(r=>t.startsWith(r));return s(t.slice(e.length))}function s(t){let e=t.split("/");return{bucket:e[0],path:e.slice(1).join("/")}}async function m(t,e,r){let{data:i}=await g({prefix:`${e}/`,limit:1,config:{...r,bucket:t}});return!!(i?.items&&i.items.length>0)}function l(t,e){return{source:s(t),destination:s(e)}}function d(t){return p(t)?c(t):s(t)}function P(t){let e=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*");return new RegExp("^"+e+"$")}function x(t){let e=t.indexOf("*"),r=t.lastIndexOf("/",e);return r>=0?t.slice(0,r+1):""}async function h(t,e,r){let i=[],o;do{let{data:n,error:a}=await g({prefix:e,paginationToken:o,config:{...r,bucket:t}});if(a)return{items:i,error:a};n?.items&&i.push(...n.items),o=n?.hasMore?n.paginationToken:void 0}while(o);return{items:i}}export{p as a,c as b,s as c,m as d,l as e,d as f,P as g,x as h,h as i};
@@ -1 +1 @@
1
- import{a as g,b as k}from"./chunk-NYAHHQ3A.js";import{a as c,b as s,c as l,d as p,e as u,r as h}from"./chunk-PKWQDQLT.js";import a from"axios";import w from"open";import{createRemoteJWKSet as T,jwtVerify as y}from"jose";var f=class{config;baseUrl;jwks=null;constructor(){this.config=g(),this.baseUrl=`https://${this.config.domain}`}getJWKS(){return this.jwks||(this.jwks=T(new URL(`${this.baseUrl}/.well-known/jwks.json`))),this.jwks}async verifyIdToken(e){let{payload:t}=await y(e,this.getJWKS(),{issuer:`${this.baseUrl}/`,audience:this.config.clientId});return t}async login(e){let o=(await a.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;e?.onDeviceCode?.(o.user_code,o.verification_uri),await this.sleep(2e3);try{await w(o.verification_uri_complete)}catch{}e?.onWaiting?.();let n=await this.pollForToken(o.device_code,o.interval||5);await c(n),h("oauth"),await this.extractAndStoreOrganizations(n.idToken)}async pollForToken(e,t){let n=0;for(;n<60;){n++;try{let r=(await a.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;if(!r.id_token)throw new Error("No ID token found. Please try again.");if((await this.verifyIdToken(r.id_token)).email_verified===!1)throw console.log("Email not verified. Please verify your email and try again."),new Error("Email not verified. Please verify your email and try again.");let m=Date.now()+(r.expires_in||3600)*1e3;return{accessToken:r.access_token,refreshToken:r.refresh_token,idToken:r.id_token,expiresAt:m}}catch(i){if(a.isAxiosError(i)&&i.response){let r=i.response.data?.error;if(r==="authorization_pending"){await this.sleep(t*1e3);continue}if(r==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(i.response.data?.error_description||"Authentication failed")}throw i}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await s();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=e.expiresAt&&(e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){let t=null;if(e?.refreshToken?t=e:t=await s(),!t)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let n=(await a.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,i={accessToken:n.access_token,refreshToken:n.refresh_token||t.refreshToken,idToken:n.id_token||t.idToken,expiresAt:Date.now()+(n.expires_in||3600)*1e3};return await c(i),i}catch{throw await l(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await s();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{return await this.verifyIdToken(e.idToken)}catch{throw new Error('ID token verification failed. Please run "tigris login" to re-authenticate.')}}async extractAndStoreOrganizations(e){if(e)try{let o=(await this.verifyIdToken(e))[k];if(!o)return;let n=o?.ns?.map(i=>typeof i=="object"&&i!==null?{id:i.id,name:i.name,displayName:i.name}:{id:i,name:i,displayName:i})||[];if(n.length===0)return;p(n)}catch{}}async getOrganizations(){return await this.getAccessToken(),u()}async logout(){await l()}async isAuthenticated(){return await s()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},d=null;function S(){return d||(d=new f),d}export{f as a,S as b};
1
+ import{a as g,b as k}from"./chunk-6U4U4JM6.js";import{a as c,b as s,c as l,d as p,e as u,r as h}from"./chunk-JVB3Y42V.js";import a from"axios";import w from"open";import{createRemoteJWKSet as T,jwtVerify as y}from"jose";var f=class{config;baseUrl;jwks=null;constructor(){this.config=g(),this.baseUrl=`https://${this.config.domain}`}getJWKS(){return this.jwks||(this.jwks=T(new URL(`${this.baseUrl}/.well-known/jwks.json`))),this.jwks}async verifyIdToken(e){let{payload:t}=await y(e,this.getJWKS(),{issuer:`${this.baseUrl}/`,audience:this.config.clientId});return t}async login(e){let o=(await a.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;e?.onDeviceCode?.(o.user_code,o.verification_uri),await this.sleep(2e3);try{await w(o.verification_uri_complete)}catch{}e?.onWaiting?.();let n=await this.pollForToken(o.device_code,o.interval||5);await c(n),h("oauth"),await this.extractAndStoreOrganizations(n.idToken)}async pollForToken(e,t){let n=0;for(;n<60;){n++;try{let r=(await a.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;if(!r.id_token)throw new Error("No ID token found. Please try again.");if((await this.verifyIdToken(r.id_token)).email_verified===!1)throw console.log("Email not verified. Please verify your email and try again."),new Error("Email not verified. Please verify your email and try again.");let m=Date.now()+(r.expires_in||3600)*1e3;return{accessToken:r.access_token,refreshToken:r.refresh_token,idToken:r.id_token,expiresAt:m}}catch(i){if(a.isAxiosError(i)&&i.response){let r=i.response.data?.error;if(r==="authorization_pending"){await this.sleep(t*1e3);continue}if(r==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(i.response.data?.error_description||"Authentication failed")}throw i}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await s();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=e.expiresAt&&(e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){let t=null;if(e?.refreshToken?t=e:t=await s(),!t)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let n=(await a.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,i={accessToken:n.access_token,refreshToken:n.refresh_token||t.refreshToken,idToken:n.id_token||t.idToken,expiresAt:Date.now()+(n.expires_in||3600)*1e3};return await c(i),i}catch{throw await l(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await s();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{return await this.verifyIdToken(e.idToken)}catch{throw new Error('ID token verification failed. Please run "tigris login" to re-authenticate.')}}async extractAndStoreOrganizations(e){if(e)try{let o=(await this.verifyIdToken(e))[k];if(!o)return;let n=o?.ns?.map(i=>typeof i=="object"&&i!==null?{id:i.id,name:i.name,displayName:i.name}:{id:i,name:i,displayName:i})||[];if(n.length===0)return;p(n)}catch{}}async getOrganizations(){return await this.getAccessToken(),u()}async logout(){await l()}async isAuthenticated(){return await s()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},d=null;function S(){return d||(d=new f),d}export{f as a,S as b};
@@ -0,0 +1,12 @@
1
+ import{a as C,c as A}from"./chunk-TUJTXB5G.js";import{a as w}from"./chunk-4LGKN5DA.js";import{Command as v}from"commander";import{existsSync as q}from"fs";import{join as c,dirname as k}from"path";import{fileURLToPath as R}from"url";process.on("unhandledRejection",e=>{(e===""||e===void 0)&&(console.error(`
2
+ Operation cancelled`),process.exit(1)),console.error(`
3
+ Error:`,e instanceof Error?e.message:e),process.exit(1)});process.on("uncaughtException",e=>{console.error(`
4
+ Error:`,e.message),process.exit(1)});var P=R(import.meta.url),d=k(P),l=w();function y(e,t){return(t?[c(d,"lib",e,`${t}.js`),c(d,"lib",e,t,"index.js")]:[c(d,"lib",`${e}.js`),c(d,"lib",e,"index.js")]).some(o=>q(o))}function E(e){let t;e.type==="positional"?t=` ${e.name}`:(t=` --${e.name}`,e.alias&&e.alias.length===1&&(t+=`, -${e.alias}`));let n=26,o=t.length>=n?t+" ":t.padEnd(n),s=e.description;return e.options&&(Array.isArray(e.options)&&typeof e.options[0]=="string"?s+=` (options: ${e.options.join(", ")})`:s+=` (options: ${e.options.map(i=>i.value).join(", ")})`),e.default&&(s+=` [default: ${e.default}]`),e.required&&(s+=" [required]"),e["required-when"]&&(s+=` [required when: ${e["required-when"]}]`),e.multiple&&(s+=" [multiple values: comma-separated]"),e.type==="positional"&&(s+=" [positional argument]"),e.examples&&e.examples.length>0&&(s+=` (examples: ${e.examples.join(", ")})`),`${o}${s}`}function b(e){if(console.log(`
5
+ ${l.name} ${e.name} - ${e.description}
6
+ `),e.operations&&e.operations.length>0){let t=e.operations.filter(n=>y(e.name,n.name));t.length>0&&(console.log("Operations:"),t.forEach(n=>{let o=` ${n.name}`;if(n.alias){let i=Array.isArray(n.alias)?n.alias:[n.alias];o+=` (${i.join(", ")})`}let s=o.padEnd(24);console.log(`${s}${n.description}`)}),console.log())}e.arguments&&e.arguments.length>0&&(console.log("Arguments:"),e.arguments.forEach(t=>{console.log(E(t))}),console.log()),console.log(`Use "${l.name} ${e.name} <operation> help" for more information about an operation.`)}function U(e,t){console.log(`
7
+ ${l.name} ${e.name} ${t.name} - ${t.description}
8
+ `),t.arguments&&t.arguments.length>0&&(console.log("Arguments:"),t.arguments.forEach(n=>{console.log(E(n))}),console.log())}function V(e){return y(e.name)?!0:e.operations?e.operations.some(t=>y(e.name,t.name)):!1}function x(){console.log(`Tigris CLI Version: ${C}
9
+ `),console.log(`Usage: tigris [command] [options]
10
+ `),console.log("Commands:"),l.commands.filter(V).forEach(t=>{let n=` ${t.name}`;t.alias&&(n+=` (${t.alias})`);let o=n.padEnd(24);console.log(`${o}${t.description}`)}),console.log(`
11
+ Use "${l.name} <command> help" for more information about a command.`)}function m(e,t=[]){t.forEach(n=>{if(n.type==="positional"){let o=n.required?`<${n.name}>`:`[${n.name}]`;e.argument(o,n.description)}else{let s=n.alias&&n.alias.length===1?`-${n.alias}, --${n.name}`:`--${n.name}`;n.type==="flag"||(n.type==="boolean"?s+=" [value]":n.options?s+=" <value>":s+=n.required||n["required-when"]?" <value>":" [value]"),e.option(s,n.description,n.default)}})}function g(e,t){for(let n of e){if(n["required-when"]){let[o,s]=n["required-when"].split("="),i=h(t,o,e),r=h(t,n.name,e);if(i===s&&!r)return console.error(`--${n.name} is required when --${o} is ${s}`),!1}if(n.required&&!h(t,n.name,e))return console.error(`--${n.name} is required`),!1}return!0}function h(e,t,n){if(n){let s=n.find(i=>i.name===t);if(s&&s.alias){let i=s.alias.charAt(0).toUpperCase()+s.alias.slice(1);if(e[i]!==void 0)return e[i]}}let o=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),_(t)];for(let s of o)if(e[s]!==void 0)return e[s]}function _(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}async function D(e,t){let n=t?[`./lib/${e}/${t}.js`,`./lib/${e}/${t}/index.js`]:[`./lib/${e}.js`,`./lib/${e}/index.js`];for(let s of n){let i=await import(s).catch(()=>null);if(i)return{module:i,error:null}}return{module:null,error:`Command not found: ${t?`${e} ${t}`:e}`}}async function $(e,t,n=[],o={},s){if(s){let j=s.replace(/\\n/g,`
12
+ `);console.log(j)}let{module:i,error:r}=await D(e,t);(r||!i)&&(console.error(r),process.exit(1));let a=t||e,p=i.default||i[a];typeof p!="function"&&(console.error(`Command not implemented: ${a}`),process.exit(1)),await p({...o,_positional:n})}var f=new v;f.name(l.name).description(l.description).version(l.version);function u(e,t,n){let o;"optsWithGlobals"in n&&typeof n.optsWithGlobals=="function"?o=n.optsWithGlobals():"opts"in n&&typeof n.opts=="function"?o=n.opts():o=n;let s={...o};return e.filter(r=>r.type==="positional").forEach((r,a)=>{t[a]!==void 0&&(r.multiple?s[r.name]=t[a].split(",").map(p=>p.trim()):s[r.name]=t[a])}),e.forEach(r=>{r.multiple&&r.type!=="positional"&&s[r.name]&&typeof s[r.name]=="string"&&(s[r.name]=s[r.name].split(",").map(a=>a.trim()))}),s}l.commands.forEach(e=>{let t=f.command(e.name).description(e.description);if(e.alias&&t.alias(e.alias),e.operations&&e.operations.length>0)if(e.operations.forEach(n=>{let o=t.command(n.name).description(n.description);n.alias&&(Array.isArray(n.alias)?n.alias:[n.alias]).forEach(i=>o.alias(i)),m(o,n.arguments),o.action(async(...s)=>{let i=s.pop(),r=s;n.arguments&&!g(n.arguments,u(n.arguments,r,i))||await $(e.name,n.name,r,u(n.arguments||[],r,i),n.message)}),o.command("help").description("Show help for this operation").action(()=>{U(e,n)})}),e.default){let n=e.operations?.find(o=>o.name===e.default);if(n){m(t,e.arguments),m(t,n.arguments);let o=[...e.arguments||[],...n.arguments||[]];t.action(async(...s)=>{let i=s.pop(),r=s;o.length>0&&!g(o,u(o,r,i))||await $(e.name,n.name,r,u(o,r,i),e.message||n.message)})}}else t.action(()=>{b(e)});else m(t,e.arguments),t.action(async(...n)=>{let o=n.pop(),s=n;e.arguments&&!g(e.arguments,u(e.arguments,s,o))||await $(e.name,void 0,s,u(e.arguments||[],s,o),e.message)});t.command("help").description("Show help for this command").action(()=>{b(e)})});f.command("help").description("Show general help").action(()=>{x()});f.action(()=>{x()});f.parse();A();
@@ -0,0 +1,8 @@
1
+ import{c as p,d as u}from"./chunk-D63SZLT5.js";import{readFileSync as h,writeFileSync as y,mkdirSync as v}from"fs";import{join as d}from"path";import{homedir as m}from"os";import b from"https";var c="2.6.2";var f=d(m(),".tigris","update-check.json");function C(){try{let e=h(f,"utf-8"),i=JSON.parse(e);return typeof i.latestVersion=="string"&&typeof i.lastChecked=="number"?i:null}catch{return null}}function k(e){try{v(d(m(),".tigris"),{recursive:!0}),y(f,JSON.stringify(e),"utf-8")}catch{}}function x(e,i){let n=t=>{let a=(t.startsWith("v")?t.slice(1):t).split(".");if(a.length!==3)return null;let o=a.map(Number);return o.some(isNaN)?null:o},s=n(e),r=n(i);if(!s||!r)return!1;for(let t=0;t<3;t++){if(r[t]>s[t])return!0;if(r[t]<s[t])return!1}return!1}function T(){try{let e=b.get(p,{timeout:5e3},i=>{let n="";i.on("data",s=>{n+=s}),i.on("end",()=>{try{let s=JSON.parse(n);typeof s.version=="string"&&k({latestVersion:s.version,lastChecked:Date.now()})}catch{}})});e.on("error",()=>{}),e.on("timeout",()=>{e.destroy()}),e.end(),e.unref()}catch{}}function V(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=C();if(e&&x(c,e.latestVersion)){let n=`Update available: ${c} \u2192 ${e.latestVersion}`,s="Run `npm install -g @tigrisdata/cli` to upgrade.",r=Math.max(n.length,s.length)+4,t="\u250C"+"\u2500".repeat(r-2)+"\u2510",l="\u2514"+"\u2500".repeat(r-2)+"\u2518",a=o=>"\u2502 "+o.padEnd(r-4)+" \u2502";console.log(`
2
+ ${t}
3
+ ${a("")}
4
+ ${a(n)}
5
+ ${a(s)}
6
+ ${a("")}
7
+ ${l}
8
+ `)}let i=Number(process.env.TIGRIS_UPDATE_CHECK_INTERVAL_MS)||864e5;(!e||Date.now()-e.lastChecked>i)&&T()}export{c as a,x as b,V as c};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-IY46B353.js";import"./chunk-4LGKN5DA.js";
2
+ import"./chunk-TPUZYSCZ.js";import"./chunk-TUJTXB5G.js";import"./chunk-4LGKN5DA.js";import"./chunk-D63SZLT5.js";
package/dist/constants.js CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-4BZ377KV.js";export{b as DEFAULT_IAM_ENDPOINT,a as DEFAULT_STORAGE_ENDPOINT};
1
+ import{a,b,c,d}from"./chunk-D63SZLT5.js";export{b as DEFAULT_IAM_ENDPOINT,a as DEFAULT_STORAGE_ENDPOINT,c as NPM_REGISTRY_URL,d as UPDATE_CHECK_INTERVAL_MS};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-IY46B353.js";import"./chunk-4LGKN5DA.js";
1
+ import"./chunk-TPUZYSCZ.js";import"./chunk-TUJTXB5G.js";import"./chunk-4LGKN5DA.js";import"./chunk-D63SZLT5.js";
package/dist/lib/_stat.js CHANGED
@@ -1 +1 @@
1
- async function e(t){t.path||t._positional?.[0]||(console.error("path argument is required"),process.exit(1)),console.error("stat command not yet implemented"),process.exit(1)}export{e as default};
1
+ import{f as o}from"../chunk-LCWHZUZZ.js";async function s(t){let e=t.path||t._positional?.[0];e||(console.error("path argument is required"),process.exit(1));let{bucket:r}=o(e);r||(console.error("Invalid path"),process.exit(1)),console.error("stat command not yet implemented"),process.exit(1)}export{s as default};
@@ -1,2 +1,2 @@
1
- import{a as R,b as l,c as t,g as b}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as A}from"../../chunk-TQWT7ROJ.js";import{b as k}from"../../chunk-WE6NZ2ZK.js";import{c as h}from"../../chunk-NYAHHQ3A.js";import{a as n}from"../../chunk-JRALYIRA.js";import{g as p}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{assignBucketRoles as C,revokeAllBucketRoles as N}from"@tigrisdata/iam";var e=b("access-keys","assign"),x=["Editor","ReadOnly","NamespaceAdmin"];function y(o){return o?Array.isArray(o)?o:[o]:[]}async function E(o){R(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 A()!=="oauth"&&(t(e,`Bucket roles can only be managed when logged in via OAuth.
1
+ import{a as R,b as l,c as t,g as b}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n}from"../../chunk-JRALYIRA.js";import{a as A}from"../../chunk-ESJWTUFN.js";import{b as k}from"../../chunk-QZXBLNMQ.js";import{c as h}from"../../chunk-6U4U4JM6.js";import{g as p}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{assignBucketRoles as C,revokeAllBucketRoles as N}from"@tigrisdata/iam";var e=b("access-keys","assign"),x=["Editor","ReadOnly","NamespaceAdmin"];function y(o){return o?Array.isArray(o)?o:[o]:[]}async function E(o){R(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 A()!=="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=p(),w=h(),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 m,b as d,c as t,g as u}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as l}from"../../chunk-TQWT7ROJ.js";import{b as g}from"../../chunk-WE6NZ2ZK.js";import{c as a}from"../../chunk-NYAHHQ3A.js";import{a as c}from"../../chunk-JRALYIRA.js";import{g as r}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{createAccessKey as y}from"@tigrisdata/iam";var e=u("access-keys","create");async function w(f){m(e);let i=c(f,["name"]);i||(t(e,"Access key name is required"),process.exit(1)),await l()!=="oauth"&&(t(e,`Access keys can only be created when logged in via OAuth.
1
+ import{a as m,b as d,c as t,g as u}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as c}from"../../chunk-JRALYIRA.js";import{a as l}from"../../chunk-ESJWTUFN.js";import{b as g}from"../../chunk-QZXBLNMQ.js";import{c as a}from"../../chunk-6U4U4JM6.js";import{g as r}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createAccessKey as y}from"@tigrisdata/iam";var e=u("access-keys","create");async function w(f){m(e);let i=c(f,["name"]);i||(t(e,"Access key name is required"),process.exit(1)),await l()!=="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=g();await n.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let p=await n.getAccessToken(),h=r(),A=a(),{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."),d(e)}export{w as default};
@@ -1,2 +1,2 @@
1
- import{a as d,b as m,c as e,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as g}from"../../chunk-TQWT7ROJ.js";import{b as a}from"../../chunk-WE6NZ2ZK.js";import{c}from"../../chunk-NYAHHQ3A.js";import{a as s}from"../../chunk-JRALYIRA.js";import{g as r}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{removeAccessKey as A}from"@tigrisdata/iam";var t=f("access-keys","delete");async function k(u){d(t);let i=s(u,["id"]);i||(e(t,"Access key ID is required"),process.exit(1)),await g()!=="oauth"&&(e(t,`Access keys can only be deleted when logged in via OAuth.
1
+ import{a as d,b as m,c as e,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as s}from"../../chunk-JRALYIRA.js";import{a as g}from"../../chunk-ESJWTUFN.js";import{b as a}from"../../chunk-QZXBLNMQ.js";import{c}from"../../chunk-6U4U4JM6.js";import{g as r}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{removeAccessKey as A}from"@tigrisdata/iam";var t=f("access-keys","delete");async function k(u){d(t);let i=s(u,["id"]);i||(e(t,"Access key ID is required"),process.exit(1)),await g()!=="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=a();await o.isAuthenticated()||(e(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let p=await o.getAccessToken(),h=r(),l=c(),{error:n}=await A(i,{config:{sessionToken:p,organizationId:h??void 0,iamEndpoint:l.iamEndpoint}});n&&(e(t,n.message),process.exit(1)),m(t)}export{k as default};
@@ -1,2 +1,2 @@
1
- import{a as f,b as u,c as t,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as d}from"../../chunk-TQWT7ROJ.js";import{b as l}from"../../chunk-WE6NZ2ZK.js";import{c as g}from"../../chunk-NYAHHQ3A.js";import{a as c}from"../../chunk-JRALYIRA.js";import{g as a}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{getAccessKey as $}from"@tigrisdata/iam";var e=m("access-keys","get");async function w(p){f(e);let i=c(p,["id"]);i||(t(e,"Access key ID is required"),process.exit(1)),await d()!=="oauth"&&(t(e,`Access keys can only be retrieved when logged in via OAuth.
1
+ import{a as f,b as u,c as t,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as c}from"../../chunk-JRALYIRA.js";import{a as d}from"../../chunk-ESJWTUFN.js";import{b as l}from"../../chunk-QZXBLNMQ.js";import{c as g}from"../../chunk-6U4U4JM6.js";import{g as a}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{getAccessKey as $}from"@tigrisdata/iam";var e=m("access-keys","get");async function w(p){f(e);let i=c(p,["id"]);i||(t(e,"Access key ID is required"),process.exit(1)),await d()!=="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=l();await n.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let h=await n.getAccessToken(),A=a(),k=g(),{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");u(e)}export{w as default};
@@ -1,2 +1,2 @@
1
- import{a as m,b as l,c as s,d as p,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as g}from"../../chunk-TQWT7ROJ.js";import{b as d}from"../../chunk-WE6NZ2ZK.js";import{c as r}from"../../chunk-NYAHHQ3A.js";import{f as u}from"../../chunk-HGIJOGCZ.js";import{g as c}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listAccessKeys as w}from"@tigrisdata/iam";var t=f("access-keys","list");async function x(){m(t),await g()!=="oauth"&&(s(t,`Access keys can only be listed when logged in via OAuth.
1
+ import{a as m,b as l,c as s,d as p,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as u}from"../../chunk-HGIJOGCZ.js";import{a as g}from"../../chunk-ESJWTUFN.js";import{b as d}from"../../chunk-QZXBLNMQ.js";import{c as r}from"../../chunk-6U4U4JM6.js";import{g as c}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listAccessKeys as w}from"@tigrisdata/iam";var t=f("access-keys","list");async function x(){m(t),await g()!=="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=c(),k=r(),{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){p(t);return}let a=i.accessKeys.map(e=>({name:e.name,id:e.id,status:e.status,created:e.createdAt})),A=u(a,"table","keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}]);console.log(A),l(t,{count:a.length})}export{x as default};
@@ -1 +1 @@
1
- import{a as x,b as k,c as b,g as A}from"../../chunk-A3TXP5Y2.js";import{c as d,d as f}from"../../chunk-4LGKN5DA.js";import{b as S}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as c}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import I from"enquirer";import{createBucket as v}from"@tigrisdata/storage";var{prompt:T}=I,p=A("buckets","create");async function C(a){x(p);let t=!c(a,["name"]),u=c(a,["name"]),h=t?void 0:c(a,["access","a","A"]),l=t?void 0:c(a,["enable-snapshots","s","S"]),g=t?void 0:c(a,["default-tier","t","T"]),m=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}),!h||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(!g||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(!m||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,h=h||e.access,l=l!==void 0?l:e.enableSnapshots,g=g||e.defaultTier,m=m||e.consistency,r=r!==void 0?r:e.region}u||(b(p,"Bucket name is required"),process.exit(1));let{error:y}=await v(u,{defaultTier:g??"STANDARD",consistency:m==="strict"?"strict":"default",enableSnapshot:l===!0,region:r!=="global"&&r!==void 0?r.split(","):void 0,config:await S()});y&&(b(p,y.message),process.exit(1)),k(p,{name:u})}export{C as default};
1
+ import{a as x,b as k,c as b,g as A}from"../../chunk-A3TXP5Y2.js";import{c as d,d as f}from"../../chunk-4LGKN5DA.js";import{a as c}from"../../chunk-JRALYIRA.js";import{b as S}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import I from"enquirer";import{createBucket as v}from"@tigrisdata/storage";var{prompt:T}=I,p=A("buckets","create");async function C(a){x(p);let t=!c(a,["name"]),u=c(a,["name"]),h=t?void 0:c(a,["access","a","A"]),l=t?void 0:c(a,["enable-snapshots","s","S"]),g=t?void 0:c(a,["default-tier","t","T"]),m=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}),!h||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(!g||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(!m||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,h=h||e.access,l=l!==void 0?l:e.enableSnapshots,g=g||e.defaultTier,m=m||e.consistency,r=r!==void 0?r:e.region}u||(b(p,"Bucket name is required"),process.exit(1));let{error:y}=await v(u,{defaultTier:g??"STANDARD",consistency:m==="strict"?"strict":"default",enableSnapshot:l===!0,region:r!=="global"&&r!==void 0?r.split(","):void 0,config:await S()});y&&(b(p,y.message),process.exit(1)),k(p,{name:u})}export{C as default};
@@ -1 +1 @@
1
- import{a as c,b as a,c as o,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as s}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as i}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{removeBucket as g}from"@tigrisdata/storage";var e=m("buckets","delete");async function k(f){c(e);let t=i(f,["name"]);t||(o(e,"Bucket name is required"),process.exit(1));let p=Array.isArray(t)?t:[t],u=await s();for(let r of p){let{error:n}=await g(r,{config:u});n&&(o(e,n.message,{name:r}),process.exit(1)),a(e,{name:r})}}export{k as default};
1
+ import{a as c,b as a,c as o,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as s}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{removeBucket as g}from"@tigrisdata/storage";var e=m("buckets","delete");async function k(f){c(e);let t=i(f,["name"]);t||(o(e,"Bucket name is required"),process.exit(1));let p=Array.isArray(t)?t:[t],u=await s();for(let r of p){let{error:n}=await g(r,{config:u});n&&(o(e,n.message,{name:r}),process.exit(1)),a(e,{name:r})}}export{k as default};
@@ -1 +1 @@
1
- import{a as u,b as c,c as r,g as i}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as p}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as n}from"../../chunk-HGIJOGCZ.js";import{a as s}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{getBucketInfo as l}from"@tigrisdata/storage";var t=i("buckets","get");async function g(m){u(t);let o=s(m,["name"]);o||(r(t,"Bucket name is required"),process.exit(1));let{data:e,error:a}=await l(o,{config:await p()});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=n(f,"table","bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(k),c(t)}export{g as default};
1
+ import{a as u,b as c,c as r,g as i}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as n}from"../../chunk-HGIJOGCZ.js";import{a as s}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{getBucketInfo as l}from"@tigrisdata/storage";var t=i("buckets","get");async function g(m){u(t);let o=s(m,["name"]);o||(r(t,"Bucket name is required"),process.exit(1));let{data:e,error:a}=await l(o,{config:await p()});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=n(f,"table","bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(k),c(t)}export{g as default};
@@ -1 +1 @@
1
- import{a as u,b as p,c as r,d as f,g}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as i}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as m}from"../../chunk-HGIJOGCZ.js";import{a as c}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listBuckets as d}from"@tigrisdata/storage";var t=g("buckets","list");async function b(k){u(t);try{let e=c(k,["format","F"],"table"),{data:o,error:n}=await d({config:await i()});if(n&&(r(t,n.message),process.exit(1)),!o.buckets||o.buckets.length===0){f(t);return}let s=o.buckets.map(a=>({name:a.name,created:a.creationDate})),l=m(s,e,"buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(l),p(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 u,b as p,c as r,d as f,g}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as m}from"../../chunk-HGIJOGCZ.js";import{a as c}from"../../chunk-JRALYIRA.js";import{b as i}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listBuckets as d}from"@tigrisdata/storage";var t=g("buckets","list");async function b(k){u(t);try{let e=c(k,["format","F"],"table"),{data:o,error:n}=await d({config:await i()});if(n&&(r(t,n.message),process.exit(1)),!o.buckets||o.buckets.length===0){f(t);return}let s=o.buckets.map(a=>({name:a.name,created:a.creationDate})),l=m(s,e,"buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(l),p(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 +1 @@
1
- import{a as y,b as w,c as r,g as k}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as O}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as e,b as c}from"../../chunk-JRALYIRA.js";import{g as D}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{updateBucket as x}from"@tigrisdata/storage";var o=k("buckets","set");async function B(n){y(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||(r(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&&(r(o,"At least one setting is required"),process.exit(1));let m=await O(),t={};a!==void 0&&(t.access=a),i!==void 0&&(t.regions=Array.isArray(i)?i:[i]),d!==void 0&&(t.allowObjectAcl=c(d)),l!==void 0&&(t.disableDirectoryListing=c(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=c(g));let p=D(),A={...m,...p&&!m.organizationId?{organizationId:p}:{}},{error:b}=await x(s,{...t,config:A});b&&(r(o,b.message),process.exit(1)),w(o,{name:s})}export{B as default};
1
+ import{a as y,b as w,c as r,g as k}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as e,b as c}from"../../chunk-JRALYIRA.js";import{b as O}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{g as D}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{updateBucket as x}from"@tigrisdata/storage";var o=k("buckets","set");async function B(n){y(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||(r(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&&(r(o,"At least one setting is required"),process.exit(1));let m=await O(),t={};a!==void 0&&(t.access=a),i!==void 0&&(t.regions=Array.isArray(i)?i:[i]),d!==void 0&&(t.allowObjectAcl=c(d)),l!==void 0&&(t.disableDirectoryListing=c(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=c(g));let p=D(),A={...m,...p&&!m.organizationId?{organizationId:p}:{}},{error:b}=await x(s,{...t,config:A});b&&(r(o,b.message),process.exit(1)),w(o,{name:s})}export{B as default};
@@ -1 +1 @@
1
- import{a as g,b as p,c as n,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{n as u,r as y}from"../../chunk-PKWQDQLT.js";import{a as d}from"../../chunk-4BZ377KV.js";import f from"enquirer";var{prompt:l}=f,i=m("configure");async function o(e){g(i);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,c=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!r||!c){let t=[];s||t.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),r||t.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),c||t.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:d});let a=await l(t);s=s||a.accessKey,r=r||a.accessSecret,c=c||a.endpoint}(!s||!r||!c)&&(n(i,"All credentials are required"),process.exit(1));try{await u({accessKeyId:s,secretAccessKey:r,endpoint:c}),await y("credentials"),p(i)}catch{n(i,"Failed to save credentials"),process.exit(1)}}export{o as default};
1
+ import{a as g,b as p,c as n,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{n as u,r as y}from"../../chunk-JVB3Y42V.js";import{a as d}from"../../chunk-D63SZLT5.js";import f from"enquirer";var{prompt:l}=f,i=m("configure");async function o(e){g(i);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,c=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!r||!c){let t=[];s||t.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),r||t.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),c||t.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:d});let a=await l(t);s=s||a.accessKey,r=r||a.accessSecret,c=c||a.endpoint}(!s||!r||!c)&&(n(i,"All credentials are required"),process.exit(1));try{await u({accessKeyId:s,secretAccessKey:r,endpoint:c}),await y("credentials"),p(i)}catch{n(i,"Failed to save credentials"),process.exit(1)}}export{o as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as k,b as $,d as F}from"../chunk-I3FOSZPG.js";import{b as P}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as g}from"../chunk-HGIJOGCZ.js";import{a as w}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import{get as I,put as S,list as W,head as j}from"@tigrisdata/storage";async function v(p){let c=w(p,["src"]),l=w(p,["dest"]);(!c||!l)&&(console.error("both src and dest arguments are required"),process.exit(1));let e=k(c),t=k(l);e.bucket||(console.error("Invalid source path"),process.exit(1)),t.bucket||(console.error("Invalid destination path"),process.exit(1)),e.path||(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let s=await P(),i=c.includes("*"),f=c.endsWith("/");if(!i&&!f&&e.path&&(f=await $(e.bucket,e.path,s)),i||f){let r=i?e.path.replace("*",""):e.path.endsWith("/")?e.path:`${e.path}/`,a=t.path?`${t.path.replace(/\/$/,"")}/`:"";e.bucket===t.bucket&&r===a&&(console.error("Source and destination are the same"),process.exit(1));let{items:u,error:o}=await F(e.bucket,r||void 0,s);o&&(console.error(o.message),process.exit(1));let b=u.filter(n=>n.name!==r),h=0;for(let n of b){let d=r?n.name.slice(r.length):n.name,m=t.path?`${t.path.replace(/\/$/,"")}/${d}`:d,C=await x(s,e.bucket,n.name,t.bucket,m);C.error?console.error(`Failed to copy ${n.name}: ${C.error}`):(console.log(`Copied ${n.name} -> ${t.bucket}/${m}`),h++)}let y=!1;if(t.path&&r){let{data:n}=await W({prefix:r,limit:1,config:{...s,bucket:e.bucket}});if(n?.items?.some(d=>d.name===r)){let d=`${t.path.replace(/\/$/,"")}/`,m=await x(s,e.bucket,r,t.bucket,d);m.error?console.error(`Failed to copy folder marker: ${m.error}`):y=!0}}if(h===0&&y&&(h=1),h===0){console.log("No objects to copy");return}console.log(`Copied ${h} object(s)`)}else{e.path||(console.error("Source object key is required"),process.exit(1));let r=e.path.split("/").pop(),a;t.path?l.endsWith("/")?a=`${t.path}${r}`:await $(t.bucket,t.path,s)?a=`${t.path}/${r}`:a=t.path:a=r,e.bucket===t.bucket&&e.path===a&&(console.error("Source and destination are the same"),process.exit(1));let u=await x(s,e.bucket,e.path,t.bucket,a,!0);u.error&&(console.error(u.error),process.exit(1)),console.log(`Copied ${c} -> ${t.bucket}/${a}`)}process.exit(0)}async function x(p,c,l,e,t,s=!1){if(l.endsWith("/")){let{error:o}=await S(t,"",{config:{...p,bucket:e}});return o?{error:o.message}:{}}let i;if(s){let{data:o}=await j(l,{config:{...p,bucket:c}});i=o?.size}let{data:f,error:r}=await I(l,"stream",{config:{...p,bucket:c}});if(r)return{error:r.message};let a=i!==void 0&&i>100*1024*1024,{error:u}=await S(t,f,{multipart:a,onUploadProgress:s?({loaded:o})=>{if(i!==void 0&&i>0){let b=Math.round(o/i*100);process.stdout.write(`\rCopying: ${g(o)} / ${g(i)} (${b}%)`)}else process.stdout.write(`\rCopying: ${g(o)}`)}:void 0,config:{...p,bucket:e}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),u?{error:u.message}:{}}export{v as default};
1
+ import{a as $}from"../chunk-HGIJOGCZ.js";import{a as v}from"../chunk-JRALYIRA.js";import{b as M}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.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"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.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 +1 @@
1
- import{a as u,b as l,c as n,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as g}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a}from"../../chunk-JRALYIRA.js";import{g as f}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listBuckets as m,getBucketInfo as p}from"@tigrisdata/storage";var e=d("credentials","test");async function b(k){u(e);let t=a(k,["bucket","b"]),o=await g();!o.accessKeyId&&!o.sessionToken&&(n(e,'No credentials found. Run "tigris configure" or "tigris login" first.'),process.exit(1));let c=f(),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).`)}l(e)}export{b as default};
1
+ import{a as u,b as l,c as n,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a}from"../../chunk-JRALYIRA.js";import{b as g}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{g as f}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listBuckets as m,getBucketInfo as p}from"@tigrisdata/storage";var e=d("credentials","test");async function b(k){u(e);let t=a(k,["bucket","b"]),o=await g();!o.accessKeyId&&!o.sessionToken&&(n(e,'No credentials found. Run "tigris configure" or "tigris login" first.'),process.exit(1));let c=f(),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).`)}l(e)}export{b as default};
@@ -1 +1 @@
1
- import{a,b as m,c as t,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as c}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as r}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{createBucket as p}from"@tigrisdata/storage";var e=f("forks","create");async function g(o){a(e);let s=r(o,["name"]),n=r(o,["fork-name","forkName"]),u=r(o,["snapshot","s","S"]);s||(t(e,"Source bucket name is required"),process.exit(1)),n||(t(e,"Fork name is required"),process.exit(1));let{error:i}=await p(n,{sourceBucketName:s,sourceBucketSnapshot:u,config:await c()});i&&(t(e,i.message),process.exit(1)),m(e,{name:s,forkName:n})}export{g as default};
1
+ import{a,b as m,c as t,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as r}from"../../chunk-JRALYIRA.js";import{b as c}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createBucket as p}from"@tigrisdata/storage";var e=f("forks","create");async function g(o){a(e);let s=r(o,["name"]),n=r(o,["fork-name","forkName"]),u=r(o,["snapshot","s","S"]);s||(t(e,"Source bucket name is required"),process.exit(1)),n||(t(e,"Fork name is required"),process.exit(1));let{error:i}=await p(n,{sourceBucketName:s,sourceBucketSnapshot:u,config:await c()});i&&(t(e,i.message),process.exit(1)),m(e,{name:s,forkName:n})}export{g as default};
@@ -1 +1 @@
1
- import{a as g,b as k,c as n,d as i,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as u}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as p}from"../../chunk-HGIJOGCZ.js";import{a as s}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listBuckets as S,getBucketInfo as l}from"@tigrisdata/storage";var t=d("forks","list");async function B(c){g(t);let e=s(c,["name"]),h=s(c,["format","f","F"],"table");e||(n(t,"Source bucket name is required"),process.exit(1));let a=await u(),{data:b,error:f}=await l(e,{config:a});if(f&&(n(t,f.message),process.exit(1)),!b.hasForks){i(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){i(t);return}let x=p(r,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(x),k(t,{count:r.length})}export{B as default};
1
+ import{a as g,b as k,c as n,d as i,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as p}from"../../chunk-HGIJOGCZ.js";import{a as s}from"../../chunk-JRALYIRA.js";import{b as u}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listBuckets as S,getBucketInfo as l}from"@tigrisdata/storage";var t=d("forks","list");async function B(c){g(t);let e=s(c,["name"]),h=s(c,["format","f","F"],"table");e||(n(t,"Source bucket name is required"),process.exit(1));let a=await u(),{data:b,error:f}=await l(e,{config:a});if(f&&(n(t,f.message),process.exit(1)),!b.hasForks){i(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){i(t);return}let x=p(r,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(x),k(t,{count:r.length})}export{B as default};
@@ -1 +1 @@
1
- import{a}from"../../chunk-DYTBLGO7.js";import"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";export{a as default};
1
+ import{a}from"../../chunk-HE7E7ZMA.js";import"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";export{a as default};
@@ -1 +1 @@
1
- import{a,b}from"../../chunk-IACJQZUD.js";import"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";export{b as default,a as oauth};
1
+ import{a,b}from"../../chunk-DJIPPZGR.js";import"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";export{b as default,a as oauth};
@@ -1 +1 @@
1
- import{a as c}from"../../chunk-DYTBLGO7.js";import{a as s}from"../../chunk-IACJQZUD.js";import"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import m from"enquirer";var{prompt:h}=m;async function n(e){let a=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(a||r){await c(e);return}let{method:t}=await h({type:"select",name:"method",message:"Choose login method:",choices:[{name:"user",message:"As a user (OAuth2 flow)"},{name:"machine",message:"As a machine (Access Key & Secret)"}]});t==="user"?await s():await c(e)}export{n as default};
1
+ import{a as c}from"../../chunk-HE7E7ZMA.js";import{a as s}from"../../chunk-DJIPPZGR.js";import"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import m from"enquirer";var{prompt:h}=m;async function n(e){let a=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(a||r){await c(e);return}let{method:t}=await h({type:"select",name:"method",message:"Choose login method:",choices:[{name:"user",message:"As a user (OAuth2 flow)"},{name:"machine",message:"As a machine (Access Key & Secret)"}]});t==="user"?await s():await c(e)}export{n as default};
@@ -1 +1 @@
1
- import{a as i,b as a,c as r,g as s}from"../chunk-A3TXP5Y2.js";import"../chunk-4LGKN5DA.js";import{t as e}from"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";var t=s("logout");async function c(){i(t);try{await e(),a(t)}catch(o){o instanceof Error?r(t,o.message):r(t),process.exit(1)}}export{c as default};
1
+ import{a as i,b as a,c as r,g as s}from"../chunk-A3TXP5Y2.js";import"../chunk-4LGKN5DA.js";import{t as e}from"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";var t=s("logout");async function c(){i(t);try{await e(),a(t)}catch(o){o instanceof Error?r(t,o.message):r(t),process.exit(1)}}export{c as default};
package/dist/lib/ls.js CHANGED
@@ -1 +1 @@
1
- import{a as p}from"../chunk-I3FOSZPG.js";import{b as i}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as k,f as c}from"../chunk-HGIJOGCZ.js";import{a as u}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import{list as w,listBuckets as z}from"@tigrisdata/storage";async function S(g){let d=u(g,["path"]);if(!d){let e=await i(),{data:t,error:o}=await z({config:e});o&&(console.error(o.message),process.exit(1));let s=(t.buckets||[]).map(l=>({name:l.name,created:l.creationDate})),a=c(s,"table","buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(a);return}let{bucket:f,path:r}=p(d);f||(console.error("Invalid path"),process.exit(1));let h=await i(),n=r?r.endsWith("/")?r:`${r}/`:void 0,{data:y,error:m}=await w({prefix:n,config:{...h,bucket:f}});m&&(console.error(m.message),process.exit(1));let b=(y.items||[]).map(e=>{let t=n?e.name.slice(n.length):e.name,o=t.indexOf("/"),s=o===-1?t:t.slice(0,o+1),a=s.endsWith("/");return{key:s,size:a?"-":k(e.size),modified:e.lastModified}}).filter((e,t,o)=>e.key!==""&&o.findIndex(s=>s.key===e.key)===t),x=c(b,"table","objects","object",[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}]);console.log(x)}export{S as default};
1
+ import{a as k,f as c}from"../chunk-HGIJOGCZ.js";import{a as u}from"../chunk-JRALYIRA.js";import{b as i}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{f as p}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{list as w,listBuckets as z}from"@tigrisdata/storage";async function S(g){let d=u(g,["path"]);if(!d){let e=await i(),{data:t,error:o}=await z({config:e});o&&(console.error(o.message),process.exit(1));let s=(t.buckets||[]).map(l=>({name:l.name,created:l.creationDate})),a=c(s,"table","buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(a);return}let{bucket:f,path:r}=p(d);f||(console.error("Invalid path"),process.exit(1));let h=await i(),n=r?r.endsWith("/")?r:`${r}/`:void 0,{data:y,error:m}=await w({prefix:n,config:{...h,bucket:f}});m&&(console.error(m.message),process.exit(1));let b=(y.items||[]).map(e=>{let t=n?e.name.slice(n.length):e.name,o=t.indexOf("/"),s=o===-1?t:t.slice(0,o+1),a=s.endsWith("/");return{key:s,size:a?"-":k(e.size),modified:e.lastModified}}).filter((e,t,o)=>e.key!==""&&o.findIndex(s=>s.key===e.key)===t),x=c(b,"table","objects","object",[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}]);console.log(x)}export{S as default};
package/dist/lib/mk.js CHANGED
@@ -1 +1 @@
1
- import{a as c}from"../chunk-I3FOSZPG.js";import{b as a}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as n}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import{createBucket as f,put as g}from"@tigrisdata/storage";async function l(p){let t=n(p,["path"]);t||(console.error("path argument is required"),process.exit(1));let{bucket:e,path:r}=c(t);e||(console.error("Invalid path"),process.exit(1));let s=await a();if(r){let o=r.endsWith("/")?r:`${r}/`,{error:i}=await g(o,"",{config:{...s,bucket:e}});i&&(console.error(i.message),process.exit(1)),console.log(`Folder '${e}/${o}' created`),process.exit(0)}else{let{error:o}=await f(e,{config:s});o&&(console.error(o.message),process.exit(1)),console.log(`Bucket '${e}' created`),process.exit(0)}}export{l as default};
1
+ import{a as n}from"../chunk-JRALYIRA.js";import{b as a}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{f as c}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{createBucket as f,put as g}from"@tigrisdata/storage";async function l(p){let t=n(p,["path"]);t||(console.error("path argument is required"),process.exit(1));let{bucket:e,path:r}=c(t);e||(console.error("Invalid path"),process.exit(1));let s=await a();if(r){let o=r.endsWith("/")?r:`${r}/`,{error:i}=await g(o,"",{config:{...s,bucket:e}});i&&(console.error(i.message),process.exit(1)),console.log(`Folder '${e}/${o}' created`),process.exit(0)}else{let{error:o}=await f(e,{config:s});o&&(console.error(o.message),process.exit(1)),console.log(`Bucket '${e}' created`),process.exit(0)}}export{l as default};
package/dist/lib/mv.js CHANGED
@@ -1 +1 @@
1
- import{a as w,b as x,d as S}from"../chunk-I3FOSZPG.js";import{b as A}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as k}from"../chunk-HGIJOGCZ.js";import{a as g}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import*as I from"readline";import{get as R,put as C,remove as F,list as q,head as z}from"@tigrisdata/storage";async function E(n){let i=I.createInterface({input:process.stdin,output:process.stdout});return new Promise(l=>{i.question(`${n} (y/N): `,f=>{i.close(),l(f.toLowerCase()==="y")})})}async function N(n){let i=g(n,["src"]),l=g(n,["dest"]),f=g(n,["force","f","F"]);(!i||!l)&&(console.error("both src and dest arguments are required"),process.exit(1));let e=w(i),t=w(l);e.bucket||(console.error("Invalid source path"),process.exit(1)),t.bucket||(console.error("Invalid destination path"),process.exit(1)),e.path||(console.error("Cannot move a bucket. Provide a path within the bucket."),process.exit(1));let r=await A(),m=i.includes("*"),p=i.endsWith("/");if(!m&&!p&&e.path&&(p=await x(e.bucket,e.path,r)),m||p){let o=m?e.path.replace("*",""):e.path.endsWith("/")?e.path:`${e.path}/`,c=t.path?`${t.path.replace(/\/$/,"")}/`:"";e.bucket===t.bucket&&o===c&&(console.error("Source and destination are the same"),process.exit(1));let{items:d,error:a}=await S(e.bucket,o||void 0,r);a&&(console.error(a.message),process.exit(1));let u=d.filter(s=>s.name!==o),{data:j}=await q({prefix:o,limit:1,config:{...r,bucket:e.bucket}}),$=o?j?.items?.some(s=>s.name===o):!1;if(u.length===0&&!$){console.log("No objects to move");return}let W=u.length+($?1:0);if(!f&&!await E(`Are you sure you want to move ${W} object(s)?`)){console.log("Aborted");return}let b=0;for(let s of u){let h=o?s.name.slice(o.length):s.name,y=t.path?`${t.path.replace(/\/$/,"")}/${h}`:h,P=await M(r,e.bucket,s.name,t.bucket,y);P.error?console.error(`Failed to move ${s.name}: ${P.error}`):(console.log(`Moved ${s.name} -> ${t.bucket}/${y}`),b++)}let v=!1;if($)if(t.path){let s=`${t.path.replace(/\/$/,"")}/`,h=await M(r,e.bucket,o,t.bucket,s);h.error?console.error(`Failed to move folder marker: ${h.error}`):v=!0}else{let{error:s}=await F(o,{config:{...r,bucket:e.bucket}});s?console.error(`Failed to remove source folder marker: ${s.message}`):v=!0}b===0&&v&&(b=1),console.log(`Moved ${b} object(s)`)}else{e.path||(console.error("Source object key is required"),process.exit(1));let o=e.path.split("/").pop(),c;if(t.path?l.endsWith("/")?c=`${t.path}${o}`:await x(t.bucket,t.path,r)?c=`${t.path}/${o}`:c=t.path:c=o,e.bucket===t.bucket&&e.path===c&&(console.error("Source and destination are the same"),process.exit(1)),!f&&!await E(`Are you sure you want to move '${e.bucket}/${e.path}'?`)){console.log("Aborted");return}let d=await M(r,e.bucket,e.path,t.bucket,c,!0);d.error&&(console.error(d.error),process.exit(1)),console.log(`Moved ${i} -> ${t.bucket}/${c}`)}process.exit(0)}async function M(n,i,l,f,e,t=!1){if(l.endsWith("/")){let{error:a}=await C(e,"",{config:{...n,bucket:f}});if(a)return{error:a.message};let{error:u}=await F(l,{config:{...n,bucket:i}});return u?{error:`Copied but failed to delete source: ${u.message}`}:{}}let r;if(t){let{data:a}=await z(l,{config:{...n,bucket:i}});r=a?.size}let{data:m,error:p}=await R(l,"stream",{config:{...n,bucket:i}});if(p)return{error:p.message};let o=r!==void 0&&r>100*1024*1024,{error:c}=await C(e,m,{multipart:o,onUploadProgress:t?({loaded:a})=>{if(r!==void 0&&r>0){let u=Math.round(a/r*100);process.stdout.write(`\rMoving: ${k(a)} / ${k(r)} (${u}%)`)}else process.stdout.write(`\rMoving: ${k(a)}`)}:void 0,config:{...n,bucket:f}});if(t&&process.stdout.write("\r"+" ".repeat(60)+"\r"),c)return{error:c.message};let{error:d}=await F(l,{config:{...n,bucket:i}});return d?{error:`Copied but failed to delete source: ${d.message}`}:{}}export{N as default};
1
+ import{a as x}from"../chunk-HGIJOGCZ.js";import{a as v}from"../chunk-JRALYIRA.js";import{b as j}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{a as F,b as y,d as S,g as A,h as C,i as I}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import*as N from"readline";import{get as B,put as T,remove as E,list as L,head as G}from"@tigrisdata/storage";async function D(i){let n=N.createInterface({input:process.stdin,output:process.stdout});return new Promise(a=>{n.question(`${i} (y/N): `,d=>{n.close(),a(d.toLowerCase()==="y")})})}async function H(i){let n=v(i,["src"]),a=v(i,["dest"]),d=v(i,["force","f","F"]),h=!!v(i,["recursive","r"]);(!n||!a)&&(console.error("both src and dest arguments are required"),process.exit(1)),(!F(n)||!F(a))&&(console.error("Both src and dest must be remote Tigris paths (t3:// or tigris://)"),process.exit(1));let e=y(n),t=y(a);e.bucket||(console.error("Invalid source path"),process.exit(1)),t.bucket||(console.error("Invalid destination path"),process.exit(1));let $=n.endsWith("/");!e.path&&!$&&(console.error("Cannot move a bucket. Provide a path within the bucket."),process.exit(1));let c=await j(),l=e.path.includes("*"),p=e.path.endsWith("/")||!e.path&&$;if(!l&&!p&&e.path&&(p=await S(e.bucket,e.path,c)),p&&!l&&!h&&(console.error("Source is a remote folder (not moved). Use -r to move recursively."),process.exit(1)),l||p){let r=l?C(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",o=!l&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",f=[t.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),z=f?`${f}/`:"";e.bucket===t.bucket&&r===z&&(console.error("Source and destination are the same"),process.exit(1));let{items:q,error:R}=await I(e.bucket,r||void 0,c);R&&(console.error(R.message),process.exit(1));let b=q.filter(s=>s.name!==r);if(l){let s=e.path.split("/").pop(),m=A(s);b=b.filter(g=>{let k=r?g.name.slice(r.length):g.name;return!h&&k.includes("/")?!1:m.test(k.split("/").pop())})}let{data:O}=await L({prefix:r,limit:1,config:{...c,bucket:e.bucket}}),P=r?O?.items?.some(s=>s.name===r):!1;if(b.length===0&&!P){console.log("No objects to move");return}let U=b.length+(P?1:0);if(!d&&!await D(`Are you sure you want to move ${U} object(s)?`)){console.log("Aborted");return}let w=0;for(let s of b){let m=r?s.name.slice(r.length):s.name,g=f?`${f}/${m}`:m,k=await W(c,e.bucket,s.name,t.bucket,g);k.error?console.error(`Failed to move ${s.name}: ${k.error}`):(console.log(`Moved t3://${e.bucket}/${s.name} -> t3://${t.bucket}/${g}`),w++)}let M=!1;if(P)if(f){let s=`${f}/`,m=await W(c,e.bucket,r,t.bucket,s);m.error?console.error(`Failed to move folder marker: ${m.error}`):M=!0}else{let{error:s}=await E(r,{config:{...c,bucket:e.bucket}});s?console.error(`Failed to remove source folder marker: ${s.message}`):M=!0}w===0&&M&&(w=1),console.log(`Moved ${w} object(s)`)}else{let r=e.path.split("/").pop(),o;if(t.path?t.path.endsWith("/")?o=`${t.path}${r}`:await S(t.bucket,t.path,c)?o=`${t.path}/${r}`:o=t.path:o=r,e.bucket===t.bucket&&e.path===o&&(console.error("Source and destination are the same"),process.exit(1)),!d&&!await D(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`)){console.log("Aborted");return}let u=await W(c,e.bucket,e.path,t.bucket,o,!0);u.error&&(console.error(u.error),process.exit(1)),console.log(`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${o}`)}process.exit(0)}async function W(i,n,a,d,h,e=!1){if(a.endsWith("/")){let{error:o}=await T(h,"",{config:{...i,bucket:d}});if(o)return{error:o.message};let{error:u}=await E(a,{config:{...i,bucket:n}});return u?{error:`Copied but failed to delete source: ${u.message}`}:{}}let t;if(e){let{data:o}=await G(a,{config:{...i,bucket:n}});t=o?.size}let{data:$,error:c}=await B(a,"stream",{config:{...i,bucket:n}});if(c)return{error:c.message};let l=t!==void 0&&t>100*1024*1024,{error:p}=await T(h,$,{multipart:l,onUploadProgress:e?({loaded:o})=>{if(t!==void 0&&t>0){let u=Math.round(o/t*100);process.stdout.write(`\rMoving: ${x(o)} / ${x(t)} (${u}%)`)}else process.stdout.write(`\rMoving: ${x(o)}`)}:void 0,config:{...i,bucket:d}});if(e&&process.stdout.write("\r"+" ".repeat(60)+"\r"),p)return{error:p.message};let{error:r}=await E(a,{config:{...i,bucket:n}});return r?{error:`Copied but failed to delete source: ${r.message}`}:{}}export{H as default};
@@ -1 +1 @@
1
- import{a,b as g,c as r,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as f}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as i}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{remove as k}from"@tigrisdata/storage";var e=m("objects","delete");async function y(s){a(e);let n=i(s,["bucket"]),t=i(s,["key"]);n||(r(e,"Bucket name is required"),process.exit(1)),t||(r(e,"Object key is required"),process.exit(1));let p=await f(),u=Array.isArray(t)?t:[t];for(let o of u){let{error:c}=await k(o,{config:{...p,bucket:n}});c&&(r(e,c.message,{key:o}),process.exit(1)),g(e,{key:o})}}export{y as default};
1
+ import{a,b as g,c as r,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as f}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{remove as k}from"@tigrisdata/storage";var e=m("objects","delete");async function y(s){a(e);let n=i(s,["bucket"]),t=i(s,["key"]);n||(r(e,"Bucket name is required"),process.exit(1)),t||(r(e,"Object key is required"),process.exit(1));let p=await f(),u=Array.isArray(t)?t:[t];for(let o of u){let{error:c}=await k(o,{config:{...p,bucket:n}});c&&(r(e,c.message,{key:o}),process.exit(1)),g(e,{key:o})}}export{y as default};
@@ -1 +1 @@
1
- import{a as f,b as c,c as m,g as l}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as p}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as n}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{createWriteStream as j,writeFileSync as k}from"fs";import{Readable as d}from"stream";import{pipeline as u}from"stream/promises";import{extname as w}from"path";import{get as h}from"@tigrisdata/storage";var e=l("objects","get"),S=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function y(r,o){let t=w(o||r).toLowerCase();return S.has(t)?"string":"stream"}async function q(r){f(e);let o=n(r,["bucket"]),s=n(r,["key"]),t=n(r,["output","o","O"]),x=n(r,["mode","m","M"]);o||(m(e,"Bucket name is required"),process.exit(1)),s||(m(e,"Object key is required"),process.exit(1));let g=await p();if((x||y(s,t))==="stream"){let{data:i,error:a}=await h(s,"stream",{config:{...g,bucket:o}});if(a&&(m(e,a.message),process.exit(1)),t){let b=j(t);await u(d.fromWeb(i),b),c(e,{key:s,output:t})}else await u(d.fromWeb(i),process.stdout),c(e)}else{let{data:i,error:a}=await h(s,"string",{config:{...g,bucket:o}});a&&(m(e,a.message),process.exit(1)),t?(k(t,i),c(e,{key:s,output:t})):(console.log(i),c(e))}}export{q as default};
1
+ import{a as f,b as c,c as m,g as l}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createWriteStream as j,writeFileSync as k}from"fs";import{Readable as d}from"stream";import{pipeline as u}from"stream/promises";import{extname as w}from"path";import{get as h}from"@tigrisdata/storage";var e=l("objects","get"),S=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function y(r,o){let t=w(o||r).toLowerCase();return S.has(t)?"string":"stream"}async function q(r){f(e);let o=n(r,["bucket"]),s=n(r,["key"]),t=n(r,["output","o","O"]),x=n(r,["mode","m","M"]);o||(m(e,"Bucket name is required"),process.exit(1)),s||(m(e,"Object key is required"),process.exit(1));let g=await p();if((x||y(s,t))==="stream"){let{data:i,error:a}=await h(s,"stream",{config:{...g,bucket:o}});if(a&&(m(e,a.message),process.exit(1)),t){let b=j(t);await u(d.fromWeb(i),b),c(e,{key:s,output:t})}else await u(d.fromWeb(i),process.stdout),c(e)}else{let{data:i,error:a}=await h(s,"string",{config:{...g,bucket:o}});a&&(m(e,a.message),process.exit(1)),t?(k(t,i),c(e,{key:s,output:t})):(console.log(i),c(e))}}export{q as default};
@@ -1 +1 @@
1
- import{a as d,b as u,c as s,d as g,g as l}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as a}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as m,f as p}from"../../chunk-HGIJOGCZ.js";import{a as e}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{list as h}from"@tigrisdata/storage";var t=l("objects","list");async function j(i){d(t);let n=e(i,["bucket"]),k=e(i,["prefix","p","P"]),b=e(i,["format","f","F"],"table");n||(s(t,"Bucket name is required"),process.exit(1));let y=await a(),{data:o,error:c}=await h({prefix:k||void 0,config:{...y,bucket:n}});if(c&&(s(t,c.message),process.exit(1)),!o.items||o.items.length===0){g(t);return}let f=o.items.map(r=>({key:r.name,size:m(r.size),modified:r.lastModified})),x=p(f,b,"objects","object",[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}]);console.log(x),u(t,{count:f.length})}export{j as default};
1
+ import{a as d,b as u,c as s,d as g,g as l}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as m,f as p}from"../../chunk-HGIJOGCZ.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as a}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{list as h}from"@tigrisdata/storage";var t=l("objects","list");async function j(i){d(t);let n=e(i,["bucket"]),k=e(i,["prefix","p","P"]),b=e(i,["format","f","F"],"table");n||(s(t,"Bucket name is required"),process.exit(1));let y=await a(),{data:o,error:c}=await h({prefix:k||void 0,config:{...y,bucket:n}});if(c&&(s(t,c.message),process.exit(1)),!o.items||o.items.length===0){g(t);return}let f=o.items.map(r=>({key:r.name,size:m(r.size),modified:r.lastModified})),x=p(f,b,"objects","object",[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}]);console.log(x),u(t,{count:f.length})}export{j as default};
@@ -1 +1 @@
1
- import{a as b,b as y,c as o,g as S}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as l}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as n,f as g}from"../../chunk-HGIJOGCZ.js";import{a as t}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{createReadStream as F,statSync as O}from"fs";import{Readable as h}from"stream";import{put as q}from"@tigrisdata/storage";var r=S("objects","put");async function v(s){b(r);let p=t(s,["bucket"]),d=t(s,["key"]),i=t(s,["file"]),k=t(s,["access","a","A"],"private"),T=t(s,["content-type","contentType","t","T"]),x=t(s,["format","f","F"],"table");p||(o(r,"Bucket name is required"),process.exit(1)),d||(o(r,"Object key is required"),process.exit(1));let z=!process.stdin.isTTY;!i&&!z&&(o(r,"File path is required (or pipe data via stdin)"),process.exit(1));let f,e;if(i){try{e=O(i).size}catch{o(r,`File not found: ${i}`),process.exit(1)}let c=F(i);f=h.toWeb(c)}else f=h.toWeb(process.stdin);let w=await l(),R=!i||e!==void 0&&e>100*1024*1024,{data:a,error:u}=await q(d,f,{access:k==="public"?"public":"private",contentType:T,multipart:R,onUploadProgress:({loaded:c,percentage:m})=>{e!==void 0&&e>0?process.stdout.write(`\rUploading: ${n(c)} / ${n(e)} (${m}%)`):process.stdout.write(`\rUploading: ${n(c)}`)},config:{...w,bucket:p}});process.stdout.write("\r"+" ".repeat(60)+"\r"),u&&(o(r,u.message),process.exit(1));let j=[{path:a.path,size:n(a.size??e??0),contentType:a.contentType||"-",modified:a.modified}],$=g(j,x,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log($),y(r,{key:d,bucket:p})}export{v as default};
1
+ import{a as b,b as y,c as o,g as S}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n,f as g}from"../../chunk-HGIJOGCZ.js";import{a as t}from"../../chunk-JRALYIRA.js";import{b as l}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createReadStream as F,statSync as O}from"fs";import{Readable as h}from"stream";import{put as q}from"@tigrisdata/storage";var r=S("objects","put");async function v(s){b(r);let p=t(s,["bucket"]),d=t(s,["key"]),i=t(s,["file"]),k=t(s,["access","a","A"],"private"),T=t(s,["content-type","contentType","t","T"]),x=t(s,["format","f","F"],"table");p||(o(r,"Bucket name is required"),process.exit(1)),d||(o(r,"Object key is required"),process.exit(1));let z=!process.stdin.isTTY;!i&&!z&&(o(r,"File path is required (or pipe data via stdin)"),process.exit(1));let f,e;if(i){try{e=O(i).size}catch{o(r,`File not found: ${i}`),process.exit(1)}let c=F(i);f=h.toWeb(c)}else f=h.toWeb(process.stdin);let w=await l(),R=!i||e!==void 0&&e>100*1024*1024,{data:a,error:u}=await q(d,f,{access:k==="public"?"public":"private",contentType:T,multipart:R,onUploadProgress:({loaded:c,percentage:m})=>{e!==void 0&&e>0?process.stdout.write(`\rUploading: ${n(c)} / ${n(e)} (${m}%)`):process.stdout.write(`\rUploading: ${n(c)}`)},config:{...w,bucket:p}});process.stdout.write("\r"+" ".repeat(60)+"\r"),u&&(o(r,u.message),process.exit(1));let j=[{path:a.path,size:n(a.size??e??0),contentType:a.contentType||"-",modified:a.modified}],$=g(j,x,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log($),y(r,{key:d,bucket:p})}export{v as default};
@@ -1,4 +1,4 @@
1
- import{a as g,b as c,c as o,f as l,g as u}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as s}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as e}from"../../chunk-JRALYIRA.js";import{k as r,s as a}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{createOrganization as h}from"@tigrisdata/iam";var i=u("organizations","create");async function w(m){if(g(i),a()!=="oauth"){r()?console.log(`You are using access key credentials, which belong to a single organization.
1
+ import{a as g,b as c,c as o,f as l,g as u}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as s}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{k as r,s as a}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createOrganization as h}from"@tigrisdata/iam";var i=u("organizations","create");async function w(m){if(g(i),a()!=="oauth"){r()?console.log(`You are using access key credentials, which belong to a single organization.
2
2
  Organization creation is only available with OAuth login.
3
3
 
4
4
  Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let t=e(m,["name","N"]);t||(o(i,"Organization name is required"),process.exit(1));let f=await s(),{data:p,error:n}=await h(t,{config:f});n&&(o(i,n.message),process.exit(1));let d=p.id;c(i,{name:t,id:d}),l(i,{name:t})}export{w as default};
@@ -1,4 +1,4 @@
1
- import{a as w,b as a,c as y,d as O,g as S}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as h}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as z}from"../../chunk-HGIJOGCZ.js";import{a as d}from"../../chunk-JRALYIRA.js";import{f as m,g as u,k as p,s as f}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listOrganizations as b}from"@tigrisdata/iam";import C from"enquirer";var i=S("organizations","list");async function E(k){if(w(i),f()!=="oauth"){p()?console.log(`You are using access key credentials, which belong to a single organization.
1
+ import{a as w,b as a,c as y,d as O,g as S}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as z}from"../../chunk-HGIJOGCZ.js";import{a as d}from"../../chunk-JRALYIRA.js";import{b as h}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{f as m,g as u,k as p,s as f}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listOrganizations as b}from"@tigrisdata/iam";import C from"enquirer";var i=S("organizations","list");async function E(k){if(w(i),f()!=="oauth"){p()?console.log(`You are using access key credentials, which belong to a single organization.
2
2
  Organization listing and selection is only available with OAuth login.
3
3
 
4
4
  Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let s=d(k,["format","f","F"],"select"),x=await h(),{data:I,error:r}=await b({config:x});r&&(y(i,r.message),process.exit(1));let e=I?.organizations??[];if(e.length===0){O(i);return}let o=u();if(s==="select"){let n=e.map(t=>({name:t.id,message:`${t.name} (${t.id})`,hint:t.id===o?"currently selected":void 0})),g=(await C.prompt({type:"select",name:"organization",message:"Select an organization:",choices:n.map(t=>t.message),initial:o?e.findIndex(t=>t.id===o):0})).organization.match(/\(([^)]+)\)$/),l=g?g[1]:e[0].id;await m(l);let $=e.find(t=>t.id===l);a(i,{name:$?.name});return}let c=e.map(n=>({id:n.id,name:n.name,slug:n.slug,selected:n.id===o?"*":""})),M=z(c,s,"organizations","organization",[{key:"selected",header:" ",width:1},{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"slug",header:"Slug"}]);console.log(M),a(i,{count:c.length})}export{E as default};
@@ -1,4 +1,4 @@
1
- import{a as d,b as f,c as t,g as p}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as u}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as g}from"../../chunk-JRALYIRA.js";import{f as c,k as l,s as m}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listOrganizations as O}from"@tigrisdata/iam";var i=p("organizations","select");async function x(h){if(d(i),m()!=="oauth"){l()?console.log(`You are using access key credentials, which belong to a single organization.
1
+ import{a as d,b as f,c as t,g as p}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as g}from"../../chunk-JRALYIRA.js";import{b as u}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{f as c,k as l,s as m}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listOrganizations as O}from"@tigrisdata/iam";var i=p("organizations","select");async function x(h){if(d(i),m()!=="oauth"){l()?console.log(`You are using access key credentials, which belong to a single organization.
2
2
  Organization selection is only available with OAuth login.
3
3
 
4
4
  Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let n=g(h,["name","N"]);n||(t(i,"Organization name or ID is required"),process.exit(1));let z=await u(),{data:w,error:a}=await O({config:z});a&&(t(i,a.message),process.exit(1));let r=w?.organizations??[],e=r.find(o=>o.id===n||o.name===n);if(!e){let o=r.map(s=>` - ${s.name} (${s.id})`).join(`
package/dist/lib/rm.js CHANGED
@@ -1 +1 @@
1
- import{a as y,b as k,d as x}from"../chunk-I3FOSZPG.js";import{b as A}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as $}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import*as F from"readline";import{remove as w,removeBucket as I,list as P}from"@tigrisdata/storage";async function v(a){let n=F.createInterface({input:process.stdin,output:process.stdout});return new Promise(c=>{n.question(`${a} (y/N): `,e=>{n.close(),c(e.toLowerCase()==="y")})})}async function j(a){let n=$(a,["path"]),c=$(a,["force","f","F"]);n||(console.error("path argument is required"),process.exit(1));let{bucket:e,path:r}=y(n);e||(console.error("Invalid path"),process.exit(1));let s=await A();if(!r){if(!c&&!await v(`Are you sure you want to delete bucket '${e}'?`)){console.log("Aborted");return}let{error:t}=await I(e,{config:s});t&&(console.error(t.message),process.exit(1)),console.log(`Removed bucket '${e}'`);return}let m=n.includes("*"),f=r.endsWith("/");if(!m&&!f&&(f=await k(e,r,s)),m||f){let t=m?r.replace("*",""):r.endsWith("/")?r:`${r}/`,{items:d,error:h}=await x(e,t||void 0,s);h&&(console.error(h.message),process.exit(1));let u=d,i=t,R=u.some(o=>o.name===i),g=!1;if(!R){let{data:o}=await P({prefix:i,limit:1,config:{...s,bucket:e}});g=o?.items?.some(l=>l.name===i)||!1}let b=u.length+(g?1:0);if(b===0){console.log("No objects to remove");return}if(!c&&!await v(`Are you sure you want to delete ${b} object(s)?`)){console.log("Aborted");return}let p=0;for(let o of u){let{error:l}=await w(o.name,{config:{...s,bucket:e}});l?console.error(`Failed to remove ${o.name}: ${l.message}`):(console.log(`Removed ${e}/${o.name}`),p++)}if(g){let{error:o}=await w(i,{config:{...s,bucket:e}});o?console.error(`Failed to remove ${i}: ${o.message}`):(console.log(`Removed ${e}/${i}`),p++)}console.log(`Removed ${p} object(s)`)}else{if(!c&&!await v(`Are you sure you want to delete '${e}/${r}'?`)){console.log("Aborted");return}let{error:t}=await w(r,{config:{...s,bucket:e}});t&&(console.error(t.message),process.exit(1)),console.log(`Removed ${e}/${r}`)}process.exit(0)}export{j as default};
1
+ import{a as g}from"../chunk-JRALYIRA.js";import{b as j}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{a as P,b as A,d as F,g as I,h as S,i as W}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import*as E from"readline";import{remove as w,removeBucket as T,list as q}from"@tigrisdata/storage";async function $(l){let s=E.createInterface({input:process.stdin,output:process.stdout});return new Promise(m=>{s.question(`${l} (y/N): `,d=>{s.close(),m(d.toLowerCase()==="y")})})}async function C(l){let s=g(l,["path"]),m=g(l,["force","f","F"]),d=!!g(l,["recursive","r"]);s||(console.error("path argument is required"),process.exit(1)),P(s)||(console.error("Path must be a remote Tigris path (t3:// or tigris://)"),process.exit(1));let{bucket:e,path:o}=A(s);e||(console.error("Invalid path"),process.exit(1));let i=await j(),b=s.endsWith("/");if(!o&&!b){if(!m&&!await $(`Are you sure you want to delete bucket '${e}'?`)){console.log("Aborted");return}let{error:t}=await T(e,{config:i});t&&(console.error(t.message),process.exit(1)),console.log(`Removed bucket '${e}'`);return}let n=o.includes("*"),u=o.endsWith("/")||!o&&b;if(!n&&!u&&(u=await F(e,o,i)),u&&!n&&!d&&(console.error("Source is a remote folder (not removed). Use -r to remove recursively."),process.exit(1)),n||u){let t=n?S(o):o?o.endsWith("/")?o:`${o}/`:"",{items:p,error:x}=await W(e,t||void 0,i);x&&(console.error(x.message),process.exit(1));let f=p;if(n){let r=o.split("/").pop(),a=I(r);f=f.filter(R=>{let k=t?R.name.slice(t.length):R.name;return!d&&k.includes("/")?!1:a.test(k.split("/").pop())})}let c=t,M=f.some(r=>r.name===c),v=!1;if(!M&&!n){let{data:r}=await q({prefix:c,limit:1,config:{...i,bucket:e}});v=r?.items?.some(a=>a.name===c)||!1}let y=f.length+(v?1:0);if(y===0){console.log("No objects to remove");return}if(!m&&!await $(`Are you sure you want to delete ${y} object(s)?`)){console.log("Aborted");return}let h=0;for(let r of f){let{error:a}=await w(r.name,{config:{...i,bucket:e}});a?console.error(`Failed to remove ${r.name}: ${a.message}`):(console.log(`Removed t3://${e}/${r.name}`),h++)}if(v){let{error:r}=await w(c,{config:{...i,bucket:e}});r?console.error(`Failed to remove ${c}: ${r.message}`):(console.log(`Removed t3://${e}/${c}`),h++)}console.log(`Removed ${h} object(s)`)}else{if(!m&&!await $(`Are you sure you want to delete 't3://${e}/${o}'?`)){console.log("Aborted");return}let{error:t}=await w(o,{config:{...i,bucket:e}});t&&(console.error(t.message),process.exit(1)),console.log(`Removed t3://${e}/${o}`)}process.exit(0)}export{C as default};
@@ -1 +1 @@
1
- import{a as f,b as u,c as n,d as g,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as c}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as p}from"../../chunk-HGIJOGCZ.js";import{a as o}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{listBucketSnapshots as y}from"@tigrisdata/storage";var t=d("snapshots","list");async function x(s){f(t);let a=o(s,["name"]),l=o(s,["format","f","F"],"table");a||(n(t,"Bucket name is required"),process.exit(1));let h=await c(),{data:e,error:i}=await y(a,{config:h});if(i&&(n(t,i.message),process.exit(1)),!e||e.length===0){g(t);return}let m=e.map(r=>({name:r.name||"",version:r.version||"",created:r.creationDate})),k=p(m,l,"snapshots","snapshot",[{key:"name",header:"Name"},{key:"version",header:"Version"},{key:"created",header:"Created"}]);console.log(k),u(t,{count:m.length})}export{x as default};
1
+ import{a as f,b as u,c as n,d as g,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as p}from"../../chunk-HGIJOGCZ.js";import{a as o}from"../../chunk-JRALYIRA.js";import{b as c}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listBucketSnapshots as y}from"@tigrisdata/storage";var t=d("snapshots","list");async function x(s){f(t);let a=o(s,["name"]),l=o(s,["format","f","F"],"table");a||(n(t,"Bucket name is required"),process.exit(1));let h=await c(),{data:e,error:i}=await y(a,{config:h});if(i&&(n(t,i.message),process.exit(1)),!e||e.length===0){g(t);return}let m=e.map(r=>({name:r.name||"",version:r.version||"",created:r.creationDate})),k=p(m,l,"snapshots","snapshot",[{key:"name",header:"Name"},{key:"version",header:"Version"},{key:"created",header:"Created"}]);console.log(k),u(t,{count:m.length})}export{x as default};
@@ -1 +1 @@
1
- import{a as p,b as c,c as e,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{b as m}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as n}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.js";import{createBucketSnapshot as h}from"@tigrisdata/storage";var t=f("snapshots","take");async function u(o){p(t);let s=n(o,["name"]),a=n(o,["snapshot-name","snapshotName"]);s||(e(t,"Bucket name is required"),process.exit(1));let g=await m(),{data:r,error:i}=await h(s,{name:a,config:g});i&&(e(t,i.message),process.exit(1)),c(t,{name:s,snapshotName:a||r?.snapshotVersion,version:r?.snapshotVersion})}export{u as default};
1
+ import{a as p,b as c,c as e,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n}from"../../chunk-JRALYIRA.js";import{b as m}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createBucketSnapshot as h}from"@tigrisdata/storage";var t=f("snapshots","take");async function u(o){p(t);let s=n(o,["name"]),a=n(o,["snapshot-name","snapshotName"]);s||(e(t,"Bucket name is required"),process.exit(1));let g=await m(),{data:r,error:i}=await h(s,{name:a,config:g});i&&(e(t,i.message),process.exit(1)),c(t,{name:s,snapshotName:a||r?.snapshotVersion,version:r?.snapshotVersion})}export{u as default};
package/dist/lib/touch.js CHANGED
@@ -1 +1 @@
1
- import{a as s}from"../chunk-I3FOSZPG.js";import{b as c}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as i}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import{put as p}from"@tigrisdata/storage";async function f(n){let r=i(n,["path"]);r||(console.error("path argument is required"),process.exit(1));let{bucket:o,path:e}=s(r);o||(console.error("Invalid path"),process.exit(1)),e||(console.error("Object key is required (use mk to create buckets)"),process.exit(1));let a=await c(),{error:t}=await p(e,"",{config:{...a,bucket:o}});t&&(console.error(t.message),process.exit(1)),console.log(`Created '${o}/${e}'`),process.exit(0)}export{f as default};
1
+ import{a as i}from"../chunk-JRALYIRA.js";import{b as n}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{f as s}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{put as p}from"@tigrisdata/storage";async function f(c){let r=i(c,["path"]);r||(console.error("path argument is required"),process.exit(1));let{bucket:o,path:e}=s(r);o||(console.error("Invalid path"),process.exit(1)),e||(console.error("Object key is required (use mk to create buckets)"),process.exit(1));let a=await n(),{error:t}=await p(e,"",{config:{...a,bucket:o}});t&&(console.error(t.message),process.exit(1)),console.log(`Created '${o}/${e}'`),process.exit(0)}export{f as default};
@@ -1,2 +1,2 @@
1
- import{c,e as h,g as $}from"../chunk-A3TXP5Y2.js";import"../chunk-4LGKN5DA.js";import{b as O}from"../chunk-TQWT7ROJ.js";import{b as z}from"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{g as f,k as p,s as A}from"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import{listOrganizations as C}from"@tigrisdata/iam";var s=$("whoami");async function y(){try{let i=A(),d=p(),l,u;if(i==="oauth"){let n=z();if(!await n.isAuthenticated()){h(s);return}let a=await n.getIdTokenClaims();l=a.email,u=a.sub}else if(d)l=void 0,u=d.accessKeyId;else{h(s);return}let e=[];if(e.push(""),e.push("User Information:"),e.push(` Email: ${l||"N/A"}`),e.push(` User ID: ${u||"N/A"}`),i==="oauth"){let n=await O(),o=f(),{data:a,error:g}=await C({config:n});g&&(c(s,g.message),process.exit(1));let r=a?.organizations??[];if(r.length>0){if(e.push(""),e.push(`Organizations (${r.length}):`),r.forEach(t=>{let w=t.id===o?">":" ";e.push(` ${w} ${t.name} (${t.id})`)}),o){let t=r.find(m=>m.id===o);t&&(e.push(""),e.push(`Active: ${t.name}`))}}else e.push(""),e.push("Organizations: None")}else e.push(""),e.push("Login method: Access Key Credentials"),e.push(" (Organization listing requires OAuth login: tigris login)");e.push(""),console.log(e.join(`
1
+ import{c,e as h,g as $}from"../chunk-A3TXP5Y2.js";import"../chunk-4LGKN5DA.js";import{b as O}from"../chunk-ESJWTUFN.js";import{b as z}from"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{g as f,k as p,s as A}from"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{listOrganizations as C}from"@tigrisdata/iam";var s=$("whoami");async function y(){try{let i=A(),d=p(),l,u;if(i==="oauth"){let n=z();if(!await n.isAuthenticated()){h(s);return}let a=await n.getIdTokenClaims();l=a.email,u=a.sub}else if(d)l=void 0,u=d.accessKeyId;else{h(s);return}let e=[];if(e.push(""),e.push("User Information:"),e.push(` Email: ${l||"N/A"}`),e.push(` User ID: ${u||"N/A"}`),i==="oauth"){let n=await O(),o=f(),{data:a,error:g}=await C({config:n});g&&(c(s,g.message),process.exit(1));let r=a?.organizations??[];if(r.length>0){if(e.push(""),e.push(`Organizations (${r.length}):`),r.forEach(t=>{let w=t.id===o?">":" ";e.push(` ${w} ${t.name} (${t.id})`)}),o){let t=r.find(m=>m.id===o);t&&(e.push(""),e.push(`Active: ${t.name}`))}}else e.push(""),e.push("Organizations: None")}else e.push(""),e.push("Login method: Access Key Credentials"),e.push(" (Organization listing requires OAuth login: tigris login)");e.push(""),console.log(e.join(`
2
2
  `))}catch(i){i instanceof Error?c(s,i.message):c(s),process.exit(1)}}export{y as default};
package/dist/specs.yaml CHANGED
@@ -200,10 +200,12 @@ commands:
200
200
  arguments:
201
201
  - name: path
202
202
  type: positional
203
- description: a bucket or path in a bucket (if not provided, lists all buckets)
203
+ description: a bucket or path in a bucket (if not provided, lists all buckets). Supports t3:// and tigris:// prefixes.
204
204
  examples:
205
205
  - my-bucket
206
206
  - my-bucket/my-path
207
+ - t3://my-bucket
208
+ - t3://my-bucket/my-path
207
209
 
208
210
  # mk
209
211
  - name: mk
@@ -213,10 +215,12 @@ commands:
213
215
  - name: path
214
216
  required: true
215
217
  type: positional
216
- description: a bucket or a folder in a bucket
218
+ description: a bucket or a folder in a bucket. Supports t3:// and tigris:// prefixes.
217
219
  examples:
218
220
  - my-bucket
219
221
  - my-bucket/my-path
222
+ - t3://my-bucket
223
+ - t3://my-bucket/my-path
220
224
 
221
225
  # touch
222
226
  - name: touch
@@ -225,9 +229,10 @@ commands:
225
229
  - name: path
226
230
  required: true
227
231
  type: positional
228
- description: path to the object (bucket/key)
232
+ description: path to the object (bucket/key). Supports t3:// and tigris:// prefixes.
229
233
  examples:
230
234
  - my-bucket/my-file.txt
235
+ - t3://my-bucket/my-file.txt
231
236
 
232
237
  # stat
233
238
  - name: stat
@@ -236,55 +241,67 @@ commands:
236
241
  - name: path
237
242
  required: true
238
243
  type: positional
239
- description: a bucket or a folder in a bucket or an object in a bucket or path
244
+ description: a bucket, folder, or object path. Supports t3:// and tigris:// prefixes.
240
245
  examples:
241
246
  - my-bucket
242
247
  - my-bucket/my-path
248
+ - t3://my-bucket
249
+ - t3://my-bucket/my-path
243
250
  - my-bucket/my-path/my-object.json
244
251
 
245
252
  # cp
246
253
  - name: cp
247
- description: Copy a folder or an object
254
+ description: Copy files between local filesystem and Tigris, or within Tigris
248
255
  alias: copy
249
256
  arguments:
250
257
  - name: src
251
258
  required: true
252
259
  type: positional
253
- description: a bucket, a folder in a bucket, an object in a bucket / path. Wildcard is supported.
260
+ description: source path. Use t3:// (or tigris://) prefix for remote Tigris paths, bare paths for local files. At least one side must be remote. Quote wildcard patterns to prevent shell expansion.
254
261
  examples:
255
- - my-bucket
256
- - my-bucket/my-path
257
- - my-bucket/my-path/my-object.json
262
+ - ./file.txt
263
+ - ./dir/
264
+ - '"./dir/*.jpg"'
265
+ - t3://my-bucket/my-path/my-object.json
266
+ - t3://my-bucket/my-path/*
258
267
  - name: dest
259
268
  required: true
260
269
  type: positional
261
- description: path to copy to
270
+ description: destination path. Use t3:// (or tigris://) prefix for remote Tigris paths, bare paths for local files.
262
271
  examples:
263
- - my-bucket
264
- - my-bucket/my-path
265
- - my-bucket/my-path/*
266
- - my-bucket/my-path/my-object.json
272
+ - .
273
+ - ./local-dir/
274
+ - t3://my-bucket
275
+ - t3://my-bucket/my-path/
276
+ - name: recursive
277
+ type: flag
278
+ alias: r
279
+ description: copy directories recursively
267
280
 
268
281
  # mv
269
282
  - name: mv
270
- description: Move a folder or an object
283
+ description: Move objects within Tigris
271
284
  alias: move
272
285
  arguments:
273
286
  - name: src
274
287
  type: positional
275
288
  required: true
276
- description: path to move from
289
+ description: remote source path. Use t3:// (or tigris://) prefix. Quote wildcard patterns to prevent shell expansion.
277
290
  examples:
278
- - my-bucket/my-path
279
- - my-bucket/my-path/*
280
- - my-bucket/my-path/my-object.json
291
+ - t3://my-bucket/my-path/my-object.json
292
+ - t3://my-bucket/my-path/
293
+ - '"t3://my-bucket/my-path/*.jpg"'
281
294
  - name: dest
282
295
  type: positional
283
296
  required: true
284
- description: path to move to
297
+ description: remote destination path. Use t3:// (or tigris://) prefix.
285
298
  examples:
286
- - my-bucket
287
- - my-bucket/new-path
299
+ - t3://my-bucket
300
+ - t3://my-bucket/new-path/
301
+ - name: recursive
302
+ type: flag
303
+ alias: r
304
+ description: move directories recursively
288
305
  - name: force
289
306
  type: flag
290
307
  alias: f
@@ -292,18 +309,22 @@ commands:
292
309
 
293
310
  # rm
294
311
  - name: rm
295
- description: Remove a bucket or a folder in a bucket or an object in a bucket or path
312
+ description: Remove a bucket, folder, or object from Tigris
296
313
  alias: remove
297
314
  arguments:
298
315
  - name: path
299
316
  type: positional
300
317
  required: true
301
- description: a bucket, a folder in a bucket, an object in a bucket / path. Wildcard is supported.
318
+ description: remote path. Use t3:// (or tigris://) prefix. Bucket-only path removes the bucket. Quote wildcard patterns to prevent shell expansion.
302
319
  examples:
303
- - my-bucket
304
- - my-bucket/my-path
305
- - my-bucket/my-path/*
306
- - my-bucket/my-path/my-object.json
320
+ - t3://my-bucket
321
+ - t3://my-bucket/my-path/my-object.json
322
+ - t3://my-bucket/my-path/
323
+ - '"t3://my-bucket/my-path/*.jpg"'
324
+ - name: recursive
325
+ type: flag
326
+ alias: r
327
+ description: remove directories recursively
307
328
  - name: force
308
329
  type: flag
309
330
  alias: f
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-I3FOSZPG.js";export{b as isPathFolder,d as listAllItems,a as parsePath,c as parsePaths};
1
+ import{a,b,c,d,e,f,g,h,i}from"../chunk-LCWHZUZZ.js";export{g as globToRegex,d as isPathFolder,a as isRemotePath,i as listAllItems,f as parseAnyPath,c as parsePath,e as parsePaths,b as parseRemotePath,h as wildcardPrefix};
@@ -0,0 +1 @@
1
+ import{b as a,c as b}from"../chunk-TUJTXB5G.js";import"../chunk-D63SZLT5.js";export{b as checkForUpdates,a as isNewerVersion};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigrisdata/cli",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "Command line interface for Tigris object storage",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1 +0,0 @@
1
- var t="https://t3.storage.dev",e="https://iam.storageapi.dev";export{t as a,e as b};
@@ -1 +0,0 @@
1
- import{list as g}from"@tigrisdata/storage";function a(i){let t=i.split("/");return{bucket:t[0],path:t.slice(1).join("/")}}async function p(i,t,s){let{data:e}=await g({prefix:`${t}/`,limit:1,config:{...s,bucket:i}});return!!(e?.items&&e.items.length>0)}function f(i,t){return{source:a(i),destination:a(t)}}async function d(i,t,s){let e=[],n;do{let{data:r,error:o}=await g({prefix:t,paginationToken:n,config:{...s,bucket:i}});if(o)return{items:e,error:o};r?.items&&e.push(...r.items),n=r?.hasMore?r.paginationToken:void 0}while(n);return{items:e}}export{a,p as b,f as c,d};
@@ -1,12 +0,0 @@
1
- import{a as b}from"./chunk-4LGKN5DA.js";import{Command as E}from"commander";import{existsSync as k}from"fs";import{join as f,dirname as q}from"path";import{fileURLToPath as R}from"url";var w="2.6.1";process.on("unhandledRejection",e=>{(e===""||e===void 0)&&(console.error(`
2
- Operation cancelled`),process.exit(1)),console.error(`
3
- Error:`,e instanceof Error?e.message:e),process.exit(1)});process.on("uncaughtException",e=>{console.error(`
4
- Error:`,e.message),process.exit(1)});var P=R(import.meta.url),d=q(P),l=b();function y(e,t){return(t?[f(d,"lib",e,`${t}.js`),f(d,"lib",e,t,"index.js")]:[f(d,"lib",`${e}.js`),f(d,"lib",e,"index.js")]).some(s=>k(s))}function C(e){let t;e.type==="positional"?t=` ${e.name}`:(t=` --${e.name}`,e.alias&&e.alias.length===1&&(t+=`, -${e.alias}`));let n=26,s=t.length>=n?t+" ":t.padEnd(n),i=e.description;return e.options&&(Array.isArray(e.options)&&typeof e.options[0]=="string"?i+=` (options: ${e.options.join(", ")})`:i+=` (options: ${e.options.map(o=>o.value).join(", ")})`),e.default&&(i+=` [default: ${e.default}]`),e.required&&(i+=" [required]"),e["required-when"]&&(i+=` [required when: ${e["required-when"]}]`),e.multiple&&(i+=" [multiple values: comma-separated]"),e.type==="positional"&&(i+=" [positional argument]"),e.examples&&e.examples.length>0&&(i+=` (examples: ${e.examples.join(", ")})`),`${s}${i}`}function v(e){if(console.log(`
5
- ${l.name} ${e.name} - ${e.description}
6
- `),e.operations&&e.operations.length>0){let t=e.operations.filter(n=>y(e.name,n.name));t.length>0&&(console.log("Operations:"),t.forEach(n=>{let s=` ${n.name}`;if(n.alias){let o=Array.isArray(n.alias)?n.alias:[n.alias];s+=` (${o.join(", ")})`}let i=s.padEnd(24);console.log(`${i}${n.description}`)}),console.log())}e.arguments&&e.arguments.length>0&&(console.log("Arguments:"),e.arguments.forEach(t=>{console.log(C(t))}),console.log()),console.log(`Use "${l.name} ${e.name} <operation> help" for more information about an operation.`)}function D(e,t){console.log(`
7
- ${l.name} ${e.name} ${t.name} - ${t.description}
8
- `),t.arguments&&t.arguments.length>0&&(console.log("Arguments:"),t.arguments.forEach(n=>{console.log(C(n))}),console.log())}function V(e){return y(e.name)?!0:e.operations?e.operations.some(t=>y(e.name,t.name)):!1}function x(){console.log(`Tigris CLI Version: ${w}
9
- `),console.log(`Usage: tigris [command] [options]
10
- `),console.log("Commands:"),l.commands.filter(V).forEach(t=>{let n=` ${t.name}`;t.alias&&(n+=` (${t.alias})`);let s=n.padEnd(24);console.log(`${s}${t.description}`)}),console.log(`
11
- Use "${l.name} <command> help" for more information about a command.`)}function m(e,t=[]){t.forEach(n=>{if(n.type==="positional"){let s=n.required?`<${n.name}>`:`[${n.name}]`;e.argument(s,n.description)}else{let i=n.alias&&n.alias.length===1?`-${n.alias}, --${n.name}`:`--${n.name}`;n.type==="flag"||(n.type==="boolean"?i+=" [value]":n.options?i+=" <value>":i+=n.required||n["required-when"]?" <value>":" [value]"),e.option(i,n.description,n.default)}})}function g(e,t){for(let n of e){if(n["required-when"]){let[s,i]=n["required-when"].split("="),o=h(t,s,e),r=h(t,n.name,e);if(o===i&&!r)return console.error(`--${n.name} is required when --${s} is ${i}`),!1}if(n.required&&!h(t,n.name,e))return console.error(`--${n.name} is required`),!1}return!0}function h(e,t,n){if(n){let i=n.find(o=>o.name===t);if(i&&i.alias){let o=i.alias.charAt(0).toUpperCase()+i.alias.slice(1);if(e[o]!==void 0)return e[o]}}let s=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),U(t)];for(let i of s)if(e[i]!==void 0)return e[i]}function U(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}async function T(e,t){let n=t?[`./lib/${e}/${t}.js`,`./lib/${e}/${t}/index.js`]:[`./lib/${e}.js`,`./lib/${e}/index.js`];for(let i of n){let o=await import(i).catch(()=>null);if(o)return{module:o,error:null}}return{module:null,error:`Command not found: ${t?`${e} ${t}`:e}`}}async function $(e,t,n=[],s={},i){if(i){let A=i.replace(/\\n/g,`
12
- `);console.log(A)}let{module:o,error:r}=await T(e,t);(r||!o)&&(console.error(r),process.exit(1));let a=t||e,p=o.default||o[a];typeof p!="function"&&(console.error(`Command not implemented: ${a}`),process.exit(1)),await p({...s,_positional:n})}var u=new E;u.name(l.name).description(l.description).version(l.version);function c(e,t,n){let s;"optsWithGlobals"in n&&typeof n.optsWithGlobals=="function"?s=n.optsWithGlobals():"opts"in n&&typeof n.opts=="function"?s=n.opts():s=n;let i={...s};return e.filter(r=>r.type==="positional").forEach((r,a)=>{t[a]!==void 0&&(r.multiple?i[r.name]=t[a].split(",").map(p=>p.trim()):i[r.name]=t[a])}),e.forEach(r=>{r.multiple&&r.type!=="positional"&&i[r.name]&&typeof i[r.name]=="string"&&(i[r.name]=i[r.name].split(",").map(a=>a.trim()))}),i}l.commands.forEach(e=>{let t=u.command(e.name).description(e.description);if(e.alias&&t.alias(e.alias),e.operations&&e.operations.length>0)if(e.operations.forEach(n=>{let s=t.command(n.name).description(n.description);n.alias&&(Array.isArray(n.alias)?n.alias:[n.alias]).forEach(o=>s.alias(o)),m(s,n.arguments),s.action(async(...i)=>{let o=i.pop(),r=i;n.arguments&&!g(n.arguments,c(n.arguments,r,o))||await $(e.name,n.name,r,c(n.arguments||[],r,o),n.message)}),s.command("help").description("Show help for this operation").action(()=>{D(e,n)})}),e.default){let n=e.operations?.find(s=>s.name===e.default);if(n){m(t,e.arguments),m(t,n.arguments);let s=[...e.arguments||[],...n.arguments||[]];t.action(async(...i)=>{let o=i.pop(),r=i;s.length>0&&!g(s,c(s,r,o))||await $(e.name,n.name,r,c(s,r,o),e.message||n.message)})}}else t.action(()=>{v(e)});else m(t,e.arguments),t.action(async(...n)=>{let s=n.pop(),i=n;e.arguments&&!g(e.arguments,c(e.arguments,i,s))||await $(e.name,void 0,i,c(e.arguments||[],i,s),e.message)});t.command("help").description("Show help for this command").action(()=>{v(e)})});u.command("help").description("Show general help").action(()=>{x()});u.action(()=>{x()});u.parse();