@tigrisdata/cli 2.16.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/auth/iam.js +1 -1
  2. package/dist/auth/provider.js +1 -1
  3. package/dist/{chunk-YYVLDLPP.js → chunk-4D33BI67.js} +1 -1
  4. package/dist/{chunk-LVAJB4FR.js → chunk-7ERBLTNY.js} +1 -1
  5. package/dist/{chunk-EYGRHNNY.js → chunk-P4RBPX26.js} +1 -1
  6. package/dist/{chunk-AU3RCZHB.js → chunk-PNSKHQX4.js} +1 -1
  7. package/dist/chunk-ZADGAARW.js +1 -0
  8. package/dist/cli.js +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/lib/access-keys/assign.js +1 -1
  11. package/dist/lib/access-keys/attach-policy.js +1 -0
  12. package/dist/lib/access-keys/create.js +1 -1
  13. package/dist/lib/access-keys/delete.js +1 -1
  14. package/dist/lib/access-keys/detach-policy.js +1 -0
  15. package/dist/lib/access-keys/get.js +1 -1
  16. package/dist/lib/access-keys/list-policies.js +1 -0
  17. package/dist/lib/access-keys/list.js +1 -1
  18. package/dist/lib/access-keys/rotate.js +1 -0
  19. package/dist/lib/buckets/create.js +1 -1
  20. package/dist/lib/buckets/delete.js +1 -1
  21. package/dist/lib/buckets/get.js +1 -1
  22. package/dist/lib/buckets/list.js +1 -1
  23. package/dist/lib/buckets/set-cors.js +1 -1
  24. package/dist/lib/buckets/set-locations.js +1 -1
  25. package/dist/lib/buckets/set-migration.js +1 -1
  26. package/dist/lib/buckets/set-notifications.js +1 -1
  27. package/dist/lib/buckets/set-transition.js +1 -1
  28. package/dist/lib/buckets/set-ttl.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/iam/policies/create.js +1 -1
  36. package/dist/lib/iam/policies/delete.js +1 -1
  37. package/dist/lib/iam/policies/edit.js +1 -1
  38. package/dist/lib/iam/policies/get.js +1 -1
  39. package/dist/lib/iam/policies/link-key.js +1 -0
  40. package/dist/lib/iam/policies/list-keys.js +1 -0
  41. package/dist/lib/iam/policies/list.js +1 -1
  42. package/dist/lib/iam/policies/select-policy.js +1 -0
  43. package/dist/lib/iam/policies/unlink-key.js +1 -0
  44. package/dist/lib/iam/users/invite.js +1 -1
  45. package/dist/lib/iam/users/list.js +1 -1
  46. package/dist/lib/iam/users/remove.js +1 -1
  47. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  48. package/dist/lib/iam/users/update-role.js +1 -1
  49. package/dist/lib/login/credentials.js +1 -1
  50. package/dist/lib/login/select.js +1 -1
  51. package/dist/lib/ls.js +1 -1
  52. package/dist/lib/mk.js +1 -1
  53. package/dist/lib/mv.js +1 -1
  54. package/dist/lib/objects/delete.js +1 -1
  55. package/dist/lib/objects/get.js +1 -1
  56. package/dist/lib/objects/info.js +1 -1
  57. package/dist/lib/objects/list.js +1 -1
  58. package/dist/lib/objects/put.js +1 -1
  59. package/dist/lib/objects/set.js +1 -1
  60. package/dist/lib/organizations/create.js +1 -1
  61. package/dist/lib/organizations/list.js +1 -1
  62. package/dist/lib/organizations/select.js +1 -1
  63. package/dist/lib/presign.js +1 -1
  64. package/dist/lib/rm.js +1 -1
  65. package/dist/lib/snapshots/list.js +1 -1
  66. package/dist/lib/snapshots/take.js +1 -1
  67. package/dist/lib/stat.js +1 -1
  68. package/dist/lib/touch.js +1 -1
  69. package/dist/lib/update.js +1 -1
  70. package/dist/lib/whoami.js +1 -1
  71. package/dist/specs.yaml +172 -0
  72. package/dist/utils/update-check.js +1 -1
  73. package/package.json +3 -3
  74. /package/dist/{chunk-ALJKYIQL.js → chunk-YOKGP6YU.js} +0 -0
