@tigrisdata/cli 3.0.0-beta.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +630 -512
  2. package/dist/chunk-G4DHMSCQ.js +8 -0
  3. package/dist/chunk-GLKOUVFH.js +8 -0
  4. package/dist/chunk-LAB2KJTN.js +1 -0
  5. package/dist/chunk-N3Y6RFSK.js +1 -0
  6. package/dist/{chunk-EBWDZEHM.js → chunk-RZPBM4CD.js} +1 -1
  7. package/dist/{chunk-ABUCZZSA.js → chunk-WE7KHYIP.js} +1 -1
  8. package/dist/cli-core.js +1 -1
  9. package/dist/cli.js +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/lib/buckets/create.js +1 -1
  12. package/dist/lib/buckets/get.js +1 -1
  13. package/dist/lib/buckets/lifecycle/create.js +1 -1
  14. package/dist/lib/buckets/lifecycle/edit.js +1 -1
  15. package/dist/lib/buckets/lifecycle/list.js +1 -1
  16. package/dist/lib/buckets/lifecycle/shared.js +1 -1
  17. package/dist/lib/buckets/list.js +1 -1
  18. package/dist/lib/buckets/restore.js +1 -0
  19. package/dist/lib/buckets/set-locations.js +1 -1
  20. package/dist/lib/buckets/set.js +1 -1
  21. package/dist/lib/cp.js +1 -1
  22. package/dist/lib/iam/policies/edit.js +1 -1
  23. package/dist/lib/mk.js +1 -1
  24. package/dist/lib/mv.js +1 -1
  25. package/dist/lib/objects/delete.js +1 -1
  26. package/dist/lib/objects/get.js +1 -1
  27. package/dist/lib/objects/info.js +1 -1
  28. package/dist/lib/objects/list-versions.js +6 -0
  29. package/dist/lib/objects/put.js +1 -1
  30. package/dist/lib/objects/set-access.js +1 -0
  31. package/dist/lib/objects/set.js +1 -1
  32. package/dist/lib/stat.js +1 -1
  33. package/dist/lib/update.js +1 -1
  34. package/dist/specs.yaml +116 -3
  35. package/dist/utils/bucket-info.js +1 -1
  36. package/dist/utils/locations.js +1 -1
  37. package/dist/utils/update-check.js +1 -1
  38. package/package.json +2 -2
  39. package/dist/chunk-HWX63Y3P.js +0 -1
  40. package/dist/chunk-K4QARFBT.js +0 -8
  41. package/dist/chunk-QWZ6FK7E.js +0 -8
  42. package/dist/chunk-TD2HGNDY.js +0 -1
