@tigrisdata/cli 1.6.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ import f from"axios";import N from"open";function w(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var y="https://tigris";import{homedir as A}from"os";import{join as T}from"path";import{readFileSync as I,writeFileSync as O,existsSync as C,mkdirSync as P}from"fs";import{chmod as S}from"fs/promises";var u=T(A(),".tigris"),l=T(u,"config.json");function z(){C(u)||P(u,{recursive:!0,mode:448})}function c(){if(C(l))try{let t=I(l,"utf8");return JSON.parse(t)}catch{return{}}return{}}async function d(t){z(),O(l,JSON.stringify(t,null,2),{mode:384});try{await S(l,384)}catch{}}async function p(t){let e=c();e.tokens=t,await d(e)}async function g(){return c().tokens||null}async function h(){let t=c();delete t.tokens,await d(t)}async function _(t){let e=c();e.organizations=t,await d(e)}function v(){return c().organizations||[]}async function x(t){let e=c();e.loginMethod=t,await d(e)}var k=class{config;baseUrl;constructor(){this.config=w(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
2
+ `);try{let n=(await f.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await N(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
3
+ `)}console.log(`\u23F3 Waiting for authentication...
4
+ `);let o=await this.pollForToken(n.device_code,n.interval||5);await p(o),x("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
5
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let a=0;for(;a<60;){a++;try{let i=(await f.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,r=Date.now()+(i.expires_in||3600)*1e3;return{accessToken:i.access_token,refreshToken:i.refresh_token,idToken:i.id_token,expiresAt:r}}catch(s){if(f.isAxiosError(s)&&s.response){let i=s.response.data?.error;if(i==="authorization_pending"){await this.sleep(n*1e3);continue}if(i==="slow_down"){n+=5,await this.sleep(n*1e3);continue}throw new Error(s.response.data?.error_description||"Authentication failed")}throw s}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await g();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await f.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a={accessToken:o.access_token,refreshToken:o.refresh_token||e.refreshToken,idToken:o.id_token||e.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await p(a),a}catch{throw await h(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await g();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.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(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=e.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),s=JSON.parse(o)[y];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let i=s?.ns?.map(r=>typeof r=="object"&&r!==null?{id:r.id,name:r.name,displayName:r.name}:{id:r,name:r,displayName:r})||[];if(i.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}_(i),console.log(`\u{1F4C2} Found ${i.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),v()}async logout(){await h(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await g()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},m=null;function j(){return m||(m=new k),m}export{k as TigrisAuthClient,j as getAuthClient};
@@ -0,0 +1 @@
1
+ function t(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var e="https://tigris";export{e as TIGRIS_CLAIMS_NAMESPACE,t as getAuth0Config};
@@ -0,0 +1,5 @@
1
+ import{S3Client as O}from"@aws-sdk/client-s3";import{homedir as E}from"os";import{join as y}from"path";import{readFileSync as b,writeFileSync as M,existsSync as k,mkdirSync as D}from"fs";import{chmod as L}from"fs/promises";var u=y(E(),".tigris"),l=y(u,"config.json");function R(){k(u)||D(u,{recursive:!0,mode:448})}function a(){if(k(l))try{let t=b(l,"utf8");return JSON.parse(t)}catch{return{}}return{}}async function d(t){R(),M(l,JSON.stringify(t,null,2),{mode:384});try{await L(l,384)}catch{}}async function p(t){let e=a();e.tokens=t,await d(e)}async function g(){return a().tokens||null}async function h(){let t=a();delete t.tokens,await d(t)}async function T(t){let e=a();e.organizations=t,await d(e)}function C(){return a().organizations||[]}function v(){return a().selectedOrganization||null}function _(){let t=a();return t.temporaryCredentials||t.credentials||null}async function x(t){let e=a();e.loginMethod=t,await d(e)}function A(){return a().loginMethod||null}import f from"axios";import F from"open";function I(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var P="https://tigris";var w=class{config;baseUrl;constructor(){this.config=I(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
2
+ `);try{let n=(await f.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await F(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
3
+ `)}console.log(`\u23F3 Waiting for authentication...
4
+ `);let o=await this.pollForToken(n.device_code,n.interval||5);await p(o),x("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
5
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let c=0;for(;c<60;){c++;try{let i=(await f.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,r=Date.now()+(i.expires_in||3600)*1e3;return{accessToken:i.access_token,refreshToken:i.refresh_token,idToken:i.id_token,expiresAt:r}}catch(s){if(f.isAxiosError(s)&&s.response){let i=s.response.data?.error;if(i==="authorization_pending"){await this.sleep(n*1e3);continue}if(i==="slow_down"){n+=5,await this.sleep(n*1e3);continue}throw new Error(s.response.data?.error_description||"Authentication failed")}throw s}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await g();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await f.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,c={accessToken:o.access_token,refreshToken:o.refresh_token||e.refreshToken,idToken:o.id_token||e.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await p(c),c}catch{throw await h(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await g();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.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(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=e.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),s=JSON.parse(o)[P];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let i=s?.ns?.map(r=>typeof r=="object"&&r!==null?{id:r.id,name:r.name,displayName:r.name}:{id:r,name:r,displayName:r})||[];if(i.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}T(i),console.log(`\u{1F4C2} Found ${i.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),C()}async logout(){await h(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await g()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},m=null;function S(){return m||(m=new w),m}async function z(){return A()}async function ee(){let t=await z();if(!t)throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.');if(t==="oauth"){let n=await S().getAccessToken(),o=v();if(!o)throw new Error('No organization selected. Please run "tigris orgs select" first.');let c=process.env.TIGRIS_ENDPOINT??"https://t3.storage.dev",s=new O({region:"auto",endpoint:c,credentials:{sessionToken:n,accessKeyId:"",secretAccessKey:""}});return s.middlewareStack.add(i=>async r=>{let N=r.request;return N.headers["x-Tigris-Namespace"]=o,await i(r)},{name:"x-Tigris-Namespace-Middleware",step:"build",override:!0}),s}else{let e=_();if(!e)throw new Error('No credentials found. Please run "tigris configure" first.');return new O({region:"auto",endpoint:e.endpoint,credentials:{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey}})}}async function te(){return await z()!==null}export{z as getLoginMethod,ee as getS3Client,te as isAuthenticated};
@@ -0,0 +1 @@
1
+ import{homedir as c}from"os";import{join as s}from"path";import{readFileSync as g,writeFileSync as f,existsSync as a,mkdirSync as l}from"fs";import{chmod as d}from"fs/promises";var r=s(c(),".tigris"),t=s(r,"config.json");function u(){a(r)||l(r,{recursive:!0,mode:448})}function e(){if(a(t))try{let n=g(t,"utf8");return JSON.parse(n)}catch{return{}}return{}}async function i(n){u(),f(t,JSON.stringify(n,null,2),{mode:384});try{await d(t,384)}catch{}}async function x(n){let o=e();o.tokens=n,await i(o)}async function O(){return e().tokens||null}async function v(){let n=e();delete n.tokens,await i(n)}async function z(n){let o=e();o.organizations=n,await i(o)}function w(){return e().organizations||[]}async function h(n){let o=e();o.selectedOrganization=n,await i(o)}function k(){return e().selectedOrganization||null}function P(){let n=e();return n.temporaryCredentials||n.credentials||null}async function S(n){let o=e();o.credentials=n,await i(o)}async function T(n){let o=e();o.temporaryCredentials=n,await i(o)}async function I(){let n=e();delete n.temporaryCredentials,await i(n)}async function F(){let n=e();delete n.credentials,await i(n)}async function M(n){let o=e();o.loginMethod=n,await i(o)}function N(){return e().loginMethod||null}async function j(){let o=e().credentials;await i({credentials:o})}export{j as clearAllData,F as clearCredentials,I as clearTemporaryCredentials,v as clearTokens,P as getCredentials,N as getLoginMethod,w as getOrganizations,k as getSelectedOrganization,O as getTokens,S as storeCredentials,M as storeLoginMethod,z as storeOrganizations,h as storeSelectedOrganization,T as storeTemporaryCredentials,x as storeTokens};
File without changes
package/dist/cli.js CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env node
2
-
3
- // src/cli.ts
4
- import { Command } from "commander";
5
- var program = new Command();
6
- program.name("tigris").description("Command line interface for Tigris object storage").version("0.0.1");
7
- program.parse();
8
- //# sourceMappingURL=cli.js.map
2
+ import{Command as C}from"commander";import{readFileSync as E}from"fs";import{join as x,dirname as q}from"path";import{fileURLToPath as v}from"url";import*as w from"yaml";var P=v(import.meta.url),b=q(P),j=x(b,"specs.yaml"),k=E(j,"utf8"),l=w.parse(k);function y(e){let t;e.type==="noun"?t=` ${e.name}`:(t=` --${e.name}`,e.alias&&(t+=`, -${e.alias}`));let n=26,i=t.length>=n?t+" ":t.padEnd(n),o=e.description;return e.options&&(Array.isArray(e.options)&&typeof e.options[0]=="string"?o+=` (options: ${e.options.join(", ")})`:o+=` (options: ${e.options.map(s=>s.value).join(", ")})`),e.default&&(o+=` [default: ${e.default}]`),e.required&&(o+=" [required]"),e["required-when"]&&(o+=` [required when: ${e["required-when"]}]`),e.multiple&&(o+=" [multiple values: comma-separated]"),e.type==="noun"&&(o+=" [positional argument]"),e.examples&&e.examples.length>0&&(o+=` (examples: ${e.examples.join(", ")})`),`${i}${o}`}function g(e){console.log(`
3
+ ${l.name} ${e.name} - ${e.description}
4
+ `),e.operations&&e.operations.length>0&&(console.log("Operations:"),e.operations.forEach(t=>{let n=` ${t.name}`;if(t.alias){let o=Array.isArray(t.alias)?t.alias:[t.alias];n+=` (${o.join(", ")})`}let i=n.padEnd(24);console.log(`${i}${t.description}`)}),console.log()),e.arguments&&e.arguments.length>0&&(console.log("Arguments:"),e.arguments.forEach(t=>{console.log(y(t))}),console.log()),console.log(`Use "${l.name} ${e.name} <operation> help" for more information about an operation.`)}function R(e,t){console.log(`
5
+ ${l.name} ${e.name} ${t.name} - ${t.description}
6
+ `),t.arguments&&t.arguments.length>0&&(console.log("Arguments:"),t.arguments.forEach(n=>{console.log(y(n))}),console.log())}function A(){console.log(`
7
+ ${l.name} - ${l.description}
8
+ `),console.log(`Usage: tigris [command] [options]
9
+ `),console.log("Commands:"),l.commands.forEach(e=>{let t=` ${e.name}`;e.alias&&(t+=` (${e.alias})`);let n=t.padEnd(24);console.log(`${n}${e.description}`)}),console.log(`
10
+ Version: ${l.version}`),console.log(`
11
+ Use "${l.name} <command> help" for more information about a command.`)}function p(e,t=[]){t.forEach(n=>{if(n.type==="noun"){let i=n.required?`<${n.name}>`:`[${n.name}]`;e.argument(i,n.description)}else{let i=`--${n.name}`;n.alias&&(i+=`, -${n.alias}`),n.options?i+=" <value>":i+=n.required||n["required-when"]?" <value>":" [value]",e.option(i,n.description,n.default)}})}function d(e,t){for(let n of e){if(n["required-when"]){let[i,o]=n["required-when"].split("="),s=m(t,i,e),r=m(t,n.name,e);if(s===o&&!r)return console.error(`Error: --${n.name} is required when --${i} is ${o}`),!1}if(n.required&&!m(t,n.name,e))return console.error(`Error: --${n.name} is required`),!1}return!0}function m(e,t,n){if(n){let o=n.find(s=>s.name===t);if(o&&o.alias){let s=o.alias.charAt(0).toUpperCase()+o.alias.slice(1);if(e[s]!==void 0)return e[s]}}let i=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),U(t)];for(let o of i)if(e[o]!==void 0)return e[o]}function U(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}async function $(e,t,n=[],i={}){try{let o,s;t?(o=`./lib/${e}/${t}.js`,s=t):(o=`./lib/${e}.js`,s=e);try{let r=await import(o),a=r.default||r[s];typeof a=="function"?await a({...i,_positional:n}):console.error(`No default export or ${s} function found in ${o}`)}catch{try{let a=t?`./lib/${e}/${t}/index.js`:`./lib/${e}/index.js`,f=await import(a),h=f.default||f[s];typeof h=="function"?await h({...i,_positional:n}):console.error(`No default export or ${s} function found in ${a}`)}catch{console.error(`Command implementation not found: ${o} or ${t?`${e}/${t}/index`:`${e}/index`}`),console.error("Create the implementation file with a default export function.")}}}catch(o){console.error(`Error executing command: ${o}`)}}var c=new C;c.name(l.name).description(l.description).version(l.version);function u(e,t,n){let i;"opts"in n&&typeof n.opts=="function"?i=n.opts():i=n;let o={...i};return e.filter(r=>r.type==="noun").forEach((r,a)=>{t[a]!==void 0&&(r.multiple?o[r.name]=t[a].split(",").map(f=>f.trim()):o[r.name]=t[a])}),e.forEach(r=>{r.multiple&&r.type!=="noun"&&o[r.name]&&typeof o[r.name]=="string"&&(o[r.name]=o[r.name].split(",").map(a=>a.trim()))}),o}l.commands.forEach(e=>{let t=c.command(e.name).description(e.description);if(e.alias&&t.alias(e.alias),e.operations&&e.operations.length>0)if(e.operations.forEach(n=>{let i=t.command(n.name).description(n.description);n.alias&&(Array.isArray(n.alias)?n.alias:[n.alias]).forEach(s=>i.alias(s)),p(i,n.arguments),i.action(async(...o)=>{let s=o.pop(),r=o;n.arguments&&!d(n.arguments,u(n.arguments,r,s))||await $(e.name,n.name,r,u(n.arguments||[],r,s))}),i.command("help").description("Show help for this operation").action(()=>{R(e,n)})}),e.default){let n=e.operations?.find(i=>i.name===e.default);n&&(p(t,n.arguments),t.action(async(...i)=>{let o=i.pop(),s=i;n.arguments&&!d(n.arguments,u(n.arguments,s,o))||await $(e.name,n.name,s,u(n.arguments||[],s,o))}))}else t.action(()=>{g(e)});else p(t,e.arguments),t.action(async(...n)=>{let i=n.pop(),o=n;e.arguments&&!d(e.arguments,u(e.arguments,o,i))||await $(e.name,void 0,o,u(e.arguments||[],o,i))});t.command("help").description("Show help for this command").action(()=>{g(e)})});c.command("help").description("Show general help").action(()=>{A()});c.action(()=>{A()});c.parse();
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import{Command as C}from"commander";import{readFileSync as E}from"fs";import{join as x,dirname as q}from"path";import{fileURLToPath as v}from"url";import*as w from"yaml";var P=v(import.meta.url),b=q(P),j=x(b,"specs.yaml"),k=E(j,"utf8"),l=w.parse(k);function y(e){let t;e.type==="noun"?t=` ${e.name}`:(t=` --${e.name}`,e.alias&&(t+=`, -${e.alias}`));let n=26,i=t.length>=n?t+" ":t.padEnd(n),o=e.description;return e.options&&(Array.isArray(e.options)&&typeof e.options[0]=="string"?o+=` (options: ${e.options.join(", ")})`:o+=` (options: ${e.options.map(s=>s.value).join(", ")})`),e.default&&(o+=` [default: ${e.default}]`),e.required&&(o+=" [required]"),e["required-when"]&&(o+=` [required when: ${e["required-when"]}]`),e.multiple&&(o+=" [multiple values: comma-separated]"),e.type==="noun"&&(o+=" [positional argument]"),e.examples&&e.examples.length>0&&(o+=` (examples: ${e.examples.join(", ")})`),`${i}${o}`}function g(e){console.log(`
2
+ ${l.name} ${e.name} - ${e.description}
3
+ `),e.operations&&e.operations.length>0&&(console.log("Operations:"),e.operations.forEach(t=>{let n=` ${t.name}`;if(t.alias){let o=Array.isArray(t.alias)?t.alias:[t.alias];n+=` (${o.join(", ")})`}let i=n.padEnd(24);console.log(`${i}${t.description}`)}),console.log()),e.arguments&&e.arguments.length>0&&(console.log("Arguments:"),e.arguments.forEach(t=>{console.log(y(t))}),console.log()),console.log(`Use "${l.name} ${e.name} <operation> help" for more information about an operation.`)}function R(e,t){console.log(`
4
+ ${l.name} ${e.name} ${t.name} - ${t.description}
5
+ `),t.arguments&&t.arguments.length>0&&(console.log("Arguments:"),t.arguments.forEach(n=>{console.log(y(n))}),console.log())}function A(){console.log(`
6
+ ${l.name} - ${l.description}
7
+ `),console.log(`Usage: tigris [command] [options]
8
+ `),console.log("Commands:"),l.commands.forEach(e=>{let t=` ${e.name}`;e.alias&&(t+=` (${e.alias})`);let n=t.padEnd(24);console.log(`${n}${e.description}`)}),console.log(`
9
+ Version: ${l.version}`),console.log(`
10
+ Use "${l.name} <command> help" for more information about a command.`)}function p(e,t=[]){t.forEach(n=>{if(n.type==="noun"){let i=n.required?`<${n.name}>`:`[${n.name}]`;e.argument(i,n.description)}else{let i=`--${n.name}`;n.alias&&(i+=`, -${n.alias}`),n.options?i+=" <value>":i+=n.required||n["required-when"]?" <value>":" [value]",e.option(i,n.description,n.default)}})}function d(e,t){for(let n of e){if(n["required-when"]){let[i,o]=n["required-when"].split("="),s=m(t,i,e),r=m(t,n.name,e);if(s===o&&!r)return console.error(`Error: --${n.name} is required when --${i} is ${o}`),!1}if(n.required&&!m(t,n.name,e))return console.error(`Error: --${n.name} is required`),!1}return!0}function m(e,t,n){if(n){let o=n.find(s=>s.name===t);if(o&&o.alias){let s=o.alias.charAt(0).toUpperCase()+o.alias.slice(1);if(e[s]!==void 0)return e[s]}}let i=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),U(t)];for(let o of i)if(e[o]!==void 0)return e[o]}function U(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}async function $(e,t,n=[],i={}){try{let o,s;t?(o=`./lib/${e}/${t}.js`,s=t):(o=`./lib/${e}.js`,s=e);try{let r=await import(o),a=r.default||r[s];typeof a=="function"?await a({...i,_positional:n}):console.error(`No default export or ${s} function found in ${o}`)}catch{try{let a=t?`./lib/${e}/${t}/index.js`:`./lib/${e}/index.js`,f=await import(a),h=f.default||f[s];typeof h=="function"?await h({...i,_positional:n}):console.error(`No default export or ${s} function found in ${a}`)}catch{console.error(`Command implementation not found: ${o} or ${t?`${e}/${t}/index`:`${e}/index`}`),console.error("Create the implementation file with a default export function.")}}}catch(o){console.error(`Error executing command: ${o}`)}}var c=new C;c.name(l.name).description(l.description).version(l.version);function u(e,t,n){let i;"opts"in n&&typeof n.opts=="function"?i=n.opts():i=n;let o={...i};return e.filter(r=>r.type==="noun").forEach((r,a)=>{t[a]!==void 0&&(r.multiple?o[r.name]=t[a].split(",").map(f=>f.trim()):o[r.name]=t[a])}),e.forEach(r=>{r.multiple&&r.type!=="noun"&&o[r.name]&&typeof o[r.name]=="string"&&(o[r.name]=o[r.name].split(",").map(a=>a.trim()))}),o}l.commands.forEach(e=>{let t=c.command(e.name).description(e.description);if(e.alias&&t.alias(e.alias),e.operations&&e.operations.length>0)if(e.operations.forEach(n=>{let i=t.command(n.name).description(n.description);n.alias&&(Array.isArray(n.alias)?n.alias:[n.alias]).forEach(s=>i.alias(s)),p(i,n.arguments),i.action(async(...o)=>{let s=o.pop(),r=o;n.arguments&&!d(n.arguments,u(n.arguments,r,s))||await $(e.name,n.name,r,u(n.arguments||[],r,s))}),i.command("help").description("Show help for this operation").action(()=>{R(e,n)})}),e.default){let n=e.operations?.find(i=>i.name===e.default);n&&(p(t,n.arguments),t.action(async(...i)=>{let o=i.pop(),s=i;n.arguments&&!d(n.arguments,u(n.arguments,s,o))||await $(e.name,n.name,s,u(n.arguments||[],s,o))}))}else t.action(()=>{g(e)});else p(t,e.arguments),t.action(async(...n)=>{let i=n.pop(),o=n;e.arguments&&!d(e.arguments,u(e.arguments,o,i))||await $(e.name,void 0,o,u(e.arguments||[],o,i))});t.command("help").description("Show help for this command").action(()=>{g(e)})});c.command("help").description("Show general help").action(()=>{A()});c.action(()=>{A()});c.parse();
@@ -0,0 +1,14 @@
1
+ function C(n,e,t){for(let o of e)if(n[o]!==void 0)return n[o];return t}function $(n){return JSON.stringify(n,null,2)}function j(n,e=" "){return Object.entries(n).map(([t,o])=>`${e}<${t}>${o}</${t}>`).join(`
2
+ `)}function D(n,e,t){let o=[`<${e}>`];return n.forEach(r=>{o.push(` <${t}>`),o.push(j(r," ")),o.push(` </${t}>`)}),o.push(`</${e}>`),o.join(`
3
+ `)}function L(n,e){let t=[],o="\u250C"+e.map(i=>"\u2500".repeat(i.width+2)).join("\u252C")+"\u2510",r="\u251C"+e.map(i=>"\u2500".repeat(i.width+2)).join("\u253C")+"\u2524",s="\u2514"+e.map(i=>"\u2500".repeat(i.width+2)).join("\u2534")+"\u2518";t.push(`
4
+ `+o);let a="\u2502 "+e.map(i=>i.header.padEnd(i.width)).join(" \u2502 ")+" \u2502";return t.push(a),t.push(r),n.forEach(i=>{let p=e.map(d=>{let y=String(i[d.key]??"");return d.align==="right"?y.padStart(d.width):y.padEnd(d.width)});t.push("\u2502 "+p.join(" \u2502 ")+" \u2502")}),t.push(s+`
5
+ `),t.join(`
6
+ `)}function x(n,e,t,o,r){switch(e){case"json":return $(n);case"xml":return D(n,t,o);default:return L(n,r)}}import{S3Client as R}from"@aws-sdk/client-s3";import{homedir as F}from"os";import{join as v}from"path";import{readFileSync as B,writeFileSync as J,existsSync as _,mkdirSync as U}from"fs";import{chmod as K}from"fs/promises";var h=v(F(),".tigris"),l=v(h,"config.json");function H(){_(h)||U(h,{recursive:!0,mode:448})}function c(){if(_(l))try{let n=B(l,"utf8");return JSON.parse(n)}catch{return{}}return{}}async function g(n){H(),J(l,JSON.stringify(n,null,2),{mode:384});try{await K(l,384)}catch{}}async function m(n){let e=c();e.tokens=n,await g(e)}async function u(){return c().tokens||null}async function w(){let n=c();delete n.tokens,await g(n)}async function A(n){let e=c();e.organizations=n,await g(e)}function I(){return c().organizations||[]}function O(){return c().selectedOrganization||null}function S(){let n=c();return n.temporaryCredentials||n.credentials||null}async function P(n){let e=c();e.loginMethod=n,await g(e)}function N(){return c().loginMethod||null}import f from"axios";import q from"open";function b(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var z="https://tigris";var T=class{config;baseUrl;constructor(){this.config=b(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
7
+ `);try{let t=(await f.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await q(t.verification_uri_complete)}catch{console.log(`Visit: ${t.verification_uri} and Enter code: ${t.user_code}
8
+ `)}console.log(`\u23F3 Waiting for authentication...
9
+ `);let o=await this.pollForToken(t.device_code,t.interval||5);await m(o),P("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
10
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,t){let r=0;for(;r<60;){r++;try{let a=(await f.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,i=Date.now()+(a.expires_in||3600)*1e3;return{accessToken:a.access_token,refreshToken:a.refresh_token,idToken:a.id_token,expiresAt:i}}catch(s){if(f.isAxiosError(s)&&s.response){let a=s.response.data?.error;if(a==="authorization_pending"){await this.sleep(t*1e3);continue}if(a==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(s.response.data?.error_description||"Authentication failed")}throw s}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await u();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await f.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:o.access_token,refreshToken:o.refresh_token||e.refreshToken,idToken:o.id_token||e.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await m(r),r}catch{throw await w(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await u();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let t=e.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(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let t=e.split(".")[1],o=Buffer.from(t,"base64").toString("utf8"),s=JSON.parse(o)[z];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let a=s?.ns?.map(i=>typeof i=="object"&&i!==null?{id:i.id,name:i.name,displayName:i.name}:{id:i,name:i,displayName:i})||[];if(a.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}A(a),console.log(`\u{1F4C2} Found ${a.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),I()}async logout(){await w(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await u()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},k=null;function E(){return k||(k=new T),k}async function G(){return N()}async function M(){let n=await G();if(!n)throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.');if(n==="oauth"){let t=await E().getAccessToken(),o=O();if(!o)throw new Error('No organization selected. Please run "tigris orgs select" first.');let r=process.env.TIGRIS_ENDPOINT??"https://t3.storage.dev",s=new R({region:"auto",endpoint:r,credentials:{sessionToken:t,accessKeyId:"",secretAccessKey:""}});return s.middlewareStack.add(a=>async i=>{let p=i.request;return p.headers["x-Tigris-Namespace"]=o,await a(i)},{name:"x-Tigris-Namespace-Middleware",step:"build",override:!0}),s}else{let e=S();if(!e)throw new Error('No credentials found. Please run "tigris configure" first.');return new R({region:"auto",endpoint:e.endpoint,credentials:{accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey}})}}import{ListBucketsCommand as V}from"@aws-sdk/client-s3";async function W(n){console.log("\u{1FAA3} Listing Buckets");try{let e=C(n,["format","F"],"table"),t=await M(),o=new V({}),r=await t.send(o);if(!r.Buckets||r.Buckets.length===0){console.log("No buckets found");return}let s=r.Buckets.map(i=>({name:i.Name||"",created:i.CreationDate?i.CreationDate.toISOString().split("T")[0]:"N/A"})),a=x(s,e,"buckets","bucket",[{key:"name",header:"Name",width:50},{key:"created",header:"Created",width:50}]);console.log(a),console.log(`Found ${s.length} bucket(s)`)}catch(e){e instanceof Error?(console.error(`
11
+ \u274C Failed to list buckets: ${e.message}`),e.message.includes("Not authenticated")?console.log(`\u{1F4A1} Run "tigris login" or "tigris configure" to authenticate
12
+ `):e.message.includes("No organization selected")&&console.log(`\u{1F4A1} Run "tigris orgs select" to choose an organization
13
+ `)):console.error(`
14
+ \u274C An unknown error occurred`),process.exit(1)}}export{W as default};
@@ -0,0 +1,6 @@
1
+ import T from"enquirer";import{homedir as y}from"os";import{join as a}from"path";import{readFileSync as p,writeFileSync as m,existsSync as d,mkdirSync as C}from"fs";import{chmod as h}from"fs/promises";var c=a(y(),".tigris"),r=a(c,"config.json");function x(){d(c)||C(c,{recursive:!0,mode:448})}function g(){if(d(r))try{let e=p(r,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function l(e){x(),m(r,JSON.stringify(e,null,2),{mode:384});try{await h(r,384)}catch{}}async function f(e){let n=g();n.credentials=e,await l(n)}async function u(e){let n=g();n.loginMethod=e,await l(n)}var{prompt:w}=T;async function S(e){console.log(`\u{1F510} Tigris Configuration
2
+ `);let n=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,i=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,o=e.endpoint||e.e||e.E||e.Endpoint;if(!n||!i||!o){console.log(`Please provide your Tigris credentials. You can find these in your Tigris dashboard.
3
+ `);try{let t=[];n||t.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),i||t.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),o||t.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:process.env.TIGRIS_ENDPOINT??"https://t3.storage.dev"});let s=await w(t);n=n||s.accessKey,i=i||s.accessSecret,o=o||s.endpoint}catch{console.error(`
4
+ \u274C Configuration cancelled`),process.exit(1)}}(!n||!i||!o)&&(console.error("\u274C All credentials are required"),process.exit(1));try{await f({accessKeyId:n,secretAccessKey:i,endpoint:o}),await u("credentials"),console.log(`
5
+ \u2705 Credentials saved successfully!`),console.log(`
6
+ \u{1F4A1} You can now use Tigris CLI commands with these credentials.`)}catch(t){console.error("\u274C Failed to save credentials:",t),process.exit(1)}}export{S as default};
package/dist/lib/cp.js ADDED
@@ -0,0 +1 @@
1
+ function n(t){let o=t.split("/");return{bucket:o[0],path:o.slice(1).join("/")}}function a(t,o){return{source:n(t),destination:n(o)}}async function c(t){let o=t.src||t._positional?.[0],r=t.dest||t._positional?.[1];if(!o||!r){console.error("Error: both src and dest arguments are required");return}console.log(`Copying from: ${o} to: ${r}`);let{source:s,destination:e}=a(o,r);console.log(`Source bucket: ${s.bucket}, path: ${s.path||"(root)"}`),console.log(`Destination bucket: ${e.bucket}, path: ${e.path||"(root)"}`),console.log("Implementation pending - this would copy folders or objects")}export{c as default};
@@ -0,0 +1,9 @@
1
+ import T from"enquirer";import{homedir as v}from"os";import{join as u}from"path";import{readFileSync as h,writeFileSync as w,existsSync as y,mkdirSync as x}from"fs";import{chmod as K}from"fs/promises";var c=u(v(),".tigris"),i=u(c,"config.json");function P(){y(c)||x(c,{recursive:!0,mode:448})}function a(){if(y(i))try{let e=h(i,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function p(e){P(),w(i,JSON.stringify(e,null,2),{mode:384});try{await K(i,384)}catch{}}function l(){let e=a();return e.temporaryCredentials||e.credentials||null}async function m(e){let s=a();s.temporaryCredentials=e,await p(s)}async function C(e){let s=a();s.loginMethod=e,await p(s)}var{prompt:d}=T;async function k(e){console.log(`\u{1F510} Tigris Machine Login
2
+ `);let s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,n=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,g=e.profile||e.Profile||e.p||e.P;if(!s||!n){let o=l();if(o)if(g)console.log(`\u{1F4C1} Using saved credentials from profile...
3
+ `),s=o.accessKeyId,n=o.secretAccessKey;else try{if((await d({type:"confirm",name:"useSaved",message:"Saved credentials found. Use them?",initial:!0})).useSaved)console.log(`\u{1F4C1} Using saved credentials...
4
+ `),s=o.accessKeyId,n=o.secretAccessKey;else{console.log(`Please provide your access credentials.
5
+ `);let r=[];s||r.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),n||r.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0});let f=await d(r);s=s||f.accessKey,n=n||f.accessSecret}}catch{console.error(`
6
+ \u274C Login cancelled`),process.exit(1)}else{g&&(console.error(`\u274C No saved credentials found. Please run "tigris configure" first.
7
+ `),process.exit(1)),console.log(`No saved credentials found. Please provide your access credentials.
8
+ `);try{let t=[];s||t.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),n||t.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0});let r=await d(t);s=s||r.accessKey,n=n||r.accessSecret}catch{console.error(`
9
+ \u274C Login cancelled`),process.exit(1)}}}(!s||!n)&&(console.error("\u274C Access key and secret are required"),process.exit(1)),console.log("\u{1F511} Authenticating with credentials..."),console.log(`Access Key: ${s}`),console.log(`Access Secret: ${"*".repeat(String(n).length)}`);let S=l()?.endpoint||"https://t3.storage.dev";await m({accessKeyId:s,secretAccessKey:n,endpoint:S}),await C("credentials"),console.log("\u2705 Successfully authenticated with credentials")}export{k as default};
@@ -0,0 +1,18 @@
1
+ import q from"enquirer";import m from"axios";import $ from"open";function x(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var _="https://tigris";import{homedir as E}from"os";import{join as P}from"path";import{readFileSync as L,writeFileSync as D,existsSync as I,mkdirSync as R}from"fs";import{chmod as M}from"fs/promises";var h=P(E(),".tigris"),u=P(h,"config.json");function U(){I(h)||R(h,{recursive:!0,mode:448})}function c(){if(I(u))try{let e=L(u,"utf8");return JSON.parse(e)}catch{return{}}return{}}async function d(e){U(),D(u,JSON.stringify(e,null,2),{mode:384});try{await M(u,384)}catch{}}async function y(e){let t=c();t.tokens=e,await d(t)}async function f(){return c().tokens||null}async function w(){let e=c();delete e.tokens,await d(e)}async function O(e){let t=c();t.organizations=e,await d(t)}function z(){return c().organizations||[]}async function K(e){let t=c();t.selectedOrganization=e,await d(t)}function k(){let e=c();return e.temporaryCredentials||e.credentials||null}async function N(e){let t=c();t.temporaryCredentials=e,await d(t)}async function p(e){let t=c();t.loginMethod=e,await d(t)}var v=class{config;baseUrl;constructor(){this.config=x(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
2
+ `);try{let n=(await m.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await $(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
3
+ `)}console.log(`\u23F3 Waiting for authentication...
4
+ `);let o=await this.pollForToken(n.device_code,n.interval||5);await y(o),p("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
5
+ `)}catch(t){throw t instanceof Error?console.error(`\u274C Authentication failed: ${t.message}`):console.error("\u274C Authentication failed"),t}}async pollForToken(t,n){let a=0;for(;a<60;){a++;try{let s=(await m.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,r=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:r}}catch(i){if(m.isAxiosError(i)&&i.response){let s=i.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(i.response.data?.error_description||"Authentication failed")}throw i}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let t=await f();if(!t)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=t.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),t=await this.refreshAccessToken(t)),t.accessToken}async refreshAccessToken(t){if(!t.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await m.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a={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 y(a),a}catch{throw await w(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let t=await f();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){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=t.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),i=JSON.parse(o)[_];if(!i){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let s=i?.ns?.map(r=>typeof r=="object"&&r!==null?{id:r.id,name:r.name,displayName:r.name}:{id:r,name:r,displayName:r})||[];if(s.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}O(s),console.log(`\u{1F4C2} Found ${s.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),z()}async logout(){await w(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await f()!==null}sleep(t){return new Promise(n=>setTimeout(n,t))}},T=null;function b(){return T||(T=new v),T}async function C(){console.log("\u{1F510} Tigris User Login");try{let e=b();if(await e.isAuthenticated()){console.log("\u26A0\uFE0F You are already logged in."),console.log(`\u{1F4A1} Run "tigris logout" first if you want to login with a different account.
6
+ `);return}await e.login();let n=await e.getOrganizations();if(n.length>0){let o=n[0];K(o.id),console.log("\u{1F3AF} Auto-selected organization:"),console.log(` ${o.displayName||o.name} (${o.id})
7
+ `),n.length>1&&(console.log(`\u{1F4A1} You have ${n.length} organizations available.`),console.log(` Run "tigris orgs list" to see all and switch if needed.
8
+ `))}}catch{process.exit(1)}}import F from"enquirer";var{prompt:A}=F;async function g(e){console.log(`\u{1F510} Tigris Machine Login
9
+ `);let t=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,n=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,o=e.profile||e.Profile||e.p||e.P;if(!t||!n){let s=k();if(s)if(o)console.log(`\u{1F4C1} Using saved credentials from profile...
10
+ `),t=s.accessKeyId,n=s.secretAccessKey;else try{if((await A({type:"confirm",name:"useSaved",message:"Saved credentials found. Use them?",initial:!0})).useSaved)console.log(`\u{1F4C1} Using saved credentials...
11
+ `),t=s.accessKeyId,n=s.secretAccessKey;else{console.log(`Please provide your access credentials.
12
+ `);let l=[];t||l.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),n||l.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0});let S=await A(l);t=t||S.accessKey,n=n||S.accessSecret}}catch{console.error(`
13
+ \u274C Login cancelled`),process.exit(1)}else{o&&(console.error(`\u274C No saved credentials found. Please run "tigris configure" first.
14
+ `),process.exit(1)),console.log(`No saved credentials found. Please provide your access credentials.
15
+ `);try{let r=[];t||r.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),n||r.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0});let l=await A(r);t=t||l.accessKey,n=n||l.accessSecret}catch{console.error(`
16
+ \u274C Login cancelled`),process.exit(1)}}}(!t||!n)&&(console.error("\u274C Access key and secret are required"),process.exit(1)),console.log("\u{1F511} Authenticating with credentials..."),console.log(`Access Key: ${t}`),console.log(`Access Secret: ${"*".repeat(String(n).length)}`);let i=k()?.endpoint||"https://t3.storage.dev";await N({accessKeyId:t,secretAccessKey:n,endpoint:i}),await p("credentials"),console.log("\u2705 Successfully authenticated with credentials")}var{prompt:J}=q;async function H(e){let t=e.profile||e.Profile||e.p||e.P,n=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,o=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,a=e.oauth||e.OAuth||e.o||e.O;if(t){await g(e);return}if(n||o){await g(e);return}if(a){await C();return}console.log(`\u{1F510} Tigris Login
17
+ `);try{(await J({type:"select",name:"loginType",message:"How would you like to login?",choices:[{name:"user",message:"As a user (OAuth2 flow)",value:"user"},{name:"machine",message:"As a machine (Access Key & Secret)",value:"machine"}]})).loginType==="user"?await C():await g(e)}catch{console.error(`
18
+ \u274C Login cancelled`),process.exit(1)}}export{H as default};
@@ -0,0 +1,8 @@
1
+ import f from"axios";import E from"open";function k(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var y="https://tigris";import{homedir as O}from"os";import{join as T}from"path";import{readFileSync as P,writeFileSync as z,existsSync as C,mkdirSync as S}from"fs";import{chmod as N}from"fs/promises";var u=T(O(),".tigris"),g=T(u,"config.json");function b(){C(u)||S(u,{recursive:!0,mode:448})}function a(){if(C(g))try{let t=P(g,"utf8");return JSON.parse(t)}catch{return{}}return{}}async function l(t){b(),z(g,JSON.stringify(t,null,2),{mode:384});try{await N(g,384)}catch{}}async function p(t){let e=a();e.tokens=t,await l(e)}async function d(){return a().tokens||null}async function h(){let t=a();delete t.tokens,await l(t)}async function v(t){let e=a();e.organizations=t,await l(e)}function _(){return a().organizations||[]}async function x(t){let e=a();e.selectedOrganization=t,await l(e)}async function A(t){let e=a();e.loginMethod=t,await l(e)}var w=class{config;baseUrl;constructor(){this.config=k(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
2
+ `);try{let n=(await f.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await E(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
3
+ `)}console.log(`\u23F3 Waiting for authentication...
4
+ `);let o=await this.pollForToken(n.device_code,n.interval||5);await p(o),A("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
5
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let c=0;for(;c<60;){c++;try{let i=(await f.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,r=Date.now()+(i.expires_in||3600)*1e3;return{accessToken:i.access_token,refreshToken:i.refresh_token,idToken:i.id_token,expiresAt:r}}catch(s){if(f.isAxiosError(s)&&s.response){let i=s.response.data?.error;if(i==="authorization_pending"){await this.sleep(n*1e3);continue}if(i==="slow_down"){n+=5,await this.sleep(n*1e3);continue}throw new Error(s.response.data?.error_description||"Authentication failed")}throw s}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await d();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await f.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,c={accessToken:o.access_token,refreshToken:o.refresh_token||e.refreshToken,idToken:o.id_token||e.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await p(c),c}catch{throw await h(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await d();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.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(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=e.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),s=JSON.parse(o)[y];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let i=s?.ns?.map(r=>typeof r=="object"&&r!==null?{id:r.id,name:r.name,displayName:r.name}:{id:r,name:r,displayName:r})||[];if(i.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}v(i),console.log(`\u{1F4C2} Found ${i.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),_()}async logout(){await h(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await d()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},m=null;function I(){return m||(m=new w),m}async function D(){console.log("\u{1F510} Tigris User Login");try{let t=I();if(await t.isAuthenticated()){console.log("\u26A0\uFE0F You are already logged in."),console.log(`\u{1F4A1} Run "tigris logout" first if you want to login with a different account.
6
+ `);return}await t.login();let n=await t.getOrganizations();if(n.length>0){let o=n[0];x(o.id),console.log("\u{1F3AF} Auto-selected organization:"),console.log(` ${o.displayName||o.name} (${o.id})
7
+ `),n.length>1&&(console.log(`\u{1F4A1} You have ${n.length} organizations available.`),console.log(` Run "tigris orgs list" to see all and switch if needed.
8
+ `))}}catch{process.exit(1)}}var V=D;export{V as default,D as ui};
@@ -0,0 +1,4 @@
1
+ import{homedir as a}from"os";import{join as t}from"path";import{readFileSync as c,writeFileSync as l,existsSync as i,mkdirSync as g}from"fs";import{chmod as f}from"fs/promises";var e=t(a(),".tigris"),o=t(e,"config.json");function d(){i(e)||g(e,{recursive:!0,mode:448})}function u(){if(i(o))try{let n=c(o,"utf8");return JSON.parse(n)}catch{return{}}return{}}async function m(n){d(),l(o,JSON.stringify(n,null,2),{mode:384});try{await f(o,384)}catch{}}async function r(){let s=u().credentials;await m({credentials:s})}async function p(){try{console.log(`\u{1F513} Logging out...
2
+ `),await r(),console.log("\u2705 Successfully logged out"),console.log(`\u{1F4A1} All stored tokens and data have been cleared
3
+ `)}catch(n){console.error("\u274C Error during logout"),n instanceof Error&&console.error(` ${n.message}
4
+ `),process.exit(1)}}export{p as default};
package/dist/lib/ls.js ADDED
@@ -0,0 +1 @@
1
+ function n(s){let t=s.split("/");return{bucket:t[0],path:t.slice(1).join("/")}}async function r(s){let t=s.path||s._positional?.[0];if(!t){console.error("Error: path argument is required");return}console.log(`Listing: ${t}`);let{bucket:e,path:o}=n(t);console.log(o?`Listing objects in bucket "${e}" at path "${o}"`:`Listing objects in bucket "${e}"`),console.log("Implementation pending - this would list buckets or objects")}export{r as default};
package/dist/lib/mk.js ADDED
@@ -0,0 +1 @@
1
+ function s(e){let t=e.split("/");return{bucket:t[0],path:t.slice(1).join("/")}}async function n(e){let t=e.path||e._positional?.[0];if(!t){console.error("Error: path argument is required");return}console.log(`Creating: ${t}`);let{bucket:r,path:o}=s(t);console.log(o?`Creating folder "${o}" in bucket "${r}"`:`Creating bucket "${r}"`),console.log("Implementation pending - this would create buckets or folders")}export{n as default};
package/dist/lib/mv.js ADDED
@@ -0,0 +1 @@
1
+ function n(t){let o=t.split("/");return{bucket:o[0],path:o.slice(1).join("/")}}function a(t,o){return{source:n(t),destination:n(o)}}async function i(t){let o=t.src||t._positional?.[0],r=t.dest||t._positional?.[1];if(!o||!r){console.error("Error: both src and dest arguments are required");return}console.log(`Moving from: ${o} to: ${r}`);let{source:s,destination:e}=a(o,r);console.log(`Source bucket: ${s.bucket}, path: ${s.path||"(root)"}`),console.log(`Destination bucket: ${e.bucket}, path: ${e.path||"(root)"}`),console.log("Implementation pending - this would move folders or objects")}export{i as default};
@@ -0,0 +1,2 @@
1
+ function i(e,o,n){for(let t of o)if(e[t]!==void 0)return e[t];return n}async function s(e){console.log("\u{1F3D7}\uFE0F Creating Organization");let o=i(e,["name","N"]),n=i(e,["description","D"]);o||(console.error("\u274C Organization name is required"),process.exit(1)),console.log(`\u{1F4DD} Name: ${o}`),n&&console.log(`\u{1F4C4} Description: ${n}`),console.log("\u{1F504} Creating organization..."),await new Promise(r=>setTimeout(r,1e3));let t=Math.random().toString(36).substring(2,10);console.log("\u2705 Organization created successfully!"),console.log(`\u{1F194} Organization ID: ${t}`),console.log(`\u{1F4DB} Organization Name: ${o}`),n&&console.log(`\u{1F4C4} Description: ${n}`),console.log(`
2
+ \u{1F4A1} Next steps:`),console.log(` - Select this organization: tigris orgs select --name ${o}`),console.log(" - Create a bucket: tigris buckets create --name my-bucket")}export{s as default};
@@ -0,0 +1,21 @@
1
+ function v(t,e,n){for(let o of e)if(t[o]!==void 0)return t[o];return n}function j(t){return JSON.stringify(t,null,2)}function D(t,e=" "){return Object.entries(t).map(([n,o])=>`${e}<${n}>${o}</${n}>`).join(`
2
+ `)}function F(t,e,n){let o=[`<${e}>`];return t.forEach(r=>{o.push(` <${n}>`),o.push(D(r," ")),o.push(` </${n}>`)}),o.push(`</${e}>`),o.join(`
3
+ `)}function M(t,e){let n=[],o="\u250C"+e.map(i=>"\u2500".repeat(i.width+2)).join("\u252C")+"\u2510",r="\u251C"+e.map(i=>"\u2500".repeat(i.width+2)).join("\u253C")+"\u2524",a="\u2514"+e.map(i=>"\u2500".repeat(i.width+2)).join("\u2534")+"\u2518";n.push(`
4
+ `+o);let s="\u2502 "+e.map(i=>i.header.padEnd(i.width)).join(" \u2502 ")+" \u2502";return n.push(s),n.push(r),t.forEach(i=>{let c=e.map(l=>{let g=String(i[l.key]??"");return l.align==="right"?g.padStart(l.width):g.padEnd(l.width)});n.push("\u2502 "+c.join(" \u2502 ")+" \u2502")}),n.push(a+`
5
+ `),n.join(`
6
+ `)}function O(t,e,n,o,r){switch(e){case"json":return j(t);case"xml":return F(t,n,o);default:return M(t,r)}}import h from"axios";import q from"open";function z(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var A="https://tigris";import{homedir as L}from"os";import{join as I}from"path";import{readFileSync as J,writeFileSync as U,existsSync as S,mkdirSync as B}from"fs";import{chmod as H}from"fs/promises";var k=I(L(),".tigris"),p=I(k,"config.json");function G(){S(k)||B(k,{recursive:!0,mode:448})}function d(){if(S(p))try{let t=J(p,"utf8");return JSON.parse(t)}catch{return{}}return{}}async function f(t){G(),U(p,JSON.stringify(t,null,2),{mode:384});try{await H(p,384)}catch{}}async function y(t){let e=d();e.tokens=t,await f(e)}async function m(){return d().tokens||null}async function T(){let t=d();delete t.tokens,await f(t)}async function N(t){let e=d();e.organizations=t,await f(e)}function P(){return d().organizations||[]}async function b(t){let e=d();e.selectedOrganization=t,await f(e)}function $(){return d().selectedOrganization||null}async function E(t){let e=d();e.loginMethod=t,await f(e)}var x=class{config;baseUrl;constructor(){this.config=z(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
7
+ `);try{let n=(await h.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await q(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
8
+ `)}console.log(`\u23F3 Waiting for authentication...
9
+ `);let o=await this.pollForToken(n.device_code,n.interval||5);await y(o),E("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
10
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let r=0;for(;r<60;){r++;try{let s=(await h.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,i=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:i}}catch(a){if(h.isAxiosError(a)&&a.response){let s=a.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(a.response.data?.error_description||"Authentication failed")}throw a}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await m();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await h.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:o.access_token,refreshToken:o.refresh_token||e.refreshToken,idToken:o.id_token||e.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await y(r),r}catch{throw await T(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await m();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.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(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=e.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),a=JSON.parse(o)[A];if(!a){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let s=a?.ns?.map(i=>typeof i=="object"&&i!==null?{id:i.id,name:i.name,displayName:i.name}:{id:i,name:i,displayName:i})||[];if(s.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}N(s),console.log(`\u{1F4C2} Found ${s.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),P()}async logout(){await T(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await m()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},C=null;function R(){return C||(C=new x),C}import K from"enquirer";async function V(t){console.log("\u{1F4CB} Listing Organizations");let e=v(t,["format","f","F"],"select");try{let n=R();await n.getAccessToken();let o=await n.getOrganizations();if(o.length===0){console.log(`
11
+ \u26A0\uFE0F No organizations found. You may need to re-authenticate.`),console.log(` Run: tigris login
12
+ `);return}let r=$();if(e==="select"){let i=o.map(c=>({name:c.id,message:`${c.displayName||c.name} (${c.id})`,hint:c.id===r?"currently selected":void 0}));try{let g=(await K.prompt({type:"select",name:"organization",message:"Select an organization:",choices:i.map(u=>u.message),initial:r?o.findIndex(u=>u.id===r):0})).organization.match(/\(([^)]+)\)$/),w=g?g[1]:o[0].id;b(w);let _=o.find(u=>u.id===w);console.log(`
13
+ \u2705 Selected organization: ${_?.displayName||_?.name} (${w})
14
+ `);return}catch{console.log(`
15
+ \u274C Selection cancelled
16
+ `),process.exit(0)}}let a=o.map(i=>({id:i.id,name:i.name,displayName:i.displayName||i.name,selected:i.id===r?"\u2713":""})),s=O(a,e,"organizations","organization",[{key:"selected",header:"",width:3},{key:"id",header:"ID",width:20},{key:"name",header:"Name",width:20},{key:"displayName",header:"Display Name",width:30}]);if(console.log(s),console.log(`
17
+ Found ${a.length} organization(s)`),r){let i=o.find(c=>c.id===r);console.log(`Currently selected: ${i?.displayName||i?.name} (${r})`)}else console.log("No organization selected.")}catch(n){n instanceof Error?console.error(`
18
+ \u274C ${n.message}
19
+ `):console.error(`
20
+ \u274C Failed to list organizations
21
+ `),process.exit(1)}}export{V as default};
@@ -0,0 +1,12 @@
1
+ function w(o,e,n){for(let t of e)if(o[t]!==void 0)return o[t];return n}import f from"axios";import $ from"open";function T(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var y="https://tigris";import{homedir as I}from"os";import{join as C}from"path";import{readFileSync as P,writeFileSync as S,existsSync as v,mkdirSync as N}from"fs";import{chmod as b}from"fs/promises";var u=C(I(),".tigris"),g=C(u,"config.json");function E(){v(u)||N(u,{recursive:!0,mode:448})}function c(){if(v(g))try{let o=P(g,"utf8");return JSON.parse(o)}catch{return{}}return{}}async function l(o){E(),S(g,JSON.stringify(o,null,2),{mode:384});try{await b(g,384)}catch{}}async function p(o){let e=c();e.tokens=o,await l(e)}async function d(){return c().tokens||null}async function m(){let o=c();delete o.tokens,await l(o)}async function _(o){let e=c();e.organizations=o,await l(e)}function x(){return c().organizations||[]}async function A(o){let e=c();e.selectedOrganization=o,await l(e)}async function O(o){let e=c();e.loginMethod=o,await l(e)}var k=class{config;baseUrl;constructor(){this.config=T(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
2
+ `);try{let n=(await f.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await $(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
3
+ `)}console.log(`\u23F3 Waiting for authentication...
4
+ `);let t=await this.pollForToken(n.device_code,n.interval||5);await p(t),O("oauth"),await this.extractAndStoreOrganizations(t.idToken),console.log(`\u2705 Authentication successful!
5
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let r=0;for(;r<60;){r++;try{let s=(await f.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(i){if(f.isAxiosError(i)&&i.response){let s=i.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(i.response.data?.error_description||"Authentication failed")}throw i}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await d();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let t=(await f.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:t.access_token,refreshToken:t.refresh_token||e.refreshToken,idToken:t.id_token||e.idToken,expiresAt:Date.now()+(t.expires_in||3600)*1e3};return await p(r),r}catch{throw await m(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await d();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.idToken.split(".")[1],t=Buffer.from(n,"base64").toString("utf8");return JSON.parse(t)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=e.split(".")[1],t=Buffer.from(n,"base64").toString("utf8"),i=JSON.parse(t)[y];if(!i){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let s=i?.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){console.warn("\u26A0\uFE0F No organizations found in claims");return}_(s),console.log(`\u{1F4C2} Found ${s.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),x()}async logout(){await m(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await d()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},h=null;function z(){return h||(h=new k),h}async function D(o){console.log("\u{1F3AF} Selecting Organization");let e=w(o,["name","N"]);e||(console.error("\u274C Organization name or ID is required"),process.exit(1));try{console.log(`\u{1F50D} Looking for organization: ${e}`);let n=z();await n.getAccessToken();let t=await n.getOrganizations(),r=t.find(i=>i.id===e||i.name===e);r||(console.error(`
6
+ \u274C Organization "${e}" not found`),console.log(`
7
+ \u{1F4A1} Available organizations:`),t.forEach(i=>console.log(` - ${i.name} (${i.id})`)),console.log(),process.exit(1)),A(r.id),console.log("\u2705 Organization selected successfully!"),console.log(`\u{1F4DB} Active Organization: ${r.name} (${r.id})`),console.log(`
8
+ \u{1F4A1} This organization will be used for all subsequent commands`)}catch(n){n instanceof Error?console.error(`
9
+ \u274C ${n.message}
10
+ `):console.error(`
11
+ \u274C Failed to select organization
12
+ `),process.exit(1)}}export{D as default};
package/dist/lib/rm.js ADDED
@@ -0,0 +1 @@
1
+ function s(e){let t=e.split("/");return{bucket:t[0],path:t.slice(1).join("/")}}async function n(e){let t=e.path||e._positional?.[0];if(!t){console.error("Error: path argument is required");return}console.log(`Removing: ${t}`);let{bucket:r,path:o}=s(t);o?o.includes("*")?console.log(`Removing objects matching pattern "${o}" in bucket "${r}"`):console.log(`Removing object "${o}" from bucket "${r}"`):console.log(`Removing bucket "${r}"`),console.log("Implementation pending - this would remove buckets, folders, or objects")}export{n as default};
@@ -0,0 +1 @@
1
+ function r(e){let t=e.split("/");return{bucket:t[0],path:t.slice(1).join("/")}}async function n(e){let t=e.path||e._positional?.[0];if(!t){console.error("Error: path argument is required");return}console.log(`Getting details for: ${t}`);let{bucket:o,path:s}=r(t);console.log(s?`Getting object details for "${s}" in bucket "${o}"`:`Getting bucket details for "${o}"`),console.log("Implementation pending - this would show details of buckets, folders, or objects")}export{n as default};
@@ -0,0 +1,14 @@
1
+ import f from"axios";import b from"open";function w(){return{domain:process.env.AUTH0_DOMAIN||"auth-dev.tigris.dev",clientId:process.env.AUTH0_CLIENT_ID||"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF",audience:process.env.AUTH0_AUDIENCE||"https://tigris-api-dev"}}var y="https://tigris";import{homedir as O}from"os";import{join as T}from"path";import{readFileSync as z,writeFileSync as P,existsSync as C,mkdirSync as S}from"fs";import{chmod as N}from"fs/promises";var u=T(O(),".tigris"),l=T(u,"config.json");function E(){C(u)||S(u,{recursive:!0,mode:448})}function c(){if(C(l))try{let t=z(l,"utf8");return JSON.parse(t)}catch{return{}}return{}}async function d(t){E(),P(l,JSON.stringify(t,null,2),{mode:384});try{await N(l,384)}catch{}}async function p(t){let e=c();e.tokens=t,await d(e)}async function g(){return c().tokens||null}async function m(){let t=c();delete t.tokens,await d(t)}async function v(t){let e=c();e.organizations=t,await d(e)}function _(){return c().organizations||[]}function A(){return c().selectedOrganization||null}async function x(t){let e=c();e.loginMethod=t,await d(e)}var k=class{config;baseUrl;constructor(){this.config=w(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
2
+ `);try{let n=(await f.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;console.log("\u{1F4F1} Please authenticate in your browser:");try{await b(n.verification_uri_complete)}catch{console.log(`Visit: ${n.verification_uri} and Enter code: ${n.user_code}
3
+ `)}console.log(`\u23F3 Waiting for authentication...
4
+ `);let o=await this.pollForToken(n.device_code,n.interval||5);await p(o),x("oauth"),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
5
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let a=0;for(;a<60;){a++;try{let r=(await f.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,s=Date.now()+(r.expires_in||3600)*1e3;return{accessToken:r.access_token,refreshToken:r.refresh_token,idToken:r.id_token,expiresAt:s}}catch(i){if(f.isAxiosError(i)&&i.response){let r=i.response.data?.error;if(r==="authorization_pending"){await this.sleep(n*1e3);continue}if(r==="slow_down"){n+=5,await this.sleep(n*1e3);continue}throw new Error(i.response.data?.error_description||"Authentication failed")}throw i}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await g();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let n=300*1e3;return Date.now()+n>=e.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){if(!e.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await f.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:e.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,a={accessToken:o.access_token,refreshToken:o.refresh_token||e.refreshToken,idToken:o.id_token||e.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await p(a),a}catch{throw await m(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await g();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let n=e.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(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let n=e.split(".")[1],o=Buffer.from(n,"base64").toString("utf8"),i=JSON.parse(o)[y];if(!i){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let r=i?.ns?.map(s=>typeof s=="object"&&s!==null?{id:s.id,name:s.name,displayName:s.name}:{id:s,name:s,displayName:s})||[];if(r.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}v(r),console.log(`\u{1F4C2} Found ${r.length} organization(s)`)}catch{console.error("Failed to extract organizations from token")}}async getOrganizations(){return await this.getAccessToken(),_()}async logout(){await m(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await g()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},h=null;function I(){return h||(h=new k),h}async function $(){try{let t=I();if(!await t.isAuthenticated()){console.log("\u274C Not authenticated"),console.log(`\u{1F4A1} Run "tigris login" to authenticate
6
+ `);return}let n=await t.getIdTokenClaims(),o=await t.getOrganizations(),a=A();if(console.log(`
7
+ \u{1F464} User Information:`),console.log(` Email: ${n.email||"N/A"}`),console.log(` User ID: ${n.sub}`),o.length>0){if(console.log(`
8
+ \u{1F4C2} Organizations (${o.length}):`),o.forEach(i=>{let s=i.id===a?"\u2192":" ";console.log(` ${s} ${i.name} (${i.id})`)}),a){let i=o.find(r=>r.id===a);i&&console.log(`
9
+ \u2713 Active: ${i.name}`)}}else console.log(`
10
+ \u{1F4C2} Organizations: None`);console.log()}catch(t){t instanceof Error?console.error(`
11
+ \u274C ${t.message}
12
+ `):console.error(`
13
+ \u274C Failed to retrieve user information
14
+ `),process.exit(1)}}export{$ as default};
@@ -0,0 +1,577 @@
1
+ name: tigris
2
+ alias: t3
3
+ description: Command line interface for Tigris
4
+ version: 0.0.1
5
+ commands:
6
+ #########################
7
+ # Unix style commands
8
+ #########################
9
+
10
+ # ls
11
+ - name: ls
12
+ description: List buckets or objects in a bucket or path
13
+ alias: list
14
+ arguments:
15
+ - name: path
16
+ required: true
17
+ type: noun
18
+ description: a bucket or path in a bucket
19
+ examples:
20
+ - my-bucket
21
+ - my-bucket/my-path
22
+
23
+ # mk
24
+ - name: mk
25
+ description: Create a bucket or a folder in a bucket
26
+ alias: create
27
+ arguments:
28
+ - name: path
29
+ required: true
30
+ type: noun
31
+ description: a bucket or a folder in a bucket
32
+ examples:
33
+ - my-bucket
34
+ - my-bucket/my-path
35
+
36
+ # stat
37
+ - name: stat
38
+ description: Get the details of a bucket or a folder in a bucket or an object in a bucket or path
39
+ arguments:
40
+ - name: path
41
+ required: true
42
+ type: noun
43
+ description: a bucket or a folder in a bucket or an object in a bucket or path
44
+ examples:
45
+ - my-bucket
46
+ - my-bucket/my-path
47
+ - my-bucket/my-path/my-object.json
48
+
49
+ # cp
50
+ - name: cp
51
+ description: Copy a folder or an object
52
+ alias: copy
53
+ arguments:
54
+ - name: src
55
+ required: true
56
+ type: noun
57
+ description: a bucket, a folder in a bucket, an object in a bucket / path. Wildcard is supported.
58
+ examples:
59
+ - my-bucket
60
+ - my-bucket/my-path
61
+ - my-bucket/my-path/my-object.json
62
+ - name: dest
63
+ required: true
64
+ type: noun
65
+ description: path to copy to
66
+ examples:
67
+ - my-bucket
68
+ - my-bucket/my-path
69
+ - my-bucket/my-path/*
70
+ - my-bucket/my-path/my-object.json
71
+
72
+ # mv
73
+ - name: mv
74
+ description: Move a folder or an object
75
+ alias: move
76
+ arguments:
77
+ - name: src
78
+ type: noun
79
+ required: true
80
+ description: path to move from
81
+ examples:
82
+ - my-bucket
83
+ - my-bucket/my-path
84
+ - my-bucket/my-path/*
85
+ - my-bucket/my-path/my-object.json
86
+ - name: dest
87
+ type: noun
88
+ required: true
89
+ description: path to move to
90
+ examples:
91
+ - my-bucket
92
+ - my-bucket/new-path
93
+
94
+ # rm
95
+ - name: rm
96
+ description: Remove a bucket or a folder in a bucket or an object in a bucket or path
97
+ alias: remvoe
98
+ arguments:
99
+ - name: path
100
+ type: noun
101
+ required: true
102
+ description: a bucket, a folder in a bucket, an object in a bucket / path. Wildcard is supported.
103
+ examples:
104
+ - my-bucket
105
+ - my-bucket/my-path
106
+ - my-bucket/my-path/*
107
+ - my-bucket/my-path/my-object.json
108
+
109
+ #########################
110
+ # Authentication
111
+ #########################
112
+ # logout
113
+ - name: logout
114
+ description: Logout from Tigris
115
+
116
+ # whoami
117
+ - name: whoami
118
+ description: Show information about the current user
119
+ alias: w
120
+
121
+ # configure
122
+ - name: configure
123
+ description: Configure Tigris credentials interactively
124
+ alias: c
125
+ arguments:
126
+ - name: access-key
127
+ description: Tigris Access key ID
128
+ alias: key
129
+ required: false
130
+ - name: access-secret
131
+ description: Tigris Access secret
132
+ alias: secret
133
+ required: false
134
+ - name: endpoint
135
+ description: Tigris Endpoint
136
+ alias: e
137
+ required: false
138
+
139
+ # login
140
+ - name: login
141
+ description: Login to Tigris (interactive selection between user and machine)
142
+ alias: l
143
+ arguments:
144
+ - name: access-key
145
+ description: Access key (optional, will use credentials flow if provided)
146
+ alias: key
147
+ required: false
148
+ - name: access-secret
149
+ description: Access secret (optional, will use credentials flow if provided)
150
+ alias: secret
151
+ required: false
152
+ - name: profile
153
+ description: Use saved credentials profile (loads from ~/.tigris/credentials.json)
154
+ alias: p
155
+ required: false
156
+ type: flag
157
+ - name: oauth
158
+ description: Login as a user (OAuth2 flow)
159
+ alias: o
160
+ required: false
161
+ type: flag
162
+ operations:
163
+ # login (main interactive operation)
164
+ - name: select
165
+ description: Interactive selection between user and machine login
166
+ arguments:
167
+ - name: access-key
168
+ description: Access key (optional, will use credentials flow if provided)
169
+ alias: key
170
+ required: false
171
+ - name: access-secret
172
+ description: Access secret (optional, will use credentials flow if provided)
173
+ alias: secret
174
+ required: false
175
+ - name: profile
176
+ description: Use saved credentials profile (loads from ~/.tigris/credentials.json)
177
+ alias: p
178
+ required: false
179
+ type: flag
180
+ - name: oauth
181
+ description: Login as a user (OAuth2 flow)
182
+ alias: o
183
+ required: false
184
+ type: flag
185
+ # ui
186
+ - name: ui
187
+ description: Login as a user (OAuth2 flow)
188
+ alias: u
189
+ # credentials
190
+ - name: credentials
191
+ description: Login as a machine (with access key and secret)
192
+ alias: c
193
+ arguments:
194
+ - name: access-key
195
+ description: Access key (optional, will prompt or use saved credentials if not provided)
196
+ alias: key
197
+ required: false
198
+ - name: access-secret
199
+ description: Access secret (optional, will prompt or use saved credentials if not provided)
200
+ alias: secret
201
+ required: false
202
+ default: select
203
+
204
+ #########################
205
+ # Manage organizations
206
+ #########################
207
+ - name: orgs
208
+ description: Manage organizations
209
+ operations:
210
+ # list
211
+ - name: list
212
+ description: List organizations
213
+ alias: l
214
+ arguments:
215
+ - name: format
216
+ description: Format
217
+ alias: f
218
+ options: [json, table, xml, select]
219
+ default: select
220
+ - name: select
221
+ description: Interactive selection mode
222
+ alias: i
223
+ type: flag
224
+ - name: create
225
+ description: Create organization
226
+ alias: c
227
+ arguments:
228
+ - name: name
229
+ description: Name of the organization
230
+ alias: n
231
+ required: true
232
+ - name: description
233
+ description: Description of the organization
234
+ alias: d
235
+ - name: select
236
+ description: Select the organization to use
237
+ alias: s
238
+ arguments:
239
+ - name: name
240
+ type: noun
241
+ required: true
242
+ description: Name of the organization
243
+
244
+ #########################
245
+ # Manage buckets
246
+ #########################
247
+ - name: buckets
248
+ description: Manage buckets
249
+ alias: b
250
+ operations:
251
+ # list
252
+ - name: list
253
+ description: List buckets
254
+ alias: l
255
+ arguments:
256
+ - name: format
257
+ description: Format
258
+ alias: f
259
+ options: [json, table, xml]
260
+ default: table
261
+ # create
262
+ - name: create
263
+ description: Create bucket
264
+ alias: [c]
265
+ arguments:
266
+ - name: name
267
+ description: Name of the bucket
268
+ type: noun
269
+ required: true
270
+ - name: access
271
+ description: Access level
272
+ alias: a
273
+ options: [public, private]
274
+ default: private
275
+ - name: default-tier
276
+ description: Choose the default tier for the bucket
277
+ alias: t
278
+ options:
279
+ - name: Standard
280
+ value: STANDARD
281
+ description: The default storage class. It provides high durability, availability, and performance for frequently accessed data.
282
+ - name: Infrequent Access
283
+ value: STANDARD_IA
284
+ description: Lower-cost storage for data that is accessed less frequently but requires rapid access when needed.
285
+ - name: Archive
286
+ value: GLACIER
287
+ description: Low-cost storage for data archiving. Long-term data archiving with infrequent access.
288
+ - name: Instant Retrieval Archive
289
+ value: GLACIER_IR
290
+ description: Lowest-cost storage for long-lived data that is rarely accessed and requires retrieval in milliseconds.
291
+ default: STANDARD
292
+ - name: consistency
293
+ description: Choose the consistency level for the bucket
294
+ alias: c
295
+ options:
296
+ - name: Default
297
+ value: default
298
+ description: Strict read-after-write consistency in same region. Eventual consistency globally.
299
+ - name: Strict
300
+ value: strict
301
+ description: Strict read-after-write consistency globally. Latency will be higher than the default.
302
+ default: default
303
+ - name: region
304
+ description: Region
305
+ alias: r
306
+ options:
307
+ - name: Global
308
+ value: ''
309
+ description: Global
310
+ - name: USA
311
+ value: usa
312
+ description: Restrict to USA
313
+ - name: Europe
314
+ value: eur
315
+ description: Restrict to Europe
316
+ - name: Amsterdam, Netherlands
317
+ value: ams
318
+ description: Amsterdam, Netherlands
319
+ - name: Frankfurt, Germany
320
+ value: fra
321
+ description: Frankfurt, Germany
322
+ - name: Sao Paulo, Brazil
323
+ value: gru
324
+ description: Sao Paulo, Brazil
325
+ - name: Ashburn, Virginia (US)
326
+ value: iad
327
+ description: Ashburn, Virginia (US)
328
+ - name: Johannesburg, South Africa
329
+ value: jnb
330
+ description: Johannesburg, South Africa
331
+ - name: London, United Kingdom
332
+ value: lhr
333
+ description: London, United Kingdom
334
+ - name: Tokyo, Japan
335
+ value: nrt
336
+ description: Tokyo, Japan
337
+ - name: Chicago, Illinois (US)
338
+ value: ord
339
+ description: Chicago, Illinois (US)
340
+ - name: Singapore, Singapore
341
+ value: sin
342
+ description: Singapore, Singapore
343
+ - name: San Jose, California (US)
344
+ value: sjc
345
+ description: San Jose, California (US)
346
+ - name: Sydney, Australia
347
+ value: syd
348
+ description: Sydney, Australia
349
+ default: ''
350
+ - name: Cache Control
351
+ description: This lets you set the default Cache-Control header for objects in the bucket. Tigris will set some cache control headers by default for public objects, but you can set an implicit default here.
352
+ alias: cc
353
+ - name: Delete Protection
354
+ description: This lets you enable or disable delete protection for the bucket. When enabled, objects in the bucket cannot be deleted.
355
+ alias: dp
356
+ options:
357
+ - name: Enabled
358
+ value: enabled
359
+ description: Enabled
360
+ - name: Disabled
361
+ value: disabled
362
+ description: Disabled
363
+ default: disabled
364
+ # get
365
+ - name: get
366
+ description: Get bucket details
367
+ alias: g
368
+ arguments:
369
+ - name: name
370
+ description: Name of the bucket
371
+ type: noun
372
+ required: true
373
+ # delete
374
+ - name: delete
375
+ description: Delete bucket
376
+ alias: d
377
+ arguments:
378
+ - name: name
379
+ description: Name of the bucket or comma separated list of buckets
380
+ type: noun
381
+ required: true
382
+ multiple: true
383
+
384
+ #########################
385
+ # Manage forks
386
+ #########################
387
+ - name: forks
388
+ description: Manage forks
389
+ alias: f
390
+ operations:
391
+ # list
392
+ - name: list
393
+ description: List forks
394
+ alias: l
395
+ arguments:
396
+ - name: name
397
+ description: Name of the bucket
398
+ type: noun
399
+ required: true
400
+ # create
401
+ - name: create
402
+ description: Create fork
403
+ alias: c
404
+ arguments:
405
+ - name: name
406
+ description: Name of the bucket
407
+ type: noun
408
+ required: true
409
+ - name: fork-name
410
+ description: Name of the fork
411
+ type: noun
412
+ required: true
413
+
414
+ #########################
415
+ # Manage snapshots
416
+ #########################
417
+ - name: snapshots
418
+ description: Manage snapshots
419
+ alias: s
420
+ operations:
421
+ # list
422
+ - name: list
423
+ description: List snapshots
424
+ alias: l
425
+ arguments:
426
+ - name: name
427
+ description: Name of the bucket
428
+ type: noun
429
+ required: true
430
+ # create
431
+ - name: create
432
+ description: Create snapshot
433
+ alias: c
434
+ arguments:
435
+ - name: name
436
+ description: Name of the bucket
437
+ type: noun
438
+ required: true
439
+ - name: snapshot-name
440
+ description: Name of the snapshot
441
+ type: noun
442
+ required: true
443
+
444
+ #########################
445
+ # Manage objects
446
+ #########################
447
+ - name: objects
448
+ description: Manage objects
449
+ alias: o
450
+ operations:
451
+ # list
452
+ - name: list
453
+ description: List objects
454
+ alias: l
455
+ arguments:
456
+ - name: bucket
457
+ description: Name of the bucket
458
+ alias: b
459
+ required: true
460
+ - name: format
461
+ description: Format
462
+ alias: f
463
+ options: [json, table, xml]
464
+ default: table
465
+ # get
466
+ - name: get
467
+ description: Get object
468
+ alias: g
469
+ arguments:
470
+ - name: bucket
471
+ description: Name of the bucket
472
+ type: noun
473
+ required: true
474
+ - name: key
475
+ description: Name of the object
476
+ type: noun
477
+ required: true
478
+ - name: format
479
+ description: Format
480
+ alias: f
481
+ options: [string, file, stream]
482
+ default: string
483
+ # create
484
+ - name: create
485
+ description: Create object
486
+ alias: c
487
+ arguments:
488
+ - name: bucket
489
+ description: Name of the bucket
490
+ type: noun
491
+ required: true
492
+ - name: name
493
+ description: Name of the object
494
+ type: noun
495
+ required: true
496
+ - name: body
497
+ description: Body of the object
498
+ alias: d
499
+ required: true
500
+ - name: access
501
+ description: Access level
502
+ alias: a
503
+ options: [public, private]
504
+ default: private
505
+ - name: content-type
506
+ description: Content type
507
+ alias: c
508
+ - name: content-disposition
509
+ description: Content disposition
510
+ alias: d
511
+ - name: tier
512
+ description: Tier
513
+ alias: t
514
+ options:
515
+ - name: Standard
516
+ value: STANDARD
517
+ description: The default storage class. It provides high durability, availability, and performance for frequently accessed data.
518
+ - name: Infrequent Access
519
+ value: STANDARD_IA
520
+ description: Lower-cost storage for data that is accessed less frequently but requires rapid access when needed.
521
+ - name: Archive
522
+ value: GLACIER
523
+ description: Low-cost storage for data archiving. Long-term data archiving with infrequent access.
524
+ - name: Instant Retrieval Archive
525
+ value: GLACIER_IR
526
+ description: Lowest-cost storage for long-lived data that is rarely accessed and requires retrieval in milliseconds.
527
+ default: STANDARD
528
+ # delete
529
+ - name: delete
530
+ description: Delete object
531
+ alias: d
532
+ arguments:
533
+ - name: bucket
534
+ description: Name of the bucket
535
+ type: noun
536
+ required: true
537
+ - name: key
538
+ description: Name of the object (comma separated names for multiple objects)
539
+ type: noun
540
+ required: true
541
+ multiple: true
542
+ # copy
543
+ - name: copy
544
+ description: Copy object
545
+ alias: c
546
+ arguments:
547
+ - name: bucket
548
+ description: Name of the bucket
549
+ type: noun
550
+ required: true
551
+ - name: name
552
+ description: Name of the object (comma separated names for multiple objects)
553
+ type: noun
554
+ required: true
555
+ multiple: true
556
+ - name: destination
557
+ description: Destination
558
+ type: noun
559
+ required: true
560
+ # move
561
+ - name: move
562
+ description: Move object
563
+ alias: m
564
+ arguments:
565
+ - name: bucket
566
+ description: Name of the bucket
567
+ type: noun
568
+ required: true
569
+ - name: source
570
+ description: Name of the object (comma separated names for multiple objects)
571
+ type: noun
572
+ required: true
573
+ multiple: true
574
+ - name: destination
575
+ description: Destination
576
+ type: noun
577
+ required: true
package/dist/types.js ADDED
File without changes
@@ -0,0 +1,6 @@
1
+ function g(r){return JSON.stringify(r,null,2)}function h(r,t=" "){return Object.entries(r).map(([n,e])=>`${t}<${n}>${e}</${n}>`).join(`
2
+ `)}function c(r,t,n){let e=[`<${t}>`];return r.forEach(o=>{e.push(` <${n}>`),e.push(h(o," ")),e.push(` </${n}>`)}),e.push(`</${t}>`),e.join(`
3
+ `)}function f(r,t){let n=[],e="\u250C"+t.map(i=>"\u2500".repeat(i.width+2)).join("\u252C")+"\u2510",o="\u251C"+t.map(i=>"\u2500".repeat(i.width+2)).join("\u253C")+"\u2524",u="\u2514"+t.map(i=>"\u2500".repeat(i.width+2)).join("\u2534")+"\u2518";n.push(`
4
+ `+e);let p="\u2502 "+t.map(i=>i.header.padEnd(i.width)).join(" \u2502 ")+" \u2502";return n.push(p),n.push(o),r.forEach(i=>{let d=t.map(s=>{let a=String(i[s.key]??"");return s.align==="right"?a.padStart(s.width):a.padEnd(s.width)});n.push("\u2502 "+d.join(" \u2502 ")+" \u2502")}),n.push(u+`
5
+ `),n.join(`
6
+ `)}function w(r,t,n,e,o){switch(t){case"json":return g(r);case"xml":return c(r,n,e);default:return f(r,o)}}export{g as formatJson,w as formatOutput,f as formatTable,c as formatXml,h as formatXmlObject};
@@ -0,0 +1 @@
1
+ function f(n,r,t){for(let e of r)if(n[e]!==void 0)return n[e];return t}export{f as getOption};
@@ -0,0 +1 @@
1
+ function r(s){let t=s.split("/");return{bucket:t[0],path:t.slice(1).join("/")}}function e(s,t){return{source:r(s),destination:r(t)}}export{r as parsePath,e as parsePaths};
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@tigrisdata/cli",
3
- "version": "1.6.3",
3
+ "version": "2.0.0",
4
4
  "description": "Command line interface for Tigris object storage",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./dist/cli.js",
9
- "require": "./dist/cli.cjs"
8
+ "import": "./dist/cli.js"
10
9
  }
11
10
  },
12
11
  "bin": {
13
- "tigris": "./dist/cli.js"
12
+ "tigris": "./dist/cli.js",
13
+ "t3": "./dist/cli.js"
14
14
  },
15
15
  "files": [
16
16
  "dist",
@@ -22,9 +22,16 @@
22
22
  "scripts": {
23
23
  "build": "tsup",
24
24
  "dev": "tsup --watch",
25
+ "lint": "eslint src --ext .ts",
26
+ "lint:fix": "eslint src --ext .ts --fix",
27
+ "format": "prettier --write \"src/**/*.ts\"",
28
+ "format:check": "prettier --check \"src/**/*.ts\"",
25
29
  "publint": "publint",
26
30
  "prepublishOnly": "npm run build",
27
- "clean": "rm -rf dist"
31
+ "clean": "rm -rf dist",
32
+ "commit": "cz",
33
+ "semantic-release": "semantic-release",
34
+ "prepare": "husky install"
28
35
  },
29
36
  "keywords": [
30
37
  "cli",
@@ -36,12 +43,59 @@
36
43
  "author": "Tigris Data",
37
44
  "repository": {
38
45
  "type": "git",
39
- "url": "git+https://github.com/tigrisdata/storage.git",
40
- "directory": "packages/cli"
46
+ "url": "git+https://github.com/tigrisdata/cli.git"
41
47
  },
42
48
  "license": "MIT",
49
+ "config": {
50
+ "commitizen": {
51
+ "path": "cz-conventional-changelog"
52
+ }
53
+ },
54
+ "commitlint": {
55
+ "extends": [
56
+ "@commitlint/config-conventional"
57
+ ]
58
+ },
59
+ "release": {
60
+ "branches": [
61
+ "main",
62
+ {
63
+ "name": "next",
64
+ "prerelease": true
65
+ }
66
+ ],
67
+ "plugins": [
68
+ "@semantic-release/commit-analyzer",
69
+ "@semantic-release/release-notes-generator",
70
+ "@semantic-release/github",
71
+ "@semantic-release/npm"
72
+ ]
73
+ },
43
74
  "dependencies": {
75
+ "@aws-sdk/client-s3": "^3.908.0",
44
76
  "@tigrisdata/storage": "*",
45
- "commander": "^11.0.0"
77
+ "axios": "^1.12.2",
78
+ "commander": "^11.0.0",
79
+ "enquirer": "^2.4.1",
80
+ "open": "^10.2.0",
81
+ "yaml": "^2.3.4"
82
+ },
83
+ "devDependencies": {
84
+ "@commitlint/cli": "^18.0.0",
85
+ "@commitlint/config-conventional": "^18.0.0",
86
+ "@semantic-release/changelog": "^6.0.0",
87
+ "@semantic-release/git": "^10.0.0",
88
+ "@types/node": "^20.0.0",
89
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
90
+ "@typescript-eslint/parser": "^6.0.0",
91
+ "commitizen": "^4.3.0",
92
+ "cz-conventional-changelog": "^3.3.0",
93
+ "eslint": "^8.0.0",
94
+ "husky": "^8.0.0",
95
+ "prettier": "^3.0.0",
96
+ "publint": "^0.2.0",
97
+ "semantic-release": "^22.0.0",
98
+ "tsup": "^8.0.0",
99
+ "typescript": "^5.0.0"
46
100
  }
47
101
  }
package/dist/cli.cjs DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- // src/cli.ts
5
- var import_commander = require("commander");
6
- var program = new import_commander.Command();
7
- program.name("tigris").description("Command line interface for Tigris object storage").version("0.0.1");
8
- program.parse();
9
- //# sourceMappingURL=cli.cjs.map
package/dist/cli.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\n\nconst program = new Command();\n\nprogram\n .name('tigris')\n .description('Command line interface for Tigris object storage')\n .version('0.0.1');\n\nprogram.parse();\n"],"mappings":";;;;AAEA,uBAAwB;AAExB,IAAM,UAAU,IAAI,yBAAQ;AAE5B,QACG,KAAK,QAAQ,EACb,YAAY,kDAAkD,EAC9D,QAAQ,OAAO;AAElB,QAAQ,MAAM;","names":[]}
package/dist/cli.d.cts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\n\nconst program = new Command();\n\nprogram\n .name('tigris')\n .description('Command line interface for Tigris object storage')\n .version('0.0.1');\n\nprogram.parse();\n"],"mappings":";;;AAEA,SAAS,eAAe;AAExB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,QAAQ,EACb,YAAY,kDAAkD,EAC9D,QAAQ,OAAO;AAElB,QAAQ,MAAM;","names":[]}