package/dist/auth/iam.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c}from"../chunk-LVAJB4FR.js";import"../chunk-ALJKYIQL.js";import"../chunk-VAVMX5DC.js";import"../chunk-DV3LCXRH.js";import"../chunk-PG746YF3.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import{a}from"../chunk-GAWFFIPC.js";import"../chunk-OHGCOC5Q.js";export{c as getIAMConfig,b as getOAuthIAMConfig,a as isFlyOrganization};
1
+ import{a as b,b as c}from"../chunk-7ERBLTNY.js";import"../chunk-YOKGP6YU.js";import"../chunk-VAVMX5DC.js";import"../chunk-DV3LCXRH.js";import"../chunk-PG746YF3.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import{a}from"../chunk-GAWFFIPC.js";import"../chunk-OHGCOC5Q.js";export{c as getIAMConfig,b as getOAuthIAMConfig,a as isFlyOrganization};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-ALJKYIQL.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";export{b as getEnvCredentials,d as getStorageConfig,e as getStorageConfigWithOrg,a as getTigrisConfig,f as requireOAuthLogin,c as resolveAuthMethod};
1
+ import{a,b,c,d,e,f}from"../chunk-YOKGP6YU.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";export{b as getEnvCredentials,d as getStorageConfig,e as getStorageConfigWithOrg,a as getTigrisConfig,f as requireOAuthLogin,c as resolveAuthMethod};
@@ -1,4 +1,4 @@
1
- import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{execSync as _}from"child_process";import{mkdirSync as C,readFileSync as E,writeFileSync as I}from"fs";import T from"https";import{homedir as g}from"os";import{join as h}from"path";var u="2.16.0";var b=h(g(),".tigris","update-check.json");function y(){try{let t=E(b,"utf-8"),i=JSON.parse(t);return typeof i.latestVersion=="string"&&typeof i.lastChecked=="number"?i:null}catch{return null}}function v(t){try{C(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(t),"utf-8")}catch{}}function N(t,i){let a=n=>{let s=n.startsWith("v")?n.slice(1):n,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(t),e=a(i);return!r||!e?!1:e.major>r.major?!0:e.major<r.major?!1:e.minor>r.minor?!0:e.minor<r.minor?!1:e.patch>r.patch?!0:e.patch<r.patch?!1:r.prerelease&&!e.prerelease?!0:(!r.prerelease&&e.prerelease,!1)}function x(){if(process.platform==="win32")return!1;try{return _("brew list tigris",{stdio:"ignore"}),!0}catch{return!1}}function O(){let t=globalThis.__TIGRIS_BINARY===!0,i=process.platform==="win32";return t?x()?"brew upgrade tigris":i?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function j(t={}){return new Promise((i,a)=>{let r=T.get(m,{timeout:1e4},e=>{let n="";e.on("data",s=>{n+=s}),e.on("end",()=>{try{let s=JSON.parse(n);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),i(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",e=>{a(e)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),t.unref&&r.on("socket",e=>{e.unref()}),r.end()})}function k(){j({unref:!0}).catch(()=>{})}function P(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let t=y(),i=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(t&&N(u,t.latestVersion)&&(!t.lastNotified||Date.now()-t.lastNotified>i)){let r=`Update available: ${u} \u2192 ${t.latestVersion}`,e='Run "tigris update" to upgrade.',n=Math.max(r.length,e.length)+4,s="\u250C"+"\u2500".repeat(n-2)+"\u2510",l="\u2514"+"\u2500".repeat(n-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(n-4)+" \u2502";console.log(`
1
+ import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{execSync as _}from"child_process";import{mkdirSync as C,readFileSync as E,writeFileSync as I}from"fs";import T from"https";import{homedir as g}from"os";import{join as h}from"path";var u="2.17.0";var b=h(g(),".tigris","update-check.json");function y(){try{let t=E(b,"utf-8"),i=JSON.parse(t);return typeof i.latestVersion=="string"&&typeof i.lastChecked=="number"?i:null}catch{return null}}function v(t){try{C(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(t),"utf-8")}catch{}}function N(t,i){let a=n=>{let s=n.startsWith("v")?n.slice(1):n,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(t),e=a(i);return!r||!e?!1:e.major>r.major?!0:e.major<r.major?!1:e.minor>r.minor?!0:e.minor<r.minor?!1:e.patch>r.patch?!0:e.patch<r.patch?!1:r.prerelease&&!e.prerelease?!0:(!r.prerelease&&e.prerelease,!1)}function x(){if(process.platform==="win32")return!1;try{return _("brew list tigris",{stdio:"ignore"}),!0}catch{return!1}}function O(){let t=globalThis.__TIGRIS_BINARY===!0,i=process.platform==="win32";return t?x()?"brew upgrade tigris":i?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function j(t={}){return new Promise((i,a)=>{let r=T.get(m,{timeout:1e4},e=>{let n="";e.on("data",s=>{n+=s}),e.on("end",()=>{try{let s=JSON.parse(n);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),i(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",e=>{a(e)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),t.unref&&r.on("socket",e=>{e.unref()}),r.end()})}function k(){j({unref:!0}).catch(()=>{})}function P(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let t=y(),i=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(t&&N(u,t.latestVersion)&&(!t.lastNotified||Date.now()-t.lastNotified>i)){let r=`Update available: ${u} \u2192 ${t.latestVersion}`,e='Run "tigris update" to upgrade.',n=Math.max(r.length,e.length)+4,s="\u250C"+"\u2500".repeat(n-2)+"\u2510",l="\u2514"+"\u2500".repeat(n-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(n-4)+" \u2502";console.log(`
2
2
  ${s}
3
3
  ${o("")}
4
4
  ${o(r)}
@@ -1,2 +1,2 @@
1
- import{a as o,c as a}from"./chunk-ALJKYIQL.js";import{b as i}from"./chunk-VAVMX5DC.js";import{c as r}from"./chunk-KK7FZ7QM.js";import{i as n,p as s}from"./chunk-OHGCOC5Q.js";async function d(e){s()!=="oauth"&&i(e,`This operation requires OAuth login.
1
+ import{a as o,c as a}from"./chunk-YOKGP6YU.js";import{b as i}from"./chunk-VAVMX5DC.js";import{c as r}from"./chunk-KK7FZ7QM.js";import{i as n,p as s}from"./chunk-OHGCOC5Q.js";async function d(e){s()!=="oauth"&&i(e,`This operation requires OAuth login.
2
2
  Run "tigris login oauth" first.`);let t=r();await t.isAuthenticated()||i(e,'Not authenticated. Run "tigris login oauth" first.');let c=n(),{iamEndpoint:g,mgmtEndpoint:u}=o();return{sessionToken:await t.getAccessToken(),organizationId:c??void 0,iamEndpoint:g,mgmtEndpoint:u}}async function A(e){let t=await a();switch(t.type){case"oauth":return d(e);case"aws-profile":case"credentials":case"environment":case"configured":return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,organizationId:n()??void 0,iamEndpoint:o().iamEndpoint};case"none":i(e,'Not authenticated. Run "tigris login" or "tigris configure" first.')}}export{d as a,A as b};
@@ -1 +1 @@
1
- import{a as K}from"./chunk-S77OAN6Y.js";import{a as w}from"./chunk-ALJKYIQL.js";import{b as S}from"./chunk-YFMOI263.js";import{b as d,d as m}from"./chunk-VAVMX5DC.js";import{b as i,c as n,j as o}from"./chunk-PG746YF3.js";import{a as g}from"./chunk-ATBINUDP.js";import{l as f,n as y,o as p,q as u,s as l}from"./chunk-OHGCOC5Q.js";import C from"enquirer";import{whoami as k}from"@tigrisdata/iam";var{prompt:I}=C,a=o("login","credentials");async function q(e){i(a);let A=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!r){let t=[];s||t.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),r||t.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0}),K("Provide --access-key and --access-secret");let c=await I(t);s=s||c.accessKey,r=r||c.accessSecret}(!s||!r)&&d(a,"Access key and secret are required");let h=f()?.endpoint||g;await y({accessKeyId:s,secretAccessKey:r,endpoint:h}),await p("credentials"),await l();try{let t=w(),{data:c}=await k({config:{accessKeyId:s,secretAccessKey:r,iamEndpoint:t.iamEndpoint}});c?.organizationId&&await u(c.organizationId,"temporary")}catch{}A==="json"&&console.log(JSON.stringify({action:"logged_in"})),n(a),m(a)}export{q as a};
1
+ import{a as K}from"./chunk-S77OAN6Y.js";import{a as w}from"./chunk-YOKGP6YU.js";import{b as S}from"./chunk-YFMOI263.js";import{b as d,d as m}from"./chunk-VAVMX5DC.js";import{b as i,c as n,j as o}from"./chunk-PG746YF3.js";import{a as g}from"./chunk-ATBINUDP.js";import{l as f,n as y,o as p,q as u,s as l}from"./chunk-OHGCOC5Q.js";import C from"enquirer";import{whoami as k}from"@tigrisdata/iam";var{prompt:I}=C,a=o("login","credentials");async function q(e){i(a);let A=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!r){let t=[];s||t.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),r||t.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0}),K("Provide --access-key and --access-secret");let c=await I(t);s=s||c.accessKey,r=r||c.accessSecret}(!s||!r)&&d(a,"Access key and secret are required");let h=f()?.endpoint||g;await y({accessKeyId:s,secretAccessKey:r,endpoint:h}),await p("credentials"),await l();try{let t=w(),{data:c}=await k({config:{accessKeyId:s,secretAccessKey:r,iamEndpoint:t.iamEndpoint}});c?.organizationId&&await u(c.organizationId,"temporary")}catch{}A==="json"&&console.log(JSON.stringify({action:"logged_in"})),n(a),m(a)}export{q as a};
@@ -1 +1 @@
1
- import{a as s,f as l}from"./chunk-YYVLDLPP.js";import{a as i,k as m}from"./chunk-TRRXHLUE.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
1
+ import{a as s,f as l}from"./chunk-4D33BI67.js";import{a as i,k as m}from"./chunk-TRRXHLUE.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-S77OAN6Y.js";import{b as s}from"./chunk-VAVMX5DC.js";import{e as o}from"./chunk-PG746YF3.js";import m from"enquirer";import{listPolicies as f}from"@tigrisdata/iam";var{prompt:p}=m;async function h(a,t,c="Select a policy:"){let{data:e,error:r}=await f({config:a});if(r&&s(t,r),!e.policies||e.policies.length===0){o(t);return}n("Provide the policy ARN as a positional argument");let{selected:l}=await p({type:"select",name:"selected",message:c,choices:e.policies.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});return l}export{h as a};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-AU3RCZHB.js";import"./chunk-YYVLDLPP.js";import"./chunk-TRRXHLUE.js";import"./chunk-VAVMX5DC.js";import"./chunk-DV3LCXRH.js";import"./chunk-PG746YF3.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
2
+ import"./chunk-PNSKHQX4.js";import"./chunk-4D33BI67.js";import"./chunk-TRRXHLUE.js";import"./chunk-VAVMX5DC.js";import"./chunk-DV3LCXRH.js";import"./chunk-PG746YF3.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-AU3RCZHB.js";import"./chunk-YYVLDLPP.js";import"./chunk-TRRXHLUE.js";import"./chunk-VAVMX5DC.js";import"./chunk-DV3LCXRH.js";import"./chunk-PG746YF3.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
1
+ import"./chunk-PNSKHQX4.js";import"./chunk-4D33BI67.js";import"./chunk-TRRXHLUE.js";import"./chunk-VAVMX5DC.js";import"./chunk-DV3LCXRH.js";import"./chunk-PG746YF3.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
@@ -1 +1 @@
1
- import{b as y}from"../../chunk-LVAJB4FR.js";import"../../chunk-ALJKYIQL.js";import{a as s,b as h}from"../../chunk-YFMOI263.js";import{b as n,c as b,d as p}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as f,j as R}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{assignBucketRoles as x,revokeAllBucketRoles as w}from"@tigrisdata/iam";var e=R("access-keys","assign"),N=["Editor","ReadOnly","NamespaceAdmin"];function v(r){return r?Array.isArray(r)?r:[r]:[]}async function O(r){A(e);let g=h(r),i=s(r,["id"]),m=s(r,["admin"]),d=s(r,["revokeRoles","revoke-roles"]),l=v(s(r,["bucket","b"])),t=v(s(r,["role","r"]));i||n(e,"Access key ID is required"),m&&d&&n(e,"Cannot use --admin and --revoke-roles together");let u=await y(e);if(d){let{error:o}=await w(i,{config:u});o&&n(e,o),g==="json"&&console.log(JSON.stringify({action:"revoked",id:i})),f(e);return}let a;if(m)a=[{bucket:"*",role:"NamespaceAdmin"}];else{l.length===0&&n(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),t.length===0&&n(e,"At least one role is required (or use --admin or --revoke-roles)");for(let o of t)N.includes(o)||n(e,`Invalid role "${o}". Valid roles are: ${N.join(", ")}`);t.length===1?a=l.map(o=>({bucket:o,role:t[0]})):t.length===l.length?a=l.map((o,c)=>({bucket:o,role:t[c]})):n(e,`Number of roles (${t.length}) must be 1 or match number of buckets (${l.length})`)}let{error:k}=await x(i,a,{config:u});if(k&&n(e,k),g==="json"){let o=b(e),c={action:"assigned",id:i,assignments:a};o.length>0&&(c.nextActions=o),console.log(JSON.stringify(c))}f(e),p(e)}export{O as default};
1
+ import{b as y}from"../../chunk-7ERBLTNY.js";import"../../chunk-YOKGP6YU.js";import{a as s,b as h}from"../../chunk-YFMOI263.js";import{b as n,c as b,d as p}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as f,j as R}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{assignBucketRoles as x,revokeAllBucketRoles as w}from"@tigrisdata/iam";var e=R("access-keys","assign"),N=["Editor","ReadOnly","NamespaceAdmin"];function v(r){return r?Array.isArray(r)?r:[r]:[]}async function O(r){A(e);let g=h(r),i=s(r,["id"]),m=s(r,["admin"]),d=s(r,["revokeRoles","revoke-roles"]),l=v(s(r,["bucket","b"])),t=v(s(r,["role","r"]));i||n(e,"Access key ID is required"),m&&d&&n(e,"Cannot use --admin and --revoke-roles together");let u=await y(e);if(d){let{error:o}=await w(i,{config:u});o&&n(e,o),g==="json"&&console.log(JSON.stringify({action:"revoked",id:i})),f(e);return}let a;if(m)a=[{bucket:"*",role:"NamespaceAdmin"}];else{l.length===0&&n(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),t.length===0&&n(e,"At least one role is required (or use --admin or --revoke-roles)");for(let o of t)N.includes(o)||n(e,`Invalid role "${o}". Valid roles are: ${N.join(", ")}`);t.length===1?a=l.map(o=>({bucket:o,role:t[0]})):t.length===l.length?a=l.map((o,c)=>({bucket:o,role:t[c]})):n(e,`Number of roles (${t.length}) must be 1 or match number of buckets (${l.length})`)}let{error:k}=await x(i,a,{config:u});if(k&&n(e,k),g==="json"){let o=b(e),c={action:"assigned",id:i,assignments:a};o.length>0&&(c.nextActions=o),console.log(JSON.stringify(c))}f(e),p(e)}export{O as default};
@@ -0,0 +1 @@
1
+ import{b as u}from"../../chunk-7ERBLTNY.js";import{a as d}from"../../chunk-S77OAN6Y.js";import"../../chunk-YOKGP6YU.js";import{a as l,b as h}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as y,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import S from"enquirer";import{attachPolicyToAccessKey as N,listPolicies as R,listPoliciesForAccessKey as q}from"@tigrisdata/iam";var{prompt:k}=S,e=g("access-keys","attach-policy");async function v(s){p(e);let A=h(s),o=l(s,["id"]),r=l(s,["policyArn","policy-arn"]);o||t(e,"Access key ID is required");let c=await u(e);if(!r){d("Use --policy-arn to specify the policy ARN");let[a,n]=await Promise.all([R({config:c}),q(o,{config:c})]);a.error&&t(e,a.error),n.error&&t(e,n.error);let w=new Set(n.data.policies),f=a.data.policies.filter(i=>!w.has(i.name));f.length===0&&t(e,"No unassigned policies available. All policies are already attached to this access key.");let{selected:P}=await k({type:"select",name:"selected",message:"Select a policy to attach:",choices:f.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});r=P}let{error:m}=await N(o,r,{config:c});m&&t(e,m),A==="json"&&console.log(JSON.stringify({action:"attached",id:o,policyArn:r})),y(e)}export{v as default};
@@ -1 +1 @@
1
- import{b as u}from"../../chunk-LVAJB4FR.js";import"../../chunk-ALJKYIQL.js";import{a as d,b as p}from"../../chunk-YFMOI263.js";import{b as o,c as g,d as f}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,j as l}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{createAccessKey as w}from"@tigrisdata/iam";var t=l("access-keys","create");async function x(n){a(t);let A=p(n),c=d(n,["name"]);c||o(t,"Access key name is required");let y=await u(t),{data:e,error:s}=await w(c,{config:y});if(s&&o(t,s),A==="json"){let r=g(t,{name:e.name,id:e.id}),i={action:"created",name:e.name,id:e.id,secret:e.secret};r.length>0&&(i.nextActions=r),console.log(JSON.stringify(i))}else console.log(` Name: ${e.name}`),console.log(` Access Key ID: ${e.id}`),console.log(` Secret Access Key: ${e.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");m(t),f(t,{name:e.name,id:e.id})}export{x as default};
1
+ import{b as u}from"../../chunk-7ERBLTNY.js";import"../../chunk-YOKGP6YU.js";import{a as d,b as p}from"../../chunk-YFMOI263.js";import{b as o,c as g,d as f}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,j as l}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{createAccessKey as w}from"@tigrisdata/iam";var t=l("access-keys","create");async function x(n){a(t);let A=p(n),c=d(n,["name"]);c||o(t,"Access key name is required");let y=await u(t),{data:e,error:s}=await w(c,{config:y});if(s&&o(t,s),A==="json"){let r=g(t,{name:e.name,id:e.id}),i={action:"created",name:e.name,id:e.id,secret:e.secret};r.length>0&&(i.nextActions=r),console.log(JSON.stringify(i))}else console.log(` Name: ${e.name}`),console.log(` Access Key ID: ${e.id}`),console.log(` Secret Access Key: ${e.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");m(t),f(t,{name:e.name,id:e.id})}export{x as default};
@@ -1 +1 @@
1
- import{b as g}from"../../chunk-LVAJB4FR.js";import{a as m,b as a}from"../../chunk-S77OAN6Y.js";import"../../chunk-ALJKYIQL.js";import{a as i,b as d}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as s,j as f}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{removeAccessKey as u}from"@tigrisdata/iam";var e=f("access-keys","delete");async function k(r){n(e);let l=d(r),o=i(r,["id"]),p=i(r,["yes","y","force"]);if(o||t(e,"Access key ID is required"),!p&&(m("Use --yes to skip confirmation"),!await a(`Delete access key '${o}'?`))){console.log("Aborted");return}let y=await g(e),{error:c}=await u(o,{config:y});c&&t(e,c),l==="json"&&console.log(JSON.stringify({action:"deleted",id:o})),s(e)}export{k as default};
1
+ import{b as g}from"../../chunk-7ERBLTNY.js";import{a as m,b as a}from"../../chunk-S77OAN6Y.js";import"../../chunk-YOKGP6YU.js";import{a as i,b as d}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as s,j as f}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{removeAccessKey as u}from"@tigrisdata/iam";var e=f("access-keys","delete");async function k(r){n(e);let l=d(r),o=i(r,["id"]),p=i(r,["yes","y","force"]);if(o||t(e,"Access key ID is required"),!p&&(m("Use --yes to skip confirmation"),!await a(`Delete access key '${o}'?`))){console.log("Aborted");return}let y=await g(e),{error:c}=await u(o,{config:y});c&&t(e,c),l==="json"&&console.log(JSON.stringify({action:"deleted",id:o})),s(e)}export{k as default};
@@ -0,0 +1 @@
1
+ import{b as A}from"../../chunk-7ERBLTNY.js";import{a as m,b as h}from"../../chunk-S77OAN6Y.js";import"../../chunk-YOKGP6YU.js";import{a,b as u}from"../../chunk-YFMOI263.js";import{b as o}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as y,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import N from"enquirer";import{detachPolicyFromAccessKey as $,listPolicies as q,listPoliciesForAccessKey as F}from"@tigrisdata/iam";var{prompt:R}=N,e=g("access-keys","detach-policy");async function I(c){p(e);let w=u(c),t=a(c,["id"]),i=a(c,["policyArn","policy-arn"]),k=a(c,["yes","y","force"]);t||o(e,"Access key ID is required");let n=await A(e);if(!i){m("Use --policy-arn to specify the policy ARN");let[s,l]=await Promise.all([F(t,{config:n}),q({config:n})]);s.error&&o(e,s.error),l.error&&o(e,l.error);let P=new Set(s.data.policies),d=l.data.policies.filter(r=>P.has(r.name));d.length===0&&o(e,"No policies are attached to this access key.");let{selected:S}=await R({type:"select",name:"selected",message:"Select a policy to detach:",choices:d.map(r=>({name:r.resource,message:`${r.name} (${r.resource})`}))});i=S}if(!k&&(m("Use --yes to skip confirmation"),!await h(`Detach policy '${i}' from access key '${t}'?`))){console.log("Aborted");return}let{error:f}=await $(t,i,{config:n});f&&o(e,f),w==="json"&&console.log(JSON.stringify({action:"detached",id:t,policyArn:i})),y(e)}export{I as default};
@@ -1 +1 @@
1
- import{b as m}from"../../chunk-LVAJB4FR.js";import"../../chunk-ALJKYIQL.js";import{a,b as f}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{getAccessKey as u}from"@tigrisdata/iam";var e=g("access-keys","get");async function $(s){c(e);let d=f(s),r=a(s,["id"]);r||t(e,"Access key ID is required");let p=await m(e),{data:o,error:n}=await u(r,{config:p});if(n&&t(e,n),d==="json")console.log(JSON.stringify(o));else if(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 i of o.roles)console.log(` - ${i.bucket}: ${i.role}`)}else console.log(" Roles: None");l(e)}export{$ as default};
1
+ import{b as m}from"../../chunk-7ERBLTNY.js";import"../../chunk-YOKGP6YU.js";import{a,b as f}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{getAccessKey as u}from"@tigrisdata/iam";var e=g("access-keys","get");async function $(s){c(e);let d=f(s),r=a(s,["id"]);r||t(e,"Access key ID is required");let p=await m(e),{data:o,error:n}=await u(r,{config:p});if(n&&t(e,n),d==="json")console.log(JSON.stringify(o));else if(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 i of o.roles)console.log(` - ${i.bucket}: ${i.role}`)}else console.log(" Roles: None");l(e)}export{$ as default};
@@ -0,0 +1 @@
1
+ import{b as P}from"../../chunk-7ERBLTNY.js";import{g as A}from"../../chunk-IRDNZN7R.js";import"../../chunk-YOKGP6YU.js";import{a as y,b as k,c as h}from"../../chunk-YFMOI263.js";import{b as c}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as f,e as g,i as d,j as u}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listPoliciesForAccessKey as E}from"@tigrisdata/iam";var i=u("access-keys","list-policies");async function F(o){m(i);let n=k(o),{limit:r,pageToken:s}=h(o),a=y(o,["id"]);a||c(i,"Access key ID is required");let T=await P(i),{data:t,error:p}=await E(a,{...r!==void 0?{limit:r}:{},...s?{paginationToken:s}:{},config:T});if(p&&c(i,p),!t.policies||t.policies.length===0){g(i);return}let e=t.policies.map(O=>({policy:O})),x=[{key:"policy",header:e.length>1?"Attached Policies":"Attached Policy"}],l=t.paginationToken||void 0,w=A(e,n,"policies","policy",x,{paginationToken:l});console.log(w),n!=="json"&&n!=="xml"&&d(l),f(i,{count:e.length})}export{F as default};
@@ -1 +1 @@
1
- import{b as x}from"../../chunk-LVAJB4FR.js";import{f as K,g as P}from"../../chunk-IRDNZN7R.js";import"../../chunk-ALJKYIQL.js";import{b as h,c as T}from"../../chunk-YFMOI263.js";import{b as l}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as u,e as g,i as k,j as y}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listAccessKeys as O}from"@tigrisdata/iam";var t=y("access-keys","list");async function S(s){f(t);let e=h(s),{limit:i,pageToken:r,isPaginated:c}=T(s),w=await x(t),{data:n,error:m}=await O({...i!==void 0?{limit:i}:{},...r?{paginationToken:r}:{},config:w});if(m&&l(t,m),!n.accessKeys||n.accessKeys.length===0){g(t);return}let o=n.accessKeys.map(a=>({name:a.name,id:a.id,status:a.status,created:a.createdAt})),d=[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}],p=n.paginationToken||void 0,A=c?P(o,e,"keys","key",d,{paginationToken:p}):K(o,e,"keys","key",d);console.log(A),c&&e!=="json"&&e!=="xml"&&k(p),u(t,{count:o.length})}export{S as default};
1
+ import{b as h}from"../../chunk-7ERBLTNY.js";import{g as T}from"../../chunk-IRDNZN7R.js";import"../../chunk-YOKGP6YU.js";import{b as k,c as y}from"../../chunk-YFMOI263.js";import{b as l}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as d,c as p,e as f,i as g,j as u}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listAccessKeys as A}from"@tigrisdata/iam";var t=u("access-keys","list");async function P(a){d(t);let o=k(a),{limit:s,pageToken:i}=y(a),x=await h(t),{data:e,error:r}=await A({...s!==void 0?{limit:s}:{},...i?{paginationToken:i}:{},config:x});if(r&&l(t,r),!e.accessKeys||e.accessKeys.length===0){f(t);return}let c=e.accessKeys.map(n=>({name:n.name,id:n.id,status:n.status,created:n.createdAt})),K=[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}],m=e.paginationToken||void 0,w=T(c,o,"keys","key",K,{paginationToken:m});console.log(w),o!=="json"&&o!=="xml"&&g(m),p(t,{count:c.length})}export{P as default};
@@ -0,0 +1 @@
1
+ import{b as w}from"../../chunk-7ERBLTNY.js";import{a as u,b as y}from"../../chunk-S77OAN6Y.js";import"../../chunk-YOKGP6YU.js";import{a as i,b as p}from"../../chunk-YFMOI263.js";import{b as n,c as g,d as m}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as l,j as d}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{rotateAccessKey as k}from"@tigrisdata/iam";var e=d("access-keys","rotate");async function x(o){f(e);let A=p(o),r=i(o,["id"]),S=i(o,["yes","y","force"]);if(r||n(e,"Access key ID is required"),!S&&(u("Use --yes to skip confirmation"),!await y(`Rotate access key '${r}'? The current secret will be invalidated.`))){console.log("Aborted");return}let h=await w(e),{data:t,error:s}=await k(r,{config:h});if(s&&n(e,s),A==="json"){let c=g(e,{id:t.id}),a={action:"rotated",id:t.id,secret:t.newSecret};c.length>0&&(a.nextActions=c),console.log(JSON.stringify(a))}else console.log(` Access Key ID: ${t.id}`),console.log(` New Secret Access Key: ${t.newSecret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");l(e),m(e,{id:t.id})}export{x as default};
@@ -1 +1 @@
1
- import{a as R,b as O}from"../../chunk-TD2HGNDY.js";import{a as q}from"../../chunk-S77OAN6Y.js";import{d as N}from"../../chunk-ALJKYIQL.js";import{a as t,b as D}from"../../chunk-YFMOI263.js";import{b as r,c as T,d as L}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as C,j as B}from"../../chunk-PG746YF3.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as E}from"@tigrisdata/storage";import j from"enquirer";var{prompt:F}=j,n=B("buckets","create");async function J(e){x(n);let P=D(e),s=t(e,["name"]),b=t(e,["public"])?"public":t(e,["access","a","A"]),h=t(e,["enable-snapshots","s","S"]),S=t(e,["default-tier","t","T"]),l=t(e,["locations","l","L"]),a=t(e,["fork-of","forkOf","fork"]),f=t(e,["source-snapshot","sourceSnapshot","source-snap"]),k=t(e,["region","r","R"]),I=t(e,["consistency","c","C"]);k!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),l===void 0&&(l=k)),I!==void 0&&console.warn("Warning: --consistency is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/");let W=!s,w;if(W){q("Provide --name to skip interactive mode");let c=p("buckets","access","create"),o=g(c),d=o?.findIndex(i=>i.value===c?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(i=>i.value===v?.default),u=await F([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:o||[],initial:d!==void 0&&d>=0?d:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,b=u.access,S=u.defaultTier,h=u.enableSnapshots;try{w=await R()}catch(i){r(n,i)}}s||r(n,"Bucket name is required"),f&&!a&&r(n,"--source-snapshot requires --fork-of");let{error:y}=await E(s,{defaultTier:S??"STANDARD",enableSnapshot:h===!0,access:b??"private",locations:w??O(l??"global"),...a?{sourceBucketName:a}:{},...f?{sourceBucketSnapshot:f}:{},config:await N()});if(y&&r(n,y),P==="json"){let c=T(n,{name:s}),o={action:"created",name:s,...a?{forkOf:a}:{}};c.length>0&&(o.nextActions=c),console.log(JSON.stringify(o))}C(n,{name:s}),L(n,{name:s})}export{J as default};
1
+ import{a as R,b as O}from"../../chunk-TD2HGNDY.js";import{a as q}from"../../chunk-S77OAN6Y.js";import{d as N}from"../../chunk-YOKGP6YU.js";import{a as t,b as D}from"../../chunk-YFMOI263.js";import{b as r,c as T,d as L}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as C,j as B}from"../../chunk-PG746YF3.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as E}from"@tigrisdata/storage";import j from"enquirer";var{prompt:F}=j,n=B("buckets","create");async function J(e){x(n);let P=D(e),s=t(e,["name"]),b=t(e,["public"])?"public":t(e,["access","a","A"]),h=t(e,["enable-snapshots","s","S"]),S=t(e,["default-tier","t","T"]),l=t(e,["locations","l","L"]),a=t(e,["fork-of","forkOf","fork"]),f=t(e,["source-snapshot","sourceSnapshot","source-snap"]),k=t(e,["region","r","R"]),I=t(e,["consistency","c","C"]);k!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),l===void 0&&(l=k)),I!==void 0&&console.warn("Warning: --consistency is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/");let W=!s,w;if(W){q("Provide --name to skip interactive mode");let c=p("buckets","access","create"),o=g(c),d=o?.findIndex(i=>i.value===c?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(i=>i.value===v?.default),u=await F([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:o||[],initial:d!==void 0&&d>=0?d:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,b=u.access,S=u.defaultTier,h=u.enableSnapshots;try{w=await R()}catch(i){r(n,i)}}s||r(n,"Bucket name is required"),f&&!a&&r(n,"--source-snapshot requires --fork-of");let{error:y}=await E(s,{defaultTier:S??"STANDARD",enableSnapshot:h===!0,access:b??"private",locations:w??O(l??"global"),...a?{sourceBucketName:a}:{},...f?{sourceBucketSnapshot:f}:{},config:await N()});if(y&&r(n,y),P==="json"){let c=T(n,{name:s}),o={action:"created",name:s,...a?{forkOf:a}:{}};c.length>0&&(o.nextActions=c),console.log(JSON.stringify(o))}C(n,{name:s}),L(n,{name:s})}export{J as default};
@@ -1 +1 @@
1
- import{a as x,b as y}from"../../chunk-S77OAN6Y.js";import{d as b}from"../../chunk-ALJKYIQL.js";import{a as s,b as A}from"../../chunk-YFMOI263.js";import{a as p,b as d,c as k,d as h}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as g,d as u,j as l}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{removeBucket as N}from"@tigrisdata/storage";var e=l("buckets","delete");async function B(i){f(e);let w=A(i),o=s(i,["name"]),c=s(i,["yes","y","force"]);o||d(e,"Bucket name is required");let a=Array.isArray(o)?o:[o],S=await b();if(!c&&(x("Use --yes to skip confirmation"),!await y(`Delete ${a.length} bucket(s)?`))){console.log("Aborted");return}let m=[],n=[];for(let t of a){let{error:r}=await N(t,{config:S,force:c});r?(u(e,r.message,{name:t}),n.push({name:t,error:r.message})):(m.push(t),g(e,{name:t}))}if(w==="json"){let t=k(e),r={action:"deleted",names:m,errors:n};t.length>0&&(r.nextActions=t),console.log(JSON.stringify(r))}n.length>0&&p(n[0].error,e),h(e)}export{B as default};
1
+ import{a as x,b as y}from"../../chunk-S77OAN6Y.js";import{d as b}from"../../chunk-YOKGP6YU.js";import{a as s,b as A}from"../../chunk-YFMOI263.js";import{a as p,b as d,c as k,d as h}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as g,d as u,j as l}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{removeBucket as N}from"@tigrisdata/storage";var e=l("buckets","delete");async function B(i){f(e);let w=A(i),o=s(i,["name"]),c=s(i,["yes","y","force"]);o||d(e,"Bucket name is required");let a=Array.isArray(o)?o:[o],S=await b();if(!c&&(x("Use --yes to skip confirmation"),!await y(`Delete ${a.length} bucket(s)?`))){console.log("Aborted");return}let m=[],n=[];for(let t of a){let{error:r}=await N(t,{config:S,force:c});r?(u(e,r.message,{name:t}),n.push({name:t,error:r.message})):(m.push(t),g(e,{name:t}))}if(w==="json"){let t=k(e),r={action:"deleted",names:m,errors:n};t.length>0&&(r.nextActions=t),console.log(JSON.stringify(r))}n.length>0&&p(n[0].error,e),h(e)}export{B as default};
@@ -1 +1 @@
1
- import{a as s}from"../../chunk-4ZHCF5D6.js";import{f as u}from"../../chunk-IRDNZN7R.js";import{d as f}from"../../chunk-ALJKYIQL.js";import{a as p,b as c}from"../../chunk-YFMOI263.js";import{b as o}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h}from"@tigrisdata/storage";var t=m("buckets","get");async function w(e){a(t);let r=p(e,["name"]),g=c(e);r||o(t,"Bucket name is required");let{data:k,error:n}=await h(r,{config:await f()});n&&o(t,n);let l=[{property:"Name",value:r},...s(k).map(({label:d,value:b})=>({property:d,value:b}))],y=u(l,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(y),i(t)}export{w as default};
1
+ import{a as s}from"../../chunk-4ZHCF5D6.js";import{f as u}from"../../chunk-IRDNZN7R.js";import{d as f}from"../../chunk-YOKGP6YU.js";import{a as p,b as c}from"../../chunk-YFMOI263.js";import{b as o}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h}from"@tigrisdata/storage";var t=m("buckets","get");async function w(e){a(t);let r=p(e,["name"]),g=c(e);r||o(t,"Bucket name is required");let{data:k,error:n}=await h(r,{config:await f()});n&&o(t,n);let l=[{property:"Name",value:r},...s(k).map(({label:d,value:b})=>({property:d,value:b}))],y=u(l,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(y),i(t)}export{w as default};
@@ -1 +1 @@
1
- import{f as d,g as E}from"../../chunk-IRDNZN7R.js";import{d as D}from"../../chunk-ALJKYIQL.js";import{a as x,b as B,c as C}from"../../chunk-YFMOI263.js";import{b as g}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as O,c as k,e as s,i as P,j as T}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as N,listBuckets as j}from"@tigrisdata/storage";var t=T("buckets","list");async function A(f){O(t);let n=B(f),e=x(f,["forks-of","forksOf"]),{limit:p,pageToken:l,isPaginated:r}=C(f),u=await D();e&&r&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)");let{data:o,error:h}=await j({...e||!r?{}:{...p!==void 0?{limit:p}:{},...l?{paginationToken:l}:{}},config:u});if(h&&g(t,h),!o.buckets||o.buckets.length===0){s(t);return}if(e){let{data:a,error:y}=await N(e,{config:u});if(y&&g(t,y),!a.hasForks){s(t);return}let i=[];for(let c of o.buckets){if(c.name===e)continue;let{data:I}=await N(c.name,{config:u});I?.sourceBucketName===e&&i.push({name:c.name,created:c.creationDate})}if(i.length===0){s(t);return}let F=d(i,n,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(F),k(t,{count:i.length});return}let m=o.buckets.map(a=>({name:a.name,created:a.creationDate})),b=[{key:"name",header:"Name"},{key:"created",header:"Created"}],w=o.paginationToken||void 0,S=r?E(m,n,"buckets","bucket",b,{paginationToken:w}):d(m,n,"buckets","bucket",b);console.log(S),r&&n!=="json"&&n!=="xml"&&P(w),k(t,{count:m.length})}export{A as default};
1
+ import{f as x,g as I}from"../../chunk-IRDNZN7R.js";import{d as T}from"../../chunk-YOKGP6YU.js";import{a as y,b as C,c as P}from"../../chunk-YFMOI263.js";import{b as m}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b,c as u,e as s,i as O,j as w}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as D,listBuckets as F}from"@tigrisdata/storage";var t=w("buckets","list");async function H(f){b(t);let o=C(f),e=y(f,["forks-of","forksOf"]),{limit:k,pageToken:g,isPaginated:E}=P(f),c=await T();e&&E&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)");let{data:n,error:d}=await F({...e?{}:{...k!==void 0?{limit:k}:{},...g?{paginationToken:g}:{}},config:c});if(d&&m(t,d),!n.buckets||n.buckets.length===0){s(t);return}if(e){let{data:r,error:h}=await D(e,{config:c});if(h&&m(t,h),!r.forkInfo?.hasChildren){s(t);return}let a=[];for(let i of n.buckets){if(i.name===e)continue;let{data:j}=await D(i.name,{config:c});j?.forkInfo?.parents?.some(A=>A.bucketName===e)&&a.push({name:i.name,created:i.creationDate})}if(a.length===0){s(t);return}let B=x(a,o,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(B),u(t,{count:a.length});return}let l=n.buckets.map(r=>({name:r.name,created:r.creationDate})),N=[{key:"name",header:"Name"},{key:"created",header:"Created"}],p=n.paginationToken||void 0,S=I(l,o,"buckets","bucket",N,{paginationToken:p});console.log(S),o!=="json"&&o!=="xml"&&O(p),u(t,{count:l.length})}export{H as default};
@@ -1 +1 @@
1
- import{e as b}from"../../chunk-ALJKYIQL.js";import{a as r,b as x}from"../../chunk-YFMOI263.js";import{b as i}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as h}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=h("buckets","set-cors");async function k(e){c(n);let p=x(e),o=r(e,["name"]),s=r(e,["origins"]),d=r(e,["methods"]),a=r(e,["headers"]),f=r(e,["expose-headers","exposeHeaders"]),t=r(e,["max-age","maxAge"]),g=r(e,["override"]),m=r(e,["reset"]);o||i(n,"Bucket name is required"),m&&(s!==void 0||d!==void 0||a!==void 0||f!==void 0||t!==void 0||g)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await b(),{error:u}=await N(o,{rules:m?[]:[{allowedOrigins:s,...d!==void 0?{allowedMethods:d}:{},...a!==void 0?{allowedHeaders:a}:{},...f!==void 0?{exposeHeaders:f}:{},maxAge:t!==void 0?Number(t):3600}],override:g??!1,config:w});u&&i(n,u),p==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(n,{name:o})}export{k as default};
1
+ import{e as b}from"../../chunk-YOKGP6YU.js";import{a as r,b as x}from"../../chunk-YFMOI263.js";import{b as i}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as h}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=h("buckets","set-cors");async function k(e){c(n);let p=x(e),o=r(e,["name"]),s=r(e,["origins"]),d=r(e,["methods"]),a=r(e,["headers"]),f=r(e,["expose-headers","exposeHeaders"]),t=r(e,["max-age","maxAge"]),g=r(e,["override"]),m=r(e,["reset"]);o||i(n,"Bucket name is required"),m&&(s!==void 0||d!==void 0||a!==void 0||f!==void 0||t!==void 0||g)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await b(),{error:u}=await N(o,{rules:m?[]:[{allowedOrigins:s,...d!==void 0?{allowedMethods:d}:{},...a!==void 0?{allowedHeaders:a}:{},...f!==void 0?{exposeHeaders:f}:{},maxAge:t!==void 0?Number(t):3600}],override:g??!1,config:w});u&&i(n,u),p==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(n,{name:o})}export{k as default};
@@ -1 +1 @@
1
- import{a as l,b as d}from"../../chunk-TD2HGNDY.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-ALJKYIQL.js";import{a as e,b as p}from"../../chunk-YFMOI263.js";import{b as i}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as y}from"@tigrisdata/storage";var t=m("buckets","set-locations");async function B(r){s(t);let k=p(r),o=e(r,["name"]),a=e(r,["locations"]);o||i(t,"Bucket name is required");let n;if(a!==void 0)n=d(a);else{g("Provide --locations flag");try{n=await l()}catch(w){i(t,w)}}let L=await u(),{error:c}=await y(o,{locations:n,config:L});c&&i(t,c),k==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),f(t,{name:o})}export{B as default};
1
+ import{a as l,b as d}from"../../chunk-TD2HGNDY.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-YOKGP6YU.js";import{a as e,b as p}from"../../chunk-YFMOI263.js";import{b as i}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as y}from"@tigrisdata/storage";var t=m("buckets","set-locations");async function B(r){s(t);let k=p(r),o=e(r,["name"]),a=e(r,["locations"]);o||i(t,"Bucket name is required");let n;if(a!==void 0)n=d(a);else{g("Provide --locations flag");try{n=await l()}catch(w){i(t,w)}}let L=await u(),{error:c}=await y(o,{locations:n,config:L});c&&i(t,c),k==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),f(t,{name:o})}export{B as default};
@@ -1 +1 @@
1
- import{e as p}from"../../chunk-ALJKYIQL.js";import{a as t,b as w}from"../../chunk-YFMOI263.js";import{b as r}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketMigration as S}from"@tigrisdata/storage";var n=y("buckets","set-migration");async function K(e){h(n);let d=w(e),i=t(e,["name"]),o=t(e,["bucket"]),a=t(e,["endpoint"]),s=t(e,["region"]),c=t(e,["access-key","accessKey"]),g=t(e,["secret-key","secretKey"]),u=t(e,["write-through","writeThrough"]),m=t(e,["disable"]);i||r(n,"Bucket name is required"),m&&(o!==void 0||a!==void 0||s!==void 0||c!==void 0||g!==void 0||u!==void 0)&&r(n,"Cannot use --disable with other migration options");let l=await p();if(m){let{error:k}=await S(i,{dataMigration:{enabled:!1},config:l});k&&r(n,k),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i});return}(!o||!a||!s||!c||!g)&&r(n,"Required: --bucket, --endpoint, --region, --access-key, --secret-key");let{error:b}=await S(i,{dataMigration:{enabled:!0,accessKey:c,secretKey:g,region:s,name:o,endpoint:a,writeThrough:u??!1},config:l});b&&r(n,b),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i})}export{K as default};
1
+ import{e as p}from"../../chunk-YOKGP6YU.js";import{a as t,b as w}from"../../chunk-YFMOI263.js";import{b as r}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketMigration as S}from"@tigrisdata/storage";var n=y("buckets","set-migration");async function K(e){h(n);let d=w(e),i=t(e,["name"]),o=t(e,["bucket"]),a=t(e,["endpoint"]),s=t(e,["region"]),c=t(e,["access-key","accessKey"]),g=t(e,["secret-key","secretKey"]),u=t(e,["write-through","writeThrough"]),m=t(e,["disable"]);i||r(n,"Bucket name is required"),m&&(o!==void 0||a!==void 0||s!==void 0||c!==void 0||g!==void 0||u!==void 0)&&r(n,"Cannot use --disable with other migration options");let l=await p();if(m){let{error:k}=await S(i,{dataMigration:{enabled:!1},config:l});k&&r(n,k),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i});return}(!o||!a||!s||!c||!g)&&r(n,"Required: --bucket, --endpoint, --region, --access-key, --secret-key");let{error:b}=await S(i,{dataMigration:{enabled:!0,accessKey:c,secretKey:g,region:s,name:o,endpoint:a,writeThrough:u??!1},config:l});b&&r(n,b),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i})}export{K as default};
@@ -1 +1 @@
1
- import{e as p}from"../../chunk-ALJKYIQL.js";import{a as n,b as w}from"../../chunk-YFMOI263.js";import{b as i}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketNotifications as N}from"@tigrisdata/storage";var t=k("buckets","set-notifications");async function y(e){b(t);let C=w(e),d=n(e,["name"]),s=n(e,["url"]),u=n(e,["filter"]),a=n(e,["token"]),o=n(e,["username"]),r=n(e,["password"]),l=n(e,["enable"]),g=n(e,["disable"]),c=n(e,["reset"]);d||i(t,"Bucket name is required"),[l,g,c].filter(Boolean).length>1&&i(t,"Only one of --enable, --disable, or --reset can be used"),c&&(s!==void 0||u!==void 0||a!==void 0||o!==void 0||r!==void 0)&&i(t,"Cannot use --reset with other options"),!l&&!g&&!c&&s===void 0&&u===void 0&&a===void 0&&o===void 0&&r===void 0&&i(t,"Provide at least one option"),a&&(o!==void 0||r!==void 0)&&i(t,"Cannot use --token with --username/--password. Choose one auth method"),(o!==void 0&&r===void 0||o===void 0&&r!==void 0)&&i(t,"Both --username and --password are required");let B=await p(),f;c?f={}:(f={...l?{enabled:!0}:{},...g?{enabled:!1}:{},...s!==void 0?{url:s}:{},...u!==void 0?{filter:u}:{}},a?f={...f,auth:{token:a}}:o&&r&&(f={...f,auth:{username:o,password:r}}));let{error:m}=await N(d,{notificationConfig:f,config:B});m&&i(t,m),C==="json"&&console.log(JSON.stringify({action:"updated",bucket:d})),h(t,{name:d})}export{y as default};
1
+ import{e as p}from"../../chunk-YOKGP6YU.js";import{a as n,b as w}from"../../chunk-YFMOI263.js";import{b as i}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketNotifications as N}from"@tigrisdata/storage";var t=k("buckets","set-notifications");async function y(e){b(t);let C=w(e),d=n(e,["name"]),s=n(e,["url"]),u=n(e,["filter"]),a=n(e,["token"]),o=n(e,["username"]),r=n(e,["password"]),l=n(e,["enable"]),g=n(e,["disable"]),c=n(e,["reset"]);d||i(t,"Bucket name is required"),[l,g,c].filter(Boolean).length>1&&i(t,"Only one of --enable, --disable, or --reset can be used"),c&&(s!==void 0||u!==void 0||a!==void 0||o!==void 0||r!==void 0)&&i(t,"Cannot use --reset with other options"),!l&&!g&&!c&&s===void 0&&u===void 0&&a===void 0&&o===void 0&&r===void 0&&i(t,"Provide at least one option"),a&&(o!==void 0||r!==void 0)&&i(t,"Cannot use --token with --username/--password. Choose one auth method"),(o!==void 0&&r===void 0||o===void 0&&r!==void 0)&&i(t,"Both --username and --password are required");let B=await p(),f;c?f={}:(f={...l?{enabled:!0}:{},...g?{enabled:!1}:{},...s!==void 0?{url:s}:{},...u!==void 0?{filter:u}:{}},a?f={...f,auth:{token:a}}:o&&r&&(f={...f,auth:{username:o,password:r}}));let{error:m}=await N(d,{notificationConfig:f,config:B});m&&i(t,m),C==="json"&&console.log(JSON.stringify({action:"updated",bucket:d})),h(t,{name:d})}export{y as default};
@@ -1 +1 @@
1
- import{e as b}from"../../chunk-ALJKYIQL.js";import{a as i,b as m}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as l,c as u,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketLifecycle as S}from"@tigrisdata/storage";var e=g("buckets","set-transition"),y=["STANDARD_IA","GLACIER","GLACIER_IR"];async function A(a){l(e);let N=m(a),d=i(a,["name"]),r=i(a,["storage-class","storageClass"]),s=i(a,["days"]),n=i(a,["date"]),f=i(a,["enable"]),o=i(a,["disable"]);d||t(e,"Bucket name is required"),f&&o&&t(e,"Cannot use both --enable and --disable"),o&&(s!==void 0||n!==void 0||r!==void 0)&&t(e,"Cannot use --disable with --days, --date, or --storage-class"),!f&&!o&&s===void 0&&n===void 0&&t(e,"Provide --days, --date, --enable, or --disable"),(s!==void 0||n!==void 0)&&!r&&t(e,"--storage-class is required when setting --days or --date"),r&&!y.includes(r)&&t(e,`--storage-class must be one of: ${y.join(", ")} (STANDARD is not a valid transition target)`),s!==void 0&&(isNaN(Number(s))||Number(s)<=0)&&t(e,"--days must be a positive number"),n!==void 0&&(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}/.test(n)||isNaN(new Date(n).getTime()))&&t(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)");let C=await b(),R={...f?{enabled:!0}:{},...o?{enabled:!1}:{},...r?{storageClass:r}:{},...s!==void 0?{days:Number(s)}:{},...n!==void 0?{date:n}:{}},{error:c}=await S(d,{lifecycleRules:[R],config:C});c&&t(e,c),N==="json"&&console.log(JSON.stringify({action:"updated",bucket:d})),u(e,{name:d})}export{A as default};
1
+ import{e as b}from"../../chunk-YOKGP6YU.js";import{a as i,b as m}from"../../chunk-YFMOI263.js";import{b as t}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as l,c as u,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketLifecycle as S}from"@tigrisdata/storage";var e=g("buckets","set-transition"),y=["STANDARD_IA","GLACIER","GLACIER_IR"];async function A(a){l(e);let N=m(a),d=i(a,["name"]),r=i(a,["storage-class","storageClass"]),s=i(a,["days"]),n=i(a,["date"]),f=i(a,["enable"]),o=i(a,["disable"]);d||t(e,"Bucket name is required"),f&&o&&t(e,"Cannot use both --enable and --disable"),o&&(s!==void 0||n!==void 0||r!==void 0)&&t(e,"Cannot use --disable with --days, --date, or --storage-class"),!f&&!o&&s===void 0&&n===void 0&&t(e,"Provide --days, --date, --enable, or --disable"),(s!==void 0||n!==void 0)&&!r&&t(e,"--storage-class is required when setting --days or --date"),r&&!y.includes(r)&&t(e,`--storage-class must be one of: ${y.join(", ")} (STANDARD is not a valid transition target)`),s!==void 0&&(isNaN(Number(s))||Number(s)<=0)&&t(e,"--days must be a positive number"),n!==void 0&&(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}/.test(n)||isNaN(new Date(n).getTime()))&&t(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)");let C=await b(),R={...f?{enabled:!0}:{},...o?{enabled:!1}:{},...r?{storageClass:r}:{},...s!==void 0?{days:Number(s)}:{},...n!==void 0?{date:n}:{}},{error:c}=await S(d,{lifecycleRules:[R],config:C});c&&t(e,c),N==="json"&&console.log(JSON.stringify({action:"updated",bucket:d})),u(e,{name:d})}export{A as default};
@@ -1 +1 @@
1
- import{e as b}from"../../chunk-ALJKYIQL.js";import{a as d,b as m}from"../../chunk-YFMOI263.js";import{b as n}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as l,j as c}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketTtl as p}from"@tigrisdata/storage";var e=c("buckets","set-ttl");async function k(a){u(e);let g=m(a),o=d(a,["name"]),i=d(a,["days"]),t=d(a,["date"]),r=d(a,["enable"]),s=d(a,["disable"]);o||n(e,"Bucket name is required"),r&&s&&n(e,"Cannot use both --enable and --disable"),s&&(i!==void 0||t!==void 0)&&n(e,"Cannot use --disable with --days or --date"),!r&&!s&&i===void 0&&t===void 0&&n(e,"Provide --days, --date, --enable, or --disable"),i!==void 0&&(isNaN(Number(i))||Number(i)<=0)&&n(e,"--days must be a positive number"),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&n(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)");let y=await b(),N={...r?{enabled:!0}:{},...s?{enabled:!1}:{},...i!==void 0?{days:Number(i)}:{},...t!==void 0?{date:t}:{}},{error:f}=await p(o,{ttlConfig:N,config:y});f&&n(e,f),g==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(e,{name:o})}export{k as default};
1
+ import{e as b}from"../../chunk-YOKGP6YU.js";import{a as d,b as m}from"../../chunk-YFMOI263.js";import{b as n}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as l,j as c}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketTtl as p}from"@tigrisdata/storage";var e=c("buckets","set-ttl");async function k(a){u(e);let g=m(a),o=d(a,["name"]),i=d(a,["days"]),t=d(a,["date"]),r=d(a,["enable"]),s=d(a,["disable"]);o||n(e,"Bucket name is required"),r&&s&&n(e,"Cannot use both --enable and --disable"),s&&(i!==void 0||t!==void 0)&&n(e,"Cannot use --disable with --days or --date"),!r&&!s&&i===void 0&&t===void 0&&n(e,"Provide --days, --date, --enable, or --disable"),i!==void 0&&(isNaN(Number(i))||Number(i)<=0)&&n(e,"--days must be a positive number"),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&n(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)");let y=await b(),N={...r?{enabled:!0}:{},...s?{enabled:!1}:{},...i!==void 0?{days:Number(i)}:{},...t!==void 0?{date:t}:{}},{error:f}=await p(o,{ttlConfig:N,config:y});f&&n(e,f),g==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(e,{name:o})}export{k as default};
@@ -1 +1 @@
1
- import{b as y}from"../../chunk-TD2HGNDY.js";import"../../chunk-S77OAN6Y.js";import{e as k}from"../../chunk-ALJKYIQL.js";import{a as n,b as h,d as o}from"../../chunk-YFMOI263.js";import{b as r}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as D,j as O}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as B}from"@tigrisdata/storage";var a=O("buckets","set");async function C(e){w(a);let A=h(e),c=n(e,["name"]),s=n(e,["access"]),i=n(e,["locations"]),b=n(e,["region"]);b!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),i===void 0&&(i=b));let d=n(e,["allow-object-acl","allowObjectAcl"]),l=n(e,["disable-directory-listing","disableDirectoryListing"]),f=n(e,["cache-control","cacheControl"]),u=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),m=n(e,["enable-additional-headers","enableAdditionalHeaders"]);c||r(a,"Bucket name is required"),s===void 0&&i===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&r(a,"At least one setting is required");let t={};s!==void 0&&(t.access=s),i!==void 0&&(t.locations=y(i)),d!==void 0&&(t.allowObjectAcl=o(d)),l!==void 0&&(t.disableDirectoryListing=o(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=o(g)),m!==void 0&&(t.enableAdditionalHeaders=o(m));let j=await k(),{error:p}=await B(c,{...t,config:j});p&&r(a,p),A==="json"&&console.log(JSON.stringify({action:"updated",name:c})),D(a,{name:c})}export{C as default};
1
+ import{b as y}from"../../chunk-TD2HGNDY.js";import"../../chunk-S77OAN6Y.js";import{e as k}from"../../chunk-YOKGP6YU.js";import{a as n,b as h,d as o}from"../../chunk-YFMOI263.js";import{b as r}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as D,j as O}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as B}from"@tigrisdata/storage";var a=O("buckets","set");async function C(e){w(a);let A=h(e),c=n(e,["name"]),s=n(e,["access"]),i=n(e,["locations"]),b=n(e,["region"]);b!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),i===void 0&&(i=b));let d=n(e,["allow-object-acl","allowObjectAcl"]),l=n(e,["disable-directory-listing","disableDirectoryListing"]),f=n(e,["cache-control","cacheControl"]),u=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),m=n(e,["enable-additional-headers","enableAdditionalHeaders"]);c||r(a,"Bucket name is required"),s===void 0&&i===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&r(a,"At least one setting is required");let t={};s!==void 0&&(t.access=s),i!==void 0&&(t.locations=y(i)),d!==void 0&&(t.allowObjectAcl=o(d)),l!==void 0&&(t.disableDirectoryListing=o(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=o(g)),m!==void 0&&(t.enableAdditionalHeaders=o(m));let j=await k(),{error:p}=await B(c,{...t,config:j});p&&r(a,p),A==="json"&&console.log(JSON.stringify({action:"updated",name:c})),D(a,{name:c})}export{C as default};
@@ -1 +1 @@
1
- import{a as K}from"../../chunk-S77OAN6Y.js";import{a as E}from"../../chunk-ALJKYIQL.js";import{b as S}from"../../chunk-YFMOI263.js";import{a as m,b as f,d as p}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import{a as u}from"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import{m as y,q as l}from"../../chunk-OHGCOC5Q.js";import A from"enquirer";import{whoami as w}from"@tigrisdata/iam";var{prompt:q}=A,a=g("configure");async function I(e){n(a);let h=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,t=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,c=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!t||!c){let r=[];s||r.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),t||r.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),c||r.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:u}),K("Provide --access-key, --access-secret, and --endpoint");let i=await q(r);s=s||i.accessKey,t=t||i.accessSecret,c=c||i.endpoint}(!s||!t||!c)&&f(a,"All credentials are required");try{await y({accessKeyId:s,secretAccessKey:t,endpoint:c});try{let r=E(),{data:i}=await w({config:{accessKeyId:s,secretAccessKey:t,iamEndpoint:r.iamEndpoint}});i?.organizationId&&await l(i.organizationId,"saved")}catch{}h==="json"&&console.log(JSON.stringify({action:"configured"})),o(a),p(a)}catch(r){d(a,"Failed to save credentials"),m(r,a)}}export{I as default};
1
+ import{a as K}from"../../chunk-S77OAN6Y.js";import{a as E}from"../../chunk-YOKGP6YU.js";import{b as S}from"../../chunk-YFMOI263.js";import{a as m,b as f,d as p}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import{a as u}from"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import{m as y,q as l}from"../../chunk-OHGCOC5Q.js";import A from"enquirer";import{whoami as w}from"@tigrisdata/iam";var{prompt:q}=A,a=g("configure");async function I(e){n(a);let h=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,t=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,c=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!t||!c){let r=[];s||r.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),t||r.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),c||r.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:u}),K("Provide --access-key, --access-secret, and --endpoint");let i=await q(r);s=s||i.accessKey,t=t||i.accessSecret,c=c||i.endpoint}(!s||!t||!c)&&f(a,"All credentials are required");try{await y({accessKeyId:s,secretAccessKey:t,endpoint:c});try{let r=E(),{data:i}=await w({config:{accessKeyId:s,secretAccessKey:t,iamEndpoint:r.iamEndpoint}});i?.organizationId&&await l(i.organizationId,"saved")}catch{}h==="json"&&console.log(JSON.stringify({action:"configured"})),o(a),p(a)}catch(r){d(a,"Failed to save credentials"),m(r,a)}}export{I as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as C}from"../chunk-SAAGVLRE.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as T,d as D,g as O,h as J,j}from"../chunk-JQUG732D.js";import{d as G}from"../chunk-ALJKYIQL.js";import{a as x,b as q}from"../chunk-YFMOI263.js";import{a as f}from"../chunk-VAVMX5DC.js";import"../chunk-DV3LCXRH.js";import"../chunk-PG746YF3.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";import{get as V,head as X,list as tt,put as E}from"@tigrisdata/storage";import{createReadStream as et,createWriteStream as ot,existsSync as Y,mkdirSync as it,readdirSync as z,statSync as L}from"fs";import{homedir as nt}from"os";import{basename as M,dirname as K,join as N,relative as _,resolve as H}from"path";import{Readable as Z}from"stream";import{pipeline as rt}from"stream/promises";var h=!1;function at(n,t){let e=U(n),l=U(t);return!e&&!l&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&l?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function P(n){return n==="~"||n.startsWith("~/")?H(nt(),n.slice(2)):H(n)}function lt(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let l=e.parentPath??e.path;return N(l,e.name)})}function ct(n,t){let e=K(n),l=M(n),s=O(l);return Y(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&s.test(r.name)).map(r=>{let o=r.parentPath??r.path;return N(o,r.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>N(e,o.name)):[]}async function I(n,t,e,l,s=!1){let p;try{p=L(n).size}catch{return{error:`File not found: ${n}`}}let r=et(n),o=Z.toWeb(r),{error:i}=await E(e,o,{...B(p),onUploadProgress:s?({loaded:a})=>{if(p!==void 0&&p>0){let c=Math.round(a/p*100);process.stdout.write(`\rUploading: ${w(a)} / ${w(p)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(a)}`)}:void 0,config:{...l,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),i?{error:i.message}:{}}async function Q(n,t,e,l,s=!1){let p;if(s){let{data:u}=await X(t,{config:{...l,bucket:n}});p=u?.size}let{data:r,error:o}=await V(t,"stream",{config:{...l,bucket:n}});if(o)return{error:o.message};let i=K(e);Y(i)||it(i,{recursive:!0});let a=ot(e),c=Z.fromWeb(r);if(s&&p!==void 0&&p>0){let u=0;c.on("data",m=>{u+=m.length;let g=Math.round(u/p*100);process.stdout.write(`\rDownloading: ${w(u)} / ${w(p)} (${g}%)`)})}return await rt(c,a),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,l,s,p=!1){if(e.endsWith("/")){let{error:c}=await E(s,"",{config:{...n,bucket:l}});return c?{error:c.message}:{}}let r;if(p){let{data:c}=await X(e,{config:{...n,bucket:t}});r=c?.size}let{data:o,error:i}=await V(e,"stream",{config:{...n,bucket:t}});if(i)return{error:i.message};let{error:a}=await E(s,o,{...B(r),onUploadProgress:p?({loaded:c})=>{if(r!==void 0&&r>0){let u=Math.round(c/r*100);process.stdout.write(`\rCopying: ${w(c)} / ${w(r)} (${u}%)`)}else process.stdout.write(`\rCopying: ${w(c)}`)}:void 0,config:{...n,bucket:l}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),a?{error:a.message}:{}}async function st(n,t,e,l){let s=P(n);if(n.includes("*")){let o=ct(s,l);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let i=K(s),a=o.map(m=>async()=>{let g=_(i,m),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,$=await I(m,t.bucket,k,e);return $.error?(console.error(`Failed to upload ${m}: ${$.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),u=(await C(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`);return}let r;try{r=L(s)}catch{f(`Source not found: ${n}`)}if(r.isDirectory()){l||f(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=lt(s);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let i=n.endsWith("/")?"":M(s),a=o.map(m=>async()=>{let g=_(s,m),$=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(m,t.bucket,$,e);return R.error?(console.error(`Failed to upload ${m}: ${R.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${$}`),!0)}),u=(await C(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await D(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let a=await I(s,t.bucket,i,e,!h);a.error&&f(a.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:n,dest:`t3://${t.bucket}/${i}`}):`Uploaded ${n} -> t3://${t.bucket}/${i}`)}}async function pt(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=P(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&p;if(!o&&!i&&(i=await D(t.bucket,t.path,l)),i&&!o&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let a=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",c=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:m}=await j(t.bucket,a||void 0,l);m&&f(m);let g=u.filter(y=>!y.name.endsWith("/"));if(o){let y=t.path.split("/").pop(),b=O(y);g=g.filter(S=>{let d=a?S.name.slice(a.length):S.name;return!s&&d.includes("/")?!1:b.test(d.split("/").pop())})}if(g.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let k=g.map(y=>async()=>{let b=a?y.name.slice(a.length):y.name,S=c?N(r,c,b):N(r,b),d=await Q(t.bucket,y.name,S,l);return d.error?(console.error(`Failed to download ${y.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),R=(await C(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let a=t.path.split("/").pop(),c,u=!1;try{u=L(r).isDirectory()}catch{}u||e.endsWith("/")?c=N(r,a):c=r;let m=await Q(t.bucket,t.path,c,l,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:c}):`Downloaded t3://${t.bucket}/${t.path} -> ${c}`)}}async function ut(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=n.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!r&&!o&&t.path&&(o=await D(t.bucket,t.path,l)),o&&!r&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||o){let i=r?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",a=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",a].filter(Boolean).join("/"),m=u?`${u}/`:"";t.bucket===e.bucket&&i===m&&f("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,l);k&&f(k);let $=g.filter(d=>d.name!==i);if(r){let d=t.path.split("/").pop(),W=O(d);$=$.filter(F=>{let v=i?F.name.slice(i.length):F.name;return!s&&v.includes("/")?!1:W.test(v.split("/").pop())})}let R=$.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=u?`${u}/${W}`:W,v=await A(l,t.bucket,d.name,e.bucket,F);return v.error?(console.error(`Failed to copy ${d.name}: ${v.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${d.name} -> t3://${e.bucket}/${F}`),!0)}),b=(await C(R,8)).filter(Boolean).length,S=!1;if(u&&i){let{data:d}=await tt({prefix:i,limit:1,config:{...l,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${u}/`,F=await A(l,t.bucket,i,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let i=t.path.split("/").pop(),a;e.path?e.path.endsWith("/")?a=`${e.path}${i}`:await D(e.bucket,e.path,l)?a=`${e.path}/${i}`:a=e.path:a=i,t.bucket===e.bucket&&t.path===a&&f("Source and destination are the same");let c=await A(l,t.bucket,t.path,e.bucket,a,!h);c.error&&f(c.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${a}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${a}`)}}async function ft(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let l=!!x(n,["recursive","r"]);h=q(n)==="json";let p=at(t,e),r=await G({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=T(e);o.bucket||f("Invalid destination path"),await st(t,o,r,l);break}case"remote-to-local":{let o=T(t);o.bucket||f("Invalid source path"),await pt(t,o,e,r,l);break}case"remote-to-remote":{let o=T(t),i=T(e);o.bucket||f("Invalid source path"),i.bucket||f("Invalid destination path"),await ut(t,o,i,r,l);break}}process.exit(0)}export{ft as default};
1
+ import{a as C}from"../chunk-SAAGVLRE.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as T,d as D,g as O,h as J,j}from"../chunk-JQUG732D.js";import{d as G}from"../chunk-YOKGP6YU.js";import{a as x,b as q}from"../chunk-YFMOI263.js";import{a as f}from"../chunk-VAVMX5DC.js";import"../chunk-DV3LCXRH.js";import"../chunk-PG746YF3.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";import{get as V,head as X,list as tt,put as E}from"@tigrisdata/storage";import{createReadStream as et,createWriteStream as ot,existsSync as Y,mkdirSync as it,readdirSync as z,statSync as L}from"fs";import{homedir as nt}from"os";import{basename as M,dirname as K,join as N,relative as _,resolve as H}from"path";import{Readable as Z}from"stream";import{pipeline as rt}from"stream/promises";var h=!1;function at(n,t){let e=U(n),l=U(t);return!e&&!l&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&l?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function P(n){return n==="~"||n.startsWith("~/")?H(nt(),n.slice(2)):H(n)}function lt(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let l=e.parentPath??e.path;return N(l,e.name)})}function ct(n,t){let e=K(n),l=M(n),s=O(l);return Y(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&s.test(r.name)).map(r=>{let o=r.parentPath??r.path;return N(o,r.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>N(e,o.name)):[]}async function I(n,t,e,l,s=!1){let p;try{p=L(n).size}catch{return{error:`File not found: ${n}`}}let r=et(n),o=Z.toWeb(r),{error:i}=await E(e,o,{...B(p),onUploadProgress:s?({loaded:a})=>{if(p!==void 0&&p>0){let c=Math.round(a/p*100);process.stdout.write(`\rUploading: ${w(a)} / ${w(p)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(a)}`)}:void 0,config:{...l,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),i?{error:i.message}:{}}async function Q(n,t,e,l,s=!1){let p;if(s){let{data:u}=await X(t,{config:{...l,bucket:n}});p=u?.size}let{data:r,error:o}=await V(t,"stream",{config:{...l,bucket:n}});if(o)return{error:o.message};let i=K(e);Y(i)||it(i,{recursive:!0});let a=ot(e),c=Z.fromWeb(r);if(s&&p!==void 0&&p>0){let u=0;c.on("data",m=>{u+=m.length;let g=Math.round(u/p*100);process.stdout.write(`\rDownloading: ${w(u)} / ${w(p)} (${g}%)`)})}return await rt(c,a),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,l,s,p=!1){if(e.endsWith("/")){let{error:c}=await E(s,"",{config:{...n,bucket:l}});return c?{error:c.message}:{}}let r;if(p){let{data:c}=await X(e,{config:{...n,bucket:t}});r=c?.size}let{data:o,error:i}=await V(e,"stream",{config:{...n,bucket:t}});if(i)return{error:i.message};let{error:a}=await E(s,o,{...B(r),onUploadProgress:p?({loaded:c})=>{if(r!==void 0&&r>0){let u=Math.round(c/r*100);process.stdout.write(`\rCopying: ${w(c)} / ${w(r)} (${u}%)`)}else process.stdout.write(`\rCopying: ${w(c)}`)}:void 0,config:{...n,bucket:l}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),a?{error:a.message}:{}}async function st(n,t,e,l){let s=P(n);if(n.includes("*")){let o=ct(s,l);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let i=K(s),a=o.map(m=>async()=>{let g=_(i,m),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,$=await I(m,t.bucket,k,e);return $.error?(console.error(`Failed to upload ${m}: ${$.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),u=(await C(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`);return}let r;try{r=L(s)}catch{f(`Source not found: ${n}`)}if(r.isDirectory()){l||f(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=lt(s);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let i=n.endsWith("/")?"":M(s),a=o.map(m=>async()=>{let g=_(s,m),$=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(m,t.bucket,$,e);return R.error?(console.error(`Failed to upload ${m}: ${R.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${$}`),!0)}),u=(await C(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await D(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let a=await I(s,t.bucket,i,e,!h);a.error&&f(a.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:n,dest:`t3://${t.bucket}/${i}`}):`Uploaded ${n} -> t3://${t.bucket}/${i}`)}}async function pt(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=P(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&p;if(!o&&!i&&(i=await D(t.bucket,t.path,l)),i&&!o&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let a=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",c=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:m}=await j(t.bucket,a||void 0,l);m&&f(m);let g=u.filter(y=>!y.name.endsWith("/"));if(o){let y=t.path.split("/").pop(),b=O(y);g=g.filter(S=>{let d=a?S.name.slice(a.length):S.name;return!s&&d.includes("/")?!1:b.test(d.split("/").pop())})}if(g.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let k=g.map(y=>async()=>{let b=a?y.name.slice(a.length):y.name,S=c?N(r,c,b):N(r,b),d=await Q(t.bucket,y.name,S,l);return d.error?(console.error(`Failed to download ${y.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),R=(await C(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let a=t.path.split("/").pop(),c,u=!1;try{u=L(r).isDirectory()}catch{}u||e.endsWith("/")?c=N(r,a):c=r;let m=await Q(t.bucket,t.path,c,l,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:c}):`Downloaded t3://${t.bucket}/${t.path} -> ${c}`)}}async function ut(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=n.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!r&&!o&&t.path&&(o=await D(t.bucket,t.path,l)),o&&!r&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||o){let i=r?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",a=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",a].filter(Boolean).join("/"),m=u?`${u}/`:"";t.bucket===e.bucket&&i===m&&f("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,l);k&&f(k);let $=g.filter(d=>d.name!==i);if(r){let d=t.path.split("/").pop(),W=O(d);$=$.filter(F=>{let v=i?F.name.slice(i.length):F.name;return!s&&v.includes("/")?!1:W.test(v.split("/").pop())})}let R=$.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=u?`${u}/${W}`:W,v=await A(l,t.bucket,d.name,e.bucket,F);return v.error?(console.error(`Failed to copy ${d.name}: ${v.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${d.name} -> t3://${e.bucket}/${F}`),!0)}),b=(await C(R,8)).filter(Boolean).length,S=!1;if(u&&i){let{data:d}=await tt({prefix:i,limit:1,config:{...l,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${u}/`,F=await A(l,t.bucket,i,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let i=t.path.split("/").pop(),a;e.path?e.path.endsWith("/")?a=`${e.path}${i}`:await D(e.bucket,e.path,l)?a=`${e.path}/${i}`:a=e.path:a=i,t.bucket===e.bucket&&t.path===a&&f("Source and destination are the same");let c=await A(l,t.bucket,t.path,e.bucket,a,!h);c.error&&f(c.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${a}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${a}`)}}async function ft(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let l=!!x(n,["recursive","r"]);h=q(n)==="json";let p=at(t,e),r=await G({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=T(e);o.bucket||f("Invalid destination path"),await st(t,o,r,l);break}case"remote-to-local":{let o=T(t);o.bucket||f("Invalid source path"),await pt(t,o,e,r,l);break}case"remote-to-remote":{let o=T(t),i=T(e);o.bucket||f("Invalid source path"),i.bucket||f("Invalid destination path"),await ut(t,o,i,r,l);break}}process.exit(0)}export{ft as default};
@@ -1 +1 @@
1
- import{e as k}from"../../chunk-ALJKYIQL.js";import{a as d,b as m}from"../../chunk-YFMOI263.js";import{a as s,b as u}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as f,d as r,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{list as p,listBuckets as b}from"@tigrisdata/storage";var t=g("credentials","test");async function h(n){a(t);let c=m(n),e=d(n,["bucket","b"]),i=await k();if(!i.accessKeyId&&!i.sessionToken&&u(t,'No credentials found. Run "tigris configure" or "tigris login" first.'),e){let{error:o}=await p({config:{...i,bucket:e},limit:1});o&&(r(t,`Current credentials don't have access to bucket "${e}"`),s(o,t)),c==="json"?console.log(JSON.stringify({valid:!0,bucket:e})):(console.log(` Bucket: ${e}`),console.log(" Access verified."))}else{let{data:o,error:l}=await b({config:i});l&&(r(t,"Current credentials don't have sufficient access"),s(l,t)),console.log(c==="json"?JSON.stringify({valid:!0,bucketCount:o.buckets.length}):` Access verified. Found ${o.buckets.length} bucket(s).`)}f(t)}export{h as default};
1
+ import{e as k}from"../../chunk-YOKGP6YU.js";import{a as d,b as m}from"../../chunk-YFMOI263.js";import{a as s,b as u}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as f,d as r,j as g}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{list as p,listBuckets as b}from"@tigrisdata/storage";var t=g("credentials","test");async function h(n){a(t);let c=m(n),e=d(n,["bucket","b"]),i=await k();if(!i.accessKeyId&&!i.sessionToken&&u(t,'No credentials found. Run "tigris configure" or "tigris login" first.'),e){let{error:o}=await p({config:{...i,bucket:e},limit:1});o&&(r(t,`Current credentials don't have access to bucket "${e}"`),s(o,t)),c==="json"?console.log(JSON.stringify({valid:!0,bucket:e})):(console.log(` Bucket: ${e}`),console.log(" Access verified."))}else{let{data:o,error:l}=await b({config:i});l&&(r(t,"Current credentials don't have sufficient access"),s(l,t)),console.log(c==="json"?JSON.stringify({valid:!0,bucketCount:o.buckets.length}):` Access verified. Found ${o.buckets.length} bucket(s).`)}f(t)}export{h as default};
@@ -1 +1 @@
1
- import{d as g}from"../../chunk-ALJKYIQL.js";import{a,b as m}from"../../chunk-YFMOI263.js";import{b as n}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as s,j as f}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as p}from"@tigrisdata/storage";var r=f("forks","create");async function S(t){c(r);let u=m(t),o=a(t,["name"]),e=a(t,["fork-name","forkName"]),k=a(t,["snapshot","s","S"]);o||n(r,"Source bucket name is required"),e||n(r,"Fork name is required");let{error:i}=await p(e,{sourceBucketName:o,sourceBucketSnapshot:k,config:await g()});i&&n(r,i),u==="json"&&console.log(JSON.stringify({action:"created",name:e,forkOf:o})),s(r,{name:o,forkName:e})}export{S as default};
1
+ import{d as g}from"../../chunk-YOKGP6YU.js";import{a,b as m}from"../../chunk-YFMOI263.js";import{b as n}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as s,j as f}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as p}from"@tigrisdata/storage";var r=f("forks","create");async function S(t){c(r);let u=m(t),o=a(t,["name"]),e=a(t,["fork-name","forkName"]),k=a(t,["snapshot","s","S"]);o||n(r,"Source bucket name is required"),e||n(r,"Fork name is required");let{error:i}=await p(e,{sourceBucketName:o,sourceBucketSnapshot:k,config:await g()});i&&n(r,i),u==="json"&&console.log(JSON.stringify({action:"created",name:e,forkOf:o})),s(r,{name:o,forkName:e})}export{S as default};
@@ -1 +1 @@
1
- import{f as l}from"../../chunk-IRDNZN7R.js";import{d}from"../../chunk-ALJKYIQL.js";import{a as g,b as p}from"../../chunk-YFMOI263.js";import{b as n}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as u,e as i,j as k}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h,listBuckets as E}from"@tigrisdata/storage";var t=k("forks","list");async function x(c){m(t);let r=g(c,["name"]),w=p(c);r||n(t,"Source bucket name is required");let a=await d(),{data:y,error:f}=await h(r,{config:a});if(f&&n(t,f),!y.hasForks){i(t);return}let{data:b,error:s}=await E({config:a});s&&n(t,s);let e=[];for(let o of b.buckets){if(o.name===r)continue;let{data:B}=await h(o.name,{config:a});B?.sourceBucketName===r&&e.push({name:o.name,created:o.creationDate})}if(e.length===0){i(t);return}let S=l(e,w,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(S),u(t,{count:e.length})}export{x as default};
1
+ import{f as l}from"../../chunk-IRDNZN7R.js";import{d as g}from"../../chunk-YOKGP6YU.js";import{a as d,b as p}from"../../chunk-YFMOI263.js";import{b as n}from"../../chunk-VAVMX5DC.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as u,e as i,j as k}from"../../chunk-PG746YF3.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h,listBuckets as S}from"@tigrisdata/storage";var t=k("forks","list");async function E(f){m(t);let r=d(f,["name"]),b=p(f);r||n(t,"Source bucket name is required");let a=await g(),{data:w,error:c}=await h(r,{config:a});if(c&&n(t,c),!w.forkInfo?.hasChildren){i(t);return}let{data:y,error:s}=await S({config:a});s&&n(t,s);let o=[];for(let e of y.buckets){if(e.name===r)continue;let{data:I}=await h(e.name,{config:a});I?.forkInfo?.parents?.some(O=>O.bucketName===r)&&o.push({name:e.name,created:e.creationDate})}if(o.length===0){i(t);return}let C=l(o,b,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(C),u(t,{count:o.length})}export{E as default};
@@ -1 +1 @@
1
- import{a as g,b as y}from"../../../chunk-Y7MJZRR4.js";import{a as p}from"../../../chunk-LVAJB4FR.js";import"../../../chunk-ALJKYIQL.js";import{a as c,b as u}from"../../../chunk-YFMOI263.js";import{b as t}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as l,j as f}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as h,readFileSync as w}from"fs";import{addPolicy as O}from"@tigrisdata/iam";var e=f("iam policies","create");async function A(o){d(e);let P=u(o),a=c(o,["name"]),i=c(o,["document","d"]),S=c(o,["description"])??"";a||t(e,"Policy name is required"),/^[a-zA-Z0-9=,.@_-]+$/.test(a)||t(e,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed.");let v=await p(e),n;i?h(i)?n=w(i,"utf-8"):n=i:process.stdin.isTTY?t(e,"Policy document is required. Provide via --document or pipe to stdin."):n=await g();let m;try{m=y(n)}catch{t(e,"Invalid JSON in policy document")}let{data:r,error:s}=await O(a,{document:m,description:S,config:v});s&&t(e,s),P==="json"&&console.log(JSON.stringify({action:"created",name:r.name,arn:r.resource})),l(e,{name:r.name}),console.log(`Resource: ${r.resource}`)}export{A as default};
1
+ import{a as g,b as y}from"../../../chunk-Y7MJZRR4.js";import{a as p}from"../../../chunk-7ERBLTNY.js";import"../../../chunk-YOKGP6YU.js";import{a as c,b as u}from"../../../chunk-YFMOI263.js";import{b as t}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as l,j as f}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as h,readFileSync as w}from"fs";import{addPolicy as O}from"@tigrisdata/iam";var e=f("iam policies","create");async function A(o){d(e);let P=u(o),a=c(o,["name"]),i=c(o,["document","d"]),S=c(o,["description"])??"";a||t(e,"Policy name is required"),/^[a-zA-Z0-9=,.@_-]+$/.test(a)||t(e,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed.");let v=await p(e),n;i?h(i)?n=w(i,"utf-8"):n=i:process.stdin.isTTY?t(e,"Policy document is required. Provide via --document or pipe to stdin."):n=await g();let m;try{m=y(n)}catch{t(e,"Invalid JSON in policy document")}let{data:r,error:s}=await O(a,{document:m,description:S,config:v});s&&t(e,s),P==="json"&&console.log(JSON.stringify({action:"created",name:r.name,arn:r.resource})),l(e,{name:r.name}),console.log(`Resource: ${r.resource}`)}export{A as default};
@@ -1 +1 @@
1
- import{a as w}from"../../../chunk-LVAJB4FR.js";import{a as n,b as u}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-ALJKYIQL.js";import{a as s,b as y}from"../../../chunk-YFMOI263.js";import{b as c}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as p,e as g,j as d}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import E from"enquirer";import{deletePolicy as P,listPolicies as $}from"@tigrisdata/iam";var{prompt:O}=E,o=d("iam policies","delete");async function b(i){f(o);let h=y(i),e=s(i,["resource"]),A=s(i,["yes","y","force"]),a=await w(o);if(!e){let{data:t,error:m}=await $({config:a});if(m&&c(o,m),!t.policies||t.policies.length===0){g(o);return}n("Provide the policy ARN as a positional argument");let{selected:S}=await O({type:"select",name:"selected",message:"Select a policy to delete:",choices:t.policies.map(r=>({name:r.resource,message:`${r.name} (${r.resource})`}))});e=S}if(!A&&(n("Use --yes to skip confirmation"),!await u(`Delete policy '${e}'?`))){console.log("Aborted");return}let{error:l}=await P(e,{config:a});l&&c(o,l),h==="json"&&console.log(JSON.stringify({action:"deleted",arn:e})),p(o,{resource:e})}export{b as default};
1
+ import{a as u}from"../../../chunk-ZADGAARW.js";import{a as g}from"../../../chunk-7ERBLTNY.js";import{a as l,b as p}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as i,b as d}from"../../../chunk-YFMOI263.js";import{b as a}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as s,j as m}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{deletePolicy as S}from"@tigrisdata/iam";var e=m("iam policies","delete");async function A(t){f(e);let y=d(t),o=i(t,["resource"]),w=i(t,["yes","y","force"]),n=await g(e);if(!o){let r=await u(n,e,"Select a policy to delete:");if(!r)return;o=r}if(!w&&(l("Use --yes to skip confirmation"),!await p(`Delete policy '${o}'?`))){console.log("Aborted");return}let{error:c}=await S(o,{config:n});c&&a(e,c),y==="json"&&console.log(JSON.stringify({action:"deleted",arn:o})),s(e,{resource:o})}export{A as default};
@@ -1 +1 @@
1
- import{a as E,b as l}from"../../../chunk-Y7MJZRR4.js";import{a as D}from"../../../chunk-LVAJB4FR.js";import{a as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-ALJKYIQL.js";import{a as s,b as A}from"../../../chunk-YFMOI263.js";import{b as i}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as h,c as w,e as S,j as P}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as O,readFileSync as q}from"fs";import x from"enquirer";import{editPolicy as T,getPolicy as R,listPolicies as C}from"@tigrisdata/iam";var{prompt:I}=x,e=P("iam policies","edit");async function F(o){h(e);let J=A(o),r=s(o,["resource"]),n=s(o,["document","d"]),a=s(o,["description"]),m=await D(e);if(!r){process.stdin.isTTY||i(e,"Policy ARN is required when piping document via stdin.");let{data:t,error:y}=await C({config:m});if(y&&i(e,y),!t.policies||t.policies.length===0){S(e);return}v("Provide the policy ARN as a positional argument");let{selected:N}=await I({type:"select",name:"selected",message:"Select a policy to edit:",choices:t.policies.map(d=>({name:d.resource,message:`${d.name} (${d.resource})`}))});r=N}let c;if(n){let t;O(n)?t=q(n,"utf-8"):t=n;try{c=l(t)}catch{i(e,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!a){let t=await E();try{c=l(t)}catch{i(e,"Invalid JSON in policy document")}}!c&&!a&&i(e,"Either --document or --description is required.");let{data:p,error:u}=await R(r,{config:m});u&&i(e,u);let{data:f,error:g}=await T(r,{document:c??p.document,description:a??p.description,config:m});g&&i(e,g),J==="json"&&console.log(JSON.stringify({action:"updated",arn:f.resource})),w(e,{resource:f.resource})}export{F as default};
1
+ import{a as h,b as a}from"../../../chunk-Y7MJZRR4.js";import{a as J}from"../../../chunk-ZADGAARW.js";import{a as P}from"../../../chunk-7ERBLTNY.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as s,b as w}from"../../../chunk-YFMOI263.js";import{b as e}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await P(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await h();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-LVAJB4FR.js";import{f as v}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-ALJKYIQL.js";import{a as p,b as y}from"../../../chunk-YFMOI263.js";import{b as n}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as s,e as g,j as d}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import $ from"enquirer";import{getPolicy as w,listPolicies as I}from"@tigrisdata/iam";var{prompt:D}=$,t=d("iam policies","get");async function C(c){m(t);let r=p(c,["resource"]),l=y(c),a=await h(t);if(!r){let{data:o,error:u}=await I({config:a});if(u&&n(t,u),!o.policies||o.policies.length===0){g(t);return}let{selected:O}=await D({type:"select",name:"selected",message:"Select a policy:",choices:o.policies.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});r=O}let{data:e,error:f}=await w(r,{config:a});if(f&&n(t,f),l==="json"){console.log(JSON.stringify(e,null,2)),s(t);return}let S=[{field:"Name",value:e.name},{field:"ID",value:e.id},{field:"Resource",value:e.resource},{field:"Description",value:e.description||"-"},{field:"Path",value:e.path},{field:"Version",value:e.defaultVersionId},{field:"Attachments",value:String(e.attachmentCount)},{field:"Created",value:e.createDate.toISOString()},{field:"Updated",value:e.updateDate.toISOString()}],A=v(S,l,"policy","field",[{key:"field",header:"Field"},{key:"value",header:"Value"}]);if(console.log(A),e.users&&e.users.length>0){console.log("Attached Users:");for(let o of e.users)console.log(` - ${o}`);console.log()}console.log("Policy Document:"),console.log(` Version: ${e.document.version}`),console.log(" Statements:");for(let o of e.document.statements)console.log(` - Effect: ${o.effect}`),console.log(` Action: ${Array.isArray(o.action)?o.action.join(", "):o.action}`),console.log(` Resource: ${Array.isArray(o.resource)?o.resource.join(", "):o.resource}`);s(t)}export{C as default};
1
+ import{a as y}from"../../../chunk-ZADGAARW.js";import{a as g}from"../../../chunk-7ERBLTNY.js";import{f as p}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as m,b as d}from"../../../chunk-YFMOI263.js";import{b as u}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,j as f}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{getPolicy as A}from"@tigrisdata/iam";var t=f("iam policies","get");async function S(n){a(t);let r=m(n,["resource"]),s=d(n),l=await g(t);if(!r){let o=await y(l,t);if(!o)return;r=o}let{data:e,error:c}=await A(r,{config:l});if(c&&u(t,c),s==="json"){console.log(JSON.stringify(e,null,2)),i(t);return}let v=[{field:"Name",value:e.name},{field:"ID",value:e.id},{field:"Resource",value:e.resource},{field:"Description",value:e.description||"-"},{field:"Path",value:e.path},{field:"Version",value:e.defaultVersionId},{field:"Attachments",value:String(e.attachmentCount)},{field:"Created",value:e.createDate.toISOString()},{field:"Updated",value:e.updateDate.toISOString()}],h=p(v,s,"policy","field",[{key:"field",header:"Field"},{key:"value",header:"Value"}]);if(console.log(h),e.users&&e.users.length>0){console.log("Attached Users:");for(let o of e.users)console.log(` - ${o.name} (${o.id})`);console.log()}console.log("Policy Document:"),console.log(` Version: ${e.document.version}`),console.log(" Statements:");for(let o of e.document.statements)console.log(` - Effect: ${o.effect}`),console.log(` Action: ${Array.isArray(o.action)?o.action.join(", "):o.action}`),console.log(` Resource: ${Array.isArray(o.resource)?o.resource.join(", "):o.resource}`);i(t)}export{S as default};
@@ -0,0 +1 @@
1
+ import{a as h}from"../../../chunk-ZADGAARW.js";import{a as k}from"../../../chunk-7ERBLTNY.js";import{a as g}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as l,b as u}from"../../../chunk-YFMOI263.js";import{b as o}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as y,j as p}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import I from"enquirer";import{attachPolicyToAccessKey as P,getPolicy as v,listAccessKeys as O}from"@tigrisdata/iam";var{prompt:K}=I,e=p("iam policies","link-key");async function R(a){d(e);let w=u(a),r=l(a,["resource"]),s=l(a,["id"]),c=await k(e);if(!r){let i=await h(c,e);if(!i)return;r=i}if(!s){g("Use --id to specify the access key ID");let[i,n]=await Promise.all([O({config:c}),v(r,{config:c})]);i.error&&o(e,i.error),n.error&&o(e,n.error);let A=new Set((n.data.users??[]).map(t=>t.id)),f=i.data.accessKeys.filter(t=>!A.has(t.id));f.length===0&&o(e,"No unlinked access keys available. All access keys are already linked to this policy.");let{selected:S}=await K({type:"select",name:"selected",message:"Select an access key to link:",choices:f.map(t=>({name:t.id,message:`${t.name} (${t.id})`}))});s=S}let{error:m}=await P(s,r,{config:c});m&&o(e,m),w==="json"&&console.log(JSON.stringify({action:"linked",policyArn:r,id:s})),y(e)}export{R as default};
@@ -0,0 +1 @@
1
+ import{a as k}from"../../../chunk-ZADGAARW.js";import{a as y}from"../../../chunk-7ERBLTNY.js";import{f as d}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as p,b as g}from"../../../chunk-YFMOI263.js";import{b as l}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as a,e as f,j as u}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{getPolicy as O}from"@tigrisdata/iam";var t=u("iam policies","list-keys");async function x(i){c(t);let h=g(i),e=p(i,["resource"]),n=await y(t);if(!e){let o=await k(n,t);if(!o)return;e=o}let{data:r,error:s}=await O(e,{config:n});if(s&&l(t,s),!r.users||r.users.length===0){f(t);return}let m=r.users.map(o=>({name:o.name,id:o.id})),w=d(m,h,"keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"}]);console.log(w),a(t,{count:m.length})}export{x as default};
@@ -1 +1 @@
1
- import{a as x}from"../../../chunk-LVAJB4FR.js";import{f as C,g as D}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-ALJKYIQL.js";import{b as y,c as P}from"../../../chunk-YFMOI263.js";import{b as T}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as f,e as l,i as h,j as k}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{listPolicies as I}from"@tigrisdata/iam";var e=k("iam policies","list");async function O(r){g(e);let i=y(r),{limit:s,pageToken:c,isPaginated:d}=P(r),o=await x(e),{data:n,error:m}=await I({...s!==void 0?{limit:s}:{},...c?{paginationToken:c}:{},config:{sessionToken:o.sessionToken,organizationId:o.organizationId,iamEndpoint:o.iamEndpoint}});if(m&&T(e,m),!n.policies||n.policies.length===0){l(e);return}let a=n.policies.map(t=>({name:t.name,id:t.id,resource:t.resource,description:t.description||"-",attachments:t.attachmentCount,created:t.createDate,updated:t.updateDate})),p=[{key:"id",header:"ID"},{key:"resource",header:"Resource"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"attachments",header:"Attachments"},{key:"created",header:"Created"},{key:"updated",header:"Updated"}],u=n.paginationToken||void 0,E=d?D(a,i,"policies","policy",p,{paginationToken:u}):C(a,i,"policies","policy",p);console.log(E),d&&i!=="json"&&i!=="xml"&&h(u),f(e,{count:a.length})}export{O as default};
1
+ import{a as x}from"../../../chunk-7ERBLTNY.js";import{g as y}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-YOKGP6YU.js";import{b as l,c as T}from"../../../chunk-YFMOI263.js";import{b as k}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as u,e as g,i as f,j as h}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{listPolicies as E}from"@tigrisdata/iam";var t=h("iam policies","list");async function I(a){p(t);let i=l(a),{limit:r,pageToken:s}=T(a),o=await x(t),{data:n,error:c}=await E({...r!==void 0?{limit:r}:{},...s?{paginationToken:s}:{},config:{sessionToken:o.sessionToken,organizationId:o.organizationId,iamEndpoint:o.iamEndpoint}});if(c&&k(t,c),!n.policies||n.policies.length===0){g(t);return}let d=n.policies.map(e=>({name:e.name,id:e.id,resource:e.resource,description:e.description||"-",attachments:e.attachmentCount,created:e.createDate,updated:e.updateDate})),C=[{key:"id",header:"ID"},{key:"resource",header:"Resource"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"attachments",header:"Attachments"},{key:"created",header:"Created"},{key:"updated",header:"Updated"}],m=n.paginationToken||void 0,D=y(d,i,"policies","policy",C,{paginationToken:m});console.log(D),i!=="json"&&i!=="xml"&&f(m),u(t,{count:d.length})}export{I as default};
@@ -0,0 +1 @@
1
+ import{a}from"../../../chunk-ZADGAARW.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";export{a as selectPolicy};
@@ -0,0 +1 @@
1
+ import{a as h}from"../../../chunk-ZADGAARW.js";import{a as k}from"../../../chunk-7ERBLTNY.js";import{a as f,b as d}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as n,b as u}from"../../../chunk-YFMOI263.js";import{b as c}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as y,c as p,j as g}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import $ from"enquirer";import{detachPolicyFromAccessKey as O,getPolicy as P}from"@tigrisdata/iam";var{prompt:I}=$,o=g("iam policies","unlink-key");async function U(r){y(o);let w=u(r),i=n(r,["resource"]),t=n(r,["id"]),A=n(r,["yes","y","force"]),s=await k(o);if(!i){let e=await h(s,o);if(!e)return;i=e}if(!t){f("Use --id to specify the access key ID");let{data:e,error:l}=await P(i,{config:s});l&&c(o,l),(!e.users||e.users.length===0)&&c(o,"No access keys are linked to this policy.");let{selected:S}=await I({type:"select",name:"selected",message:"Select an access key to unlink:",choices:e.users.map(a=>({name:a.id,message:`${a.name} (${a.id})`}))});t=S}if(!A&&(f("Use --yes to skip confirmation"),!await d(`Unlink access key '${t}' from policy '${i}'?`))){console.log("Aborted");return}let{error:m}=await O(t,i,{config:s});m&&c(o,m),w==="json"&&console.log(JSON.stringify({action:"unlinked",policyArn:i,id:t})),p(o)}export{U as default};
@@ -1 +1 @@
1
- import{a as u}from"../../../chunk-LVAJB4FR.js";import"../../../chunk-ALJKYIQL.js";import{a as s,b as p}from"../../../chunk-YFMOI263.js";import{b as n}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c,j as f}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as g}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{inviteUser as b}from"@tigrisdata/iam";var i=f("iam users","invite");async function j(e){l(i);let d=p(e);if(g("User management"))return;let o=s(e,["email"]),r=s(e,["role","r"])??"member",t=Array.isArray(o)?o:o?[o]:[];t.length===0&&n(i,"Email address is required");let a=["admin","member"];a.includes(r)||n(i,`Invalid role "${r}". Must be one of: ${a.join(", ")}`);let v=r,y=await u(i),R=t.map(O=>({email:O,role:v})),{error:m}=await b(R,{config:y});m&&n(i,m),d==="json"&&console.log(JSON.stringify({action:"invited",email:t.join(", ")})),c(i,{email:t.join(", ")})}export{j as default};
1
+ import{a as u}from"../../../chunk-7ERBLTNY.js";import"../../../chunk-YOKGP6YU.js";import{a as s,b as p}from"../../../chunk-YFMOI263.js";import{b as n}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c,j as f}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as g}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{inviteUser as b}from"@tigrisdata/iam";var i=f("iam users","invite");async function j(e){l(i);let d=p(e);if(g("User management"))return;let o=s(e,["email"]),r=s(e,["role","r"])??"member",t=Array.isArray(o)?o:o?[o]:[];t.length===0&&n(i,"Email address is required");let a=["admin","member"];a.includes(r)||n(i,`Invalid role "${r}". Must be one of: ${a.join(", ")}`);let v=r,y=await u(i),R=t.map(O=>({email:O,role:v})),{error:m}=await b(R,{config:y});m&&n(i,m),d==="json"&&console.log(JSON.stringify({action:"invited",email:t.join(", ")})),c(i,{email:t.join(", ")})}export{j as default};
@@ -1,4 +1,4 @@
1
- import{a as p}from"../../../chunk-LVAJB4FR.js";import{b as y,d as i,e as a}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-ALJKYIQL.js";import{b as h}from"../../../chunk-YFMOI263.js";import{b as d}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as g,e as c,j as u}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as f}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{listUsers as v}from"@tigrisdata/iam";var n=u("iam users","list");async function w(k){m(n);let r=h(k);if(f("User management"))return;let C=await p(n),{data:l,error:s}=await v({config:C});s&&d(n,s);let o=l.users.map(e=>({email:e.email,name:e.userName||"-",role:e.isOrgOwner?"owner":e.role,userId:e.userId})),t=l.invitations.map(e=>({id:e.id,email:e.email,role:e.role,status:e.status,validUntil:e.validUntil.toLocaleDateString()}));if(o.length===0&&t.length===0){c(n);return}let I=[{key:"email",header:"Email"},{key:"name",header:"Name"},{key:"role",header:"Role"},{key:"userId",header:"User ID"}],U=[{key:"id",header:"ID"},{key:"email",header:"Email"},{key:"role",header:"Role"},{key:"status",header:"Status"},{key:"validUntil",header:"Valid Until"}];if(r==="json")console.log(y({users:o,invitations:t}));else if(r==="xml"){let e=["<organization>"];e.push(" "+i(o,"users","user").replace(/\n/g,`
1
+ import{a as p}from"../../../chunk-7ERBLTNY.js";import{b as y,d as i,e as a}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-YOKGP6YU.js";import{b as h}from"../../../chunk-YFMOI263.js";import{b as d}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as g,e as c,j as u}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as f}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{listUsers as v}from"@tigrisdata/iam";var n=u("iam users","list");async function w(k){m(n);let r=h(k);if(f("User management"))return;let C=await p(n),{data:l,error:s}=await v({config:C});s&&d(n,s);let o=l.users.map(e=>({email:e.email,name:e.userName||"-",role:e.isOrgOwner?"owner":e.role,userId:e.userId})),t=l.invitations.map(e=>({id:e.id,email:e.email,role:e.role,status:e.status,validUntil:e.validUntil.toLocaleDateString()}));if(o.length===0&&t.length===0){c(n);return}let I=[{key:"email",header:"Email"},{key:"name",header:"Name"},{key:"role",header:"Role"},{key:"userId",header:"User ID"}],U=[{key:"id",header:"ID"},{key:"email",header:"Email"},{key:"role",header:"Role"},{key:"status",header:"Status"},{key:"validUntil",header:"Valid Until"}];if(r==="json")console.log(y({users:o,invitations:t}));else if(r==="xml"){let e=["<organization>"];e.push(" "+i(o,"users","user").replace(/\n/g,`
2
2
  `)),e.push(" "+i(t,"invitations","invitation").replace(/\n/g,`
