@tigrisdata/cli 3.4.0 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/auth/client.js +1 -1
  2. package/dist/auth/fly.js +1 -1
  3. package/dist/auth/iam.js +1 -1
  4. package/dist/auth/provider.js +1 -1
  5. package/dist/auth/storage.js +1 -1
  6. package/dist/{chunk-RS4HZYP3.js → chunk-3QCSRNXC.js} +1 -1
  7. package/dist/chunk-6FFMMSBH.js +1 -0
  8. package/dist/chunk-6JDBAIGA.js +8 -0
  9. package/dist/{chunk-KQTMMFPE.js → chunk-76L56E5U.js} +1 -1
  10. package/dist/chunk-7ZCVOA6A.js +1 -0
  11. package/dist/chunk-AFM3TY2D.js +7 -0
  12. package/dist/{chunk-VQDOL2GU.js → chunk-CL4GEWT2.js} +1 -1
  13. package/dist/{chunk-7ZUCJBD5.js → chunk-D7WXNA2O.js} +1 -1
  14. package/dist/{chunk-OHGCOC5Q.js → chunk-F4AGJWCK.js} +1 -1
  15. package/dist/{chunk-S7EO4QWK.js → chunk-JLNCN27M.js} +1 -1
  16. package/dist/{chunk-LAB2KJTN.js → chunk-JNSFDQGG.js} +1 -1
  17. package/dist/{chunk-2ITYREA5.js → chunk-KJA757WE.js} +1 -1
  18. package/dist/{chunk-GAWFFIPC.js → chunk-KJBSIIND.js} +1 -1
  19. package/dist/{chunk-PPNBQWSR.js → chunk-NI4EYBQH.js} +1 -1
  20. package/dist/chunk-Q6UVMHAZ.js +1 -0
  21. package/dist/{chunk-UBANDLB4.js → chunk-SE5TRZWU.js} +1 -1
  22. package/dist/{chunk-3EAZ2L6H.js → chunk-VNUR4TRP.js} +1 -1
  23. package/dist/{chunk-2GLKQBPM.js → chunk-W52B2I2N.js} +1 -1
  24. package/dist/{chunk-G4DHMSCQ.js → chunk-Z2LVZ3ZF.js} +4 -4
  25. package/dist/cli-core.js +1 -1
  26. package/dist/cli.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/lib/access-keys/assign.js +1 -1
  29. package/dist/lib/access-keys/attach-policy.js +1 -1
  30. package/dist/lib/access-keys/create.js +1 -1
  31. package/dist/lib/access-keys/delete.js +1 -1
  32. package/dist/lib/access-keys/detach-policy.js +1 -1
  33. package/dist/lib/access-keys/get.js +1 -1
  34. package/dist/lib/access-keys/list-policies.js +1 -1
  35. package/dist/lib/access-keys/list.js +1 -1
  36. package/dist/lib/access-keys/rotate.js +1 -1
  37. package/dist/lib/buckets/create.js +1 -1
  38. package/dist/lib/buckets/delete.js +1 -1
  39. package/dist/lib/buckets/disable-snapshots.js +1 -1
  40. package/dist/lib/buckets/enable-snapshots.js +1 -1
  41. package/dist/lib/buckets/get.js +1 -1
  42. package/dist/lib/buckets/lifecycle/create.js +1 -1
  43. package/dist/lib/buckets/lifecycle/edit.js +1 -1
  44. package/dist/lib/buckets/lifecycle/list.js +1 -1
  45. package/dist/lib/buckets/lifecycle/shared.js +1 -1
  46. package/dist/lib/buckets/list.js +1 -1
  47. package/dist/lib/buckets/merge.js +1 -1
  48. package/dist/lib/buckets/migrate.js +1 -1
  49. package/dist/lib/buckets/rebase.js +1 -1
  50. package/dist/lib/buckets/restore.js +1 -1
  51. package/dist/lib/buckets/set-cors.js +1 -1
  52. package/dist/lib/buckets/set-locations.js +1 -1
  53. package/dist/lib/buckets/set-migration.js +1 -1
  54. package/dist/lib/buckets/set-notifications.js +1 -1
  55. package/dist/lib/buckets/set.js +1 -1
  56. package/dist/lib/bundle.js +3 -3
  57. package/dist/lib/configure/index.js +1 -1
  58. package/dist/lib/cp.js +1 -1
  59. package/dist/lib/credentials/test.js +1 -1
  60. package/dist/lib/iam/policies/create.js +1 -1
  61. package/dist/lib/iam/policies/delete.js +1 -1
  62. package/dist/lib/iam/policies/edit.js +1 -1
  63. package/dist/lib/iam/policies/get.js +1 -1
  64. package/dist/lib/iam/policies/link-key.js +1 -1
  65. package/dist/lib/iam/policies/list-keys.js +1 -1
  66. package/dist/lib/iam/policies/list.js +1 -1
  67. package/dist/lib/iam/policies/select-policy.js +1 -1
  68. package/dist/lib/iam/policies/unlink-key.js +1 -1
  69. package/dist/lib/iam/teams/create.js +1 -1
  70. package/dist/lib/iam/teams/edit.js +1 -1
  71. package/dist/lib/iam/teams/list.js +1 -1
  72. package/dist/lib/iam/teams/shared.js +1 -1
  73. package/dist/lib/iam/users/invite.js +1 -1
  74. package/dist/lib/iam/users/list.js +2 -2
  75. package/dist/lib/iam/users/remove.js +1 -1
  76. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  77. package/dist/lib/iam/users/update-role.js +1 -1
  78. package/dist/lib/login/credentials.js +1 -1
  79. package/dist/lib/login/oauth.js +1 -1
  80. package/dist/lib/login/select.js +1 -1
  81. package/dist/lib/logout.js +1 -1
  82. package/dist/lib/ls.js +1 -1
  83. package/dist/lib/mk.js +1 -1
  84. package/dist/lib/mv.js +1 -1
  85. package/dist/lib/objects/delete.js +1 -1
  86. package/dist/lib/objects/get.js +1 -1
  87. package/dist/lib/objects/info.js +1 -1
  88. package/dist/lib/objects/list-versions.js +1 -1
  89. package/dist/lib/objects/list.js +1 -1
  90. package/dist/lib/objects/put.js +1 -1
  91. package/dist/lib/objects/restore-info.js +1 -1
  92. package/dist/lib/objects/restore.js +1 -1
  93. package/dist/lib/objects/set-access.js +1 -1
  94. package/dist/lib/objects/set.js +1 -1
  95. package/dist/lib/organizations/create.js +1 -1
  96. package/dist/lib/organizations/list.js +1 -1
  97. package/dist/lib/organizations/select.js +1 -1
  98. package/dist/lib/presign.js +1 -1
  99. package/dist/lib/rm.js +1 -1
  100. package/dist/lib/snapshots/list.js +1 -1
  101. package/dist/lib/snapshots/take.js +1 -1
  102. package/dist/lib/stat.js +1 -1
  103. package/dist/lib/touch.js +1 -1
  104. package/dist/lib/update.js +1 -1
  105. package/dist/lib/whoami.js +1 -1
  106. package/dist/utils/bucket-info.js +1 -1
  107. package/dist/utils/exit.js +1 -1
  108. package/dist/utils/format.js +1 -1
  109. package/dist/utils/messages.js +1 -1
  110. package/dist/utils/path.js +1 -1
  111. package/dist/utils/specs.js +1 -1
  112. package/dist/utils/update-check.js +1 -1
  113. package/package.json +30 -47
  114. package/postinstall.cjs +4 -0
  115. package/dist/chunk-HHDQ3ISR.js +0 -1
  116. package/dist/chunk-IRDNZN7R.js +0 -7
  117. package/dist/chunk-NOD4ZVXO.js +0 -8
  118. package/dist/chunk-RXNG56FL.js +0 -1
  119. package/dist/chunk-RZPBM4CD.js +0 -1