@@ -0,0 +1,8 @@
1
+ import{a as w}from"./chunk-UBANDLB4.js";import{h as C}from"./chunk-7ZUCJBD5.js";import{Command as q,Option as L}from"commander";function A(n,t,e,a,o){let r=n[n.length-1],s=typeof r=="object"&&r!==null&&"args"in r?r.args:n.filter(m=>typeof m=="string");if(s.length===0)return s;let l=s[0],d=(t.commands??[]).filter(m=>g(m,[...e,m.name],o));if(!new Set(d.flatMap(m=>[m.name,...Array.isArray(m.alias)?m.alias:m.alias?[m.alias]:[]])).has(l)){let m=d.map(u=>u.name),p=e.length>0?`'${l}' for '${e.join(" ")}'`:`'${l}'`;console.error(`Unknown command ${p}.`),m.length>0&&console.error(`Available commands: ${m.join(", ")}`);let f=e.length>0?`${a.name} ${e.join(" ")} help`:`${a.name} help`;console.error(`
2
+ Run "${f}" for usage.`),process.exit(1)}return s}function G(){process.on("unhandledRejection",n=>{(n===""||n===void 0)&&(console.error(`
3
+ Operation cancelled`),process.exit(1)),w(n)}),process.on("uncaughtException",n=>{w(n)})}function U(n){return/^[a-zA-Z0-9_-]+$/.test(n)}function D(n){let t;n.type==="positional"?t=` ${n.name}`:(t=` --${n.name}`,n.alias&&typeof n.alias=="string"&&(t+=n.alias.length===1?`, -${n.alias}`:`, --${n.alias}`));let e=26,a=t.length>=e?t+" ":t.padEnd(e),o=n.description;return n.options&&(Array.isArray(n.options)&&typeof n.options[0]=="string"?o+=` (options: ${n.options.join(", ")})`:o+=` (options: ${n.options.map(r=>r.value).join(", ")})`),n.default&&(o+=` [default: ${n.default}]`),n.required&&(o+=" [required]"),n.deprecated&&(o+=n.replaced_by?` [deprecated: use ${n.replaced_by}]`:" [deprecated]"),n["required-when"]&&(o+=` [required when: ${n["required-when"]}]`),n.multiple&&(o+=" [multiple values: comma-separated]"),n.type==="positional"&&(o+=" [positional argument]"),n.examples&&n.examples.length>0&&(o+=` (examples: ${n.examples.join(", ")})`),`${a}${o}`}function g(n,t,e){return n.removed||e(t)?!0:n.commands?n.commands.some(a=>g(a,[...t,a.name],e)):!1}function R(n,t){let e=t?` Use ${t} instead.`:" See the changelog for migration guidance.";console.error(`${n} was removed in this version.${e}`),process.exit(1)}function v(n,t){if(n)for(let e of n){if(!e.removed)continue;h(t,e.name,n)!==void 0&&R(`--${e.name}`,e.replaced_by)}}function b(n,t,e,a){let o=e.join(" ");if(console.log(`
4
+ ${n.name} ${o} - ${t.description??""}
5
+ `),t.commands&&t.commands.length>0){let l=t.commands.filter(i=>!i.removed&&g(i,[...e,i.name],a));l.length>0&&(console.log("Commands:"),l.forEach(i=>{let d=` ${i.name}`;if(i.alias){let m=Array.isArray(i.alias)?i.alias:[i.alias];d+=` (${m.join(", ")})`}let c=d.padEnd(24);console.log(`${c}${i.description??""}`)}),console.log())}let r=n.definitions?.global_arguments??[],s=y(r,t.arguments).filter(l=>!l.removed);s.length>0&&(console.log("Arguments:"),s.forEach(l=>{console.log(D(l))}),console.log()),t.examples&&t.examples.length>0&&(console.log("Examples:"),t.examples.forEach(l=>{console.log(` ${l}`)}),console.log()),t.commands&&t.commands.length>0&&console.log(`Use "${n.name} ${o} <command> help" for more information about a command.`)}function k(n,t,e){console.log(`Tigris CLI Version: ${t}
6
+ `),console.log(`Usage: tigris [command] [options]
7
+ `),console.log("Commands:"),n.commands.filter(o=>!o.removed&&g(o,[o.name],e)).forEach(o=>{let r=` ${o.name}`;if(o.alias){let l=Array.isArray(o.alias)?o.alias:[o.alias];r+=` (${l.join(", ")})`}let s=r.padEnd(24);console.log(`${s}${o.description??""}`)}),console.log(`
8
+ Use "${n.name} <command> help" for more information about a command.`)}function y(n,t){let e=t??[],a=new Set(e.map(s=>s.name)),o=new Set(e.filter(s=>s.alias).map(s=>s.alias)),r=n.filter(s=>!a.has(s.name)&&!(s.alias&&o.has(s.alias)));return[...e,...r]}function E(n,t=[]){t.forEach(e=>{if(e.type==="positional"){let a=e.required?`<${e.name}>`:`[${e.name}]`;n.argument(a,e.description)}else{let a=e.alias&&typeof e.alias=="string"&&e.alias.length===1,o=e.alias&&typeof e.alias=="string"&&e.alias.length>1,r=a?`-${e.alias}, --${e.name}`:o?`--${e.alias}, --${e.name}`:`--${e.name}`;if(e.type==="flag"||(e.type==="boolean"?r+=" [value]":e.options?r+=" <value>":r+=e.required||e["required-when"]?" <value>":" [value]"),e.removed)n.addOption(new L(r,e.description??"").hideHelp());else{let s=e.description??"";if(e.deprecated){let l=e.replaced_by?` Use ${e.replaced_by} instead.`:"";s=`(deprecated) ${s}${l}`}n.option(r,s,e.default)}}})}function M(n){return n.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function h(n,t,e){if(e){let o=e.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(n[r]!==void 0)return n[r]}}let a=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),M(t)];for(let o of a)if(n[o]!==void 0)return n[o]}function S(n,t){for(let e of n){if(e["required-when"]){let[a,o]=e["required-when"].split("="),r=h(t,a,n),s=h(t,e.name,n);if(r===o&&!s)return console.error(`--${e.name} is required when --${a} is ${o}`),!1}if(e.required&&!h(t,e.name,n))return console.error(`--${e.name} is required`),!1}return!0}function j(n,t,e){let a;"optsWithGlobals"in e&&typeof e.optsWithGlobals=="function"?a=e.optsWithGlobals():"opts"in e&&typeof e.opts=="function"?a=e.opts():a=e;let o={...a};return n.filter(s=>s.type==="positional").forEach((s,l)=>{t[l]!==void 0&&(s.multiple?o[s.name]=t[l].split(",").map(i=>i.trim()):o[s.name]=t[l])}),n.forEach(s=>{s.multiple&&s.type!=="positional"&&o[s.name]&&typeof o[s.name]=="string"&&(o[s.name]=o[s.name].split(",").map(l=>l.trim()))}),o}async function I(n,t,e=[],a={}){(a.json||a.format==="json")&&(globalThis.__TIGRIS_JSON_MODE=!0);let{module:o,error:r}=await n(t);(r||!o)&&(console.error(r),process.exit(1));let s=t[t.length-1],l=o.default||o[s];typeof l!="function"&&(console.error(`Command not implemented: ${t.join(" ")}`),process.exit(1)),await l({...a,_positional:e})}function _(n,t,e,a=[]){let{specs:o,loadModule:r,hasImplementation:s}=n,l=o.definitions?.global_arguments??[];for(let i of e){U(i.name)||(console.error(`Invalid command name "${i.name}": only alphanumeric, hyphens, and underscores allowed`),process.exit(1));let d=[...a,i.name];if(!g(i,d,s))continue;let c=t.command(i.name,i.removed?{hidden:!0}:void 0).description(i.description??"");if(i.alias&&(Array.isArray(i.alias)?i.alias:[i.alias]).forEach(p=>c.alias(p)),i.removed){c.allowUnknownOption(!0),c.allowExcessArguments(!0),c.action(()=>{R(`${o.name} ${d.join(" ")}`,i.replaced_by)});continue}if(i.commands&&i.commands.length>0)if(_(n,c,i.commands,d),i.default){let m=i.commands.find(p=>p.name===i.default);if(m){let p=y(l,[...i.arguments||[],...m.arguments||[]]);E(c,p),c.allowExcessArguments(!0),c.action(async(...f)=>{let u=f.pop(),x=A([u],i,d,o,s),$=j(p,x,u);p.length>0&&!S(p,$)||(v(p,$),m.deprecated&&m.messages?.onDeprecated&&C(m.messages.onDeprecated),await I(r,[...d,m.name],x,$))})}}else c.allowExcessArguments(!0),c.action((...m)=>{A(m,i,d,o,s),b(o,i,d,s)});else E(c,y(l,i.arguments)),c.action(async(...m)=>{let p=m.pop(),f=m,u=j(i.arguments||[],f,p);i.arguments&&!S(i.arguments,u)||(v(i.arguments,u),i.deprecated&&i.messages?.onDeprecated&&C(i.messages.onDeprecated),await I(r,d,f,u))});c.command("help").description("Show help for this command").action(()=>{b(o,i,d,s)})}}function P(n){let{specs:t,version:e,hasImplementation:a}=n,o=new q;return o.name(t.name).description(t.description).version(e),_(n,o,t.commands),o.command("help").description("Show general help").action(()=>{k(t,e,a)}),o.command("version").description("Show the CLI version").action(()=>{console.log(e)}),o.allowExcessArguments(!0),o.action((...r)=>{A(r,{commands:t.commands},[],t,a),k(t,e,a)}),o}export{G as a,U as b,D as c,g as d,b as e,k as f,E as g,S as h,j as i,_ as j,P as k};
@@ -0,0 +1,8 @@
1
+ import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{mkdirSync as w,readFileSync as _,realpathSync as E,writeFileSync as I}from"fs";import x from"https";import{homedir as g}from"os";import{join as h}from"path";var u="3.1.0";var b=h(g(),".tigris","update-check.json");function y(){try{let e=_(b,"utf-8"),n=JSON.parse(e);return typeof n.latestVersion=="string"&&typeof n.lastChecked=="number"?n:null}catch{return null}}function v(e){try{w(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function T(e,n){let a=i=>{let s=i.startsWith("v")?i.slice(1):i,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(e),t=a(n);return!r||!t?!1:t.major>r.major?!0:t.major<r.major?!1:t.minor>r.minor?!0:t.minor<r.minor?!1:t.patch>r.patch?!0:t.patch<r.patch?!1:r.prerelease&&!t.prerelease?!0:(!r.prerelease&&t.prerelease,!1)}function N(){if(process.platform==="win32")return!1;try{let e=E(process.execPath);return e.includes("/Cellar/")||e.includes("/Caskroom/")}catch{return!1}}function M(){return globalThis.__TIGRIS_BINARY===!0?N()?"brew upgrade tigris":process.platform==="win32"?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function k(e={}){return new Promise((n,a)=>{let r=x.get(m,{timeout:1e4},t=>{let i="";t.on("data",s=>{i+=s}),t.on("end",()=>{try{let s=JSON.parse(i);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),n(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",t=>{a(t)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),e.unref&&r.on("socket",t=>{t.unref()}),r.end()})}function j(){k({unref:!0}).catch(()=>{})}function O(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),n=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(e&&T(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>n)){let r=`Update available: ${u} \u2192 ${e.latestVersion}`,t='Run "tigris update" to upgrade.',i=Math.max(r.length,t.length)+4,s="\u250C"+"\u2500".repeat(i-2)+"\u2510",l="\u2514"+"\u2500".repeat(i-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(i-4)+" \u2502";console.log(`
2
+ ${s}
3
+ ${o("")}
4
+ ${o(r)}
5
+ ${o(t)}
6
+ ${o("")}
7
+ ${l}
8
+ `),v({...e,lastNotified:Date.now()})}let a=Number(process.env.TIGRIS_UPDATE_CHECK_INTERVAL_MS)||216e5;(!e||Date.now()-e.lastChecked>a)&&j()}export{u as a,y as b,T as c,M as d,k as e,O as f};
@@ -0,0 +1 @@
1
+ import{a as l}from"./chunk-IRDNZN7R.js";import{b as r}from"./chunk-N3Y6RFSK.js";function a(e){if(e.storageClass)return e.days!==void 0?`${e.storageClass} after ${e.days}d`:e.date!==void 0?`${e.storageClass} on ${e.date}`:e.storageClass}function f(e){if(e.expiration){if(e.expiration.days!==void 0)return`${e.expiration.days}d`;if(e.expiration.date!==void 0)return e.expiration.date}}function u(e){let n=[],i=a(e);i&&n.push(i);let t=f(e);t&&n.push(e.expiration?.days!==void 0?`expire after ${t}`:`expire on ${t}`);let s=[];e.filter?.prefix&&s.push(`prefix=${e.filter.prefix}`),e.enabled===!1&&s.push("disabled");let o=n.join(", ");return s.length>0?`${o} (${s.join(", ")})`:o}function p(e){let n=[{label:"Number of Objects",value:e.sizeInfo.numberOfObjects?.toString()??"N/A"},{label:"Total Size",value:e.sizeInfo.size!==void 0?l(e.sizeInfo.size):"N/A"},{label:"All Versions Count",value:e.sizeInfo.numberOfObjectsAllVersions?.toString()??"N/A"},{label:"Default Tier",value:e.settings.defaultTier},{label:"Locations",value:r(e.locations)},{label:"Snapshots Enabled",value:e.isSnapshotEnabled?"Yes":"No"},{label:"Delete Protection",value:e.settings.deleteProtection?"Yes":"No"},{label:"Soft Delete",value:e.settings.softDelete.enabled?`Enabled (${e.settings.softDelete.retentionDays} day retention)`:"Disabled"},{label:"Allow Object ACL",value:e.settings.allowObjectAcl?"Yes":"No"},{label:"Custom Domain",value:e.settings.customDomain??"None"},{label:"Has Forks",value:e.forkInfo?.hasChildren?"Yes":"No"}];return e.forkInfo?.parents?.length&&(n.push({label:"Forked From",value:e.forkInfo.parents[0].bucketName}),n.push({label:"Fork Snapshot",value:e.forkInfo.parents[0].snapshot})),e.settings.lifecycleRules?.length&&n.push({label:"Lifecycle Rules",value:e.settings.lifecycleRules.map(i=>u(i)).join(", ")}),e.settings.additionalHeaders&&n.push({label:"Additional Headers",value:Object.entries(e.settings.additionalHeaders).map(([i,t])=>`${i}: ${t}`).join(", ")}),e.settings.corsRules.length&&n.push({label:"CORS Rules",value:`${e.settings.corsRules.length} rule(s)`}),e.settings.notifications&&n.push({label:"Notifications",value:e.settings.notifications.enabled!==!1?"Enabled":"Disabled"}),e.settings.dataMigration&&n.push({label:"Data Migration",value:e.settings.dataMigration.endpoint?`${e.settings.dataMigration.name??"N/A"} (${e.settings.dataMigration.endpoint})`:e.settings.dataMigration.name??"Configured"}),n}export{a,f as b,p as c};
@@ -0,0 +1 @@
1
+ import{a as s}from"./chunk-S77OAN6Y.js";import l from"enquirer";var{prompt:r}=l,u=["usa","eur"],g=[{name:"USA",value:"usa"},{name:"Europe",value:"eur"}],o=[{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 m(e){try{if(e==="multi"){let{region:a}=await r({type:"select",name:"region",message:"Multi-region:",choices:g.map(n=>({name:n.value,message:n.name}))});return i(a)}if(e==="single"){let{region:a}=await r({type:"select",name:"region",message:"Region:",choices:o.map(n=>({name:n.value,message:n.name}))});return i(a)}let{regions:t}=await r({type:"multiselect",name:"regions",message:"Press space key to select regions (multiple supported) and enter to confirm:",choices:o.map(a=>({name:a.value,message:a.name}))});if(t.length<2)throw new Error("Dual region requires at least two regions");return i(t)}catch(t){if(t==="")return null;throw t}}async function c(){s("Provide --locations flag");let e;try{({locationType:e}=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 e==="global"?{type:"global"}:await m(e)??c()}function v(e){switch(e.type){case"global":return"Global";case"multi":return`Multi-region (${e.values})`;case"single":return e.values;case"dual":return`Dual region (${Array.isArray(e.values)?e.values.join(", "):e.values})`}}function i(e){let t=(Array.isArray(e)?e:[e]).flatMap(a=>a.split(",")).map(a=>a.trim()).filter(a=>a.length>0);if(t.length===0||t.length===1&&t[0]==="global")return{type:"global"};if(t.length===1){let a=t[0];return u.includes(a)?{type:"multi",values:a}:{type:"single",values:a}}return{type:"dual",values:t}}export{c as a,v as b,i as c};
@@ -1 +1 @@
1
- import{a as d,b as o}from"./chunk-HWX63Y3P.js";import{a}from"./chunk-S6KFKBMY.js";import{b as i}from"./chunk-UBANDLB4.js";import{getBucketInfo as l,setBucketLifecycle as g}from"@tigrisdata/storage";var f=["STANDARD_IA","GLACIER","GLACIER_IR"];function c(e){return f.includes(e)}function u(e){return/^\d{4}-\d{2}-\d{2}/.test(e)&&!isNaN(new Date(e).getTime())}function C(e){return{prefix:a(e,["prefix"]),storageClass:a(e,["storage-class","storageClass"]),days:a(e,["days"]),date:a(e,["date"]),expireDays:a(e,["expire-days","expireDays"]),expireDate:a(e,["expire-date","expireDate"]),enable:a(e,["enable"]),disable:a(e,["disable"])}}function p(e,{requireStorageClassForTiming:r=!0}={}){if(e.enable&&e.disable)return"Cannot use both --enable and --disable";if(r&&(e.days!==void 0||e.date!==void 0)&&!e.storageClass)return"--storage-class is required when setting --days or --date";if(e.storageClass&&!c(e.storageClass))return`--storage-class must be one of: ${f.join(", ")} (STANDARD is not a valid transition target)`;if(e.days!==void 0&&e.date!==void 0)return"Cannot specify both --days and --date";if(e.days!==void 0&&(isNaN(Number(e.days))||Number(e.days)<=0))return"--days must be a positive number";if(e.date!==void 0&&!u(e.date))return"--date must be a valid ISO-8601 date (e.g. 2026-06-01)";if(e.expireDays!==void 0&&e.expireDate!==void 0)return"Cannot specify both --expire-days and --expire-date";if(e.expireDays!==void 0&&(isNaN(Number(e.expireDays))||Number(e.expireDays)<=0))return"--expire-days must be a positive number";if(e.expireDate!==void 0&&!u(e.expireDate))return"--expire-date must be a valid ISO-8601 date (e.g. 2026-06-01)";if(e.prefix!==void 0&&e.prefix==="")return"--prefix cannot be empty"}function D(e){let r={};return e.storageClass&&(r.storageClass=e.storageClass),e.days!==void 0?(r.days=Number(e.days),r.date=void 0):e.date!==void 0&&(r.date=e.date,r.days=void 0),r}function R(e){if(e.expireDays!==void 0)return{days:Number(e.expireDays),date:void 0};if(e.expireDate!==void 0)return{date:e.expireDate,days:void 0}}function I(e){if(e.enable)return!0;if(e.disable)return!1}async function T(e,r,t){let{data:s,error:n}=await l(r,{config:t});return n&&i(e,n),s?.settings.lifecycleRules??[]}async function N(e,r,t,s){let{error:n}=await g(r,{lifecycleRules:t,config:s});n&&i(e,n)}function S(e){return d(e)??"-"}function A(e){return o(e)??"-"}export{C as a,p as b,D as c,R as d,I as e,T as f,N as g,S as h,A as i};
1
+ import{a as d,b as o}from"./chunk-LAB2KJTN.js";import{a}from"./chunk-S6KFKBMY.js";import{b as i}from"./chunk-UBANDLB4.js";import{getBucketInfo as l,setBucketLifecycle as g}from"@tigrisdata/storage";var f=["STANDARD_IA","GLACIER","GLACIER_IR"];function c(e){return f.includes(e)}function u(e){return/^\d{4}-\d{2}-\d{2}/.test(e)&&!isNaN(new Date(e).getTime())}function C(e){return{prefix:a(e,["prefix"]),storageClass:a(e,["storage-class","storageClass"]),days:a(e,["days"]),date:a(e,["date"]),expireDays:a(e,["expire-days","expireDays"]),expireDate:a(e,["expire-date","expireDate"]),enable:a(e,["enable"]),disable:a(e,["disable"])}}function p(e,{requireStorageClassForTiming:r=!0}={}){if(e.enable&&e.disable)return"Cannot use both --enable and --disable";if(r&&(e.days!==void 0||e.date!==void 0)&&!e.storageClass)return"--storage-class is required when setting --days or --date";if(e.storageClass&&!c(e.storageClass))return`--storage-class must be one of: ${f.join(", ")} (STANDARD is not a valid transition target)`;if(e.days!==void 0&&e.date!==void 0)return"Cannot specify both --days and --date";if(e.days!==void 0&&(isNaN(Number(e.days))||Number(e.days)<=0))return"--days must be a positive number";if(e.date!==void 0&&!u(e.date))return"--date must be a valid ISO-8601 date (e.g. 2026-06-01)";if(e.expireDays!==void 0&&e.expireDate!==void 0)return"Cannot specify both --expire-days and --expire-date";if(e.expireDays!==void 0&&(isNaN(Number(e.expireDays))||Number(e.expireDays)<=0))return"--expire-days must be a positive number";if(e.expireDate!==void 0&&!u(e.expireDate))return"--expire-date must be a valid ISO-8601 date (e.g. 2026-06-01)";if(e.prefix!==void 0&&e.prefix==="")return"--prefix cannot be empty"}function D(e){let r={};return e.storageClass&&(r.storageClass=e.storageClass),e.days!==void 0?(r.days=Number(e.days),r.date=void 0):e.date!==void 0&&(r.date=e.date,r.days=void 0),r}function R(e){if(e.expireDays!==void 0)return{days:Number(e.expireDays),date:void 0};if(e.expireDate!==void 0)return{date:e.expireDate,days:void 0}}function I(e){if(e.enable)return!0;if(e.disable)return!1}async function T(e,r,t){let{data:s,error:n}=await l(r,{config:t});return n&&i(e,n),s?.settings.lifecycleRules??[]}async function N(e,r,t,s){let{error:n}=await g(r,{lifecycleRules:t,config:s});n&&i(e,n)}function S(e){return d(e)??"-"}function A(e){return o(e)??"-"}export{C as a,p as b,D as c,R as d,I as e,T as f,N as g,S as h,A as i};
@@ -1 +1 @@
1
- import{a as s,f as l}from"./chunk-K4QARFBT.js";import{a as i,k as m}from"./chunk-QWZ6FK7E.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
1
+ import{a as s,f as l}from"./chunk-GLKOUVFH.js";import{a as i,k as m}from"./chunk-G4DHMSCQ.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
package/dist/cli-core.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.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-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.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-ABUCZZSA.js";import"./chunk-K4QARFBT.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
2
+ import"./chunk-WE7KHYIP.js";import"./chunk-GLKOUVFH.js";import"./chunk-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-ABUCZZSA.js";import"./chunk-K4QARFBT.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
1
+ import"./chunk-WE7KHYIP.js";import"./chunk-GLKOUVFH.js";import"./chunk-G4DHMSCQ.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
@@ -1 +1 @@
1
- import{a as D,b as N}from"../../chunk-TD2HGNDY.js";import{a as C}from"../../chunk-S77OAN6Y.js";import{d as q}from"../../chunk-YN2TKPPT.js";import{a as t,b as L}from"../../chunk-S6KFKBMY.js";import{b as i,c as T,d as w}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as y,j as B}from"../../chunk-7ZUCJBD5.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as R}from"@tigrisdata/storage";import E from"enquirer";var{prompt:j}=E,a=B("buckets","create");async function F(e){x(a);let O=L(e),s=t(e,["name"]),d=t(e,["public"])?"public":t(e,["access","a","A"]),b=t(e,["enable-snapshots","s","S"]),h=t(e,["default-tier","t","T"]),P=t(e,["locations","l","L"]),o=t(e,["fork-of","forkOf","fork"]),l=t(e,["source-snapshot","sourceSnapshot","source-snap"]),I=!s,S;if(I){C("Provide --name to skip interactive mode");let n=p("buckets","access","create"),r=g(n),f=r?.findIndex(c=>c.value===n?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(c=>c.value===v?.default),u=await j([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:r||[],initial:f!==void 0&&f>=0?f:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,d=u.access,h=u.defaultTier,b=u.enableSnapshots;try{S=await D()}catch(c){i(a,c)}}s||i(a,"Bucket name is required"),l&&!o&&i(a,"--source-snapshot requires --fork-of");let{error:k}=await R(s,{defaultTier:h??"STANDARD",enableSnapshot:b===!0,access:d??"private",locations:S??N(P??"global"),...o?{sourceBucketName:o}:{},...l?{sourceBucketSnapshot:l}:{},config:await q()});if(k&&i(a,k),O==="json"){let n=T(a,{name:s}),r={action:"created",name:s,...o?{forkOf:o}:{}};n.length>0&&(r.nextActions=n),console.log(JSON.stringify(r))}y(a,{name:s}),w(a,{name:s})}export{F as default};
1
+ import{a as D,c as N}from"../../chunk-N3Y6RFSK.js";import{a as C}from"../../chunk-S77OAN6Y.js";import{d as q}from"../../chunk-YN2TKPPT.js";import{a as t,b as L}from"../../chunk-S6KFKBMY.js";import{b as i,c as T,d as w}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as y,j as B}from"../../chunk-7ZUCJBD5.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as R}from"@tigrisdata/storage";import E from"enquirer";var{prompt:j}=E,a=B("buckets","create");async function F(e){x(a);let O=L(e),s=t(e,["name"]),d=t(e,["public"])?"public":t(e,["access","a","A"]),b=t(e,["enable-snapshots","s","S"]),h=t(e,["default-tier","t","T"]),P=t(e,["locations","l","L"]),o=t(e,["fork-of","forkOf","fork"]),l=t(e,["source-snapshot","sourceSnapshot","source-snap"]),I=!s,S;if(I){C("Provide --name to skip interactive mode");let n=p("buckets","access","create"),r=g(n),f=r?.findIndex(c=>c.value===n?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(c=>c.value===v?.default),u=await j([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:r||[],initial:f!==void 0&&f>=0?f:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,d=u.access,h=u.defaultTier,b=u.enableSnapshots;try{S=await D()}catch(c){i(a,c)}}s||i(a,"Bucket name is required"),l&&!o&&i(a,"--source-snapshot requires --fork-of");let{error:k}=await R(s,{defaultTier:h??"STANDARD",enableSnapshot:b===!0,access:d??"private",locations:S??N(P??"global"),...o?{sourceBucketName:o}:{},...l?{sourceBucketSnapshot:l}:{},config:await q()});if(k&&i(a,k),O==="json"){let n=T(a,{name:s}),r={action:"created",name:s,...o?{forkOf:o}:{}};n.length>0&&(r.nextActions=n),console.log(JSON.stringify(r))}y(a,{name:s}),w(a,{name:s})}export{F as default};
@@ -1 +1 @@
1
- import{c as s}from"../../chunk-HWX63Y3P.js";import{f as u}from"../../chunk-IRDNZN7R.js";import{d as f}from"../../chunk-YN2TKPPT.js";import{a as p,b as c}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h}from"@tigrisdata/storage";var t=m("buckets","get");async function w(e){a(t);let r=p(e,["name"]),g=c(e);r||o(t,"Bucket name is required");let{data:k,error:n}=await h(r,{config:await f()});n&&o(t,n);let l=[{property:"Name",value:r},...s(k).map(({label:d,value:b})=>({property:d,value:b}))],y=u(l,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(y),i(t)}export{w as default};
1
+ import{c as s}from"../../chunk-LAB2KJTN.js";import{f as u}from"../../chunk-IRDNZN7R.js";import"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{d as f}from"../../chunk-YN2TKPPT.js";import{a as p,b as c}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h}from"@tigrisdata/storage";var t=m("buckets","get");async function w(e){a(t);let r=p(e,["name"]),g=c(e);r||o(t,"Bucket name is required");let{data:k,error:n}=await h(r,{config:await f()});n&&o(t,n);let l=[{property:"Name",value:r},...s(k).map(({label:d,value:b})=>({property:d,value:b}))],y=u(l,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(y),i(t)}export{w as default};
@@ -1 +1 @@
1
- import{a as R,b as k,c as b,d as F,e as I,f as c,g as h}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import"../../../chunk-IRDNZN7R.js";import{e as y}from"../../../chunk-YN2TKPPT.js";import{a as x,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as p,j as g}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";var t=g("buckets lifecycle","create");async function O(r){m(t);let C=w(r),i=x(r,["name"]);i||n(t,"Bucket name is required");let e=R(r),d=k(e);d&&n(t,d);let a=b(e),o=F(e);!a.storageClass&&!o&&n(t,"A new rule must include a transition (--storage-class with --days or --date) and/or an expiration (--expire-days or --expire-date)"),a.storageClass&&e.days===void 0&&e.date===void 0&&n(t,"--storage-class requires --days or --date for a new transition rule");let f=I(e),s=await y(),u=await c(t,i,s),S={...a,...o?{expiration:o}:{},...e.prefix!==void 0?{filter:{prefix:e.prefix}}:{},...f!==void 0?{enabled:f}:{}};await h(t,i,[...u,S],s);let l=(await c(t,i,s)).find(B=>!u.some(E=>E.id===B.id))?.id??"(unknown)";C==="json"&&console.log(JSON.stringify({action:"created",bucket:i,id:l})),p(t,{name:i,id:l})}export{O as default};
1
+ import{a as R,b as k,c as b,d as F,e as I,f as c,g as h}from"../../../chunk-RZPBM4CD.js";import"../../../chunk-LAB2KJTN.js";import"../../../chunk-IRDNZN7R.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{e as y}from"../../../chunk-YN2TKPPT.js";import{a as x,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as p,j as g}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";var t=g("buckets lifecycle","create");async function O(r){m(t);let C=w(r),i=x(r,["name"]);i||n(t,"Bucket name is required");let e=R(r),d=k(e);d&&n(t,d);let a=b(e),o=F(e);!a.storageClass&&!o&&n(t,"A new rule must include a transition (--storage-class with --days or --date) and/or an expiration (--expire-days or --expire-date)"),a.storageClass&&e.days===void 0&&e.date===void 0&&n(t,"--storage-class requires --days or --date for a new transition rule");let f=I(e),s=await y(),u=await c(t,i,s),S={...a,...o?{expiration:o}:{},...e.prefix!==void 0?{filter:{prefix:e.prefix}}:{},...f!==void 0?{enabled:f}:{}};await h(t,i,[...u,S],s);let l=(await c(t,i,s)).find(B=>!u.some(E=>E.id===B.id))?.id??"(unknown)";C==="json"&&console.log(JSON.stringify({action:"created",bucket:i,id:l})),p(t,{name:i,id:l})}export{O as default};
@@ -1 +1 @@
1
- import{a as C,b as R,c as k,d as F,e as S,f as q,g as w}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import"../../../chunk-IRDNZN7R.js";import{e as b}from"../../../chunk-YN2TKPPT.js";import{a as c,b as x}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as y,j as h}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";var i=h("buckets lifecycle","edit");async function E(o){p(i);let T=x(o),n=c(o,["name"]),s=c(o,["id"]);n||t(i,"Bucket name is required"),s||t(i,"Rule id is required");let e=C(o),l=R(e,{requireStorageClassForTiming:!1});l&&t(i,l);let d=k(e),f=F(e),u=S(e);d.storageClass!==void 0||d.days!==void 0||d.date!==void 0||f!==void 0||u!==void 0||e.prefix!==void 0||t(i,"Provide at least one field to change (--storage-class, --days, --date, --expire-days, --expire-date, --prefix, --enable, --disable)");let g=await b(),m=await q(i,n,g),r=m.find(a=>a.id===s);if(r||t(i,`No lifecycle rule with id "${s}" found. Run \`tigris buckets lifecycle list ${n}\` to see ids.`),e.storageClass!==void 0||e.days!==void 0||e.date!==void 0){let a=d.storageClass??r.storageClass,B=e.days!==void 0?Number(e.days):e.date!==void 0?void 0:r.days,D=e.date!==void 0?e.date:e.days!==void 0?void 0:r.date;a||t(i,"--storage-class is required (this rule has no existing transition target)"),B===void 0&&D===void 0&&t(i,"--days or --date is required (this rule has no existing transition timing)")}let I={...r,...d,...f?{expiration:f}:{},...e.prefix!==void 0?{filter:{prefix:e.prefix}}:{},...u!==void 0?{enabled:u}:{}},v=m.map(a=>a.id===s?I:a);await w(i,n,v,g),T==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,id:s})),y(i,{name:n,id:s})}export{E as default};
1
+ import{a as C,b as R,c as k,d as F,e as S,f as q,g as w}from"../../../chunk-RZPBM4CD.js";import"../../../chunk-LAB2KJTN.js";import"../../../chunk-IRDNZN7R.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{e as b}from"../../../chunk-YN2TKPPT.js";import{a as c,b as x}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as y,j as h}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";var i=h("buckets lifecycle","edit");async function E(o){p(i);let T=x(o),n=c(o,["name"]),s=c(o,["id"]);n||t(i,"Bucket name is required"),s||t(i,"Rule id is required");let e=C(o),l=R(e,{requireStorageClassForTiming:!1});l&&t(i,l);let d=k(e),f=F(e),u=S(e);d.storageClass!==void 0||d.days!==void 0||d.date!==void 0||f!==void 0||u!==void 0||e.prefix!==void 0||t(i,"Provide at least one field to change (--storage-class, --days, --date, --expire-days, --expire-date, --prefix, --enable, --disable)");let g=await b(),m=await q(i,n,g),r=m.find(a=>a.id===s);if(r||t(i,`No lifecycle rule with id "${s}" found. Run \`tigris buckets lifecycle list ${n}\` to see ids.`),e.storageClass!==void 0||e.days!==void 0||e.date!==void 0){let a=d.storageClass??r.storageClass,B=e.days!==void 0?Number(e.days):e.date!==void 0?void 0:r.days,D=e.date!==void 0?e.date:e.days!==void 0?void 0:r.date;a||t(i,"--storage-class is required (this rule has no existing transition target)"),B===void 0&&D===void 0&&t(i,"--days or --date is required (this rule has no existing transition timing)")}let I={...r,...d,...f?{expiration:f}:{},...e.prefix!==void 0?{filter:{prefix:e.prefix}}:{},...u!==void 0?{enabled:u}:{}},v=m.map(a=>a.id===s?I:a);await w(i,n,v,g),T==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,id:s})),y(i,{name:n,id:s})}export{E as default};
@@ -1 +1 @@
1
- import{h,i as b}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import{b as x,d as y,e as k}from"../../../chunk-IRDNZN7R.js";import{d as g}from"../../../chunk-YN2TKPPT.js";import{a as u,b as d}from"../../../chunk-S6KFKBMY.js";import{b as r}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as m,e as c,j as p}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";import{getBucketInfo as T}from"@tigrisdata/storage";var e=p("buckets lifecycle","list");async function w(n){f(e);let a=u(n,["name"]),s=d(n);a||r(e,"Bucket name is required");let{data:C,error:l}=await T(a,{config:await g()});l&&r(e,l);let o=C?.settings.lifecycleRules??[];if(o.length===0){c(e);return}let i=o.map(t=>({id:t.id??"-",prefix:t.filter?.prefix??"-",transition:h(t),expiration:b(t),status:t.enabled===!1?"disabled":"enabled"}));console.log(s==="json"?x(i):s==="xml"?y(i,"lifecycleRules","rule"):k(i,[{key:"id",header:"ID"},{key:"prefix",header:"Prefix"},{key:"transition",header:"Transition"},{key:"expiration",header:"Expiration"},{key:"status",header:"Status"}])),m(e,{count:o.length})}export{w as default};
1
+ import{h,i as b}from"../../../chunk-RZPBM4CD.js";import"../../../chunk-LAB2KJTN.js";import{b as x,d as y,e as k}from"../../../chunk-IRDNZN7R.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{d as g}from"../../../chunk-YN2TKPPT.js";import{a as u,b as d}from"../../../chunk-S6KFKBMY.js";import{b as r}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as m,e as c,j as p}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";import{getBucketInfo as T}from"@tigrisdata/storage";var e=p("buckets lifecycle","list");async function w(n){f(e);let a=u(n,["name"]),s=d(n);a||r(e,"Bucket name is required");let{data:C,error:l}=await T(a,{config:await g()});l&&r(e,l);let o=C?.settings.lifecycleRules??[];if(o.length===0){c(e);return}let i=o.map(t=>({id:t.id??"-",prefix:t.filter?.prefix??"-",transition:h(t),expiration:b(t),status:t.enabled===!1?"disabled":"enabled"}));console.log(s==="json"?x(i):s==="xml"?y(i,"lifecycleRules","rule"):k(i,[{key:"id",header:"ID"},{key:"prefix",header:"Prefix"},{key:"transition",header:"Transition"},{key:"expiration",header:"Expiration"},{key:"status",header:"Status"}])),m(e,{count:o.length})}export{w as default};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import"../../../chunk-IRDNZN7R.js";import"../../../chunk-S6KFKBMY.js";import"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";export{e as enabledFromInput,d as expirationFromInput,f as fetchExistingRules,i as formatExpirationCell,h as formatTransitionCell,a as readRuleInput,g as submitRules,c as transitionDeltaFromInput,b as validateRuleFieldCombinations};
1
+ import{a,b,c,d,e,f,g,h,i}from"../../../chunk-RZPBM4CD.js";import"../../../chunk-LAB2KJTN.js";import"../../../chunk-IRDNZN7R.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-S6KFKBMY.js";import"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";export{e as enabledFromInput,d as expirationFromInput,f as fetchExistingRules,i as formatExpirationCell,h as formatTransitionCell,a as readRuleInput,g as submitRules,c as transitionDeltaFromInput,b as validateRuleFieldCombinations};
@@ -1 +1 @@
1
- import{f as x,g as I}from"../../chunk-IRDNZN7R.js";import{d as T}from"../../chunk-YN2TKPPT.js";import{a as y,b as C,c as P}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b,c as u,e as s,i as O,j as w}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as D,listBuckets as F}from"@tigrisdata/storage";var t=w("buckets","list");async function H(f){b(t);let o=C(f),e=y(f,["forks-of","forksOf"]),{limit:k,pageToken:g,isPaginated:E}=P(f),c=await T();e&&E&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)");let{data:n,error:d}=await F({...e?{}:{...k!==void 0?{limit:k}:{},...g?{paginationToken:g}:{}},config:c});if(d&&m(t,d),!n.buckets||n.buckets.length===0){s(t);return}if(e){let{data:r,error:h}=await D(e,{config:c});if(h&&m(t,h),!r.forkInfo?.hasChildren){s(t);return}let a=[];for(let i of n.buckets){if(i.name===e)continue;let{data:j}=await D(i.name,{config:c});j?.forkInfo?.parents?.some(A=>A.bucketName===e)&&a.push({name:i.name,created:i.creationDate})}if(a.length===0){s(t);return}let B=x(a,o,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(B),u(t,{count:a.length});return}let l=n.buckets.map(r=>({name:r.name,created:r.creationDate})),N=[{key:"name",header:"Name"},{key:"created",header:"Created"}],p=n.paginationToken||void 0,S=I(l,o,"buckets","bucket",N,{paginationToken:p});console.log(S),o!=="json"&&o!=="xml"&&O(p),u(t,{count:l.length})}export{H as default};
1
+ import{f as D,g as E}from"../../chunk-IRDNZN7R.js";import{d as C}from"../../chunk-YN2TKPPT.js";import{a as u,b as T,c as x}from"../../chunk-S6KFKBMY.js";import{b as d}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as y,c as f,e as c,i as O,j as P}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listBuckets as A,listForks as B}from"@tigrisdata/storage";var t=P("buckets","list");async function H(o){y(t);let n=T(o),r=u(o,["forks-of","forksOf"]),i=u(o,["deleted"]),{limit:k,pageToken:m,isPaginated:S}=x(o),g=await C();if(r&&S&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)"),r&&i&&console.warn("\u26A0 --deleted is ignored when --forks-of is used; use --deleted on its own to list soft-deleted buckets"),r){let{data:e,error:b}=await B(r,{config:g});if(b&&d(t,b),!e.forks||e.forks.length===0){c(t);return}let s=[];for(let w of e.forks)s.push({name:w.name,created:w.creationDate});let j=D(s,n,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(j),f(t,{count:s.length});return}let{data:a,error:l}=await A({...k!==void 0?{limit:k}:{},...m?{paginationToken:m}:{},...i?{deleted:i}:{},config:g});if(l&&d(t,l),!a.buckets||a.buckets.length===0){c(t);return}let p=a.buckets.map(e=>({name:e.name,created:e.creationDate})),F=[{key:"name",header:"Name"},{key:"created",header:"Created"}],h=a.paginationToken||void 0,N=E(p,n,"buckets","bucket",F,{paginationToken:h});console.log(N),n!=="json"&&n!=="xml"&&O(h),f(t,{count:p.length})}export{H as default};
@@ -0,0 +1 @@
1
+ import{d as x}from"../../chunk-YN2TKPPT.js";import{a as d,b as l}from"../../chunk-S6KFKBMY.js";import{a as i,b as g,c as u,d as p}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,d as n,j as f}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{restoreBucket as w}from"@tigrisdata/storage";var t=f("buckets","restore");async function A(s){a(t);let k=l(s),o=d(s,["name"]);o||g(t,"Bucket name is required");let{data:S,error:e}=await w(o,{config:await x()});if(e&&(n(t,e.message,{name:o}),i(e,t)),!S.restored){let r="Bucket could not be restored";n(t,r,{name:o}),i(r,t)}if(k==="json"){let r=u(t,{name:o}),c={action:"restored",name:o};r.length>0&&(c.nextActions=r),console.log(JSON.stringify(c))}m(t,{name:o}),p(t,{name:o})}export{A as default};
@@ -1 +1 @@
1
- import{a as l,b as d}from"../../chunk-TD2HGNDY.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-YN2TKPPT.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as y}from"@tigrisdata/storage";var t=m("buckets","set-locations");async function B(r){s(t);let k=p(r),o=e(r,["name"]),a=e(r,["locations"]);o||i(t,"Bucket name is required");let n;if(a!==void 0)n=d(a);else{g("Provide --locations flag");try{n=await l()}catch(w){i(t,w)}}let L=await u(),{error:c}=await y(o,{locations:n,config:L});c&&i(t,c),k==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),f(t,{name:o})}export{B as default};
1
+ import{a as l,c as d}from"../../chunk-N3Y6RFSK.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-YN2TKPPT.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as y}from"@tigrisdata/storage";var t=m("buckets","set-locations");async function B(r){s(t);let k=p(r),o=e(r,["name"]),a=e(r,["locations"]);o||i(t,"Bucket name is required");let n;if(a!==void 0)n=d(a);else{g("Provide --locations flag");try{n=await l()}catch(w){i(t,w)}}let L=await u(),{error:c}=await y(o,{locations:n,config:L});c&&i(t,c),k==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),f(t,{name:o})}export{B as default};
@@ -1 +1 @@
1
- import{b as y}from"../../chunk-TD2HGNDY.js";import"../../chunk-S77OAN6Y.js";import{e as w}from"../../chunk-YN2TKPPT.js";import{a as n,b as h,d as i}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as D,j as O}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as j}from"@tigrisdata/storage";var o=O("buckets","set");async function B(e){p(o);let A=h(e),a=n(e,["name"]),r=n(e,["access"]),s=n(e,["locations"]),d=n(e,["allow-object-acl","allowObjectAcl"]),l=n(e,["disable-directory-listing","disableDirectoryListing"]),f=n(e,["cache-control","cacheControl"]),u=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),m=n(e,["enable-additional-headers","enableAdditionalHeaders"]);a||c(o,"Bucket name is required"),r===void 0&&s===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&c(o,"At least one setting is required");let t={};r!==void 0&&(t.access=r),s!==void 0&&(t.locations=y(s)),d!==void 0&&(t.allowObjectAcl=i(d)),l!==void 0&&(t.disableDirectoryListing=i(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=i(g)),m!==void 0&&(t.enableAdditionalHeaders=i(m));let k=await w(),{error:b}=await j(a,{...t,config:k});b&&c(o,b),A==="json"&&console.log(JSON.stringify({action:"updated",name:a})),D(o,{name:a})}export{B as default};
1
+ import{c as j}from"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{e as k}from"../../chunk-YN2TKPPT.js";import{a as n,b as A,d as s}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as w,j as O}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as L}from"@tigrisdata/storage";var i=O("buckets","set");async function S(e){h(i);let B=A(e),d=n(e,["name"]),r=n(e,["access"]),l=n(e,["locations"]),c=n(e,["allow-object-acl","allowObjectAcl"]),f=n(e,["disable-directory-listing","disableDirectoryListing"]),u=n(e,["cache-control","cacheControl"]),b=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),a=n(e,["soft-delete","softDelete"]),m=n(e,["retention-days","retentionDays"]),y=n(e,["enable-additional-headers","enableAdditionalHeaders"]);d||o(i,"Bucket name is required"),r===void 0&&l===void 0&&c===void 0&&f===void 0&&u===void 0&&b===void 0&&g===void 0&&a===void 0&&y===void 0&&o(i,"At least one setting is required");let t={};if(r!==void 0&&(t.access=r),l!==void 0&&(t.locations=j(l)),c!==void 0&&(t.allowObjectAcl=s(c)),f!==void 0&&(t.disableDirectoryListing=s(f)),u!==void 0&&(t.cacheControl=u),b!==void 0&&(t.customDomain=b),g!==void 0&&(t.enableDeleteProtection=s(g)),a!==void 0&&a!=="enable"&&a!=="disable"&&o(i,'--soft-delete must be "enable" or "disable"'),m!==void 0&&a!=="enable"&&o(i,"--retention-days can only be used with --soft-delete enable"),a==="enable"){m===void 0&&o(i,"--retention-days is required when enabling soft delete");let D=Number(m);(!Number.isInteger(D)||D<=0)&&o(i,"--retention-days must be a positive integer"),t.softDelete={enabled:!0,retentionDays:D}}else a==="disable"&&(t.softDelete={enabled:!1});y!==void 0&&(t.enableAdditionalHeaders=s(y));let C=await k(),{error:p}=await L(d,{...t,config:C});p&&o(i,p),B==="json"&&console.log(JSON.stringify({action:"updated",name:d})),w(i,{name:d})}export{S as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as D}from"../chunk-SAAGVLRE.js";import{a as _}from"../chunk-HPICBIXL.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as N,d as v,f as O,g as J,i as j}from"../chunk-RXNG56FL.js";import{d as G}from"../chunk-YN2TKPPT.js";import{a as x,b as q}from"../chunk-S6KFKBMY.js";import{a as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{get as X,head as Y,list as et,put as E}from"@tigrisdata/storage";import{createReadStream as ot,createWriteStream as it,existsSync as Z,mkdirSync as nt,readdirSync as z,statSync as L}from"fs";import{homedir as rt}from"os";import{basename as M,dirname as K,join as T,relative as H,resolve as Q}from"path";import{Readable as P}from"stream";import{pipeline as at}from"stream/promises";var h=!1;function lt(n,t){let e=U(n),r=U(t);return!e&&!r&&m("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&r?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function tt(n){return n==="~"||n.startsWith("~/")?Q(rt(),n.slice(2)):Q(n)}function ct(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let r=e.parentPath??e.path;return T(r,e.name)})}function st(n,t){let e=K(n),r=M(n),s=O(r);return Z(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(a=>a.isFile()&&s.test(a.name)).map(a=>{let o=a.parentPath??a.path;return T(o,a.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>T(e,o.name)):[]}async function I(n,t,e,r,s=!1){let f;try{f=L(n).size}catch{return{error:`File not found: ${n}`}}let a=ot(n),o=P.toWeb(a),i=_(n),{error:l}=await E(e,o,{...B(f),...i?{contentType:i}:{},onUploadProgress:s?({loaded:p})=>{if(f!==void 0&&f>0){let c=Math.round(p/f*100);process.stdout.write(`\rUploading: ${w(p)} / ${w(f)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(p)}`)}:void 0,config:{...r,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),l?{error:l.message}:{}}async function V(n,t,e,r,s=!1){let f;if(s){let{data:c}=await Y(t,{config:{...r,bucket:n}});f=c?.size}let{data:a,error:o}=await X(t,"stream",{config:{...r,bucket:n}});if(o)return{error:o.message};let i=K(e);Z(i)||nt(i,{recursive:!0});let l=it(e),p=P.fromWeb(a);if(s&&f!==void 0&&f>0){let c=0;p.on("data",u=>{c+=u.length;let g=Math.round(c/f*100);process.stdout.write(`\rDownloading: ${w(c)} / ${w(f)} (${g}%)`)})}return await at(p,l),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,r,s,f=!1){if(e.endsWith("/")){let{error:u}=await E(s,"",{config:{...n,bucket:r}});return u?{error:u.message}:{}}let{data:a}=await Y(e,{config:{...n,bucket:t}}),o=a?.size,i=a?.contentType,{data:l,error:p}=await X(e,"stream",{config:{...n,bucket:t}});if(p)return{error:p.message};let{error:c}=await E(s,l,{...B(o),...i?{contentType:i}:{},onUploadProgress:f?({loaded:u})=>{if(o!==void 0&&o>0){let g=Math.round(u/o*100);process.stdout.write(`\rCopying: ${w(u)} / ${w(o)} (${g}%)`)}else process.stdout.write(`\rCopying: ${w(u)}`)}:void 0,config:{...n,bucket:r}});return f&&process.stdout.write("\r"+" ".repeat(60)+"\r"),c?{error:c.message}:{}}async function pt(n,t,e,r){let s=tt(n);if(n.includes("*")){let o=st(s,r);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let i=K(s),l=o.map(u=>async()=>{let g=H(i,u),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,y=await I(u,t.bucket,k,e);return y.error?(console.error(`Failed to upload ${u}: ${y.error}`),!1):(h||console.log(`Uploaded ${u} -> t3://${t.bucket}/${k}`),!0)}),c=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:c}):`Uploaded ${c} file(s)`);return}let a;try{a=L(s)}catch{m(`Source not found: ${n}`)}if(a.isDirectory()){r||m(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=ct(s);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let i=n.endsWith("/")?"":M(s),l=o.map(u=>async()=>{let g=H(s,u),y=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(u,t.bucket,y,e);return R.error?(console.error(`Failed to upload ${u}: ${R.error}`),!1):(h||console.log(`Uploaded ${u} -> t3://${t.bucket}/${y}`),!0)}),c=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:c}):`Uploaded ${c} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await v(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let l=await I(s,t.bucket,i,e,!h);l.error&&m(l.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:n,dest:`t3://${t.bucket}/${i}`}):`Uploaded ${n} -> t3://${t.bucket}/${i}`)}}async function ut(n,t,e,r,s){let f=n.endsWith("/");!t.path&&!f&&m("Cannot copy a bucket. Provide a path within the bucket.");let a=tt(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&f;if(!o&&!i&&(i=await v(t.bucket,t.path,r)),i&&!o&&!s&&m("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let l=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",p=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:c,error:u}=await j(t.bucket,l||void 0,r);u&&m(u);let g=c.filter($=>!$.name.endsWith("/"));if(o){let $=t.path.split("/").pop(),b=O($);g=g.filter(S=>{let d=l?S.name.slice(l.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($=>async()=>{let b=l?$.name.slice(l.length):$.name,S=p?T(a,p,b):T(a,b),d=await V(t.bucket,$.name,S,r);return d.error?(console.error(`Failed to download ${$.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${$.name} -> ${S}`),!0)}),R=(await D(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let l=t.path.split("/").pop(),p,c=!1;try{c=L(a).isDirectory()}catch{}c||e.endsWith("/")?p=T(a,l):p=a;let u=await V(t.bucket,t.path,p,r,!h);u.error&&m(u.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:p}):`Downloaded t3://${t.bucket}/${t.path} -> ${p}`)}}async function ft(n,t,e,r,s){let f=n.endsWith("/");!t.path&&!f&&m("Cannot copy a bucket. Provide a path within the bucket.");let a=n.includes("*"),o=t.path.endsWith("/")||!t.path&&f;if(!a&&!o&&t.path&&(o=await v(t.bucket,t.path,r)),o&&!a&&!s&&m("Source is a remote folder (not copied). Use -r to copy recursively."),a||o){let i=a?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",l=!a&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",c=[e.path?.replace(/\/$/,"")||"",l].filter(Boolean).join("/"),u=c?`${c}/`:"";t.bucket===e.bucket&&i===u&&m("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,r);k&&m(k);let y=g.filter(d=>d.name!==i);if(a){let d=t.path.split("/").pop(),W=O(d);y=y.filter(F=>{let C=i?F.name.slice(i.length):F.name;return!s&&C.includes("/")?!1:W.test(C.split("/").pop())})}let R=y.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=c?`${c}/${W}`:W,C=await A(r,t.bucket,d.name,e.bucket,F);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}/${F}`),!0)}),b=(await D(R,8)).filter(Boolean).length,S=!1;if(c&&i){let{data:d}=await et({prefix:i,limit:1,config:{...r,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${c}/`,F=await A(r,t.bucket,i,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let i=t.path.split("/").pop(),l;e.path?e.path.endsWith("/")?l=`${e.path}${i}`:await v(e.bucket,e.path,r)?l=`${e.path}/${i}`:l=e.path:l=i,t.bucket===e.bucket&&t.path===l&&m("Source and destination are the same");let p=await A(r,t.bucket,t.path,e.bucket,l,!h);p.error&&m(p.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${l}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${l}`)}}async function mt(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&m("Both src and dest arguments are required");let r=!!x(n,["recursive","r"]);h=q(n)==="json";let f=lt(t,e),a=await G({withCredentialProvider:!0});switch(f){case"local-to-remote":{let o=N(e);o.bucket||m("Invalid destination path"),await pt(t,o,a,r);break}case"remote-to-local":{let o=N(t);o.bucket||m("Invalid source path"),await ut(t,o,e,a,r);break}case"remote-to-remote":{let o=N(t),i=N(e);o.bucket||m("Invalid source path"),i.bucket||m("Invalid destination path"),await ft(t,o,i,a,r);break}}process.exit(0)}export{mt as default};
1
+ import{a as G}from"../chunk-EKW6XTGL.js";import{a as D}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-IRDNZN7R.js";import{a as U,b as v,d as C,f as O,g as J,i as j}from"../chunk-RXNG56FL.js";import{d as K}from"../chunk-YN2TKPPT.js";import{a as x,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as P,get as tt,head as et,list as ot,put as V}from"@tigrisdata/storage";import{createReadStream as it,createWriteStream as nt,existsSync as X,mkdirSync as rt,readdirSync as A,statSync as z}from"fs";import{homedir as at}from"os";import{basename as E,dirname as L,join as N,relative as _,resolve as H}from"path";import{Readable as Y}from"stream";import{pipeline as lt}from"stream/promises";var h=!1;function ct(i,t){let e=U(i),r=U(t);return!e&&!r&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&r?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(at(),i.slice(2)):H(i)}function st(i){return A(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let r=e.parentPath??e.path;return N(r,e.name)})}function pt(i,t){let e=L(i),r=E(i),c=O(r);return X(e)?t?A(e,{recursive:!0,withFileTypes:!0}).filter(a=>a.isFile()&&c.test(a.name)).map(a=>{let o=a.parentPath??a.path;return N(o,a.name)}):A(e,{withFileTypes:!0}).filter(o=>o.isFile()&&c.test(o.name)).map(o=>N(e,o.name)):[]}async function B(i,t,e,r,c=!1){let p;try{p=z(i).size}catch{return{error:`File not found: ${i}`}}let a=it(i),o=Y.toWeb(a),n=q(i),{error:l}=await V(e,o,{...G(p),...n?{contentType:n}:{},onUploadProgress:c?({loaded:u})=>{if(p!==void 0&&p>0){let s=Math.round(u/p*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(p)} (${s}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...r,bucket:t}});return c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),l?{error:l.message}:{}}async function Q(i,t,e,r,c=!1){let p;if(c){let{data:s}=await et(t,{config:{...r,bucket:i}});p=s?.size}let{data:a,error:o}=await tt(t,"stream",{config:{...r,bucket:i}});if(o)return{error:o.message};let n=L(e);X(n)||rt(n,{recursive:!0});let l=nt(e),u=Y.fromWeb(a);if(c&&p!==void 0&&p>0){let s=0;u.on("data",m=>{s+=m.length;let d=Math.round(s/p*100);process.stdout.write(`\rDownloading: ${R(s)} / ${R(p)} (${d}%)`)})}return await lt(u,l),c&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function I(i,t,e,r,c){if(e.endsWith("/")){let{error:a}=await V(c,"",{config:{...i,bucket:r}});return a?{error:a.message}:{}}let{error:p}=await P(e,c,{srcBucket:t,destBucket:r,config:{...i,bucket:r}});return p?{error:p.message}:{}}async function ut(i,t,e,r){let c=Z(i);if(i.includes("*")){let o=pt(c,r);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let n=L(c),l=o.map(m=>async()=>{let d=_(n,m),w=t.path?`${t.path.replace(/\/$/,"")}/${d}`:d,y=await B(m,t.bucket,w,e);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${w}`),!0)}),s=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:s}):`Uploaded ${s} file(s)`);return}let a;try{a=z(c)}catch{f(`Source not found: ${i}`)}if(a.isDirectory()){r||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let o=st(c);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let n=i.endsWith("/")?"":E(c),l=o.map(m=>async()=>{let d=_(c,m),y=[t.path?.replace(/\/$/,""),n,d].filter(Boolean).join("/"),F=await B(m,t.bucket,y,e);return F.error?(console.error(`Failed to upload ${m}: ${F.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${y}`),!0)}),s=(await D(l,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:s}):`Uploaded ${s} file(s)`)}else{let o=E(c),n;t.path?i.endsWith("/")||t.path.endsWith("/")?n=`${t.path.replace(/\/$/,"")}/${o}`:await C(t.bucket,t.path,e)?n=`${t.path}/${o}`:n=t.path:n=o;let l=await B(c,t.bucket,n,e,!h);l.error&&f(l.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${n}`}):`Uploaded ${i} -> t3://${t.bucket}/${n}`)}}async function ft(i,t,e,r,c){let p=i.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=Z(e),o=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&p;if(!o&&!n&&(n=await C(t.bucket,t.path,r)),n&&!o&&!c&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||n){let l=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",u=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:s,error:m}=await j(t.bucket,l||void 0,r);m&&f(m);let d=s.filter($=>!$.name.endsWith("/"));if(o){let $=t.path.split("/").pop(),b=O($);d=d.filter(k=>{let g=l?k.name.slice(l.length):k.name;return!c&&g.includes("/")?!1:b.test(g.split("/").pop())})}if(d.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=d.map($=>async()=>{let b=l?$.name.slice(l.length):$.name,k=u?N(a,u,b):N(a,b),g=await Q(t.bucket,$.name,k,r);return g.error?(console.error(`Failed to download ${$.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${$.name} -> ${k}`),!0)}),F=(await D(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:F}):`Downloaded ${F} file(s)`)}else{let l=t.path.split("/").pop(),u,s=!1;try{s=z(a).isDirectory()}catch{}s||e.endsWith("/")?u=N(a,l):u=a;let m=await Q(t.bucket,t.path,u,r,!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:u}):`Downloaded t3://${t.bucket}/${t.path} -> ${u}`)}}async function mt(i,t,e,r,c){let p=i.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let a=i.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!a&&!o&&t.path&&(o=await C(t.bucket,t.path,r)),o&&!a&&!c&&f("Source is a remote folder (not copied). Use -r to copy recursively."),a||o){let n=a?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",l=!a&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",s=[e.path?.replace(/\/$/,"")||"",l].filter(Boolean).join("/"),m=s?`${s}/`:"";t.bucket===e.bucket&&n===m&&f("Source and destination are the same");let{items:d,error:w}=await j(t.bucket,n||void 0,r);w&&f(w);let y=d.filter(g=>g.name!==n);if(a){let g=t.path.split("/").pop(),S=O(g);y=y.filter(W=>{let T=n?W.name.slice(n.length):W.name;return!c&&T.includes("/")?!1:S.test(T.split("/").pop())})}let F=y.map(g=>async()=>{let S=n?g.name.slice(n.length):g.name,W=s?`${s}/${S}`:S,T=await I(r,t.bucket,g.name,e.bucket,W);return T.error?(console.error(`Failed to copy ${g.name}: ${T.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${W}`),!0)}),b=(await D(F,8)).filter(Boolean).length,k=!1;if(s&&n){let{data:g}=await ot({prefix:n,limit:1,config:{...r,bucket:t.bucket}});if(g?.items?.some(S=>S.name===n)){let S=`${s}/`,W=await I(r,t.bucket,n,e.bucket,S);W.error?console.error(`Failed to copy folder marker: ${W.error}`):k=!0}}if(b===0&&k&&(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 n=t.path.split("/").pop(),l;e.path?e.path.endsWith("/")?l=`${e.path}${n}`:await C(e.bucket,e.path,r)?l=`${e.path}/${n}`:l=e.path:l=n,t.bucket===e.bucket&&t.path===l&&f("Source and destination are the same");let u=await I(r,t.bucket,t.path,e.bucket,l);u.error&&f(u.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${l}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${l}`)}}async function ht(i){let t=x(i,["src"]),e=x(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let r=!!x(i,["recursive","r"]);h=M(i)==="json";let p=ct(t,e),a=await K({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=v(e);o.bucket||f("Invalid destination path"),await ut(t,o,a,r);break}case"remote-to-local":{let o=v(t);o.bucket||f("Invalid source path"),await ft(t,o,e,a,r);break}case"remote-to-remote":{let o=v(t),n=v(e);o.bucket||f("Invalid source path"),n.bucket||f("Invalid destination path"),await mt(t,o,n,a,r);break}}process.exit(0)}export{ht as default};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-TUDALPGD.js";import{a as J}from"../../../chunk-S7EO4QWK.js";import{a as h}from"../../../chunk-EFPPY2JQ.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YN2TKPPT.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
1
+ import{a as J}from"../../../chunk-S7EO4QWK.js";import{a}from"../../../chunk-TUDALPGD.js";import{a as h}from"../../../chunk-EFPPY2JQ.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-YN2TKPPT.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-GAWFFIPC.js";import"../../../chunk-OHGCOC5Q.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
package/dist/lib/mk.js CHANGED
@@ -1 +1 @@
1
- import{b as d}from"../chunk-TD2HGNDY.js";import"../chunk-S77OAN6Y.js";import{e as m}from"../chunk-RXNG56FL.js";import{d as h}from"../chunk-YN2TKPPT.js";import{a as e,b as g}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{createBucket as y,put as O}from"@tigrisdata/storage";async function T(t){let l=e(t,["path"]);l||s("path argument is required");let{bucket:o,path:r}=m(l);o||s("Invalid path");let f=await h(),u=g(t);if(r){let a=r.endsWith("/")?r:`${r}/`,{error:c}=await O(a,"",{config:{...f,bucket:o}});c&&s(c),console.log(u==="json"?JSON.stringify({action:"created",type:"folder",bucket:o,path:a}):`Folder '${o}/${a}' created`),process.exit(0)}else{let c=e(t,["public"])?"public":e(t,["access","a","A"]),b=e(t,["enableSnapshots","enable-snapshots","s","S"]),S=e(t,["defaultTier","default-tier","t","T"]),k=e(t,["locations","l","L"]),n=e(t,["fork-of","forkOf","fork"]),i=e(t,["source-snapshot","sourceSnapshot","source-snap"]);i&&!n&&s("--source-snapshot requires --fork-of");let{error:p}=await y(o,{defaultTier:S??"STANDARD",enableSnapshot:b===!0,access:c??"private",locations:d(k??"global"),...n?{sourceBucketName:n}:{},...i?{sourceBucketSnapshot:i}:{},config:f});p&&s(p),console.log(u==="json"?JSON.stringify({action:"created",type:"bucket",name:o}):`Bucket '${o}' created`),process.exit(0)}}export{T as default};
1
+ import{c as d}from"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import{e as m}from"../chunk-RXNG56FL.js";import{d as h}from"../chunk-YN2TKPPT.js";import{a as e,b as g}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{createBucket as y,put as O}from"@tigrisdata/storage";async function T(t){let l=e(t,["path"]);l||s("path argument is required");let{bucket:o,path:r}=m(l);o||s("Invalid path");let f=await h(),u=g(t);if(r){let a=r.endsWith("/")?r:`${r}/`,{error:c}=await O(a,"",{config:{...f,bucket:o}});c&&s(c),console.log(u==="json"?JSON.stringify({action:"created",type:"folder",bucket:o,path:a}):`Folder '${o}/${a}' created`),process.exit(0)}else{let c=e(t,["public"])?"public":e(t,["access","a","A"]),b=e(t,["enableSnapshots","enable-snapshots","s","S"]),S=e(t,["defaultTier","default-tier","t","T"]),k=e(t,["locations","l","L"]),n=e(t,["fork-of","forkOf","fork"]),i=e(t,["source-snapshot","sourceSnapshot","source-snap"]);i&&!n&&s("--source-snapshot requires --fork-of");let{error:p}=await y(o,{defaultTier:S??"STANDARD",enableSnapshot:b===!0,access:c??"private",locations:d(k??"global"),...n?{sourceBucketName:n}:{},...i?{sourceBucketSnapshot:i}:{},config:f});p&&s(p),console.log(u==="json"?JSON.stringify({action:"created",type:"bucket",name:o}):`Bucket '${o}' created`),process.exit(0)}}export{T as default};
package/dist/lib/mv.js CHANGED
@@ -1 +1 @@
1
- import{a as J}from"../chunk-EKW6XTGL.js";import{a as M}from"../chunk-IRDNZN7R.js";import{a as x,b as E}from"../chunk-S77OAN6Y.js";import{a as T,b as j,d as C,f as U,g as D,i as z}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-YN2TKPPT.js";import{a as P,b as N}from"../chunk-S6KFKBMY.js";import{a}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{get as L,head as Q,list as V,put as q,remove as A}from"@tigrisdata/storage";var m=!1;async function X(s){let c=P(s,["src"]),l=P(s,["dest"]),g=P(s,["yes","y","force","f"]),b=!!P(s,["recursive","r"]);m=N(s)==="json",(!c||!l)&&a("both src and dest arguments are required"),(!T(c)||!T(l))&&a("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=j(c),t=j(l);e.bucket||a("Invalid source path"),t.bucket||a("Invalid destination path");let k=c.endsWith("/");!e.path&&!k&&a("Cannot move a bucket. Provide a path within the bucket.");let n=await O({withCredentialProvider:!0}),f=e.path.includes("*"),p=e.path.endsWith("/")||!e.path&&k;if(!f&&!p&&e.path&&(p=await C(e.bucket,e.path,n)),p&&!f&&!b&&a("Source is a remote folder (not moved). Use -r to move recursively."),f||p){let o=f?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",r=!f&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",d=[t.path?.replace(/\/$/,"")||"",r].filter(Boolean).join("/"),B=d?`${d}/`:"";e.bucket===t.bucket&&o===B&&a("Source and destination are the same");let{items:_,error:I}=await z(e.bucket,o||void 0,n);I&&a(I);let v=_.filter(i=>i.name!==o);if(f){let i=e.path.split("/").pop(),h=U(i);v=v.filter(w=>{let y=o?w.name.slice(o.length):w.name;return!b&&y.includes("/")?!1:h.test(y.split("/").pop())})}let{data:G}=await V({prefix:o,limit:1,config:{...n,bucket:e.bucket}}),F=o?G?.items?.some(i=>i.name===o):!1;if(v.length===0&&!F){console.log(m?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let H=v.length+(F?1:0);if(!g&&(x("Use --yes to skip confirmation"),!await E(`Are you sure you want to move ${H} object(s)?`))){m||console.log("Aborted");return}let $=0;for(let i of v){let h=o?i.name.slice(o.length):i.name,w=d?`${d}/${h}`:h,y=await R(n,e.bucket,i.name,t.bucket,w);y.error?console.error(`Failed to move ${i.name}: ${y.error}`):(m||console.log(`Moved t3://${e.bucket}/${i.name} -> t3://${t.bucket}/${w}`),$++)}let W=!1;if(F)if(d){let i=`${d}/`,h=await R(n,e.bucket,o,t.bucket,i);h.error?console.error(`Failed to move folder marker: ${h.error}`):W=!0}else{let{error:i}=await A(o,{config:{...n,bucket:e.bucket}});i?console.error(`Failed to remove source folder marker: ${i.message}`):W=!0}$===0&&W&&($=1),console.log(m?JSON.stringify({action:"moved",count:$}):`Moved ${$} object(s)`)}else{let o=e.path.split("/").pop(),r;if(t.path?t.path.endsWith("/")?r=`${t.path}${o}`:await C(t.bucket,t.path,n)?r=`${t.path}/${o}`:r=t.path:r=o,e.bucket===t.bucket&&e.path===r&&a("Source and destination are the same"),!g&&(x("Use --yes to skip confirmation"),!await E(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){m||console.log("Aborted");return}let u=await R(n,e.bucket,e.path,t.bucket,r,!m);u.error&&a(u.error),console.log(m?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${r}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${r}`)}process.exit(0)}async function R(s,c,l,g,b,S=!1){if(l.endsWith("/")){let{error:r}=await q(b,"",{config:{...s,bucket:g}});if(r)return{error:r.message};let{error:u}=await A(l,{config:{...s,bucket:c}});return u?{error:`Copied but failed to delete source: ${u.message}`}:{}}let{data:e}=await Q(l,{config:{...s,bucket:c}}),t=e?.size,k=e?.contentType,{data:n,error:f}=await L(l,"stream",{config:{...s,bucket:c}});if(f)return{error:f.message};let{error:p}=await q(b,n,{...J(t),...k?{contentType:k}:{},onUploadProgress:S?({loaded:r})=>{if(t!==void 0&&t>0){let u=Math.round(r/t*100);process.stdout.write(`\rMoving: ${M(r)} / ${M(t)} (${u}%)`)}else process.stdout.write(`\rMoving: ${M(r)}`)}:void 0,config:{...s,bucket:g}});if(S&&process.stdout.write("\r"+" ".repeat(60)+"\r"),p)return{error:p.message};let{error:o}=await A(l,{config:{...s,bucket:c}});return o?{error:`Copied but failed to delete source: ${o.message}`}:{}}export{X as default};
1
+ import{a as x,b as M}from"../chunk-S77OAN6Y.js";import{a as E,b as j,d as R,f as T,g as D,i as J}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-YN2TKPPT.js";import{a as w,b as N}from"../chunk-S6KFKBMY.js";import{a as s}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{copy as G,list as H,move as L,put as Q,remove as C}from"@tigrisdata/storage";var d=!1;async function V(i){let a=w(i,["src"]),c=w(i,["dest"]),m=w(i,["yes","y","force","f"]),p=!!w(i,["recursive","r"]);d=N(i)==="json",(!a||!c)&&s("both src and dest arguments are required"),(!E(a)||!E(c))&&s("Both src and dest must be remote Tigris paths (t3:// or tigris://)");let e=j(a),t=j(c);e.bucket||s("Invalid source path"),t.bucket||s("Invalid destination path");let g=a.endsWith("/");!e.path&&!g&&s("Cannot move a bucket. Provide a path within the bucket.");let l=await O({withCredentialProvider:!0}),h=e.path.includes("*"),y=e.path.endsWith("/")||!e.path&&g;if(!h&&!y&&e.path&&(y=await R(e.bucket,e.path,l)),y&&!h&&!p&&s("Source is a remote folder (not moved). Use -r to move recursively."),h||y){let r=h?D(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",n=!h&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",f=[t.path?.replace(/\/$/,"")||"",n].filter(Boolean).join("/"),U=f?`${f}/`:"";e.bucket===t.bucket&&r===U&&s("Source and destination are the same");let{items:q,error:I}=await J(e.bucket,r||void 0,l);I&&s(I);let b=q.filter(o=>o.name!==r);if(h){let o=e.path.split("/").pop(),u=T(o);b=b.filter(k=>{let $=r?k.name.slice(r.length):k.name;return!p&&$.includes("/")?!1:u.test($.split("/").pop())})}let{data:_}=await H({prefix:r,limit:1,config:{...l,bucket:e.bucket}}),S=r?_?.items?.some(o=>o.name===r):!1;if(b.length===0&&!S){console.log(d?JSON.stringify({action:"moved",count:0}):"No objects to move");return}let z=b.length+(S?1:0);if(!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move ${z} object(s)?`))){d||console.log("Aborted");return}let v=0;for(let o of b){let u=r?o.name.slice(r.length):o.name,k=f?`${f}/${u}`:u,$=await A(l,e.bucket,o.name,t.bucket,k);$.error?console.error(`Failed to move ${o.name}: ${$.error}`):(d||console.log(`Moved t3://${e.bucket}/${o.name} -> t3://${t.bucket}/${k}`),v++)}let W=!1;if(S)if(f){let o=`${f}/`,u=await A(l,e.bucket,r,t.bucket,o);u.error?console.error(`Failed to move folder marker: ${u.error}`):W=!0}else{let{error:o}=await C(r,{config:{...l,bucket:e.bucket}});o?console.error(`Failed to remove source folder marker: ${o.message}`):W=!0}v===0&&W&&(v=1),console.log(d?JSON.stringify({action:"moved",count:v}):`Moved ${v} object(s)`)}else{let r=e.path.split("/").pop(),n;if(t.path?t.path.endsWith("/")?n=`${t.path}${r}`:await R(t.bucket,t.path,l)?n=`${t.path}/${r}`:n=t.path:n=r,e.bucket===t.bucket&&e.path===n&&s("Source and destination are the same"),!m&&(x("Use --yes to skip confirmation"),!await M(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`))){d||console.log("Aborted");return}let F=await A(l,e.bucket,e.path,t.bucket,n);F.error&&s(F.error),console.log(d?JSON.stringify({action:"moved",count:1,src:`t3://${e.bucket}/${e.path}`,dest:`t3://${t.bucket}/${n}`}):`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${n}`)}process.exit(0)}async function A(i,a,c,m,p){if(c.endsWith("/")){let{error:t}=await Q(p,"",{config:{...i,bucket:m}});if(t)return{error:t.message};let{error:g}=await C(c,{config:{...i,bucket:a}});return g?{error:`Copied but failed to delete source: ${g.message}`}:{}}if(a===m){let{error:t}=await L(c,p,{config:{...i,bucket:a}});return t?{error:t.message}:{}}let{error:P}=await G(c,p,{srcBucket:a,destBucket:m,config:{...i,bucket:m}});if(P)return{error:P.message};let{error:e}=await C(c,{config:{...i,bucket:a}});return e?{error:`Copied but failed to delete source: ${e.message}`}:{}}export{V as default};
@@ -1 +1 @@
1
- import{a as h,b as j}from"../../chunk-S77OAN6Y.js";import{h as w}from"../../chunk-RXNG56FL.js";import{d as O}from"../../chunk-YN2TKPPT.js";import{a as c,b as x}from"../../chunk-S6KFKBMY.js";import{a as p,b as f,c as b,d as A}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as l,c as d,d as k,j as y}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{remove as E}from"@tigrisdata/storage";var t=y("objects","delete");async function F(n){l(t);let S=x(n),g=c(n,["bucket"]),v=c(n,["key"]),q=c(n,["yes","y","force"]);g||f(t,"Bucket name or path is required");let m=w(g),o=m.bucket,s=v||m.key||void 0;s||f(t,"Object key is required");let N=await O(),a=Array.isArray(s)?s:[s];if(!q&&(h("Use --yes to skip confirmation"),!await j(`Delete ${a.length} object(s) from '${o}'?`))){console.log("Aborted");return}let u=[],i=[];for(let e of a){let{error:r}=await E(e,{config:{...N,bucket:o}});r?(k(t,r.message,{key:e}),i.push({key:e,error:r.message})):(u.push(e),d(t,{key:e}))}if(S==="json"){let e=b(t,{bucket:o}),r={action:"deleted",bucket:o,keys:u,errors:i};e.length>0&&(r.nextActions=e),console.log(JSON.stringify(r))}i.length>0&&p(i[0].error,t),A(t,{bucket:o})}export{F as default};
1
+ import{a as V,b as N}from"../../chunk-S77OAN6Y.js";import{h as C}from"../../chunk-RXNG56FL.js";import{d as q}from"../../chunk-YN2TKPPT.js";import{a as d,b as T}from"../../chunk-S6KFKBMY.js";import{a as w,b as o,c as O,d as S}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as $,d as j,j as M}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listVersions as H,remove as R}from"@tigrisdata/storage";var r=M("objects","delete");async function W(c){A(r);let K=T(c),b=d(c,["bucket"]),E=d(c,["key"]),F=d(c,["yes","y","force"]),a=d(c,["version-id","versionId"]),u=!!d(c,["all-versions","allVersions"]);b||o(r,"Bucket name or path is required"),a&&u&&o(r,"Cannot use --version-id with --all-versions");let h=C(b),s=h.bucket,m=E||h.key||void 0;m||o(r,"Object key is required");let I={...await q(),bucket:s},n=Array.isArray(m)?m:[m];a&&n.length>1&&o(r,"--version-id targets a single object; pass exactly one key");let f=[];if(u)for(let e of n){let t=0,g,v,p=!1;for(;;){let{data:l,error:x}=await H({prefix:e,...g?{keyMarker:g}:{},...v?{versionIdMarker:v}:{},config:I});x&&o(r,x);for(let i of l.versions)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);for(let i of l.deleteMarkers)i.name===e?(f.push({key:e,versionId:i.versionId}),t++):i.name>e&&(p=!0);if(p||!l.hasMore)break;l.nextKeyMarker||o(r,`listVersions reported more pages but no nextKeyMarker for key '${e}'`),g=l.nextKeyMarker,v=l.nextVersionIdMarker}t===0&&o(r,`No versions or delete markers found for key '${e}'`)}else if(a)f.push({key:n[0],versionId:a});else for(let e of n)f.push({key:e});if(!F){V("Use --yes to skip confirmation");let e=u?`Hard-delete ${f.length} version(s) and delete marker(s) for ${n.length} object(s) from '${s}'?`:a?`Hard-delete version '${a}' of '${n[0]}' from '${s}'?`:`Delete ${n.length} object(s) from '${s}'?`;if(!await N(e)){console.log("Aborted");return}}let y=[],k=[];for(let e of f){let{error:t}=await R(e.key,{...e.versionId?{versionId:e.versionId}:{},config:I});t?(j(r,t.message,e),k.push({...e,error:t.message})):(y.push(e),$(r,e))}if(K==="json"){let e=O(r,{bucket:s}),t={action:"deleted",bucket:s,keys:y.map(g=>g.key),deleted:y,errors:k};e.length>0&&(t.nextActions=e),console.log(JSON.stringify(t))}k.length>0&&w(k[0].error,r),S(r,{bucket:s})}export{W as default};
@@ -1 +1 @@
1
- import{h as k}from"../../chunk-RXNG56FL.js";import{d as j}from"../../chunk-YN2TKPPT.js";import{a as r,b}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as a,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{get as w}from"@tigrisdata/storage";import{createWriteStream as v,writeFileSync as q}from"fs";import{extname as T}from"path";import{Readable as S}from"stream";import{pipeline as x}from"stream/promises";var e=u("objects","get"),C=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function E(s,m){let l=T(m||s).toLowerCase();return C.has(l)?"string":"stream"}async function F(s){h(e);let m=b(s),p=r(s,["bucket"]),l=r(s,["key"]),t=r(s,["output","o","O"]),y=r(s,["mode","m","M"]),g=r(s,["snapshot-version","snapshotVersion","snapshot"]);p||c(e,"Bucket name or path is required");let{bucket:f,key:o}=k(p,l);o||c(e,"Object key is required");let d=await j();if((y||E(o,t))==="stream"){let{data:i,error:n}=await w(o,"stream",{...g?{snapshotVersion:g}:{},config:{...d,bucket:f}});if(n&&c(e,n),t){let O=v(t);await x(S.fromWeb(i),O),a(e,{key:o,output:t}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:f,key:o,output:t}))}else await x(S.fromWeb(i),process.stdout),a(e)}else{let{data:i,error:n}=await w(o,"string",{...g?{snapshotVersion:g}:{},config:{...d,bucket:f}});n&&c(e,n),t?(q(t,i),a(e,{key:o,output:t}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:f,key:o,output:t}))):(console.log(i),a(e))}}export{F as default};
1
+ import{h as w}from"../../chunk-RXNG56FL.js";import{d as k}from"../../chunk-YN2TKPPT.js";import{a as r,b as j}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as a,j as b}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{get as S}from"@tigrisdata/storage";import{createWriteStream as q,writeFileSync as T}from"fs";import{extname as C}from"path";import{Readable as x}from"stream";import{pipeline as y}from"stream/promises";var e=b("objects","get"),E=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function F(t,m){let d=C(m||t).toLowerCase();return E.has(d)?"string":"stream"}async function N(t){u(e);let m=j(t),p=r(t,["bucket"]),d=r(t,["key"]),s=r(t,["output","o","O"]),v=r(t,["mode","m","M"]),g=r(t,["snapshot-version","snapshotVersion","snapshot"]),f=r(t,["version-id","versionId"]);p||c(e,"Bucket name or path is required");let{bucket:l,key:o}=w(p,d);o||c(e,"Object key is required");let h=await k();if((v||F(o,s))==="stream"){let{data:i,error:n}=await S(o,"stream",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});if(n&&c(e,n),s){let O=q(s);await y(x.fromWeb(i),O),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))}else await y(x.fromWeb(i),process.stdout),a(e)}else{let{data:i,error:n}=await S(o,"string",{...g?{snapshotVersion:g}:{},...f?{versionId:f}:{},config:{...h,bucket:l}});n&&c(e,n),s?(T(s,i),a(e,{key:o,output:s}),m==="json"&&console.log(JSON.stringify({action:"downloaded",bucket:l,key:o,output:s}))):(console.log(i),a(e))}}export{N as default};
@@ -1 +1 @@
1
- import{a as h,f as k}from"../../chunk-IRDNZN7R.js";import{h as d}from"../../chunk-RXNG56FL.js";import{d as l}from"../../chunk-YN2TKPPT.js";import{a as i,b as g}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as u,j as p}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{head as O}from"@tigrisdata/storage";var e=p("objects","info");async function A(r){m(e);let b=g(r),c=i(r,["bucket"]),v=i(r,["key"]),s=i(r,["snapshot-version","snapshotVersion","snapshot"]);c||o(e,"Bucket name or path is required");let{bucket:a,key:n}=d(c,v);n||o(e,"Object key is required");let y=await l(),{data:t,error:f}=await O(n,{...s?{snapshotVersion:s}:{},config:{...y,bucket:a}});f&&o(e,f),t||o(e,"Object not found");let S=[{metric:"Path",value:t.path},{metric:"Size",value:h(t.size)},{metric:"Content-Type",value:t.contentType||"N/A"},{metric:"Content-Disposition",value:t.contentDisposition||"N/A"},{metric:"Modified",value:t.modified.toISOString()},{metric:"URL",value:t.url}],j=k(S,b,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(j),u(e,{bucket:a,key:n})}export{A as default};
1
+ import{a as h,f as k}from"../../chunk-IRDNZN7R.js";import{h as v}from"../../chunk-RXNG56FL.js";import{d as l}from"../../chunk-YN2TKPPT.js";import{a as i,b as d}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as u,c as p,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{head as A}from"@tigrisdata/storage";var e=g("objects","info");async function I(o){u(e);let b=d(o),s=i(o,["bucket"]),y=i(o,["key"]),c=i(o,["snapshot-version","snapshotVersion","snapshot"]),a=i(o,["version-id","versionId"]);s||r(e,"Bucket name or path is required");let{bucket:f,key:n}=v(s,y);n||r(e,"Object key is required");let S=await l(),{data:t,error:m}=await A(n,{...c?{snapshotVersion:c}:{},...a?{versionId:a}:{},config:{...S,bucket:f}});m&&r(e,m),t||r(e,"Object not found");let j=[{metric:"Path",value:t.path},{metric:"Size",value:h(t.size)},{metric:"Content-Type",value:t.contentType||"N/A"},{metric:"Content-Disposition",value:t.contentDisposition||"N/A"},{metric:"Modified",value:t.modified.toISOString()},{metric:"URL",value:t.url}],O=k(j,b,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(O),p(e,{bucket:f,key:n})}export{I as default};
@@ -0,0 +1,6 @@
1
+ import{a as K,b as w,d as l,e as d}from"../../chunk-IRDNZN7R.js";import{e as C}from"../../chunk-RXNG56FL.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as o,b as I,c as V}from"../../chunk-S6KFKBMY.js";import{b as a}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as u,e as x,j as v}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{listVersions as D}from"@tigrisdata/storage";var i=v("objects","list-versions");async function O(s){p(i);let k=o(s,["bucket"]),z=o(s,["prefix","p","P"]),m=o(s,["delimiter","d"]),c=o(s,["key-marker","keyMarker"]),f=o(s,["version-id-marker","versionIdMarker"]),g=I(s),{limit:y}=V(s);k||a(i,"Bucket name is required");let M=C(k),P=M.bucket,S=z||M.path||void 0,j=await b(),{data:r,error:h}=await D({prefix:S,...m?{delimiter:m}:{},...y!==void 0?{limit:y}:{},...c?{keyMarker:c}:{},...f?{versionIdMarker:f}:{},config:{...j,bucket:P}});h&&a(i,h);let t=r.versions.map(e=>({key:e.name,versionId:e.versionId,latest:e.isLatest?"yes":"",size:K(e.size),modified:e.lastModified})),n=r.deleteMarkers.map(e=>({key:e.name,versionId:e.versionId,latest:e.isLatest?"yes":"",modified:e.lastModified})),L=[{key:"key",header:"Key"},{key:"versionId",header:"Version ID"},{key:"latest",header:"Latest"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}],T=[{key:"key",header:"Key"},{key:"versionId",header:"Version ID"},{key:"latest",header:"Latest"},{key:"modified",header:"Modified"}];if(g==="json")console.log(w({versions:r.versions,deleteMarkers:r.deleteMarkers,commonPrefixes:r.commonPrefixes,nextKeyMarker:r.nextKeyMarker,nextVersionIdMarker:r.nextVersionIdMarker,hasMore:r.hasMore}));else if(g==="xml"){let e=["<listVersions>"];e.push(" "+l(t,"versions","version").replace(/\n/g,`
2
+ `)),e.push(" "+l(n,"deleteMarkers","deleteMarker").replace(/\n/g,`
3
+ `)),e.push("</listVersions>"),console.log(e.join(`
4
+ `))}else{if(t.length===0&&n.length===0){x(i);return}if(t.length>0&&(console.log(`
5
+ Versions`),console.log(d(t,L))),n.length>0&&(console.log("Delete Markers"),console.log(d(n,T))),r.hasMore&&r.nextKeyMarker){let e=`
6
+ Next page: --key-marker "${r.nextKeyMarker}"`;r.nextVersionIdMarker&&(e+=` --version-id-marker "${r.nextVersionIdMarker}"`),console.error(e)}}u(i,{versions:t.length,deleteMarkers:n.length})}export{O as default};
@@ -1 +1 @@
1
- import{a as A}from"../../chunk-HPICBIXL.js";import{a as R}from"../../chunk-EKW6XTGL.js";import{a as s,f as v}from"../../chunk-IRDNZN7R.js";import{h as j}from"../../chunk-RXNG56FL.js";import{d as w}from"../../chunk-YN2TKPPT.js";import{a as n,b as z}from"../../chunk-S6KFKBMY.js";import{b as i,d as T}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as k,c as S,j as h}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{put as E}from"@tigrisdata/storage";import{createReadStream as M,statSync as N}from"fs";import{Readable as C}from"stream";var t=h("objects","put");async function Y(r){k(t);let u=n(r,["bucket"]),l=n(r,["key"]),y=n(r,["file"]),O=n(r,["access","a","A"],"private"),P=n(r,["content-type","contentType","t","T"]),$=z(r);u||i(t,"Bucket name or path is required");let d=j(u),m=d.bucket,a=d.key||l,e=d.key&&l||y;a||i(t,"Object key is required");let q=!process.stdin.isTTY;!e&&!q&&i(t,"File path is required (or pipe data via stdin)");let f,o;if(e){try{o=N(e).size}catch{i(t,`File not found: ${e}`)}let p=M(e);f=C.toWeb(p)}else f=C.toWeb(process.stdin);let U=await w({withCredentialProvider:!0}),x=e?R(o):{multipart:!0,partSize:5*1024*1024,queueSize:8},F=P??(e?A(e):void 0),{data:c,error:g}=await E(a,f,{access:O==="public"?"public":"private",contentType:F,...x,onUploadProgress:({loaded:p,percentage:b})=>{o!==void 0&&o>0?process.stdout.write(`\rUploading: ${s(p)} / ${s(o)} (${b}%)`):process.stdout.write(`\rUploading: ${s(p)}`)},config:{...U,bucket:m}});process.stdout.write("\r"+" ".repeat(60)+"\r"),g&&i(t,g);let W=[{path:c.path,size:s(c.size??o??0),contentType:c.contentType||"-",modified:c.modified}],B=v(W,$,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log(B),S(t,{key:a,bucket:m}),T(t,{key:a,bucket:m})}export{Y as default};
1
+ import{a as R}from"../../chunk-EKW6XTGL.js";import{a as A}from"../../chunk-HPICBIXL.js";import{a as s,f as v}from"../../chunk-IRDNZN7R.js";import{h as j}from"../../chunk-RXNG56FL.js";import{d as w}from"../../chunk-YN2TKPPT.js";import{a as n,b as z}from"../../chunk-S6KFKBMY.js";import{b as i,d as T}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as k,c as S,j as h}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{put as E}from"@tigrisdata/storage";import{createReadStream as M,statSync as N}from"fs";import{Readable as C}from"stream";var t=h("objects","put");async function Y(r){k(t);let u=n(r,["bucket"]),l=n(r,["key"]),y=n(r,["file"]),O=n(r,["access","a","A"],"private"),P=n(r,["content-type","contentType","t","T"]),$=z(r);u||i(t,"Bucket name or path is required");let d=j(u),m=d.bucket,a=d.key||l,e=d.key&&l||y;a||i(t,"Object key is required");let q=!process.stdin.isTTY;!e&&!q&&i(t,"File path is required (or pipe data via stdin)");let f,o;if(e){try{o=N(e).size}catch{i(t,`File not found: ${e}`)}let p=M(e);f=C.toWeb(p)}else f=C.toWeb(process.stdin);let U=await w({withCredentialProvider:!0}),x=e?R(o):{multipart:!0,partSize:5*1024*1024,queueSize:8},F=P??(e?A(e):void 0),{data:c,error:g}=await E(a,f,{access:O==="public"?"public":"private",contentType:F,...x,onUploadProgress:({loaded:p,percentage:b})=>{o!==void 0&&o>0?process.stdout.write(`\rUploading: ${s(p)} / ${s(o)} (${b}%)`):process.stdout.write(`\rUploading: ${s(p)}`)},config:{...U,bucket:m}});process.stdout.write("\r"+" ".repeat(60)+"\r"),g&&i(t,g);let W=[{path:c.path,size:s(c.size??o??0),contentType:c.contentType||"-",modified:c.modified}],B=v(W,$,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log(B),S(t,{key:a,bucket:m}),T(t,{key:a,bucket:m})}export{Y as default};
@@ -0,0 +1 @@
1
+ import{h as l}from"../../chunk-RXNG56FL.js";import{d as k}from"../../chunk-YN2TKPPT.js";import{a as o,b}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as u,j as p}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{setObjectAccess as v}from"@tigrisdata/storage";var e=p("objects","set-access");async function j(r){m(e);let d=b(r),a=o(r,["bucket"]),f=o(r,["key"]),y=o(r,["access"]);a||c(e,"Bucket name or path is required");let i=l(a),n=i.bucket,s=i.key||f,t=i.key?f:y;s||c(e,"Object key is required"),t||c(e,"Access level is required (public or private)"),t!=="public"&&t!=="private"&&c(e,'Access level must be either "public" or "private"');let A=await k(),{error:g}=await v(s,{access:t,config:{...A,bucket:n}});g&&c(e,g),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,key:s,access:t})),u(e,{key:s,bucket:n,access:t})}export{j as default};
@@ -1 +1 @@
1
- import{h as k}from"../../chunk-RXNG56FL.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as c,b as p}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as g,c as m,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateObject as j}from"@tigrisdata/storage";var e=u("objects","set");async function w(t){g(e);let l=p(t),a=c(t,["bucket"]),y=c(t,["key"]),s=c(t,["access","a","A"]),i=c(t,["new-key","n","newKey"]);a||r(e,"Bucket name or path is required");let{bucket:n,key:o}=k(a,y);o||r(e,"Object key is required"),s||r(e,"Access level is required (--access public|private)");let d=await b(),{error:f}=await j(o,{access:s==="public"?"public":"private",...i&&{key:i},config:{...d,bucket:n}});f&&r(e,f),l==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,key:o,access:s,...i?{newKey:i}:{}})),m(e,{key:o,bucket:n})}export{w as default};
1
+ import{h as d}from"../../chunk-RXNG56FL.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as i,b as y}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as k,j as l}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{move as v,setObjectAccess as A}from"@tigrisdata/storage";var e=l("objects","set");async function O(r){p(e);let w=y(r),f=i(r,["bucket"]),j=i(r,["key"]),s=i(r,["access","a","A"]),c=i(r,["new-key","n","newKey"]);f||t(e,"Bucket name or path is required");let{bucket:n,key:a}=d(f,j);a||t(e,"Object key is required"),s||t(e,"Access level is required (--access public|private)");let g={...await b(),bucket:n},o=a;if(c){let{error:u}=await v(a,c,{config:g});u&&t(e,u),o=c}let{error:m}=await A(o,{access:s==="public"?"public":"private",config:g});m&&t(e,m),w==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,key:o,access:s,...c?{newKey:c}:{}})),k(e,{key:o,bucket:n})}export{O as default};
package/dist/lib/stat.js CHANGED
@@ -1 +1 @@
1
- import{c as w}from"../chunk-HWX63Y3P.js";import{a as d,f as c}from"../chunk-IRDNZN7R.js";import{e as j}from"../chunk-RXNG56FL.js";import{d as O}from"../chunk-YN2TKPPT.js";import{a as g,b}from"../chunk-S6KFKBMY.js";import{b as i}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as k,c as n,j as y}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{getBucketInfo as A,getStats as I,head as M}from"@tigrisdata/storage";var t=y("stat");async function z(u){k(t);let h=g(u,["path"]),m=b(u),v=g(u,["snapshot-version","snapshotVersion","snapshot"]),f=await O();if(!h){let{data:o,error:r}=await I({config:f});r&&i(t,r);let p=[{metric:"Active Buckets",value:String(o.stats.activeBuckets)},{metric:"Total Objects",value:String(o.stats.totalObjects)},{metric:"Total Unique Objects",value:String(o.stats.totalUniqueObjects)},{metric:"Total Storage",value:d(o.stats.totalStorageBytes)}],l=c(p,m,"stats","stat",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(l),n(t),process.exit(0)}let{bucket:a,path:s}=j(h);if(a||i(t,"Invalid path"),!s||s==="/"){let{data:o,error:r}=await A(a,{config:f});r&&i(t,r);let p=w(o).map(({label:T,value:V})=>({metric:T,value:V})),l=c(p,m,"bucket-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(l),n(t,{bucket:a}),process.exit(0)}let{data:e,error:S}=await M(s,{...v?{snapshotVersion:v}:{},config:{...f,bucket:a}});S&&i(t,S),e||i(t,"Object not found");let x=[{metric:"Path",value:e.path},{metric:"Size",value:d(e.size)},{metric:"Content-Type",value:e.contentType||"N/A"},{metric:"Content-Disposition",value:e.contentDisposition||"N/A"},{metric:"Modified",value:e.modified.toISOString()}],B=c(x,m,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(B),n(t,{bucket:a,path:s}),process.exit(0)}export{z as default};
1
+ import{c as w}from"../chunk-LAB2KJTN.js";import{a as d,f as m}from"../chunk-IRDNZN7R.js";import"../chunk-N3Y6RFSK.js";import"../chunk-S77OAN6Y.js";import{e as I}from"../chunk-RXNG56FL.js";import{d as j}from"../chunk-YN2TKPPT.js";import{a as u,b as O}from"../chunk-S6KFKBMY.js";import{b as i}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as y,c,j as b}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{getBucketInfo as A,getStats as M,head as z}from"@tigrisdata/storage";var t=b("stat");async function C(s){y(t);let h=u(s,["path"]),f=O(s),v=u(s,["snapshot-version","snapshotVersion","snapshot"]),S=u(s,["version-id","versionId"]),l=await j();if(!h){let{data:o,error:a}=await M({config:l});a&&i(t,a);let p=[{metric:"Active Buckets",value:String(o.stats.activeBuckets)},{metric:"Total Objects",value:String(o.stats.totalObjects)},{metric:"Total Unique Objects",value:String(o.stats.totalUniqueObjects)},{metric:"Total Storage",value:d(o.stats.totalStorageBytes)}],g=m(p,f,"stats","stat",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(g),c(t),process.exit(0)}let{bucket:r,path:n}=I(h);if(r||i(t,"Invalid path"),!n||n==="/"){let{data:o,error:a}=await A(r,{config:l});a&&i(t,a);let p=w(o).map(({label:T,value:V})=>({metric:T,value:V})),g=m(p,f,"bucket-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(g),c(t,{bucket:r}),process.exit(0)}let{data:e,error:k}=await z(n,{...v?{snapshotVersion:v}:{},...S?{versionId:S}:{},config:{...l,bucket:r}});k&&i(t,k),e||i(t,"Object not found");let x=[{metric:"Path",value:e.path},{metric:"Size",value:d(e.size)},{metric:"Content-Type",value:e.contentType||"N/A"},{metric:"Content-Disposition",value:e.contentDisposition||"N/A"},{metric:"Modified",value:e.modified.toISOString()}],B=m(x,f,"object-info","info",[{key:"metric",header:"Metric"},{key:"value",header:"Value"}]);console.log(B),c(t,{bucket:r,path:n}),process.exit(0)}export{C as default};
@@ -1 +1 @@
1
- import{b as d}from"../chunk-S6KFKBMY.js";import{a as t,c as l,d as p,e as f}from"../chunk-K4QARFBT.js";import{b as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as s,c as i,f as a,j as c}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{execSync as h}from"child_process";var r=c("update");async function v(u={}){let g=d(u);s(r);try{let o=await f(),e=l(t,o),n=p();if(g==="json"){console.log(JSON.stringify({currentVersion:t,latestVersion:o,updateAvailable:e,updateCommand:n}));return}console.log(`Current version: ${t}`),e?(console.log(`Latest version: ${o}`),console.log("Updating..."),h(n,{stdio:"inherit",...process.platform==="win32"?{shell:"powershell.exe"}:{}}),i(r,{latestVersion:o})):a(r,{currentVersion:t})}catch(o){m(r,o)}}export{v as default};
1
+ import{b as d}from"../chunk-S6KFKBMY.js";import{a as t,c as l,d as p,e as f}from"../chunk-GLKOUVFH.js";import{b as m}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import{b as s,c as i,f as a,j as c}from"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import{execSync as h}from"child_process";var r=c("update");async function v(u={}){let g=d(u);s(r);try{let o=await f(),e=l(t,o),n=p();if(g==="json"){console.log(JSON.stringify({currentVersion:t,latestVersion:o,updateAvailable:e,updateCommand:n}));return}console.log(`Current version: ${t}`),e?(console.log(`Latest version: ${o}`),console.log("Updating..."),h(n,{stdio:"inherit",...process.platform==="win32"?{shell:"powershell.exe"}:{}}),i(r,{latestVersion:o})):a(r,{currentVersion:t})}catch(o){m(r,o)}}export{v as default};