3
3
  `)),e.push("</organization>"),console.log(e.join(`
4
4
  `))}else o.length>0&&(console.log(`
@@ -1 +1 @@
1
- import{a as O}from"../../../chunk-LVAJB4FR.js";import{a,b as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-ALJKYIQL.js";import{a as m,b as w}from"../../../chunk-YFMOI263.js";import{b as n}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c as u,e as p,j as d}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as y}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import I from"enquirer";import{listUsers as E,removeUser as F}from"@tigrisdata/iam";var{prompt:S}=I,e=d("iam users","remove");async function $(s){l(e);let h=w(s),t=m(s,["resource"]),U=m(s,["yes","y","force"]);if(y("User management"))return;let c=await O(e),r=Array.isArray(t)?t:t?[t]:[];if(r.length===0){let{data:i,error:g}=await E({config:c});if(g&&n(e,g),i.users.length===0){p(e);return}a("Provide user ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select user(s) to remove (space to select, enter to confirm):",choices:i.users.map(o=>({name:o.userId,message:`${o.email} (${o.isOrgOwner?"owner":o.role})`}))});r=A}if(!U&&(a("Use --yes to skip confirmation"),!await v(`Remove ${r.length} user(s)?`))){console.log("Aborted");return}let{error:f}=await F(r,{config:c});f&&n(e,f),h==="json"&&console.log(JSON.stringify({action:"removed",users:r})),u(e)}export{$ as default};
1
+ import{a as O}from"../../../chunk-7ERBLTNY.js";import{a,b as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as m,b as w}from"../../../chunk-YFMOI263.js";import{b as n}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c as u,e as p,j as d}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as y}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import I from"enquirer";import{listUsers as E,removeUser as F}from"@tigrisdata/iam";var{prompt:S}=I,e=d("iam users","remove");async function $(s){l(e);let h=w(s),t=m(s,["resource"]),U=m(s,["yes","y","force"]);if(y("User management"))return;let c=await O(e),r=Array.isArray(t)?t:t?[t]:[];if(r.length===0){let{data:i,error:g}=await E({config:c});if(g&&n(e,g),i.users.length===0){p(e);return}a("Provide user ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select user(s) to remove (space to select, enter to confirm):",choices:i.users.map(o=>({name:o.userId,message:`${o.email} (${o.isOrgOwner?"owner":o.role})`}))});r=A}if(!U&&(a("Use --yes to skip confirmation"),!await v(`Remove ${r.length} user(s)?`))){console.log("Aborted");return}let{error:f}=await F(r,{config:c});f&&n(e,f),h==="json"&&console.log(JSON.stringify({action:"removed",users:r})),u(e)}export{$ as default};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-LVAJB4FR.js";import{a,b as y}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-ALJKYIQL.js";import{a as c,b as k}from"../../../chunk-YFMOI263.js";import{b as s}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as p,e as u,j as v}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as d}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import O from"enquirer";import{listUsers as $,revokeInvitation as E}from"@tigrisdata/iam";var{prompt:S}=O,t=v("iam users","revoke-invitation");async function U(r){g(t);let w=k(r),o=c(r,["resource"]),I=c(r,["yes","y","force"]);if(d("User management"))return;let m=await h(t),e=Array.isArray(o)?o:o?[o]:[];if(e.length===0){let{data:n,error:l}=await $({config:m});if(l&&s(t,l),n.invitations.length===0){u(t);return}a("Provide invitation ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select invitation(s) to revoke (space to select, enter to confirm):",choices:n.invitations.map(i=>({name:i.id,message:`${i.email} (${i.role} - ${i.status})`}))});e=A}if(!I&&(a("Use --yes to skip confirmation"),!await y(`Revoke ${e.length} invitation(s)?`))){console.log("Aborted");return}let{error:f}=await E(e,{config:m});f&&s(t,f),w==="json"&&console.log(JSON.stringify({action:"revoked",invitations:e})),p(t)}export{U as default};
1
+ import{a as h}from"../../../chunk-7ERBLTNY.js";import{a,b as y}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-YOKGP6YU.js";import{a as c,b as k}from"../../../chunk-YFMOI263.js";import{b as s}from"../../../chunk-VAVMX5DC.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as p,e as u,j as v}from"../../../chunk-PG746YF3.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-KK7FZ7QM.js";import{a as d}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import O from"enquirer";import{listUsers as $,revokeInvitation as E}from"@tigrisdata/iam";var{prompt:S}=O,t=v("iam users","revoke-invitation");async function U(r){g(t);let w=k(r),o=c(r,["resource"]),I=c(r,["yes","y","force"]);if(d("User management"))return;let m=await h(t),e=Array.isArray(o)?o:o?[o]:[];if(e.length===0){let{data:n,error:l}=await $({config:m});if(l&&s(t,l),n.invitations.length===0){u(t);return}a("Provide invitation ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select invitation(s) to revoke (space to select, enter to confirm):",choices:n.invitations.map(i=>({name:i.id,message:`${i.email} (${i.role} - ${i.status})`}))});e=A}if(!I&&(a("Use --yes to skip confirmation"),!await y(`Revoke ${e.length} invitation(s)?`))){console.log("Aborted");return}let{error:f}=await E(e,{config:m});f&&s(t,f),w==="json"&&console.log(JSON.stringify({action:"revoked",invitations:e})),p(t)}export{U as default};