@tigrisdata/cli 1.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.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @tigrisdata/cli
2
+
3
+ Command line interface for Tigris object storage.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @tigrisdata/cli
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ WIP
14
+
15
+ ## License
16
+
17
+ MIT
@@ -0,0 +1,8 @@
1
+ import p from"axios";import F from"open";import{readFileSync as O,existsSync as C}from"fs";import{join as E}from"path";var w=!1;function N(){if(!w){try{let s=E(process.cwd(),".env");if(C(s)){let t=O(s,"utf8").split(`
2
+ `);for(let o of t){let a=o.trim();if(!a||a.startsWith("#"))continue;let r=a.match(/^([^=]+)=(.*)$/);if(r){let i=r[1].trim(),n=r[2].trim();(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),process.env[i]||(process.env[i]=n)}}}}catch{}w=!0}}function y(){return N(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var _="https://tigris";import{homedir as P}from"os";import{join as u}from"path";import{readFileSync as v,writeFileSync as A,existsSync as f,mkdirSync as z,unlinkSync as b}from"fs";import{chmod as D}from"fs/promises";var l=u(P(),".tigris"),c=u(l,"tokens.json"),g=u(l,"organizations.json"),G=u(l,"selected-org");function S(){f(l)||z(l,{recursive:!0,mode:448})}async function h(s){S(),A(c,JSON.stringify(s,null,2),{mode:384});try{await D(c,384)}catch{}}async function d(){if(f(c))try{let s=v(c,"utf8");return JSON.parse(s)}catch{return null}return null}async function m(){if(f(c))try{b(c)}catch{}}function x(s){S(),A(g,JSON.stringify(s,null,2),{mode:384})}function I(){if(f(g))try{let s=v(g,"utf8");return JSON.parse(s)}catch{return[]}return[]}var T=class{config;baseUrl;constructor(){this.config=y(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
3
+ `);try{let t=(await p.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:"),console.log(`
4
+ ${t.verification_uri_complete}
5
+ `),console.log(` Or visit: ${t.verification_uri}`),console.log(` And enter code: ${t.user_code}
6
+ `);try{await F(t.verification_uri_complete)}catch{}console.log(`\u23F3 Waiting for authentication...
7
+ `);let o=await this.pollForToken(t.device_code,t.interval||5);await h(o),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
8
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,t){let a=0;for(;a<60;){a++;try{let i=(await p.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,n=Date.now()+(i.expires_in||3600)*1e3;return{accessToken:i.access_token,refreshToken:i.refresh_token,idToken:i.id_token,expiresAt:n}}catch(r){if(p.isAxiosError(r)&&r.response){let i=r.response.data?.error;if(i==="authorization_pending"){await this.sleep(t*1e3);continue}if(i==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(r.response.data?.error_description||"Authentication failed")}throw r}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await d();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 p.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 h(a),a}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 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"),r=JSON.parse(o)[_];if(!r){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let i=r?.ns?.map(n=>typeof n=="object"&&n!==null?{id:n.id,name:n.name,displayName:n.name}:{id:n,name:n,displayName:n})||[];if(i.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}x(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(),I()}async logout(){await m(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await d()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},k=null;function Q(){return k||(k=new T),k}export{T as TigrisAuthClient,Q as getAuthClient};
@@ -0,0 +1,2 @@
1
+ import{readFileSync as a,existsSync as f}from"fs";import{join as d}from"path";var o=!1;function u(){if(!o){try{let e=d(process.cwd(),".env");if(f(e)){let r=a(e,"utf8").split(`
2
+ `);for(let c of r){let n=c.trim();if(!n||n.startsWith("#"))continue;let i=n.match(/^([^=]+)=(.*)$/);if(i){let s=i[1].trim(),t=i[2].trim();(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),process.env[s]||(process.env[s]=t)}}}}catch{}o=!0}}function l(){return u(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var v="https://tigris";export{v as TIGRIS_CLAIMS_NAMESPACE,l as getAuth0Config};
@@ -0,0 +1 @@
1
+ import{homedir as m}from"os";import{join as c}from"path";import{readFileSync as s,writeFileSync as a,existsSync as o,mkdirSync as d,unlinkSync as l}from"fs";import{chmod as y}from"fs/promises";var r=c(m(),".tigris"),n=c(r,"tokens.json"),i=c(r,"organizations.json"),e=c(r,"selected-org");function f(){o(r)||d(r,{recursive:!0,mode:448})}async function x(t){f(),a(n,JSON.stringify(t,null,2),{mode:384});try{await y(n,384)}catch{}}async function h(){if(o(n))try{let t=s(n,"utf8");return JSON.parse(t)}catch{return null}return null}async function g(){if(o(n))try{l(n)}catch{}}function z(t){f(),a(i,JSON.stringify(t,null,2),{mode:384})}function I(){if(o(i))try{let t=s(i,"utf8");return JSON.parse(t)}catch{return[]}return[]}function T(t){f(),a(e,t,{mode:384})}function v(){if(o(e))try{return s(e,"utf8").trim()}catch{return null}return null}async function E(){await g();let t=[i,e];for(let u of t)if(o(u))try{l(u)}catch{}}export{E as clearAllData,g as clearTokens,I as getOrganizations,v as getSelectedOrganization,h as getTokens,z as storeOrganizations,T as storeSelectedOrganization,x as storeTokens};
File without changes
package/dist/cli.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
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,6 @@
1
+ function c(t,n,e){for(let r of n)if(t[r]!==void 0)return t[r];return e}function p(t){return JSON.stringify(t,null,2)}function f(t,n=" "){return Object.entries(t).map(([e,r])=>`${n}<${e}>${r}</${e}>`).join(`
2
+ `)}function l(t,n,e){let r=[`<${n}>`];return t.forEach(o=>{r.push(` <${e}>`),r.push(f(o," ")),r.push(` </${e}>`)}),r.push(`</${n}>`),r.join(`
3
+ `)}function m(t,n){let e=[],r="\u250C"+n.map(i=>"\u2500".repeat(i.width+2)).join("\u252C")+"\u2510",o="\u251C"+n.map(i=>"\u2500".repeat(i.width+2)).join("\u253C")+"\u2524",d="\u2514"+n.map(i=>"\u2500".repeat(i.width+2)).join("\u2534")+"\u2518";e.push(`
4
+ `+r);let g="\u2502 "+n.map(i=>i.header.padEnd(i.width)).join(" \u2502 ")+" \u2502";return e.push(g),e.push(o),t.forEach(i=>{let h=n.map(s=>{let a=String(i[s.key]??"");return s.align==="right"?a.padStart(s.width):a.padEnd(s.width)});e.push("\u2502 "+h.join(" \u2502 ")+" \u2502")}),e.push(d+`
5
+ `),e.join(`
6
+ `)}function u(t,n,e,r,o){switch(n){case"json":return p(t);case"xml":return l(t,e,r);default:return m(t,o)}}async function w(t){console.log("\u{1FAA3} Listing Buckets");let n=c(t,["format","F"],"table"),e=[{name:"user-uploads",access:"private",tier:"STANDARD",region:"usa",objects:1250,size:"2.3 GB",created:"2024-01-15"},{name:"static-assets",access:"public",tier:"STANDARD",region:"global",objects:45,size:"156 MB",created:"2024-02-01"},{name:"backups",access:"private",tier:"GLACIER",region:"eur",objects:89,size:"8.7 GB",created:"2024-01-20"}],r=u(e,n,"buckets","bucket",[{key:"name",header:"Name",width:15},{key:"access",header:"Access",width:7},{key:"tier",header:"Tier",width:9},{key:"region",header:"Region",width:6},{key:"objects",header:"Objects",width:7,align:"right"},{key:"size",header:"Size",width:8,align:"right"},{key:"created",header:"Created",width:10}]);console.log(r),console.log(`Found ${e.length} bucket(s)`)}export{w 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 p from"axios";import R from"open";import{readFileSync as O,existsSync as P}from"fs";import{join as E}from"path";var y=!1;function N(){if(!y){try{let o=E(process.cwd(),".env");if(P(o)){let t=O(o,"utf8").split(`
2
+ `);for(let i of t){let a=i.trim();if(!a||a.startsWith("#"))continue;let s=a.match(/^([^=]+)=(.*)$/);if(s){let r=s[1].trim(),n=s[2].trim();(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),process.env[r]||(process.env[r]=n)}}}}catch{}y=!0}}function T(){return N(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var _="https://tigris";import{homedir as z}from"os";import{join as u}from"path";import{readFileSync as v,writeFileSync as A,existsSync as f,mkdirSync as b,unlinkSync as D}from"fs";import{chmod as F}from"fs/promises";var l=u(z(),".tigris"),c=u(l,"tokens.json"),g=u(l,"organizations.json"),B=u(l,"selected-org");function x(){f(l)||b(l,{recursive:!0,mode:448})}async function h(o){x(),A(c,JSON.stringify(o,null,2),{mode:384});try{await F(c,384)}catch{}}async function d(){if(f(c))try{let o=v(c,"utf8");return JSON.parse(o)}catch{return null}return null}async function m(){if(f(c))try{D(c)}catch{}}function S(o){x(),A(g,JSON.stringify(o,null,2),{mode:384})}function I(){if(f(g))try{let o=v(g,"utf8");return JSON.parse(o)}catch{return[]}return[]}var w=class{config;baseUrl;constructor(){this.config=T(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
3
+ `);try{let t=(await p.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:"),console.log(`
4
+ ${t.verification_uri_complete}
5
+ `),console.log(` Or visit: ${t.verification_uri}`),console.log(` And enter code: ${t.user_code}
6
+ `);try{await R(t.verification_uri_complete)}catch{}console.log(`\u23F3 Waiting for authentication...
7
+ `);let i=await this.pollForToken(t.device_code,t.interval||5);await h(i),await this.extractAndStoreOrganizations(i.idToken),console.log(`\u2705 Authentication successful!
8
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,t){let a=0;for(;a<60;){a++;try{let r=(await p.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,n=Date.now()+(r.expires_in||3600)*1e3;return{accessToken:r.access_token,refreshToken:r.refresh_token,idToken:r.id_token,expiresAt:n}}catch(s){if(p.isAxiosError(s)&&s.response){let r=s.response.data?.error;if(r==="authorization_pending"){await this.sleep(t*1e3);continue}if(r==="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 d();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 i=(await p.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:i.access_token,refreshToken:i.refresh_token||e.refreshToken,idToken:i.id_token||e.idToken,expiresAt:Date.now()+(i.expires_in||3600)*1e3};return await h(a),a}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 t=e.idToken.split(".")[1],i=Buffer.from(t,"base64").toString("utf8");return JSON.parse(i)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let t=e.split(".")[1],i=Buffer.from(t,"base64").toString("utf8"),s=JSON.parse(i)[_];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let r=s?.ns?.map(n=>typeof n=="object"&&n!==null?{id:n.id,name:n.name,displayName:n.name}:{id:n,name:n,displayName:n})||[];if(r.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}S(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(),I()}async logout(){await m(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await d()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},k=null;function C(){return k||(k=new w),k}async function L(){try{let o=C();if(await o.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.
9
+ `);return}await o.login()}catch{process.exit(1)}}export{L as default};
@@ -0,0 +1,9 @@
1
+ import g from"axios";import $ from"open";import{readFileSync as P,existsSync as E}from"fs";import{join as N}from"path";var T=!1;function z(){if(!T){try{let n=N(process.cwd(),".env");if(E(n)){let t=P(n,"utf8").split(`
2
+ `);for(let i of t){let a=i.trim();if(!a||a.startsWith("#"))continue;let s=a.match(/^([^=]+)=(.*)$/);if(s){let r=s[1].trim(),o=s[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),process.env[r]||(process.env[r]=o)}}}}catch{}T=!0}}function _(){return z(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var v="https://tigris";import{homedir as b}from"os";import{join as u}from"path";import{readFileSync as A,writeFileSync as S,existsSync as d,mkdirSync as D,unlinkSync as F}from"fs";import{chmod as R}from"fs/promises";var l=u(b(),".tigris"),c=u(l,"tokens.json"),p=u(l,"organizations.json"),B=u(l,"selected-org");function x(){d(l)||D(l,{recursive:!0,mode:448})}async function h(n){x(),S(c,JSON.stringify(n,null,2),{mode:384});try{await R(c,384)}catch{}}async function f(){if(d(c))try{let n=A(c,"utf8");return JSON.parse(n)}catch{return null}return null}async function m(){if(d(c))try{F(c)}catch{}}function I(n){x(),S(p,JSON.stringify(n,null,2),{mode:384})}function C(){if(d(p))try{let n=A(p,"utf8");return JSON.parse(n)}catch{return[]}return[]}var y=class{config;baseUrl;constructor(){this.config=_(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
3
+ `);try{let t=(await g.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:"),console.log(`
4
+ ${t.verification_uri_complete}
5
+ `),console.log(` Or visit: ${t.verification_uri}`),console.log(` And enter code: ${t.user_code}
6
+ `);try{await $(t.verification_uri_complete)}catch{}console.log(`\u23F3 Waiting for authentication...
7
+ `);let i=await this.pollForToken(t.device_code,t.interval||5);await h(i),await this.extractAndStoreOrganizations(i.idToken),console.log(`\u2705 Authentication successful!
8
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,t){let a=0;for(;a<60;){a++;try{let r=(await g.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,o=Date.now()+(r.expires_in||3600)*1e3;return{accessToken:r.access_token,refreshToken:r.refresh_token,idToken:r.id_token,expiresAt:o}}catch(s){if(g.isAxiosError(s)&&s.response){let r=s.response.data?.error;if(r==="authorization_pending"){await this.sleep(t*1e3);continue}if(r==="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 f();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 i=(await g.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:i.access_token,refreshToken:i.refresh_token||e.refreshToken,idToken:i.id_token||e.idToken,expiresAt:Date.now()+(i.expires_in||3600)*1e3};return await h(a),a}catch{throw await m(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await f();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let t=e.idToken.split(".")[1],i=Buffer.from(t,"base64").toString("utf8");return JSON.parse(i)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(e){if(!e){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let t=e.split(".")[1],i=Buffer.from(t,"base64").toString("utf8"),s=JSON.parse(i)[v];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let r=s?.ns?.map(o=>typeof o=="object"&&o!==null?{id:o.id,name:o.name,displayName:o.name}:{id:o,name:o,displayName:o})||[];if(r.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}I(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(),C()}async logout(){await m(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await f()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},k=null;function O(){return k||(k=new y),k}async function w(){try{let n=O();if(await n.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.
9
+ `);return}await n.login()}catch{process.exit(1)}}async function L(n){if(console.log("\u{1F510} Tigris Login"),(n.mode||n.M||"ui")==="credentials"){let t=n["access-key"]||n.accessKey||n.Key,i=n["access-secret"]||n.accessSecret||n.Secret;(!t||!i)&&(console.error("\u274C Access key and secret are required for credentials mode"),process.exit(1)),console.log("\u{1F511} Authenticating with credentials..."),console.log(`Access Key: ${t}`),console.log(`Access Secret: ${"*".repeat(String(i).length)}`),console.log("\u2705 Successfully authenticated with credentials")}else await w()}export{L as default};
@@ -0,0 +1,4 @@
1
+ import{homedir as a}from"os";import{join as t}from"path";import{readFileSync as p,writeFileSync as S,existsSync as i,mkdirSync as O,unlinkSync as c}from"fs";var n=t(a(),".tigris"),e=t(n,"tokens.json"),l=t(n,"organizations.json"),u=t(n,"selected-org");async function f(){if(i(e))try{c(e)}catch{}}async function s(){await f();let o=[l,u];for(let r of o)if(i(r))try{c(r)}catch{}}async function g(){try{console.log(`\u{1F513} Logging out...
2
+ `),await s(),console.log("\u2705 Successfully logged out"),console.log(`\u{1F4A1} All stored tokens and data have been cleared
3
+ `)}catch(o){console.error("\u274C Error during logout"),o instanceof Error&&console.error(` ${o.message}
4
+ `),process.exit(1)}}export{g 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,24 @@
1
+ function N(i,n,e){for(let o of n)if(i[o]!==void 0)return i[o];return e}function L(i){return JSON.stringify(i,null,2)}function U(i,n=" "){return Object.entries(i).map(([e,o])=>`${n}<${e}>${o}</${e}>`).join(`
2
+ `)}function J(i,n,e){let o=[`<${n}>`];return i.forEach(r=>{o.push(` <${e}>`),o.push(U(r," ")),o.push(` </${e}>`)}),o.push(`</${n}>`),o.join(`
3
+ `)}function B(i,n){let e=[],o="\u250C"+n.map(t=>"\u2500".repeat(t.width+2)).join("\u252C")+"\u2510",r="\u251C"+n.map(t=>"\u2500".repeat(t.width+2)).join("\u253C")+"\u2524",s="\u2514"+n.map(t=>"\u2500".repeat(t.width+2)).join("\u2534")+"\u2518";e.push(`
4
+ `+o);let a="\u2502 "+n.map(t=>t.header.padEnd(t.width)).join(" \u2502 ")+" \u2502";return e.push(a),e.push(r),i.forEach(t=>{let c=n.map(d=>{let u=String(t[d.key]??"");return d.align==="right"?u.padStart(d.width):u.padEnd(d.width)});e.push("\u2502 "+c.join(" \u2502 ")+" \u2502")}),e.push(s+`
5
+ `),e.join(`
6
+ `)}function C(i,n,e,o,r){switch(n){case"json":return L(i);case"xml":return J(i,e,o);default:return B(i,r)}}import w from"axios";import Q from"open";import{readFileSync as W,existsSync as G}from"fs";import{join as M}from"path";var E=!1;function H(){if(!E){try{let i=M(process.cwd(),".env");if(G(i)){let e=W(i,"utf8").split(`
7
+ `);for(let o of e){let r=o.trim();if(!r||r.startsWith("#"))continue;let s=r.match(/^([^=]+)=(.*)$/);if(s){let a=s[1].trim(),t=s[2].trim();(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),process.env[a]||(process.env[a]=t)}}}}catch{}E=!0}}function $(){return H(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var b="https://tigris";import{homedir as X}from"os";import{join as m}from"path";import{readFileSync as _,writeFileSync as x,existsSync as g,mkdirSync as q,unlinkSync as K}from"fs";import{chmod as Y}from"fs/promises";var p=m(X(),".tigris"),l=m(p,"tokens.json"),y=m(p,"organizations.json"),T=m(p,"selected-org");function v(){g(p)||q(p,{recursive:!0,mode:448})}async function S(i){v(),x(l,JSON.stringify(i,null,2),{mode:384});try{await Y(l,384)}catch{}}async function h(){if(g(l))try{let i=_(l,"utf8");return JSON.parse(i)}catch{return null}return null}async function O(){if(g(l))try{K(l)}catch{}}function P(i){v(),x(y,JSON.stringify(i,null,2),{mode:384})}function R(){if(g(y))try{let i=_(y,"utf8");return JSON.parse(i)}catch{return[]}return[]}function j(i){v(),x(T,i,{mode:384})}function F(){if(g(T))try{return _(T,"utf8").trim()}catch{return null}return null}var z=class{config;baseUrl;constructor(){this.config=$(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
8
+ `);try{let e=(await w.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:"),console.log(`
9
+ ${e.verification_uri_complete}
10
+ `),console.log(` Or visit: ${e.verification_uri}`),console.log(` And enter code: ${e.user_code}
11
+ `);try{await Q(e.verification_uri_complete)}catch{}console.log(`\u23F3 Waiting for authentication...
12
+ `);let o=await this.pollForToken(e.device_code,e.interval||5);await S(o),await this.extractAndStoreOrganizations(o.idToken),console.log(`\u2705 Authentication successful!
13
+ `)}catch(n){throw n instanceof Error?console.error(`\u274C Authentication failed: ${n.message}`):console.error("\u274C Authentication failed"),n}}async pollForToken(n,e){let r=0;for(;r<60;){r++;try{let a=(await w.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,device_code:n,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,t=Date.now()+(a.expires_in||3600)*1e3;return{accessToken:a.access_token,refreshToken:a.refresh_token,idToken:a.id_token,expiresAt:t}}catch(s){if(w.isAxiosError(s)&&s.response){let a=s.response.data?.error;if(a==="authorization_pending"){await this.sleep(e*1e3);continue}if(a==="slow_down"){e+=5,await this.sleep(e*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 n=await h();if(!n)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let e=300*1e3;return Date.now()+e>=n.expiresAt&&(console.log("\u{1F504} Refreshing access token..."),n=await this.refreshAccessToken(n)),n.accessToken}async refreshAccessToken(n){if(!n.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let o=(await w.post(`${this.baseUrl}/oauth/token`,{client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:n.refreshToken},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})).data,r={accessToken:o.access_token,refreshToken:o.refresh_token||n.refreshToken,idToken:o.id_token||n.idToken,expiresAt:Date.now()+(o.expires_in||3600)*1e3};return await S(r),r}catch{throw await O(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let n=await h();if(!n||!n.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let e=n.idToken.split(".")[1],o=Buffer.from(e,"base64").toString("utf8");return JSON.parse(o)}catch{throw new Error("Failed to decode ID token")}}async extractAndStoreOrganizations(n){if(!n){console.warn("\u26A0\uFE0F No ID token available, skipping organization extraction");return}try{let e=n.split(".")[1],o=Buffer.from(e,"base64").toString("utf8"),s=JSON.parse(o)[b];if(!s){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let a=s?.ns?.map(t=>typeof t=="object"&&t!==null?{id:t.id,name:t.name,displayName:t.name}:{id:t,name:t,displayName:t})||[];if(a.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}P(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(),R()}async logout(){await O(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await h()!==null}sleep(n){return new Promise(e=>setTimeout(e,n))}},A=null;function D(){return A||(A=new z),A}import V from"enquirer";async function Z(i){console.log("\u{1F4CB} Listing Organizations");let n=N(i,["format","f","F"],"select");try{let e=D();await e.getAccessToken();let o=await e.getOrganizations();if(o.length===0){console.log(`
14
+ \u26A0\uFE0F No organizations found. You may need to re-authenticate.`),console.log(` Run: tigris login
15
+ `);return}let r=F();if(n==="select"){let t=o.map(c=>({name:c.id,message:`${c.displayName||c.name} (${c.id})`,hint:c.id===r?"currently selected":void 0}));try{let u=(await V.prompt({type:"select",name:"organization",message:"Select an organization:",choices:t.map(f=>f.message),initial:r?o.findIndex(f=>f.id===r):0})).organization.match(/\(([^)]+)\)$/),k=u?u[1]:o[0].id;j(k);let I=o.find(f=>f.id===k);console.log(`
16
+ \u2705 Selected organization: ${I?.displayName||I?.name} (${k})
17
+ `);return}catch{console.log(`
18
+ \u274C Selection cancelled
19
+ `),process.exit(0)}}let s=o.map(t=>({id:t.id,name:t.name,displayName:t.displayName||t.name,selected:t.id===r?"\u2713":""})),a=C(s,n,"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(a),console.log(`
20
+ Found ${s.length} organization(s)`),r){let t=o.find(c=>c.id===r);console.log(`Currently selected: ${t?.displayName||t?.name} (${r})`)}else console.log("No organization selected.")}catch(e){e instanceof Error?console.error(`
21
+ \u274C ${e.message}
22
+ `):console.error(`
23
+ \u274C Failed to list organizations
24
+ `),process.exit(1)}}export{Z as default};
@@ -0,0 +1,15 @@
1
+ function _(o,e,n){for(let t of e)if(o[t]!==void 0)return o[t];return n}import g from"axios";import U from"open";import{readFileSync as E,existsSync as N}from"fs";import{join as P}from"path";var v=!1;function b(){if(!v){try{let o=P(process.cwd(),".env");if(N(o)){let n=E(o,"utf8").split(`
2
+ `);for(let t of n){let s=t.trim();if(!s||s.startsWith("#"))continue;let i=s.match(/^([^=]+)=(.*)$/);if(i){let a=i[1].trim(),r=i[2].trim();(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),process.env[a]||(process.env[a]=r)}}}}catch{}v=!0}}function A(){return b(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var x="https://tigris";import{homedir as $}from"os";import{join as f}from"path";import{readFileSync as O,writeFileSync as m,existsSync as u,mkdirSync as D,unlinkSync as F}from"fs";import{chmod as R}from"fs/promises";var l=f($(),".tigris"),c=f(l,"tokens.json"),p=f(l,"organizations.json"),L=f(l,"selected-org");function h(){u(l)||D(l,{recursive:!0,mode:448})}async function k(o){h(),m(c,JSON.stringify(o,null,2),{mode:384});try{await R(c,384)}catch{}}async function d(){if(u(c))try{let o=O(c,"utf8");return JSON.parse(o)}catch{return null}return null}async function T(){if(u(c))try{F(c)}catch{}}function S(o){h(),m(p,JSON.stringify(o,null,2),{mode:384})}function I(){if(u(p))try{let o=O(p,"utf8");return JSON.parse(o)}catch{return[]}return[]}function z(o){h(),m(L,o,{mode:384})}var y=class{config;baseUrl;constructor(){this.config=A(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
3
+ `);try{let n=(await g.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:"),console.log(`
4
+ ${n.verification_uri_complete}
5
+ `),console.log(` Or visit: ${n.verification_uri}`),console.log(` And enter code: ${n.user_code}
6
+ `);try{await U(n.verification_uri_complete)}catch{}console.log(`\u23F3 Waiting for authentication...
7
+ `);let t=await this.pollForToken(n.device_code,n.interval||5);await k(t),await this.extractAndStoreOrganizations(t.idToken),console.log(`\u2705 Authentication successful!
8
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,n){let s=0;for(;s<60;){s++;try{let a=(await g.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()+(a.expires_in||3600)*1e3;return{accessToken:a.access_token,refreshToken:a.refresh_token,idToken:a.id_token,expiresAt:r}}catch(i){if(g.isAxiosError(i)&&i.response){let a=i.response.data?.error;if(a==="authorization_pending"){await this.sleep(n*1e3);continue}if(a==="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 g.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,s={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 k(s),s}catch{throw await T(),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)[x];if(!i){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let a=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(a.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}S(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 T(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await d()!==null}sleep(e){return new Promise(n=>setTimeout(n,e))}},w=null;function C(){return w||(w=new y),w}async function j(o){console.log("\u{1F3AF} Selecting Organization");let e=_(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=C();await n.getAccessToken();let t=await n.getOrganizations(),s=t.find(i=>i.id===e||i.name===e);s||(console.error(`
9
+ \u274C Organization "${e}" not found`),console.log(`
10
+ \u{1F4A1} Available organizations:`),t.forEach(i=>console.log(` - ${i.name} (${i.id})`)),console.log(),process.exit(1)),z(s.id),console.log("\u2705 Organization selected successfully!"),console.log(`\u{1F4DB} Active Organization: ${s.name} (${s.id})`),console.log(`
11
+ \u{1F4A1} This organization will be used for all subsequent commands`)}catch(n){n instanceof Error?console.error(`
12
+ \u274C ${n.message}
13
+ `):console.error(`
14
+ \u274C Failed to select organization
15
+ `),process.exit(1)}}export{j 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,17 @@
1
+ import g from"axios";import U from"open";import{readFileSync as N,existsSync as z}from"fs";import{join as P}from"path";var T=!1;function b(){if(!T){try{let i=P(process.cwd(),".env");if(z(i)){let t=N(i,"utf8").split(`
2
+ `);for(let r of t){let a=r.trim();if(!a||a.startsWith("#"))continue;let n=a.match(/^([^=]+)=(.*)$/);if(n){let s=n[1].trim(),o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),process.env[s]||(process.env[s]=o)}}}}catch{}T=!0}}function _(){return b(),{domain:process.env.AUTH0_DOMAIN||"your-tenant.auth0.com",clientId:process.env.AUTH0_CLIENT_ID||"your-client-id",audience:process.env.AUTH0_AUDIENCE||"https://api.tigrisdata.com"}}var v="https://tigris";import{homedir as $}from"os";import{join as d}from"path";import{readFileSync as m,writeFileSync as S,existsSync as u,mkdirSync as D,unlinkSync as F}from"fs";import{chmod as R}from"fs/promises";var l=d($(),".tigris"),c=d(l,"tokens.json"),p=d(l,"organizations.json"),A=d(l,"selected-org");function x(){u(l)||D(l,{recursive:!0,mode:448})}async function h(i){x(),S(c,JSON.stringify(i,null,2),{mode:384});try{await R(c,384)}catch{}}async function f(){if(u(c))try{let i=m(c,"utf8");return JSON.parse(i)}catch{return null}return null}async function k(){if(u(c))try{F(c)}catch{}}function I(i){x(),S(p,JSON.stringify(i,null,2),{mode:384})}function O(){if(u(p))try{let i=m(p,"utf8");return JSON.parse(i)}catch{return[]}return[]}function C(){if(u(A))try{return m(A,"utf8").trim()}catch{return null}return null}var y=class{config;baseUrl;constructor(){this.config=_(),this.baseUrl=`https://${this.config.domain}`}async login(){console.log(`\u{1F510} Initiating authentication...
3
+ `);try{let t=(await g.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:"),console.log(`
4
+ ${t.verification_uri_complete}
5
+ `),console.log(` Or visit: ${t.verification_uri}`),console.log(` And enter code: ${t.user_code}
6
+ `);try{await U(t.verification_uri_complete)}catch{}console.log(`\u23F3 Waiting for authentication...
7
+ `);let r=await this.pollForToken(t.device_code,t.interval||5);await h(r),await this.extractAndStoreOrganizations(r.idToken),console.log(`\u2705 Authentication successful!
8
+ `)}catch(e){throw e instanceof Error?console.error(`\u274C Authentication failed: ${e.message}`):console.error("\u274C Authentication failed"),e}}async pollForToken(e,t){let a=0;for(;a<60;){a++;try{let s=(await g.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,o=Date.now()+(s.expires_in||3600)*1e3;return{accessToken:s.access_token,refreshToken:s.refresh_token,idToken:s.id_token,expiresAt:o}}catch(n){if(g.isAxiosError(n)&&n.response){let s=n.response.data?.error;if(s==="authorization_pending"){await this.sleep(t*1e3);continue}if(s==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(n.response.data?.error_description||"Authentication failed")}throw n}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await f();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 r=(await g.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:r.access_token,refreshToken:r.refresh_token||e.refreshToken,idToken:r.id_token||e.idToken,expiresAt:Date.now()+(r.expires_in||3600)*1e3};return await h(a),a}catch{throw await k(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await f();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{let t=e.idToken.split(".")[1],r=Buffer.from(t,"base64").toString("utf8");return JSON.parse(r)}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],r=Buffer.from(t,"base64").toString("utf8"),n=JSON.parse(r)[v];if(!n){console.warn("\u26A0\uFE0F No Tigris claims found in token");return}let s=n?.ns?.map(o=>typeof o=="object"&&o!==null?{id:o.id,name:o.name,displayName:o.name}:{id:o,name:o,displayName:o})||[];if(s.length===0){console.warn("\u26A0\uFE0F No organizations found in claims");return}I(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(),O()}async logout(){await k(),console.log("\u2705 Logged out successfully")}async isAuthenticated(){return await f()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},w=null;function E(){return w||(w=new y),w}async function L(){try{let i=E();if(!await i.isAuthenticated()){console.log("\u274C Not authenticated"),console.log(`\u{1F4A1} Run "tigris login" to authenticate
9
+ `);return}let t=await i.getIdTokenClaims(),r=await i.getOrganizations(),a=C();if(console.log(`
10
+ \u{1F464} User Information:`),console.log(` Email: ${t.email||"N/A"}`),console.log(` User ID: ${t.sub}`),r.length>0){if(console.log(`
11
+ \u{1F4C2} Organizations (${r.length}):`),r.forEach(n=>{let o=n.id===a?"\u2192":" ";console.log(` ${o} ${n.name} (${n.id})`)}),a){let n=r.find(s=>s.id===a);n&&console.log(`
12
+ \u2713 Active: ${n.name}`)}}else console.log(`
13
+ \u{1F4C2} Organizations: None`);console.log()}catch(i){i instanceof Error?console.error(`
14
+ \u274C ${i.message}
15
+ `):console.error(`
16
+ \u274C Failed to retrieve user information
17
+ `),process.exit(1)}}export{L as default};
@@ -0,0 +1,535 @@
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
+ # login
122
+ - name: login
123
+ description: Login to Tigris
124
+ alias: l
125
+ operations:
126
+ # configure
127
+ - name: configure
128
+ description: Configure Tigris
129
+ alias: c
130
+ arguments:
131
+ - name: access-key
132
+ description: Tigris Access key ID
133
+ alias: key
134
+ required: true
135
+ - name: access-secret
136
+ description: Tigris Access secret
137
+ alias: secret
138
+ required: true
139
+ - name: endpoint
140
+ description: Tigris Endpoint
141
+ alias: e
142
+ required: true
143
+ # credentials
144
+ - name: credentials
145
+ description: Login with credentials
146
+ alias: c
147
+ arguments:
148
+ - name: access-key
149
+ description: Access key
150
+ alias: key
151
+ required-when: mode=credentials
152
+ - name: access-secret
153
+ description: Access secret
154
+ alias: secret
155
+ required-when: mode=credentials
156
+ # ui
157
+ - name: ui
158
+ description: Login with UI
159
+ alias: u
160
+ default: ui
161
+
162
+ #########################
163
+ # Manage organizations
164
+ #########################
165
+ - name: orgs
166
+ description: Manage organizations
167
+ operations:
168
+ # list
169
+ - name: list
170
+ description: List organizations
171
+ alias: l
172
+ arguments:
173
+ - name: format
174
+ description: Format
175
+ alias: f
176
+ options: [json, table, xml, select]
177
+ default: select
178
+ - name: select
179
+ description: Interactive selection mode
180
+ alias: i
181
+ type: flag
182
+ - name: create
183
+ description: Create organization
184
+ alias: c
185
+ arguments:
186
+ - name: name
187
+ description: Name of the organization
188
+ alias: n
189
+ required: true
190
+ - name: description
191
+ description: Description of the organization
192
+ alias: d
193
+ - name: select
194
+ description: Select the organization to use
195
+ alias: s
196
+ arguments:
197
+ - name: name
198
+ type: noun
199
+ required: true
200
+ description: Name of the organization
201
+
202
+ #########################
203
+ # Manage buckets
204
+ #########################
205
+ - name: buckets
206
+ description: Manage buckets
207
+ alias: b
208
+ operations:
209
+ # list
210
+ - name: list
211
+ description: List buckets
212
+ alias: l
213
+ arguments:
214
+ - name: format
215
+ description: Format
216
+ alias: f
217
+ options: [json, table, xml]
218
+ default: table
219
+ # create
220
+ - name: create
221
+ description: Create bucket
222
+ alias: [c]
223
+ arguments:
224
+ - name: name
225
+ description: Name of the bucket
226
+ type: noun
227
+ required: true
228
+ - name: access
229
+ description: Access level
230
+ alias: a
231
+ options: [public, private]
232
+ default: private
233
+ - name: default-tier
234
+ description: Choose the default tier for the bucket
235
+ alias: t
236
+ options:
237
+ - name: Standard
238
+ value: STANDARD
239
+ description: The default storage class. It provides high durability, availability, and performance for frequently accessed data.
240
+ - name: Infrequent Access
241
+ value: STANDARD_IA
242
+ description: Lower-cost storage for data that is accessed less frequently but requires rapid access when needed.
243
+ - name: Archive
244
+ value: GLACIER
245
+ description: Low-cost storage for data archiving. Long-term data archiving with infrequent access.
246
+ - name: Instant Retrieval Archive
247
+ value: GLACIER_IR
248
+ description: Lowest-cost storage for long-lived data that is rarely accessed and requires retrieval in milliseconds.
249
+ default: STANDARD
250
+ - name: consistency
251
+ description: Choose the consistency level for the bucket
252
+ alias: c
253
+ options:
254
+ - name: Default
255
+ value: default
256
+ description: Strict read-after-write consistency in same region. Eventual consistency globally.
257
+ - name: Strict
258
+ value: strict
259
+ description: Strict read-after-write consistency globally. Latency will be higher than the default.
260
+ default: default
261
+ - name: region
262
+ description: Region
263
+ alias: r
264
+ options:
265
+ - name: Global
266
+ value: ''
267
+ description: Global
268
+ - name: USA
269
+ value: usa
270
+ description: Restrict to USA
271
+ - name: Europe
272
+ value: eur
273
+ description: Restrict to Europe
274
+ - name: Amsterdam, Netherlands
275
+ value: ams
276
+ description: Amsterdam, Netherlands
277
+ - name: Frankfurt, Germany
278
+ value: fra
279
+ description: Frankfurt, Germany
280
+ - name: Sao Paulo, Brazil
281
+ value: gru
282
+ description: Sao Paulo, Brazil
283
+ - name: Ashburn, Virginia (US)
284
+ value: iad
285
+ description: Ashburn, Virginia (US)
286
+ - name: Johannesburg, South Africa
287
+ value: jnb
288
+ description: Johannesburg, South Africa
289
+ - name: London, United Kingdom
290
+ value: lhr
291
+ description: London, United Kingdom
292
+ - name: Tokyo, Japan
293
+ value: nrt
294
+ description: Tokyo, Japan
295
+ - name: Chicago, Illinois (US)
296
+ value: ord
297
+ description: Chicago, Illinois (US)
298
+ - name: Singapore, Singapore
299
+ value: sin
300
+ description: Singapore, Singapore
301
+ - name: San Jose, California (US)
302
+ value: sjc
303
+ description: San Jose, California (US)
304
+ - name: Sydney, Australia
305
+ value: syd
306
+ description: Sydney, Australia
307
+ default: ''
308
+ - name: Cache Control
309
+ 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.
310
+ alias: cc
311
+ - name: Delete Protection
312
+ description: This lets you enable or disable delete protection for the bucket. When enabled, objects in the bucket cannot be deleted.
313
+ alias: dp
314
+ options:
315
+ - name: Enabled
316
+ value: enabled
317
+ description: Enabled
318
+ - name: Disabled
319
+ value: disabled
320
+ description: Disabled
321
+ default: disabled
322
+ # get
323
+ - name: get
324
+ description: Get bucket details
325
+ alias: g
326
+ arguments:
327
+ - name: name
328
+ description: Name of the bucket
329
+ type: noun
330
+ required: true
331
+ # delete
332
+ - name: delete
333
+ description: Delete bucket
334
+ alias: d
335
+ arguments:
336
+ - name: name
337
+ description: Name of the bucket or comma separated list of buckets
338
+ type: noun
339
+ required: true
340
+ multiple: true
341
+
342
+ #########################
343
+ # Manage forks
344
+ #########################
345
+ - name: forks
346
+ description: Manage forks
347
+ alias: f
348
+ operations:
349
+ # list
350
+ - name: list
351
+ description: List forks
352
+ alias: l
353
+ arguments:
354
+ - name: name
355
+ description: Name of the bucket
356
+ type: noun
357
+ required: true
358
+ # create
359
+ - name: create
360
+ description: Create fork
361
+ alias: c
362
+ arguments:
363
+ - name: name
364
+ description: Name of the bucket
365
+ type: noun
366
+ required: true
367
+ - name: fork-name
368
+ description: Name of the fork
369
+ type: noun
370
+ required: true
371
+
372
+ #########################
373
+ # Manage snapshots
374
+ #########################
375
+ - name: snapshots
376
+ description: Manage snapshots
377
+ alias: s
378
+ operations:
379
+ # list
380
+ - name: list
381
+ description: List snapshots
382
+ alias: l
383
+ arguments:
384
+ - name: name
385
+ description: Name of the bucket
386
+ type: noun
387
+ required: true
388
+ # create
389
+ - name: create
390
+ description: Create snapshot
391
+ alias: c
392
+ arguments:
393
+ - name: name
394
+ description: Name of the bucket
395
+ type: noun
396
+ required: true
397
+ - name: snapshot-name
398
+ description: Name of the snapshot
399
+ type: noun
400
+ required: true
401
+
402
+ #########################
403
+ # Manage objects
404
+ #########################
405
+ - name: objects
406
+ description: Manage objects
407
+ alias: o
408
+ operations:
409
+ # list
410
+ - name: list
411
+ description: List objects
412
+ alias: l
413
+ arguments:
414
+ - name: bucket
415
+ description: Name of the bucket
416
+ alias: b
417
+ required: true
418
+ - name: format
419
+ description: Format
420
+ alias: f
421
+ options: [json, table, xml]
422
+ default: table
423
+ # get
424
+ - name: get
425
+ description: Get object
426
+ alias: g
427
+ arguments:
428
+ - name: bucket
429
+ description: Name of the bucket
430
+ type: noun
431
+ required: true
432
+ - name: key
433
+ description: Name of the object
434
+ type: noun
435
+ required: true
436
+ - name: format
437
+ description: Format
438
+ alias: f
439
+ options: [string, file, stream]
440
+ default: string
441
+ # create
442
+ - name: create
443
+ description: Create object
444
+ alias: c
445
+ arguments:
446
+ - name: bucket
447
+ description: Name of the bucket
448
+ type: noun
449
+ required: true
450
+ - name: name
451
+ description: Name of the object
452
+ type: noun
453
+ required: true
454
+ - name: body
455
+ description: Body of the object
456
+ alias: d
457
+ required: true
458
+ - name: access
459
+ description: Access level
460
+ alias: a
461
+ options: [public, private]
462
+ default: private
463
+ - name: content-type
464
+ description: Content type
465
+ alias: c
466
+ - name: content-disposition
467
+ description: Content disposition
468
+ alias: d
469
+ - name: tier
470
+ description: Tier
471
+ alias: t
472
+ options:
473
+ - name: Standard
474
+ value: STANDARD
475
+ description: The default storage class. It provides high durability, availability, and performance for frequently accessed data.
476
+ - name: Infrequent Access
477
+ value: STANDARD_IA
478
+ description: Lower-cost storage for data that is accessed less frequently but requires rapid access when needed.
479
+ - name: Archive
480
+ value: GLACIER
481
+ description: Low-cost storage for data archiving. Long-term data archiving with infrequent access.
482
+ - name: Instant Retrieval Archive
483
+ value: GLACIER_IR
484
+ description: Lowest-cost storage for long-lived data that is rarely accessed and requires retrieval in milliseconds.
485
+ default: STANDARD
486
+ # delete
487
+ - name: delete
488
+ description: Delete object
489
+ alias: d
490
+ arguments:
491
+ - name: bucket
492
+ description: Name of the bucket
493
+ type: noun
494
+ required: true
495
+ - name: key
496
+ description: Name of the object (comma separated names for multiple objects)
497
+ type: noun
498
+ required: true
499
+ multiple: true
500
+ # copy
501
+ - name: copy
502
+ description: Copy object
503
+ alias: c
504
+ arguments:
505
+ - name: bucket
506
+ description: Name of the bucket
507
+ type: noun
508
+ required: true
509
+ - name: name
510
+ description: Name of the object (comma separated names for multiple objects)
511
+ type: noun
512
+ required: true
513
+ multiple: true
514
+ - name: destination
515
+ description: Destination
516
+ type: noun
517
+ required: true
518
+ # move
519
+ - name: move
520
+ description: Move object
521
+ alias: m
522
+ arguments:
523
+ - name: bucket
524
+ description: Name of the bucket
525
+ type: noun
526
+ required: true
527
+ - name: source
528
+ description: Name of the object (comma separated names for multiple objects)
529
+ type: noun
530
+ required: true
531
+ multiple: true
532
+ - name: destination
533
+ description: Destination
534
+ type: noun
535
+ 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 ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@tigrisdata/cli",
3
+ "version": "1.0.0",
4
+ "description": "Command line interface for Tigris object storage",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/cli.js"
9
+ }
10
+ },
11
+ "bin": {
12
+ "tigris": "./dist/cli.js",
13
+ "t3": "./dist/cli.js"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "build": "tsup",
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\"",
29
+ "publint": "publint",
30
+ "prepublishOnly": "npm run build",
31
+ "clean": "rm -rf dist",
32
+ "commit": "cz",
33
+ "semantic-release": "semantic-release",
34
+ "prepare": "husky install"
35
+ },
36
+ "keywords": [
37
+ "cli",
38
+ "object",
39
+ "storage",
40
+ "tigris",
41
+ "blob"
42
+ ],
43
+ "author": "Tigris Data",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/tigrisdata/cli.git"
47
+ },
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
+ },
74
+ "dependencies": {
75
+ "@tigrisdata/storage": "*",
76
+ "axios": "^1.12.2",
77
+ "commander": "^11.0.0",
78
+ "enquirer": "^2.4.1",
79
+ "open": "^10.2.0",
80
+ "yaml": "^2.3.4"
81
+ },
82
+ "devDependencies": {
83
+ "@commitlint/cli": "^18.0.0",
84
+ "@commitlint/config-conventional": "^18.0.0",
85
+ "@semantic-release/changelog": "^6.0.0",
86
+ "@semantic-release/git": "^10.0.0",
87
+ "@types/node": "^20.0.0",
88
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
89
+ "@typescript-eslint/parser": "^6.0.0",
90
+ "commitizen": "^4.3.0",
91
+ "cz-conventional-changelog": "^3.3.0",
92
+ "eslint": "^8.0.0",
93
+ "husky": "^8.0.0",
94
+ "prettier": "^3.0.0",
95
+ "publint": "^0.2.0",
96
+ "semantic-release": "^22.0.0",
97
+ "tsup": "^8.0.0",
98
+ "typescript": "^5.0.0"
99
+ }
100
+ }