@tigrisdata/cli 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -13
- package/dist/auth/client.js +1 -1
- package/dist/auth/config.js +1 -1
- package/dist/auth/s3-client.js +1 -1
- package/dist/auth/storage.js +1 -1
- package/dist/chunk-4LGKN5DA.js +1 -0
- package/dist/chunk-6U4U4JM6.js +1 -0
- package/dist/chunk-A3TXP5Y2.js +2 -0
- package/dist/chunk-D63SZLT5.js +1 -0
- package/dist/chunk-DJIPPZGR.js +4 -0
- package/dist/chunk-ESJWTUFN.js +1 -0
- package/dist/chunk-HE7E7ZMA.js +1 -0
- package/dist/chunk-HGIJOGCZ.js +6 -0
- package/dist/chunk-JRALYIRA.js +1 -0
- package/dist/chunk-JVB3Y42V.js +1 -0
- package/dist/chunk-LCWHZUZZ.js +1 -0
- package/dist/chunk-QZXBLNMQ.js +1 -0
- package/dist/chunk-TPUZYSCZ.js +12 -0
- package/dist/chunk-TUJTXB5G.js +8 -0
- package/dist/cli.js +1 -12
- package/dist/constants.js +1 -1
- package/dist/index.js +1 -12
- package/dist/lib/_stat.js +1 -1
- package/dist/lib/access-keys/assign.js +2 -3
- package/dist/lib/access-keys/create.js +2 -3
- package/dist/lib/access-keys/delete.js +2 -3
- package/dist/lib/access-keys/get.js +2 -3
- package/dist/lib/access-keys/list.js +2 -8
- package/dist/lib/buckets/create.js +1 -2
- package/dist/lib/buckets/delete.js +1 -2
- package/dist/lib/buckets/get.js +1 -7
- package/dist/lib/buckets/list.js +1 -7
- package/dist/lib/buckets/set.js +1 -2
- package/dist/lib/configure/index.js +1 -2
- package/dist/lib/cp.js +1 -1
- package/dist/lib/credentials/test.js +1 -2
- package/dist/lib/forks/create.js +1 -2
- package/dist/lib/forks/list.js +1 -7
- package/dist/lib/login/credentials.js +1 -2
- package/dist/lib/login/oauth.js +1 -5
- package/dist/lib/login/select.js +1 -5
- package/dist/lib/logout.js +1 -2
- package/dist/lib/ls.js +1 -6
- package/dist/lib/mk.js +1 -1
- package/dist/lib/mv.js +1 -1
- package/dist/lib/objects/delete.js +1 -2
- package/dist/lib/objects/get.js +1 -2
- package/dist/lib/objects/list.js +1 -7
- package/dist/lib/objects/put.js +1 -7
- package/dist/lib/organizations/create.js +2 -3
- package/dist/lib/organizations/list.js +2 -8
- package/dist/lib/organizations/select.js +4 -5
- package/dist/lib/rm.js +1 -1
- package/dist/lib/snapshots/list.js +1 -7
- package/dist/lib/snapshots/take.js +1 -2
- package/dist/lib/touch.js +1 -1
- package/dist/lib/whoami.js +2 -3
- package/dist/specs.yaml +49 -28
- package/dist/utils/format.js +1 -6
- package/dist/utils/messages.js +1 -2
- package/dist/utils/options.js +1 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/specs.js +1 -1
- package/dist/utils/update-check.js +1 -0
- package/package.json +3 -2
package/dist/lib/mk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as n}from"../chunk-JRALYIRA.js";import{b as a}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{f as c}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{createBucket as f,put as g}from"@tigrisdata/storage";async function l(p){let t=n(p,["path"]);t||(console.error("path argument is required"),process.exit(1));let{bucket:e,path:r}=c(t);e||(console.error("Invalid path"),process.exit(1));let s=await a();if(r){let o=r.endsWith("/")?r:`${r}/`,{error:i}=await g(o,"",{config:{...s,bucket:e}});i&&(console.error(i.message),process.exit(1)),console.log(`Folder '${e}/${o}' created`),process.exit(0)}else{let{error:o}=await f(e,{config:s});o&&(console.error(o.message),process.exit(1)),console.log(`Bucket '${e}' created`),process.exit(0)}}export{l as default};
|
package/dist/lib/mv.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as se from"readline";import{list as j}from"@tigrisdata/storage";function b(t){let e=t.split("/");return{bucket:e[0],path:e.slice(1).join("/")}}async function O(t,e,n){let{data:i}=await j({prefix:`${e}/`,limit:1,config:{...n,bucket:t}});return!!(i?.items&&i.items.length>0)}async function q(t,e,n){let i=[],o;do{let{data:r,error:s}=await j({prefix:e,paginationToken:o,config:{...n,bucket:t}});if(s)return{items:i,error:s};r?.items&&i.push(...r.items),o=r?.hasMore?r.paginationToken:void 0}while(o);return{items:i}}function C(t,e,n){for(let i of e)if(t[i]!==void 0)return t[i];return n}import{S3Client as Ge}from"@aws-sdk/client-s3";import{fromIni as he}from"@aws-sdk/credential-providers";import{homedir as H}from"os";import{join as m}from"path";import{readFileSync as de,writeFileSync as le,existsSync as k,mkdirSync as fe}from"fs";import{loadSharedConfigFiles as ge}from"@smithy/shared-ini-file-loader";import{chmod as pe}from"fs/promises";var g="https://t3.storage.dev",N="https://iam.storageapi.dev";var R=m(H(),".tigris"),I=m(R,"config.json");function ue(){k(R)||fe(R,{recursive:!0,mode:448})}function f(){if(k(I))try{let t=de(I,"utf8");return JSON.parse(t)}catch{return{}}return{}}async function A(t){ue(),le(I,JSON.stringify(t,null,2),{mode:384});try{await pe(I,384)}catch{}}async function D(t){let e=f();e.tokens=t,await A(e)}async function h(){return f().tokens||null}async function K(){let t=f();delete t.tokens,await A(t)}async function J(t){let e=f();e.organizations=t,await A(e)}function Y(){return f().organizations||[]}function M(){return f().selectedOrganization||null}function B(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let i=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,o=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!i||!o)return null;let r=process.env.TIGRIS_STORAGE_ENDPOINT||g;return{accessKeyId:i,secretAccessKey:o,endpoint:r}}let t=process.env.AWS_ACCESS_KEY_ID,e=process.env.AWS_SECRET_ACCESS_KEY;if(!t||!e)return null;let n=process.env.AWS_ENDPOINT_URL_S3||g;return{accessKeyId:t,secretAccessKey:e,endpoint:n}}function V(){if(!process.env.AWS_PROFILE)return!1;let t=m(H(),".aws");return k(m(t,"credentials"))||k(m(t,"config"))}async function Q(t){try{let{configFile:e}=await ge(),n=e[t];return n?{endpoint:n.endpoint_url_s3||n.endpoint_url,iamEndpoint:n.endpoint_url_iam,region:n.region}:{}}catch{return{}}}function $(){let t=f();return t.temporaryCredentials||t.credentials||null}async function X(t){let e=f();e.loginMethod=t,await A(e)}function Z(){return f().loginMethod||null}import S from"axios";import me from"open";function _(){let t=process.env.TIGRIS_ENV==="development",e=process.env.AUTH0_DOMAIN||t?"auth-dev.tigris.dev":"auth.tigris.dev",n=process.env.AUTH0_CLIENT_ID||t?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",i=process.env.AUTH0_AUDIENCE||t?"https://tigris-api-dev":"https://tigris-os-api";return{domain:e,clientId:n,audience:i}}var ee=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function te(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||g,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||N}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||g,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||N}}var L=class{config;baseUrl;constructor(){this.config=_(),this.baseUrl=`https://${this.config.domain}`}async login(e){let i=(await S.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;e?.onDeviceCode?.(i.user_code,i.verification_uri),await this.sleep(2e3);try{await me(i.verification_uri_complete)}catch{}e?.onWaiting?.();let o=await this.pollForToken(i.device_code,i.interval||5);await D(o),X("oauth"),await this.extractAndStoreOrganizations(o.idToken)}async pollForToken(e,n){let o=0;for(;o<60;){o++;try{let s=(await S.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:a}}catch(r){if(S.isAxiosError(r)&&r.response){let s=r.response.data?.error;if(s==="authorization_pending"){await this.sleep(n*1e3);continue}if(s==="slow_down"){n+=5,await this.sleep(n*1e3);continue}throw new Error(r.response.data?.error_description||"Authentication failed")}throw r}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await h();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){let n=null;if(e?.refreshToken?n=e:n=await h(),!n)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await S.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:n.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:o.access_token,refreshToken:o.refresh_token||n.refreshToken,idToken:o.id_token||n.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await D(r),r}catch{throw await K(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await h();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.idToken.split(".")[1],i=Buffer.from(n,"base64").toString("utf8");return JSON.parse(i)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(e){if(e)try{let n=e.split(".")[1],i=Buffer.from(n,"base64").toString("utf8"),r=JSON.parse(i)[ee];if(!r)return;let s=r?.ns?.map(a=>typeof a=="object"&&a!==null?{id:a.id,name:a.name,displayName:a.name}:{id:a,name:a,displayName:a})||[];if(s.length===0)return;J(s)}catch{}}async getOrganizations(){return await this.getAccessToken(),Y()}async logout(){await K()}async isAuthenticated(){return await h()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},F=null;function ne(){return F||(F=new L),F}var v=te(),Te=_();async function ye(){return Z()}async function oe(){if(V()){let i=process.env.AWS_PROFILE||"default",o=await Q(i),r=await he({profile:i})();return{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,endpoint:o.endpoint||v.endpoint||g,iamEndpoint:o.iamEndpoint||v.iamEndpoint}}let t=await ye();if(t==="oauth"){let o=await ne().getAccessToken();if(!M())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:o,accessKeyId:"",secretAccessKey:"",endpoint:v.endpoint,organizationId:M()??void 0,iamEndpoint:v.iamEndpoint,authDomain:Te.domain}}if(t==="credentials"){let i=$();if(i)return{accessKeyId:i.accessKeyId,secretAccessKey:i.secretAccessKey,endpoint:i.endpoint}}let e=B();if(e)return{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,endpoint:e.endpoint};let n=$();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}import{get as we,put as re,remove as G,list as Ce}from"@tigrisdata/storage";async function ie(t){let e=se.createInterface({input:process.stdin,output:process.stdout});return new Promise(n=>{e.question(`${t} (y/N): `,i=>{e.close(),n(i.toLowerCase()==="y")})})}async function ke(t){let e=C(t,["src"]),n=C(t,["dest"]),i=C(t,["force","f","F"]);(!e||!n)&&(console.error("both src and dest arguments are required"),process.exit(1));let o=b(e),r=b(n);o.bucket||(console.error("Invalid source path"),process.exit(1)),r.bucket||(console.error("Invalid destination path"),process.exit(1)),o.path||(console.error("Cannot move a bucket. Provide a path within the bucket."),process.exit(1));let s=await oe(),a=e.includes("*"),p=e.endsWith("/");if(!a&&!p&&o.path&&(p=await O(o.bucket,o.path,s)),a||p){let c=a?o.path.replace("*",""):o.path.endsWith("/")?o.path:`${o.path}/`,l=r.path?`${r.path.replace(/\/$/,"")}/`:"";o.bucket===r.bucket&&c===l&&(console.error("Source and destination are the same"),process.exit(1));let{items:T,error:y}=await q(o.bucket,c||void 0,s);y&&(console.error(y.message),process.exit(1));let E=T.filter(d=>d.name!==c),{data:ae}=await Ce({prefix:c,limit:1,config:{...s,bucket:o.bucket}}),P=c?ae?.items?.some(d=>d.name===c):!1;if(E.length===0&&!P){console.log("No objects to move");return}let ce=E.length+(P?1:0);if(!i&&!await ie(`Are you sure you want to move ${ce} object(s)?`)){console.log("Aborted");return}let w=0;for(let d of E){let u=c?d.name.slice(c.length):d.name,U=r.path?`${r.path.replace(/\/$/,"")}/${u}`:u,W=await z(s,o.bucket,d.name,r.bucket,U);W.error?console.error(`Failed to move ${d.name}: ${W.error}`):(console.log(`Moved ${d.name} -> ${r.bucket}/${U}`),w++)}let x=!1;if(P)if(r.path){let d=`${r.path.replace(/\/$/,"")}/`,u=await z(s,o.bucket,c,r.bucket,d);u.error?console.error(`Failed to move folder marker: ${u.error}`):x=!0}else{let{error:d}=await G(c,{config:{...s,bucket:o.bucket}});d?console.error(`Failed to remove source folder marker: ${d.message}`):x=!0}w===0&&x&&(w=1),console.log(`Moved ${w} object(s)`)}else{o.path||(console.error("Source object key is required"),process.exit(1));let c=o.path.split("/").pop(),l;if(r.path?n.endsWith("/")?l=`${r.path}${c}`:await O(r.bucket,r.path,s)?l=`${r.path}/${c}`:l=r.path:l=c,o.bucket===r.bucket&&o.path===l&&(console.error("Source and destination are the same"),process.exit(1)),!i&&!await ie(`Are you sure you want to move '${o.bucket}/${o.path}'?`)){console.log("Aborted");return}let T=await z(s,o.bucket,o.path,r.bucket,l);T.error&&(console.error(T.error),process.exit(1)),console.log(`Moved ${e} -> ${r.bucket}/${l}`)}process.exit(0)}async function z(t,e,n,i,o){if(n.endsWith("/")){let{error:c}=await re(o,"",{config:{...t,bucket:i}});if(c)return{error:c.message};let{error:l}=await G(n,{config:{...t,bucket:e}});return l?{error:`Copied but failed to delete source: ${l.message}`}:{}}let{data:r,error:s}=await we(n,"stream",{config:{...t,bucket:e}});if(s)return{error:s.message};let{error:a}=await re(o,r,{config:{...t,bucket:i}});if(a)return{error:a.message};let{error:p}=await G(n,{config:{...t,bucket:e}});return p?{error:`Copied but failed to delete source: ${p.message}`}:{}}export{ke as default};
|
|
1
|
+
import{a as x}from"../chunk-HGIJOGCZ.js";import{a as v}from"../chunk-JRALYIRA.js";import{b as j}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{a as F,b as y,d as S,g as A,h as C,i as I}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import*as N from"readline";import{get as B,put as T,remove as E,list as L,head as G}from"@tigrisdata/storage";async function D(i){let n=N.createInterface({input:process.stdin,output:process.stdout});return new Promise(a=>{n.question(`${i} (y/N): `,d=>{n.close(),a(d.toLowerCase()==="y")})})}async function H(i){let n=v(i,["src"]),a=v(i,["dest"]),d=v(i,["force","f","F"]),h=!!v(i,["recursive","r"]);(!n||!a)&&(console.error("both src and dest arguments are required"),process.exit(1)),(!F(n)||!F(a))&&(console.error("Both src and dest must be remote Tigris paths (t3:// or tigris://)"),process.exit(1));let e=y(n),t=y(a);e.bucket||(console.error("Invalid source path"),process.exit(1)),t.bucket||(console.error("Invalid destination path"),process.exit(1));let $=n.endsWith("/");!e.path&&!$&&(console.error("Cannot move a bucket. Provide a path within the bucket."),process.exit(1));let c=await j(),l=e.path.includes("*"),p=e.path.endsWith("/")||!e.path&&$;if(!l&&!p&&e.path&&(p=await S(e.bucket,e.path,c)),p&&!l&&!h&&(console.error("Source is a remote folder (not moved). Use -r to move recursively."),process.exit(1)),l||p){let r=l?C(e.path):e.path?e.path.endsWith("/")?e.path:`${e.path}/`:"",o=!l&&e.path&&!e.path.endsWith("/")?e.path.split("/").filter(Boolean).pop()??"":"",f=[t.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),z=f?`${f}/`:"";e.bucket===t.bucket&&r===z&&(console.error("Source and destination are the same"),process.exit(1));let{items:q,error:R}=await I(e.bucket,r||void 0,c);R&&(console.error(R.message),process.exit(1));let b=q.filter(s=>s.name!==r);if(l){let s=e.path.split("/").pop(),m=A(s);b=b.filter(g=>{let k=r?g.name.slice(r.length):g.name;return!h&&k.includes("/")?!1:m.test(k.split("/").pop())})}let{data:O}=await L({prefix:r,limit:1,config:{...c,bucket:e.bucket}}),P=r?O?.items?.some(s=>s.name===r):!1;if(b.length===0&&!P){console.log("No objects to move");return}let U=b.length+(P?1:0);if(!d&&!await D(`Are you sure you want to move ${U} object(s)?`)){console.log("Aborted");return}let w=0;for(let s of b){let m=r?s.name.slice(r.length):s.name,g=f?`${f}/${m}`:m,k=await W(c,e.bucket,s.name,t.bucket,g);k.error?console.error(`Failed to move ${s.name}: ${k.error}`):(console.log(`Moved t3://${e.bucket}/${s.name} -> t3://${t.bucket}/${g}`),w++)}let M=!1;if(P)if(f){let s=`${f}/`,m=await W(c,e.bucket,r,t.bucket,s);m.error?console.error(`Failed to move folder marker: ${m.error}`):M=!0}else{let{error:s}=await E(r,{config:{...c,bucket:e.bucket}});s?console.error(`Failed to remove source folder marker: ${s.message}`):M=!0}w===0&&M&&(w=1),console.log(`Moved ${w} object(s)`)}else{let r=e.path.split("/").pop(),o;if(t.path?t.path.endsWith("/")?o=`${t.path}${r}`:await S(t.bucket,t.path,c)?o=`${t.path}/${r}`:o=t.path:o=r,e.bucket===t.bucket&&e.path===o&&(console.error("Source and destination are the same"),process.exit(1)),!d&&!await D(`Are you sure you want to move 't3://${e.bucket}/${e.path}'?`)){console.log("Aborted");return}let u=await W(c,e.bucket,e.path,t.bucket,o,!0);u.error&&(console.error(u.error),process.exit(1)),console.log(`Moved t3://${e.bucket}/${e.path} -> t3://${t.bucket}/${o}`)}process.exit(0)}async function W(i,n,a,d,h,e=!1){if(a.endsWith("/")){let{error:o}=await T(h,"",{config:{...i,bucket:d}});if(o)return{error:o.message};let{error:u}=await E(a,{config:{...i,bucket:n}});return u?{error:`Copied but failed to delete source: ${u.message}`}:{}}let t;if(e){let{data:o}=await G(a,{config:{...i,bucket:n}});t=o?.size}let{data:$,error:c}=await B(a,"stream",{config:{...i,bucket:n}});if(c)return{error:c.message};let l=t!==void 0&&t>100*1024*1024,{error:p}=await T(h,$,{multipart:l,onUploadProgress:e?({loaded:o})=>{if(t!==void 0&&t>0){let u=Math.round(o/t*100);process.stdout.write(`\rMoving: ${x(o)} / ${x(t)} (${u}%)`)}else process.stdout.write(`\rMoving: ${x(o)}`)}:void 0,config:{...i,bucket:d}});if(e&&process.stdout.write("\r"+" ".repeat(60)+"\r"),p)return{error:p.message};let{error:r}=await E(a,{config:{...i,bucket:n}});return r?{error:`Copied but failed to delete source: ${r.message}`}:{}}export{H as default};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`),e&&(t=t.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let r=e[i];return r!==void 0?String(r):`{{${i}}}`})),t}function J(n,e){if(!H())return;let t=P(n);t?.onStart&&console.log(N(t.onStart,e))}function B(n,e){if(!H())return;let t=P(n);t?.onSuccess&&console.log(`${q.success} ${N(t.onSuccess,e)}`)}function T(n,e,t){let o=P(n);o?.onFailure&&console.error(`${q.failure} ${N(o.onFailure,t)}`),e&&console.error(` ${e}`)}function Q(n,e){return{command:n,operation:e}}var p=Q("objects","delete");async function Ce(n){J(p);let e=S(n,["bucket"]),t=S(n,["key"]);e||(T(p,"Bucket name is required"),process.exit(1)),t||(T(p,"Object key is required"),process.exit(1));let o=await $(),i=Array.isArray(t)?t:[t];for(let r of i){let{error:s}=await ye(r,{config:{...o,bucket:e}});s&&(T(p,s.message,{key:r}),process.exit(1)),B(p,{key:r})}}export{Ce as default};
|
|
1
|
+
import{a,b as g,c as r,g as m}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as i}from"../../chunk-JRALYIRA.js";import{b as f}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{remove as k}from"@tigrisdata/storage";var e=m("objects","delete");async function y(s){a(e);let n=i(s,["bucket"]),t=i(s,["key"]);n||(r(e,"Bucket name is required"),process.exit(1)),t||(r(e,"Object key is required"),process.exit(1));let p=await f(),u=Array.isArray(t)?t:[t];for(let o of u){let{error:c}=await k(o,{config:{...p,bucket:n}});c&&(r(e,c.message,{key:o}),process.exit(1)),g(e,{key:o})}}export{y as default};
|
package/dist/lib/objects/get.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),e&&(n=n.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let s=e[i];return s!==void 0?String(s):`{{${i}}}`})),n}function X(t,e){if(!B())return;let n=M(t);n?.onStart&&console.log(R(n.onStart,e))}function m(t,e){if(!B())return;let n=M(t);n?.onSuccess&&console.log(`${J.success} ${R(n.onSuccess,e)}`)}function h(t,e,n){let o=M(t);o?.onFailure&&console.error(`${J.failure} ${R(o.onFailure,n)}`),e&&console.error(` ${e}`)}function Q(t,e){return{command:t,operation:e}}var d=Q("objects","get"),Ie=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 Ee(t,e){let o=_e(e||t).toLowerCase();return Ie.has(o)?"string":"stream"}async function xe(t){X(d);let e=p(t,["bucket"]),n=p(t,["key"]),o=p(t,["output","o","O"]),i=p(t,["mode","m","M"]);e||(h(d,"Bucket name is required"),process.exit(1)),n||(h(d,"Object key is required"),process.exit(1));let s=await q();if((i||Ee(n,o))==="stream"){let{data:r,error:g}=await te(n,"stream",{config:{...s,bucket:e}});if(g&&(h(d,g.message),process.exit(1)),o){let ne=Ae(o);await ee(Z.fromWeb(r),ne),m(d,{key:n,output:o})}else await ee(Z.fromWeb(r),process.stdout),m(d)}else{let{data:r,error:g}=await te(n,"string",{config:{...s,bucket:e}});g&&(h(d,g.message),process.exit(1)),o?(we(o,r),m(d,{key:n,output:o})):(console.log(r),m(d))}}export{xe as default};
|
|
1
|
+
import{a as f,b as c,c as m,g as l}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n}from"../../chunk-JRALYIRA.js";import{b as p}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createWriteStream as j,writeFileSync as k}from"fs";import{Readable as d}from"stream";import{pipeline as u}from"stream/promises";import{extname as w}from"path";import{get as h}from"@tigrisdata/storage";var e=l("objects","get"),S=new Set([".js",".ts",".jsx",".tsx",".mjs",".cjs",".py",".rb",".php",".java",".go",".rs",".c",".cpp",".h",".hpp",".cs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".sql",".graphql",".gql",".json",".yaml",".yml",".toml",".ini",".cfg",".conf",".xml",".plist",".env",".properties",".html",".htm",".css",".scss",".sass",".less",".styl",".md",".markdown",".mdx",".rst",".txt",".text",".csv",".tsv",".log",".ejs",".hbs",".pug",".jade",".njk",".twig",".liquid",".svg",".gitignore",".dockerignore",".editorconfig"]);function y(r,o){let t=w(o||r).toLowerCase();return S.has(t)?"string":"stream"}async function q(r){f(e);let o=n(r,["bucket"]),s=n(r,["key"]),t=n(r,["output","o","O"]),x=n(r,["mode","m","M"]);o||(m(e,"Bucket name is required"),process.exit(1)),s||(m(e,"Object key is required"),process.exit(1));let g=await p();if((x||y(s,t))==="stream"){let{data:i,error:a}=await h(s,"stream",{config:{...g,bucket:o}});if(a&&(m(e,a.message),process.exit(1)),t){let b=j(t);await u(d.fromWeb(i),b),c(e,{key:s,output:t})}else await u(d.fromWeb(i),process.stdout),c(e)}else{let{data:i,error:a}=await h(s,"string",{config:{...g,bucket:o}});a&&(m(e,a.message),process.exit(1)),t?(k(t,i),c(e,{key:s,output:t})):(console.log(i),c(e))}}export{q as default};
|
package/dist/lib/objects/list.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`)}function de(e,n,t){let o=[`<${n}>`];return e.forEach(i=>{o.push(` <${t}>`),o.push(ce(i," ")),o.push(` </${t}>`)}),o.push(`</${n}>`),o.join(`
|
|
3
|
-
`)}function F(e){if(e==null)return"";if(e instanceof Date)return L(e);if(typeof e=="string"){let n=new Date(e);if(!isNaN(n.getTime())&&e.includes("T"))return L(n)}return String(e)}function L(e){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(e)}function ue(e,n){return n.map(t=>{if(t.width)return t.width;let o=t.header.length,i=e.reduce((r,s)=>{let a=F(s[t.key]);return Math.max(r,a.length)},0);return Math.max(o,i)})}function pe(e,n){let t=[],o=ue(e,n),i="\u250C"+o.map(c=>"\u2500".repeat(c+2)).join("\u252C")+"\u2510",r="\u251C"+o.map(c=>"\u2500".repeat(c+2)).join("\u253C")+"\u2524",s="\u2514"+o.map(c=>"\u2500".repeat(c+2)).join("\u2534")+"\u2518";t.push(`
|
|
4
|
-
`+i);let a="\u2502 "+n.map((c,p)=>c.header.padEnd(o[p])).join(" \u2502 ")+" \u2502";return t.push(a),t.push(r),e.forEach(c=>{let p=n.map((b,K)=>{let z=F(c[b.key]);return b.align==="right"?z.padStart(o[K]):z.padEnd(o[K])});t.push("\u2502 "+p.join(" \u2502 ")+" \u2502")}),t.push(s+`
|
|
5
|
-
`),t.join(`
|
|
6
|
-
`)}function j(e,n,t,o,i){switch(n){case"json":return ae(e);case"xml":return de(e,t,o);default:return pe(e,i)}}import{S3Client as Xe}from"@aws-sdk/client-s3";import{fromIni as Ce}from"@aws-sdk/credential-providers";import{homedir as G}from"os";import{join as g}from"path";import{readFileSync as ge,writeFileSync as le,existsSync as h,mkdirSync as fe}from"fs";import{loadSharedConfigFiles as me}from"@smithy/shared-ini-file-loader";import{chmod as he}from"fs/promises";var u="https://t3.storage.dev",I="https://iam.storageapi.dev";var x=g(G(),".tigris"),T=g(x,"config.json");function Te(){h(x)||fe(x,{recursive:!0,mode:448})}function d(){if(h(T))try{let e=ge(T,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function y(e){Te(),le(T,JSON.stringify(e,null,2),{mode:384});try{await he(T,384)}catch{}}async function k(e){let n=d();n.tokens=e,await y(n)}async function l(){return d().tokens||null}async function E(){let e=d();delete e.tokens,await y(e)}async function $(e){let n=d();n.organizations=e,await y(n)}function U(){return d().organizations||[]}function v(){return d().selectedOrganization||null}function B(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let o=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,i=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!o||!i)return null;let r=process.env.TIGRIS_STORAGE_ENDPOINT||u;return{accessKeyId:o,secretAccessKey:i,endpoint:r}}let e=process.env.AWS_ACCESS_KEY_ID,n=process.env.AWS_SECRET_ACCESS_KEY;if(!e||!n)return null;let t=process.env.AWS_ENDPOINT_URL_S3||u;return{accessKeyId:e,secretAccessKey:n,endpoint:t}}function W(){if(!process.env.AWS_PROFILE)return!1;let e=g(G(),".aws");return h(g(e,"credentials"))||h(g(e,"config"))}async function V(e){try{let{configFile:n}=await me(),t=n[e];return t?{endpoint:t.endpoint_url_s3||t.endpoint_url,iamEndpoint:t.endpoint_url_iam,region:t.region}:{}}catch{return{}}}function O(){let e=d();return e.temporaryCredentials||e.credentials||null}async function Y(e){let n=d();n.loginMethod=e,await y(n)}function J(){return d().loginMethod||null}import S from"axios";import ye from"open";function C(){let e=process.env.TIGRIS_ENV==="development",n=process.env.AUTH0_DOMAIN||e?"auth-dev.tigris.dev":"auth.tigris.dev",t=process.env.AUTH0_CLIENT_ID||e?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",o=process.env.AUTH0_AUDIENCE||e?"https://tigris-api-dev":"https://tigris-os-api";return{domain:n,clientId:t,audience:o}}var q=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function H(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||u,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||I}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||u,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||I}}var M=class{config;baseUrl;constructor(){this.config=C(),this.baseUrl=`https://${this.config.domain}`}async login(n){let o=(await S.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;n?.onDeviceCode?.(o.user_code,o.verification_uri),await this.sleep(2e3);try{await ye(o.verification_uri_complete)}catch{}n?.onWaiting?.();let i=await this.pollForToken(o.device_code,o.interval||5);await k(i),Y("oauth"),await this.extractAndStoreOrganizations(i.idToken)}async pollForToken(n,t){let i=0;for(;i<60;){i++;try{let s=(await S.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:n,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:a}}catch(r){if(S.isAxiosError(r)&&r.response){let s=r.response.data?.error;if(s==="authorization_pending"){await this.sleep(t*1e3);continue}if(s==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(r.response.data?.error_description||"Authentication failed")}throw r}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let n=await l();if(!n)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=n.expiresAt&&(n=await this.refreshAccessToken(n)),n.accessToken}async refreshAccessToken(n){let t=null;if(n?.refreshToken?t=n:t=await l(),!t)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let i=(await S.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:i.access_token,refreshToken:i.refresh_token||t.refreshToken,idToken:i.id_token||t.idToken,expiresAt:Date.now()+(i.expires_in||3600)*1e3};return await k(r),r}catch{throw await E(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let n=await l();if(!n||!n.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let t=n.idToken.split(".")[1],o=Buffer.from(t,"base64").toString("utf8");return JSON.parse(o)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(n){if(n)try{let t=n.split(".")[1],o=Buffer.from(t,"base64").toString("utf8"),r=JSON.parse(o)[q];if(!r)return;let s=r?.ns?.map(a=>typeof a=="object"&&a!==null?{id:a.id,name:a.name,displayName:a.name}:{id:a,name:a,displayName:a})||[];if(s.length===0)return;$(s)}catch{}}async getOrganizations(){return await this.getAccessToken(),U()}async logout(){await E()}async isAuthenticated(){return await l()!==null}sleep(n){return new Promise(t=>setTimeout(t,n))}},P=null;function X(){return P||(P=new M),P}var w=H(),Se=C();async function we(){return J()}async function Q(){if(W()){let o=process.env.AWS_PROFILE||"default",i=await V(o),r=await Ce({profile:o})();return{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,endpoint:i.endpoint||w.endpoint||u,iamEndpoint:i.iamEndpoint||w.iamEndpoint}}let e=await we();if(e==="oauth"){let i=await X().getAccessToken();if(!v())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:i,accessKeyId:"",secretAccessKey:"",endpoint:w.endpoint,organizationId:v()??void 0,iamEndpoint:w.iamEndpoint,authDomain:Se.domain}}if(e==="credentials"){let o=O();if(o)return{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,endpoint:o.endpoint}}let n=B();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};let t=O();if(t)return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}import{list as Pe}from"@tigrisdata/storage";import{readFileSync as Ae,existsSync as _e}from"fs";import{join as Z,dirname as Ie}from"path";import{fileURLToPath as xe}from"url";import*as ee from"yaml";var ke=xe(import.meta.url),Ee=Ie(ke),N=null;function ve(){let e=Ee;for(let n=0;n<5;n++){let t=Z(e,"specs.yaml");if(_e(t))return t;e=Z(e,"..")}throw new Error("Could not find specs.yaml")}function Oe(){if(!N){let e=ve(),n=Ae(e,"utf8");N=ee.parse(n)}return N}function ne(e,n){let o=Oe().commands.find(i=>i.name===e);return o?n&&o.operations?o.operations.find(i=>i.name===n)||null:o:null}var te={success:"\u2714",failure:"\u2716",hint:"\u2192"};function D(){return process.stdout.isTTY===!0}function A(e){let n=ne(e.command,e.operation);if(n)return n.messages}function _(e,n){let t=e;return t=t.replace(/\\n/g,`
|
|
7
|
-
`),n&&(t=t.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let r=n[i];return r!==void 0?String(r):`{{${i}}}`})),t}function oe(e,n){if(!D())return;let t=A(e);t?.onStart&&console.log(_(t.onStart,n))}function ie(e,n){if(!D())return;let t=A(e);t?.onSuccess&&console.log(`${te.success} ${_(t.onSuccess,n)}`)}function R(e,n,t){let o=A(e);o?.onFailure&&console.error(`${te.failure} ${_(o.onFailure,t)}`),n&&console.error(` ${n}`)}function re(e,n){if(!D())return;let t=A(e);t?.onEmpty&&console.log(_(t.onEmpty,n))}function se(e,n){return{command:e,operation:n}}var f=se("objects","list");async function Me(e){oe(f);let n=m(e,["bucket"]),t=m(e,["prefix","p","P"]),o=m(e,["format","f","F"],"table");n||(R(f,"Bucket name is required"),process.exit(1));let i=await Q(),{data:r,error:s}=await Pe({prefix:t||void 0,config:{...i,bucket:n}});if(s&&(R(f,s.message),process.exit(1)),!r.items||r.items.length===0){re(f);return}let a=r.items.map(p=>({key:p.name,size:Ne(p.size),modified:p.lastModified})),c=j(a,o,"objects","object",[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}]);console.log(c),ie(f,{count:a.length})}function Ne(e){if(e===0)return"0 B";let n=["B","KB","MB","GB","TB"],t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,t)).toFixed(t>0?1:0)} ${n[t]}`}export{Me as default};
|
|
1
|
+
import{a as d,b as u,c as s,d as g,g as l}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as m,f as p}from"../../chunk-HGIJOGCZ.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as a}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{list as h}from"@tigrisdata/storage";var t=l("objects","list");async function j(i){d(t);let n=e(i,["bucket"]),k=e(i,["prefix","p","P"]),b=e(i,["format","f","F"],"table");n||(s(t,"Bucket name is required"),process.exit(1));let y=await a(),{data:o,error:c}=await h({prefix:k||void 0,config:{...y,bucket:n}});if(c&&(s(t,c.message),process.exit(1)),!o.items||o.items.length===0){g(t);return}let f=o.items.map(r=>({key:r.name,size:m(r.size),modified:r.lastModified})),x=p(f,b,"objects","object",[{key:"key",header:"Key"},{key:"size",header:"Size"},{key:"modified",header:"Modified"}]);console.log(x),u(t,{count:f.length})}export{j as default};
|
package/dist/lib/objects/put.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import{createReadStream as
|
|
2
|
-
`)}function me(e,t,n){let o=[`<${t}>`];return e.forEach(i=>{o.push(` <${n}>`),o.push(ge(i," ")),o.push(` </${n}>`)}),o.push(`</${t}>`),o.join(`
|
|
3
|
-
`)}function G(e){if(e==null)return"";if(e instanceof Date)return j(e);if(typeof e=="string"){let t=new Date(e);if(!isNaN(t.getTime())&&e.includes("T"))return j(t)}return String(e)}function j(e){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(e)}function he(e,t){return t.map(n=>{if(n.width)return n.width;let o=n.header.length,i=e.reduce((r,s)=>{let a=G(s[n.key]);return Math.max(r,a.length)},0);return Math.max(o,i)})}function Te(e,t){let n=[],o=he(e,t),i="\u250C"+o.map(c=>"\u2500".repeat(c+2)).join("\u252C")+"\u2510",r="\u251C"+o.map(c=>"\u2500".repeat(c+2)).join("\u253C")+"\u2524",s="\u2514"+o.map(c=>"\u2500".repeat(c+2)).join("\u2534")+"\u2518";n.push(`
|
|
4
|
-
`+i);let a="\u2502 "+t.map((c,d)=>c.header.padEnd(o[d])).join(" \u2502 ")+" \u2502";return n.push(a),n.push(r),e.forEach(c=>{let d=t.map((y,C)=>{let l=G(c[y.key]);return y.align==="right"?l.padStart(o[C]):l.padEnd(o[C])});n.push("\u2502 "+d.join(" \u2502 ")+" \u2502")}),n.push(s+`
|
|
5
|
-
`),n.join(`
|
|
6
|
-
`)}function U(e,t,n,o,i){switch(t){case"json":return fe(e);case"xml":return me(e,n,o);default:return Te(e,i)}}import{S3Client as it}from"@aws-sdk/client-s3";import{fromIni as xe}from"@aws-sdk/credential-providers";import{homedir as W}from"os";import{join as h}from"path";import{readFileSync as ye,writeFileSync as Ce,existsSync as w,mkdirSync as Se}from"fs";import{loadSharedConfigFiles as we}from"@smithy/shared-ini-file-loader";import{chmod as Ae}from"fs/promises";var u="https://t3.storage.dev",v="https://iam.storageapi.dev";var O=h(W(),".tigris"),A=h(O,"config.json");function _e(){w(O)||Se(O,{recursive:!0,mode:448})}function p(){if(w(A))try{let e=ye(A,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function _(e){_e(),Ce(A,JSON.stringify(e,null,2),{mode:384});try{await Ae(A,384)}catch{}}async function P(e){let t=p();t.tokens=e,await _(t)}async function T(){return p().tokens||null}async function b(){let e=p();delete e.tokens,await _(e)}async function B(e){let t=p();t.organizations=e,await _(t)}function V(){return p().organizations||[]}function M(){return p().selectedOrganization||null}function Y(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let o=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,i=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!o||!i)return null;let r=process.env.TIGRIS_STORAGE_ENDPOINT||u;return{accessKeyId:o,secretAccessKey:i,endpoint:r}}let e=process.env.AWS_ACCESS_KEY_ID,t=process.env.AWS_SECRET_ACCESS_KEY;if(!e||!t)return null;let n=process.env.AWS_ENDPOINT_URL_S3||u;return{accessKeyId:e,secretAccessKey:t,endpoint:n}}function q(){if(!process.env.AWS_PROFILE)return!1;let e=h(W(),".aws");return w(h(e,"credentials"))||w(h(e,"config"))}async function J(e){try{let{configFile:t}=await we(),n=t[e];return n?{endpoint:n.endpoint_url_s3||n.endpoint_url,iamEndpoint:n.endpoint_url_iam,region:n.region}:{}}catch{return{}}}function N(){let e=p();return e.temporaryCredentials||e.credentials||null}async function H(e){let t=p();t.loginMethod=e,await _(t)}function X(){return p().loginMethod||null}import x from"axios";import Ie from"open";function I(){let e=process.env.TIGRIS_ENV==="development",t=process.env.AUTH0_DOMAIN||e?"auth-dev.tigris.dev":"auth.tigris.dev",n=process.env.AUTH0_CLIENT_ID||e?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",o=process.env.AUTH0_AUDIENCE||e?"https://tigris-api-dev":"https://tigris-os-api";return{domain:t,clientId:n,audience:o}}var Q=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function Z(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||u,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||v}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||u,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||v}}var D=class{config;baseUrl;constructor(){this.config=I(),this.baseUrl=`https://${this.config.domain}`}async login(t){let o=(await x.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;t?.onDeviceCode?.(o.user_code,o.verification_uri),await this.sleep(2e3);try{await Ie(o.verification_uri_complete)}catch{}t?.onWaiting?.();let i=await this.pollForToken(o.device_code,o.interval||5);await P(i),H("oauth"),await this.extractAndStoreOrganizations(i.idToken)}async pollForToken(t,n){let i=0;for(;i<60;){i++;try{let s=(await x.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:a}}catch(r){if(x.isAxiosError(r)&&r.response){let s=r.response.data?.error;if(s==="authorization_pending"){await this.sleep(n*1e3);continue}if(s==="slow_down"){n+=5,await this.sleep(n*1e3);continue}throw new Error(r.response.data?.error_description||"Authentication failed")}throw r}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let t=await T();if(!t)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=t.expiresAt&&(t=await this.refreshAccessToken(t)),t.accessToken}async refreshAccessToken(t){let n=null;if(t?.refreshToken?n=t:n=await T(),!n)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let i=(await x.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:n.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:i.access_token,refreshToken:i.refresh_token||n.refreshToken,idToken:i.id_token||n.idToken,expiresAt:Date.now()+(i.expires_in||3600)*1e3};return await P(r),r}catch{throw await b(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let t=await T();if(!t||!t.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=t.idToken.split(".")[1],o=Buffer.from(n,"base64").toString("utf8");return JSON.parse(o)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(t){if(t)try{let n=t.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),r=JSON.parse(o)[Q];if(!r)return;let s=r?.ns?.map(a=>typeof a=="object"&&a!==null?{id:a.id,name:a.name,displayName:a.name}:{id:a,name:a,displayName:a})||[];if(s.length===0)return;B(s)}catch{}}async getOrganizations(){return await this.getAccessToken(),V()}async logout(){await b()}async isAuthenticated(){return await T()!==null}sleep(t){return new Promise(n=>setTimeout(n,t))}},R=null;function ee(){return R||(R=new D),R}var k=Z(),ke=I();async function Ee(){return X()}async function te(){if(q()){let o=process.env.AWS_PROFILE||"default",i=await J(o),r=await xe({profile:o})();return{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,endpoint:i.endpoint||k.endpoint||u,iamEndpoint:i.iamEndpoint||k.iamEndpoint}}let e=await Ee();if(e==="oauth"){let i=await ee().getAccessToken();if(!M())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:i,accessKeyId:"",secretAccessKey:"",endpoint:k.endpoint,organizationId:M()??void 0,iamEndpoint:k.iamEndpoint,authDomain:ke.domain}}if(e==="credentials"){let o=N();if(o)return{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,endpoint:o.endpoint}}let t=Y();if(t)return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint};let n=N();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}import{put as Fe}from"@tigrisdata/storage";import{readFileSync as ve,existsSync as Oe}from"fs";import{join as ne,dirname as Pe}from"path";import{fileURLToPath as be}from"url";import*as oe from"yaml";var Me=be(import.meta.url),Ne=Pe(Me),K=null;function Re(){let e=Ne;for(let t=0;t<5;t++){let n=ne(e,"specs.yaml");if(Oe(n))return n;e=ne(e,"..")}throw new Error("Could not find specs.yaml")}function De(){if(!K){let e=Re(),t=ve(e,"utf8");K=oe.parse(t)}return K}function ie(e,t){let o=De().commands.find(i=>i.name===e);return o?t&&o.operations?o.operations.find(i=>i.name===t)||null:o:null}var re={success:"\u2714",failure:"\u2716",hint:"\u2192"};function se(){return process.stdout.isTTY===!0}function z(e){let t=ie(e.command,e.operation);if(t)return t.messages}function F(e,t){let n=e;return n=n.replace(/\\n/g,`
|
|
7
|
-
`),t&&(n=n.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let r=t[i];return r!==void 0?String(r):`{{${i}}}`})),n}function ae(e,t){if(!se())return;let n=z(e);n?.onStart&&console.log(F(n.onStart,t))}function ce(e,t){if(!se())return;let n=z(e);n?.onSuccess&&console.log(`${re.success} ${F(n.onSuccess,t)}`)}function m(e,t,n){let o=z(e);o?.onFailure&&console.error(`${re.failure} ${F(o.onFailure,n)}`),t&&console.error(` ${t}`)}function de(e,t){return{command:e,operation:t}}var g=de("objects","put");async function Le(e){ae(g);let t=f(e,["bucket"]),n=f(e,["key"]),o=f(e,["file"]),i=f(e,["access","a","A"],"private"),r=f(e,["content-type","contentType","t","T"]),s=f(e,["format","f","F"],"table");t||(m(g,"Bucket name is required"),process.exit(1)),n||(m(g,"Object key is required"),process.exit(1));let a=!process.stdin.isTTY;!o&&!a&&(m(g,"File path is required (or pipe data via stdin)"),process.exit(1));let c,d;if(o){try{d=ze(o).size}catch{m(g,`File not found: ${o}`),process.exit(1)}let S=Ke(o);c=pe.toWeb(S)}else c=pe.toWeb(process.stdin);let y=await te(),C=!o||d!==void 0&&d>100*1024*1024,{data:l,error:L}=await Fe(n,c,{access:i==="public"?"public":"private",contentType:r,multipart:C,onUploadProgress:({loaded:S,percentage:$})=>{d!==void 0&&d>0?process.stdout.write(`\rUploading: ${E(S)} / ${E(d)} (${$}%)`):process.stdout.write(`\rUploading: ${E(S)}`)},config:{...y,bucket:t}});process.stdout.write("\r"+" ".repeat(60)+"\r"),L&&(m(g,L.message),process.exit(1));let ue=[{path:l.path,size:E(l.size??d??0),contentType:l.contentType||"-",modified:l.modified}],le=U(ue,s,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log(le),ce(g,{key:n,bucket:t})}function E(e){if(e===0)return"0 B";let t=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,n)).toFixed(n>0?1:0)} ${t[n]}`}export{Le as default};
|
|
1
|
+
import{a as b,b as y,c as o,g as S}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n,f as g}from"../../chunk-HGIJOGCZ.js";import{a as t}from"../../chunk-JRALYIRA.js";import{b as l}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createReadStream as F,statSync as O}from"fs";import{Readable as h}from"stream";import{put as q}from"@tigrisdata/storage";var r=S("objects","put");async function v(s){b(r);let p=t(s,["bucket"]),d=t(s,["key"]),i=t(s,["file"]),k=t(s,["access","a","A"],"private"),T=t(s,["content-type","contentType","t","T"]),x=t(s,["format","f","F"],"table");p||(o(r,"Bucket name is required"),process.exit(1)),d||(o(r,"Object key is required"),process.exit(1));let z=!process.stdin.isTTY;!i&&!z&&(o(r,"File path is required (or pipe data via stdin)"),process.exit(1));let f,e;if(i){try{e=O(i).size}catch{o(r,`File not found: ${i}`),process.exit(1)}let c=F(i);f=h.toWeb(c)}else f=h.toWeb(process.stdin);let w=await l(),R=!i||e!==void 0&&e>100*1024*1024,{data:a,error:u}=await q(d,f,{access:k==="public"?"public":"private",contentType:T,multipart:R,onUploadProgress:({loaded:c,percentage:m})=>{e!==void 0&&e>0?process.stdout.write(`\rUploading: ${n(c)} / ${n(e)} (${m}%)`):process.stdout.write(`\rUploading: ${n(c)}`)},config:{...w,bucket:p}});process.stdout.write("\r"+" ".repeat(60)+"\r"),u&&(o(r,u.message),process.exit(1));let j=[{path:a.path,size:n(a.size??e??0),contentType:a.contentType||"-",modified:a.modified}],$=g(j,x,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log($),y(r,{key:d,bucket:p})}export{v as default};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),e&&(t=t.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let r=e[i];return r!==void 0?String(r):`{{${i}}}`})),t}function B(n,e){if(!D())return;let t=S(n);t?.onStart&&console.log(A(t.onStart,e))}function Q(n,e){if(!D())return;let t=S(n);t?.onSuccess&&console.log(`${M.success} ${A(t.onSuccess,e)}`)}function R(n,e,t){let o=S(n);o?.onFailure&&console.error(`${M.failure} ${A(o.onFailure,t)}`),e&&console.error(` ${e}`)}function X(n,e){if(!D())return;let t=S(n);t?.hint&&console.log(`${M.hint} ${A(t.hint,e)}`)}function Z(n,e){return{command:n,operation:e}}var p=Z("organizations","create");async function Te(n){if(B(p),h()!=="oauth"){U()?console.log(`You are using access key credentials, which belong to a single organization.
|
|
1
|
+
import{a as g,b as c,c as o,f as l,g as u}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as e}from"../../chunk-JRALYIRA.js";import{b as s}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{k as r,s as a}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createOrganization as h}from"@tigrisdata/iam";var i=u("organizations","create");async function w(m){if(g(i),a()!=="oauth"){r()?console.log(`You are using access key credentials, which belong to a single organization.
|
|
3
2
|
Organization creation is only available with OAuth login.
|
|
4
3
|
|
|
5
|
-
Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let t=
|
|
4
|
+
Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let t=e(m,["name","N"]);t||(o(i,"Organization name is required"),process.exit(1));let f=await s(),{data:p,error:n}=await h(t,{config:f});n&&(o(i,n.message),process.exit(1));let d=p.id;c(i,{name:t,id:d}),l(i,{name:t})}export{w as default};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}function me(e,n,t){let i=[`<${n}>`];return e.forEach(o=>{i.push(` <${t}>`),i.push(fe(o," ")),i.push(` </${t}>`)}),i.push(`</${n}>`),i.join(`
|
|
3
|
-
`)}function W(e){if(e==null)return"";if(e instanceof Date)return U(e);if(typeof e=="string"){let n=new Date(e);if(!isNaN(n.getTime())&&e.includes("T"))return U(n)}return String(e)}function U(e){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(e)}function he(e,n){return n.map(t=>{if(t.width)return t.width;let i=t.header.length,o=e.reduce((r,s)=>{let a=W(s[t.key]);return Math.max(r,a.length)},0);return Math.max(i,o)})}function ye(e,n){let t=[],i=he(e,n),o="\u250C"+i.map(c=>"\u2500".repeat(c+2)).join("\u252C")+"\u2510",r="\u251C"+i.map(c=>"\u2500".repeat(c+2)).join("\u253C")+"\u2524",s="\u2514"+i.map(c=>"\u2500".repeat(c+2)).join("\u2534")+"\u2518";t.push(`
|
|
4
|
-
`+o);let a="\u2502 "+n.map((c,p)=>c.header.padEnd(i[p])).join(" \u2502 ")+" \u2502";return t.push(a),t.push(r),e.forEach(c=>{let p=n.map((l,k)=>{let O=W(c[l.key]);return l.align==="right"?O.padStart(i[k]):O.padEnd(i[k])});t.push("\u2502 "+p.join(" \u2502 ")+" \u2502")}),t.push(s+`
|
|
5
|
-
`),t.join(`
|
|
6
|
-
`)}function V(e,n,t,i,o){switch(n){case"json":return pe(e);case"xml":return me(e,t,i);default:return ye(e,o)}}import{S3Client as on}from"@aws-sdk/client-s3";import{fromIni as xe}from"@aws-sdk/credential-providers";import{homedir as Y}from"os";import{join as f}from"path";import{readFileSync as Te,writeFileSync as Ce,existsSync as C,mkdirSync as we}from"fs";import{loadSharedConfigFiles as Se}from"@smithy/shared-ini-file-loader";import{chmod as Ae}from"fs/promises";var u="https://t3.storage.dev",v="https://iam.storageapi.dev";var P=f(Y(),".tigris"),w=f(P,"config.json");function _e(){C(P)||we(P,{recursive:!0,mode:448})}function d(){if(C(w))try{let e=Te(w,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function m(e){_e(),Ce(w,JSON.stringify(e,null,2),{mode:384});try{await Ae(w,384)}catch{}}async function N(e){let n=d();n.tokens=e,await m(n)}async function h(){return d().tokens||null}async function M(){let e=d();delete e.tokens,await m(e)}async function J(e){let n=d();n.organizations=e,await m(n)}function q(){return d().organizations||[]}async function B(e){let n=d();n.selectedOrganization=e,await m(n)}function y(){return d().selectedOrganization||null}function D(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let i=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,o=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!i||!o)return null;let r=process.env.TIGRIS_STORAGE_ENDPOINT||u;return{accessKeyId:i,secretAccessKey:o,endpoint:r}}let e=process.env.AWS_ACCESS_KEY_ID,n=process.env.AWS_SECRET_ACCESS_KEY;if(!e||!n)return null;let t=process.env.AWS_ENDPOINT_URL_S3||u;return{accessKeyId:e,secretAccessKey:n,endpoint:t}}function H(){if(!process.env.AWS_PROFILE)return!1;let e=f(Y(),".aws");return C(f(e,"credentials"))||C(f(e,"config"))}async function X(e){try{let{configFile:n}=await Se(),t=n[e];return t?{endpoint:t.endpoint_url_s3||t.endpoint_url,iamEndpoint:t.endpoint_url_iam,region:t.region}:{}}catch{return{}}}function Q(){let e=d();return D()||e.temporaryCredentials||e.credentials||null}function R(){let e=d();return e.temporaryCredentials||e.credentials||null}async function Z(e){let n=d();n.loginMethod=e,await m(n)}function S(){return d().loginMethod||null}import _ from"axios";import Ie from"open";function A(){let e=process.env.TIGRIS_ENV==="development",n=process.env.AUTH0_DOMAIN||e?"auth-dev.tigris.dev":"auth.tigris.dev",t=process.env.AUTH0_CLIENT_ID||e?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",i=process.env.AUTH0_AUDIENCE||e?"https://tigris-api-dev":"https://tigris-os-api";return{domain:n,clientId:t,audience:i}}var ee=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function ne(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||u,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||v}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||u,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||v}}var K=class{config;baseUrl;constructor(){this.config=A(),this.baseUrl=`https://${this.config.domain}`}async login(n){let i=(await _.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;n?.onDeviceCode?.(i.user_code,i.verification_uri),await this.sleep(2e3);try{await Ie(i.verification_uri_complete)}catch{}n?.onWaiting?.();let o=await this.pollForToken(i.device_code,i.interval||5);await N(o),Z("oauth"),await this.extractAndStoreOrganizations(o.idToken)}async pollForToken(n,t){let o=0;for(;o<60;){o++;try{let s=(await _.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:n,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:a}}catch(r){if(_.isAxiosError(r)&&r.response){let s=r.response.data?.error;if(s==="authorization_pending"){await this.sleep(t*1e3);continue}if(s==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(r.response.data?.error_description||"Authentication failed")}throw r}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let n=await h();if(!n)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=n.expiresAt&&(n=await this.refreshAccessToken(n)),n.accessToken}async refreshAccessToken(n){let t=null;if(n?.refreshToken?t=n:t=await h(),!t)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await _.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:o.access_token,refreshToken:o.refresh_token||t.refreshToken,idToken:o.id_token||t.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await N(r),r}catch{throw await M(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let n=await h();if(!n||!n.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let t=n.idToken.split(".")[1],i=Buffer.from(t,"base64").toString("utf8");return JSON.parse(i)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(n){if(n)try{let t=n.split(".")[1],i=Buffer.from(t,"base64").toString("utf8"),r=JSON.parse(i)[ee];if(!r)return;let s=r?.ns?.map(a=>typeof a=="object"&&a!==null?{id:a.id,name:a.name,displayName:a.name}:{id:a,name:a,displayName:a})||[];if(s.length===0)return;J(s)}catch{}}async getOrganizations(){return await this.getAccessToken(),q()}async logout(){await M()}async isAuthenticated(){return await h()!==null}sleep(n){return new Promise(t=>setTimeout(t,n))}},b=null;function te(){return b||(b=new K),b}var I=ne(),Ee=A();async function ke(){return S()}async function ie(){if(H()){let i=process.env.AWS_PROFILE||"default",o=await X(i),r=await xe({profile:i})();return{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,endpoint:o.endpoint||I.endpoint||u,iamEndpoint:o.iamEndpoint||I.iamEndpoint}}let e=await ke();if(e==="oauth"){let o=await te().getAccessToken();if(!y())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:o,accessKeyId:"",secretAccessKey:"",endpoint:I.endpoint,organizationId:y()??void 0,iamEndpoint:I.iamEndpoint,authDomain:Ee.domain}}if(e==="credentials"){let i=R();if(i)return{accessKeyId:i.accessKeyId,secretAccessKey:i.secretAccessKey,endpoint:i.endpoint}}let n=D();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};let t=R();if(t)return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}import ze from"enquirer";import{readFileSync as Oe,existsSync as ve}from"fs";import{join as oe,dirname as Pe}from"path";import{fileURLToPath as Ne}from"url";import*as re from"yaml";var Me=Ne(import.meta.url),De=Pe(Me),z=null;function Re(){let e=De;for(let n=0;n<5;n++){let t=oe(e,"specs.yaml");if(ve(t))return t;e=oe(e,"..")}throw new Error("Could not find specs.yaml")}function be(){if(!z){let e=Re(),n=Oe(e,"utf8");z=re.parse(n)}return z}function se(e,n){let i=be().commands.find(o=>o.name===e);return i?n&&i.operations?i.operations.find(o=>o.name===n)||null:i:null}var ae={success:"\u2714",failure:"\u2716",hint:"\u2192"};function L(){return process.stdout.isTTY===!0}function x(e){let n=se(e.command,e.operation);if(n)return n.messages}function E(e,n){let t=e;return t=t.replace(/\\n/g,`
|
|
7
|
-
`),n&&(t=t.replace(/\{\{(\w+)\}\}/g,(i,o)=>{let r=n[o];return r!==void 0?String(r):`{{${o}}}`})),t}function ce(e,n){if(!L())return;let t=x(e);t?.onStart&&console.log(E(t.onStart,n))}function F(e,n){if(!L())return;let t=x(e);t?.onSuccess&&console.log(`${ae.success} ${E(t.onSuccess,n)}`)}function de(e,n,t){let i=x(e);i?.onFailure&&console.error(`${ae.failure} ${E(i.onFailure,t)}`),n&&console.error(` ${n}`)}function ge(e,n){if(!L())return;let t=x(e);t?.onEmpty&&console.log(E(t.onEmpty,n))}function le(e,n){return{command:e,operation:n}}var T=le("organizations","list");async function Le(e){if(ce(T),S()!=="oauth"){Q()?console.log(`You are using access key credentials, which belong to a single organization.
|
|
1
|
+
import{a as w,b as a,c as y,d as O,g as S}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as z}from"../../chunk-HGIJOGCZ.js";import{a as d}from"../../chunk-JRALYIRA.js";import{b as h}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{f as m,g as u,k as p,s as f}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listOrganizations as b}from"@tigrisdata/iam";import C from"enquirer";var i=S("organizations","list");async function E(k){if(w(i),f()!=="oauth"){p()?console.log(`You are using access key credentials, which belong to a single organization.
|
|
8
2
|
Organization listing and selection is only available with OAuth login.
|
|
9
3
|
|
|
10
|
-
Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let
|
|
4
|
+
Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let s=d(k,["format","f","F"],"select"),x=await h(),{data:I,error:r}=await b({config:x});r&&(y(i,r.message),process.exit(1));let e=I?.organizations??[];if(e.length===0){O(i);return}let o=u();if(s==="select"){let n=e.map(t=>({name:t.id,message:`${t.name} (${t.id})`,hint:t.id===o?"currently selected":void 0})),g=(await C.prompt({type:"select",name:"organization",message:"Select an organization:",choices:n.map(t=>t.message),initial:o?e.findIndex(t=>t.id===o):0})).organization.match(/\(([^)]+)\)$/),l=g?g[1]:e[0].id;await m(l);let $=e.find(t=>t.id===l);a(i,{name:$?.name});return}let c=e.map(n=>({id:n.id,name:n.name,slug:n.slug,selected:n.id===o?"*":""})),M=z(c,s,"organizations","organization",[{key:"selected",header:" ",width:1},{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"slug",header:"Slug"}]);console.log(M),a(i,{count:c.length})}export{E as default};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),e&&(t=t.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let s=e[i];return s!==void 0?String(s):`{{${i}}}`})),t}function Z(n,e){if(!X())return;let t=M(n);t?.onStart&&console.log(D(t.onStart,e))}function ee(n,e){if(!X())return;let t=M(n);t?.onSuccess&&console.log(`${Q.success} ${D(t.onSuccess,e)}`)}function A(n,e,t){let o=M(n);o?.onFailure&&console.error(`${Q.failure} ${D(o.onFailure,t)}`),e&&console.error(` ${e}`)}function ne(n,e){return{command:n,operation:e}}var f=ne("organizations","select");async function Ae(n){if(Z(f),C()!=="oauth"){$()?console.log(`You are using access key credentials, which belong to a single organization.
|
|
1
|
+
import{a as d,b as f,c as t,g as p}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as g}from"../../chunk-JRALYIRA.js";import{b as u}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import{f as c,k as l,s as m}from"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listOrganizations as O}from"@tigrisdata/iam";var i=p("organizations","select");async function x(h){if(d(i),m()!=="oauth"){l()?console.log(`You are using access key credentials, which belong to a single organization.
|
|
3
2
|
Organization selection is only available with OAuth login.
|
|
4
3
|
|
|
5
|
-
Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let
|
|
6
|
-
`);
|
|
4
|
+
Run "tigris login" to login with your Tigris account.`):console.log('Not authenticated. Please run "tigris login" to login with your Tigris account.');return}let n=g(h,["name","N"]);n||(t(i,"Organization name or ID is required"),process.exit(1));let z=await u(),{data:w,error:a}=await O({config:z});a&&(t(i,a.message),process.exit(1));let r=w?.organizations??[],e=r.find(o=>o.id===n||o.name===n);if(!e){let o=r.map(s=>` - ${s.name} (${s.id})`).join(`
|
|
5
|
+
`);t(i,`Organization "${n}" not found
|
|
7
6
|
|
|
8
7
|
Available organizations:
|
|
9
|
-
${
|
|
8
|
+
${o}`),process.exit(1)}await c(e.id),f(i,{name:e.name})}export{x as default};
|
package/dist/lib/rm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{a as g}from"../chunk-JRALYIRA.js";import{b as j}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{a as P,b as A,d as F,g as I,h as S,i as W}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import*as E from"readline";import{remove as w,removeBucket as T,list as q}from"@tigrisdata/storage";async function $(l){let s=E.createInterface({input:process.stdin,output:process.stdout});return new Promise(m=>{s.question(`${l} (y/N): `,d=>{s.close(),m(d.toLowerCase()==="y")})})}async function C(l){let s=g(l,["path"]),m=g(l,["force","f","F"]),d=!!g(l,["recursive","r"]);s||(console.error("path argument is required"),process.exit(1)),P(s)||(console.error("Path must be a remote Tigris path (t3:// or tigris://)"),process.exit(1));let{bucket:e,path:o}=A(s);e||(console.error("Invalid path"),process.exit(1));let i=await j(),b=s.endsWith("/");if(!o&&!b){if(!m&&!await $(`Are you sure you want to delete bucket '${e}'?`)){console.log("Aborted");return}let{error:t}=await T(e,{config:i});t&&(console.error(t.message),process.exit(1)),console.log(`Removed bucket '${e}'`);return}let n=o.includes("*"),u=o.endsWith("/")||!o&&b;if(!n&&!u&&(u=await F(e,o,i)),u&&!n&&!d&&(console.error("Source is a remote folder (not removed). Use -r to remove recursively."),process.exit(1)),n||u){let t=n?S(o):o?o.endsWith("/")?o:`${o}/`:"",{items:p,error:x}=await W(e,t||void 0,i);x&&(console.error(x.message),process.exit(1));let f=p;if(n){let r=o.split("/").pop(),a=I(r);f=f.filter(R=>{let k=t?R.name.slice(t.length):R.name;return!d&&k.includes("/")?!1:a.test(k.split("/").pop())})}let c=t,M=f.some(r=>r.name===c),v=!1;if(!M&&!n){let{data:r}=await q({prefix:c,limit:1,config:{...i,bucket:e}});v=r?.items?.some(a=>a.name===c)||!1}let y=f.length+(v?1:0);if(y===0){console.log("No objects to remove");return}if(!m&&!await $(`Are you sure you want to delete ${y} object(s)?`)){console.log("Aborted");return}let h=0;for(let r of f){let{error:a}=await w(r.name,{config:{...i,bucket:e}});a?console.error(`Failed to remove ${r.name}: ${a.message}`):(console.log(`Removed t3://${e}/${r.name}`),h++)}if(v){let{error:r}=await w(c,{config:{...i,bucket:e}});r?console.error(`Failed to remove ${c}: ${r.message}`):(console.log(`Removed t3://${e}/${c}`),h++)}console.log(`Removed ${h} object(s)`)}else{if(!m&&!await $(`Are you sure you want to delete 't3://${e}/${o}'?`)){console.log("Aborted");return}let{error:t}=await w(o,{config:{...i,bucket:e}});t&&(console.error(t.message),process.exit(1)),console.log(`Removed t3://${e}/${o}`)}process.exit(0)}export{C as default};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`)}function de(e,n,t){let o=[`<${n}>`];return e.forEach(i=>{o.push(` <${t}>`),o.push(ce(i," ")),o.push(` </${t}>`)}),o.push(`</${n}>`),o.join(`
|
|
3
|
-
`)}function F(e){if(e==null)return"";if(e instanceof Date)return z(e);if(typeof e=="string"){let n=new Date(e);if(!isNaN(n.getTime())&&e.includes("T"))return z(n)}return String(e)}function z(e){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(e)}function pe(e,n){return n.map(t=>{if(t.width)return t.width;let o=t.header.length,i=e.reduce((r,s)=>{let a=F(s[t.key]);return Math.max(r,a.length)},0);return Math.max(o,i)})}function ue(e,n){let t=[],o=pe(e,n),i="\u250C"+o.map(c=>"\u2500".repeat(c+2)).join("\u252C")+"\u2510",r="\u251C"+o.map(c=>"\u2500".repeat(c+2)).join("\u253C")+"\u2524",s="\u2514"+o.map(c=>"\u2500".repeat(c+2)).join("\u2534")+"\u2518";t.push(`
|
|
4
|
-
`+i);let a="\u2502 "+n.map((c,A)=>c.header.padEnd(o[A])).join(" \u2502 ")+" \u2502";return t.push(a),t.push(r),e.forEach(c=>{let A=n.map((K,b)=>{let L=F(c[K.key]);return K.align==="right"?L.padStart(o[b]):L.padEnd(o[b])});t.push("\u2502 "+A.join(" \u2502 ")+" \u2502")}),t.push(s+`
|
|
5
|
-
`),t.join(`
|
|
6
|
-
`)}function G(e,n,t,o,i){switch(n){case"json":return ae(e);case"xml":return de(e,t,o);default:return ue(e,i)}}import{S3Client as He}from"@aws-sdk/client-s3";import{fromIni as ye}from"@aws-sdk/credential-providers";import{homedir as j}from"os";import{join as u}from"path";import{readFileSync as ge,writeFileSync as le,existsSync as f,mkdirSync as fe}from"fs";import{loadSharedConfigFiles as me}from"@smithy/shared-ini-file-loader";import{chmod as he}from"fs/promises";var p="https://t3.storage.dev",I="https://iam.storageapi.dev";var x=u(j(),".tigris"),m=u(x,"config.json");function Te(){f(x)||fe(x,{recursive:!0,mode:448})}function d(){if(f(m))try{let e=ge(m,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function h(e){Te(),le(m,JSON.stringify(e,null,2),{mode:384});try{await he(m,384)}catch{}}async function E(e){let n=d();n.tokens=e,await h(n)}async function g(){return d().tokens||null}async function k(){let e=d();delete e.tokens,await h(e)}async function $(e){let n=d();n.organizations=e,await h(n)}function U(){return d().organizations||[]}function v(){return d().selectedOrganization||null}function W(){if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID||process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let o=process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,i=process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY;if(!o||!i)return null;let r=process.env.TIGRIS_STORAGE_ENDPOINT||p;return{accessKeyId:o,secretAccessKey:i,endpoint:r}}let e=process.env.AWS_ACCESS_KEY_ID,n=process.env.AWS_SECRET_ACCESS_KEY;if(!e||!n)return null;let t=process.env.AWS_ENDPOINT_URL_S3||p;return{accessKeyId:e,secretAccessKey:n,endpoint:t}}function V(){if(!process.env.AWS_PROFILE)return!1;let e=u(j(),".aws");return f(u(e,"credentials"))||f(u(e,"config"))}async function Y(e){try{let{configFile:n}=await me(),t=n[e];return t?{endpoint:t.endpoint_url_s3||t.endpoint_url,iamEndpoint:t.endpoint_url_iam,region:t.region}:{}}catch{return{}}}function O(){let e=d();return e.temporaryCredentials||e.credentials||null}async function B(e){let n=d();n.loginMethod=e,await h(n)}function J(){return d().loginMethod||null}import C from"axios";import Ce from"open";function T(){let e=process.env.TIGRIS_ENV==="development",n=process.env.AUTH0_DOMAIN||e?"auth-dev.tigris.dev":"auth.tigris.dev",t=process.env.AUTH0_CLIENT_ID||e?"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",o=process.env.AUTH0_AUDIENCE||e?"https://tigris-api-dev":"https://tigris-os-api";return{domain:n,clientId:t,audience:o}}var q=process.env.TIGRIS_CLAIMS_NAMESPACE||"https://tigris";function H(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||p,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||I}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||p,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||I}}var N=class{config;baseUrl;constructor(){this.config=T(),this.baseUrl=`https://${this.config.domain}`}async login(n){let o=(await C.post(`${this.baseUrl}/oauth/device/code`,{client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data;n?.onDeviceCode?.(o.user_code,o.verification_uri),await this.sleep(2e3);try{await Ce(o.verification_uri_complete)}catch{}n?.onWaiting?.();let i=await this.pollForToken(o.device_code,o.interval||5);await E(i),B("oauth"),await this.extractAndStoreOrganizations(i.idToken)}async pollForToken(n,t){let i=0;for(;i<60;){i++;try{let s=(await C.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:n,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:a}}catch(r){if(C.isAxiosError(r)&&r.response){let s=r.response.data?.error;if(s==="authorization_pending"){await this.sleep(t*1e3);continue}if(s==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(r.response.data?.error_description||"Authentication failed")}throw r}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let n=await g();if(!n)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=n.expiresAt&&(n=await this.refreshAccessToken(n)),n.accessToken}async refreshAccessToken(n){let t=null;if(n?.refreshToken?t=n:t=await g(),!t)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let i=(await C.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken,scope:"openid profile email offline_access"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:i.access_token,refreshToken:i.refresh_token||t.refreshToken,idToken:i.id_token||t.idToken,expiresAt:Date.now()+(i.expires_in||3600)*1e3};return await E(r),r}catch{throw await k(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let n=await g();if(!n||!n.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let t=n.idToken.split(".")[1],o=Buffer.from(t,"base64").toString("utf8");return JSON.parse(o)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(n){if(n)try{let t=n.split(".")[1],o=Buffer.from(t,"base64").toString("utf8"),r=JSON.parse(o)[q];if(!r)return;let s=r?.ns?.map(a=>typeof a=="object"&&a!==null?{id:a.id,name:a.name,displayName:a.name}:{id:a,name:a,displayName:a})||[];if(s.length===0)return;$(s)}catch{}}async getOrganizations(){return await this.getAccessToken(),U()}async logout(){await k()}async isAuthenticated(){return await g()!==null}sleep(n){return new Promise(t=>setTimeout(t,n))}},P=null;function X(){return P||(P=new N),P}var y=H(),Se=T();async function we(){return J()}async function Q(){if(V()){let o=process.env.AWS_PROFILE||"default",i=await Y(o),r=await ye({profile:o})();return{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,endpoint:i.endpoint||y.endpoint||p,iamEndpoint:i.iamEndpoint||y.iamEndpoint}}let e=await we();if(e==="oauth"){let i=await X().getAccessToken();if(!v())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:i,accessKeyId:"",secretAccessKey:"",endpoint:y.endpoint,organizationId:v()??void 0,iamEndpoint:y.iamEndpoint,authDomain:Se.domain}}if(e==="credentials"){let o=O();if(o)return{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,endpoint:o.endpoint}}let n=W();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};let t=O();if(t)return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,endpoint:t.endpoint};throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}import{listBucketSnapshots as Pe}from"@tigrisdata/storage";import{readFileSync as Ae,existsSync as _e}from"fs";import{join as Z,dirname as Ie}from"path";import{fileURLToPath as xe}from"url";import*as ee from"yaml";var Ee=xe(import.meta.url),ke=Ie(Ee),D=null;function ve(){let e=ke;for(let n=0;n<5;n++){let t=Z(e,"specs.yaml");if(_e(t))return t;e=Z(e,"..")}throw new Error("Could not find specs.yaml")}function Oe(){if(!D){let e=ve(),n=Ae(e,"utf8");D=ee.parse(n)}return D}function ne(e,n){let o=Oe().commands.find(i=>i.name===e);return o?n&&o.operations?o.operations.find(i=>i.name===n)||null:o:null}var te={success:"\u2714",failure:"\u2716",hint:"\u2192"};function M(){return process.stdout.isTTY===!0}function S(e){let n=ne(e.command,e.operation);if(n)return n.messages}function w(e,n){let t=e;return t=t.replace(/\\n/g,`
|
|
7
|
-
`),n&&(t=t.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let r=n[i];return r!==void 0?String(r):`{{${i}}}`})),t}function oe(e,n){if(!M())return;let t=S(e);t?.onStart&&console.log(w(t.onStart,n))}function ie(e,n){if(!M())return;let t=S(e);t?.onSuccess&&console.log(`${te.success} ${w(t.onSuccess,n)}`)}function R(e,n,t){let o=S(e);o?.onFailure&&console.error(`${te.failure} ${w(o.onFailure,t)}`),n&&console.error(` ${n}`)}function re(e,n){if(!M())return;let t=S(e);t?.onEmpty&&console.log(w(t.onEmpty,n))}function se(e,n){return{command:e,operation:n}}var l=se("snapshots","list");async function Ne(e){oe(l);let n=_(e,["name"]),t=_(e,["format","f","F"],"table");n||(R(l,"Bucket name is required"),process.exit(1));let o=await Q(),{data:i,error:r}=await Pe(n,{config:o});if(r&&(R(l,r.message),process.exit(1)),!i||i.length===0){re(l);return}let s=i.map(c=>({name:c.name||"",version:c.version||"",created:c.creationDate})),a=G(s,t,"snapshots","snapshot",[{key:"name",header:"Name"},{key:"version",header:"Version"},{key:"created",header:"Created"}]);console.log(a),ie(l,{count:s.length})}export{Ne as default};
|
|
1
|
+
import{a as f,b as u,c as n,d as g,g as d}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{f as p}from"../../chunk-HGIJOGCZ.js";import{a as o}from"../../chunk-JRALYIRA.js";import{b as c}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{listBucketSnapshots as y}from"@tigrisdata/storage";var t=d("snapshots","list");async function x(s){f(t);let a=o(s,["name"]),l=o(s,["format","f","F"],"table");a||(n(t,"Bucket name is required"),process.exit(1));let h=await c(),{data:e,error:i}=await y(a,{config:h});if(i&&(n(t,i.message),process.exit(1)),!e||e.length===0){g(t);return}let m=e.map(r=>({name:r.name||"",version:r.version||"",created:r.creationDate})),k=p(m,l,"snapshots","snapshot",[{key:"name",header:"Name"},{key:"version",header:"Version"},{key:"created",header:"Created"}]);console.log(k),u(t,{count:m.length})}export{x as default};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`),e&&(t=t.replace(/\{\{(\w+)\}\}/g,(o,i)=>{let s=e[i];return s!==void 0?String(s):`{{${i}}}`})),t}function B(n,e){if(!H())return;let t=O(n);t?.onStart&&console.log(P(t.onStart,e))}function J(n,e){if(!H())return;let t=O(n);t?.onSuccess&&console.log(`${q.success} ${P(t.onSuccess,e)}`)}function N(n,e,t){let o=O(n);o?.onFailure&&console.error(`${q.failure} ${P(o.onFailure,t)}`),e&&console.error(` ${e}`)}function Q(n,e){return{command:n,operation:e}}var y=Q("snapshots","take");async function Ce(n){B(y);let e=T(n,["name"]),t=T(n,["snapshot-name","snapshotName"]);e||(N(y,"Bucket name is required"),process.exit(1));let o=await V(),{data:i,error:s}=await he(e,{name:t,config:o});s&&(N(y,s.message),process.exit(1)),J(y,{name:e,snapshotName:t||i?.snapshotVersion,version:i?.snapshotVersion})}export{Ce as default};
|
|
1
|
+
import{a as p,b as c,c as e,g as f}from"../../chunk-A3TXP5Y2.js";import"../../chunk-4LGKN5DA.js";import{a as n}from"../../chunk-JRALYIRA.js";import{b as m}from"../../chunk-ESJWTUFN.js";import"../../chunk-QZXBLNMQ.js";import"../../chunk-6U4U4JM6.js";import"../../chunk-JVB3Y42V.js";import"../../chunk-D63SZLT5.js";import{createBucketSnapshot as h}from"@tigrisdata/storage";var t=f("snapshots","take");async function u(o){p(t);let s=n(o,["name"]),a=n(o,["snapshot-name","snapshotName"]);s||(e(t,"Bucket name is required"),process.exit(1));let g=await m(),{data:r,error:i}=await h(s,{name:a,config:g});i&&(e(t,i.message),process.exit(1)),c(t,{name:s,snapshotName:a||r?.snapshotVersion,version:r?.snapshotVersion})}export{u as default};
|
package/dist/lib/touch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as i}from"../chunk-JRALYIRA.js";import{b as n}from"../chunk-ESJWTUFN.js";import"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{f as s}from"../chunk-LCWHZUZZ.js";import"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{put as p}from"@tigrisdata/storage";async function f(c){let r=i(c,["path"]);r||(console.error("path argument is required"),process.exit(1));let{bucket:o,path:e}=s(r);o||(console.error("Invalid path"),process.exit(1)),e||(console.error("Object key is required (use mk to create buckets)"),process.exit(1));let a=await n(),{error:t}=await p(e,"",{config:{...a,bucket:o}});t&&(console.error(t.message),process.exit(1)),console.log(`Created '${o}/${e}'`),process.exit(0)}export{f as default};
|
package/dist/lib/whoami.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)
|
|
3
|
-
`))}catch(n){n instanceof Error?I(f,n.message):I(f),process.exit(1)}}export{Se as default};
|
|
1
|
+
import{c,e as h,g as $}from"../chunk-A3TXP5Y2.js";import"../chunk-4LGKN5DA.js";import{b as O}from"../chunk-ESJWTUFN.js";import{b as z}from"../chunk-QZXBLNMQ.js";import"../chunk-6U4U4JM6.js";import{g as f,k as p,s as A}from"../chunk-JVB3Y42V.js";import"../chunk-D63SZLT5.js";import{listOrganizations as C}from"@tigrisdata/iam";var s=$("whoami");async function y(){try{let i=A(),d=p(),l,u;if(i==="oauth"){let n=z();if(!await n.isAuthenticated()){h(s);return}let a=await n.getIdTokenClaims();l=a.email,u=a.sub}else if(d)l=void 0,u=d.accessKeyId;else{h(s);return}let e=[];if(e.push(""),e.push("User Information:"),e.push(` Email: ${l||"N/A"}`),e.push(` User ID: ${u||"N/A"}`),i==="oauth"){let n=await O(),o=f(),{data:a,error:g}=await C({config:n});g&&(c(s,g.message),process.exit(1));let r=a?.organizations??[];if(r.length>0){if(e.push(""),e.push(`Organizations (${r.length}):`),r.forEach(t=>{let w=t.id===o?">":" ";e.push(` ${w} ${t.name} (${t.id})`)}),o){let t=r.find(m=>m.id===o);t&&(e.push(""),e.push(`Active: ${t.name}`))}}else e.push(""),e.push("Organizations: None")}else e.push(""),e.push("Login method: Access Key Credentials"),e.push(" (Organization listing requires OAuth login: tigris login)");e.push(""),console.log(e.join(`
|
|
2
|
+
`))}catch(i){i instanceof Error?c(s,i.message):c(s),process.exit(1)}}export{y as default};
|