@@ -1,3 +1,3 @@
1
- import{a as w}from"../../chunk-SAAGVLRE.js";import{a as h}from"../../chunk-IRDNZN7R.js";import{e as F}from"../../chunk-RXNG56FL.js";import{d as v}from"../../chunk-RS4HZYP3.js";import{a as M}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{d as S,j as y}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{isMigrated as x,list as B,migrate as R}from"@tigrisdata/storage";var u=y("buckets","migrate"),N=10*1024*1024*1024,b=50,z=5e3,D=50,k=3,_=class{constructor(r,i,s,c){this.bucket=r;this.source=i;this.prefix=s;this.config=c}bucket;source;prefix;config;buffer=[];index=0;token;_done=!1;get done(){return this._done&&this.index>=this.buffer.length}async current(){return this.index<this.buffer.length?this.buffer[this.index]:this._done?null:(await this.fetchPage(),this.index<this.buffer.length?this.buffer[this.index]:null)}advance(){this.index++}async fetchPage(){if(this._done)return;let{data:r,error:i}=await B({prefix:this.prefix,source:this.source,...this.token?{paginationToken:this.token}:{},config:{...this.config,bucket:this.bucket}});if(i)throw i;this.buffer=r.items??[],this.index=0,this.token=r.paginationToken,!r.paginationToken&&!r.hasMore&&(this._done=!0)}};async function C(t,r,i){let s=new _(t,"shadow",r,i),c=new _(t,"tigris",r,i),o=[],n=await s.current(),a=await c.current();for(;n!==null;){if(a===null){o.push({name:n.name,size:n.size}),s.advance(),n=await s.current();continue}n.name<a.name?(o.push({name:n.name,size:n.size}),s.advance(),n=await s.current()):n.name>a.name?(c.advance(),a=await c.current()):(s.advance(),c.advance(),n=await s.current(),a=await c.current())}return o}function L(t){return new Promise(r=>setTimeout(r,t))}function E(t){let r=Math.floor(t/1e3),i=Math.floor(r/60),s=r%60;return i===0?`${s}s`:`${i}m ${s}s`}function p(t,r){if(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)return;let i=E(Date.now()-t.startTime),s=`\rMigrating ${r}: ${t.confirmed.toLocaleString()} / ${t.total.toLocaleString()} objects | In-flight: ${h(t.inFlightBytes)} | ${i}`;process.stderr.write(s+" ".repeat(Math.max(0,100-s.length)))}function T(){!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE||process.stderr.write("\r"+" ".repeat(100)+"\r")}async function $(t,r,i,s){let c=await w(t.map(o=>()=>R(o.name,{config:{...i,bucket:s}})),b);for(let o=0;o<c.length;o++){let n=c[o],a=t[o];n.error?(r.failed++,r.errors.push({name:a.name,error:n.error.message})):(r.inFlight.push({...a,checkFailures:0}),r.inFlightBytes+=a.size,r.scheduled++)}}async function O(t,r,i){if(t.inFlight.length===0)return;let s=t.inFlight.slice(0,b),c=await w(s.map(n=>()=>x(n.name,{config:{...r,bucket:i}})),b),o=new Set;for(let n=0;n<c.length;n++){let a=c[n],l=s[n];a.error?(l.checkFailures++,l.checkFailures>=k&&(o.add(l.name),t.failed++,t.inFlightBytes-=l.size,t.errors.push({name:l.name,error:`Failed to verify migration status after ${k} attempts`}))):a.data&&(o.add(l.name),t.confirmed++,t.confirmedBytes+=l.size,t.inFlightBytes-=l.size)}o.size>0&&(t.inFlight=t.inFlight.filter(n=>!o.has(n.name))),o.size===0&&await L(z)}async function P(t){let r=M(t,["path"]);r||m(u,"Bucket name or path is required");let{bucket:i,path:s}=F(r);i||m(u,"Invalid path");let c=await v(),o=!1,n=()=>{o=!0};process.on("SIGINT",n);try{process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&process.stderr.write("Discovering objects to migrate...");let a;try{a=await C(i,s,c)}catch(f){T(),m(u,f)}if(T(),a.length===0){process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error("All objects are already migrated."),globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:0,confirmed:0,failed:0}));return}let l=a.reduce((f,d)=>f+d.size,0);process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error(`Found ${a.length.toLocaleString()} objects to migrate (${h(l)})`);let e={total:a.length,totalBytes:l,scheduled:0,confirmed:0,confirmedBytes:0,failed:0,inFlight:[],inFlightBytes:0,errors:[],startTime:Date.now()},g=[];for(let f of a){if(o)break;for(;e.inFlightBytes+f.size>N&&e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);if(o)break;g.push(f),g.length>=D&&(await $(g,e,c,i),g=[],p(e,i))}for(g.length>0&&!o&&(await $(g,e,c,i),p(e,i));e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);T();let I=E(Date.now()-e.startTime);if(globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:e.total,scheduled:e.scheduled,confirmed:e.confirmed,failed:e.failed,elapsed:I,...e.errors.length>0?{errors:e.errors.slice(0,20)}:{}})),o&&(console.error(`
1
+ import{a as w}from"../../chunk-SAAGVLRE.js";import{a as h}from"../../chunk-AFM3TY2D.js";import{e as F}from"../../chunk-7ZCVOA6A.js";import{d as v}from"../../chunk-3QCSRNXC.js";import{a as M}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{d as S,j as y}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{isMigrated as x,list as B,migrate as R}from"@tigrisdata/storage";var u=y("buckets","migrate"),N=10*1024*1024*1024,b=50,z=5e3,D=50,k=3,_=class{constructor(r,i,s,c){this.bucket=r;this.source=i;this.prefix=s;this.config=c}bucket;source;prefix;config;buffer=[];index=0;token;_done=!1;get done(){return this._done&&this.index>=this.buffer.length}async current(){return this.index<this.buffer.length?this.buffer[this.index]:this._done?null:(await this.fetchPage(),this.index<this.buffer.length?this.buffer[this.index]:null)}advance(){this.index++}async fetchPage(){if(this._done)return;let{data:r,error:i}=await B({prefix:this.prefix,source:this.source,...this.token?{paginationToken:this.token}:{},config:{...this.config,bucket:this.bucket}});if(i)throw i;this.buffer=r.items??[],this.index=0,this.token=r.paginationToken,!r.paginationToken&&!r.hasMore&&(this._done=!0)}};async function C(t,r,i){let s=new _(t,"shadow",r,i),c=new _(t,"tigris",r,i),o=[],n=await s.current(),a=await c.current();for(;n!==null;){if(a===null){o.push({name:n.name,size:n.size}),s.advance(),n=await s.current();continue}n.name<a.name?(o.push({name:n.name,size:n.size}),s.advance(),n=await s.current()):n.name>a.name?(c.advance(),a=await c.current()):(s.advance(),c.advance(),n=await s.current(),a=await c.current())}return o}function L(t){return new Promise(r=>setTimeout(r,t))}function E(t){let r=Math.floor(t/1e3),i=Math.floor(r/60),s=r%60;return i===0?`${s}s`:`${i}m ${s}s`}function p(t,r){if(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)return;let i=E(Date.now()-t.startTime),s=`\rMigrating ${r}: ${t.confirmed.toLocaleString()} / ${t.total.toLocaleString()} objects | In-flight: ${h(t.inFlightBytes)} | ${i}`;process.stderr.write(s+" ".repeat(Math.max(0,100-s.length)))}function T(){!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE||process.stderr.write(`\r${" ".repeat(100)}\r`)}async function $(t,r,i,s){let c=await w(t.map(o=>()=>R(o.name,{config:{...i,bucket:s}})),b);for(let o=0;o<c.length;o++){let n=c[o],a=t[o];n.error?(r.failed++,r.errors.push({name:a.name,error:n.error.message})):(r.inFlight.push({...a,checkFailures:0}),r.inFlightBytes+=a.size,r.scheduled++)}}async function O(t,r,i){if(t.inFlight.length===0)return;let s=t.inFlight.slice(0,b),c=await w(s.map(n=>()=>x(n.name,{config:{...r,bucket:i}})),b),o=new Set;for(let n=0;n<c.length;n++){let a=c[n],l=s[n];a.error?(l.checkFailures++,l.checkFailures>=k&&(o.add(l.name),t.failed++,t.inFlightBytes-=l.size,t.errors.push({name:l.name,error:`Failed to verify migration status after ${k} attempts`}))):a.data&&(o.add(l.name),t.confirmed++,t.confirmedBytes+=l.size,t.inFlightBytes-=l.size)}o.size>0&&(t.inFlight=t.inFlight.filter(n=>!o.has(n.name))),o.size===0&&await L(z)}async function P(t){let r=M(t,["path"]);r||m(u,"Bucket name or path is required");let{bucket:i,path:s}=F(r);i||m(u,"Invalid path");let c=await v(),o=!1,n=()=>{o=!0};process.on("SIGINT",n);try{process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&process.stderr.write("Discovering objects to migrate...");let a;try{a=await C(i,s,c)}catch(f){T(),m(u,f)}if(T(),a.length===0){process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error("All objects are already migrated."),globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:0,confirmed:0,failed:0}));return}let l=a.reduce((f,d)=>f+d.size,0);process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error(`Found ${a.length.toLocaleString()} objects to migrate (${h(l)})`);let e={total:a.length,totalBytes:l,scheduled:0,confirmed:0,confirmedBytes:0,failed:0,inFlight:[],inFlightBytes:0,errors:[],startTime:Date.now()},g=[];for(let f of a){if(o)break;for(;e.inFlightBytes+f.size>N&&e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);if(o)break;g.push(f),g.length>=D&&(await $(g,e,c,i),g=[],p(e,i))}for(g.length>0&&!o&&(await $(g,e,c,i),p(e,i));e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);T();let I=E(Date.now()-e.startTime);if(globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:e.total,scheduled:e.scheduled,confirmed:e.confirmed,failed:e.failed,elapsed:I,...e.errors.length>0?{errors:e.errors.slice(0,20)}:{}})),o&&(console.error(`
2
2
  Interrupted. ${e.confirmed} confirmed, ${e.inFlight.length} still in-flight, ${e.total-e.scheduled} not yet scheduled.`),process.exit(1)),e.failed>0){if(S(u,`${e.failed} object(s) failed to migrate. ${e.confirmed} migrated successfully in ${I}.`),process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&e.errors.length>0){let f=e.errors.slice(0,10);for(let d of f)console.error(` ${d.name}: ${d.error}`);e.errors.length>10&&console.error(` ... and ${e.errors.length-10} more`)}process.exit(1)}console.error(`
3
3
  Migration complete: ${e.confirmed.toLocaleString()} object(s) migrated (${h(e.confirmedBytes)}) in ${I}`)}finally{process.removeListener("SIGINT",n)}}export{P as default};
@@ -1 +1 @@
1
- import{a as k,b}from"../../chunk-S77OAN6Y.js";import{d as l}from"../../chunk-RS4HZYP3.js";import{a as s,b as d}from"../../chunk-S6KFKBMY.js";import{b as n,c as g,d as p}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as m,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{rebaseFork as A}from"@tigrisdata/storage";var o=u("buckets","rebase");async function S(r){f(o);let h=d(r),t=s(r,["fork"]),x=s(r,["yes","y"]);t||n(o,"Fork bucket name is required");let w=await l();if(!x&&(k("Use --yes to skip confirmation"),!await b(`Rebase fork '${t}' onto the latest state of its source bucket? This updates '${t}'.`))){console.log("Aborted");return}let{data:y,error:i}=await A(t,{config:w});i&&n(o,i);let c=y?.snapshotVersion??"";if(h==="json"){let e=g(o,{fork:t}),a={action:"rebased",fork:t,snapshotVersion:c};e.length>0&&(a.nextActions=e),console.log(JSON.stringify(a))}m(o,{fork:t,snapshotVersion:c}),p(o,{fork:t})}export{S as default};
1
+ import{a as k,b}from"../../chunk-S77OAN6Y.js";import{d as l}from"../../chunk-3QCSRNXC.js";import{a as s,b as d}from"../../chunk-S6KFKBMY.js";import{b as n,c as g,d as p}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as m,j as u}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{rebaseFork as A}from"@tigrisdata/storage";var o=u("buckets","rebase");async function S(r){f(o);let h=d(r),t=s(r,["fork"]),x=s(r,["yes","y"]);t||n(o,"Fork bucket name is required");let w=await l();if(!x&&(k("Use --yes to skip confirmation"),!await b(`Rebase fork '${t}' onto the latest state of its source bucket? This updates '${t}'.`))){console.log("Aborted");return}let{data:y,error:i}=await A(t,{config:w});i&&n(o,i);let c=y?.snapshotVersion??"";if(h==="json"){let e=g(o,{fork:t}),a={action:"rebased",fork:t,snapshotVersion:c};e.length>0&&(a.nextActions=e),console.log(JSON.stringify(a))}m(o,{fork:t,snapshotVersion:c}),p(o,{fork:t})}export{S as default};
@@ -1 +1 @@
1
- import{d as x}from"../../chunk-RS4HZYP3.js";import{a as d,b as l}from"../../chunk-S6KFKBMY.js";import{a as i,b as g,c as u,d as p}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,d as n,j as f}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{restoreBucket as w}from"@tigrisdata/storage";var t=f("buckets","restore");async function A(s){a(t);let k=l(s),o=d(s,["name"]);o||g(t,"Bucket name is required");let{data:S,error:e}=await w(o,{config:await x()});if(e&&(n(t,e.message,{name:o}),i(e,t)),!S.restored){let r="Bucket could not be restored";n(t,r,{name:o}),i(r,t)}if(k==="json"){let r=u(t,{name:o}),c={action:"restored",name:o};r.length>0&&(c.nextActions=r),console.log(JSON.stringify(c))}m(t,{name:o}),p(t,{name:o})}export{A as default};
1
+ import{d as x}from"../../chunk-3QCSRNXC.js";import{a as d,b as l}from"../../chunk-S6KFKBMY.js";import{a as i,b as g,c as u,d as p}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,d as n,j as f}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{restoreBucket as w}from"@tigrisdata/storage";var t=f("buckets","restore");async function A(s){a(t);let k=l(s),o=d(s,["name"]);o||g(t,"Bucket name is required");let{data:S,error:e}=await w(o,{config:await x()});if(e&&(n(t,e.message,{name:o}),i(e,t)),!S.restored){let r="Bucket could not be restored";n(t,r,{name:o}),i(r,t)}if(k==="json"){let r=u(t,{name:o}),c={action:"restored",name:o};r.length>0&&(c.nextActions=r),console.log(JSON.stringify(c))}m(t,{name:o}),p(t,{name:o})}export{A as default};
@@ -1 +1 @@
1
- import{e as b}from"../../chunk-RS4HZYP3.js";import{a as r,b as x}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as h}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.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 x}from"../../chunk-3QCSRNXC.js";import{a as r,b as h}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as b}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=b("buckets","set-cors");async function k(e){c(n);let p=h(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"]),u=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||u)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(Number.isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await x(),{error:g}=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:u??!1,config:w});g&&i(n,g),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,c as d}from"../../chunk-N3Y6RFSK.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-RS4HZYP3.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.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,c as d}from"../../chunk-N3Y6RFSK.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-3QCSRNXC.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.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-RS4HZYP3.js";import{a as t,b as w}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.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-3QCSRNXC.js";import{a as t,b as w}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.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-RS4HZYP3.js";import{a as n,b as w}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.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-3QCSRNXC.js";import{a as n,b as w}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.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{c as j}from"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{e as k}from"../../chunk-RS4HZYP3.js";import{a as n,b as A,d as s}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as w,j as O}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as L}from"@tigrisdata/storage";var i=O("buckets","set");async function S(e){h(i);let B=A(e),d=n(e,["name"]),r=n(e,["access"]),l=n(e,["locations"]),c=n(e,["allow-object-acl","allowObjectAcl"]),f=n(e,["disable-directory-listing","disableDirectoryListing"]),u=n(e,["cache-control","cacheControl"]),b=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),a=n(e,["soft-delete","softDelete"]),m=n(e,["retention-days","retentionDays"]),y=n(e,["enable-additional-headers","enableAdditionalHeaders"]);d||o(i,"Bucket name is required"),r===void 0&&l===void 0&&c===void 0&&f===void 0&&u===void 0&&b===void 0&&g===void 0&&a===void 0&&y===void 0&&o(i,"At least one setting is required");let t={};if(r!==void 0&&(t.access=r),l!==void 0&&(t.locations=j(l)),c!==void 0&&(t.allowObjectAcl=s(c)),f!==void 0&&(t.disableDirectoryListing=s(f)),u!==void 0&&(t.cacheControl=u),b!==void 0&&(t.customDomain=b),g!==void 0&&(t.enableDeleteProtection=s(g)),a!==void 0&&a!=="enable"&&a!=="disable"&&o(i,'--soft-delete must be "enable" or "disable"'),m!==void 0&&a!=="enable"&&o(i,"--retention-days can only be used with --soft-delete enable"),a==="enable"){m===void 0&&o(i,"--retention-days is required when enabling soft delete");let D=Number(m);(!Number.isInteger(D)||D<=0)&&o(i,"--retention-days must be a positive integer"),t.softDelete={enabled:!0,retentionDays:D}}else a==="disable"&&(t.softDelete={enabled:!1});y!==void 0&&(t.enableAdditionalHeaders=s(y));let C=await k(),{error:p}=await L(d,{...t,config:C});p&&o(i,p),B==="json"&&console.log(JSON.stringify({action:"updated",name:d})),w(i,{name:d})}export{S as default};
1
+ import{c as j}from"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{e as k}from"../../chunk-3QCSRNXC.js";import{a as n,b as A,d as s}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as w,j as O}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{updateBucket as L}from"@tigrisdata/storage";var i=O("buckets","set");async function S(e){h(i);let B=A(e),d=n(e,["name"]),r=n(e,["access"]),l=n(e,["locations"]),c=n(e,["allow-object-acl","allowObjectAcl"]),f=n(e,["disable-directory-listing","disableDirectoryListing"]),u=n(e,["cache-control","cacheControl"]),b=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),a=n(e,["soft-delete","softDelete"]),m=n(e,["retention-days","retentionDays"]),y=n(e,["enable-additional-headers","enableAdditionalHeaders"]);d||o(i,"Bucket name is required"),r===void 0&&l===void 0&&c===void 0&&f===void 0&&u===void 0&&b===void 0&&g===void 0&&a===void 0&&y===void 0&&o(i,"At least one setting is required");let t={};if(r!==void 0&&(t.access=r),l!==void 0&&(t.locations=j(l)),c!==void 0&&(t.allowObjectAcl=s(c)),f!==void 0&&(t.disableDirectoryListing=s(f)),u!==void 0&&(t.cacheControl=u),b!==void 0&&(t.customDomain=b),g!==void 0&&(t.enableDeleteProtection=s(g)),a!==void 0&&a!=="enable"&&a!=="disable"&&o(i,'--soft-delete must be "enable" or "disable"'),m!==void 0&&a!=="enable"&&o(i,"--retention-days can only be used with --soft-delete enable"),a==="enable"){m===void 0&&o(i,"--retention-days is required when enabling soft delete");let D=Number(m);(!Number.isInteger(D)||D<=0)&&o(i,"--retention-days must be a positive integer"),t.softDelete={enabled:!0,retentionDays:D}}else a==="disable"&&(t.softDelete={enabled:!1});y!==void 0&&(t.enableAdditionalHeaders=s(y));let C=await k(),{error:p}=await L(d,{...t,config:C});p&&o(i,p),B==="json"&&console.log(JSON.stringify({action:"updated",name:d})),w(i,{name:d})}export{S as default};
@@ -1,3 +1,3 @@
1
- import{e as k}from"../chunk-RXNG56FL.js";import{d as h}from"../chunk-RS4HZYP3.js";import{a,b as p,e as y}from"../chunk-S6KFKBMY.js";import{a as o}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{bundle as E}from"@tigrisdata/storage";import{createWriteStream as j,existsSync as v,readFileSync as B}from"fs";import{Readable as C}from"stream";import{pipeline as b}from"stream/promises";var z=5e3;function S(t){return t.split(`
2
- `).map(n=>n.trim()).filter(n=>n.length>0&&!n.startsWith("#"))}function K(t){if(t.endsWith(".tar.gz")||t.endsWith(".tgz"))return"gzip";if(t.endsWith(".tar.zst"))return"zstd";if(t.endsWith(".tar"))return"none"}async function N(t){let n=a(t,["bucket"]),s=a(t,["keys","k"]),i=a(t,["output","o"]),g=a(t,["compression"]),w=a(t,["on-error","onError"],"skip"),l=p(t)==="json",W=!i;n||o("Bucket is required");let{bucket:d,path:c}=k(n);d||o("Invalid bucket");let e;if(s)s.includes(",")?e=s.split(",").map(r=>r.trim()).filter(r=>r.length>0):v(s)?e=S(B(s,"utf-8")):e=[s.trim()];else if(process.stdin.isTTY)o("Keys are required. Provide via --keys or pipe to stdin.");else{let r=await y();e=S(r)}if(c){let r=c.endsWith("/")?c:`${c}/`;e=e.map(A=>`${r}${A}`)}e.length===0&&o("No keys found"),e.length>z&&o(`Too many keys (max ${z}). Got ${e.length}`);let f="none";g?f=g:i&&(f=K(i)??"none"),!W&&!l&&process.stderr.write(`Bundling ${e.length} object(s)...
3
- `);let $=await h({withCredentialProvider:!0}),{data:x,error:m}=await E(e,{config:{...$,bucket:d},compression:f,onError:w});m&&o(m);let u=C.fromWeb(x.body);if(i){let r=j(i);await b(u,r),console.log(l?JSON.stringify({action:"bundled",bucket:d,keys:e.length,compression:f,output:i}):`Bundled ${e.length} object(s) from '${d}' to ${i}`)}else await b(u,process.stdout),l&&console.error(JSON.stringify({action:"bundled",bucket:d,keys:e.length,compression:f,output:"stdout"}));process.exit(0)}export{N as default};
1
+ import{e as k}from"../chunk-7ZCVOA6A.js";import{d as h}from"../chunk-3QCSRNXC.js";import{a,b as p,e as y}from"../chunk-S6KFKBMY.js";import{a as o}from"../chunk-SE5TRZWU.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-ATBINUDP.js";import"../chunk-VNUR4TRP.js";import"../chunk-F4AGJWCK.js";import{createWriteStream as E,existsSync as j,readFileSync as v}from"fs";import{Readable as B}from"stream";import{pipeline as b}from"stream/promises";import{bundle as C}from"@tigrisdata/storage";var z=5e3;function S(t){return t.split(`
2
+ `).map(n=>n.trim()).filter(n=>n.length>0&&!n.startsWith("#"))}function K(t){if(t.endsWith(".tar.gz")||t.endsWith(".tgz"))return"gzip";if(t.endsWith(".tar.zst"))return"zstd";if(t.endsWith(".tar"))return"none"}async function N(t){let n=a(t,["bucket"]),s=a(t,["keys","k"]),i=a(t,["output","o"]),g=a(t,["compression"]),w=a(t,["on-error","onError"],"skip"),l=p(t)==="json",W=!i;n||o("Bucket is required");let{bucket:d,path:c}=k(n);d||o("Invalid bucket");let e;if(s)s.includes(",")?e=s.split(",").map(r=>r.trim()).filter(r=>r.length>0):j(s)?e=S(v(s,"utf-8")):e=[s.trim()];else if(process.stdin.isTTY)o("Keys are required. Provide via --keys or pipe to stdin.");else{let r=await y();e=S(r)}if(c){let r=c.endsWith("/")?c:`${c}/`;e=e.map(A=>`${r}${A}`)}e.length===0&&o("No keys found"),e.length>z&&o(`Too many keys (max ${z}). Got ${e.length}`);let f="none";g?f=g:i&&(f=K(i)??"none"),!W&&!l&&process.stderr.write(`Bundling ${e.length} object(s)...
3
+ `);let $=await h({withCredentialProvider:!0}),{data:x,error:m}=await C(e,{config:{...$,bucket:d},compression:f,onError:w});m&&o(m);let u=B.fromWeb(x.body);if(i){let r=E(i);await b(u,r),console.log(l?JSON.stringify({action:"bundled",bucket:d,keys:e.length,compression:f,output:i}):`Bundled ${e.length} object(s) from '${d}' to ${i}`)}else await b(u,process.stdout),l&&console.error(JSON.stringify({action:"bundled",bucket:d,keys:e.length,compression:f,output:"stdout"}));process.exit(0)}export{N as default};
@@ -1 +1 @@
1
- import{a as K}from"../../chunk-S77OAN6Y.js";import{a as E}from"../../chunk-RS4HZYP3.js";import{b as S}from"../../chunk-S6KFKBMY.js";import{a as m,b as f,d as p}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import{a as u}from"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.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-3QCSRNXC.js";import{b as S}from"../../chunk-S6KFKBMY.js";import{a as m,b as f,d as p}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import{a as u}from"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import{m as y,q as l}from"../../chunk-F4AGJWCK.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 G}from"../chunk-EKW6XTGL.js";import{a as x}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-IRDNZN7R.js";import{a as U,b as C,d as D,f as O,g as j,i as A}from"../chunk-RXNG56FL.js";import{d as K}from"../chunk-RS4HZYP3.js";import{a as T,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as P,get as tt,head as et,list as ot,put as V}from"@tigrisdata/storage";import{createReadStream as it,createWriteStream as nt,existsSync as X,mkdirSync as rt,readdirSync as I,statSync as z}from"fs";import{homedir as at}from"os";import{basename as E,dirname as L,join as v,relative as _,resolve as H}from"path";import{Readable as Y}from"stream";import{pipeline as lt}from"stream/promises";var h=!1;function ct(i,t){let e=U(i),a=U(t);return!e&&!a&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&a?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(at(),i.slice(2)):H(i)}function st(i){return I(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let a=e.parentPath??e.path;return v(a,e.name)})}function pt(i,t){let e=L(i),a=E(i),p=O(a);return X(e)?t?I(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&p.test(r.name)).map(r=>{let l=r.parentPath??r.path;return v(l,r.name)}):I(e,{withFileTypes:!0}).filter(l=>l.isFile()&&p.test(l.name)).map(l=>v(e,l.name)):[]}async function J(i,t,e,a,p=!1,c){let r;try{r=z(i).size}catch{return{error:`File not found: ${i}`}}let l=it(i),n=Y.toWeb(l),o=q(i),{error:s}=await V(e,n,{...G(r),...o?{contentType:o}:{},...c?{access:c}:{},onUploadProgress:p?({loaded:u})=>{if(r!==void 0&&r>0){let d=Math.round(u/r*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(r)} (${d}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...a,bucket:t}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),s?{error:s.message}:{}}async function Q(i,t,e,a,p=!1){let c;if(p){let{data:u}=await et(t,{config:{...a,bucket:i}});c=u?.size}let{data:r,error:l}=await tt(t,"stream",{config:{...a,bucket:i}});if(l)return{error:l.message};let n=L(e);X(n)||rt(n,{recursive:!0});let o=nt(e),s=Y.fromWeb(r);if(p&&c!==void 0&&c>0){let u=0;s.on("data",d=>{u+=d.length;let m=Math.round(u/c*100);process.stdout.write(`\rDownloading: ${R(u)} / ${R(c)} (${m}%)`)})}return await lt(s,o),p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function B(i,t,e,a,p){if(e.endsWith("/")){let{error:r}=await V(p,"",{config:{...i,bucket:a}});return r?{error:r.message}:{}}let{error:c}=await P(e,p,{srcBucket:t,destBucket:a,config:{...i,bucket:a}});return c?{error:c.message}:{}}async function ut(i,t,e,a,p){let c=Z(i);if(i.includes("*")){let n=pt(c,a);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let o=L(c),s=n.map(m=>async()=>{let w=_(o,m),k=t.path?`${t.path.replace(/\/$/,"")}/${w}`:w,b=await J(m,t.bucket,k,e,!1,p);return b.error?(console.error(`Failed to upload ${m}: ${b.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`);return}let l;try{l=z(c)}catch{f(`Source not found: ${i}`)}if(l.isDirectory()){a||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let n=st(c);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let o=i.endsWith("/")?"":E(c),s=n.map(m=>async()=>{let w=_(c,m),b=[t.path?.replace(/\/$/,""),o,w].filter(Boolean).join("/"),y=await J(m,t.bucket,b,e,!1,p);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${b}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`)}else{let n=E(c),o;t.path?i.endsWith("/")||t.path.endsWith("/")?o=`${t.path.replace(/\/$/,"")}/${n}`:await D(t.bucket,t.path,e)?o=`${t.path}/${n}`:o=t.path:o=n;let s=await J(c,t.bucket,o,e,!h,p);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${o}`}):`Uploaded ${i} -> t3://${t.bucket}/${o}`)}}async function ft(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=Z(e),l=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&c;if(!l&&!n&&(n=await D(t.bucket,t.path,a)),n&&!l&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),l||n){let o=l?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",s=!l&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:d}=await A(t.bucket,o||void 0,a);d&&f(d);let m=u.filter(y=>!y.name.endsWith("/"));if(l){let y=t.path.split("/").pop(),$=O(y);m=m.filter(S=>{let g=o?S.name.slice(o.length):S.name;return!p&&g.includes("/")?!1:$.test(g.split("/").pop())})}if(m.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=m.map(y=>async()=>{let $=o?y.name.slice(o.length):y.name,S=s?v(r,s,$):v(r,$),g=await Q(t.bucket,y.name,S,a);return g.error?(console.error(`Failed to download ${y.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),b=(await x(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:b}):`Downloaded ${b} file(s)`)}else{let o=t.path.split("/").pop(),s,u=!1;try{u=z(r).isDirectory()}catch{}u||e.endsWith("/")?s=v(r,o):s=r;let d=await Q(t.bucket,t.path,s,a,!h);d.error&&f(d.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:s}):`Downloaded t3://${t.bucket}/${t.path} -> ${s}`)}}async function mt(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=i.includes("*"),l=t.path.endsWith("/")||!t.path&&c;if(!r&&!l&&t.path&&(l=await D(t.bucket,t.path,a)),l&&!r&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||l){let n=r?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",o=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),d=u?`${u}/`:"";t.bucket===e.bucket&&n===d&&f("Source and destination are the same");let{items:m,error:w}=await A(t.bucket,n||void 0,a);w&&f(w);let k=m.filter(g=>g.name!==n);if(r){let g=t.path.split("/").pop(),W=O(g);k=k.filter(F=>{let N=n?F.name.slice(n.length):F.name;return!p&&N.includes("/")?!1:W.test(N.split("/").pop())})}let b=k.map(g=>async()=>{let W=n?g.name.slice(n.length):g.name,F=u?`${u}/${W}`:W,N=await B(a,t.bucket,g.name,e.bucket,F);return N.error?(console.error(`Failed to copy ${g.name}: ${N.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${F}`),!0)}),$=(await x(b,8)).filter(Boolean).length,S=!1;if(u&&n){let{data:g}=await ot({prefix:n,limit:1,config:{...a,bucket:t.bucket}});if(g?.items?.some(W=>W.name===n)){let W=`${u}/`,F=await B(a,t.bucket,n,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if($===0&&S&&($=1),$===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:$}):`Copied ${$} object(s)`)}else{let n=t.path.split("/").pop(),o;e.path?e.path.endsWith("/")?o=`${e.path}${n}`:await D(e.bucket,e.path,a)?o=`${e.path}/${n}`:o=e.path:o=n,t.bucket===e.bucket&&t.path===o&&f("Source and destination are the same");let s=await B(a,t.bucket,t.path,e.bucket,o);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${o}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${o}`)}}async function ht(i){let t=T(i,["src"]),e=T(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let a=!!T(i,["recursive","r"]),p=T(i,["access","a","A"]);h=M(i)==="json";let r;p===void 0?r=void 0:p==="public"||p==="private"?r=p:f('Access level must be either "public" or "private"');let l=ct(t,e);r!==void 0&&l!=="local-to-remote"&&f('--access only applies to local-to-remote uploads. Use "tigris objects set-access" to change access on existing objects.');let n=await K({withCredentialProvider:!0});switch(l){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await ut(t,o,n,a,r);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await ft(t,o,e,n,a);break}case"remote-to-remote":{let o=C(t),s=C(e);o.bucket||f("Invalid source path"),s.bucket||f("Invalid destination path"),await mt(t,o,s,n,a);break}}process.exit(0)}export{ht as default};
1
+ import{a as G}from"../chunk-EKW6XTGL.js";import{a as x}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-AFM3TY2D.js";import{a as U,b as C,d as D,f as O,g as j,i as A}from"../chunk-7ZCVOA6A.js";import{d as K}from"../chunk-3QCSRNXC.js";import{a as N,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-SE5TRZWU.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-ATBINUDP.js";import"../chunk-VNUR4TRP.js";import"../chunk-F4AGJWCK.js";import{createReadStream as P,createWriteStream as tt,existsSync as V,mkdirSync as et,readdirSync as I,statSync as z}from"fs";import{homedir as ot}from"os";import{basename as E,dirname as L,join as v,relative as _,resolve as H}from"path";import{Readable as X}from"stream";import{pipeline as it}from"stream/promises";import{copy as nt,get as rt,head as at,list as lt,put as Y}from"@tigrisdata/storage";var h=!1;function ct(i,t){let e=U(i),a=U(t);return!e&&!a&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&a?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(ot(),i.slice(2)):H(i)}function st(i){return I(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let a=e.parentPath??e.path;return v(a,e.name)})}function pt(i,t){let e=L(i),a=E(i),p=O(a);return V(e)?t?I(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&p.test(r.name)).map(r=>{let l=r.parentPath??r.path;return v(l,r.name)}):I(e,{withFileTypes:!0}).filter(l=>l.isFile()&&p.test(l.name)).map(l=>v(e,l.name)):[]}async function J(i,t,e,a,p=!1,c){let r;try{r=z(i).size}catch{return{error:`File not found: ${i}`}}let l=P(i),n=X.toWeb(l),o=q(i),{error:s}=await Y(e,n,{...G(r),...o?{contentType:o}:{},...c?{access:c}:{},onUploadProgress:p?({loaded:u})=>{if(r!==void 0&&r>0){let d=Math.round(u/r*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(r)} (${d}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...a,bucket:t}});return p&&process.stdout.write(`\r${" ".repeat(60)}\r`),s?{error:s.message}:{}}async function Q(i,t,e,a,p=!1){let c;if(p){let{data:u}=await at(t,{config:{...a,bucket:i}});c=u?.size}let{data:r,error:l}=await rt(t,"stream",{config:{...a,bucket:i}});if(l)return{error:l.message};let n=L(e);V(n)||et(n,{recursive:!0});let o=tt(e),s=X.fromWeb(r);if(p&&c!==void 0&&c>0){let u=0;s.on("data",d=>{u+=d.length;let m=Math.round(u/c*100);process.stdout.write(`\rDownloading: ${R(u)} / ${R(c)} (${m}%)`)})}return await it(s,o),p&&process.stdout.write(`\r${" ".repeat(60)}\r`),{}}async function B(i,t,e,a,p){if(e.endsWith("/")){let{error:r}=await Y(p,"",{config:{...i,bucket:a}});return r?{error:r.message}:{}}let{error:c}=await nt(e,p,{srcBucket:t,destBucket:a,config:{...i,bucket:a}});return c?{error:c.message}:{}}async function ut(i,t,e,a,p){let c=Z(i);if(i.includes("*")){let n=pt(c,a);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let o=L(c),s=n.map(m=>async()=>{let w=_(o,m),k=t.path?`${t.path.replace(/\/$/,"")}/${w}`:w,b=await J(m,t.bucket,k,e,!1,p);return b.error?(console.error(`Failed to upload ${m}: ${b.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`);return}let l;try{l=z(c)}catch{f(`Source not found: ${i}`)}if(l.isDirectory()){a||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let n=st(c);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let o=i.endsWith("/")?"":E(c),s=n.map(m=>async()=>{let w=_(c,m),b=[t.path?.replace(/\/$/,""),o,w].filter(Boolean).join("/"),y=await J(m,t.bucket,b,e,!1,p);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${b}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`)}else{let n=E(c),o;t.path?i.endsWith("/")||t.path.endsWith("/")?o=`${t.path.replace(/\/$/,"")}/${n}`:await D(t.bucket,t.path,e)?o=`${t.path}/${n}`:o=t.path:o=n;let s=await J(c,t.bucket,o,e,!h,p);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${o}`}):`Uploaded ${i} -> t3://${t.bucket}/${o}`)}}async function ft(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=Z(e),l=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&c;if(!l&&!n&&(n=await D(t.bucket,t.path,a)),n&&!l&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),l||n){let o=l?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",s=!l&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:d}=await A(t.bucket,o||void 0,a);d&&f(d);let m=u.filter(y=>!y.name.endsWith("/"));if(l){let y=t.path.split("/").pop(),$=O(y);m=m.filter(S=>{let g=o?S.name.slice(o.length):S.name;return!p&&g.includes("/")?!1:$.test(g.split("/").pop())})}if(m.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=m.map(y=>async()=>{let $=o?y.name.slice(o.length):y.name,S=s?v(r,s,$):v(r,$),g=await Q(t.bucket,y.name,S,a);return g.error?(console.error(`Failed to download ${y.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),b=(await x(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:b}):`Downloaded ${b} file(s)`)}else{let o=t.path.split("/").pop(),s,u=!1;try{u=z(r).isDirectory()}catch{}u||e.endsWith("/")?s=v(r,o):s=r;let d=await Q(t.bucket,t.path,s,a,!h);d.error&&f(d.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:s}):`Downloaded t3://${t.bucket}/${t.path} -> ${s}`)}}async function mt(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=i.includes("*"),l=t.path.endsWith("/")||!t.path&&c;if(!r&&!l&&t.path&&(l=await D(t.bucket,t.path,a)),l&&!r&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||l){let n=r?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",o=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),d=u?`${u}/`:"";t.bucket===e.bucket&&n===d&&f("Source and destination are the same");let{items:m,error:w}=await A(t.bucket,n||void 0,a);w&&f(w);let k=m.filter(g=>g.name!==n);if(r){let g=t.path.split("/").pop(),W=O(g);k=k.filter(F=>{let T=n?F.name.slice(n.length):F.name;return!p&&T.includes("/")?!1:W.test(T.split("/").pop())})}let b=k.map(g=>async()=>{let W=n?g.name.slice(n.length):g.name,F=u?`${u}/${W}`:W,T=await B(a,t.bucket,g.name,e.bucket,F);return T.error?(console.error(`Failed to copy ${g.name}: ${T.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${F}`),!0)}),$=(await x(b,8)).filter(Boolean).length,S=!1;if(u&&n){let{data:g}=await lt({prefix:n,limit:1,config:{...a,bucket:t.bucket}});if(g?.items?.some(W=>W.name===n)){let W=`${u}/`,F=await B(a,t.bucket,n,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if($===0&&S&&($=1),$===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:$}):`Copied ${$} object(s)`)}else{let n=t.path.split("/").pop(),o;e.path?e.path.endsWith("/")?o=`${e.path}${n}`:await D(e.bucket,e.path,a)?o=`${e.path}/${n}`:o=e.path:o=n,t.bucket===e.bucket&&t.path===o&&f("Source and destination are the same");let s=await B(a,t.bucket,t.path,e.bucket,o);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${o}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${o}`)}}async function ht(i){let t=N(i,["src"]),e=N(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let a=!!N(i,["recursive","r"]),p=N(i,["access","a","A"]);h=M(i)==="json";let r;p===void 0?r=void 0:p==="public"||p==="private"?r=p:f('Access level must be either "public" or "private"');let l=ct(t,e);r!==void 0&&l!=="local-to-remote"&&f('--access only applies to local-to-remote uploads. Use "tigris objects set-access" to change access on existing objects.');let n=await K({withCredentialProvider:!0});switch(l){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await ut(t,o,n,a,r);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await ft(t,o,e,n,a);break}case"remote-to-remote":{let o=C(t),s=C(e);o.bucket||f("Invalid source path"),s.bucket||f("Invalid destination path"),await mt(t,o,s,n,a);break}}process.exit(0)}export{ht as default};
@@ -1 +1 @@
1
- import{e as k}from"../../chunk-RS4HZYP3.js";import{a as d,b as m}from"../../chunk-S6KFKBMY.js";import{a as s,b as u}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as f,d as r,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.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-3QCSRNXC.js";import{a as d,b as m}from"../../chunk-S6KFKBMY.js";import{a as s,b as u}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as f,d as r,j as g}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.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{a as y}from"../../../chunk-TUDALPGD.js";import{a as g}from"../../../chunk-VQDOL2GU.js";import"../../../chunk-RS4HZYP3.js";import{a as c,b as u,e as p}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as l,j as f}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as 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 g(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 p();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 y}from"../../../chunk-TUDALPGD.js";import{a as g}from"../../../chunk-CL4GEWT2.js";import"../../../chunk-3QCSRNXC.js";import{a as c,b as u,e as p}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as l,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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 g(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 p();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 u}from"../../../chunk-S7EO4QWK.js";import{a as g}from"../../../chunk-VQDOL2GU.js";import{a as l,b as p}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as i,b as d}from"../../../chunk-S6KFKBMY.js";import{b as a}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as s,j as m}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{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
+ import{a as u}from"../../../chunk-JLNCN27M.js";import{a as g}from"../../../chunk-CL4GEWT2.js";import{a as l,b as p}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as i,b as d}from"../../../chunk-S6KFKBMY.js";import{b as a}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as s,j as m}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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}from"../../../chunk-TUDALPGD.js";import{a as J}from"../../../chunk-S7EO4QWK.js";import{a as h}from"../../../chunk-VQDOL2GU.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
1
+ import{a}from"../../../chunk-TUDALPGD.js";import{a as J}from"../../../chunk-JLNCN27M.js";import{a as h}from"../../../chunk-CL4GEWT2.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
@@ -1 +1 @@
1
- import{a as y}from"../../../chunk-S7EO4QWK.js";import{a as g}from"../../../chunk-VQDOL2GU.js";import{f as p}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as m,b as d}from"../../../chunk-S6KFKBMY.js";import{b as u}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,j as f}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{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};
1
+ import{a as y}from"../../../chunk-JLNCN27M.js";import{a as g}from"../../../chunk-CL4GEWT2.js";import{f as p}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as m,b as d}from"../../../chunk-S6KFKBMY.js";import{b as u}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-S7EO4QWK.js";import{a as k}from"../../../chunk-VQDOL2GU.js";import{a as g}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as l,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as y,j as p}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import 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};
1
+ import{a as h}from"../../../chunk-JLNCN27M.js";import{a as k}from"../../../chunk-CL4GEWT2.js";import{a as g}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as l,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as y,j as p}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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};
@@ -1 +1 @@
1
- import{a as k}from"../../../chunk-S7EO4QWK.js";import{a as y}from"../../../chunk-VQDOL2GU.js";import{f as d}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as p,b as g}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as a,e as f,j as u}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{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
+ import{a as k}from"../../../chunk-JLNCN27M.js";import{a as y}from"../../../chunk-CL4GEWT2.js";import{f as d}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as p,b as g}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as a,e as f,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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-VQDOL2GU.js";import{g as y}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-RS4HZYP3.js";import{b as l,c as T}from"../../../chunk-S6KFKBMY.js";import{b as k}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as u,e as g,i as f,j as h}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{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};
1
+ import{a as x}from"../../../chunk-CL4GEWT2.js";import{g as y}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-3QCSRNXC.js";import{b as l,c as T}from"../../../chunk-S6KFKBMY.js";import{b as k}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as u,e as g,i as f,j as h}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-S7EO4QWK.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";export{a as selectPolicy};
1
+ import{a}from"../../../chunk-JLNCN27M.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";export{a as selectPolicy};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-S7EO4QWK.js";import{a as k}from"../../../chunk-VQDOL2GU.js";import{a as f,b as d}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as c}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as y,c as p,j as g}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import $ 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
+ import{a as h}from"../../../chunk-JLNCN27M.js";import{a as k}from"../../../chunk-CL4GEWT2.js";import{a as f,b as d}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as c}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as y,c as p,j as g}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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 b}from"../../../chunk-2ITYREA5.js";import{a as l}from"../../../chunk-VQDOL2GU.js";import"../../../chunk-RS4HZYP3.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as g,j as d}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as p}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{createTeam as y}from"@tigrisdata/iam";var t=d("iam teams","create");async function O(e){f(t);let I=u(e);if(p("Team management"))return;let r=n(e,["name"]),i=n(e,["description","d"]),a=typeof i=="string"?i:void 0,m=b(t,n(e,["members","m"]));r||o(t,"Team name is required");let w=await l(t),{data:s,error:c}=await y({name:r,...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:w});if(c&&o(t,c),I==="json"){console.log(JSON.stringify({action:"created",teamId:s.teamId,name:r}));return}g(t,{name:r}),console.log(`Team ID: ${s.teamId}`)}export{O as default};
1
+ import{a as b}from"../../../chunk-KJA757WE.js";import{a as l}from"../../../chunk-CL4GEWT2.js";import"../../../chunk-3QCSRNXC.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as g,j as d}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as p}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{createTeam as y}from"@tigrisdata/iam";var t=d("iam teams","create");async function O(e){f(t);let I=u(e);if(p("Team management"))return;let r=n(e,["name"]),i=n(e,["description","d"]),a=typeof i=="string"?i:void 0,m=b(t,n(e,["members","m"]));r||o(t,"Team name is required");let w=await l(t),{data:s,error:c}=await y({name:r,...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:w});if(c&&o(t,c),I==="json"){console.log(JSON.stringify({action:"created",teamId:s.teamId,name:r}));return}g(t,{name:r}),console.log(`Team ID: ${s.teamId}`)}export{O as default};
@@ -1 +1 @@
1
- import{a as w}from"../../../chunk-2ITYREA5.js";import{a as b}from"../../../chunk-VQDOL2GU.js";import"../../../chunk-RS4HZYP3.js";import{a as t,b as l}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as g,j as u}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as p}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{editTeam as I}from"@tigrisdata/iam";var e=u("iam teams","edit");async function R(n){c(e);let y=l(n);if(p("Team management"))return;let i=t(n,["id"]);i||o(e,"Team ID is required");let s=t(n,["name","n"]),r=typeof s=="string"?s:void 0,d=t(n,["description","d"]),a=typeof d=="string"?d:void 0,m=w(e,t(n,["members","m"]));r===void 0&&a===void 0&&m===void 0&&o(e,"Provide at least one of --name, --description, or --members to update");let O=await b(e),{error:f}=await I(i,{...r!==void 0?{name:r}:{},...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:O});f&&o(e,f),y==="json"&&console.log(JSON.stringify({action:"updated",teamId:i})),g(e,{id:i})}export{R as default};
1
+ import{a as w}from"../../../chunk-KJA757WE.js";import{a as b}from"../../../chunk-CL4GEWT2.js";import"../../../chunk-3QCSRNXC.js";import{a as t,b as l}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as g,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as p}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{editTeam as I}from"@tigrisdata/iam";var e=u("iam teams","edit");async function R(n){c(e);let y=l(n);if(p("Team management"))return;let i=t(n,["id"]);i||o(e,"Team ID is required");let s=t(n,["name","n"]),r=typeof s=="string"?s:void 0,d=t(n,["description","d"]),a=typeof d=="string"?d:void 0,m=w(e,t(n,["members","m"]));r===void 0&&a===void 0&&m===void 0&&o(e,"Provide at least one of --name, --description, or --members to update");let O=await b(e),{error:f}=await I(i,{...r!==void 0?{name:r}:{},...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:O});f&&o(e,f),y==="json"&&console.log(JSON.stringify({action:"updated",teamId:i})),g(e,{id:i})}export{R as default};
@@ -1 +1 @@
1
- import{a as p}from"../../../chunk-VQDOL2GU.js";import{b as g,d as u,e as h}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-RS4HZYP3.js";import{b as d}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,e as s,j as c}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as f}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{listTeams as k}from"@tigrisdata/iam";var t=c("iam teams","list");async function C(y){a(t);let r=d(y);if(f("Team management"))return;let b=await p(t),{data:o,error:m}=await k({config:b});if(m&&l(t,m),o.teams.length===0){s(t);return}let n=o.teams.map(e=>({id:e.id,name:e.name,description:e.description||"-",members:e.members.length,created:e.createdAt}));console.log(r==="json"?g({teams:o.teams}):r==="xml"?u(n,"teams","team"):h(n,[{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"members",header:"Members"},{key:"created",header:"Created"}])),i(t,{count:o.teams.length})}export{C as default};
1
+ import{a as p}from"../../../chunk-CL4GEWT2.js";import{b as g,d as u,e as h}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-3QCSRNXC.js";import{b as d}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,e as s,j as c}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as f}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listTeams as k}from"@tigrisdata/iam";var t=c("iam teams","list");async function C(y){a(t);let r=d(y);if(f("Team management"))return;let b=await p(t),{data:o,error:m}=await k({config:b});if(m&&l(t,m),o.teams.length===0){s(t);return}let n=o.teams.map(e=>({id:e.id,name:e.name,description:e.description||"-",members:e.members.length,created:e.createdAt}));console.log(r==="json"?g({teams:o.teams}):r==="xml"?u(n,"teams","team"):h(n,[{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"members",header:"Members"},{key:"created",header:"Created"}])),i(t,{count:o.teams.length})}export{C as default};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-2ITYREA5.js";import"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";export{a as parseMembers};
1
+ import{a}from"../../../chunk-KJA757WE.js";import"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";export{a as parseMembers};
@@ -1 +1 @@
1
- import{a as u}from"../../../chunk-VQDOL2GU.js";import"../../../chunk-RS4HZYP3.js";import{a as s,b as p}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c,j as f}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.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-CL4GEWT2.js";import"../../../chunk-3QCSRNXC.js";import{a as s,b as p}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as g}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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,5 +1,5 @@
1
- import{a as p}from"../../../chunk-VQDOL2GU.js";import{b as y,d as i,e as a}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-RS4HZYP3.js";import{b as h}from"../../../chunk-S6KFKBMY.js";import{b as d}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as g,e as c,j as u}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as f}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{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
- `)),e.push(" "+i(t,"invitations","invitation").replace(/\n/g,`
1
+ import{a as p}from"../../../chunk-CL4GEWT2.js";import{b as y,d as i,e as a}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-3QCSRNXC.js";import{b as h}from"../../../chunk-S6KFKBMY.js";import{b as d}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as g,e as c,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as f}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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
+ `)}`),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(`
5
5
  Members`),console.log(a(o,I))),t.length>0&&(console.log("Pending Invitations"),console.log(a(t,U)));let b=o.length+t.length;g(n,{count:b})}export{w as default};
@@ -1 +1 @@
1
- import{a as O}from"../../../chunk-VQDOL2GU.js";import{a,b as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as m,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c as u,e as p,j as d}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.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-CL4GEWT2.js";import{a,b as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as m,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c as u,e as p,j as d}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as y}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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-VQDOL2GU.js";import{a,b as y}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as c,b as k}from"../../../chunk-S6KFKBMY.js";import{b as s}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as p,e as u,j as v}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.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-CL4GEWT2.js";import{a,b as y}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as c,b as k}from"../../../chunk-S6KFKBMY.js";import{b as s}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as p,e as u,j as v}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as d}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.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 +1 @@
1
- import{a as v}from"../../../chunk-VQDOL2GU.js";import{a as w}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-RS4HZYP3.js";import{a as c,b}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as h,e as y,j as R}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import{a as O}from"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import I from"enquirer";import{listUsers as S,updateUserRole as q}from"@tigrisdata/iam";var{prompt:U}=I,e=R("iam users","update-role");async function E(m){d(e);let A=b(m);if(O("User management"))return;let f=["admin","member"],i=c(m,["role","r"]);i||o(e,"Role is required. Use --role admin or --role member");let r=Array.isArray(i)?i:[i];for(let t of r)f.includes(t)||o(e,`Invalid role "${t}". Must be one of: ${f.join(", ")}`);let n=c(m,["resource"]),s=Array.isArray(n)?n:n?[n]:[],u=await v(e);if(s.length===0){let{data:t,error:a}=await S({config:u});if(a&&o(e,a),t.users.length===0){y(e);return}w("Provide user ID(s) as a positional argument");let{selected:$}=await U({type:"multiselect",name:"selected",message:"Select user(s) to update (space to select, enter to confirm):",choices:t.users.map(l=>({name:l.userId,message:`${l.email} (${l.isOrgOwner?"owner":l.role})`}))});s=$}r.length>1&&r.length!==s.length&&o(e,`Number of roles (${r.length}) must match number of users (${s.length}), or provide a single role for all users`);let g=s.map((t,a)=>({userId:t,role:r.length===1?r[0]:r[a]})),{error:p}=await q(g,{config:u});p&&o(e,p),A==="json"&&console.log(JSON.stringify({action:"updated",users:g})),h(e)}export{E as default};
1
+ import{a as v}from"../../../chunk-CL4GEWT2.js";import{a as w}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-3QCSRNXC.js";import{a as c,b}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-SE5TRZWU.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as h,e as y,j as R}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-VNUR4TRP.js";import{a as O}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{listUsers as S,updateUserRole as q}from"@tigrisdata/iam";var{prompt:U}=I,e=R("iam users","update-role");async function E(m){d(e);let A=b(m);if(O("User management"))return;let f=["admin","member"],i=c(m,["role","r"]);i||o(e,"Role is required. Use --role admin or --role member");let r=Array.isArray(i)?i:[i];for(let t of r)f.includes(t)||o(e,`Invalid role "${t}". Must be one of: ${f.join(", ")}`);let n=c(m,["resource"]),s=Array.isArray(n)?n:n?[n]:[],u=await v(e);if(s.length===0){let{data:t,error:a}=await S({config:u});if(a&&o(e,a),t.users.length===0){y(e);return}w("Provide user ID(s) as a positional argument");let{selected:$}=await U({type:"multiselect",name:"selected",message:"Select user(s) to update (space to select, enter to confirm):",choices:t.users.map(l=>({name:l.userId,message:`${l.email} (${l.isOrgOwner?"owner":l.role})`}))});s=$}r.length>1&&r.length!==s.length&&o(e,`Number of roles (${r.length}) must match number of users (${s.length}), or provide a single role for all users`);let g=s.map((t,a)=>({userId:t,role:r.length===1?r[0]:r[a]})),{error:p}=await q(g,{config:u});p&&o(e,p),A==="json"&&console.log(JSON.stringify({action:"updated",users:g})),h(e)}export{E as default};
@@ -1 +1 @@
1
- import{a}from"../../chunk-2GLKQBPM.js";import"../../chunk-S77OAN6Y.js";import"../../chunk-RS4HZYP3.js";import"../../chunk-S6KFKBMY.js";import"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";export{a as default};
1
+ import{a}from"../../chunk-W52B2I2N.js";import"../../chunk-S77OAN6Y.js";import"../../chunk-3QCSRNXC.js";import"../../chunk-S6KFKBMY.js";import"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";export{a as default};
@@ -1 +1 @@
1
- import{a,b}from"../../chunk-KQTMMFPE.js";import"../../chunk-S6KFKBMY.js";import"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";export{b as default,a as oauth};
1
+ import{a,b}from"../../chunk-76L56E5U.js";import"../../chunk-S6KFKBMY.js";import"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";export{b as default,a as oauth};
@@ -1 +1 @@
1
- import{a as r}from"../../chunk-KQTMMFPE.js";import{a as c}from"../../chunk-2GLKQBPM.js";import{a as s}from"../../chunk-S77OAN6Y.js";import"../../chunk-RS4HZYP3.js";import"../../chunk-S6KFKBMY.js";import"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import i from"enquirer";var{prompt:n}=i;async function u(e){let a=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,t=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(a||t){await c(e);return}s('Use "tigris login oauth" or "tigris login credentials --access-key ... --access-secret ..."');let{method:m}=await n({type:"select",name:"method",message:"Choose login method:",choices:[{name:"user",message:"As a user (OAuth2 flow)"},{name:"machine",message:"As a machine (Access Key & Secret)"}]});m==="user"?await r():await c(e)}export{u as default};
1
+ import{a as r}from"../../chunk-76L56E5U.js";import{a as c}from"../../chunk-W52B2I2N.js";import{a as s}from"../../chunk-S77OAN6Y.js";import"../../chunk-3QCSRNXC.js";import"../../chunk-S6KFKBMY.js";import"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import i from"enquirer";var{prompt:n}=i;async function u(e){let a=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,t=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(a||t){await c(e);return}s('Use "tigris login oauth" or "tigris login credentials --access-key ... --access-secret ..."');let{method:m}=await n({type:"select",name:"method",message:"Choose login method:",choices:[{name:"user",message:"As a user (OAuth2 flow)"},{name:"machine",message:"As a machine (Access Key & Secret)"}]});m==="user"?await r():await c(e)}export{u as default};
@@ -1 +1 @@
1
- import{b as c}from"../chunk-S6KFKBMY.js";import{b as n}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as t,c as r,j as i}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import{t as a}from"../chunk-OHGCOC5Q.js";var o=i("logout");async function f(m={}){t(o);let e=c(m);try{await a(),e==="json"&&console.log(JSON.stringify({action:"logged_out"})),r(o)}catch(s){n(o,s)}}export{f as default};
1
+ import{b as c}from"../chunk-S6KFKBMY.js";import{b as n}from"../chunk-SE5TRZWU.js";import"../chunk-DV3LCXRH.js";import{b as t,c as r,j as i}from"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import{t as a}from"../chunk-F4AGJWCK.js";var o=i("logout");async function f(m={}){t(o);let e=c(m);try{await a(),e==="json"&&console.log(JSON.stringify({action:"logged_out"})),r(o)}catch(s){n(o,s)}}export{f as default};
package/dist/lib/ls.js CHANGED
@@ -1 +1 @@
1
- import{a as P,g}from"../chunk-IRDNZN7R.js";import{e as N}from"../chunk-RXNG56FL.js";import{d as p}from"../chunk-RS4HZYP3.js";import{a as d,b as z,c as j}from"../chunk-S6KFKBMY.js";import{a as c}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{i as f}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{list as D,listBuckets as E}from"@tigrisdata/storage";async function F(n){let l=d(n,["path"]),u=d(n,["snapshot-version","snapshotVersion","snapshot"]),t=z(n),k=d(n,["source"]),{limit:i,pageToken:a}=j(n);if(!l){let e=await p(),{data:r,error:x}=await E({...i!==void 0?{limit:i}:{},...a?{paginationToken:a}:{},config:e});x&&c(x);let W=(r.buckets||[]).map(w=>({name:w.name,created:w.creationDate})),A=[{key:"name",header:"Name"},{key:"created",header:"Created"}],b=r.paginationToken||void 0,B=g(W,t,"buckets","bucket",A,{paginationToken:b});console.log(B),t!=="json"&&t!=="xml"&&f(b);return}let{bucket:h,path:s}=N(l);h||c("Invalid path");let S=await p(),o=s?s.endsWith("/")?s:`${s}/`:void 0,{data:m,error:y}=await D({prefix:o,delimiter:"/",...u?{snapshotVersion:u}:{},...k?{source:k}:{},...i!==void 0?{limit:i}:{},...a?{paginationToken:a}:{},config:{...S,bucket:h}});y&&c(y);let O=(m.commonPrefixes||[]).map(e=>({key:o?e.slice(o.length):e,size:"-",modified:""})),v=(m.items||[]).map(e=>({key:o?e.name.slice(o.length):e.name,size:P(e.size),modified:e.lastModified})).filter(e=>e.key!==""),C=[...O,...v],M=[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}],T=m.paginationToken||void 0,V=g(C,t,"objects","object",M,{paginationToken:T});console.log(V),t!=="json"&&t!=="xml"&&f(T)}export{F as default};
1
+ import{a as P,g}from"../chunk-AFM3TY2D.js";import{e as N}from"../chunk-7ZCVOA6A.js";import{d as p}from"../chunk-3QCSRNXC.js";import{a as d,b as z,c as j}from"../chunk-S6KFKBMY.js";import{a as c}from"../chunk-SE5TRZWU.js";import"../chunk-DV3LCXRH.js";import{i as f}from"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-ATBINUDP.js";import"../chunk-VNUR4TRP.js";import"../chunk-F4AGJWCK.js";import{list as D,listBuckets as E}from"@tigrisdata/storage";async function F(n){let l=d(n,["path"]),u=d(n,["snapshot-version","snapshotVersion","snapshot"]),t=z(n),k=d(n,["source"]),{limit:i,pageToken:a}=j(n);if(!l){let e=await p(),{data:r,error:x}=await E({...i!==void 0?{limit:i}:{},...a?{paginationToken:a}:{},config:e});x&&c(x);let W=(r.buckets||[]).map(w=>({name:w.name,created:w.creationDate})),A=[{key:"name",header:"Name"},{key:"created",header:"Created"}],b=r.paginationToken||void 0,B=g(W,t,"buckets","bucket",A,{paginationToken:b});console.log(B),t!=="json"&&t!=="xml"&&f(b);return}let{bucket:h,path:s}=N(l);h||c("Invalid path");let S=await p(),o=s?s.endsWith("/")?s:`${s}/`:void 0,{data:m,error:y}=await D({prefix:o,delimiter:"/",...u?{snapshotVersion:u}:{},...k?{source:k}:{},...i!==void 0?{limit:i}:{},...a?{paginationToken:a}:{},config:{...S,bucket:h}});y&&c(y);let O=(m.commonPrefixes||[]).map(e=>({key:o?e.slice(o.length):e,size:"-",modified:""})),v=(m.items||[]).map(e=>({key:o?e.name.slice(o.length):e.name,size:P(e.size),modified:e.lastModified})).filter(e=>e.key!==""),C=[...O,...v],M=[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}],T=m.paginationToken||void 0,V=g(C,t,"objects","object",M,{paginationToken:T});console.log(V),t!=="json"&&t!=="xml"&&f(T)}export{F as default};
package/dist/lib/mk.js CHANGED
@@ -1 +1 @@
1
- import{c as m}from"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import{e as h}from"../chunk-RXNG56FL.js";import{d as b}from"../chunk-RS4HZYP3.js";import{a as t,b as p}from"../chunk-S6KFKBMY.js";import{a as r}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{createBucket as O,put as A}from"@tigrisdata/storage";async function j(e){let l=t(e,["path"]);l||r("path argument is required");let{bucket:o,path:a}=h(l);o||r("Invalid path");let f=await b(),u=p(e);if(a){let s=a.endsWith("/")?a:`${a}/`,{error:c}=await A(s,"",{config:{...f,bucket:o}});c&&r(c),console.log(u==="json"?JSON.stringify({action:"created",type:"folder",bucket:o,path:s}):`Folder '${o}/${s}' created`),process.exit(0)}else{let c=t(e,["public"])?"public":t(e,["access","a","A"]),d=t(e,["enableSnapshots","enable-snapshots","s","S"]),S=t(e,["allow-object-acl","allowObjectAcl"]),k=t(e,["enable-directory-listing","enableDirectoryListing"]),y=t(e,["defaultTier","default-tier","t","T"]),w=t(e,["locations","l","L"]),n=t(e,["fork-of","forkOf","fork"]),i=t(e,["source-snapshot","sourceSnapshot","source-snap"]);i&&!n&&r("--source-snapshot requires --fork-of");let{error:g}=await O(o,{defaultTier:y??"STANDARD",enableSnapshot:d===!0,allowObjectAcl:S===!0,enableDirectoryListing:k===!0,access:c??"private",locations:m(w??"global"),...n?{sourceBucketName:n}:{},...i?{sourceBucketSnapshot:i}:{},config:f});g&&r(g),console.log(u==="json"?JSON.stringify({action:"created",type:"bucket",name:o}):`Bucket '${o}' created`),process.exit(0)}}export{j as default};
1
+ import{c as m}from"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import{e as h}from"../chunk-7ZCVOA6A.js";import{d as b}from"../chunk-3QCSRNXC.js";import{a as t,b as p}from"../chunk-S6KFKBMY.js";import{a as r}from"../chunk-SE5TRZWU.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-ATBINUDP.js";import"../chunk-VNUR4TRP.js";import"../chunk-F4AGJWCK.js";import{createBucket as O,put as A}from"@tigrisdata/storage";async function j(e){let l=t(e,["path"]);l||r("path argument is required");let{bucket:o,path:a}=h(l);o||r("Invalid path");let f=await b(),u=p(e);if(a){let s=a.endsWith("/")?a:`${a}/`,{error:c}=await A(s,"",{config:{...f,bucket:o}});c&&r(c),console.log(u==="json"?JSON.stringify({action:"created",type:"folder",bucket:o,path:s}):`Folder '${o}/${s}' created`),process.exit(0)}else{let c=t(e,["public"])?"public":t(e,["access","a","A"]),d=t(e,["enableSnapshots","enable-snapshots","s","S"]),S=t(e,["allow-object-acl","allowObjectAcl"]),k=t(e,["enable-directory-listing","enableDirectoryListing"]),y=t(e,["defaultTier","default-tier","t","T"]),w=t(e,["locations","l","L"]),n=t(e,["fork-of","forkOf","fork"]),i=t(e,["source-snapshot","sourceSnapshot","source-snap"]);i&&!n&&r("--source-snapshot requires --fork-of");let{error:g}=await O(o,{defaultTier:y??"STANDARD",enableSnapshot:d===!0,allowObjectAcl:S===!0,enableDirectoryListing:k===!0,access:c??"private",locations:m(w??"global"),...n?{sourceBucketName:n}:{},...i?{sourceBucketSnapshot:i}:{},config:f});g&&r(g),console.log(u==="json"?JSON.stringify({action:"created",type:"bucket",name:o}):`Bucket '${o}' created`),process.exit(0)}}export{j as default};
package/dist/lib/mv.js CHANGED
@@ -1 +1 @@
1
- import{a as x,b as M}from"../chunk-S77OAN6Y.js";import{a as E,b as j,d as R,f as T,g as D,i as J}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-RS4HZYP3.js";import{a as w,b as N}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as G,list as H,move as L,put as Q,remove as C}from"@tigrisdata/storage";var d=!1;async function V(i){let a=w(i,["src"]),c=w(i,["dest"]),m=w(i,["yes","y","force","f"]),p=!!w(i,["recursive","r"]);d=N(i)==="json",(!a||!c)&&s("both src and dest arguments are required"),(!E(a)||!E(c))&&s("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=j(a),t=j(c);e.bucket||s("Invalid source path"),t.bucket||s("Invalid destination path");let g=a.endsWith("/");!e.path&&!g&&s("Cannot move a bucket. Provide a path within the bucket.");let l=await O({withCredentialProvider:!0}),h=e.path.includes("*"),y=e.path.endsWith("/")||!e.path&&g;if(!h&&!y&&e.path&&(y=await R(e.bucket,e.path,l)),y&&!h&&!p&&s("Source is a remote folder (not moved). Use -r to move recursively."),h||y){let r=h?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",n=!h&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",f=[t.path?.replace(/\/$/,"")||"",n].filter(Boolean).join("/"),U=f?`${f}/`:"";e.bucket===t.bucket&&r===U&&s("Source and destination are the same");let{items:q,error:I}=await J(e.bucket,r||void 0,l);I&&s(I);let b=q.filter(o=>o.name!==r);if(h){let o=e.path.split("/").pop(),u=T(o);b=b.filter(k=>{let $=r?k.name.slice(r.length):k.name;return!p&&$.includes("/")?!1:u.test($.split("/").pop())})}let{data:_}=await H({prefix:r,limit:1,config:{...l,bucket:e.bucket}}),S=r?_?.items?.some(o=>o.name===r):!1;if(b.length===0&&!S){console.log(d?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let z=b.length+(S?1:0);if(!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move ${z} object(s)?`))){d||console.log("Aborted");return}let v=0;for(let o of b){let u=r?o.name.slice(r.length):o.name,k=f?`${f}/${u}`:u,$=await A(l,e.bucket,o.name,t.bucket,k);$.error?console.error(`Failed to move ${o.name}: ${$.error}`):(d||console.log(`Moved t3://${e.bucket}/${o.name} -> t3://${t.bucket}/${k}`),v++)}let W=!1;if(S)if(f){let o=`${f}/`,u=await A(l,e.bucket,r,t.bucket,o);u.error?console.error(`Failed to move folder marker: ${u.error}`):W=!0}else{let{error:o}=await C(r,{config:{...l,bucket:e.bucket}});o?console.error(`Failed to remove source folder marker: ${o.message}`):W=!0}v===0&&W&&(v=1),console.log(d?JSON.stringify({action:"moved",count:v}):`Moved ${v} object(s)`)}else{let r=e.path.split("/").pop(),n;if(t.path?t.path.endsWith("/")?n=`${t.path}${r}`:await R(t.bucket,t.path,l)?n=`${t.path}/${r}`:n=t.path:n=r,e.bucket===t.bucket&&e.path===n&&s("Source and destination are the same"),!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){d||console.log("Aborted");return}let F=await A(l,e.bucket,e.path,t.bucket,n);F.error&&s(F.error),console.log(d?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${n}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${n}`)}process.exit(0)}async function A(i,a,c,m,p){if(c.endsWith("/")){let{error:t}=await Q(p,"",{config:{...i,bucket:m}});if(t)return{error:t.message};let{error:g}=await C(c,{config:{...i,bucket:a}});return g?{error:`Copied but failed to delete source: ${g.message}`}:{}}if(a===m){let{error:t}=await L(c,p,{config:{...i,bucket:a}});return t?{error:t.message}:{}}let{error:P}=await G(c,p,{srcBucket:a,destBucket:m,config:{...i,bucket:m}});if(P)return{error:P.message};let{error:e}=await C(c,{config:{...i,bucket:a}});return e?{error:`Copied but failed to delete source: ${e.message}`}:{}}export{V as default};
1
+ import{a as x,b as M}from"../chunk-S77OAN6Y.js";import{a as E,b as j,d as R,f as T,g as D,i as J}from"../chunk-7ZCVOA6A.js";import{d as O}from"../chunk-3QCSRNXC.js";import{a as w,b as N}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-SE5TRZWU.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-ATBINUDP.js";import"../chunk-VNUR4TRP.js";import"../chunk-F4AGJWCK.js";import{copy as G,list as H,move as L,put as Q,remove as C}from"@tigrisdata/storage";var d=!1;async function V(i){let a=w(i,["src"]),c=w(i,["dest"]),m=w(i,["yes","y","force","f"]),p=!!w(i,["recursive","r"]);d=N(i)==="json",(!a||!c)&&s("both src and dest arguments are required"),(!E(a)||!E(c))&&s("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=j(a),t=j(c);e.bucket||s("Invalid source path"),t.bucket||s("Invalid destination path");let g=a.endsWith("/");!e.path&&!g&&s("Cannot move a bucket. Provide a path within the bucket.");let l=await O({withCredentialProvider:!0}),h=e.path.includes("*"),y=e.path.endsWith("/")||!e.path&&g;if(!h&&!y&&e.path&&(y=await R(e.bucket,e.path,l)),y&&!h&&!p&&s("Source is a remote folder (not moved). Use -r to move recursively."),h||y){let r=h?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",n=!h&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",f=[t.path?.replace(/\/$/,"")||"",n].filter(Boolean).join("/"),U=f?`${f}/`:"";e.bucket===t.bucket&&r===U&&s("Source and destination are the same");let{items:q,error:I}=await J(e.bucket,r||void 0,l);I&&s(I);let b=q.filter(o=>o.name!==r);if(h){let o=e.path.split("/").pop(),u=T(o);b=b.filter(k=>{let $=r?k.name.slice(r.length):k.name;return!p&&$.includes("/")?!1:u.test($.split("/").pop())})}let{data:_}=await H({prefix:r,limit:1,config:{...l,bucket:e.bucket}}),S=r?_?.items?.some(o=>o.name===r):!1;if(b.length===0&&!S){console.log(d?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let z=b.length+(S?1:0);if(!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move ${z} object(s)?`))){d||console.log("Aborted");return}let v=0;for(let o of b){let u=r?o.name.slice(r.length):o.name,k=f?`${f}/${u}`:u,$=await A(l,e.bucket,o.name,t.bucket,k);$.error?console.error(`Failed to move ${o.name}: ${$.error}`):(d||console.log(`Moved t3://${e.bucket}/${o.name} -> t3://${t.bucket}/${k}`),v++)}let W=!1;if(S)if(f){let o=`${f}/`,u=await A(l,e.bucket,r,t.bucket,o);u.error?console.error(`Failed to move folder marker: ${u.error}`):W=!0}else{let{error:o}=await C(r,{config:{...l,bucket:e.bucket}});o?console.error(`Failed to remove source folder marker: ${o.message}`):W=!0}v===0&&W&&(v=1),console.log(d?JSON.stringify({action:"moved",count:v}):`Moved ${v} object(s)`)}else{let r=e.path.split("/").pop(),n;if(t.path?t.path.endsWith("/")?n=`${t.path}${r}`:await R(t.bucket,t.path,l)?n=`${t.path}/${r}`:n=t.path:n=r,e.bucket===t.bucket&&e.path===n&&s("Source and destination are the same"),!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){d||console.log("Aborted");return}let F=await A(l,e.bucket,e.path,t.bucket,n);F.error&&s(F.error),console.log(d?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${n}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${n}`)}process.exit(0)}async function A(i,a,c,m,p){if(c.endsWith("/")){let{error:t}=await Q(p,"",{config:{...i,bucket:m}});if(t)return{error:t.message};let{error:g}=await C(c,{config:{...i,bucket:a}});return g?{error:`Copied but failed to delete source: ${g.message}`}:{}}if(a===m){let{error:t}=await L(c,p,{config:{...i,bucket:a}});return t?{error:t.message}:{}}let{error:P}=await G(c,p,{srcBucket:a,destBucket:m,config:{...i,bucket:m}});if(P)return{error:P.message};let{error:e}=await C(c,{config:{...i,bucket:a}});return e?{error:`Copied but failed to delete source: ${e.message}`}:{}}export{V as default};
@@ -1 +1 @@
1
- import{a as V,b as N}from"../../chunk-S77OAN6Y.js";import{h as C}from"../../chunk-RXNG56FL.js";import{d as q}from"../../chunk-RS4HZYP3.js";import{a as d,b as T}from"../../chunk-S6KFKBMY.js";import{a as w,b as o,c as O,d as S}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as $,d as j,j as M}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listVersions as H,remove as R}from"@tigrisdata/storage";var r=M("objects","delete");async function W(c){A(r);let K=T(c),b=d(c,["bucket"]),E=d(c,["key"]),F=d(c,["yes","y","force"]),a=d(c,["version-id","versionId"]),u=!!d(c,["all-versions","allVersions"]);b||o(r,"Bucket name or path is required"),a&&u&&o(r,"Cannot use --version-id with --all-versions");let h=C(b),s=h.bucket,m=E||h.key||void 0;m||o(r,"Object key is required");let I={...await q(),bucket:s},n=Array.isArray(m)?m:[m];a&&n.length>1&&o(r,"--version-id targets a single object; pass exactly one key");let f=[];if(u)for(let e of n){let t=0,g,v,p=!1;for(;;){let{data:l,error:x}=await H({prefix:e,...g?{keyMarker:g}:{},...v?{versionIdMarker:v}:{},config:I});x&&o(r,x);for(let i of l.versions)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);for(let i of l.deleteMarkers)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);if(p||!l.hasMore)break;l.nextKeyMarker||o(r,`listVersions reported more pages but no nextKeyMarker for key '${e}'`),g=l.nextKeyMarker,v=l.nextVersionIdMarker}t===0&&o(r,`No versions or delete markers found for key '${e}'`)}else if(a)f.push({key:n[0],versionId:a});else for(let e of n)f.push({key:e});if(!F){V("Use --yes to skip confirmation");let e=u?`Hard-delete ${f.length} version(s) and delete marker(s) for ${n.length} object(s) from '${s}'?`:a?`Hard-delete version '${a}' of '${n[0]}' from '${s}'?`:`Delete ${n.length} object(s) from '${s}'?`;if(!await N(e)){console.log("Aborted");return}}let y=[],k=[];for(let e of f){let{error:t}=await R(e.key,{...e.versionId?{versionId:e.versionId}:{},config:I});t?(j(r,t.message,e),k.push({...e,error:t.message})):(y.push(e),$(r,e))}if(K==="json"){let e=O(r,{bucket:s}),t={action:"deleted",bucket:s,keys:y.map(g=>g.key),deleted:y,errors:k};e.length>0&&(t.nextActions=e),console.log(JSON.stringify(t))}k.length>0&&w(k[0].error,r),S(r,{bucket:s})}export{W as default};
1
+ import{a as V,b as N}from"../../chunk-S77OAN6Y.js";import{h as C}from"../../chunk-7ZCVOA6A.js";import{d as q}from"../../chunk-3QCSRNXC.js";import{a as d,b as T}from"../../chunk-S6KFKBMY.js";import{a as w,b as o,c as O,d as S}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as $,d as j,j as M}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{listVersions as H,remove as R}from"@tigrisdata/storage";var r=M("objects","delete");async function W(c){A(r);let K=T(c),b=d(c,["bucket"]),E=d(c,["key"]),F=d(c,["yes","y","force"]),a=d(c,["version-id","versionId"]),u=!!d(c,["all-versions","allVersions"]);b||o(r,"Bucket name or path is required"),a&&u&&o(r,"Cannot use --version-id with --all-versions");let h=C(b),s=h.bucket,m=E||h.key||void 0;m||o(r,"Object key is required");let I={...await q(),bucket:s},n=Array.isArray(m)?m:[m];a&&n.length>1&&o(r,"--version-id targets a single object; pass exactly one key");let f=[];if(u)for(let e of n){let t=0,g,v,p=!1;for(;;){let{data:l,error:x}=await H({prefix:e,...g?{keyMarker:g}:{},...v?{versionIdMarker:v}:{},config:I});x&&o(r,x);for(let i of l.versions)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);for(let i of l.deleteMarkers)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);if(p||!l.hasMore)break;l.nextKeyMarker||o(r,`listVersions reported more pages but no nextKeyMarker for key '${e}'`),g=l.nextKeyMarker,v=l.nextVersionIdMarker}t===0&&o(r,`No versions or delete markers found for key '${e}'`)}else if(a)f.push({key:n[0],versionId:a});else for(let e of n)f.push({key:e});if(!F){V("Use --yes to skip confirmation");let e=u?`Hard-delete ${f.length} version(s) and delete marker(s) for ${n.length} object(s) from '${s}'?`:a?`Hard-delete version '${a}' of '${n[0]}' from '${s}'?`:`Delete ${n.length} object(s) from '${s}'?`;if(!await N(e)){console.log("Aborted");return}}let y=[],k=[];for(let e of f){let{error:t}=await R(e.key,{...e.versionId?{versionId:e.versionId}:{},config:I});t?(j(r,t.message,e),k.push({...e,error:t.message})):(y.push(e),$(r,e))}if(K==="json"){let e=O(r,{bucket:s}),t={action:"deleted",bucket:s,keys:y.map(g=>g.key),deleted:y,errors:k};e.length>0&&(t.nextActions=e),console.log(JSON.stringify(t))}k.length>0&&w(k[0].error,r),S(r,{bucket:s})}export{W as default};
@@ -1 +1 @@
1
- import{h as w}from"../../chunk-RXNG56FL.js";import{d as k}from"../../chunk-RS4HZYP3.js";import{a as r,b as j}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as a,j as b}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{get as S}from"@tigrisdata/storage";import{createWriteStream as q,writeFileSync as T}from"fs";import{extname as C}from"path";import{Readable as x}from"stream";import{pipeline as y}from"stream/promises";var e=b("objects","get"),E=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function F(t,m){let d=C(m||t).toLowerCase();return E.has(d)?"string":"stream"}async function N(t){u(e);let m=j(t),p=r(t,["bucket"]),d=r(t,["key"]),s=r(t,["output","o","O"]),v=r(t,["mode","m","M"]),g=r(t,["snapshot-version","snapshotVersion","snapshot"]),f=r(t,["version-id","versionId"]);p||c(e,"Bucket name or path is required");let{bucket:l,key:o}=w(p,d);o||c(e,"Object key is required");let h=await k();if((v||F(o,s))==="stream"){let{data:i,error:n}=await S(o,"stream",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});if(n&&c(e,n),s){let O=q(s);await y(x.fromWeb(i),O),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))}else await y(x.fromWeb(i),process.stdout),a(e)}else{let{data:i,error:n}=await S(o,"string",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});n&&c(e,n),s?(T(s,i),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))):(console.log(i),a(e))}}export{N as default};
1
+ import{h as w}from"../../chunk-7ZCVOA6A.js";import{d as k}from"../../chunk-3QCSRNXC.js";import{a as r,b as j}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-SE5TRZWU.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as a,j as b}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-ATBINUDP.js";import"../../chunk-VNUR4TRP.js";import"../../chunk-F4AGJWCK.js";import{createWriteStream as q,writeFileSync as T}from"fs";import{extname as C}from"path";import{Readable as S}from"stream";import{pipeline as x}from"stream/promises";import{get as y}from"@tigrisdata/storage";var e=b("objects","get"),E=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function F(t,m){let d=C(m||t).toLowerCase();return E.has(d)?"string":"stream"}async function N(t){u(e);let m=j(t),p=r(t,["bucket"]),d=r(t,["key"]),s=r(t,["output","o","O"]),v=r(t,["mode","m","M"]),g=r(t,["snapshot-version","snapshotVersion","snapshot"]),f=r(t,["version-id","versionId"]);p||c(e,"Bucket name or path is required");let{bucket:l,key:o}=w(p,d);o||c(e,"Object key is required");let h=await k();if((v||F(o,s))==="stream"){let{data:i,error:n}=await y(o,"stream",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});if(n&&c(e,n),s){let O=q(s);await x(S.fromWeb(i),O),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))}else await x(S.fromWeb(i),process.stdout),a(e)}else{let{data:i,error:n}=await y(o,"string",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});n&&c(e,n),s?(T(s,i),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))):(console.log(i),a(e))}}export{N as default};