@tigrisdata/cli 2.13.1 → 2.14.0-beta.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 (83) hide show
  1. package/dist/auth/s3-client.js +1 -1
  2. package/dist/chunk-5LRGY6RN.js +2 -0
  3. package/dist/chunk-DHUR7FTP.js +4 -0
  4. package/dist/chunk-DV3LCXRH.js +1 -0
  5. package/dist/chunk-FP2FMNEE.js +8 -0
  6. package/dist/chunk-GHTFMDGV.js +4 -0
  7. package/dist/chunk-S5P27E6L.js +7 -0
  8. package/dist/chunk-S77OAN6Y.js +1 -0
  9. package/dist/chunk-TD2HGNDY.js +1 -0
  10. package/dist/chunk-XLRVNE6T.js +1 -0
  11. package/dist/chunk-ZK3HJDIZ.js +1 -0
  12. package/dist/cli-core.js +1 -1
  13. package/dist/cli.js +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/lib/access-keys/assign.js +3 -2
  16. package/dist/lib/access-keys/create.js +3 -2
  17. package/dist/lib/access-keys/delete.js +3 -2
  18. package/dist/lib/access-keys/get.js +3 -2
  19. package/dist/lib/access-keys/list.js +3 -2
  20. package/dist/lib/buckets/create.js +1 -1
  21. package/dist/lib/buckets/delete.js +1 -1
  22. package/dist/lib/buckets/get.js +1 -1
  23. package/dist/lib/buckets/list.js +1 -1
  24. package/dist/lib/buckets/set-cors.js +1 -1
  25. package/dist/lib/buckets/set-locations.js +1 -0
  26. package/dist/lib/buckets/set-migration.js +1 -1
  27. package/dist/lib/buckets/set-notifications.js +1 -1
  28. package/dist/lib/buckets/set-transition.js +1 -1
  29. package/dist/lib/buckets/set-ttl.js +1 -1
  30. package/dist/lib/buckets/set.js +1 -1
  31. package/dist/lib/configure/index.js +1 -1
  32. package/dist/lib/cp.js +1 -1
  33. package/dist/lib/credentials/test.js +1 -1
  34. package/dist/lib/forks/create.js +1 -1
  35. package/dist/lib/forks/list.js +1 -1
  36. package/dist/lib/iam/policies/create.js +3 -2
  37. package/dist/lib/iam/policies/delete.js +3 -2
  38. package/dist/lib/iam/policies/edit.js +3 -2
  39. package/dist/lib/iam/policies/get.js +3 -2
  40. package/dist/lib/iam/policies/list.js +3 -2
  41. package/dist/lib/iam/users/invite.js +4 -3
  42. package/dist/lib/iam/users/list.js +8 -7
  43. package/dist/lib/iam/users/remove.js +4 -3
  44. package/dist/lib/iam/users/revoke-invitation.js +4 -3
  45. package/dist/lib/iam/users/update-role.js +4 -3
  46. package/dist/lib/login/credentials.js +1 -1
  47. package/dist/lib/login/oauth.js +1 -1
  48. package/dist/lib/login/select.js +1 -1
  49. package/dist/lib/logout.js +1 -1
  50. package/dist/lib/ls.js +1 -1
  51. package/dist/lib/mk.js +1 -1
  52. package/dist/lib/mv.js +1 -1
  53. package/dist/lib/objects/delete.js +1 -1
  54. package/dist/lib/objects/get.js +1 -1
  55. package/dist/lib/objects/list.js +1 -1
  56. package/dist/lib/objects/put.js +1 -1
  57. package/dist/lib/objects/set.js +1 -1
  58. package/dist/lib/organizations/create.js +3 -3
  59. package/dist/lib/organizations/list.js +2 -2
  60. package/dist/lib/organizations/select.js +4 -4
  61. package/dist/lib/presign.js +1 -1
  62. package/dist/lib/rm.js +1 -1
  63. package/dist/lib/snapshots/list.js +1 -1
  64. package/dist/lib/snapshots/take.js +1 -1
  65. package/dist/lib/stat.js +1 -1
  66. package/dist/lib/touch.js +1 -1
  67. package/dist/lib/whoami.js +2 -2
  68. package/dist/specs.yaml +324 -15
  69. package/dist/utils/errors.js +1 -0
  70. package/dist/utils/exit.js +1 -0
  71. package/dist/utils/interactive.js +1 -0
  72. package/dist/utils/locations.js +1 -1
  73. package/dist/utils/messages.js +1 -1
  74. package/dist/utils/update-check.js +1 -1
  75. package/package.json +5 -4
  76. package/dist/chunk-47THEW77.js +0 -8
  77. package/dist/chunk-4V35SYMM.js +0 -9
  78. package/dist/chunk-F2VBJEK7.js +0 -1
  79. package/dist/chunk-Q4KOY3VK.js +0 -1
  80. package/dist/chunk-SYGTCM6P.js +0 -2
  81. package/dist/chunk-TNOMT3EP.js +0 -4
  82. package/dist/chunk-YERF43U2.js +0 -1
  83. /package/dist/{chunk-VOQSWXBS.js → chunk-IJYKPR4W.js} +0 -0
