@tigrisdata/cli 2.5.0 → 2.6.1
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/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-4BZ377KV.js +1 -0
- package/dist/chunk-4LGKN5DA.js +1 -0
- package/dist/chunk-A3TXP5Y2.js +2 -0
- package/dist/chunk-DYTBLGO7.js +1 -0
- package/dist/chunk-HGIJOGCZ.js +6 -0
- package/dist/chunk-I3FOSZPG.js +1 -0
- package/dist/chunk-IACJQZUD.js +4 -0
- package/dist/chunk-IY46B353.js +12 -0
- package/dist/chunk-JRALYIRA.js +1 -0
- package/dist/chunk-NYAHHQ3A.js +1 -0
- package/dist/chunk-PKWQDQLT.js +1 -0
- package/dist/chunk-TQWT7ROJ.js +1 -0
- package/dist/chunk-WE6NZ2ZK.js +1 -0
- package/dist/cli.js +1 -12
- package/dist/constants.js +1 -1
- package/dist/index.js +1 -12
- 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 +0 -1
- 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/package.json +4 -3
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{b as a}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as m,f as p}from"../../chunk-HGIJOGCZ.js";import{a as e}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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{
|
|
2
|
-
`)}function ce(e,n,t){let o=[`<${n}>`];return e.forEach(i=>{o.push(` <${t}>`),o.push(ae(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 de(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=de(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((m,y)=>{let C=F(c[m.key]);return m.align==="right"?C.padStart(o[y]):C.padEnd(o[y])});t.push("\u2502 "+p.join(" \u2502 ")+" \u2502")}),t.push(s+`
|
|
5
|
-
`),t.join(`
|
|
6
|
-
`)}function L(e,n,t,o,i){switch(n){case"json":return se(e);case"xml":return ce(e,t,o);default:return pe(e,i)}}import{S3Client as Qe}from"@aws-sdk/client-s3";import{fromIni as ye}from"@aws-sdk/credential-providers";import{homedir as j}from"os";import{join as h}from"path";import{readFileSync as ue,writeFileSync as ge,existsSync as S,mkdirSync as le}from"fs";import{loadSharedConfigFiles as fe}from"@smithy/shared-ini-file-loader";import{chmod as me}from"fs/promises";var u="https://t3.storage.dev",k="https://iam.storageapi.dev";var E=h(j(),".tigris"),w=h(E,"config.json");function he(){S(E)||le(E,{recursive:!0,mode:448})}function d(){if(S(w))try{let e=ue(w,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function A(e){he(),ge(w,JSON.stringify(e,null,2),{mode:384});try{await me(w,384)}catch{}}async function v(e){let n=d();n.tokens=e,await A(n)}async function T(){return d().tokens||null}async function O(){let e=d();delete e.tokens,await A(e)}async function G(e){let n=d();n.organizations=e,await A(n)}function $(){return d().organizations||[]}function P(){return d().selectedOrganization||null}function U(){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 B(){if(!process.env.AWS_PROFILE)return!1;let e=h(j(),".aws");return S(h(e,"credentials"))||S(h(e,"config"))}async function W(e){try{let{configFile:n}=await fe(),t=n[e];return t?{endpoint:t.endpoint_url_s3||t.endpoint_url,iamEndpoint:t.endpoint_url_iam,region:t.region}:{}}catch{return{}}}function M(){let e=d();return e.temporaryCredentials||e.credentials||null}async function V(e){let n=d();n.loginMethod=e,await A(n)}function Y(){return d().loginMethod||null}import I from"axios";import Te from"open";function _(){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 J(){return process.env.TIGRIS_STORAGE_ENDPOINT||process.env.TIGRIS_IAM_ENDPOINT?{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||u,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||k}:{endpoint:process.env.AWS_ENDPOINT_URL_S3||u,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||k}}var b=class{config;baseUrl;constructor(){this.config=_(),this.baseUrl=`https://${this.config.domain}`}async login(n){let o=(await I.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 Te(o.verification_uri_complete)}catch{}n?.onWaiting?.();let i=await this.pollForToken(o.device_code,o.interval||5);await v(i),V("oauth"),await this.extractAndStoreOrganizations(i.idToken)}async pollForToken(n,t){let i=0;for(;i<60;){i++;try{let s=(await I.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(I.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 T();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 T(),!t)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let i=(await I.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 v(r),r}catch{throw await O(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let n=await T();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;G(s)}catch{}}async getOrganizations(){return await this.getAccessToken(),$()}async logout(){await O()}async isAuthenticated(){return await T()!==null}sleep(n){return new Promise(t=>setTimeout(t,n))}},N=null;function H(){return N||(N=new b),N}var x=J(),Ce=_();async function Se(){return Y()}async function X(){if(B()){let o=process.env.AWS_PROFILE||"default",i=await W(o),r=await ye({profile:o})();return{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,endpoint:i.endpoint||x.endpoint||u,iamEndpoint:i.iamEndpoint||x.iamEndpoint}}let e=await Se();if(e==="oauth"){let i=await H().getAccessToken();if(!P())throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:i,accessKeyId:"",secretAccessKey:"",endpoint:x.endpoint,organizationId:P()??void 0,iamEndpoint:x.iamEndpoint,authDomain:Ce.domain}}if(e==="credentials"){let o=M();if(o)return{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey,endpoint:o.endpoint}}let n=U();if(n)return{accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey,endpoint:n.endpoint};let t=M();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{put as Me}from"@tigrisdata/storage";import{readFileSync as we,existsSync as Ae}from"fs";import{join as Q,dirname as _e}from"path";import{fileURLToPath as Ie}from"url";import*as Z from"yaml";var xe=Ie(import.meta.url),ke=_e(xe),D=null;function Ee(){let e=ke;for(let n=0;n<5;n++){let t=Q(e,"specs.yaml");if(Ae(t))return t;e=Q(e,"..")}throw new Error("Could not find specs.yaml")}function ve(){if(!D){let e=Ee(),n=we(e,"utf8");D=Z.parse(n)}return D}function ee(e,n){let o=ve().commands.find(i=>i.name===e);return o?n&&o.operations?o.operations.find(i=>i.name===n)||null:o:null}var ne={success:"\u2714",failure:"\u2716",hint:"\u2192"};function te(){return process.stdout.isTTY===!0}function R(e){let n=ee(e.command,e.operation);if(n)return n.messages}function K(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(!te())return;let t=R(e);t?.onStart&&console.log(K(t.onStart,n))}function ie(e,n){if(!te())return;let t=R(e);t?.onSuccess&&console.log(`${ne.success} ${K(t.onSuccess,n)}`)}function f(e,n,t){let o=R(e);o?.onFailure&&console.error(`${ne.failure} ${K(o.onFailure,t)}`),n&&console.error(` ${n}`)}function re(e,n){return{command:e,operation:n}}var l=re("objects","put");async function Ne(e){oe(l);let n=g(e,["bucket"]),t=g(e,["key"]),o=g(e,["file"]),i=g(e,["access","a","A"],"private"),r=g(e,["content-type","contentType","t","T"]),s=g(e,["format","f","F"],"table");n||(f(l,"Bucket name is required"),process.exit(1)),t||(f(l,"Object key is required"),process.exit(1)),o||(f(l,"File path is required"),process.exit(1));try{Pe(o)}catch{f(l,`File not found: ${o}`),process.exit(1)}let a=await X(),c=Oe(o),{data:p,error:m}=await Me(t,c,{access:i==="public"?"public":"private",contentType:r,config:{...a,bucket:n}});m&&(f(l,m.message),process.exit(1));let y=[{path:p.path,size:be(p.size),contentType:p.contentType||"-",modified:p.modified}],C=L(y,s,"objects","object",[{key:"path",header:"Path"},{key:"size",header:"Size"},{key:"contentType",header:"Content-Type"},{key:"modified",header:"Modified"}]);console.log(C),ie(l,{key:t,bucket:n})}function be(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{Ne 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{b as l}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as n,f as g}from"../../chunk-HGIJOGCZ.js";import{a as t}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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{b as s}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as e}from"../../chunk-JRALYIRA.js";import{k as r,s as a}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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{b as h}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as z}from"../../chunk-HGIJOGCZ.js";import{a as d}from"../../chunk-JRALYIRA.js";import{f as m,g as u,k as p,s as f}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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{b as u}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as g}from"../../chunk-JRALYIRA.js";import{f as c,k as l,s as m}from"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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 y,b as k,d as x}from"../chunk-I3FOSZPG.js";import{b as A}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as $}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import*as F from"readline";import{remove as w,removeBucket as I,list as P}from"@tigrisdata/storage";async function v(a){let n=F.createInterface({input:process.stdin,output:process.stdout});return new Promise(c=>{n.question(`${a} (y/N): `,e=>{n.close(),c(e.toLowerCase()==="y")})})}async function j(a){let n=$(a,["path"]),c=$(a,["force","f","F"]);n||(console.error("path argument is required"),process.exit(1));let{bucket:e,path:r}=y(n);e||(console.error("Invalid path"),process.exit(1));let s=await A();if(!r){if(!c&&!await v(`Are you sure you want to delete bucket '${e}'?`)){console.log("Aborted");return}let{error:t}=await I(e,{config:s});t&&(console.error(t.message),process.exit(1)),console.log(`Removed bucket '${e}'`);return}let m=n.includes("*"),f=r.endsWith("/");if(!m&&!f&&(f=await k(e,r,s)),m||f){let t=m?r.replace("*",""):r.endsWith("/")?r:`${r}/`,{items:d,error:h}=await x(e,t||void 0,s);h&&(console.error(h.message),process.exit(1));let u=d,i=t,R=u.some(o=>o.name===i),g=!1;if(!R){let{data:o}=await P({prefix:i,limit:1,config:{...s,bucket:e}});g=o?.items?.some(l=>l.name===i)||!1}let b=u.length+(g?1:0);if(b===0){console.log("No objects to remove");return}if(!c&&!await v(`Are you sure you want to delete ${b} object(s)?`)){console.log("Aborted");return}let p=0;for(let o of u){let{error:l}=await w(o.name,{config:{...s,bucket:e}});l?console.error(`Failed to remove ${o.name}: ${l.message}`):(console.log(`Removed ${e}/${o.name}`),p++)}if(g){let{error:o}=await w(i,{config:{...s,bucket:e}});o?console.error(`Failed to remove ${i}: ${o.message}`):(console.log(`Removed ${e}/${i}`),p++)}console.log(`Removed ${p} object(s)`)}else{if(!c&&!await v(`Are you sure you want to delete '${e}/${r}'?`)){console.log("Aborted");return}let{error:t}=await w(r,{config:{...s,bucket:e}});t&&(console.error(t.message),process.exit(1)),console.log(`Removed ${e}/${r}`)}process.exit(0)}export{j 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{b as c}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{f as p}from"../../chunk-HGIJOGCZ.js";import{a as o}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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{b as m}from"../../chunk-TQWT7ROJ.js";import"../../chunk-WE6NZ2ZK.js";import"../../chunk-NYAHHQ3A.js";import{a as n}from"../../chunk-JRALYIRA.js";import"../../chunk-PKWQDQLT.js";import"../../chunk-4BZ377KV.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 s}from"../chunk-I3FOSZPG.js";import{b as c}from"../chunk-TQWT7ROJ.js";import"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{a as i}from"../chunk-JRALYIRA.js";import"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.js";import{put as p}from"@tigrisdata/storage";async function f(n){let r=i(n,["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 c(),{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-TQWT7ROJ.js";import{b as z}from"../chunk-WE6NZ2ZK.js";import"../chunk-NYAHHQ3A.js";import{g as f,k as p,s as A}from"../chunk-PKWQDQLT.js";import"../chunk-4BZ377KV.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};
|
package/dist/specs.yaml
CHANGED
package/dist/utils/format.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
`)}function T(n,e,t){let r=[`<${e}>`];return n.forEach(o=>{r.push(` <${t}>`),r.push(l(o," ")),r.push(` </${t}>`)}),r.push(`</${e}>`),r.join(`
|
|
3
|
-
`)}function p(n){if(n==null)return"";if(n instanceof Date)return f(n);if(typeof n=="string"){let e=new Date(n);if(!isNaN(e.getTime())&&n.includes("T"))return f(e)}return String(n)}function f(n){return new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(n)}function w(n,e){return e.map(t=>{if(t.width)return t.width;let r=t.header.length,o=n.reduce((s,u)=>{let a=p(u[t.key]);return Math.max(s,a.length)},0);return Math.max(r,o)})}function x(n,e){let t=[],r=w(n,e),o="\u250C"+r.map(i=>"\u2500".repeat(i+2)).join("\u252C")+"\u2510",s="\u251C"+r.map(i=>"\u2500".repeat(i+2)).join("\u253C")+"\u2524",u="\u2514"+r.map(i=>"\u2500".repeat(i+2)).join("\u2534")+"\u2518";t.push(`
|
|
4
|
-
`+o);let a="\u2502 "+e.map((i,d)=>i.header.padEnd(r[d])).join(" \u2502 ")+" \u2502";return t.push(a),t.push(s),n.forEach(i=>{let d=e.map((c,g)=>{let h=p(i[c.key]);return c.align==="right"?h.padStart(r[g]):h.padEnd(r[g])});t.push("\u2502 "+d.join(" \u2502 ")+" \u2502")}),t.push(u+`
|
|
5
|
-
`),t.join(`
|
|
6
|
-
`)}function j(n,e,t,r,o){switch(e){case"json":return m(n);case"xml":return T(n,t,r);default:return x(n,o)}}export{m as formatJson,j as formatOutput,x as formatTable,T as formatXml,l as formatXmlObject};
|
|
1
|
+
import{a,b,c,d,e,f}from"../chunk-HGIJOGCZ.js";export{b as formatJson,f as formatOutput,a as formatSize,e as formatTable,d as formatXml,c as formatXmlObject};
|
package/dist/utils/messages.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`),e&&(s=s.replace(/\{\{(\w+)\}\}/g,(t,r)=>{let u=e[r];return u!==void 0?String(u):`{{${r}}}`})),s}function O(n,e){if(!a())return;let s=o(n);s?.onStart&&console.log(i(s.onStart,e))}function P(n,e){if(!a())return;let s=o(n);s?.onSuccess&&console.log(`${p.success} ${i(s.onSuccess,e)}`)}function T(n,e,s){let t=o(n);t?.onFailure&&console.error(`${p.failure} ${i(t.onFailure,s)}`),e&&console.error(` ${e}`)}function _(n,e){if(!a())return;let s=o(n);s?.onEmpty&&console.log(i(s.onEmpty,e))}function j(n,e){if(!a())return;let s=o(n);s?.onAlreadyDone&&console.log(i(s.onAlreadyDone,e))}function D(n,e){if(!a())return;let s=o(n);s?.hint&&console.log(`${p.hint} ${i(s.hint,e)}`)}function E(n,e){return{command:n,operation:e}}export{E as msg,j as printAlreadyDone,_ as printEmpty,T as printFailure,D as printHint,O as printStart,P as printSuccess};
|
|
1
|
+
import{a,b,c,d,e,f,g}from"../chunk-A3TXP5Y2.js";import"../chunk-4LGKN5DA.js";export{g as msg,e as printAlreadyDone,d as printEmpty,c as printFailure,f as printHint,a as printStart,b as printSuccess};
|
package/dist/utils/options.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{a,b}from"../chunk-JRALYIRA.js";export{a as getOption,b as parseBoolean};
|
package/dist/utils/path.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a,b,c,d}from"../chunk-I3FOSZPG.js";export{b as isPathFolder,d as listAllItems,a as parsePath,c as parsePaths};
|
package/dist/utils/specs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a,b,c,d}from"../chunk-4LGKN5DA.js";export{d as buildPromptChoices,c as getArgumentSpec,b as getCommandSpec,a as loadSpecs};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tigrisdata/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Command line interface for Tigris object storage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -81,10 +81,11 @@
|
|
|
81
81
|
"@aws-sdk/credential-providers": "^3.981.0",
|
|
82
82
|
"@smithy/shared-ini-file-loader": "^4.4.3",
|
|
83
83
|
"@tigrisdata/iam": "^1.1.0",
|
|
84
|
-
"@tigrisdata/storage": "^2.12.
|
|
84
|
+
"@tigrisdata/storage": "^2.12.2",
|
|
85
85
|
"axios": "^1.12.2",
|
|
86
86
|
"commander": "^11.0.0",
|
|
87
87
|
"enquirer": "^2.4.1",
|
|
88
|
+
"jose": "^6.1.3",
|
|
88
89
|
"open": "^10.2.0",
|
|
89
90
|
"yaml": "^2.3.4"
|
|
90
91
|
},
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
"husky": "^8.0.0",
|
|
102
103
|
"prettier": "^3.0.0",
|
|
103
104
|
"publint": "^0.2.0",
|
|
104
|
-
"semantic-release": "^25.0.
|
|
105
|
+
"semantic-release": "^25.0.3",
|
|
105
106
|
"tsup": "^8.0.0",
|
|
106
107
|
"tsx": "^4.21.0",
|
|
107
108
|
"typescript": "^5.0.0",
|