@@ -1 +1 @@
1
- import{a,b,c,d}from"../chunk-VOQSWXBS.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";export{a as getLoginMethod,c as getS3Client,b as getStorageConfig,d as isAuthenticated};
1
+ import{a,b,c,d}from"../chunk-IJYKPR4W.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";export{a as getLoginMethod,c as getS3Client,b as getStorageConfig,d as isAuthenticated};
@@ -0,0 +1,2 @@
1
+ import{c as u}from"./chunk-BETAO4PB.js";var a={success:"\u2714",failure:"\u2716",hint:"\u2192"};function t(){return process.stdout.isTTY===!0}function o(s){let n=u(s.command,s.operation);if(n)return n.messages}function r(s,n){let e=s;return e=e.replace(/\\n/g,`
2
+ `),n&&(e=e.replace(/\{\{(\w+)\}\}/g,(i,c)=>{let g=n[c];return g!==void 0?String(g):`{{${c}}}`})),e}function l(s,n){if(!t())return;let e=o(s);e?.onStart&&console.log(r(e.onStart,n))}function f(s,n){if(!t())return;let e=o(s);e?.onSuccess&&console.log(`${a.success} ${r(e.onSuccess,n)}`)}function d(s,n,e){if(globalThis.__TIGRIS_JSON_MODE===!0)return;let i=o(s);i?.onFailure&&console.error(`${a.failure} ${r(i.onFailure,e)}`),n&&console.error(` ${n}`)}function m(s,n){if(!t())return;let e=o(s);e?.onEmpty&&console.log(r(e.onEmpty,n))}function M(s,n){if(!t())return;let e=o(s);e?.onAlreadyDone&&console.log(r(e.onAlreadyDone,n))}function x(s,n){if(!t())return;let e=o(s);e?.hint&&console.log(`${a.hint} ${r(e.hint,n)}`)}function S(s){t()&&console.warn(`\u26A0 Deprecated: ${s}`)}function C(s,n){return{command:s,operation:n}}export{r as a,l as b,f as c,d,m as e,M as f,x as g,S as h,C as i};
@@ -0,0 +1,4 @@
1
+ import{a as u,c as r}from"./chunk-GHTFMDGV.js";import{b as a,c as e,d as s,f as c,g,i as l}from"./chunk-5LRGY6RN.js";import{b as f}from"./chunk-E4MLGABW.js";import{f as p}from"./chunk-DOUR5YEY.js";var t=l("login","oauth");async function m(){a(t);try{let o=f();if(await o.isAuthenticated()){c(t);return}await o.login({onDeviceCode:(i,h)=>{console.log(`
2
+ Your confirmation code: ${i}
3
+ `),console.log(`If browser doesn't open, visit: ${h}`)},onWaiting:()=>console.log(`
4
+ Waiting for authentication...`)});let n=await o.getOrganizations();if(n.length>0){let i=n[0];await p(i.id),e(t,{org:i.displayName||i.name}),r(t),n.length>1&&g(t,{count:n.length})}else e(t,{org:"none"}),r(t)}catch(o){s(t),u(o,t)}}var v=m;export{m as a,v as b};
@@ -0,0 +1 @@
1
+ var s=(n=>(n[n.Success=0]="Success",n[n.GeneralError=1]="GeneralError",n[n.AuthFailure=2]="AuthFailure",n[n.NotFound=3]="NotFound",n[n.RateLimit=4]="RateLimit",n[n.NetworkError=5]="NetworkError",n))(s||{}),r=[/not authenticated/i,/no organization selected/i,/token refresh failed/i,/please run "tigris login/i,/logged in via OAuth/i],c=[/access denied/i,/forbidden/i],a=[/NoSuchBucket/,/NoSuchKey/,/bucket not found/i,/object not found/i,/resource .+ does not exist/i,/the specified key does not exist/i],u=[/rate limit/i,/too many requests/i,/throttl/i,/SlowDown/],g=[/ECONNREFUSED/,/ENOTFOUND/,/ETIMEDOUT/,/ECONNRESET/,/socket hang up/i,/fetch failed/i];function i(t,e){return e.some(o=>o.test(t))}function d(){return[{command:"tigris login",description:"Authenticate via OAuth"},{command:"tigris configure",description:"Set up access key credentials"}]}function f(){return[{command:"tigris access-keys list",description:"Check your access key permissions"},{command:"tigris login",description:"Re-authenticate if needed"}]}function l(){return[{command:"tigris ls",description:"List available buckets"}]}function m(){return[]}function N(){return[{command:"tigris credentials test",description:"Test connectivity and credentials"}]}function x(t){return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"}function A(t){return t instanceof Error||x(t)?t.message:typeof t=="string"?t:t==null?"Unknown error":String(t)}function p(t){let e=A(t);return i(e,r)?{exitCode:2,category:"auth",message:e,nextActions:d()}:i(e,c)?{exitCode:2,category:"permission",message:e,nextActions:f()}:i(e,a)?{exitCode:3,category:"not_found",message:e,nextActions:l()}:i(e,u)?{exitCode:4,category:"rate_limit",message:e,nextActions:m()}:i(e,g)?{exitCode:5,category:"network",message:e,nextActions:N()}:{exitCode:1,category:"general",message:e,nextActions:[]}}export{s as a,p as b};
@@ -0,0 +1,8 @@
1
+ import{d as m,e as d,f}from"./chunk-2XAO2OYD.js";import{readFileSync as I,writeFileSync as T,mkdirSync as N}from"fs";import{join as g}from"path";import{homedir as h}from"os";import j from"https";var u="2.14.0-beta.2";var b=g(h(),".tigris","update-check.json");function y(){try{let t=I(b,"utf-8"),i=JSON.parse(t);return typeof i.latestVersion=="string"&&typeof i.lastChecked=="number"?i:null}catch{return null}}function v(t){try{N(g(h(),".tigris"),{recursive:!0}),T(b,JSON.stringify(t),"utf-8")}catch{}}function E(t,i){let a=o=>{let r=o.startsWith("v")?o.slice(1):o,c=null,l=r.indexOf("-");l!==-1&&(c=r.slice(l+1),r=r.slice(0,l));let p=r.split(".");if(p.length!==3)return null;let n=p.map(Number);return n.some(isNaN)?null:{major:n[0],minor:n[1],patch:n[2],prerelease:c}},e=a(t),s=a(i);return!e||!s?!1:s.major>e.major?!0:s.major<e.major?!1:s.minor>e.minor?!0:s.minor<e.minor?!1:s.patch>e.patch?!0:s.patch<e.patch?!1:e.prerelease&&!s.prerelease?!0:(!e.prerelease&&s.prerelease,!1)}function w(){try{let t=j.get(m,{timeout:5e3},i=>{let a="";i.on("data",e=>{a+=e}),i.on("end",()=>{try{let e=JSON.parse(a);if(typeof e.version=="string"){let s=y();v({...s,latestVersion:e.version,lastChecked:Date.now()})}}catch{}})});t.on("error",()=>{}),t.on("timeout",()=>{t.destroy()}),t.end(),t.on("socket",i=>{i.unref()})}catch{}}function V(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let t=y(),i=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||216e5;if(t&&E(u,t.latestVersion)&&(!t.lastNotified||Date.now()-t.lastNotified>i)){let e=globalThis.__TIGRIS_BINARY===!0,s=process.platform==="win32",o=`Update available: ${u} \u2192 ${t.latestVersion}`,r;e?s?r="Run `irm https://raw.githubusercontent.com/tigrisdata/cli/main/scripts/install.ps1 | iex`":r="Run `curl -fsSL https://raw.githubusercontent.com/tigrisdata/cli/main/scripts/install.sh | sh`":r="Run `npm install -g @tigrisdata/cli` to upgrade.";let c=Math.max(o.length,r.length)+4,l="\u250C"+"\u2500".repeat(c-2)+"\u2510",p="\u2514"+"\u2500".repeat(c-2)+"\u2518",n=_=>"\u2502 "+_.padEnd(c-4)+" \u2502";console.log(`
2
+ ${l}
3
+ ${n("")}
4
+ ${n(o)}
5
+ ${n(r)}
6
+ ${n("")}
7
+ ${p}
8
+ `),v({...t,lastNotified:Date.now()})}let a=Number(process.env.TIGRIS_UPDATE_CHECK_INTERVAL_MS)||864e5;(!t||Date.now()-t.lastChecked>a)&&w()}export{u as a,E as b,V as c};
@@ -0,0 +1,4 @@
1
+ import{b as i}from"./chunk-DV3LCXRH.js";import{a as n}from"./chunk-5LRGY6RN.js";import{c as r}from"./chunk-BETAO4PB.js";function c(){return globalThis.__TIGRIS_JSON_MODE===!0}function a(){return process.stderr.isTTY===!0}function m(){return process.stdout.isTTY===!0}function u(t,s){let e=i(t);if(c()){let o={error:{message:e.message,code:e.exitCode,category:e.category}};e.nextActions.length>0&&(o.nextActions=e.nextActions),console.error(JSON.stringify(o))}else if(s||console.error(`
2
+ Error: ${e.message}`),a()&&e.nextActions.length>0){console.error(`
3
+ Next steps:`);for(let o of e.nextActions)console.error(` \u2192 ${o.command} ${o.description}`)}process.exit(e.exitCode)}function p(t,s){let e=r(t.command,t.operation);return e?.messages?.nextActions?e.messages.nextActions.map(o=>({command:n(o.command,s),description:n(o.description,s)})):[]}function l(t,s){if(!m()||c())return;let e=p(t,s);if(e.length!==0){console.log(`
4
+ Next steps:`);for(let o of e)console.log(` \u2192 ${o.command} ${o.description}`)}}export{u as a,p as b,l as c};
@@ -0,0 +1,7 @@
1
+ import{a as C}from"./chunk-GHTFMDGV.js";import{h as g}from"./chunk-5LRGY6RN.js";import{Command as b}from"commander";function L(){process.on("unhandledRejection",e=>{(e===""||e===void 0)&&(console.error(`
2
+ Operation cancelled`),process.exit(1)),C(e)}),process.on("uncaughtException",e=>{C(e)})}function v(e){return/^[a-zA-Z0-9_-]+$/.test(e)}function I(e){let t;e.type==="positional"?t=` ${e.name}`:(t=` --${e.name}`,e.alias&&typeof e.alias=="string"&&(t+=e.alias.length===1?`, -${e.alias}`:`, --${e.alias}`));let n=26,a=t.length>=n?t+" ":t.padEnd(n),o=e.description;return e.options&&(Array.isArray(e.options)&&typeof e.options[0]=="string"?o+=` (options: ${e.options.join(", ")})`:o+=` (options: ${e.options.map(r=>r.value).join(", ")})`),e.default&&(o+=` [default: ${e.default}]`),e.required&&(o+=" [required]"),e["required-when"]&&(o+=` [required when: ${e["required-when"]}]`),e.multiple&&(o+=" [multiple values: comma-separated]"),e.type==="positional"&&(o+=" [positional argument]"),e.examples&&e.examples.length>0&&(o+=` (examples: ${e.examples.join(", ")})`),`${a}${o}`}function f(e,t,n){return n(t)?!0:e.commands?e.commands.some(a=>f(a,[...t,a.name],n)):!1}function x(e,t,n,a){let o=n.join(" ");if(console.log(`
3
+ ${e.name} ${o} - ${t.description}
4
+ `),t.commands&&t.commands.length>0){let r=t.commands.filter(s=>f(s,[...n,s.name],a));r.length>0&&(console.log("Commands:"),r.forEach(s=>{let i=` ${s.name}`;if(s.alias){let l=Array.isArray(s.alias)?s.alias:[s.alias];i+=` (${l.join(", ")})`}let p=i.padEnd(24);console.log(`${p}${s.description}`)}),console.log())}t.arguments&&t.arguments.length>0&&(console.log("Arguments:"),t.arguments.forEach(r=>{console.log(I(r))}),console.log()),t.examples&&t.examples.length>0&&(console.log("Examples:"),t.examples.forEach(r=>{console.log(` ${r}`)}),console.log()),t.commands&&t.commands.length>0&&console.log(`Use "${e.name} ${o} <command> help" for more information about a command.`)}function w(e,t,n){console.log(`Tigris CLI Version: ${t}
5
+ `),console.log(`Usage: tigris [command] [options]
6
+ `),console.log("Commands:"),e.commands.filter(o=>f(o,[o.name],n)).forEach(o=>{let r=` ${o.name}`;if(o.alias){let i=Array.isArray(o.alias)?o.alias:[o.alias];r+=` (${i.join(", ")})`}let s=r.padEnd(24);console.log(`${s}${o.description}`)}),console.log(`
7
+ Use "${e.name} <command> help" for more information about a command.`)}function $(e,t=[]){t.forEach(n=>{if(n.type==="positional"){let a=n.required?`<${n.name}>`:`[${n.name}]`;e.argument(a,n.description)}else{let a=n.alias&&typeof n.alias=="string"&&n.alias.length===1,o=n.alias&&typeof n.alias=="string"&&n.alias.length>1,r=a?`-${n.alias}, --${n.name}`:o?`--${n.alias}, --${n.name}`:`--${n.name}`;n.type==="flag"||(n.type==="boolean"?r+=" [value]":n.options?r+=" <value>":r+=n.required||n["required-when"]?" <value>":" [value]"),e.option(r,n.description,n.default)}})}function q(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function y(e,t,n){if(n){let o=n.find(r=>r.name===t);if(o&&o.alias&&typeof o.alias=="string"){let r=o.alias.charAt(0).toUpperCase()+o.alias.slice(1);if(e[r]!==void 0)return e[r]}}let a=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),q(t)];for(let o of a)if(e[o]!==void 0)return e[o]}function E(e,t){for(let n of e){if(n["required-when"]){let[a,o]=n["required-when"].split("="),r=y(t,a,e),s=y(t,n.name,e);if(r===o&&!s)return console.error(`--${n.name} is required when --${a} is ${o}`),!1}if(n.required&&!y(t,n.name,e))return console.error(`--${n.name} is required`),!1}return!0}function u(e,t,n){let a;"optsWithGlobals"in n&&typeof n.optsWithGlobals=="function"?a=n.optsWithGlobals():"opts"in n&&typeof n.opts=="function"?a=n.opts():a=n;let o={...a};return e.filter(s=>s.type==="positional").forEach((s,i)=>{t[i]!==void 0&&(s.multiple?o[s.name]=t[i].split(",").map(p=>p.trim()):o[s.name]=t[i])}),e.forEach(s=>{s.multiple&&s.type!=="positional"&&o[s.name]&&typeof o[s.name]=="string"&&(o[s.name]=o[s.name].split(",").map(i=>i.trim()))}),o}async function k(e,t,n=[],a={}){(a.json||a.format==="json")&&(globalThis.__TIGRIS_JSON_MODE=!0);let{module:o,error:r}=await e(t);(r||!o)&&(console.error(r),process.exit(1));let s=t[t.length-1],i=o.default||o[s];typeof i!="function"&&(console.error(`Command not implemented: ${t.join(" ")}`),process.exit(1)),await i({...a,_positional:n})}function S(e,t,n,a=[]){let{specs:o,loadModule:r,hasImplementation:s}=e;for(let i of n){v(i.name)||(console.error(`Invalid command name "${i.name}": only alphanumeric, hyphens, and underscores allowed`),process.exit(1));let p=[...a,i.name];if(!f(i,p,s))continue;let l=t.command(i.name).description(i.description);if(i.alias&&(Array.isArray(i.alias)?i.alias:[i.alias]).forEach(c=>l.alias(c)),i.commands&&i.commands.length>0)if(S(e,l,i.commands,p),i.default){let m=i.commands.find(c=>c.name===i.default);if(m){$(l,i.arguments),$(l,m.arguments);let c=[...i.arguments||[],...m.arguments||[]];l.action(async(...d)=>{let A=d.pop(),h=d;c.length>0&&!E(c,u(c,h,A))||(m.deprecated&&m.messages?.onDeprecated&&g(m.messages.onDeprecated),await k(r,[...p,m.name],h,u(c,h,A)))})}}else l.action(()=>{x(o,i,p,s)});else $(l,i.arguments),l.action(async(...m)=>{let c=m.pop(),d=m;i.arguments&&!E(i.arguments,u(i.arguments,d,c))||(i.deprecated&&i.messages?.onDeprecated&&g(i.messages.onDeprecated),await k(r,p,d,u(i.arguments||[],d,c)))});l.command("help").description("Show help for this command").action(()=>{x(o,i,p,s)})}}function P(e){let{specs:t,version:n,hasImplementation:a}=e,o=new b;return o.name(t.name).description(t.description).version(n),o.option("-y, --yes","Skip all confirmation prompts"),S(e,o,t.commands),o.command("help").description("Show general help").action(()=>{w(t,n,a)}),o.action(()=>{w(t,n,a)}),o}export{L as a,v as b,I as c,f as d,x as e,w as f,$ as g,E as h,u as i,S as j,P as k};
@@ -0,0 +1 @@
1
+ import*as o from"readline";function n(e){process.stdin.isTTY||(console.error("Error: this command requires interactive input (not available in piped/scripted mode)"),console.error(`Hint: ${e}`),process.exit(1))}async function s(e){let r=o.createInterface({input:process.stdin,output:process.stdout});return new Promise(t=>{r.question(`${e} (y/N): `,i=>{r.close(),t(i.toLowerCase()==="y")})})}export{n as a,s as b};
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-S77OAN6Y.js";import l from"enquirer";var{prompt:r}=l,u=["usa","eur"],m=[{name:"USA",value:"usa"},{name:"Europe",value:"eur"}],s=[{name:"Amsterdam, Netherlands (AMS)",value:"ams"},{name:"Frankfurt, Germany (FRA)",value:"fra"},{name:"Sao Paulo, Brazil (GRU)",value:"gru"},{name:"Ashburn, Virginia (IAD)",value:"iad"},{name:"Johannesburg, South Africa (JNB)",value:"jnb"},{name:"London, United Kingdom (LHR)",value:"lhr"},{name:"Tokyo, Japan (NRT)",value:"nrt"},{name:"Chicago, Illinois (ORD)",value:"ord"},{name:"Singapore, Singapore (SIN)",value:"sin"},{name:"San Jose, California (SJC)",value:"sjc"},{name:"Sydney, Australia (SYD)",value:"syd"}];async function g(t){try{if(t==="multi"){let{region:e}=await r({type:"select",name:"region",message:"Multi-region:",choices:m.map(n=>({name:n.value,message:n.name}))});return o(e)}if(t==="single"){let{region:e}=await r({type:"select",name:"region",message:"Region:",choices:s.map(n=>({name:n.value,message:n.name}))});return o(e)}let{regions:a}=await r({type:"multiselect",name:"regions",message:"Press space key to select regions (multiple supported) and enter to confirm:",choices:s.map(e=>({name:e.value,message:e.name}))});if(a.length<2)throw new Error("Dual region requires at least two regions");return o(a)}catch(a){if(a==="")return null;throw a}}async function c(){i("Provide --locations flag");let t;try{({locationType:t}=await r({type:"select",name:"locationType",message:"Location type:",choices:[{name:"global",message:"Global"},{name:"multi",message:"Multi-region (USA or Europe)"},{name:"dual",message:"Dual region"},{name:"single",message:"Single region"}]}))}catch{throw new Error("Location selection cancelled")}return t==="global"?{type:"global"}:await g(t)??c()}function o(t){let a=(Array.isArray(t)?t:[t]).flatMap(e=>e.split(",")).map(e=>e.trim()).filter(e=>e.length>0);if(a.length===0||a.length===1&&a[0]==="global")return{type:"global"};if(a.length===1){let e=a[0];return u.includes(e)?{type:"multi",values:e}:{type:"single",values:e}}return{type:"dual",values:a}}export{c as a,o as b};
@@ -0,0 +1 @@
1
+ import{a as S}from"./chunk-S77OAN6Y.js";import{a as y,c as m}from"./chunk-GHTFMDGV.js";import{b as i,c as n,d,i as o}from"./chunk-5LRGY6RN.js";import{m as f,o as p,r as g}from"./chunk-DOUR5YEY.js";import{a as u}from"./chunk-2XAO2OYD.js";import K from"enquirer";var{prompt:A}=K,r=o("login","credentials");async function k(e){i(r);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,c=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!c){let t=[];s||t.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),c||t.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0}),S("Provide --access-key and --access-secret");let a=await A(t);s=s||a.accessKey,c=c||a.accessSecret}(!s||!c)&&(d(r,"Access key and secret are required"),y("Access key and secret are required",r));let l=f()?.endpoint||u;await p({accessKeyId:s,secretAccessKey:c,endpoint:l}),await g("credentials"),n(r),m(r)}export{k as a};
@@ -0,0 +1 @@
1
+ import{a as s,c as l}from"./chunk-FP2FMNEE.js";import{a as i,k as m}from"./chunk-S5P27E6L.js";import{b as t}from"./chunk-BETAO4PB.js";import{existsSync as c}from"fs";import{join as a,dirname as u}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
package/dist/cli-core.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-4V35SYMM.js";export{g as addArgumentsToCommand,d as commandHasAnyImplementation,k as createProgram,i as extractArgumentValues,c as formatArgumentHelp,b as isValidCommandName,j as registerCommands,a as setupErrorHandlers,e as showCommandHelp,f as showMainHelp,h as validateRequiredWhen};
1
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-S5P27E6L.js";import"./chunk-GHTFMDGV.js";import"./chunk-DV3LCXRH.js";import"./chunk-5LRGY6RN.js";import"./chunk-BETAO4PB.js";export{g as addArgumentsToCommand,d as commandHasAnyImplementation,k as createProgram,i as extractArgumentValues,c as formatArgumentHelp,b as isValidCommandName,j as registerCommands,a as setupErrorHandlers,e as showCommandHelp,f as showMainHelp,h as validateRequiredWhen};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-YERF43U2.js";import"./chunk-47THEW77.js";import"./chunk-BETAO4PB.js";import"./chunk-4V35SYMM.js";import"./chunk-2XAO2OYD.js";
2
+ import"./chunk-ZK3HJDIZ.js";import"./chunk-FP2FMNEE.js";import"./chunk-S5P27E6L.js";import"./chunk-GHTFMDGV.js";import"./chunk-DV3LCXRH.js";import"./chunk-5LRGY6RN.js";import"./chunk-BETAO4PB.js";import"./chunk-2XAO2OYD.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-YERF43U2.js";import"./chunk-47THEW77.js";import"./chunk-BETAO4PB.js";import"./chunk-4V35SYMM.js";import"./chunk-2XAO2OYD.js";
1
+ import"./chunk-ZK3HJDIZ.js";import"./chunk-FP2FMNEE.js";import"./chunk-S5P27E6L.js";import"./chunk-GHTFMDGV.js";import"./chunk-DV3LCXRH.js";import"./chunk-5LRGY6RN.js";import"./chunk-BETAO4PB.js";import"./chunk-2XAO2OYD.js";
@@ -1,2 +1,3 @@
1
- import{a as A,b as l,c as t,g as R}from"../../chunk-SYGTCM6P.js";import{a as n}from"../../chunk-JRALYIRA.js";import{a as b}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import{b as k}from"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import{c as p}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{assignBucketRoles as C,revokeAllBucketRoles as N}from"@tigrisdata/iam";var e=R("access-keys","assign"),x=["Editor","ReadOnly","NamespaceAdmin"];function y(o){return o?Array.isArray(o)?o:[o]:[]}async function E(o){A(e);let c=n(o,["id"]),g=n(o,["admin"]),d=n(o,["revokeRoles","revoke-roles"]),r=y(n(o,["bucket","b"])),s=y(n(o,["role","r"]));c||(t(e,"Access key ID is required"),process.exit(1)),g&&d&&(t(e,"Cannot use --admin and --revoke-roles together"),process.exit(1)),await b()!=="oauth"&&(t(e,`Bucket roles can only be managed when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let m=k();await m.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let T=await m.getAccessToken(),v=h(),w=p(),u={sessionToken:T,organizationId:v??void 0,iamEndpoint:w.iamEndpoint};if(d){let{error:i}=await N(c,{config:u});i&&(t(e,i.message),process.exit(1)),l(e);return}let a;if(g)a=[{bucket:"*",role:"NamespaceAdmin"}];else{r.length===0&&(t(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),process.exit(1)),s.length===0&&(t(e,"At least one role is required (or use --admin or --revoke-roles)"),process.exit(1));for(let i of s)x.includes(i)||(t(e,`Invalid role "${i}". Valid roles are: ${x.join(", ")}`),process.exit(1));s.length===1?a=r.map(i=>({bucket:i,role:s[0]})):s.length===r.length?a=r.map((i,O)=>({bucket:i,role:s[O]})):(t(e,`Number of roles (${s.length}) must be 1 or match number of buckets (${r.length})`),process.exit(1))}let{error:f}=await C(c,a,{config:u});f&&(t(e,f.message),process.exit(1)),l(e)}export{E as default};
1
+ import{a as s}from"../../chunk-JRALYIRA.js";import{a as T}from"../../chunk-IJYKPR4W.js";import{a as i,b as y,c as v}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as R,c as d,d as n,i as p}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import{b as O}from"../../chunk-E4MLGABW.js";import{g as w}from"../../chunk-DOUR5YEY.js";import{c as N}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{assignBucketRoles as C,revokeAllBucketRoles as S}from"@tigrisdata/iam";var e=p("access-keys","assign"),m=["Editor","ReadOnly","NamespaceAdmin"];function j(t){return t?Array.isArray(t)?t:[t]:[]}async function E(t){R(e);let f=s(t,["json"])?"json":s(t,["format","f","F"],"table"),l=s(t,["id"]),h=s(t,["admin"]),k=s(t,["revokeRoles","revoke-roles"]),a=j(s(t,["bucket","b"])),r=j(s(t,["role","r"]));l||(n(e,"Access key ID is required"),i("Access key ID is required",e)),h&&k&&(n(e,"Cannot use --admin and --revoke-roles together"),i("Cannot use --admin and --revoke-roles together",e)),await T()!=="oauth"&&(n(e,`Bucket roles can only be managed when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),i(`Bucket roles can only be managed when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,e));let A=O();await A.isAuthenticated()||(n(e,'Not authenticated. Run "tigris login oauth" first.'),i('Not authenticated. Run "tigris login oauth" first.',e));let $=await A.getAccessToken(),x=w(),q=N(),b={sessionToken:$,organizationId:x??void 0,iamEndpoint:q.iamEndpoint};if(k){let{error:o}=await S(l,{config:b});o&&(n(e,o.message),i(o,e)),f==="json"&&console.log(JSON.stringify({action:"revoked",id:l})),d(e);return}let c;if(h)c=[{bucket:"*",role:"NamespaceAdmin"}];else{a.length===0&&(n(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),i("At least one bucket name is required (or use --admin or --revoke-roles)",e)),r.length===0&&(n(e,"At least one role is required (or use --admin or --revoke-roles)"),i("At least one role is required (or use --admin or --revoke-roles)",e));for(let o of r)m.includes(o)||(n(e,`Invalid role "${o}". Valid roles are: ${m.join(", ")}`),i(`Invalid role "${o}". Valid roles are: ${m.join(", ")}`,e));r.length===1?c=a.map(o=>({bucket:o,role:r[0]})):r.length===a.length?c=a.map((o,g)=>({bucket:o,role:r[g]})):(n(e,`Number of roles (${r.length}) must be 1 or match number of buckets (${a.length})`),i(`Number of roles (${r.length}) must be 1 or match number of buckets (${a.length})`,e))}let{error:u}=await C(l,c,{config:b});if(u&&(n(e,u.message),i(u,e)),f==="json"){let o=y(e),g={action:"assigned",id:l,assignments:c};o.length>0&&(g.nextActions=o),console.log(JSON.stringify(g))}d(e),v(e)}export{E as default};
@@ -1,2 +1,3 @@
1
- import{a as g,b as l,c as t,g as m}from"../../chunk-SYGTCM6P.js";import{a as u}from"../../chunk-JRALYIRA.js";import{a as d}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import{b as a}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createAccessKey as y}from"@tigrisdata/iam";var e=m("access-keys","create");async function w(f){g(e);let i=u(f,["name"]);i||(t(e,"Access key name is required"),process.exit(1)),await d()!=="oauth"&&(t(e,`Access keys can only be created when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let n=a();await n.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let p=await n.getAccessToken(),h=r(),A=c(),{data:o,error:s}=await y(i,{config:{sessionToken:p,organizationId:h??void 0,iamEndpoint:A.iamEndpoint}});s&&(t(e,s.message),process.exit(1)),console.log(` Name: ${o.name}`),console.log(` Access Key ID: ${o.id}`),console.log(` Secret Access Key: ${o.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again."),l(e)}export{w as default};
1
+ import{a as i}from"../../chunk-JRALYIRA.js";import{a as k}from"../../chunk-IJYKPR4W.js";import{a as o,b as f,c as h}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as d,c as m,d as n,i as u}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import{b as y}from"../../chunk-E4MLGABW.js";import{g as p}from"../../chunk-DOUR5YEY.js";import{c as A}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createAccessKey as O}from"@tigrisdata/iam";var e=u("access-keys","create");async function R(s){d(e);let w=i(s,["json"])?"json":i(s,["format","f","F"],"table"),r=i(s,["name"]);r||(n(e,"Access key name is required"),o("Access key name is required",e)),await k()!=="oauth"&&(n(e,`Access keys can only be created when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),o(`Access keys can only be created when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,e));let a=y();await a.isAuthenticated()||(n(e,'Not authenticated. Run "tigris login oauth" first.'),o('Not authenticated. Run "tigris login oauth" first.',e));let x=await a.getAccessToken(),S=p(),N=A(),{data:t,error:c}=await O(r,{config:{sessionToken:x,organizationId:S??void 0,iamEndpoint:N.iamEndpoint}});if(c&&(n(e,c.message),o(c,e)),w==="json"){let g=f(e,{name:t.name,id:t.id}),l={action:"created",name:t.name,id:t.id,secret:t.secret};g.length>0&&(l.nextActions=g),console.log(JSON.stringify(l))}else console.log(` Name: ${t.name}`),console.log(` Access Key ID: ${t.id}`),console.log(` Secret Access Key: ${t.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");m(e),h(e,{name:t.name,id:t.id})}export{R as default};
@@ -1,2 +1,3 @@
1
- import{a,b as g,c as e,g as d}from"../../chunk-SYGTCM6P.js";import{a as f}from"../../chunk-JRALYIRA.js";import{a as m}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import{b as c}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c as s}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeAccessKey as A}from"@tigrisdata/iam";var t=d("access-keys","delete");async function k(u){a(t);let i=f(u,["id"]);i||(e(t,"Access key ID is required"),process.exit(1)),await m()!=="oauth"&&(e(t,`Access keys can only be deleted when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let o=c();await o.isAuthenticated()||(e(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let p=await o.getAccessToken(),h=r(),l=s(),{error:n}=await A(i,{config:{sessionToken:p,organizationId:h??void 0,iamEndpoint:l.iamEndpoint}});n&&(e(t,n.message),process.exit(1)),g(t)}export{k as default};
1
+ import{a as u,b as h}from"../../chunk-S77OAN6Y.js";import{a as o}from"../../chunk-JRALYIRA.js";import{a as p}from"../../chunk-IJYKPR4W.js";import{a as i}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as g,d as e,i as f}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import{b as l}from"../../chunk-E4MLGABW.js";import{g as m}from"../../chunk-DOUR5YEY.js";import{c as d}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeAccessKey as O}from"@tigrisdata/iam";var t=f("access-keys","delete");async function j(n){a(t);let y=o(n,["json"])?"json":o(n,["format","f","F"],"table"),s=o(n,["id"]),A=o(n,["force","yes","y"]);s||(e(t,"Access key ID is required"),i("Access key ID is required",t)),await p()!=="oauth"&&(e(t,`Access keys can only be deleted when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),i(`Access keys can only be deleted when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,t));let c=l();if(await c.isAuthenticated()||(e(t,'Not authenticated. Run "tigris login oauth" first.'),i('Not authenticated. Run "tigris login oauth" first.',t)),!A&&(u("Use --yes to skip confirmation"),!await h(`Delete access key '${s}'?`))){console.log("Aborted");return}let k=await c.getAccessToken(),w=m(),b=d(),{error:r}=await O(s,{config:{sessionToken:k,organizationId:w??void 0,iamEndpoint:b.iamEndpoint}});r&&(e(t,r.message),i(r,t)),y==="json"&&console.log(JSON.stringify({action:"deleted",id:s})),g(t)}export{j as default};
@@ -1,2 +1,3 @@
1
- import{a as l,b as d,c as t,g as f}from"../../chunk-SYGTCM6P.js";import{a as m}from"../../chunk-JRALYIRA.js";import{a as u}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import{b as g}from"../../chunk-E4MLGABW.js";import{g as a}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getAccessKey as $}from"@tigrisdata/iam";var e=f("access-keys","get");async function w(p){l(e);let i=m(p,["id"]);i||(t(e,"Access key ID is required"),process.exit(1)),await u()!=="oauth"&&(t(e,`Access keys can only be retrieved when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let n=g();await n.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let h=await n.getAccessToken(),A=a(),k=c(),{data:o,error:s}=await $(i,{config:{sessionToken:h,organizationId:A??void 0,iamEndpoint:k.iamEndpoint}});if(s&&(t(e,s.message),process.exit(1)),console.log(` Name: ${o.name}`),console.log(` ID: ${o.id}`),console.log(` Status: ${o.status}`),console.log(` Created: ${o.createdAt}`),console.log(` Organization: ${o.organizationId}`),o.roles&&o.roles.length>0){console.log(" Roles:");for(let r of o.roles)console.log(` - ${r.bucket}: ${r.role}`)}else console.log(" Roles: None");d(e)}export{w as default};
1
+ import{a as n}from"../../chunk-JRALYIRA.js";import{a as p}from"../../chunk-IJYKPR4W.js";import{a as i}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as l,c as d,d as e,i as f}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import{b as h}from"../../chunk-E4MLGABW.js";import{g as m}from"../../chunk-DOUR5YEY.js";import{c as u}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getAccessKey as O}from"@tigrisdata/iam";var o=f("access-keys","get");async function R(s){l(o);let A=n(s,["json"])?"json":n(s,["format","f","F"],"table"),c=n(s,["id"]);c||(e(o,"Access key ID is required"),i("Access key ID is required",o)),await p()!=="oauth"&&(e(o,`Access keys can only be retrieved when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),i(`Access keys can only be retrieved when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,o));let a=h();await a.isAuthenticated()||(e(o,'Not authenticated. Run "tigris login oauth" first.'),i('Not authenticated. Run "tigris login oauth" first.',o));let k=await a.getAccessToken(),y=m(),w=u(),{data:t,error:r}=await O(c,{config:{sessionToken:k,organizationId:y??void 0,iamEndpoint:w.iamEndpoint}});if(r&&(e(o,r.message),i(r,o)),A==="json")console.log(JSON.stringify(t));else if(console.log(` Name: ${t.name}`),console.log(` ID: ${t.id}`),console.log(` Status: ${t.status}`),console.log(` Created: ${t.createdAt}`),console.log(` Organization: ${t.organizationId}`),t.roles&&t.roles.length>0){console.log(" Roles:");for(let g of t.roles)console.log(` - ${g.bucket}: ${g.role}`)}else console.log(" Roles: None");d(o)}export{R as default};
@@ -1,2 +1,3 @@
1
- import{a as g,b as u,c as s,d as m,g as l}from"../../chunk-SYGTCM6P.js";import{f}from"../../chunk-CQCBYE3X.js";import{a as p}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import{b as d}from"../../chunk-E4MLGABW.js";import{g as r}from"../../chunk-DOUR5YEY.js";import{c}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listAccessKeys as w}from"@tigrisdata/iam";var t=l("access-keys","list");async function x(){g(t),await p()!=="oauth"&&(s(t,`Access keys can only be listed when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let o=d();await o.isAuthenticated()||(s(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let h=await o.getAccessToken(),y=r(),k=c(),{data:i,error:n}=await w({config:{sessionToken:h,organizationId:y??void 0,iamEndpoint:k.iamEndpoint}});if(n&&(s(t,n.message),process.exit(1)),!i.accessKeys||i.accessKeys.length===0){m(t);return}let a=i.accessKeys.map(e=>({name:e.name,id:e.id,status:e.status,created:e.createdAt})),A=f(a,"table","keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}]);console.log(A),u(t,{count:a.length})}export{x as default};
1
+ import{f as k}from"../../chunk-CQCBYE3X.js";import{a}from"../../chunk-JRALYIRA.js";import{a as y}from"../../chunk-IJYKPR4W.js";import{a as n}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as d,d as i,e as m,i as f}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import{b as p}from"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import{c as l}from"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listAccessKeys as b}from"@tigrisdata/iam";var t=f("access-keys","list");async function j(r){u(t);let A=a(r,["json"])?"json":a(r,["format","f","F"],"table");await y()!=="oauth"&&(i(t,`Access keys can only be listed when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),n(`Access keys can only be listed when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,t));let c=p();await c.isAuthenticated()||(i(t,'Not authenticated. Run "tigris login oauth" first.'),n('Not authenticated. Run "tigris login oauth" first.',t));let w=await c.getAccessToken(),O=h(),C=l(),{data:o,error:s}=await b({config:{sessionToken:w,organizationId:O??void 0,iamEndpoint:C.iamEndpoint}});if(s&&(i(t,s.message),n(s,t)),!o.accessKeys||o.accessKeys.length===0){m(t);return}let g=o.accessKeys.map(e=>({name:e.name,id:e.id,status:e.status,created:e.createdAt})),R=k(g,A,"keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}]);console.log(R),d(t,{count:g.length})}export{j as default};
@@ -1 +1 @@
1
- import{a as R,b as A,c as g,g as L}from"../../chunk-SYGTCM6P.js";import{a as P,b as h,c as o}from"../../chunk-Q4KOY3VK.js";import{a as s}from"../../chunk-JRALYIRA.js";import{b as B}from"../../chunk-VOQSWXBS.js";import{d as f,e as b}from"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import I from"enquirer";import{createBucket as M}from"@tigrisdata/storage";var{prompt:c}=I,r=L("buckets","create");async function W(t){R(r);let n=s(t,["name"]),y=s(t,["public"])?"public":s(t,["access","a","A"]),S=s(t,["enable-snapshots","s","S"]),w=s(t,["default-tier","t","T"]),m=s(t,["locations","l","L"]),k=s(t,["region","r","R"]),q=s(t,["consistency","c","C"]);k!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),m===void 0&&(m=k)),q!==void 0&&console.warn("Warning: --consistency is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/");let E=!n,i;if(E){let T=f("buckets","access","create"),v=b(T),u=v?.findIndex(e=>e.value===T?.default),x=f("buckets","default-tier","create"),D=b(x),p=D?.findIndex(e=>e.value===x?.default),l=await c([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:v||[],initial:u!==void 0&&u>=0?u:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:D||[],initial:p!==void 0&&p>=0?p:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);n=l.name,y=l.access,w=l.defaultTier,S=l.enableSnapshots;let{locationType:d}=await c({type:"select",name:"locationType",message:"Location type:",choices:[{name:"global",message:"Global"},{name:"multi",message:"Multi-region (USA or Europe)"},{name:"dual",message:"Dual region"},{name:"single",message:"Single region"}]});if(d==="global")i={type:"global"};else if(d==="multi"){let{region:e}=await c({type:"select",name:"region",message:"Multi-region:",choices:P.map(a=>({name:a.value,message:a.name}))});i=o(e)}else if(d==="single"){let{region:e}=await c({type:"select",name:"region",message:"Region:",choices:h.map(a=>({name:a.value,message:a.name}))});i=o(e)}else{let{regions:e}=await c({type:"multiselect",name:"regions",message:"Press space key to select regions (multiple supported) and enter to confirm:",choices:h.map(a=>({name:a.value,message:a.name}))});e.length<2&&(g(r,"Dual region requires at least two regions"),process.exit(1)),i=o(e)}}n||(g(r,"Bucket name is required"),process.exit(1));let{error:C}=await M(n,{defaultTier:w??"STANDARD",enableSnapshot:S===!0,access:y??"private",locations:i??o(m??"global"),config:await B()});C&&(g(r,C.message),process.exit(1)),A(r,{name:n})}export{W as default};
1
+ import{a as N,b as R}from"../../chunk-TD2HGNDY.js";import{a as j}from"../../chunk-S77OAN6Y.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as D}from"../../chunk-IJYKPR4W.js";import{a as u,b as T,c as L}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as B,c as C,d as i,i as q}from"../../chunk-5LRGY6RN.js";import{d as b,e as h}from"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import I from"enquirer";import{createBucket as W}from"@tigrisdata/storage";var{prompt:F}=I,s=q("buckets","create");async function J(t){B(s);let O=e(t,["json"])?"json":e(t,["format","f","F"],"table"),n=e(t,["name"]),k=e(t,["public"])?"public":e(t,["access","a","A"]),S=e(t,["enable-snapshots","s","S"]),w=e(t,["default-tier","t","T"]),f=e(t,["locations","l","L"]),o=e(t,["fork-of","forkOf","fork"]),d=e(t,["source-snapshot","sourceSnapshot","source-snap"]),y=e(t,["region","r","R"]),P=e(t,["consistency","c","C"]);y!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),f===void 0&&(f=y)),P!==void 0&&console.warn("Warning: --consistency is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/");let E=!n,v;if(E){j("Provide --name to skip interactive mode");let r=b("buckets","access","create"),c=h(r),p=c?.findIndex(a=>a.value===r?.default),x=b("buckets","default-tier","create"),A=h(x),g=A?.findIndex(a=>a.value===x?.default),l=await F([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:c||[],initial:p!==void 0&&p>=0?p:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:g!==void 0&&g>=0?g:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);n=l.name,k=l.access,w=l.defaultTier,S=l.enableSnapshots;try{v=await N()}catch(a){i(s,a.message),u(a,s)}}n||(i(s,"Bucket name is required"),u("Bucket name is required",s)),d&&!o&&(i(s,"--source-snapshot requires --fork-of"),u("--source-snapshot requires --fork-of",s));let{error:m}=await W(n,{defaultTier:w??"STANDARD",enableSnapshot:S===!0,access:k??"private",locations:v??R(f??"global"),...o?{sourceBucketName:o}:{},...d?{sourceBucketSnapshot:d}:{},config:await D()});if(m&&(i(s,m.message),u(m,s)),O==="json"){let r=T(s,{name:n}),c={action:"created",name:n,...o?{forkOf:o}:{}};r.length>0&&(c.nextActions=r),console.log(JSON.stringify(c))}C(s,{name:n}),L(s,{name:n})}export{J as default};
@@ -1 +1 @@
1
- import{a as i,b as s,c as o,g as c}from"../../chunk-SYGTCM6P.js";import{a as m}from"../../chunk-JRALYIRA.js";import{b as a}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeBucket as g}from"@tigrisdata/storage";var e=c("buckets","delete");async function k(f){i(e);let t=m(f,["name"]);t||(o(e,"Bucket name is required"),process.exit(1));let p=Array.isArray(t)?t:[t],u=await a();for(let r of p){let{error:n}=await g(r,{config:u});n&&(o(e,n.message,{name:r}),process.exit(1)),s(e,{name:r})}}export{k as default};
1
+ import{a as k,b}from"../../chunk-S77OAN6Y.js";import{a as o}from"../../chunk-JRALYIRA.js";import{b as x}from"../../chunk-IJYKPR4W.js";import{a,b as d,c as p}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as g,c as u,d as c,i as l}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{removeBucket as j}from"@tigrisdata/storage";var t=l("buckets","delete");async function w(n){g(t);let y=o(n,["json"])?"json":o(n,["format","f","F"],"table"),s=o(n,["name"]),A=o(n,["force","yes","y"]);s||(c(t,"Bucket name is required"),a("Bucket name is required",t));let m=Array.isArray(s)?s:[s],h=await x();if(!A&&(k("Use --yes to skip confirmation"),!await b(`Delete ${m.length} bucket(s)?`))){console.log("Aborted");return}let f=[],i=[];for(let e of m){let{error:r}=await j(e,{config:h});r?(c(t,r.message,{name:e}),i.push({name:e,error:r.message})):(f.push(e),u(t,{name:e}))}if(y==="json"){let e=d(t),r={action:"deleted",names:f,errors:i};e.length>0&&(r.nextActions=e),console.log(JSON.stringify(r))}i.length>0&&a(i[0].error,t),p(t)}export{w as default};
@@ -1 +1 @@
1
- import{a as u}from"../../chunk-WIOXQDND.js";import{a as i,b as p,c as r,g as m}from"../../chunk-SYGTCM6P.js";import{f as s}from"../../chunk-CQCBYE3X.js";import{a as o}from"../../chunk-JRALYIRA.js";import{b as c}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getBucketInfo as b}from"@tigrisdata/storage";var t=m("buckets","get");async function x(n){i(t);let e=o(n,["name"]),f=o(n,["format"])||"table";e||(r(t,"Bucket name is required"),process.exit(1));let{data:g,error:a}=await b(e,{config:await c()});a&&(r(t,a.message),process.exit(1));let l=[{property:"Name",value:e},...u(g).map(({label:y,value:d})=>({property:y,value:d}))],k=s(l,f,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(k),p(t)}export{x as default};
1
+ import{a as f}from"../../chunk-WIOXQDND.js";import{f as u}from"../../chunk-CQCBYE3X.js";import{a as r}from"../../chunk-JRALYIRA.js";import{b as c}from"../../chunk-IJYKPR4W.js";import{a as i}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as p,d as a,i as s}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{getBucketInfo as j}from"@tigrisdata/storage";var t=s("buckets","get");async function B(o){m(t);let e=r(o,["name"]),g=r(o,["json"])?"json":r(o,["format","f","F"])||"table";e||(a(t,"Bucket name is required"),i("Bucket name is required",t));let{data:l,error:n}=await j(e,{config:await c()});n&&(a(t,n.message),i(n,t));let k=[{property:"Name",value:e},...f(l).map(({label:y,value:b})=>({property:y,value:b}))],d=u(k,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(d),p(t)}export{B as default};
@@ -1 +1 @@
1
- import{a as c,b as i,c as r,d as m,g as u}from"../../chunk-SYGTCM6P.js";import{f as g}from"../../chunk-CQCBYE3X.js";import{a as f}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as d}from"@tigrisdata/storage";var t=u("buckets","list");async function b(k){c(t);try{let e=f(k,["format","F"],"table"),{data:o,error:n}=await d({config:await p()});if(n&&(r(t,n.message),process.exit(1)),!o.buckets||o.buckets.length===0){m(t);return}let s=o.buckets.map(a=>({name:a.name,created:a.creationDate})),l=g(s,e,"buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(l),i(t,{count:s.length})}catch(e){e instanceof Error?r(t,e.message):r(t,"An unknown error occurred"),process.exit(1)}}export{b as default};
1
+ import{f as p}from"../../chunk-CQCBYE3X.js";import{a as u}from"../../chunk-JRALYIRA.js";import{b as j}from"../../chunk-IJYKPR4W.js";import{a as f}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as y,c as l,d as e,e as i,i as w}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as C,getBucketInfo as E}from"@tigrisdata/storage";var t=w("buckets","list");async function D(m){y(t);try{let h=u(m,["json"])?"json":u(m,["format","f","F"],"table"),o=u(m,["forks-of","forksOf"]),k=await j(),{data:n,error:g}=await C({config:k});if(g&&(e(t,g.message),f(g,t)),!n.buckets||n.buckets.length===0){i(t);return}if(o){let{data:a,error:d}=await E(o,{config:k});if(d&&(e(t,d.message),f(d,t)),!a.hasForks){i(t);return}let s=[];for(let c of n.buckets){if(c.name===o)continue;let{data:B}=await E(c.name,{config:k});B?.sourceBucketName===o&&s.push({name:c.name,created:c.creationDate})}if(s.length===0){i(t);return}let x=p(s,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(x),l(t,{count:s.length});return}let b=n.buckets.map(a=>({name:a.name,created:a.creationDate})),O=p(b,h,"buckets","bucket",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(O),l(t,{count:b.length})}catch(r){r instanceof Error?e(t,r.message):e(t,"An unknown error occurred"),f(r,t)}}export{D as default};
@@ -1 +1 @@
1
- import{a as p,b,c as t,g as h}from"../../chunk-SYGTCM6P.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as w}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as x}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketCors as C}from"@tigrisdata/storage";var n=h("buckets","set-cors");async function N(r){p(n);let i=e(r,["name"]),o=e(r,["origins"]),d=e(r,["methods"]),a=e(r,["headers"]),c=e(r,["expose-headers","exposeHeaders"]),s=e(r,["max-age","maxAge"]),f=e(r,["override"]),g=e(r,["reset"]);i||(t(n,"Bucket name is required"),process.exit(1)),g&&(o!==void 0||d!==void 0||a!==void 0||c!==void 0||s!==void 0||f)&&(t(n,"Cannot use --reset with other options"),process.exit(1)),!g&&!o&&(t(n,"Provide --origins or --reset"),process.exit(1)),s!==void 0&&(isNaN(Number(s))||Number(s)<=0)&&(t(n,"--max-age must be a positive number"),process.exit(1));let m=await w(),u=x(),v={...m,...u&&!m.organizationId?{organizationId:u}:{}},{error:l}=await C(i,{rules:g?[]:[{allowedOrigins:o,...d!==void 0?{allowedMethods:d}:{},...a!==void 0?{allowedHeaders:a}:{},...c!==void 0?{exposeHeaders:c}:{},maxAge:s!==void 0?Number(s):3600}],override:f??!1,config:v});l&&(t(n,l.message),process.exit(1)),b(n,{name:i})}export{N as default};
1
+ import{a as r}from"../../chunk-JRALYIRA.js";import{b as v}from"../../chunk-IJYKPR4W.js";import{a as o}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as p,d as i,i as b}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as w}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketCors as k}from"@tigrisdata/storage";var e=b("buckets","set-cors");async function N(n){h(e);let s=r(n,["name"]),a=r(n,["origins"]),d=r(n,["methods"]),m=r(n,["headers"]),g=r(n,["expose-headers","exposeHeaders"]),t=r(n,["max-age","maxAge"]),c=r(n,["override"]),u=r(n,["reset"]);s||(i(e,"Bucket name is required"),o("Bucket name is required",e)),u&&(a!==void 0||d!==void 0||m!==void 0||g!==void 0||t!==void 0||c)&&(i(e,"Cannot use --reset with other options"),o("Cannot use --reset with other options",e)),!u&&!a&&(i(e,"Provide --origins or --reset"),o("Provide --origins or --reset",e)),t!==void 0&&(isNaN(Number(t))||Number(t)<=0)&&(i(e,"--max-age must be a positive number"),o("--max-age must be a positive number",e));let l=await v(),x=w(),C={...l,...x&&!l.organizationId?{organizationId:x}:{}},{error:f}=await k(s,{rules:u?[]:[{allowedOrigins:a,...d!==void 0?{allowedMethods:d}:{},...m!==void 0?{allowedHeaders:m}:{},...g!==void 0?{exposeHeaders:g}:{},maxAge:t!==void 0?Number(t):3600}],override:c??!1,config:C});f&&(i(e,f.message),o(f,e)),p(e,{name:s})}export{N as default};
@@ -0,0 +1 @@
1
+ import{a as B,b as w}from"../../chunk-TD2HGNDY.js";import{a as k}from"../../chunk-S77OAN6Y.js";import{a}from"../../chunk-JRALYIRA.js";import{b as L}from"../../chunk-IJYKPR4W.js";import{a as r}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as u,d as o,i as d}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as l}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{updateBucket as q}from"@tigrisdata/storage";var t=d("buckets","set-locations");async function x(s){p(t);let i=a(s,["name"]),c=a(s,["locations"]);i||(o(t,"Bucket name is required"),r("Bucket name is required",t));let e;if(c!==void 0)e=w(c);else{k("Provide --locations flag");try{e=await B()}catch(f){o(t,f.message),r(f,t)}}let m=await L(),g=l(),S={...m,...g&&!m.organizationId?{organizationId:g}:{}},{error:n}=await q(i,{locations:e,config:S});n&&(o(t,n.message),r(n,t)),u(t,{name:i})}export{x as default};
@@ -1 +1 @@
1
- import{a as w,b as d,c as i,g as y}from"../../chunk-SYGTCM6P.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as x}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketMigration as K}from"@tigrisdata/storage";var n=y("buckets","set-migration");async function M(t){w(n);let r=e(t,["name"]),o=e(t,["bucket"]),s=e(t,["endpoint"]),a=e(t,["region"]),c=e(t,["access-key","accessKey"]),g=e(t,["secret-key","secretKey"]),f=e(t,["write-through","writeThrough"]),u=e(t,["disable"]);r||(i(n,"Bucket name is required"),process.exit(1)),u&&(o!==void 0||s!==void 0||a!==void 0||c!==void 0||g!==void 0||f!==void 0)&&(i(n,"Cannot use --disable with other migration options"),process.exit(1));let m=await x(),l=h(),p={...m,...l&&!m.organizationId?{organizationId:l}:{}};if(u){let{error:k}=await K(r,{dataMigration:{enabled:!1},config:p});k&&(i(n,k.message),process.exit(1)),d(n,{name:r});return}(!o||!s||!a||!c||!g)&&(i(n,"Required: --bucket, --endpoint, --region, --access-key, --secret-key"),process.exit(1));let{error:b}=await K(r,{dataMigration:{enabled:!0,accessKey:c,secretKey:g,region:a,name:o,endpoint:s,writeThrough:f??!1},config:p});b&&(i(n,b.message),process.exit(1)),d(n,{name:r})}export{M as default};
1
+ import{a as t}from"../../chunk-JRALYIRA.js";import{b as C}from"../../chunk-IJYKPR4W.js";import{a as r}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as m,d as i,i as w}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as q}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketMigration as K}from"@tigrisdata/storage";var e=w("buckets","set-migration");async function M(n){p(e);let o=t(n,["name"]),s=t(n,["bucket"]),a=t(n,["endpoint"]),c=t(n,["region"]),g=t(n,["access-key","accessKey"]),d=t(n,["secret-key","secretKey"]),k=t(n,["write-through","writeThrough"]),l=t(n,["disable"]);o||(i(e,"Bucket name is required"),r("Bucket name is required",e)),l&&(s!==void 0||a!==void 0||c!==void 0||g!==void 0||d!==void 0||k!==void 0)&&(i(e,"Cannot use --disable with other migration options"),r("Cannot use --disable with other migration options",e));let b=await C(),h=q(),y={...b,...h&&!b.organizationId?{organizationId:h}:{}};if(l){let{error:f}=await K(o,{dataMigration:{enabled:!1},config:y});f&&(i(e,f.message),r(f,e)),m(e,{name:o});return}(!s||!a||!c||!g||!d)&&(i(e,"Required: --bucket, --endpoint, --region, --access-key, --secret-key"),r("Required: --bucket, --endpoint, --region, --access-key, --secret-key",e));let{error:u}=await K(o,{dataMigration:{enabled:!0,accessKey:g,secretKey:d,region:c,name:s,endpoint:a,writeThrough:k??!1},config:y});u&&(i(e,u.message),r(u,e)),m(e,{name:o})}export{M as default};
@@ -1 +1 @@
1
- import{a as k,b as w,c as i,g as x}from"../../chunk-SYGTCM6P.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as C}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketNotifications as N}from"@tigrisdata/storage";var t=x("buckets","set-notifications");async function O(n){k(t);let c=e(n,["name"]),d=e(n,["url"]),f=e(n,["filter"]),a=e(n,["token"]),o=e(n,["username"]),s=e(n,["password"]),l=e(n,["enable"]),g=e(n,["disable"]),u=e(n,["reset"]);c||(i(t,"Bucket name is required"),process.exit(1)),[l,g,u].filter(Boolean).length>1&&(i(t,"Only one of --enable, --disable, or --reset can be used"),process.exit(1)),u&&(d!==void 0||f!==void 0||a!==void 0||o!==void 0||s!==void 0)&&(i(t,"Cannot use --reset with other options"),process.exit(1)),!l&&!g&&!u&&d===void 0&&f===void 0&&a===void 0&&o===void 0&&s===void 0&&(i(t,"Provide at least one option"),process.exit(1)),a&&(o!==void 0||s!==void 0)&&(i(t,"Cannot use --token with --username/--password. Choose one auth method"),process.exit(1)),(o!==void 0&&s===void 0||o===void 0&&s!==void 0)&&(i(t,"Both --username and --password are required"),process.exit(1));let m=await C(),p=h(),B={...m,...p&&!m.organizationId?{organizationId:p}:{}},r;u?r={}:(r={...l?{enabled:!0}:{},...g?{enabled:!1}:{},...d!==void 0?{url:d}:{},...f!==void 0?{filter:f}:{}},a?r={...r,auth:{token:a}}:o&&s&&(r={...r,auth:{username:o,password:s}}));let{error:b}=await N(c,{notificationConfig:r,config:B});b&&(i(t,b.message),process.exit(1)),w(t,{name:c})}export{O as default};
1
+ import{a as n}from"../../chunk-JRALYIRA.js";import{b as O}from"../../chunk-IJYKPR4W.js";import{a as o}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as k,d as i,i as C}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as B}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketNotifications as y}from"@tigrisdata/storage";var e=C("buckets","set-notifications");async function N(t){w(e);let l=n(t,["name"]),f=n(t,["url"]),u=n(t,["filter"]),d=n(t,["token"]),r=n(t,["username"]),a=n(t,["password"]),m=n(t,["enable"]),g=n(t,["disable"]),c=n(t,["reset"]);l||(i(e,"Bucket name is required"),o("Bucket name is required",e)),[m,g,c].filter(Boolean).length>1&&(i(e,"Only one of --enable, --disable, or --reset can be used"),o("Only one of --enable, --disable, or --reset can be used",e)),c&&(f!==void 0||u!==void 0||d!==void 0||r!==void 0||a!==void 0)&&(i(e,"Cannot use --reset with other options"),o("Cannot use --reset with other options",e)),!m&&!g&&!c&&f===void 0&&u===void 0&&d===void 0&&r===void 0&&a===void 0&&(i(e,"Provide at least one option"),o("Provide at least one option",e)),d&&(r!==void 0||a!==void 0)&&(i(e,"Cannot use --token with --username/--password. Choose one auth method"),o("Cannot use --token with --username/--password. Choose one auth method",e)),(r!==void 0&&a===void 0||r===void 0&&a!==void 0)&&(i(e,"Both --username and --password are required"),o("Both --username and --password are required",e));let b=await O(),p=B(),q={...b,...p&&!b.organizationId?{organizationId:p}:{}},s;c?s={}:(s={...m?{enabled:!0}:{},...g?{enabled:!1}:{},...f!==void 0?{url:f}:{},...u!==void 0?{filter:u}:{}},d?s={...s,auth:{token:d}}:r&&a&&(s={...s,auth:{username:r,password:a}}));let{error:h}=await y(l,{notificationConfig:s,config:q});h&&(i(e,h.message),o(h,e)),k(e,{name:l})}export{N as default};
@@ -1 +1 @@
1
- import{a as m,b,c as s,g as p}from"../../chunk-SYGTCM6P.js";import{a as n}from"../../chunk-JRALYIRA.js";import{b as y}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketLifecycle as R}from"@tigrisdata/storage";var e=p("buckets","set-transition"),x=["STANDARD_IA","GLACIER","GLACIER_IR"];async function S(a){m(e);let d=n(a,["name"]),o=n(a,["storage-class","storageClass"]),i=n(a,["days"]),t=n(a,["date"]),c=n(a,["enable"]),r=n(a,["disable"]);d||(s(e,"Bucket name is required"),process.exit(1)),c&&r&&(s(e,"Cannot use both --enable and --disable"),process.exit(1)),r&&(i!==void 0||t!==void 0||o!==void 0)&&(s(e,"Cannot use --disable with --days, --date, or --storage-class"),process.exit(1)),!c&&!r&&i===void 0&&t===void 0&&(s(e,"Provide --days, --date, --enable, or --disable"),process.exit(1)),(i!==void 0||t!==void 0)&&!o&&(s(e,"--storage-class is required when setting --days or --date"),process.exit(1)),o&&!x.includes(o)&&(s(e,`--storage-class must be one of: ${x.join(", ")} (STANDARD is not a valid transition target)`),process.exit(1)),i!==void 0&&(isNaN(Number(i))||Number(i)<=0)&&(s(e,"--days must be a positive number"),process.exit(1)),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&(s(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)"),process.exit(1));let f=await y(),l=g(),C={...f,...l&&!f.organizationId?{organizationId:l}:{}},N={...c?{enabled:!0}:{},...r?{enabled:!1}:{},...o?{storageClass:o}:{},...i!==void 0?{days:Number(i)}:{},...t!==void 0?{date:t}:{}},{error:u}=await R(d,{lifecycleRules:[N],config:C});u&&(s(e,u.message),process.exit(1)),b(e,{name:d})}export{S as default};
1
+ import{a as i}from"../../chunk-JRALYIRA.js";import{b as A}from"../../chunk-IJYKPR4W.js";import{a}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as y,d as t,i as C}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as S}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketLifecycle as I}from"@tigrisdata/storage";var e=C("buckets","set-transition"),f=["STANDARD_IA","GLACIER","GLACIER_IR"];async function p(d){m(e);let l=i(d,["name"]),o=i(d,["storage-class","storageClass"]),n=i(d,["days"]),s=i(d,["date"]),u=i(d,["enable"]),r=i(d,["disable"]);l||(t(e,"Bucket name is required"),a("Bucket name is required",e)),u&&r&&(t(e,"Cannot use both --enable and --disable"),a("Cannot use both --enable and --disable",e)),r&&(n!==void 0||s!==void 0||o!==void 0)&&(t(e,"Cannot use --disable with --days, --date, or --storage-class"),a("Cannot use --disable with --days, --date, or --storage-class",e)),!u&&!r&&n===void 0&&s===void 0&&(t(e,"Provide --days, --date, --enable, or --disable"),a("Provide --days, --date, --enable, or --disable",e)),(n!==void 0||s!==void 0)&&!o&&(t(e,"--storage-class is required when setting --days or --date"),a("--storage-class is required when setting --days or --date",e)),o&&!f.includes(o)&&(t(e,`--storage-class must be one of: ${f.join(", ")} (STANDARD is not a valid transition target)`),a(`--storage-class must be one of: ${f.join(", ")} (STANDARD is not a valid transition target)`,e)),n!==void 0&&(isNaN(Number(n))||Number(n)<=0)&&(t(e,"--days must be a positive number"),a("--days must be a positive number",e)),s!==void 0&&(typeof s!="string"||!/^\d{4}-\d{2}-\d{2}/.test(s)||isNaN(new Date(s).getTime()))&&(t(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)"),a("--date must be a valid ISO-8601 date (e.g. 2026-06-01)",e));let g=await A(),b=S(),N={...g,...b&&!g.organizationId?{organizationId:b}:{}},R={...u?{enabled:!0}:{},...r?{enabled:!1}:{},...o?{storageClass:o}:{},...n!==void 0?{days:Number(n)}:{},...s!==void 0?{date:s}:{}},{error:c}=await I(l,{lifecycleRules:[R],config:N});c&&(t(e,c.message),a(c,e)),y(e,{name:l})}export{p as default};
@@ -1 +1 @@
1
- import{a as g,b as m,c as n,g as b}from"../../chunk-SYGTCM6P.js";import{a as s}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as l}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketTtl as N}from"@tigrisdata/storage";var e=b("buckets","set-ttl");async function w(a){g(e);let d=s(a,["name"]),i=s(a,["days"]),t=s(a,["date"]),r=s(a,["enable"]),o=s(a,["disable"]);d||(n(e,"Bucket name is required"),process.exit(1)),r&&o&&(n(e,"Cannot use both --enable and --disable"),process.exit(1)),o&&(i!==void 0||t!==void 0)&&(n(e,"Cannot use --disable with --days or --date"),process.exit(1)),!r&&!o&&i===void 0&&t===void 0&&(n(e,"Provide --days, --date, --enable, or --disable"),process.exit(1)),i!==void 0&&(isNaN(Number(i))||Number(i)<=0)&&(n(e,"--days must be a positive number"),process.exit(1)),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&(n(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)"),process.exit(1));let c=await p(),f=l(),x={...c,...f&&!c.organizationId?{organizationId:f}:{}},y={...r?{enabled:!0}:{},...o?{enabled:!1}:{},...i!==void 0?{days:Number(i)}:{},...t!==void 0?{date:t}:{}},{error:u}=await N(d,{ttlConfig:y,config:x});u&&(n(e,u.message),process.exit(1)),m(e,{name:d})}export{w as default};
1
+ import{a as d}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-IJYKPR4W.js";import{a}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as m,c,d as n,i as g}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as y}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{setBucketTtl as v}from"@tigrisdata/storage";var e=g("buckets","set-ttl");async function w(s){m(e);let r=d(s,["name"]),i=d(s,["days"]),t=d(s,["date"]),u=d(s,["enable"]),o=d(s,["disable"]);r||(n(e,"Bucket name is required"),a("Bucket name is required",e)),u&&o&&(n(e,"Cannot use both --enable and --disable"),a("Cannot use both --enable and --disable",e)),o&&(i!==void 0||t!==void 0)&&(n(e,"Cannot use --disable with --days or --date"),a("Cannot use --disable with --days or --date",e)),!u&&!o&&i===void 0&&t===void 0&&(n(e,"Provide --days, --date, --enable, or --disable"),a("Provide --days, --date, --enable, or --disable",e)),i!==void 0&&(isNaN(Number(i))||Number(i)<=0)&&(n(e,"--days must be a positive number"),a("--days must be a positive number",e)),t!==void 0&&(typeof t!="string"||!/^\d{4}-\d{2}-\d{2}/.test(t)||isNaN(new Date(t).getTime()))&&(n(e,"--date must be a valid ISO-8601 date (e.g. 2026-06-01)"),a("--date must be a valid ISO-8601 date (e.g. 2026-06-01)",e));let b=await p(),l=y(),C={...b,...l&&!b.organizationId?{organizationId:l}:{}},N={...u?{enabled:!0}:{},...o?{enabled:!1}:{},...i!==void 0?{days:Number(i)}:{},...t!==void 0?{date:t}:{}},{error:f}=await v(r,{ttlConfig:N,config:C});f&&(n(e,f.message),a(f,e)),c(e,{name:r})}export{w as default};
@@ -1 +1 @@
1
- import{a as k,b as A,c,g as h}from"../../chunk-SYGTCM6P.js";import{c as x}from"../../chunk-Q4KOY3VK.js";import{a as e,b as o}from"../../chunk-JRALYIRA.js";import{b as y}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as O}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{updateBucket as C}from"@tigrisdata/storage";var a=h("buckets","set");async function S(n){k(a);let s=e(n,["name"]),r=e(n,["access"]),i=e(n,["locations"]),b=e(n,["region"]);b!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),i===void 0&&(i=b));let d=e(n,["allow-object-acl","allowObjectAcl"]),l=e(n,["disable-directory-listing","disableDirectoryListing"]),f=e(n,["cache-control","cacheControl"]),u=e(n,["custom-domain","customDomain"]),g=e(n,["enable-delete-protection","enableDeleteProtection"]),m=e(n,["enable-additional-headers","enableAdditionalHeaders"]);s||(c(a,"Bucket name is required"),process.exit(1)),r===void 0&&i===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&(c(a,"At least one setting is required"),process.exit(1));let p=await y(),t={};r!==void 0&&(t.access=r),i!==void 0&&(t.locations=x(i)),d!==void 0&&(t.allowObjectAcl=o(d)),l!==void 0&&(t.disableDirectoryListing=o(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=o(g)),m!==void 0&&(t.enableAdditionalHeaders=o(m));let w=O(),B={...p,...w&&!p.organizationId?{organizationId:w}:{}},{error:D}=await C(s,{...t,config:B});D&&(c(a,D.message),process.exit(1)),A(a,{name:s})}export{S as default};
1
+ import{b as B}from"../../chunk-TD2HGNDY.js";import"../../chunk-S77OAN6Y.js";import{a as e,b as a}from"../../chunk-JRALYIRA.js";import{b as y}from"../../chunk-IJYKPR4W.js";import{a as c}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as D,c as k,d as s,i as A}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as h}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{updateBucket as q}from"@tigrisdata/storage";var i=A("buckets","set");async function L(n){D(i);let S=e(n,["json"])?"json":e(n,["format"],"table"),r=e(n,["name"]),d=e(n,["access"]),o=e(n,["locations"]),w=e(n,["region"]);w!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),o===void 0&&(o=w));let l=e(n,["allow-object-acl","allowObjectAcl"]),f=e(n,["disable-directory-listing","disableDirectoryListing"]),u=e(n,["cache-control","cacheControl"]),g=e(n,["custom-domain","customDomain"]),m=e(n,["enable-delete-protection","enableDeleteProtection"]),b=e(n,["enable-additional-headers","enableAdditionalHeaders"]);r||(s(i,"Bucket name is required"),c("Bucket name is required",i)),d===void 0&&o===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&b===void 0&&(s(i,"At least one setting is required"),c("At least one setting is required",i));let O=await y(),t={};d!==void 0&&(t.access=d),o!==void 0&&(t.locations=B(o)),l!==void 0&&(t.allowObjectAcl=a(l)),f!==void 0&&(t.disableDirectoryListing=a(f)),u!==void 0&&(t.cacheControl=u),g!==void 0&&(t.customDomain=g),m!==void 0&&(t.enableDeleteProtection=a(m)),b!==void 0&&(t.enableAdditionalHeaders=a(b));let j=h(),C={...O,...j&&!O.organizationId?{organizationId:j}:{}},{error:p}=await q(r,{...t,config:C});p&&(s(i,p.message),c(p,i)),S==="json"&&console.log(JSON.stringify({action:"updated",name:r})),k(i,{name:r})}export{L as default};
@@ -1 +1 @@
1
- import{a as g,b as p,c as n,g as m}from"../../chunk-SYGTCM6P.js";import"../../chunk-BETAO4PB.js";import{n as u,r as y}from"../../chunk-DOUR5YEY.js";import{a as d}from"../../chunk-2XAO2OYD.js";import f from"enquirer";var{prompt:l}=f,i=m("configure");async function o(e){g(i);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,c=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,r=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!c||!r){let t=[];s||t.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),c||t.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),r||t.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:d});let a=await l(t);s=s||a.accessKey,c=c||a.accessSecret,r=r||a.endpoint}(!s||!c||!r)&&(n(i,"All credentials are required"),process.exit(1));try{await u({accessKeyId:s,secretAccessKey:c,endpoint:r}),await y("credentials"),p(i)}catch{n(i,"Failed to save credentials"),process.exit(1)}}export{o as default};
1
+ import{a as f}from"../../chunk-S77OAN6Y.js";import{a as d,c as p}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as m,d as n,i as o}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import{n as g,r as l}from"../../chunk-DOUR5YEY.js";import{a as y}from"../../chunk-2XAO2OYD.js";import K from"enquirer";var{prompt:S}=K,r=o("configure");async function q(e){u(r);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,c=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,t=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!c||!t){let i=[];s||i.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),c||i.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),t||i.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:y}),f("Provide --access-key, --access-secret, and --endpoint");let a=await S(i);s=s||a.accessKey,c=c||a.accessSecret,t=t||a.endpoint}(!s||!c||!t)&&(n(r,"All credentials are required"),d("All credentials are required",r));try{await g({accessKeyId:s,secretAccessKey:c,endpoint:t}),await l("credentials"),m(r),p(r)}catch(i){n(r,"Failed to save credentials"),d(i,r)}}export{q as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as N}from"../chunk-EKW6XTGL.js";import{a as C}from"../chunk-SAAGVLRE.js";import{a as b}from"../chunk-CQCBYE3X.js";import{a as D}from"../chunk-JRALYIRA.js";import{a as U,b as S,d as v,g as T,h as B,i as I}from"../chunk-LCWHZUZZ.js";import{b as O}from"../chunk-VOQSWXBS.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";import{createReadStream as Z,createWriteStream as _,statSync as M,readdirSync as z,mkdirSync as P,existsSync as J}from"fs";import{resolve as q,dirname as K,basename as E,join as F,relative as G}from"path";import{homedir as ee}from"os";import{Readable as Q}from"stream";import{pipeline as te}from"stream/promises";import{get as V,put as L,list as oe,head as X}from"@tigrisdata/storage";function re(r,e){let t=U(r),a=U(e);return!t&&!a&&(console.error("At least one path must be a remote Tigris path (t3:// or tigris://)"),process.exit(1)),t&&a?"remote-to-remote":t?"remote-to-local":"local-to-remote"}function Y(r){return r==="~"||r.startsWith("~/")?q(ee(),r.slice(2)):q(r)}function ne(r){return z(r,{recursive:!0,withFileTypes:!0}).filter(t=>t.isFile()).map(t=>{let a=t.parentPath??t.path;return F(a,t.name)})}function ie(r,e){let t=K(r),a=E(r),l=T(a);return J(t)?e?z(t,{recursive:!0,withFileTypes:!0}).filter(o=>o.isFile()&&l.test(o.name)).map(o=>{let i=o.parentPath??o.path;return F(i,o.name)}):z(t,{withFileTypes:!0}).filter(i=>i.isFile()&&l.test(i.name)).map(i=>F(t,i.name)):[]}async function j(r,e,t,a,l=!1){let c;try{c=M(r).size}catch{return{error:`File not found: ${r}`}}let o=Z(r),i=Q.toWeb(o),{error:n}=await L(t,i,{...N(c),onUploadProgress:l?({loaded:s})=>{if(c!==void 0&&c>0){let p=Math.round(s/c*100);process.stdout.write(`\rUploading: ${b(s)} / ${b(c)} (${p}%)`)}else process.stdout.write(`\rUploading: ${b(s)}`)}:void 0,config:{...a,bucket:e}});return l&&process.stdout.write("\r"+" ".repeat(60)+"\r"),n?{error:n.message}:{}}async function H(r,e,t,a,l=!1){let c;if(l){let{data:u}=await X(e,{config:{...a,bucket:r}});c=u?.size}let{data:o,error:i}=await V(e,"stream",{config:{...a,bucket:r}});if(i)return{error:i.message};let n=K(t);J(n)||P(n,{recursive:!0});let s=_(t),p=Q.fromWeb(o);if(l&&c!==void 0&&c>0){let u=0;p.on("data",f=>{u+=f.length;let m=Math.round(u/c*100);process.stdout.write(`\rDownloading: ${b(u)} / ${b(c)} (${m}%)`)})}return await te(p,s),l&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(r,e,t,a,l,c=!1){if(t.endsWith("/")){let{error:p}=await L(l,"",{config:{...r,bucket:a}});return p?{error:p.message}:{}}let o;if(c){let{data:p}=await X(t,{config:{...r,bucket:e}});o=p?.size}let{data:i,error:n}=await V(t,"stream",{config:{...r,bucket:e}});if(n)return{error:n.message};let{error:s}=await L(l,i,{...N(o),onUploadProgress:c?({loaded:p})=>{if(o!==void 0&&o>0){let u=Math.round(p/o*100);process.stdout.write(`\rCopying: ${b(p)} / ${b(o)} (${u}%)`)}else process.stdout.write(`\rCopying: ${b(p)}`)}:void 0,config:{...r,bucket:a}});return c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),s?{error:s.message}:{}}async function ae(r,e,t,a){let l=Y(r);if(r.includes("*")){let i=ie(l,a);if(i.length===0){console.log("No files matching pattern");return}let n=K(l),s=i.map(f=>async()=>{let m=G(n,f),w=e.path?`${e.path.replace(/\/$/,"")}/${m}`:m,d=await j(f,e.bucket,w,t);return d.error?(console.error(`Failed to upload ${f}: ${d.error}`),!1):(console.log(`Uploaded ${f} -> t3://${e.bucket}/${w}`),!0)}),u=(await C(s,8)).filter(Boolean).length;console.log(`Uploaded ${u} file(s)`);return}let o;try{o=M(l)}catch{console.error(`Source not found: ${r}`),process.exit(1)}if(o.isDirectory()){a||(console.error(`${r} is a directory (not copied). Use -r to copy recursively.`),process.exit(1));let i=ne(l);if(i.length===0){console.log("No files to upload");return}let n=r.endsWith("/")?"":E(l),s=i.map(f=>async()=>{let m=G(l,f),d=[e.path?.replace(/\/$/,""),n,m].filter(Boolean).join("/"),W=await j(f,e.bucket,d,t);return W.error?(console.error(`Failed to upload ${f}: ${W.error}`),!1):(console.log(`Uploaded ${f} -> t3://${e.bucket}/${d}`),!0)}),u=(await C(s,8)).filter(Boolean).length;console.log(`Uploaded ${u} file(s)`)}else{let i=E(l),n;e.path?r.endsWith("/")||e.path.endsWith("/")?n=`${e.path.replace(/\/$/,"")}/${i}`:await v(e.bucket,e.path,t)?n=`${e.path}/${i}`:n=e.path:n=i;let s=await j(l,e.bucket,n,t,!0);s.error&&(console.error(s.error),process.exit(1)),console.log(`Uploaded ${r} -> t3://${e.bucket}/${n}`)}}async function se(r,e,t,a,l){let c=r.endsWith("/");!e.path&&!c&&(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let o=Y(t),i=e.path.includes("*"),n=e.path.endsWith("/")||!e.path&&c;if(!i&&!n&&(n=await v(e.bucket,e.path,a)),n&&!i&&!l&&(console.error("Source is a remote folder (not copied). Use -r to copy recursively."),process.exit(1)),i||n){let s=i?B(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",p=!i&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:f}=await I(e.bucket,s||void 0,a);f&&(console.error(f.message),process.exit(1));let m=u.filter(g=>!g.name.endsWith("/"));if(i){let g=e.path.split("/").pop(),$=T(g);m=m.filter(y=>{let h=s?y.name.slice(s.length):y.name;return!l&&h.includes("/")?!1:$.test(h.split("/").pop())})}if(m.length===0){console.log("No objects to download");return}let w=m.map(g=>async()=>{let $=s?g.name.slice(s.length):g.name,y=p?F(o,p,$):F(o,$),h=await H(e.bucket,g.name,y,a);return h.error?(console.error(`Failed to download ${g.name}: ${h.error}`),!1):(console.log(`Downloaded t3://${e.bucket}/${g.name} -> ${y}`),!0)}),W=(await C(w,8)).filter(Boolean).length;console.log(`Downloaded ${W} file(s)`)}else{let s=e.path.split("/").pop(),p,u=!1;try{u=M(o).isDirectory()}catch{}u||t.endsWith("/")?p=F(o,s):p=o;let f=await H(e.bucket,e.path,p,a,!0);f.error&&(console.error(f.error),process.exit(1)),console.log(`Downloaded t3://${e.bucket}/${e.path} -> ${p}`)}}async function le(r,e,t,a,l){let c=r.endsWith("/");!e.path&&!c&&(console.error("Cannot copy a bucket. Provide a path within the bucket."),process.exit(1));let o=r.includes("*"),i=e.path.endsWith("/")||!e.path&&c;if(!o&&!i&&e.path&&(i=await v(e.bucket,e.path,a)),i&&!o&&!l&&(console.error("Source is a remote folder (not copied). Use -r to copy recursively."),process.exit(1)),o||i){let n=o?B(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",s=!o&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",u=[t.path?.replace(/\/$/,"")||"",s].filter(Boolean).join("/"),f=u?`${u}/`:"";e.bucket===t.bucket&&n===f&&(console.error("Source and destination are the same"),process.exit(1));let{items:m,error:w}=await I(e.bucket,n||void 0,a);w&&(console.error(w.message),process.exit(1));let d=m.filter(h=>h.name!==n);if(o){let h=e.path.split("/").pop(),k=T(h);d=d.filter(x=>{let R=n?x.name.slice(n.length):x.name;return!l&&R.includes("/")?!1:k.test(R.split("/").pop())})}let W=d.map(h=>async()=>{let k=n?h.name.slice(n.length):h.name,x=u?`${u}/${k}`:k,R=await A(a,e.bucket,h.name,t.bucket,x);return R.error?(console.error(`Failed to copy ${h.name}: ${R.error}`),!1):(console.log(`Copied t3://${e.bucket}/${h.name} -> t3://${t.bucket}/${x}`),!0)}),$=(await C(W,8)).filter(Boolean).length,y=!1;if(u&&n){let{data:h}=await oe({prefix:n,limit:1,config:{...a,bucket:e.bucket}});if(h?.items?.some(k=>k.name===n)){let k=`${u}/`,x=await A(a,e.bucket,n,t.bucket,k);x.error?console.error(`Failed to copy folder marker: ${x.error}`):y=!0}}if($===0&&y&&($=1),$===0){console.log("No objects to copy");return}console.log(`Copied ${$} object(s)`)}else{let n=e.path.split("/").pop(),s;t.path?t.path.endsWith("/")?s=`${t.path}${n}`:await v(t.bucket,t.path,a)?s=`${t.path}/${n}`:s=t.path:s=n,e.bucket===t.bucket&&e.path===s&&(console.error("Source and destination are the same"),process.exit(1));let p=await A(a,e.bucket,e.path,t.bucket,s,!0);p.error&&(console.error(p.error),process.exit(1)),console.log(`Copied t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${s}`)}}async function ce(r){let e=D(r,["src"]),t=D(r,["dest"]);(!e||!t)&&(console.error("Both src and dest arguments are required"),process.exit(1));let a=!!D(r,["recursive","r"]),l=re(e,t),c=await O({withCredentialProvider:!0});switch(l){case"local-to-remote":{let o=S(t);o.bucket||(console.error("Invalid destination path"),process.exit(1)),await ae(e,o,c,a);break}case"remote-to-local":{let o=S(e);o.bucket||(console.error("Invalid source path"),process.exit(1)),await se(e,o,t,c,a);break}case"remote-to-remote":{let o=S(e),i=S(t);o.bucket||(console.error("Invalid source path"),process.exit(1)),i.bucket||(console.error("Invalid destination path"),process.exit(1)),await le(e,o,i,c,a);break}}process.exit(0)}export{ce as default};
1
+ import{a as B}from"../chunk-EKW6XTGL.js";import{a as j}from"../chunk-SAAGVLRE.js";import{a as w}from"../chunk-CQCBYE3X.js";import{a as O,b as T,d as D,g as x,h as U,i as J}from"../chunk-LCWHZUZZ.js";import{a as N}from"../chunk-JRALYIRA.js";import{b as q}from"../chunk-IJYKPR4W.js";import{a as f}from"../chunk-GHTFMDGV.js";import"../chunk-DV3LCXRH.js";import"../chunk-5LRGY6RN.js";import"../chunk-BETAO4PB.js";import"../chunk-E4MLGABW.js";import"../chunk-DOUR5YEY.js";import"../chunk-KH63ANUX.js";import"../chunk-2XAO2OYD.js";import{createReadStream as P,createWriteStream as tt,statSync as L,readdirSync as E,mkdirSync as et,existsSync as Q}from"fs";import{resolve as G,dirname as K,basename as z,join as v,relative as _}from"path";import{homedir as ot}from"os";import{Readable as V}from"stream";import{pipeline as it}from"stream/promises";import{get as X,put as M,list as nt,head as Y}from"@tigrisdata/storage";var h=!1;function rt(i,t){let e=O(i),l=O(t);return!e&&!l&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&l?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?G(ot(),i.slice(2)):G(i)}function at(i){return E(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let l=e.parentPath??e.path;return v(l,e.name)})}function lt(i,t){let e=K(i),l=z(i),s=x(l);return Q(e)?t?E(e,{recursive:!0,withFileTypes:!0}).filter(a=>a.isFile()&&s.test(a.name)).map(a=>{let n=a.parentPath??a.path;return v(n,a.name)}):E(e,{withFileTypes:!0}).filter(n=>n.isFile()&&s.test(n.name)).map(n=>v(e,n.name)):[]}async function I(i,t,e,l,s=!1){let u;try{u=L(i).size}catch{return{error:`File not found: ${i}`}}let a=P(i),n=V.toWeb(a),{error:o}=await M(e,n,{...B(u),onUploadProgress:s?({loaded:r})=>{if(u!==void 0&&u>0){let c=Math.round(r/u*100);process.stdout.write(`\rUploading: ${w(r)} / ${w(u)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(r)}`)}:void 0,config:{...l,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),o?{error:o.message}:{}}async function H(i,t,e,l,s=!1){let u;if(s){let{data:p}=await Y(t,{config:{...l,bucket:i}});u=p?.size}let{data:a,error:n}=await X(t,"stream",{config:{...l,bucket:i}});if(n)return{error:n.message};let o=K(e);Q(o)||et(o,{recursive:!0});let r=tt(e),c=V.fromWeb(a);if(s&&u!==void 0&&u>0){let p=0;c.on("data",m=>{p+=m.length;let g=Math.round(p/u*100);process.stdout.write(`\rDownloading: ${w(p)} / ${w(u)} (${g}%)`)})}return await it(c,r),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(i,t,e,l,s,u=!1){if(e.endsWith("/")){let{error:c}=await M(s,"",{config:{...i,bucket:l}});return c?{error:c.message}:{}}let a;if(u){let{data:c}=await Y(e,{config:{...i,bucket:t}});a=c?.size}let{data:n,error:o}=await X(e,"stream",{config:{...i,bucket:t}});if(o)return{error:o.message};let{error:r}=await M(s,n,{...B(a),onUploadProgress:u?({loaded:c})=>{if(a!==void 0&&a>0){let p=Math.round(c/a*100);process.stdout.write(`\rCopying: ${w(c)} / ${w(a)} (${p}%)`)}else process.stdout.write(`\rCopying: ${w(c)}`)}:void 0,config:{...i,bucket:l}});return u&&process.stdout.write("\r"+" ".repeat(60)+"\r"),r?{error:r.message}:{}}async function ct(i,t,e,l){let s=Z(i);if(i.includes("*")){let n=lt(s,l);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let o=K(s),r=n.map(m=>async()=>{let g=_(o,m),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,$=await I(m,t.bucket,k,e);return $.error?(console.error(`Failed to upload ${m}: ${$.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),p=(await j(r,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:p}):`Uploaded ${p} file(s)`);return}let a;try{a=L(s)}catch{f(`Source not found: ${i}`)}if(a.isDirectory()){l||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let n=at(s);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("/")?"":z(s),r=n.map(m=>async()=>{let g=_(s,m),$=[t.path?.replace(/\/$/,""),o,g].filter(Boolean).join("/"),R=await I(m,t.bucket,$,e);return R.error?(console.error(`Failed to upload ${m}: ${R.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${$}`),!0)}),p=(await j(r,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:p}):`Uploaded ${p} file(s)`)}else{let n=z(s),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 r=await I(s,t.bucket,o,e,!h);r.error&&f(r.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 st(i,t,e,l,s){let u=i.endsWith("/");!t.path&&!u&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=Z(e),n=t.path.includes("*"),o=t.path.endsWith("/")||!t.path&&u;if(!n&&!o&&(o=await D(t.bucket,t.path,l)),o&&!n&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),n||o){let r=n?U(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",c=!n&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:p,error:m}=await J(t.bucket,r||void 0,l);m&&f(m);let g=p.filter(y=>!y.name.endsWith("/"));if(n){let y=t.path.split("/").pop(),b=x(y);g=g.filter(S=>{let d=r?S.name.slice(r.length):S.name;return!s&&d.includes("/")?!1:b.test(d.split("/").pop())})}if(g.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let k=g.map(y=>async()=>{let b=r?y.name.slice(r.length):y.name,S=c?v(a,c,b):v(a,b),d=await H(t.bucket,y.name,S,l);return d.error?(console.error(`Failed to download ${y.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),R=(await j(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let r=t.path.split("/").pop(),c,p=!1;try{p=L(a).isDirectory()}catch{}p||e.endsWith("/")?c=v(a,r):c=a;let m=await H(t.bucket,t.path,c,l,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:c}):`Downloaded t3://${t.bucket}/${t.path} -> ${c}`)}}async function pt(i,t,e,l,s){let u=i.endsWith("/");!t.path&&!u&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=i.includes("*"),n=t.path.endsWith("/")||!t.path&&u;if(!a&&!n&&t.path&&(n=await D(t.bucket,t.path,l)),n&&!a&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),a||n){let o=a?U(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",r=!a&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",p=[e.path?.replace(/\/$/,"")||"",r].filter(Boolean).join("/"),m=p?`${p}/`:"";t.bucket===e.bucket&&o===m&&f("Source and destination are the same");let{items:g,error:k}=await J(t.bucket,o||void 0,l);k&&f(k);let $=g.filter(d=>d.name!==o);if(a){let d=t.path.split("/").pop(),F=x(d);$=$.filter(W=>{let C=o?W.name.slice(o.length):W.name;return!s&&C.includes("/")?!1:F.test(C.split("/").pop())})}let R=$.map(d=>async()=>{let F=o?d.name.slice(o.length):d.name,W=p?`${p}/${F}`:F,C=await A(l,t.bucket,d.name,e.bucket,W);return C.error?(console.error(`Failed to copy ${d.name}: ${C.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${d.name} -> t3://${e.bucket}/${W}`),!0)}),b=(await j(R,8)).filter(Boolean).length,S=!1;if(p&&o){let{data:d}=await nt({prefix:o,limit:1,config:{...l,bucket:t.bucket}});if(d?.items?.some(F=>F.name===o)){let F=`${p}/`,W=await A(l,t.bucket,o,e.bucket,F);W.error?console.error(`Failed to copy folder marker: ${W.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let o=t.path.split("/").pop(),r;e.path?e.path.endsWith("/")?r=`${e.path}${o}`:await D(e.bucket,e.path,l)?r=`${e.path}/${o}`:r=e.path:r=o,t.bucket===e.bucket&&t.path===r&&f("Source and destination are the same");let c=await A(l,t.bucket,t.path,e.bucket,r,!h);c.error&&f(c.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${r}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${r}`)}}async function ut(i){let t=N(i,["src"]),e=N(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let l=!!N(i,["recursive","r"]);h=(N(i,["json"])?"json":N(i,["format"],"table"))==="json";let a=rt(t,e),n=await q({withCredentialProvider:!0});switch(a){case"local-to-remote":{let o=T(e);o.bucket||f("Invalid destination path"),await ct(t,o,n,l);break}case"remote-to-local":{let o=T(t);o.bucket||f("Invalid source path"),await st(t,o,e,n,l);break}case"remote-to-remote":{let o=T(t),r=T(e);o.bucket||f("Invalid source path"),r.bucket||f("Invalid destination path"),await pt(t,o,r,n,l);break}}process.exit(0)}export{ut as default};
@@ -1 +1 @@
1
- import{a as f,b as g,c as n,g as u}from"../../chunk-SYGTCM6P.js";import{a as d}from"../../chunk-JRALYIRA.js";import{b as l}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as a}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as m,getBucketInfo as p}from"@tigrisdata/storage";var e=u("credentials","test");async function b(k){f(e);let t=d(k,["bucket","b"]),o=await l();!o.accessKeyId&&!o.sessionToken&&(n(e,'No credentials found. Run "tigris configure" or "tigris login" first.'),process.exit(1));let c=a(),r={...o,...c&&!o.organizationId?{organizationId:c}:{}};if(t){let{data:i,error:s}=await p(t,{config:r});s&&(n(e,`Current credentials don't have access to bucket "${t}"`),process.exit(1)),console.log(` Bucket: ${t}`),console.log(" Access verified."),i.sourceBucketName&&console.log(` Fork of: ${i.sourceBucketName}`)}else{let{data:i,error:s}=await m({config:r});s&&(n(e,"Current credentials don't have sufficient access"),process.exit(1)),console.log(` Access verified. Found ${i.buckets.length} bucket(s).`)}g(e)}export{b as default};
1
+ import{a as c}from"../../chunk-JRALYIRA.js";import{b}from"../../chunk-IJYKPR4W.js";import{a as s}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as l,c as d,d as r,i as m}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import{g as k}from"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as p,getBucketInfo as N}from"@tigrisdata/storage";var e=m("credentials","test");async function B(a){l(e);let f=c(a,["json"])?"json":c(a,["format","f","F"],"table"),t=c(a,["bucket","b"]),i=await b();!i.accessKeyId&&!i.sessionToken&&(r(e,'No credentials found. Run "tigris configure" or "tigris login" first.'),s('No credentials found. Run "tigris configure" or "tigris login" first.',e));let g=k(),u={...i,...g&&!i.organizationId?{organizationId:g}:{}};if(t){let{data:o,error:n}=await N(t,{config:u});n&&(r(e,`Current credentials don't have access to bucket "${t}"`),s(n,e)),f==="json"?console.log(JSON.stringify({valid:!0,bucket:t,...o.sourceBucketName?{forkOf:o.sourceBucketName}:{}})):(console.log(` Bucket: ${t}`),console.log(" Access verified."),o.sourceBucketName&&console.log(` Fork of: ${o.sourceBucketName}`))}else{let{data:o,error:n}=await p({config:u});n&&(r(e,"Current credentials don't have sufficient access"),s(n,e)),console.log(f==="json"?JSON.stringify({valid:!0,bucketCount:o.buckets.length}):` Access verified. Found ${o.buckets.length} bucket(s).`)}d(e)}export{B as default};
@@ -1 +1 @@
1
- import{a as c,b as a,c as r,g as m}from"../../chunk-SYGTCM6P.js";import{a as t}from"../../chunk-JRALYIRA.js";import{b as f}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createBucket as p}from"@tigrisdata/storage";var e=m("forks","create");async function g(o){c(e);let s=t(o,["name"]),n=t(o,["fork-name","forkName"]),u=t(o,["snapshot","s","S"]);s||(r(e,"Source bucket name is required"),process.exit(1)),n||(r(e,"Fork name is required"),process.exit(1));let{error:i}=await p(n,{sourceBucketName:s,sourceBucketSnapshot:u,config:await f()});i&&(r(e,i.message),process.exit(1)),a(e,{name:s,forkName:n})}export{g as default};
1
+ import{a as o}from"../../chunk-JRALYIRA.js";import{b as f}from"../../chunk-IJYKPR4W.js";import{a as t}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as m,d as e,i as u}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{createBucket as g}from"@tigrisdata/storage";var r=u("forks","create");async function p(i){c(r);let n=o(i,["name"]),a=o(i,["fork-name","forkName"]),k=o(i,["snapshot","s","S"]);n||(e(r,"Source bucket name is required"),t("Source bucket name is required",r)),a||(e(r,"Fork name is required"),t("Fork name is required",r));let{error:s}=await g(a,{sourceBucketName:n,sourceBucketSnapshot:k,config:await f()});s&&(e(r,s.message),t(s,r)),m(r,{name:n,forkName:a})}export{p as default};
@@ -1 +1 @@
1
- import{a as u,b as p,c as n,d as s,g}from"../../chunk-SYGTCM6P.js";import{f as d}from"../../chunk-CQCBYE3X.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as k}from"../../chunk-VOQSWXBS.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as S,getBucketInfo as l}from"@tigrisdata/storage";var t=g("forks","list");async function B(c){u(t);let e=i(c,["name"]),h=i(c,["format","f","F"],"table");e||(n(t,"Source bucket name is required"),process.exit(1));let a=await k(),{data:b,error:f}=await l(e,{config:a});if(f&&(n(t,f.message),process.exit(1)),!b.hasForks){s(t);return}let{data:w,error:m}=await S({config:a});m&&(n(t,m.message),process.exit(1));let r=[];for(let o of w.buckets){if(o.name===e)continue;let{data:y}=await l(o.name,{config:a});y?.sourceBucketName===e&&r.push({name:o.name,created:o.creationDate})}if(r.length===0){s(t);return}let x=d(r,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(x),p(t,{count:r.length})}export{B as default};
1
+ import{f as l}from"../../chunk-CQCBYE3X.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as d}from"../../chunk-IJYKPR4W.js";import{a}from"../../chunk-GHTFMDGV.js";import"../../chunk-DV3LCXRH.js";import{b as g,c as k,d as n,e as u,i as p}from"../../chunk-5LRGY6RN.js";import"../../chunk-BETAO4PB.js";import"../../chunk-E4MLGABW.js";import"../../chunk-DOUR5YEY.js";import"../../chunk-KH63ANUX.js";import"../../chunk-2XAO2OYD.js";import{listBuckets as x,getBucketInfo as b}from"@tigrisdata/storage";var t=p("forks","list");async function B(s){g(t);let e=i(s,["name"]),h=i(s,["json"])?"json":i(s,["format","f","F"],"table");e||(n(t,"Source bucket name is required"),a("Source bucket name is required",t));let c=await d(),{data:w,error:f}=await b(e,{config:c});if(f&&(n(t,f.message),a(f,t)),!w.hasForks){u(t);return}let{data:y,error:m}=await x({config:c});m&&(n(t,m.message),a(m,t));let r=[];for(let o of y.buckets){if(o.name===e)continue;let{data:j}=await b(o.name,{config:c});j?.sourceBucketName===e&&r.push({name:o.name,created:o.creationDate})}if(r.length===0){u(t);return}let S=l(r,h,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(S),k(t,{count:r.length})}export{B as default};
@@ -1,2 +1,3 @@
1
- import{a as x,b as P}from"../../../chunk-Y7MJZRR4.js";import{a as p,b as f,c as e,g as h}from"../../../chunk-SYGTCM6P.js";import{a as n}from"../../../chunk-JRALYIRA.js";import{a as y}from"../../../chunk-VOQSWXBS.js";import"../../../chunk-BETAO4PB.js";import{b as g}from"../../../chunk-E4MLGABW.js";import{g as u}from"../../../chunk-DOUR5YEY.js";import{c as l}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import{existsSync as T,readFileSync as C}from"fs";import{addPolicy as k}from"@tigrisdata/iam";var t=h("iam policies","create");async function N(s){p(t);let r=n(s,["name"]),i=n(s,["document","d"]),w=n(s,["description"])??"";r||(e(t,"Policy name is required"),process.exit(1)),/^[a-zA-Z0-9=,.@_-]+$/.test(r)||(e(t,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed."),process.exit(1)),await y()!=="oauth"&&(e(t,`Policies can only be created when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let c=g();await c.isAuthenticated()||(e(t,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let A=await c.getAccessToken(),v=u(),S=l(),O={sessionToken:A,organizationId:v??void 0,iamEndpoint:S.iamEndpoint},o;i?T(i)?o=C(i,"utf-8"):o=i:process.stdin.isTTY?(e(t,"Policy document is required. Provide via --document or pipe to stdin."),process.exit(1)):o=await x();let a;try{a=P(o)}catch{e(t,"Invalid JSON in policy document"),process.exit(1)}let{data:d,error:m}=await k(r,{document:a,description:w,config:O});m&&(e(t,m.message),process.exit(1)),f(t,{name:d.name}),console.log(`Resource: ${d.resource}`)}export{N as default};
1
+ import{a as v,b as w}from"../../../chunk-Y7MJZRR4.js";import{a as r}from"../../../chunk-JRALYIRA.js";import{a as P}from"../../../chunk-IJYKPR4W.js";import{a as e}from"../../../chunk-GHTFMDGV.js";import"../../../chunk-DV3LCXRH.js";import{b as u,c as g,d as t,i as p}from"../../../chunk-5LRGY6RN.js";import"../../../chunk-BETAO4PB.js";import{b as y}from"../../../chunk-E4MLGABW.js";import{g as h}from"../../../chunk-DOUR5YEY.js";import{c as f}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import{existsSync as T,readFileSync as C}from"fs";import{addPolicy as I}from"@tigrisdata/iam";var i=p("iam policies","create");async function k(a){u(i);let c=r(a,["name"]),n=r(a,["document","d"]),A=r(a,["description"])??"";c||(t(i,"Policy name is required"),e("Policy name is required",i)),/^[a-zA-Z0-9=,.@_-]+$/.test(c)||(t(i,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed."),e("Invalid policy name. Only alphanumeric characters and =,.@_- are allowed.",i)),await P()!=="oauth"&&(t(i,`Policies can only be created when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),e(`Policies can only be created when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,i));let d=y();await d.isAuthenticated()||(t(i,'Not authenticated. Run "tigris login oauth" first.'),e('Not authenticated. Run "tigris login oauth" first.',i));let O=await d.getAccessToken(),S=h(),N=f(),R={sessionToken:O,organizationId:S??void 0,iamEndpoint:N.iamEndpoint},o;n?T(n)?o=C(n,"utf-8"):o=n:process.stdin.isTTY?(t(i,"Policy document is required. Provide via --document or pipe to stdin."),e("Policy document is required. Provide via --document or pipe to stdin.",i)):o=await v();let l;try{l=w(o)}catch{t(i,"Invalid JSON in policy document"),e("Invalid JSON in policy document",i)}let{data:m,error:s}=await I(c,{document:l,description:A,config:R});s&&(t(i,s.message),e(s,i)),g(i,{name:m.name}),console.log(`Resource: ${m.resource}`)}export{k as default};
@@ -1,2 +1,3 @@
1
- import{a as p,b as d,c as t,d as f,g as u}from"../../../chunk-SYGTCM6P.js";import{a as w}from"../../../chunk-JRALYIRA.js";import{a as h}from"../../../chunk-VOQSWXBS.js";import"../../../chunk-BETAO4PB.js";import{b as m}from"../../../chunk-E4MLGABW.js";import{g}from"../../../chunk-DOUR5YEY.js";import{c as l}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import E from"enquirer";import{deletePolicy as S,listPolicies as T}from"@tigrisdata/iam";var{prompt:O}=E,e=u("iam policies","delete");async function M(x){p(e);let i=w(x,["resource"]);await h()!=="oauth"&&(t(e,`Policies can only be deleted when logged in via OAuth.
2
- Run "tigris login oauth" first.`),process.exit(1));let s=m();await s.isAuthenticated()||(t(e,'Not authenticated. Run "tigris login oauth" first.'),process.exit(1));let y=await s.getAccessToken(),A=g(),C=l(),r={sessionToken:y,organizationId:A??void 0,iamEndpoint:C.iamEndpoint};if(!i){let{data:o,error:a}=await T({config:r});if(a&&(t(e,a.message),process.exit(1)),!o.policies||o.policies.length===0){f(e);return}let{selected:k}=await O({type:"select",name:"selected",message:"Select a policy to delete:",choices:o.policies.map(n=>({name:n.resource,message:`${n.name} (${n.resource})`}))});i=k}let{error:c}=await S(i,{config:r});c&&(t(e,c.message),process.exit(1)),d(e,{resource:i})}export{M as default};
1
+ import{a,b as R}from"../../../chunk-S77OAN6Y.js";import{a as l}from"../../../chunk-JRALYIRA.js";import{a as k}from"../../../chunk-IJYKPR4W.js";import{a as o}from"../../../chunk-GHTFMDGV.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as u,d as i,e as p,i as h}from"../../../chunk-5LRGY6RN.js";import"../../../chunk-BETAO4PB.js";import{b as A}from"../../../chunk-E4MLGABW.js";import{g as w}from"../../../chunk-DOUR5YEY.js";import{c as y}from"../../../chunk-KH63ANUX.js";import"../../../chunk-2XAO2OYD.js";import v from"enquirer";import{deletePolicy as T,listPolicies as x}from"@tigrisdata/iam";var{prompt:S}=v,e=h("iam policies","delete");async function M(g){d(e);let t=l(g,["resource"]),C=l(g,["force","yes","y"]);await k()!=="oauth"&&(i(e,`Policies can only be deleted when logged in via OAuth.
2
+ Run "tigris login oauth" first.`),o(`Policies can only be deleted when logged in via OAuth.
3
+ Run "tigris login oauth" first.`,e));let m=A();await m.isAuthenticated()||(i(e,'Not authenticated. Run "tigris login oauth" first.'),o('Not authenticated. Run "tigris login oauth" first.',e));let E=await m.getAccessToken(),O=w(),P=y(),f={sessionToken:E,organizationId:O??void 0,iamEndpoint:P.iamEndpoint};if(!t){let{data:n,error:s}=await x({config:f});if(s&&(i(e,s.message),o(s,e)),!n.policies||n.policies.length===0){p(e);return}a("Provide the policy ARN as a positional argument");let{selected:b}=await S({type:"select",name:"selected",message:"Select a policy to delete:",choices:n.policies.map(c=>({name:c.resource,message:`${c.name} (${c.resource})`}))});t=b}if(!C&&(a("Use --yes to skip confirmation"),!await R(`Delete policy '${t}'?`))){console.log("Aborted");return}let{error:r}=await T(t,{config:f});r&&(i(e,r.message),o(r,e)),u(e,{resource:t})}export{M as default};