@tigrisdata/cli 2.18.0 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/auth/client.js +1 -1
  2. package/dist/auth/iam.js +1 -1
  3. package/dist/auth/provider.js +1 -1
  4. package/dist/chunk-3EAZ2L6H.js +1 -0
  5. package/dist/{chunk-JP3PXFIQ.js → chunk-7ZUCJBD5.js} +1 -1
  6. package/dist/{chunk-7ZHRXMPK.js → chunk-D3UQD6W2.js} +1 -1
  7. package/dist/chunk-EBWDZEHM.js +1 -0
  8. package/dist/{chunk-27KYKU5U.js → chunk-EFPPY2JQ.js} +1 -1
  9. package/dist/chunk-HWX63Y3P.js +1 -0
  10. package/dist/{chunk-T2QR4QOR.js → chunk-KQTMMFPE.js} +1 -1
  11. package/dist/chunk-QWZ6FK7E.js +8 -0
  12. package/dist/chunk-RXNG56FL.js +1 -0
  13. package/dist/{chunk-XCZPPS7H.js → chunk-S7EO4QWK.js} +1 -1
  14. package/dist/{chunk-3L2I7HZB.js → chunk-SO7GMI24.js} +1 -1
  15. package/dist/{chunk-SMBIT5FI.js → chunk-UBANDLB4.js} +1 -1
  16. package/dist/{chunk-EKLR55EQ.js → chunk-YN2TKPPT.js} +1 -1
  17. package/dist/chunk-ZP77TNW7.js +8 -0
  18. package/dist/cli-core.js +1 -1
  19. package/dist/cli.js +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/lib/access-keys/assign.js +1 -1
  22. package/dist/lib/access-keys/attach-policy.js +1 -1
  23. package/dist/lib/access-keys/create.js +1 -1
  24. package/dist/lib/access-keys/delete.js +1 -1
  25. package/dist/lib/access-keys/detach-policy.js +1 -1
  26. package/dist/lib/access-keys/get.js +1 -1
  27. package/dist/lib/access-keys/list-policies.js +1 -1
  28. package/dist/lib/access-keys/list.js +1 -1
  29. package/dist/lib/access-keys/rotate.js +1 -1
  30. package/dist/lib/buckets/create.js +1 -1
  31. package/dist/lib/buckets/delete.js +1 -1
  32. package/dist/lib/buckets/get.js +1 -1
  33. package/dist/lib/buckets/lifecycle/create.js +1 -0
  34. package/dist/lib/buckets/lifecycle/edit.js +1 -0
  35. package/dist/lib/buckets/lifecycle/list.js +1 -0
  36. package/dist/lib/buckets/lifecycle/shared.js +1 -0
  37. package/dist/lib/buckets/list.js +1 -1
  38. package/dist/lib/buckets/migrate.js +1 -1
  39. package/dist/lib/buckets/set-cors.js +1 -1
  40. package/dist/lib/buckets/set-locations.js +1 -1
  41. package/dist/lib/buckets/set-migration.js +1 -1
  42. package/dist/lib/buckets/set-notifications.js +1 -1
  43. package/dist/lib/buckets/set.js +1 -1
  44. package/dist/lib/bundle.js +1 -1
  45. package/dist/lib/configure/index.js +1 -1
  46. package/dist/lib/cp.js +1 -1
  47. package/dist/lib/credentials/test.js +1 -1
  48. package/dist/lib/iam/policies/create.js +1 -1
  49. package/dist/lib/iam/policies/delete.js +1 -1
  50. package/dist/lib/iam/policies/edit.js +1 -1
  51. package/dist/lib/iam/policies/get.js +1 -1
  52. package/dist/lib/iam/policies/link-key.js +1 -1
  53. package/dist/lib/iam/policies/list-keys.js +1 -1
  54. package/dist/lib/iam/policies/list.js +1 -1
  55. package/dist/lib/iam/policies/select-policy.js +1 -1
  56. package/dist/lib/iam/policies/unlink-key.js +1 -1
  57. package/dist/lib/iam/users/invite.js +1 -1
  58. package/dist/lib/iam/users/list.js +1 -1
  59. package/dist/lib/iam/users/remove.js +1 -1
  60. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  61. package/dist/lib/iam/users/update-role.js +1 -1
  62. package/dist/lib/login/credentials.js +1 -1
  63. package/dist/lib/login/oauth.js +1 -1
  64. package/dist/lib/login/select.js +1 -1
  65. package/dist/lib/logout.js +1 -1
  66. package/dist/lib/ls.js +1 -1
  67. package/dist/lib/mk.js +1 -1
  68. package/dist/lib/mv.js +1 -1
  69. package/dist/lib/objects/delete.js +1 -1
  70. package/dist/lib/objects/get.js +1 -1
  71. package/dist/lib/objects/info.js +1 -1
  72. package/dist/lib/objects/list.js +1 -1
  73. package/dist/lib/objects/put.js +1 -1
  74. package/dist/lib/objects/set.js +1 -1
  75. package/dist/lib/organizations/create.js +1 -1
  76. package/dist/lib/organizations/list.js +1 -1
  77. package/dist/lib/organizations/select.js +1 -1
  78. package/dist/lib/presign.js +1 -1
  79. package/dist/lib/rm.js +1 -1
  80. package/dist/lib/snapshots/list.js +1 -1
  81. package/dist/lib/snapshots/take.js +1 -1
  82. package/dist/lib/stat.js +1 -1
  83. package/dist/lib/touch.js +1 -1
  84. package/dist/lib/update.js +1 -1
  85. package/dist/lib/whoami.js +1 -1
  86. package/dist/specs.yaml +129 -143
  87. package/dist/utils/bucket-info.js +1 -1
  88. package/dist/utils/exit.js +1 -1
  89. package/dist/utils/messages.js +1 -1
  90. package/dist/utils/path.js +1 -1
  91. package/dist/utils/update-check.js +1 -1
  92. package/package.json +20 -9
  93. package/dist/chunk-4ZHCF5D6.js +0 -1
  94. package/dist/chunk-DQMSOC2W.js +0 -8
  95. package/dist/chunk-JQUG732D.js +0 -1
  96. package/dist/chunk-KK7FZ7QM.js +0 -1
  97. package/dist/chunk-QWBEROER.js +0 -8
  98. package/dist/lib/buckets/set-transition.js +0 -1
  99. package/dist/lib/buckets/set-ttl.js +0 -1
  100. package/dist/lib/forks/create.js +0 -1
  101. package/dist/lib/forks/list.js +0 -1
@@ -1 +1 @@
1
- import{a,b,c}from"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";export{b as TigrisAuthClient,a as getAuth0Config,c as getAuthClient};
1
+ import{a,b,c}from"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";export{b as TigrisAuthClient,a as getAuth0Config,c as getAuthClient};
package/dist/auth/iam.js CHANGED
@@ -1 +1 @@
1
- import{a as b,b as c}from"../chunk-27KYKU5U.js";import"../chunk-EKLR55EQ.js";import"../chunk-SMBIT5FI.js";import"../chunk-DV3LCXRH.js";import"../chunk-JP3PXFIQ.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import{a}from"../chunk-GAWFFIPC.js";import"../chunk-OHGCOC5Q.js";export{c as getIAMConfig,b as getOAuthIAMConfig,a as isFlyOrganization};
1
+ import{a as b,b as c}from"../chunk-EFPPY2JQ.js";import"../chunk-YN2TKPPT.js";import"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import{a}from"../chunk-GAWFFIPC.js";import"../chunk-OHGCOC5Q.js";export{c as getIAMConfig,b as getOAuthIAMConfig,a as isFlyOrganization};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-EKLR55EQ.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";export{b as getEnvCredentials,d as getStorageConfig,e as getStorageConfigWithOrg,a as getTigrisConfig,f as requireOAuthLogin,c as resolveAuthMethod};
1
+ import{a,b,c,d,e,f}from"../chunk-YN2TKPPT.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";export{b as getEnvCredentials,d as getStorageConfig,e as getStorageConfigWithOrg,a as getTigrisConfig,f as requireOAuthLogin,c as resolveAuthMethod};
@@ -0,0 +1 @@
1
+ import{c as d,d as s,e as g,f,g as p,o as k}from"./chunk-OHGCOC5Q.js";import{createRemoteJWKSet as w,jwtVerify as T}from"jose";import _ from"open";function y(){let a=process.env.TIGRIS_ENV==="development",e=a?process.env.AUTH0_DOMAIN??"auth-storage.tigris.dev":process.env.AUTH0_DOMAIN??"auth.storage.tigrisdata.io",t=a?process.env.AUTH0_CLIENT_ID??"JdJVYIyw0O1uHi5L5OJH903qaWBgd3gF":process.env.AUTH0_CLIENT_ID??"DMejqeM3CQ4IqTjEcd3oA9eEiT40hn8D",n=a?process.env.AUTH0_AUDIENCE??"https://tigris-api-dev":process.env.AUTH0_AUDIENCE??"https://tigris-os-api",i=process.env.TIGRIS_CLAIMS_NAMESPACE??"https://tigris";return{domain:e,clientId:t,audience:n,claimsNamespace:i}}var u=class{config;baseUrl;jwks=null;constructor(){this.config=y(),this.baseUrl=`https://${this.config.domain}`}getJWKS(){return this.jwks||(this.jwks=w(new URL(`${this.baseUrl}/.well-known/jwks.json`))),this.jwks}async verifyIdToken(e){let{payload:t}=await T(e,this.getJWKS(),{issuer:`${this.baseUrl}/`,audience:this.config.clientId});return t}async login(e){let t=await fetch(`${this.baseUrl}/oauth/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:this.config.clientId,audience:this.config.audience,scope:"openid profile email offline_access"})});if(!t.ok)throw new Error(`Device authorization failed: ${t.statusText}`);let n=JSON.parse(await t.text());e?.onDeviceCode?.(n.user_code,n.verification_uri),await this.sleep(2e3);try{await _(n.verification_uri_complete)}catch{}e?.onWaiting?.();let i=await this.pollForToken(n.device_code,n.interval||5);await d(i),k("oauth"),await this.extractAndStoreOrganizations()}async pollForToken(e,t){let i=0;for(;i<60;){i++;let r=await fetch(`${this.baseUrl}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:this.config.clientId,device_code:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});if(!r.ok){let l=await r.text().then(JSON.parse).catch(()=>({}));if(l.error==="authorization_pending"){await this.sleep(t*1e3);continue}if(l.error==="slow_down"){t+=5,await this.sleep(t*1e3);continue}throw new Error(l.error_description||"Authentication failed")}let o=JSON.parse(await r.text());if(!o.id_token)throw new Error("No ID token found. Please try again.");if((await this.verifyIdToken(o.id_token)).email_verified===!1)throw console.log("Email not verified. Please verify your email and try again."),new Error("Email not verified. Please verify your email and try again.");let m=Date.now()+(o.expires_in||3600)*1e3;return{accessToken:o.access_token,refreshToken:o.refresh_token,idToken:o.id_token,expiresAt:m}}throw new Error("Authentication timed out. Please try again.")}async getAccessToken(){let e=await s();if(!e)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');let t=300*1e3;return Date.now()+t>=e.expiresAt&&(e=await this.refreshAccessToken(e)),e.accessToken}async refreshAccessToken(e){let t;if(e?.refreshToken?t=e:t=await s(),!t?.refreshToken)throw new Error('No refresh token available. Please run "tigris login" to re-authenticate.');try{let n=await fetch(`${this.baseUrl}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:this.config.clientId,grant_type:"refresh_token",refresh_token:t.refreshToken,scope:"openid profile email offline_access"})});if(!n.ok)throw new Error("Token refresh failed");let i=JSON.parse(await n.text()),r={accessToken:i.access_token,refreshToken:i.refresh_token||t.refreshToken,idToken:i.id_token||t.idToken,expiresAt:Date.now()+(i.expires_in||3600)*1e3};return await d(r),r}catch{throw await g(),new Error('Token refresh failed. Please run "tigris login" to re-authenticate.')}}async getIdTokenClaims(){let e=await s();if(!e||!e.idToken)throw new Error('Not authenticated. Please run "tigris login" to authenticate.');try{return await this.verifyIdToken(e.idToken)}catch{throw new Error('ID token verification failed. Please run "tigris login" to re-authenticate.')}}async extractAndStoreOrganizations(){try{let e=await this.fetchOrganizationsFromUserInfo();e&&f(e)}catch{}}async fetchOrganizationsFromUserInfo(){try{let{domain:e,claimsNamespace:t}=this.config,n=await this.getAccessToken(),i=await fetch(`https://${e}/userinfo`,{headers:{Authorization:`Bearer ${n}`}});if(!i.ok)return null;let o=JSON.parse(await i.text())[t]?.ns;return Array.isArray(o)?o.map(c=>({id:c.id,name:c.name,slug:c.name})):null}catch{return null}}async getOrganizations(){return await this.getAccessToken(),p()}async isFlyUser(){return(await this.getIdTokenClaims()).sub.includes("fly-sso")}async logout(){await g()}async isAuthenticated(){return await s()!==null}sleep(e){return new Promise(t=>setTimeout(t,e))}},h=null;function C(){return h||(h=new u),h}export{y as a,u as b,C as c};
@@ -1,3 +1,3 @@
1
- import{c as p}from"./chunk-PPNBQWSR.js";var c={success:"\u2714",failure:"\u2716",hint:"\u2192"};function t(){return process.stdout.isTTY===!0}function i(){return globalThis.__TIGRIS_JSON_MODE===!0}function o(e){let s=p(e.command,e.operation);if(s)return s.messages}function r(e,s){let n=e;return n=n.replace(/\\n/g,`
1
+ import{c as l}from"./chunk-PPNBQWSR.js";var c={success:"\u2714",failure:"\u2716",hint:"\u2192"};function t(){return process.stdout.isTTY===!0}function i(){return globalThis.__TIGRIS_JSON_MODE===!0}function o(e){let s=l(e.command,e.operation);if(s)return s.messages}function r(e,s){let n=e;return n=n.replace(/\\n/g,`
2
2
  `),s&&(n=n.replace(/\{\{(\w+)\}\}/g,(a,g)=>{let u=s[g];return u!==void 0?String(u):`{{${g}}}`})),n}function f(e,s){if(!t()||i())return;let n=o(e);n?.onStart&&console.log(r(n.onStart,s))}function d(e,s){if(!t()||i())return;let n=o(e);n?.onSuccess&&console.log(`${c.success} ${r(n.onSuccess,s)}`)}function m(e,s,n){if(globalThis.__TIGRIS_JSON_MODE===!0)return;let a=o(e);a?.onFailure&&console.error(`${c.failure} ${r(a.onFailure,n)}`),s&&console.error(` ${s}`)}function M(e,s){if(!t()||i())return;let n=o(e);n?.onEmpty&&console.log(r(n.onEmpty,s))}function x(e,s){if(!t()||i())return;let n=o(e);n?.onAlreadyDone&&console.log(r(n.onAlreadyDone,s))}function S(e,s){if(!t()||i())return;let n=o(e);n?.hint&&console.log(`${c.hint} ${r(n.hint,s)}`)}function b(e){t()&&console.warn(`\u26A0 Deprecated: ${e}`)}function C(e){e&&console.error(`
3
3
  Next page: --page-token "${e}"`)}function $(e,s){return{command:e,operation:s}}export{r as a,f as b,d as c,m as d,M as e,x as f,S as g,b as h,C as i,$ as j};
@@ -1 +1 @@
1
- import{a as K}from"./chunk-S77OAN6Y.js";import{a as w}from"./chunk-EKLR55EQ.js";import{b as S}from"./chunk-S6KFKBMY.js";import{b as d,d as m}from"./chunk-SMBIT5FI.js";import{b as i,c as n,j as o}from"./chunk-JP3PXFIQ.js";import{a as g}from"./chunk-ATBINUDP.js";import{l as f,n as y,o as p,q as u,s as l}from"./chunk-OHGCOC5Q.js";import C from"enquirer";import{whoami as k}from"@tigrisdata/iam";var{prompt:I}=C,a=o("login","credentials");async function q(e){i(a);let A=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!r){let t=[];s||t.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),r||t.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0}),K("Provide --access-key and --access-secret");let c=await I(t);s=s||c.accessKey,r=r||c.accessSecret}(!s||!r)&&d(a,"Access key and secret are required");let h=f()?.endpoint||g;await y({accessKeyId:s,secretAccessKey:r,endpoint:h}),await p("credentials"),await l();try{let t=w(),{data:c}=await k({config:{accessKeyId:s,secretAccessKey:r,iamEndpoint:t.iamEndpoint}});c?.organizationId&&await u(c.organizationId,"temporary")}catch{}A==="json"&&console.log(JSON.stringify({action:"logged_in"})),n(a),m(a)}export{q as a};
1
+ import{a as K}from"./chunk-S77OAN6Y.js";import{a as w}from"./chunk-YN2TKPPT.js";import{b as S}from"./chunk-S6KFKBMY.js";import{b as d,d as m}from"./chunk-UBANDLB4.js";import{b as i,c as n,j as o}from"./chunk-7ZUCJBD5.js";import{a as g}from"./chunk-ATBINUDP.js";import{l as f,n as y,o as p,q as u,s as l}from"./chunk-OHGCOC5Q.js";import C from"enquirer";import{whoami as k}from"@tigrisdata/iam";var{prompt:I}=C,a=o("login","credentials");async function q(e){i(a);let A=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,r=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret;if(!s||!r){let t=[];s||t.push({type:"input",name:"accessKey",message:"Access Key ID:",required:!0}),r||t.push({type:"password",name:"accessSecret",message:"Secret Access Key:",required:!0}),K("Provide --access-key and --access-secret");let c=await I(t);s=s||c.accessKey,r=r||c.accessSecret}(!s||!r)&&d(a,"Access key and secret are required");let h=f()?.endpoint||g;await y({accessKeyId:s,secretAccessKey:r,endpoint:h}),await p("credentials"),await l();try{let t=w(),{data:c}=await k({config:{accessKeyId:s,secretAccessKey:r,iamEndpoint:t.iamEndpoint}});c?.organizationId&&await u(c.organizationId,"temporary")}catch{}A==="json"&&console.log(JSON.stringify({action:"logged_in"})),n(a),m(a)}export{q as a};
@@ -0,0 +1 @@
1
+ import{a as d,b as o}from"./chunk-HWX63Y3P.js";import{a}from"./chunk-S6KFKBMY.js";import{b as i}from"./chunk-UBANDLB4.js";import{getBucketInfo as l,setBucketLifecycle as g}from"@tigrisdata/storage";var f=["STANDARD_IA","GLACIER","GLACIER_IR"];function c(e){return f.includes(e)}function u(e){return/^\d{4}-\d{2}-\d{2}/.test(e)&&!isNaN(new Date(e).getTime())}function C(e){return{prefix:a(e,["prefix"]),storageClass:a(e,["storage-class","storageClass"]),days:a(e,["days"]),date:a(e,["date"]),expireDays:a(e,["expire-days","expireDays"]),expireDate:a(e,["expire-date","expireDate"]),enable:a(e,["enable"]),disable:a(e,["disable"])}}function p(e,{requireStorageClassForTiming:r=!0}={}){if(e.enable&&e.disable)return"Cannot use both --enable and --disable";if(r&&(e.days!==void 0||e.date!==void 0)&&!e.storageClass)return"--storage-class is required when setting --days or --date";if(e.storageClass&&!c(e.storageClass))return`--storage-class must be one of: ${f.join(", ")} (STANDARD is not a valid transition target)`;if(e.days!==void 0&&e.date!==void 0)return"Cannot specify both --days and --date";if(e.days!==void 0&&(isNaN(Number(e.days))||Number(e.days)<=0))return"--days must be a positive number";if(e.date!==void 0&&!u(e.date))return"--date must be a valid ISO-8601 date (e.g. 2026-06-01)";if(e.expireDays!==void 0&&e.expireDate!==void 0)return"Cannot specify both --expire-days and --expire-date";if(e.expireDays!==void 0&&(isNaN(Number(e.expireDays))||Number(e.expireDays)<=0))return"--expire-days must be a positive number";if(e.expireDate!==void 0&&!u(e.expireDate))return"--expire-date must be a valid ISO-8601 date (e.g. 2026-06-01)";if(e.prefix!==void 0&&e.prefix==="")return"--prefix cannot be empty"}function D(e){let r={};return e.storageClass&&(r.storageClass=e.storageClass),e.days!==void 0?(r.days=Number(e.days),r.date=void 0):e.date!==void 0&&(r.date=e.date,r.days=void 0),r}function R(e){if(e.expireDays!==void 0)return{days:Number(e.expireDays),date:void 0};if(e.expireDate!==void 0)return{date:e.expireDate,days:void 0}}function I(e){if(e.enable)return!0;if(e.disable)return!1}async function T(e,r,t){let{data:s,error:n}=await l(r,{config:t});return n&&i(e,n),s?.settings.lifecycleRules??[]}async function N(e,r,t,s){let{error:n}=await g(r,{lifecycleRules:t,config:s});n&&i(e,n)}function S(e){return d(e)??"-"}function A(e){return o(e)??"-"}export{C as a,p as b,D as c,R as d,I as e,T as f,N as g,S as h,A as i};
@@ -1,2 +1,2 @@
1
- import{a as o,c as a}from"./chunk-EKLR55EQ.js";import{b as i}from"./chunk-SMBIT5FI.js";import{c as r}from"./chunk-KK7FZ7QM.js";import{i as n,p as s}from"./chunk-OHGCOC5Q.js";async function d(e){s()!=="oauth"&&i(e,`This operation requires OAuth login.
1
+ import{a as o,c as a}from"./chunk-YN2TKPPT.js";import{b as i}from"./chunk-UBANDLB4.js";import{c as r}from"./chunk-3EAZ2L6H.js";import{i as n,p as s}from"./chunk-OHGCOC5Q.js";async function d(e){s()!=="oauth"&&i(e,`This operation requires OAuth login.
2
2
  Run "tigris login oauth" first.`);let t=r();await t.isAuthenticated()||i(e,'Not authenticated. Run "tigris login oauth" first.');let c=n(),{iamEndpoint:g,mgmtEndpoint:u}=o();return{sessionToken:await t.getAccessToken(),organizationId:c??void 0,iamEndpoint:g,mgmtEndpoint:u}}async function A(e){let t=await a();switch(t.type){case"oauth":return d(e);case"aws-profile":case"credentials":case"environment":case"configured":return{accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,organizationId:n()??void 0,iamEndpoint:o().iamEndpoint};case"none":i(e,'Not authenticated. Run "tigris login" or "tigris configure" first.')}}export{d as a,A as b};
@@ -0,0 +1 @@
1
+ import{a as l}from"./chunk-IRDNZN7R.js";function r(e){if(e.storageClass)return e.days!==void 0?`${e.storageClass} after ${e.days}d`:e.date!==void 0?`${e.storageClass} on ${e.date}`:e.storageClass}function f(e){if(e.expiration){if(e.expiration.days!==void 0)return`${e.expiration.days}d`;if(e.expiration.date!==void 0)return e.expiration.date}}function a(e){let n=[],i=r(e);i&&n.push(i);let s=f(e);s&&n.push(e.expiration?.days!==void 0?`expire after ${s}`:`expire on ${s}`);let t=[];e.filter?.prefix&&t.push(`prefix=${e.filter.prefix}`),e.enabled===!1&&t.push("disabled");let o=n.join(", ");return t.length>0?`${o} (${t.join(", ")})`:o}function c(e){let n=[{label:"Number of Objects",value:e.sizeInfo.numberOfObjects?.toString()??"N/A"},{label:"Total Size",value:e.sizeInfo.size!==void 0?l(e.sizeInfo.size):"N/A"},{label:"All Versions Count",value:e.sizeInfo.numberOfObjectsAllVersions?.toString()??"N/A"},{label:"Default Tier",value:e.settings.defaultTier},{label:"Snapshots Enabled",value:e.isSnapshotEnabled?"Yes":"No"},{label:"Delete Protection",value:e.settings.deleteProtection?"Yes":"No"},{label:"Allow Object ACL",value:e.settings.allowObjectAcl?"Yes":"No"},{label:"Custom Domain",value:e.settings.customDomain??"None"},{label:"Has Forks",value:e.forkInfo?.hasChildren?"Yes":"No"}];return e.forkInfo?.parents?.length&&(n.push({label:"Forked From",value:e.forkInfo.parents[0].bucketName}),n.push({label:"Fork Snapshot",value:e.forkInfo.parents[0].snapshot})),e.settings.lifecycleRules?.length&&n.push({label:"Lifecycle Rules",value:e.settings.lifecycleRules.map(i=>a(i)).join(", ")}),e.settings.corsRules.length&&n.push({label:"CORS Rules",value:`${e.settings.corsRules.length} rule(s)`}),e.settings.notifications&&n.push({label:"Notifications",value:e.settings.notifications.enabled!==!1?"Enabled":"Disabled"}),e.settings.dataMigration&&n.push({label:"Data Migration",value:e.settings.dataMigration.endpoint?`${e.settings.dataMigration.name??"N/A"} (${e.settings.dataMigration.endpoint})`:e.settings.dataMigration.name??"Configured"}),n}export{r as a,f as b,c};
@@ -1,4 +1,4 @@
1
- import{b as d}from"./chunk-S6KFKBMY.js";import{a as f,d as e}from"./chunk-SMBIT5FI.js";import{b as s,c as r,d as g,g as c,j as l}from"./chunk-JP3PXFIQ.js";import{c as u}from"./chunk-KK7FZ7QM.js";import{h as m,r as p}from"./chunk-OHGCOC5Q.js";var o=l("login","oauth");async function x(h={}){s(o);let a=d(h);try{let t=u();await t.login({onDeviceCode:(i,w)=>{console.log(`
1
+ import{b as d}from"./chunk-S6KFKBMY.js";import{a as f,d as e}from"./chunk-UBANDLB4.js";import{b as s,c as r,d as g,g as c,j as l}from"./chunk-7ZUCJBD5.js";import{c as u}from"./chunk-3EAZ2L6H.js";import{h as m,r as p}from"./chunk-OHGCOC5Q.js";var o=l("login","oauth");async function x(h={}){s(o);let a=d(h);try{let t=u();await t.login({onDeviceCode:(i,w)=>{console.log(`
2
2
  Your confirmation code: ${i}
3
3
  `),console.log(`If browser doesn't open, visit: ${w}`)},onWaiting:()=>console.log(`
4
4
  Waiting for authentication...`)}),await p();let n=await t.getOrganizations();if(n.length>0){let i=n[0];await m(i.id),a==="json"&&console.log(JSON.stringify({action:"logged_in"})),r(o,{org:i.name}),e(o),n.length>1&&c(o,{count:n.length})}else a==="json"&&console.log(JSON.stringify({action:"logged_in"})),r(o,{org:"none"}),e(o)}catch(t){g(o),f(t,o)}}var N=x;export{x as a,N as b};
@@ -0,0 +1,8 @@
1
+ import{a as w}from"./chunk-UBANDLB4.js";import{h as C}from"./chunk-7ZUCJBD5.js";import{Command as L,Option as _}from"commander";function A(n,t,e,a,o){let r=n[n.length-1],i=typeof r=="object"&&r!==null&&"args"in r?r.args:n.filter(l=>typeof l=="string");if(i.length===0)return i;let m=i[0],d=(t.commands??[]).filter(l=>g(l,[...e,l.name],o));if(!new Set(d.flatMap(l=>[l.name,...Array.isArray(l.alias)?l.alias:l.alias?[l.alias]:[]])).has(m)){let l=d.map(u=>u.name),p=e.length>0?`'${m}' for '${e.join(" ")}'`:`'${m}'`;console.error(`Unknown command ${p}.`),l.length>0&&console.error(`Available commands: ${l.join(", ")}`);let f=e.length>0?`${a.name} ${e.join(" ")} help`:`${a.name} help`;console.error(`
2
+ Run "${f}" for usage.`),process.exit(1)}return i}function G(){process.on("unhandledRejection",n=>{(n===""||n===void 0)&&(console.error(`
3
+ Operation cancelled`),process.exit(1)),w(n)}),process.on("uncaughtException",n=>{w(n)})}function U(n){return/^[a-zA-Z0-9_-]+$/.test(n)}function D(n){let t;n.type==="positional"?t=` ${n.name}`:(t=` --${n.name}`,n.alias&&typeof n.alias=="string"&&(t+=n.alias.length===1?`, -${n.alias}`:`, --${n.alias}`));let e=26,a=t.length>=e?t+" ":t.padEnd(e),o=n.description;return n.options&&(Array.isArray(n.options)&&typeof n.options[0]=="string"?o+=` (options: ${n.options.join(", ")})`:o+=` (options: ${n.options.map(r=>r.value).join(", ")})`),n.default&&(o+=` [default: ${n.default}]`),n.required&&(o+=" [required]"),n["required-when"]&&(o+=` [required when: ${n["required-when"]}]`),n.multiple&&(o+=" [multiple values: comma-separated]"),n.type==="positional"&&(o+=" [positional argument]"),n.examples&&n.examples.length>0&&(o+=` (examples: ${n.examples.join(", ")})`),`${a}${o}`}function g(n,t,e){return n.removed||e(t)?!0:n.commands?n.commands.some(a=>g(a,[...t,a.name],e)):!1}function R(n,t){let e=t?` Use ${t} instead.`:" See the changelog for migration guidance.";console.error(`${n} was removed in this version.${e}`),process.exit(1)}function v(n,t){if(n)for(let e of n){if(!e.removed)continue;h(t,e.name,n)!==void 0&&R(`--${e.name}`,e.replaced_by)}}function b(n,t,e,a){let o=e.join(" ");if(console.log(`
4
+ ${n.name} ${o} - ${t.description??""}
5
+ `),t.commands&&t.commands.length>0){let m=t.commands.filter(s=>!s.removed&&g(s,[...e,s.name],a));m.length>0&&(console.log("Commands:"),m.forEach(s=>{let d=` ${s.name}`;if(s.alias){let l=Array.isArray(s.alias)?s.alias:[s.alias];d+=` (${l.join(", ")})`}let c=d.padEnd(24);console.log(`${c}${s.description??""}`)}),console.log())}let r=n.definitions?.global_arguments??[],i=y(r,t.arguments).filter(m=>!m.removed);i.length>0&&(console.log("Arguments:"),i.forEach(m=>{console.log(D(m))}),console.log()),t.examples&&t.examples.length>0&&(console.log("Examples:"),t.examples.forEach(m=>{console.log(` ${m}`)}),console.log()),t.commands&&t.commands.length>0&&console.log(`Use "${n.name} ${o} <command> help" for more information about a command.`)}function k(n,t,e){console.log(`Tigris CLI Version: ${t}
6
+ `),console.log(`Usage: tigris [command] [options]
7
+ `),console.log("Commands:"),n.commands.filter(o=>!o.removed&&g(o,[o.name],e)).forEach(o=>{let r=` ${o.name}`;if(o.alias){let m=Array.isArray(o.alias)?o.alias:[o.alias];r+=` (${m.join(", ")})`}let i=r.padEnd(24);console.log(`${i}${o.description??""}`)}),console.log(`
8
+ Use "${n.name} <command> help" for more information about a command.`)}function y(n,t){let e=t??[],a=new Set(e.map(i=>i.name)),o=new Set(e.filter(i=>i.alias).map(i=>i.alias)),r=n.filter(i=>!a.has(i.name)&&!(i.alias&&o.has(i.alias)));return[...e,...r]}function E(n,t=[]){t.forEach(e=>{if(e.type==="positional"){let a=e.required?`<${e.name}>`:`[${e.name}]`;n.argument(a,e.description)}else{let a=e.alias&&typeof e.alias=="string"&&e.alias.length===1,o=e.alias&&typeof e.alias=="string"&&e.alias.length>1,r=a?`-${e.alias}, --${e.name}`:o?`--${e.alias}, --${e.name}`:`--${e.name}`;e.type==="flag"||(e.type==="boolean"?r+=" [value]":e.options?r+=" <value>":r+=e.required||e["required-when"]?" <value>":" [value]"),e.removed?n.addOption(new _(r,e.description??"").hideHelp()):n.option(r,e.description??"",e.default)}})}function M(n){return n.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function h(n,t,e){if(e){let o=e.find(r=>r.name===t);if(o&&o.alias&&typeof o.alias=="string"){let r=o.alias.charAt(0).toUpperCase()+o.alias.slice(1);if(n[r]!==void 0)return n[r]}}let a=[t,t.replace(/-/g,""),t.replace(/-/g,"").toLowerCase(),t.charAt(0).toUpperCase(),M(t)];for(let o of a)if(n[o]!==void 0)return n[o]}function S(n,t){for(let e of n){if(e["required-when"]){let[a,o]=e["required-when"].split("="),r=h(t,a,n),i=h(t,e.name,n);if(r===o&&!i)return console.error(`--${e.name} is required when --${a} is ${o}`),!1}if(e.required&&!h(t,e.name,n))return console.error(`--${e.name} is required`),!1}return!0}function j(n,t,e){let a;"optsWithGlobals"in e&&typeof e.optsWithGlobals=="function"?a=e.optsWithGlobals():"opts"in e&&typeof e.opts=="function"?a=e.opts():a=e;let o={...a};return n.filter(i=>i.type==="positional").forEach((i,m)=>{t[m]!==void 0&&(i.multiple?o[i.name]=t[m].split(",").map(s=>s.trim()):o[i.name]=t[m])}),n.forEach(i=>{i.multiple&&i.type!=="positional"&&o[i.name]&&typeof o[i.name]=="string"&&(o[i.name]=o[i.name].split(",").map(m=>m.trim()))}),o}async function I(n,t,e=[],a={}){(a.json||a.format==="json")&&(globalThis.__TIGRIS_JSON_MODE=!0);let{module:o,error:r}=await n(t);(r||!o)&&(console.error(r),process.exit(1));let i=t[t.length-1],m=o.default||o[i];typeof m!="function"&&(console.error(`Command not implemented: ${t.join(" ")}`),process.exit(1)),await m({...a,_positional:e})}function q(n,t,e,a=[]){let{specs:o,loadModule:r,hasImplementation:i}=n,m=o.definitions?.global_arguments??[];for(let s of e){U(s.name)||(console.error(`Invalid command name "${s.name}": only alphanumeric, hyphens, and underscores allowed`),process.exit(1));let d=[...a,s.name];if(!g(s,d,i))continue;let c=t.command(s.name,s.removed?{hidden:!0}:void 0).description(s.description??"");if(s.alias&&(Array.isArray(s.alias)?s.alias:[s.alias]).forEach(p=>c.alias(p)),s.removed){c.allowUnknownOption(!0),c.allowExcessArguments(!0),c.action(()=>{R(`${o.name} ${d.join(" ")}`,s.replaced_by)});continue}if(s.commands&&s.commands.length>0)if(q(n,c,s.commands,d),s.default){let l=s.commands.find(p=>p.name===s.default);if(l){let p=y(m,[...s.arguments||[],...l.arguments||[]]);E(c,p),c.allowExcessArguments(!0),c.action(async(...f)=>{let u=f.pop(),x=A([u],s,d,o,i),$=j(p,x,u);p.length>0&&!S(p,$)||(v(p,$),l.deprecated&&l.messages?.onDeprecated&&C(l.messages.onDeprecated),await I(r,[...d,l.name],x,$))})}}else c.allowExcessArguments(!0),c.action((...l)=>{A(l,s,d,o,i),b(o,s,d,i)});else E(c,y(m,s.arguments)),c.action(async(...l)=>{let p=l.pop(),f=l,u=j(s.arguments||[],f,p);s.arguments&&!S(s.arguments,u)||(v(s.arguments,u),s.deprecated&&s.messages?.onDeprecated&&C(s.messages.onDeprecated),await I(r,d,f,u))});c.command("help").description("Show help for this command").action(()=>{b(o,s,d,i)})}}function P(n){let{specs:t,version:e,hasImplementation:a}=n,o=new L;return o.name(t.name).description(t.description).version(e),q(n,o,t.commands),o.command("help").description("Show general help").action(()=>{k(t,e,a)}),o.command("version").description("Show the CLI version").action(()=>{console.log(e)}),o.allowExcessArguments(!0),o.action((...r)=>{A(r,{commands:t.commands},[],t,a),k(t,e,a)}),o}export{G as a,U as b,D as c,g as d,b as e,k as f,E as g,S as h,j as i,q as j,P as k};
@@ -0,0 +1 @@
1
+ import{list as a}from"@tigrisdata/storage";var g=["t3://","tigris://"];function p(t){return g.some(e=>t.startsWith(e))}function u(t){let e=g.find(r=>t.startsWith(r));return c(t.slice(e.length))}function c(t){let e=t.split("/");return{bucket:e[0],path:e.slice(1).join("/")}}async function l(t,e,r){let{data:i}=await a({prefix:`${e}/`,limit:1,config:{...r,bucket:t}});return!!(i?.items&&i.items.length>0)}function f(t){return p(t)?u(t):c(t)}function d(t){let e=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*");return new RegExp("^"+e+"$")}function x(t){let e=t.indexOf("*"),r=t.lastIndexOf("/",e);return r>=0?t.slice(0,r+1):""}function h(t,e){let r=f(t);return e?{bucket:r.bucket,key:e}:{bucket:r.bucket,key:r.path}}async function P(t,e,r){let i=[],s;do{let{data:n,error:o}=await a({prefix:e,paginationToken:s,config:{...r,bucket:t}});if(o)return{items:i,error:o};n?.items&&i.push(...n.items),s=n?.hasMore?n.paginationToken:void 0}while(s);return{items:i}}export{p as a,u as b,c,l as d,f as e,d as f,x as g,h,P as i};
@@ -1 +1 @@
1
- import{a as n}from"./chunk-S77OAN6Y.js";import{b as s}from"./chunk-SMBIT5FI.js";import{e as o}from"./chunk-JP3PXFIQ.js";import m from"enquirer";import{listPolicies as f}from"@tigrisdata/iam";var{prompt:p}=m;async function h(a,t,c="Select a policy:"){let{data:e,error:r}=await f({config:a});if(r&&s(t,r),!e.policies||e.policies.length===0){o(t);return}n("Provide the policy ARN as a positional argument");let{selected:l}=await p({type:"select",name:"selected",message:c,choices:e.policies.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});return l}export{h as a};
1
+ import{a as n}from"./chunk-S77OAN6Y.js";import{b as s}from"./chunk-UBANDLB4.js";import{e as o}from"./chunk-7ZUCJBD5.js";import m from"enquirer";import{listPolicies as f}from"@tigrisdata/iam";var{prompt:p}=m;async function h(a,t,c="Select a policy:"){let{data:e,error:r}=await f({config:a});if(r&&s(t,r),!e.policies||e.policies.length===0){o(t);return}n("Provide the policy ARN as a positional argument");let{selected:l}=await p({type:"select",name:"selected",message:c,choices:e.policies.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});return l}export{h as a};
@@ -1 +1 @@
1
- import{a as s,f as l}from"./chunk-DQMSOC2W.js";import{a as i,k as m}from"./chunk-QWBEROER.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
1
+ import{a as s,f as l}from"./chunk-ZP77TNW7.js";import{a as i,k as m}from"./chunk-QWZ6FK7E.js";import{b as t}from"./chunk-PPNBQWSR.js";import{existsSync as c}from"fs";import{dirname as u,join as a}from"path";import{fileURLToPath as f}from"url";i();var j=f(import.meta.url),d=u(j),h=t(),y=o=>{if(o.length===0)return!1;let e=a(d,"lib",...o)+".js";if(c(e))return!0;let r=a(d,"lib",...o,"index.js");return!!c(r)},b=async o=>{let e=[`./lib/${o.join("/")}.js`,`./lib/${o.join("/")}/index.js`];for(let p of e){let n=await import(p).catch(()=>null);if(n)return{module:n,error:null}}return{module:null,error:`Command not found: ${o.join(" ")}`}},x=m({specs:h,version:s,loadModule:b,hasImplementation:y});x.parse();l();
@@ -1,4 +1,4 @@
1
- import{b as r}from"./chunk-DV3LCXRH.js";import{a as s,d as c}from"./chunk-JP3PXFIQ.js";import{c as i}from"./chunk-PPNBQWSR.js";function a(){return globalThis.__TIGRIS_JSON_MODE===!0}function m(){return process.stderr.isTTY===!0}function g(){return process.stdout.isTTY===!0}function p(n,o){let e=r(n);if(a()){let t={error:{message:e.message,code:e.exitCode,category:e.category}};e.nextActions.length>0&&(t.nextActions=e.nextActions),console.error(JSON.stringify(t))}else if(o||console.error(`
1
+ import{b as r}from"./chunk-DV3LCXRH.js";import{a as s,d as c}from"./chunk-7ZUCJBD5.js";import{c as i}from"./chunk-PPNBQWSR.js";function a(){return globalThis.__TIGRIS_JSON_MODE===!0}function m(){return process.stderr.isTTY===!0}function g(){return process.stdout.isTTY===!0}function p(n,o){let e=r(n);if(a()){let t={error:{message:e.message,code:e.exitCode,category:e.category}};e.nextActions.length>0&&(t.nextActions=e.nextActions),console.error(JSON.stringify(t))}else if(o||console.error(`
2
2
  Error: ${e.message}`),m()&&e.nextActions.length>0){console.error(`
3
3
  Next steps:`);for(let t of e.nextActions)console.error(` \u2192 ${t.command} ${t.description}`)}process.exit(e.exitCode)}function d(n,o){let e=o instanceof Error?o.message:String(o);c(n,e),p(o,n)}function f(n,o){let e=i(n.command,n.operation);return e?.messages?.nextActions?e.messages.nextActions.map(t=>({command:s(t.command,o),description:s(t.description,o)})):[]}function A(n,o){if(!g()||a())return;let e=f(n,o);if(e.length!==0){console.log(`
4
4
  Next steps:`);for(let t of e)console.log(` \u2192 ${t.command} ${t.description}`)}}export{p as a,d as b,f as c,A as d};
@@ -1,4 +1,4 @@
1
- import{a as i,b as a,c as g}from"./chunk-ATBINUDP.js";import{a as A,c as I}from"./chunk-KK7FZ7QM.js";import{i as c,j as y,k as l,l as o,p as d}from"./chunk-OHGCOC5Q.js";import{fromIni as _}from"@aws-sdk/credential-providers";function K(){return process.env.AWS_ENDPOINT_URL_S3||process.env.AWS_ENDPOINT_URL_IAM?{endpoint:process.env.AWS_ENDPOINT_URL_S3||i,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||a,mgmtEndpoint:process.env.AWS_ENDPOINT_URL_MGMT||g}:{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||i,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||a,mgmtEndpoint:process.env.TIGRIS_MGMT_ENDPOINT||g}}var r=K(),S=A();function p(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY){let e=process.env.AWS_ENDPOINT_URL_S3||i;return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,endpoint:e,source:"aws"}}if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID&&process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let e=process.env.TIGRIS_STORAGE_ENDPOINT||i;return{accessKeyId:process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,secretAccessKey:process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY,endpoint:e,source:"tigris"}}return null}var E=!1;async function T(){if(E||!process.stdin.isTTY)return!1;E=!0,console.log(`Not authenticated. Starting login...
1
+ import{a as i,b as a,c as g}from"./chunk-ATBINUDP.js";import{a as A,c as I}from"./chunk-3EAZ2L6H.js";import{i as c,j as y,k as l,l as o,p as d}from"./chunk-OHGCOC5Q.js";import{fromIni as _}from"@aws-sdk/credential-providers";function K(){return process.env.AWS_ENDPOINT_URL_S3||process.env.AWS_ENDPOINT_URL_IAM?{endpoint:process.env.AWS_ENDPOINT_URL_S3||i,iamEndpoint:process.env.AWS_ENDPOINT_URL_IAM||a,mgmtEndpoint:process.env.AWS_ENDPOINT_URL_MGMT||g}:{endpoint:process.env.TIGRIS_STORAGE_ENDPOINT||i,iamEndpoint:process.env.TIGRIS_IAM_ENDPOINT||a,mgmtEndpoint:process.env.TIGRIS_MGMT_ENDPOINT||g}}var r=K(),S=A();function p(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY){let e=process.env.AWS_ENDPOINT_URL_S3||i;return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,endpoint:e,source:"aws"}}if(process.env.TIGRIS_STORAGE_ACCESS_KEY_ID&&process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY){let e=process.env.TIGRIS_STORAGE_ENDPOINT||i;return{accessKeyId:process.env.TIGRIS_STORAGE_ACCESS_KEY_ID,secretAccessKey:process.env.TIGRIS_STORAGE_SECRET_ACCESS_KEY,endpoint:e,source:"tigris"}}return null}var E=!1;async function T(){if(E||!process.stdin.isTTY)return!1;E=!0,console.log(`Not authenticated. Starting login...
2
2
  `);let{default:e}=await import("./lib/login/select.js");return await e({}),console.log(),!0}async function C(){if(y()){let n=process.env.AWS_PROFILE||"default",u=await _({profile:n})();return{type:"aws-profile",profile:n,accessKeyId:u.accessKeyId,secretAccessKey:u.secretAccessKey}}let e=p();if(e)return{type:"environment",accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,source:e.source};let s=d();if(s==="oauth")return{type:"oauth"};if(s==="credentials"){let n=o();if(n)return{type:"credentials",accessKeyId:n.accessKeyId,secretAccessKey:n.secretAccessKey}}let t=o();return t?{type:"configured",accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey}:{type:"none"}}async function f(e){let s=await C();switch(s.type){case"aws-profile":{let t=await l(s.profile);return{accessKeyId:s.accessKeyId,secretAccessKey:s.secretAccessKey,endpoint:t.endpoint||r.endpoint||i,iamEndpoint:t.iamEndpoint||r.iamEndpoint}}case"oauth":{let t=I(),n=c();if(!n)throw new Error('No organization selected. Please run "tigris orgs select" first.');return{sessionToken:await t.getAccessToken(),accessKeyId:"",secretAccessKey:"",...e?.withCredentialProvider&&{credentialProvider:async()=>({accessKeyId:"",secretAccessKey:"",sessionToken:await t.getAccessToken(),expiration:new Date(Date.now()+600*1e3)})},endpoint:r.endpoint,organizationId:n,iamEndpoint:r.iamEndpoint,authDomain:S.domain}}case"credentials":{let t=c();return{accessKeyId:s.accessKeyId,secretAccessKey:s.secretAccessKey,endpoint:o()?.endpoint||i,organizationId:t??void 0,iamEndpoint:r.iamEndpoint}}case"environment":return{accessKeyId:s.accessKeyId,secretAccessKey:s.secretAccessKey,endpoint:p()?.endpoint||i};case"configured":{let t=c();return{accessKeyId:s.accessKeyId,secretAccessKey:s.secretAccessKey,endpoint:o()?.endpoint||i,organizationId:t??void 0,iamEndpoint:r.iamEndpoint}}case"none":{if(await T())return f(e);throw new Error('Not authenticated. Please run "tigris login" or "tigris configure" first.')}}}async function N(){let e=await f(),s=c();return{...e,...s&&!e.organizationId?{organizationId:s}:{}}}function O(e){return d()==="oauth"?!1:(p()||o()?console.log(`You are using access key credentials, which belong to a single organization.
3
3
  ${e} is only available with OAuth login.
4
4
 
@@ -0,0 +1,8 @@
1
+ import{d as m,e as d,f}from"./chunk-ATBINUDP.js";import{mkdirSync as w,readFileSync as _,realpathSync as E,writeFileSync as I}from"fs";import x from"https";import{homedir as g}from"os";import{join as h}from"path";var u="3.0.0-beta.1";var b=h(g(),".tigris","update-check.json");function y(){try{let e=_(b,"utf-8"),n=JSON.parse(e);return typeof n.latestVersion=="string"&&typeof n.lastChecked=="number"?n:null}catch{return null}}function v(e){try{w(h(g(),".tigris"),{recursive:!0}),I(b,JSON.stringify(e),"utf-8")}catch{}}function T(e,n){let a=i=>{let s=i.startsWith("v")?i.slice(1):i,l=null,o=s.indexOf("-");o!==-1&&(l=s.slice(o+1),s=s.slice(0,o));let c=s.split(".");if(c.length!==3)return null;let p=c.map(Number);return p.some(isNaN)?null:{major:p[0],minor:p[1],patch:p[2],prerelease:l}},r=a(e),t=a(n);return!r||!t?!1:t.major>r.major?!0:t.major<r.major?!1:t.minor>r.minor?!0:t.minor<r.minor?!1:t.patch>r.patch?!0:t.patch<r.patch?!1:r.prerelease&&!t.prerelease?!0:(!r.prerelease&&t.prerelease,!1)}function N(){if(process.platform==="win32")return!1;try{let e=E(process.execPath);return e.includes("/Cellar/")||e.includes("/Caskroom/")}catch{return!1}}function M(){return globalThis.__TIGRIS_BINARY===!0?N()?"brew upgrade tigris":process.platform==="win32"?"irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex":"curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh":"npm install -g @tigrisdata/cli"}function k(e={}){return new Promise((n,a)=>{let r=x.get(m,{timeout:1e4},t=>{let i="";t.on("data",s=>{i+=s}),t.on("end",()=>{try{let s=JSON.parse(i);typeof s.version=="string"?(v({...y(),latestVersion:s.version,lastChecked:Date.now()}),n(s.version)):a(new Error("Unexpected registry response"))}catch{a(new Error("Failed to parse registry response"))}})});r.on("error",t=>{a(t)}),r.on("timeout",()=>{r.destroy(),a(new Error("Request timed out"))}),e.unref&&r.on("socket",t=>{t.unref()}),r.end()})}function j(){k({unref:!0}).catch(()=>{})}function O(){if(process.env.TIGRIS_NO_UPDATE_CHECK==="1"||!process.stdout.isTTY)return;let e=y(),n=Number(process.env.TIGRIS_UPDATE_NOTIFY_INTERVAL_MS)||36e5;if(e&&T(u,e.latestVersion)&&(!e.lastNotified||Date.now()-e.lastNotified>n)){let r=`Update available: ${u} \u2192 ${e.latestVersion}`,t='Run "tigris update" to upgrade.',i=Math.max(r.length,t.length)+4,s="\u250C"+"\u2500".repeat(i-2)+"\u2510",l="\u2514"+"\u2500".repeat(i-2)+"\u2518",o=c=>"\u2502 "+c.padEnd(i-4)+" \u2502";console.log(`
2
+ ${s}
3
+ ${o("")}
4
+ ${o(r)}
5
+ ${o(t)}
6
+ ${o("")}
7
+ ${l}
8
+ `),v({...e,lastNotified:Date.now()})}let a=Number(process.env.TIGRIS_UPDATE_CHECK_INTERVAL_MS)||216e5;(!e||Date.now()-e.lastChecked>a)&&j()}export{u as a,y as b,T as c,M as d,k as e,O as f};
package/dist/cli-core.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-QWBEROER.js";import"./chunk-SMBIT5FI.js";import"./chunk-DV3LCXRH.js";import"./chunk-JP3PXFIQ.js";import"./chunk-PPNBQWSR.js";export{g as addArgumentsToCommand,d as commandHasAnyImplementation,k as createProgram,i as extractArgumentValues,c as formatArgumentHelp,b as isValidCommandName,j as registerCommands,a as setupErrorHandlers,e as showCommandHelp,f as showMainHelp,h as validateRequiredWhen};
1
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";export{g as addArgumentsToCommand,d as commandHasAnyImplementation,k as createProgram,i as extractArgumentValues,c as formatArgumentHelp,b as isValidCommandName,j as registerCommands,a as setupErrorHandlers,e as showCommandHelp,f as showMainHelp,h as validateRequiredWhen};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-3L2I7HZB.js";import"./chunk-DQMSOC2W.js";import"./chunk-QWBEROER.js";import"./chunk-SMBIT5FI.js";import"./chunk-DV3LCXRH.js";import"./chunk-JP3PXFIQ.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
2
+ import"./chunk-SO7GMI24.js";import"./chunk-ZP77TNW7.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./chunk-3L2I7HZB.js";import"./chunk-DQMSOC2W.js";import"./chunk-QWBEROER.js";import"./chunk-SMBIT5FI.js";import"./chunk-DV3LCXRH.js";import"./chunk-JP3PXFIQ.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
1
+ import"./chunk-SO7GMI24.js";import"./chunk-ZP77TNW7.js";import"./chunk-QWZ6FK7E.js";import"./chunk-UBANDLB4.js";import"./chunk-DV3LCXRH.js";import"./chunk-7ZUCJBD5.js";import"./chunk-PPNBQWSR.js";import"./chunk-ATBINUDP.js";
@@ -1 +1 @@
1
- import{b as y}from"../../chunk-27KYKU5U.js";import"../../chunk-EKLR55EQ.js";import{a as s,b as h}from"../../chunk-S6KFKBMY.js";import{b as n,c as b,d as p}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as f,j as R}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{assignBucketRoles as x,revokeAllBucketRoles as w}from"@tigrisdata/iam";var e=R("access-keys","assign"),N=["Editor","ReadOnly","NamespaceAdmin"];function v(r){return r?Array.isArray(r)?r:[r]:[]}async function O(r){A(e);let g=h(r),i=s(r,["id"]),m=s(r,["admin"]),d=s(r,["revokeRoles","revoke-roles"]),l=v(s(r,["bucket","b"])),t=v(s(r,["role","r"]));i||n(e,"Access key ID is required"),m&&d&&n(e,"Cannot use --admin and --revoke-roles together");let u=await y(e);if(d){let{error:o}=await w(i,{config:u});o&&n(e,o),g==="json"&&console.log(JSON.stringify({action:"revoked",id:i})),f(e);return}let a;if(m)a=[{bucket:"*",role:"NamespaceAdmin"}];else{l.length===0&&n(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),t.length===0&&n(e,"At least one role is required (or use --admin or --revoke-roles)");for(let o of t)N.includes(o)||n(e,`Invalid role "${o}". Valid roles are: ${N.join(", ")}`);t.length===1?a=l.map(o=>({bucket:o,role:t[0]})):t.length===l.length?a=l.map((o,c)=>({bucket:o,role:t[c]})):n(e,`Number of roles (${t.length}) must be 1 or match number of buckets (${l.length})`)}let{error:k}=await x(i,a,{config:u});if(k&&n(e,k),g==="json"){let o=b(e),c={action:"assigned",id:i,assignments:a};o.length>0&&(c.nextActions=o),console.log(JSON.stringify(c))}f(e),p(e)}export{O as default};
1
+ import{b as y}from"../../chunk-EFPPY2JQ.js";import"../../chunk-YN2TKPPT.js";import{a as s,b as h}from"../../chunk-S6KFKBMY.js";import{b as n,c as b,d as p}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as A,c as f,j as R}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{assignBucketRoles as x,revokeAllBucketRoles as w}from"@tigrisdata/iam";var e=R("access-keys","assign"),N=["Editor","ReadOnly","NamespaceAdmin"];function v(r){return r?Array.isArray(r)?r:[r]:[]}async function O(r){A(e);let g=h(r),i=s(r,["id"]),m=s(r,["admin"]),d=s(r,["revokeRoles","revoke-roles"]),l=v(s(r,["bucket","b"])),t=v(s(r,["role","r"]));i||n(e,"Access key ID is required"),m&&d&&n(e,"Cannot use --admin and --revoke-roles together");let u=await y(e);if(d){let{error:o}=await w(i,{config:u});o&&n(e,o),g==="json"&&console.log(JSON.stringify({action:"revoked",id:i})),f(e);return}let a;if(m)a=[{bucket:"*",role:"NamespaceAdmin"}];else{l.length===0&&n(e,"At least one bucket name is required (or use --admin or --revoke-roles)"),t.length===0&&n(e,"At least one role is required (or use --admin or --revoke-roles)");for(let o of t)N.includes(o)||n(e,`Invalid role "${o}". Valid roles are: ${N.join(", ")}`);t.length===1?a=l.map(o=>({bucket:o,role:t[0]})):t.length===l.length?a=l.map((o,c)=>({bucket:o,role:t[c]})):n(e,`Number of roles (${t.length}) must be 1 or match number of buckets (${l.length})`)}let{error:k}=await x(i,a,{config:u});if(k&&n(e,k),g==="json"){let o=b(e),c={action:"assigned",id:i,assignments:a};o.length>0&&(c.nextActions=o),console.log(JSON.stringify(c))}f(e),p(e)}export{O as default};
@@ -1 +1 @@
1
- import{b as u}from"../../chunk-27KYKU5U.js";import{a as d}from"../../chunk-S77OAN6Y.js";import"../../chunk-EKLR55EQ.js";import{a as l,b as h}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as y,j as g}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import S from"enquirer";import{attachPolicyToAccessKey as N,listPolicies as R,listPoliciesForAccessKey as q}from"@tigrisdata/iam";var{prompt:k}=S,e=g("access-keys","attach-policy");async function v(s){p(e);let A=h(s),o=l(s,["id"]),r=l(s,["policyArn","policy-arn"]);o||t(e,"Access key ID is required");let c=await u(e);if(!r){d("Use --policy-arn to specify the policy ARN");let[a,n]=await Promise.all([R({config:c}),q(o,{config:c})]);a.error&&t(e,a.error),n.error&&t(e,n.error);let w=new Set(n.data.policies),f=a.data.policies.filter(i=>!w.has(i.name));f.length===0&&t(e,"No unassigned policies available. All policies are already attached to this access key.");let{selected:P}=await k({type:"select",name:"selected",message:"Select a policy to attach:",choices:f.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});r=P}let{error:m}=await N(o,r,{config:c});m&&t(e,m),A==="json"&&console.log(JSON.stringify({action:"attached",id:o,policyArn:r})),y(e)}export{v as default};
1
+ import{b as u}from"../../chunk-EFPPY2JQ.js";import{a as d}from"../../chunk-S77OAN6Y.js";import"../../chunk-YN2TKPPT.js";import{a as l,b as h}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as y,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import S from"enquirer";import{attachPolicyToAccessKey as N,listPolicies as R,listPoliciesForAccessKey as q}from"@tigrisdata/iam";var{prompt:k}=S,e=g("access-keys","attach-policy");async function v(s){p(e);let A=h(s),o=l(s,["id"]),r=l(s,["policyArn","policy-arn"]);o||t(e,"Access key ID is required");let c=await u(e);if(!r){d("Use --policy-arn to specify the policy ARN");let[a,n]=await Promise.all([R({config:c}),q(o,{config:c})]);a.error&&t(e,a.error),n.error&&t(e,n.error);let w=new Set(n.data.policies),f=a.data.policies.filter(i=>!w.has(i.name));f.length===0&&t(e,"No unassigned policies available. All policies are already attached to this access key.");let{selected:P}=await k({type:"select",name:"selected",message:"Select a policy to attach:",choices:f.map(i=>({name:i.resource,message:`${i.name} (${i.resource})`}))});r=P}let{error:m}=await N(o,r,{config:c});m&&t(e,m),A==="json"&&console.log(JSON.stringify({action:"attached",id:o,policyArn:r})),y(e)}export{v as default};
@@ -1 +1 @@
1
- import{b as u}from"../../chunk-27KYKU5U.js";import"../../chunk-EKLR55EQ.js";import{a as d,b as p}from"../../chunk-S6KFKBMY.js";import{b as o,c as g,d as f}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,j as l}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{createAccessKey as w}from"@tigrisdata/iam";var t=l("access-keys","create");async function x(n){a(t);let A=p(n),c=d(n,["name"]);c||o(t,"Access key name is required");let y=await u(t),{data:e,error:s}=await w(c,{config:y});if(s&&o(t,s),A==="json"){let r=g(t,{name:e.name,id:e.id}),i={action:"created",name:e.name,id:e.id,secret:e.secret};r.length>0&&(i.nextActions=r),console.log(JSON.stringify(i))}else console.log(` Name: ${e.name}`),console.log(` Access Key ID: ${e.id}`),console.log(` Secret Access Key: ${e.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");m(t),f(t,{name:e.name,id:e.id})}export{x as default};
1
+ import{b as u}from"../../chunk-EFPPY2JQ.js";import"../../chunk-YN2TKPPT.js";import{a as d,b as p}from"../../chunk-S6KFKBMY.js";import{b as o,c as g,d as f}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,j as l}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{createAccessKey as w}from"@tigrisdata/iam";var t=l("access-keys","create");async function x(n){a(t);let A=p(n),c=d(n,["name"]);c||o(t,"Access key name is required");let y=await u(t),{data:e,error:s}=await w(c,{config:y});if(s&&o(t,s),A==="json"){let r=g(t,{name:e.name,id:e.id}),i={action:"created",name:e.name,id:e.id,secret:e.secret};r.length>0&&(i.nextActions=r),console.log(JSON.stringify(i))}else console.log(` Name: ${e.name}`),console.log(` Access Key ID: ${e.id}`),console.log(` Secret Access Key: ${e.secret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");m(t),f(t,{name:e.name,id:e.id})}export{x as default};
@@ -1 +1 @@
1
- import{b as g}from"../../chunk-27KYKU5U.js";import{a as m,b as a}from"../../chunk-S77OAN6Y.js";import"../../chunk-EKLR55EQ.js";import{a as i,b as d}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as s,j as f}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{removeAccessKey as u}from"@tigrisdata/iam";var e=f("access-keys","delete");async function k(r){n(e);let l=d(r),o=i(r,["id"]),p=i(r,["yes","y","force"]);if(o||t(e,"Access key ID is required"),!p&&(m("Use --yes to skip confirmation"),!await a(`Delete access key '${o}'?`))){console.log("Aborted");return}let y=await g(e),{error:c}=await u(o,{config:y});c&&t(e,c),l==="json"&&console.log(JSON.stringify({action:"deleted",id:o})),s(e)}export{k as default};
1
+ import{b as g}from"../../chunk-EFPPY2JQ.js";import{a as m,b as a}from"../../chunk-S77OAN6Y.js";import"../../chunk-YN2TKPPT.js";import{a as i,b as d}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as s,j as f}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{removeAccessKey as u}from"@tigrisdata/iam";var e=f("access-keys","delete");async function k(r){n(e);let l=d(r),o=i(r,["id"]),p=i(r,["yes","y","force"]);if(o||t(e,"Access key ID is required"),!p&&(m("Use --yes to skip confirmation"),!await a(`Delete access key '${o}'?`))){console.log("Aborted");return}let y=await g(e),{error:c}=await u(o,{config:y});c&&t(e,c),l==="json"&&console.log(JSON.stringify({action:"deleted",id:o})),s(e)}export{k as default};
@@ -1 +1 @@
1
- import{b as A}from"../../chunk-27KYKU5U.js";import{a as m,b as h}from"../../chunk-S77OAN6Y.js";import"../../chunk-EKLR55EQ.js";import{a,b as u}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as y,j as g}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import N from"enquirer";import{detachPolicyFromAccessKey as $,listPolicies as q,listPoliciesForAccessKey as F}from"@tigrisdata/iam";var{prompt:R}=N,e=g("access-keys","detach-policy");async function I(c){p(e);let w=u(c),t=a(c,["id"]),i=a(c,["policyArn","policy-arn"]),k=a(c,["yes","y","force"]);t||o(e,"Access key ID is required");let n=await A(e);if(!i){m("Use --policy-arn to specify the policy ARN");let[s,l]=await Promise.all([F(t,{config:n}),q({config:n})]);s.error&&o(e,s.error),l.error&&o(e,l.error);let P=new Set(s.data.policies),d=l.data.policies.filter(r=>P.has(r.name));d.length===0&&o(e,"No policies are attached to this access key.");let{selected:S}=await R({type:"select",name:"selected",message:"Select a policy to detach:",choices:d.map(r=>({name:r.resource,message:`${r.name} (${r.resource})`}))});i=S}if(!k&&(m("Use --yes to skip confirmation"),!await h(`Detach policy '${i}' from access key '${t}'?`))){console.log("Aborted");return}let{error:f}=await $(t,i,{config:n});f&&o(e,f),w==="json"&&console.log(JSON.stringify({action:"detached",id:t,policyArn:i})),y(e)}export{I as default};
1
+ import{b as A}from"../../chunk-EFPPY2JQ.js";import{a as m,b as h}from"../../chunk-S77OAN6Y.js";import"../../chunk-YN2TKPPT.js";import{a,b as u}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as y,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import N from"enquirer";import{detachPolicyFromAccessKey as $,listPolicies as q,listPoliciesForAccessKey as F}from"@tigrisdata/iam";var{prompt:R}=N,e=g("access-keys","detach-policy");async function I(c){p(e);let w=u(c),t=a(c,["id"]),i=a(c,["policyArn","policy-arn"]),k=a(c,["yes","y","force"]);t||o(e,"Access key ID is required");let n=await A(e);if(!i){m("Use --policy-arn to specify the policy ARN");let[s,l]=await Promise.all([F(t,{config:n}),q({config:n})]);s.error&&o(e,s.error),l.error&&o(e,l.error);let P=new Set(s.data.policies),d=l.data.policies.filter(r=>P.has(r.name));d.length===0&&o(e,"No policies are attached to this access key.");let{selected:S}=await R({type:"select",name:"selected",message:"Select a policy to detach:",choices:d.map(r=>({name:r.resource,message:`${r.name} (${r.resource})`}))});i=S}if(!k&&(m("Use --yes to skip confirmation"),!await h(`Detach policy '${i}' from access key '${t}'?`))){console.log("Aborted");return}let{error:f}=await $(t,i,{config:n});f&&o(e,f),w==="json"&&console.log(JSON.stringify({action:"detached",id:t,policyArn:i})),y(e)}export{I as default};
@@ -1 +1 @@
1
- import{b as m}from"../../chunk-27KYKU5U.js";import"../../chunk-EKLR55EQ.js";import{a,b as f}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as g}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{getAccessKey as u}from"@tigrisdata/iam";var e=g("access-keys","get");async function $(s){c(e);let d=f(s),r=a(s,["id"]);r||t(e,"Access key ID is required");let p=await m(e),{data:o,error:n}=await u(r,{config:p});if(n&&t(e,n),d==="json")console.log(JSON.stringify(o));else if(console.log(` Name: ${o.name}`),console.log(` ID: ${o.id}`),console.log(` Status: ${o.status}`),console.log(` Created: ${o.createdAt}`),console.log(` Organization: ${o.organizationId}`),o.roles&&o.roles.length>0){console.log(" Roles:");for(let i of o.roles)console.log(` - ${i.bucket}: ${i.role}`)}else console.log(" Roles: None");l(e)}export{$ as default};
1
+ import{b as m}from"../../chunk-EFPPY2JQ.js";import"../../chunk-YN2TKPPT.js";import{a,b as f}from"../../chunk-S6KFKBMY.js";import{b as t}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{getAccessKey as u}from"@tigrisdata/iam";var e=g("access-keys","get");async function $(s){c(e);let d=f(s),r=a(s,["id"]);r||t(e,"Access key ID is required");let p=await m(e),{data:o,error:n}=await u(r,{config:p});if(n&&t(e,n),d==="json")console.log(JSON.stringify(o));else if(console.log(` Name: ${o.name}`),console.log(` ID: ${o.id}`),console.log(` Status: ${o.status}`),console.log(` Created: ${o.createdAt}`),console.log(` Organization: ${o.organizationId}`),o.roles&&o.roles.length>0){console.log(" Roles:");for(let i of o.roles)console.log(` - ${i.bucket}: ${i.role}`)}else console.log(" Roles: None");l(e)}export{$ as default};
@@ -1 +1 @@
1
- import{b as P}from"../../chunk-27KYKU5U.js";import{g as A}from"../../chunk-IRDNZN7R.js";import"../../chunk-EKLR55EQ.js";import{a as y,b as k,c as h}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as f,e as g,i as d,j as u}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listPoliciesForAccessKey as E}from"@tigrisdata/iam";var i=u("access-keys","list-policies");async function F(o){m(i);let n=k(o),{limit:r,pageToken:s}=h(o),a=y(o,["id"]);a||c(i,"Access key ID is required");let T=await P(i),{data:t,error:p}=await E(a,{...r!==void 0?{limit:r}:{},...s?{paginationToken:s}:{},config:T});if(p&&c(i,p),!t.policies||t.policies.length===0){g(i);return}let e=t.policies.map(O=>({policy:O})),x=[{key:"policy",header:e.length>1?"Attached Policies":"Attached Policy"}],l=t.paginationToken||void 0,w=A(e,n,"policies","policy",x,{paginationToken:l});console.log(w),n!=="json"&&n!=="xml"&&d(l),f(i,{count:e.length})}export{F as default};
1
+ import{b as P}from"../../chunk-EFPPY2JQ.js";import{g as A}from"../../chunk-IRDNZN7R.js";import"../../chunk-YN2TKPPT.js";import{a as y,b as k,c as h}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as m,c as f,e as g,i as d,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listPoliciesForAccessKey as E}from"@tigrisdata/iam";var i=u("access-keys","list-policies");async function F(o){m(i);let n=k(o),{limit:r,pageToken:s}=h(o),a=y(o,["id"]);a||c(i,"Access key ID is required");let T=await P(i),{data:t,error:p}=await E(a,{...r!==void 0?{limit:r}:{},...s?{paginationToken:s}:{},config:T});if(p&&c(i,p),!t.policies||t.policies.length===0){g(i);return}let e=t.policies.map(O=>({policy:O})),x=[{key:"policy",header:e.length>1?"Attached Policies":"Attached Policy"}],l=t.paginationToken||void 0,w=A(e,n,"policies","policy",x,{paginationToken:l});console.log(w),n!=="json"&&n!=="xml"&&d(l),f(i,{count:e.length})}export{F as default};
@@ -1 +1 @@
1
- import{b as h}from"../../chunk-27KYKU5U.js";import{g as T}from"../../chunk-IRDNZN7R.js";import"../../chunk-EKLR55EQ.js";import{b as k,c as y}from"../../chunk-S6KFKBMY.js";import{b as l}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as d,c as p,e as f,i as g,j as u}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listAccessKeys as A}from"@tigrisdata/iam";var t=u("access-keys","list");async function P(a){d(t);let o=k(a),{limit:s,pageToken:i}=y(a),x=await h(t),{data:e,error:r}=await A({...s!==void 0?{limit:s}:{},...i?{paginationToken:i}:{},config:x});if(r&&l(t,r),!e.accessKeys||e.accessKeys.length===0){f(t);return}let c=e.accessKeys.map(n=>({name:n.name,id:n.id,status:n.status,created:n.createdAt})),K=[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}],m=e.paginationToken||void 0,w=T(c,o,"keys","key",K,{paginationToken:m});console.log(w),o!=="json"&&o!=="xml"&&g(m),p(t,{count:c.length})}export{P as default};
1
+ import{b as h}from"../../chunk-EFPPY2JQ.js";import{g as T}from"../../chunk-IRDNZN7R.js";import"../../chunk-YN2TKPPT.js";import{b as k,c as y}from"../../chunk-S6KFKBMY.js";import{b as l}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as d,c as p,e as f,i as g,j as u}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{listAccessKeys as A}from"@tigrisdata/iam";var t=u("access-keys","list");async function P(a){d(t);let o=k(a),{limit:s,pageToken:i}=y(a),x=await h(t),{data:e,error:r}=await A({...s!==void 0?{limit:s}:{},...i?{paginationToken:i}:{},config:x});if(r&&l(t,r),!e.accessKeys||e.accessKeys.length===0){f(t);return}let c=e.accessKeys.map(n=>({name:n.name,id:n.id,status:n.status,created:n.createdAt})),K=[{key:"name",header:"Name"},{key:"id",header:"ID"},{key:"status",header:"Status"},{key:"created",header:"Created"}],m=e.paginationToken||void 0,w=T(c,o,"keys","key",K,{paginationToken:m});console.log(w),o!=="json"&&o!=="xml"&&g(m),p(t,{count:c.length})}export{P as default};
@@ -1 +1 @@
1
- import{b as w}from"../../chunk-27KYKU5U.js";import{a as u,b as y}from"../../chunk-S77OAN6Y.js";import"../../chunk-EKLR55EQ.js";import{a as i,b as p}from"../../chunk-S6KFKBMY.js";import{b as n,c as g,d as m}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as l,j as d}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{rotateAccessKey as k}from"@tigrisdata/iam";var e=d("access-keys","rotate");async function x(o){f(e);let A=p(o),r=i(o,["id"]),S=i(o,["yes","y","force"]);if(r||n(e,"Access key ID is required"),!S&&(u("Use --yes to skip confirmation"),!await y(`Rotate access key '${r}'? The current secret will be invalidated.`))){console.log("Aborted");return}let h=await w(e),{data:t,error:s}=await k(r,{config:h});if(s&&n(e,s),A==="json"){let c=g(e,{id:t.id}),a={action:"rotated",id:t.id,secret:t.newSecret};c.length>0&&(a.nextActions=c),console.log(JSON.stringify(a))}else console.log(` Access Key ID: ${t.id}`),console.log(` New Secret Access Key: ${t.newSecret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");l(e),m(e,{id:t.id})}export{x as default};
1
+ import{b as w}from"../../chunk-EFPPY2JQ.js";import{a as u,b as y}from"../../chunk-S77OAN6Y.js";import"../../chunk-YN2TKPPT.js";import{a as i,b as p}from"../../chunk-S6KFKBMY.js";import{b as n,c as g,d as m}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as l,j as d}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-GAWFFIPC.js";import"../../chunk-OHGCOC5Q.js";import{rotateAccessKey as k}from"@tigrisdata/iam";var e=d("access-keys","rotate");async function x(o){f(e);let A=p(o),r=i(o,["id"]),S=i(o,["yes","y","force"]);if(r||n(e,"Access key ID is required"),!S&&(u("Use --yes to skip confirmation"),!await y(`Rotate access key '${r}'? The current secret will be invalidated.`))){console.log("Aborted");return}let h=await w(e),{data:t,error:s}=await k(r,{config:h});if(s&&n(e,s),A==="json"){let c=g(e,{id:t.id}),a={action:"rotated",id:t.id,secret:t.newSecret};c.length>0&&(a.nextActions=c),console.log(JSON.stringify(a))}else console.log(` Access Key ID: ${t.id}`),console.log(` New Secret Access Key: ${t.newSecret}`),console.log(""),console.log(" Save these credentials securely. The secret will not be shown again.");l(e),m(e,{id:t.id})}export{x as default};
@@ -1 +1 @@
1
- import{a as R,b as O}from"../../chunk-TD2HGNDY.js";import{a as q}from"../../chunk-S77OAN6Y.js";import{d as N}from"../../chunk-EKLR55EQ.js";import{a as t,b as D}from"../../chunk-S6KFKBMY.js";import{b as r,c as T,d as L}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as C,j as B}from"../../chunk-JP3PXFIQ.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as E}from"@tigrisdata/storage";import j from"enquirer";var{prompt:F}=j,n=B("buckets","create");async function J(e){x(n);let P=D(e),s=t(e,["name"]),b=t(e,["public"])?"public":t(e,["access","a","A"]),h=t(e,["enable-snapshots","s","S"]),S=t(e,["default-tier","t","T"]),l=t(e,["locations","l","L"]),a=t(e,["fork-of","forkOf","fork"]),f=t(e,["source-snapshot","sourceSnapshot","source-snap"]),k=t(e,["region","r","R"]),I=t(e,["consistency","c","C"]);k!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),l===void 0&&(l=k)),I!==void 0&&console.warn("Warning: --consistency is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/");let W=!s,w;if(W){q("Provide --name to skip interactive mode");let c=p("buckets","access","create"),o=g(c),d=o?.findIndex(i=>i.value===c?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(i=>i.value===v?.default),u=await F([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:o||[],initial:d!==void 0&&d>=0?d:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,b=u.access,S=u.defaultTier,h=u.enableSnapshots;try{w=await R()}catch(i){r(n,i)}}s||r(n,"Bucket name is required"),f&&!a&&r(n,"--source-snapshot requires --fork-of");let{error:y}=await E(s,{defaultTier:S??"STANDARD",enableSnapshot:h===!0,access:b??"private",locations:w??O(l??"global"),...a?{sourceBucketName:a}:{},...f?{sourceBucketSnapshot:f}:{},config:await N()});if(y&&r(n,y),P==="json"){let c=T(n,{name:s}),o={action:"created",name:s,...a?{forkOf:a}:{}};c.length>0&&(o.nextActions=c),console.log(JSON.stringify(o))}C(n,{name:s}),L(n,{name:s})}export{J as default};
1
+ import{a as D,b as N}from"../../chunk-TD2HGNDY.js";import{a as C}from"../../chunk-S77OAN6Y.js";import{d as q}from"../../chunk-YN2TKPPT.js";import{a as t,b as L}from"../../chunk-S6KFKBMY.js";import{b as i,c as T,d as w}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as x,c as y,j as B}from"../../chunk-7ZUCJBD5.js";import{d as p,e as g}from"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{createBucket as R}from"@tigrisdata/storage";import E from"enquirer";var{prompt:j}=E,a=B("buckets","create");async function F(e){x(a);let O=L(e),s=t(e,["name"]),d=t(e,["public"])?"public":t(e,["access","a","A"]),b=t(e,["enable-snapshots","s","S"]),h=t(e,["default-tier","t","T"]),P=t(e,["locations","l","L"]),o=t(e,["fork-of","forkOf","fork"]),l=t(e,["source-snapshot","sourceSnapshot","source-snap"]),I=!s,S;if(I){C("Provide --name to skip interactive mode");let n=p("buckets","access","create"),r=g(n),f=r?.findIndex(c=>c.value===n?.default),v=p("buckets","default-tier","create"),A=g(v),m=A?.findIndex(c=>c.value===v?.default),u=await j([{type:"input",name:"name",message:"Bucket name:",required:!0},{type:"select",name:"access",message:"Access level:",choices:r||[],initial:f!==void 0&&f>=0?f:0},{type:"select",name:"defaultTier",message:"Default storage tier:",choices:A||[],initial:m!==void 0&&m>=0?m:0},{type:"confirm",name:"enableSnapshots",message:"Enable snapshots?",initial:!0}]);s=u.name,d=u.access,h=u.defaultTier,b=u.enableSnapshots;try{S=await D()}catch(c){i(a,c)}}s||i(a,"Bucket name is required"),l&&!o&&i(a,"--source-snapshot requires --fork-of");let{error:k}=await R(s,{defaultTier:h??"STANDARD",enableSnapshot:b===!0,access:d??"private",locations:S??N(P??"global"),...o?{sourceBucketName:o}:{},...l?{sourceBucketSnapshot:l}:{},config:await q()});if(k&&i(a,k),O==="json"){let n=T(a,{name:s}),r={action:"created",name:s,...o?{forkOf:o}:{}};n.length>0&&(r.nextActions=n),console.log(JSON.stringify(r))}y(a,{name:s}),w(a,{name:s})}export{F as default};
@@ -1 +1 @@
1
- import{a as x,b as y}from"../../chunk-S77OAN6Y.js";import{d as b}from"../../chunk-EKLR55EQ.js";import{a as s,b as A}from"../../chunk-S6KFKBMY.js";import{a as p,b as d,c as k,d as h}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as g,d as u,j as l}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{removeBucket as N}from"@tigrisdata/storage";var e=l("buckets","delete");async function B(i){f(e);let w=A(i),o=s(i,["name"]),c=s(i,["yes","y","force"]);o||d(e,"Bucket name is required");let a=Array.isArray(o)?o:[o],S=await b();if(!c&&(x("Use --yes to skip confirmation"),!await y(`Delete ${a.length} bucket(s)?`))){console.log("Aborted");return}let m=[],n=[];for(let t of a){let{error:r}=await N(t,{config:S,force:c});r?(u(e,r.message,{name:t}),n.push({name:t,error:r.message})):(m.push(t),g(e,{name:t}))}if(w==="json"){let t=k(e),r={action:"deleted",names:m,errors:n};t.length>0&&(r.nextActions=t),console.log(JSON.stringify(r))}n.length>0&&p(n[0].error,e),h(e)}export{B as default};
1
+ import{a as x,b as y}from"../../chunk-S77OAN6Y.js";import{d as b}from"../../chunk-YN2TKPPT.js";import{a as s,b as A}from"../../chunk-S6KFKBMY.js";import{a as p,b as d,c as k,d as h}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as g,d as u,j as l}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{removeBucket as N}from"@tigrisdata/storage";var e=l("buckets","delete");async function B(i){f(e);let w=A(i),o=s(i,["name"]),c=s(i,["yes","y","force"]);o||d(e,"Bucket name is required");let a=Array.isArray(o)?o:[o],S=await b();if(!c&&(x("Use --yes to skip confirmation"),!await y(`Delete ${a.length} bucket(s)?`))){console.log("Aborted");return}let m=[],n=[];for(let t of a){let{error:r}=await N(t,{config:S,force:c});r?(u(e,r.message,{name:t}),n.push({name:t,error:r.message})):(m.push(t),g(e,{name:t}))}if(w==="json"){let t=k(e),r={action:"deleted",names:m,errors:n};t.length>0&&(r.nextActions=t),console.log(JSON.stringify(r))}n.length>0&&p(n[0].error,e),h(e)}export{B as default};
@@ -1 +1 @@
1
- import{a as s}from"../../chunk-4ZHCF5D6.js";import{f as u}from"../../chunk-IRDNZN7R.js";import{d as f}from"../../chunk-EKLR55EQ.js";import{a as p,b as c}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h}from"@tigrisdata/storage";var t=m("buckets","get");async function w(e){a(t);let r=p(e,["name"]),g=c(e);r||o(t,"Bucket name is required");let{data:k,error:n}=await h(r,{config:await f()});n&&o(t,n);let l=[{property:"Name",value:r},...s(k).map(({label:d,value:b})=>({property:d,value:b}))],y=u(l,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(y),i(t)}export{w as default};
1
+ import{c as s}from"../../chunk-HWX63Y3P.js";import{f as u}from"../../chunk-IRDNZN7R.js";import{d as f}from"../../chunk-YN2TKPPT.js";import{a as p,b as c}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as h}from"@tigrisdata/storage";var t=m("buckets","get");async function w(e){a(t);let r=p(e,["name"]),g=c(e);r||o(t,"Bucket name is required");let{data:k,error:n}=await h(r,{config:await f()});n&&o(t,n);let l=[{property:"Name",value:r},...s(k).map(({label:d,value:b})=>({property:d,value:b}))],y=u(l,g,"bucket","property",[{key:"property",header:"Property"},{key:"value",header:"Value"}]);console.log(y),i(t)}export{w as default};
@@ -0,0 +1 @@
1
+ import{a as R,b as k,c as b,d as F,e as I,f as c,g as h}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import"../../../chunk-IRDNZN7R.js";import{e as y}from"../../../chunk-YN2TKPPT.js";import{a as x,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as p,j as g}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";var t=g("buckets lifecycle","create");async function O(r){m(t);let C=w(r),i=x(r,["name"]);i||n(t,"Bucket name is required");let e=R(r),d=k(e);d&&n(t,d);let a=b(e),o=F(e);!a.storageClass&&!o&&n(t,"A new rule must include a transition (--storage-class with --days or --date) and/or an expiration (--expire-days or --expire-date)"),a.storageClass&&e.days===void 0&&e.date===void 0&&n(t,"--storage-class requires --days or --date for a new transition rule");let f=I(e),s=await y(),u=await c(t,i,s),S={...a,...o?{expiration:o}:{},...e.prefix!==void 0?{filter:{prefix:e.prefix}}:{},...f!==void 0?{enabled:f}:{}};await h(t,i,[...u,S],s);let l=(await c(t,i,s)).find(B=>!u.some(E=>E.id===B.id))?.id??"(unknown)";C==="json"&&console.log(JSON.stringify({action:"created",bucket:i,id:l})),p(t,{name:i,id:l})}export{O as default};
@@ -0,0 +1 @@
1
+ import{a as C,b as R,c as k,d as F,e as S,f as q,g as w}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import"../../../chunk-IRDNZN7R.js";import{e as b}from"../../../chunk-YN2TKPPT.js";import{a as c,b as x}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as y,j as h}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";var i=h("buckets lifecycle","edit");async function E(o){p(i);let T=x(o),n=c(o,["name"]),s=c(o,["id"]);n||t(i,"Bucket name is required"),s||t(i,"Rule id is required");let e=C(o),l=R(e,{requireStorageClassForTiming:!1});l&&t(i,l);let d=k(e),f=F(e),u=S(e);d.storageClass!==void 0||d.days!==void 0||d.date!==void 0||f!==void 0||u!==void 0||e.prefix!==void 0||t(i,"Provide at least one field to change (--storage-class, --days, --date, --expire-days, --expire-date, --prefix, --enable, --disable)");let g=await b(),m=await q(i,n,g),r=m.find(a=>a.id===s);if(r||t(i,`No lifecycle rule with id "${s}" found. Run \`tigris buckets lifecycle list ${n}\` to see ids.`),e.storageClass!==void 0||e.days!==void 0||e.date!==void 0){let a=d.storageClass??r.storageClass,B=e.days!==void 0?Number(e.days):e.date!==void 0?void 0:r.days,D=e.date!==void 0?e.date:e.days!==void 0?void 0:r.date;a||t(i,"--storage-class is required (this rule has no existing transition target)"),B===void 0&&D===void 0&&t(i,"--days or --date is required (this rule has no existing transition timing)")}let I={...r,...d,...f?{expiration:f}:{},...e.prefix!==void 0?{filter:{prefix:e.prefix}}:{},...u!==void 0?{enabled:u}:{}},v=m.map(a=>a.id===s?I:a);await w(i,n,v,g),T==="json"&&console.log(JSON.stringify({action:"updated",bucket:n,id:s})),y(i,{name:n,id:s})}export{E as default};
@@ -0,0 +1 @@
1
+ import{h,i as b}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import{b as x,d as y,e as k}from"../../../chunk-IRDNZN7R.js";import{d as g}from"../../../chunk-YN2TKPPT.js";import{a as u,b as d}from"../../../chunk-S6KFKBMY.js";import{b as r}from"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as m,e as c,j as p}from"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";import"../../../chunk-ATBINUDP.js";import"../../../chunk-3EAZ2L6H.js";import"../../../chunk-OHGCOC5Q.js";import{getBucketInfo as T}from"@tigrisdata/storage";var e=p("buckets lifecycle","list");async function w(n){f(e);let a=u(n,["name"]),s=d(n);a||r(e,"Bucket name is required");let{data:C,error:l}=await T(a,{config:await g()});l&&r(e,l);let o=C?.settings.lifecycleRules??[];if(o.length===0){c(e);return}let i=o.map(t=>({id:t.id??"-",prefix:t.filter?.prefix??"-",transition:h(t),expiration:b(t),status:t.enabled===!1?"disabled":"enabled"}));console.log(s==="json"?x(i):s==="xml"?y(i,"lifecycleRules","rule"):k(i,[{key:"id",header:"ID"},{key:"prefix",header:"Prefix"},{key:"transition",header:"Transition"},{key:"expiration",header:"Expiration"},{key:"status",header:"Status"}])),m(e,{count:o.length})}export{w as default};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i}from"../../../chunk-EBWDZEHM.js";import"../../../chunk-HWX63Y3P.js";import"../../../chunk-IRDNZN7R.js";import"../../../chunk-S6KFKBMY.js";import"../../../chunk-UBANDLB4.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-7ZUCJBD5.js";import"../../../chunk-PPNBQWSR.js";export{e as enabledFromInput,d as expirationFromInput,f as fetchExistingRules,i as formatExpirationCell,h as formatTransitionCell,a as readRuleInput,g as submitRules,c as transitionDeltaFromInput,b as validateRuleFieldCombinations};
@@ -1 +1 @@
1
- import{f as x,g as I}from"../../chunk-IRDNZN7R.js";import{d as T}from"../../chunk-EKLR55EQ.js";import{a as y,b as C,c as P}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b,c as u,e as s,i as O,j as w}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as D,listBuckets as F}from"@tigrisdata/storage";var t=w("buckets","list");async function H(f){b(t);let o=C(f),e=y(f,["forks-of","forksOf"]),{limit:k,pageToken:g,isPaginated:E}=P(f),c=await T();e&&E&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)");let{data:n,error:d}=await F({...e?{}:{...k!==void 0?{limit:k}:{},...g?{paginationToken:g}:{}},config:c});if(d&&m(t,d),!n.buckets||n.buckets.length===0){s(t);return}if(e){let{data:r,error:h}=await D(e,{config:c});if(h&&m(t,h),!r.forkInfo?.hasChildren){s(t);return}let a=[];for(let i of n.buckets){if(i.name===e)continue;let{data:j}=await D(i.name,{config:c});j?.forkInfo?.parents?.some(A=>A.bucketName===e)&&a.push({name:i.name,created:i.creationDate})}if(a.length===0){s(t);return}let B=x(a,o,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(B),u(t,{count:a.length});return}let l=n.buckets.map(r=>({name:r.name,created:r.creationDate})),N=[{key:"name",header:"Name"},{key:"created",header:"Created"}],p=n.paginationToken||void 0,S=I(l,o,"buckets","bucket",N,{paginationToken:p});console.log(S),o!=="json"&&o!=="xml"&&O(p),u(t,{count:l.length})}export{H as default};
1
+ import{f as x,g as I}from"../../chunk-IRDNZN7R.js";import{d as T}from"../../chunk-YN2TKPPT.js";import{a as y,b as C,c as P}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b,c as u,e as s,i as O,j as w}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{getBucketInfo as D,listBuckets as F}from"@tigrisdata/storage";var t=w("buckets","list");async function H(f){b(t);let o=C(f),e=y(f,["forks-of","forksOf"]),{limit:k,pageToken:g,isPaginated:E}=P(f),c=await T();e&&E&&console.warn("\u26A0 Pagination flags are ignored when --forks-of is used (all buckets are fetched for filtering)");let{data:n,error:d}=await F({...e?{}:{...k!==void 0?{limit:k}:{},...g?{paginationToken:g}:{}},config:c});if(d&&m(t,d),!n.buckets||n.buckets.length===0){s(t);return}if(e){let{data:r,error:h}=await D(e,{config:c});if(h&&m(t,h),!r.forkInfo?.hasChildren){s(t);return}let a=[];for(let i of n.buckets){if(i.name===e)continue;let{data:j}=await D(i.name,{config:c});j?.forkInfo?.parents?.some(A=>A.bucketName===e)&&a.push({name:i.name,created:i.creationDate})}if(a.length===0){s(t);return}let B=x(a,o,"forks","fork",[{key:"name",header:"Name"},{key:"created",header:"Created"}]);console.log(B),u(t,{count:a.length});return}let l=n.buckets.map(r=>({name:r.name,created:r.creationDate})),N=[{key:"name",header:"Name"},{key:"created",header:"Created"}],p=n.paginationToken||void 0,S=I(l,o,"buckets","bucket",N,{paginationToken:p});console.log(S),o!=="json"&&o!=="xml"&&O(p),u(t,{count:l.length})}export{H as default};
@@ -1,3 +1,3 @@
1
- import{a as w}from"../../chunk-SAAGVLRE.js";import{a as h}from"../../chunk-IRDNZN7R.js";import{f as F}from"../../chunk-JQUG732D.js";import{d as v}from"../../chunk-EKLR55EQ.js";import{a as M}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{d as S,j as y}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{isMigrated as x,list as B,migrate as R}from"@tigrisdata/storage";var u=y("buckets","migrate"),N=10*1024*1024*1024,b=50,z=5e3,D=50,k=3,_=class{constructor(r,i,s,c){this.bucket=r;this.source=i;this.prefix=s;this.config=c}bucket;source;prefix;config;buffer=[];index=0;token;_done=!1;get done(){return this._done&&this.index>=this.buffer.length}async current(){return this.index<this.buffer.length?this.buffer[this.index]:this._done?null:(await this.fetchPage(),this.index<this.buffer.length?this.buffer[this.index]:null)}advance(){this.index++}async fetchPage(){if(this._done)return;let{data:r,error:i}=await B({prefix:this.prefix,source:this.source,...this.token?{paginationToken:this.token}:{},config:{...this.config,bucket:this.bucket}});if(i)throw i;this.buffer=r.items??[],this.index=0,this.token=r.paginationToken,!r.paginationToken&&!r.hasMore&&(this._done=!0)}};async function C(t,r,i){let s=new _(t,"shadow",r,i),c=new _(t,"tigris",r,i),o=[],n=await s.current(),a=await c.current();for(;n!==null;){if(a===null){o.push({name:n.name,size:n.size}),s.advance(),n=await s.current();continue}n.name<a.name?(o.push({name:n.name,size:n.size}),s.advance(),n=await s.current()):n.name>a.name?(c.advance(),a=await c.current()):(s.advance(),c.advance(),n=await s.current(),a=await c.current())}return o}function L(t){return new Promise(r=>setTimeout(r,t))}function E(t){let r=Math.floor(t/1e3),i=Math.floor(r/60),s=r%60;return i===0?`${s}s`:`${i}m ${s}s`}function p(t,r){if(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)return;let i=E(Date.now()-t.startTime),s=`\rMigrating ${r}: ${t.confirmed.toLocaleString()} / ${t.total.toLocaleString()} objects | In-flight: ${h(t.inFlightBytes)} | ${i}`;process.stderr.write(s+" ".repeat(Math.max(0,100-s.length)))}function T(){!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE||process.stderr.write("\r"+" ".repeat(100)+"\r")}async function $(t,r,i,s){let c=await w(t.map(o=>()=>R(o.name,{config:{...i,bucket:s}})),b);for(let o=0;o<c.length;o++){let n=c[o],a=t[o];n.error?(r.failed++,r.errors.push({name:a.name,error:n.error.message})):(r.inFlight.push({...a,checkFailures:0}),r.inFlightBytes+=a.size,r.scheduled++)}}async function O(t,r,i){if(t.inFlight.length===0)return;let s=t.inFlight.slice(0,b),c=await w(s.map(n=>()=>x(n.name,{config:{...r,bucket:i}})),b),o=new Set;for(let n=0;n<c.length;n++){let a=c[n],l=s[n];a.error?(l.checkFailures++,l.checkFailures>=k&&(o.add(l.name),t.failed++,t.inFlightBytes-=l.size,t.errors.push({name:l.name,error:`Failed to verify migration status after ${k} attempts`}))):a.data&&(o.add(l.name),t.confirmed++,t.confirmedBytes+=l.size,t.inFlightBytes-=l.size)}o.size>0&&(t.inFlight=t.inFlight.filter(n=>!o.has(n.name))),o.size===0&&await L(z)}async function P(t){let r=M(t,["path"]);r||m(u,"Bucket name or path is required");let{bucket:i,path:s}=F(r);i||m(u,"Invalid path");let c=await v(),o=!1,n=()=>{o=!0};process.on("SIGINT",n);try{process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&process.stderr.write("Discovering objects to migrate...");let a;try{a=await C(i,s,c)}catch(f){T(),m(u,f)}if(T(),a.length===0){process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error("All objects are already migrated."),globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:0,confirmed:0,failed:0}));return}let l=a.reduce((f,d)=>f+d.size,0);process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error(`Found ${a.length.toLocaleString()} objects to migrate (${h(l)})`);let e={total:a.length,totalBytes:l,scheduled:0,confirmed:0,confirmedBytes:0,failed:0,inFlight:[],inFlightBytes:0,errors:[],startTime:Date.now()},g=[];for(let f of a){if(o)break;for(;e.inFlightBytes+f.size>N&&e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);if(o)break;g.push(f),g.length>=D&&(await $(g,e,c,i),g=[],p(e,i))}for(g.length>0&&!o&&(await $(g,e,c,i),p(e,i));e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);T();let I=E(Date.now()-e.startTime);if(globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:e.total,scheduled:e.scheduled,confirmed:e.confirmed,failed:e.failed,elapsed:I,...e.errors.length>0?{errors:e.errors.slice(0,20)}:{}})),o&&(console.error(`
1
+ import{a as w}from"../../chunk-SAAGVLRE.js";import{a as h}from"../../chunk-IRDNZN7R.js";import{e as F}from"../../chunk-RXNG56FL.js";import{d as v}from"../../chunk-YN2TKPPT.js";import{a as M}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{d as S,j as y}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{isMigrated as x,list as B,migrate as R}from"@tigrisdata/storage";var u=y("buckets","migrate"),N=10*1024*1024*1024,b=50,z=5e3,D=50,k=3,_=class{constructor(r,i,s,c){this.bucket=r;this.source=i;this.prefix=s;this.config=c}bucket;source;prefix;config;buffer=[];index=0;token;_done=!1;get done(){return this._done&&this.index>=this.buffer.length}async current(){return this.index<this.buffer.length?this.buffer[this.index]:this._done?null:(await this.fetchPage(),this.index<this.buffer.length?this.buffer[this.index]:null)}advance(){this.index++}async fetchPage(){if(this._done)return;let{data:r,error:i}=await B({prefix:this.prefix,source:this.source,...this.token?{paginationToken:this.token}:{},config:{...this.config,bucket:this.bucket}});if(i)throw i;this.buffer=r.items??[],this.index=0,this.token=r.paginationToken,!r.paginationToken&&!r.hasMore&&(this._done=!0)}};async function C(t,r,i){let s=new _(t,"shadow",r,i),c=new _(t,"tigris",r,i),o=[],n=await s.current(),a=await c.current();for(;n!==null;){if(a===null){o.push({name:n.name,size:n.size}),s.advance(),n=await s.current();continue}n.name<a.name?(o.push({name:n.name,size:n.size}),s.advance(),n=await s.current()):n.name>a.name?(c.advance(),a=await c.current()):(s.advance(),c.advance(),n=await s.current(),a=await c.current())}return o}function L(t){return new Promise(r=>setTimeout(r,t))}function E(t){let r=Math.floor(t/1e3),i=Math.floor(r/60),s=r%60;return i===0?`${s}s`:`${i}m ${s}s`}function p(t,r){if(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)return;let i=E(Date.now()-t.startTime),s=`\rMigrating ${r}: ${t.confirmed.toLocaleString()} / ${t.total.toLocaleString()} objects | In-flight: ${h(t.inFlightBytes)} | ${i}`;process.stderr.write(s+" ".repeat(Math.max(0,100-s.length)))}function T(){!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE||process.stderr.write("\r"+" ".repeat(100)+"\r")}async function $(t,r,i,s){let c=await w(t.map(o=>()=>R(o.name,{config:{...i,bucket:s}})),b);for(let o=0;o<c.length;o++){let n=c[o],a=t[o];n.error?(r.failed++,r.errors.push({name:a.name,error:n.error.message})):(r.inFlight.push({...a,checkFailures:0}),r.inFlightBytes+=a.size,r.scheduled++)}}async function O(t,r,i){if(t.inFlight.length===0)return;let s=t.inFlight.slice(0,b),c=await w(s.map(n=>()=>x(n.name,{config:{...r,bucket:i}})),b),o=new Set;for(let n=0;n<c.length;n++){let a=c[n],l=s[n];a.error?(l.checkFailures++,l.checkFailures>=k&&(o.add(l.name),t.failed++,t.inFlightBytes-=l.size,t.errors.push({name:l.name,error:`Failed to verify migration status after ${k} attempts`}))):a.data&&(o.add(l.name),t.confirmed++,t.confirmedBytes+=l.size,t.inFlightBytes-=l.size)}o.size>0&&(t.inFlight=t.inFlight.filter(n=>!o.has(n.name))),o.size===0&&await L(z)}async function P(t){let r=M(t,["path"]);r||m(u,"Bucket name or path is required");let{bucket:i,path:s}=F(r);i||m(u,"Invalid path");let c=await v(),o=!1,n=()=>{o=!0};process.on("SIGINT",n);try{process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&process.stderr.write("Discovering objects to migrate...");let a;try{a=await C(i,s,c)}catch(f){T(),m(u,f)}if(T(),a.length===0){process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error("All objects are already migrated."),globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:0,confirmed:0,failed:0}));return}let l=a.reduce((f,d)=>f+d.size,0);process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error(`Found ${a.length.toLocaleString()} objects to migrate (${h(l)})`);let e={total:a.length,totalBytes:l,scheduled:0,confirmed:0,confirmedBytes:0,failed:0,inFlight:[],inFlightBytes:0,errors:[],startTime:Date.now()},g=[];for(let f of a){if(o)break;for(;e.inFlightBytes+f.size>N&&e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);if(o)break;g.push(f),g.length>=D&&(await $(g,e,c,i),g=[],p(e,i))}for(g.length>0&&!o&&(await $(g,e,c,i),p(e,i));e.inFlight.length>0&&!o;)await O(e,c,i),p(e,i);T();let I=E(Date.now()-e.startTime);if(globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:i,toMigrate:e.total,scheduled:e.scheduled,confirmed:e.confirmed,failed:e.failed,elapsed:I,...e.errors.length>0?{errors:e.errors.slice(0,20)}:{}})),o&&(console.error(`
2
2
  Interrupted. ${e.confirmed} confirmed, ${e.inFlight.length} still in-flight, ${e.total-e.scheduled} not yet scheduled.`),process.exit(1)),e.failed>0){if(S(u,`${e.failed} object(s) failed to migrate. ${e.confirmed} migrated successfully in ${I}.`),process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&e.errors.length>0){let f=e.errors.slice(0,10);for(let d of f)console.error(` ${d.name}: ${d.error}`);e.errors.length>10&&console.error(` ... and ${e.errors.length-10} more`)}process.exit(1)}console.error(`
3
3
  Migration complete: ${e.confirmed.toLocaleString()} object(s) migrated (${h(e.confirmedBytes)}) in ${I}`)}finally{process.removeListener("SIGINT",n)}}export{P as default};
@@ -1 +1 @@
1
- import{e as b}from"../../chunk-EKLR55EQ.js";import{a as r,b as x}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as h}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=h("buckets","set-cors");async function k(e){c(n);let p=x(e),o=r(e,["name"]),s=r(e,["origins"]),d=r(e,["methods"]),a=r(e,["headers"]),f=r(e,["expose-headers","exposeHeaders"]),t=r(e,["max-age","maxAge"]),g=r(e,["override"]),m=r(e,["reset"]);o||i(n,"Bucket name is required"),m&&(s!==void 0||d!==void 0||a!==void 0||f!==void 0||t!==void 0||g)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await b(),{error:u}=await N(o,{rules:m?[]:[{allowedOrigins:s,...d!==void 0?{allowedMethods:d}:{},...a!==void 0?{allowedHeaders:a}:{},...f!==void 0?{exposeHeaders:f}:{},maxAge:t!==void 0?Number(t):3600}],override:g??!1,config:w});u&&i(n,u),p==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(n,{name:o})}export{k as default};
1
+ import{e as b}from"../../chunk-YN2TKPPT.js";import{a as r,b as x}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as h}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=h("buckets","set-cors");async function k(e){c(n);let p=x(e),o=r(e,["name"]),s=r(e,["origins"]),d=r(e,["methods"]),a=r(e,["headers"]),f=r(e,["expose-headers","exposeHeaders"]),t=r(e,["max-age","maxAge"]),g=r(e,["override"]),m=r(e,["reset"]);o||i(n,"Bucket name is required"),m&&(s!==void 0||d!==void 0||a!==void 0||f!==void 0||t!==void 0||g)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await b(),{error:u}=await N(o,{rules:m?[]:[{allowedOrigins:s,...d!==void 0?{allowedMethods:d}:{},...a!==void 0?{allowedHeaders:a}:{},...f!==void 0?{exposeHeaders:f}:{},maxAge:t!==void 0?Number(t):3600}],override:g??!1,config:w});u&&i(n,u),p==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(n,{name:o})}export{k as default};
@@ -1 +1 @@
1
- import{a as l,b as d}from"../../chunk-TD2HGNDY.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-EKLR55EQ.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as y}from"@tigrisdata/storage";var t=m("buckets","set-locations");async function B(r){s(t);let k=p(r),o=e(r,["name"]),a=e(r,["locations"]);o||i(t,"Bucket name is required");let n;if(a!==void 0)n=d(a);else{g("Provide --locations flag");try{n=await l()}catch(w){i(t,w)}}let L=await u(),{error:c}=await y(o,{locations:n,config:L});c&&i(t,c),k==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),f(t,{name:o})}export{B as default};
1
+ import{a as l,b as d}from"../../chunk-TD2HGNDY.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{e as u}from"../../chunk-YN2TKPPT.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as y}from"@tigrisdata/storage";var t=m("buckets","set-locations");async function B(r){s(t);let k=p(r),o=e(r,["name"]),a=e(r,["locations"]);o||i(t,"Bucket name is required");let n;if(a!==void 0)n=d(a);else{g("Provide --locations flag");try{n=await l()}catch(w){i(t,w)}}let L=await u(),{error:c}=await y(o,{locations:n,config:L});c&&i(t,c),k==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),f(t,{name:o})}export{B as default};
@@ -1 +1 @@
1
- import{e as p}from"../../chunk-EKLR55EQ.js";import{a as t,b as w}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketMigration as S}from"@tigrisdata/storage";var n=y("buckets","set-migration");async function K(e){h(n);let d=w(e),i=t(e,["name"]),o=t(e,["bucket"]),a=t(e,["endpoint"]),s=t(e,["region"]),c=t(e,["access-key","accessKey"]),g=t(e,["secret-key","secretKey"]),u=t(e,["write-through","writeThrough"]),m=t(e,["disable"]);i||r(n,"Bucket name is required"),m&&(o!==void 0||a!==void 0||s!==void 0||c!==void 0||g!==void 0||u!==void 0)&&r(n,"Cannot use --disable with other migration options");let l=await p();if(m){let{error:k}=await S(i,{dataMigration:{enabled:!1},config:l});k&&r(n,k),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i});return}(!o||!a||!s||!c||!g)&&r(n,"Required: --bucket, --endpoint, --region, --access-key, --secret-key");let{error:b}=await S(i,{dataMigration:{enabled:!0,accessKey:c,secretKey:g,region:s,name:o,endpoint:a,writeThrough:u??!1},config:l});b&&r(n,b),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i})}export{K as default};
1
+ import{e as p}from"../../chunk-YN2TKPPT.js";import{a as t,b as w}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{setBucketMigration as S}from"@tigrisdata/storage";var n=y("buckets","set-migration");async function K(e){h(n);let d=w(e),i=t(e,["name"]),o=t(e,["bucket"]),a=t(e,["endpoint"]),s=t(e,["region"]),c=t(e,["access-key","accessKey"]),g=t(e,["secret-key","secretKey"]),u=t(e,["write-through","writeThrough"]),m=t(e,["disable"]);i||r(n,"Bucket name is required"),m&&(o!==void 0||a!==void 0||s!==void 0||c!==void 0||g!==void 0||u!==void 0)&&r(n,"Cannot use --disable with other migration options");let l=await p();if(m){let{error:k}=await S(i,{dataMigration:{enabled:!1},config:l});k&&r(n,k),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i});return}(!o||!a||!s||!c||!g)&&r(n,"Required: --bucket, --endpoint, --region, --access-key, --secret-key");let{error:b}=await S(i,{dataMigration:{enabled:!0,accessKey:c,secretKey:g,region:s,name:o,endpoint:a,writeThrough:u??!1},config:l});b&&r(n,b),d==="json"&&console.log(JSON.stringify({action:"updated",bucket:i})),f(n,{name:i})}export{K as default};
@@ -1 +1 @@
1
- import{e as p}from"../../chunk-EKLR55EQ.js";import{a as n,b as w}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{setBucketNotifications as N}from"@tigrisdata/storage";var t=k("buckets","set-notifications");async function y(e){b(t);let C=w(e),d=n(e,["name"]),s=n(e,["url"]),u=n(e,["filter"]),a=n(e,["token"]),o=n(e,["username"]),r=n(e,["password"]),l=n(e,["enable"]),g=n(e,["disable"]),c=n(e,["reset"]);d||i(t,"Bucket name is required"),[l,g,c].filter(Boolean).length>1&&i(t,"Only one of --enable, --disable, or --reset can be used"),c&&(s!==void 0||u!==void 0||a!==void 0||o!==void 0||r!==void 0)&&i(t,"Cannot use --reset with other options"),!l&&!g&&!c&&s===void 0&&u===void 0&&a===void 0&&o===void 0&&r===void 0&&i(t,"Provide at least one option"),a&&(o!==void 0||r!==void 0)&&i(t,"Cannot use --token with --username/--password. Choose one auth method"),(o!==void 0&&r===void 0||o===void 0&&r!==void 0)&&i(t,"Both --username and --password are required");let B=await p(),f;c?f={}:(f={...l?{enabled:!0}:{},...g?{enabled:!1}:{},...s!==void 0?{url:s}:{},...u!==void 0?{filter:u}:{}},a?f={...f,auth:{token:a}}:o&&r&&(f={...f,auth:{username:o,password:r}}));let{error:m}=await N(d,{notificationConfig:f,config:B});m&&i(t,m),C==="json"&&console.log(JSON.stringify({action:"updated",bucket:d})),h(t,{name:d})}export{y as default};
1
+ import{e as p}from"../../chunk-YN2TKPPT.js";import{a as n,b as w}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{setBucketNotifications as N}from"@tigrisdata/storage";var t=k("buckets","set-notifications");async function y(e){b(t);let C=w(e),d=n(e,["name"]),s=n(e,["url"]),u=n(e,["filter"]),a=n(e,["token"]),o=n(e,["username"]),r=n(e,["password"]),l=n(e,["enable"]),g=n(e,["disable"]),c=n(e,["reset"]);d||i(t,"Bucket name is required"),[l,g,c].filter(Boolean).length>1&&i(t,"Only one of --enable, --disable, or --reset can be used"),c&&(s!==void 0||u!==void 0||a!==void 0||o!==void 0||r!==void 0)&&i(t,"Cannot use --reset with other options"),!l&&!g&&!c&&s===void 0&&u===void 0&&a===void 0&&o===void 0&&r===void 0&&i(t,"Provide at least one option"),a&&(o!==void 0||r!==void 0)&&i(t,"Cannot use --token with --username/--password. Choose one auth method"),(o!==void 0&&r===void 0||o===void 0&&r!==void 0)&&i(t,"Both --username and --password are required");let B=await p(),f;c?f={}:(f={...l?{enabled:!0}:{},...g?{enabled:!1}:{},...s!==void 0?{url:s}:{},...u!==void 0?{filter:u}:{}},a?f={...f,auth:{token:a}}:o&&r&&(f={...f,auth:{username:o,password:r}}));let{error:m}=await N(d,{notificationConfig:f,config:B});m&&i(t,m),C==="json"&&console.log(JSON.stringify({action:"updated",bucket:d})),h(t,{name:d})}export{y as default};
@@ -1 +1 @@
1
- import{b as y}from"../../chunk-TD2HGNDY.js";import"../../chunk-S77OAN6Y.js";import{e as k}from"../../chunk-EKLR55EQ.js";import{a as n,b as h,d as o}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as D,j as O}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as B}from"@tigrisdata/storage";var a=O("buckets","set");async function C(e){w(a);let A=h(e),c=n(e,["name"]),s=n(e,["access"]),i=n(e,["locations"]),b=n(e,["region"]);b!==void 0&&(console.warn("Warning: --region is deprecated, use --locations instead. See https://www.tigrisdata.com/docs/buckets/locations/"),i===void 0&&(i=b));let d=n(e,["allow-object-acl","allowObjectAcl"]),l=n(e,["disable-directory-listing","disableDirectoryListing"]),f=n(e,["cache-control","cacheControl"]),u=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),m=n(e,["enable-additional-headers","enableAdditionalHeaders"]);c||r(a,"Bucket name is required"),s===void 0&&i===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&r(a,"At least one setting is required");let t={};s!==void 0&&(t.access=s),i!==void 0&&(t.locations=y(i)),d!==void 0&&(t.allowObjectAcl=o(d)),l!==void 0&&(t.disableDirectoryListing=o(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=o(g)),m!==void 0&&(t.enableAdditionalHeaders=o(m));let j=await k(),{error:p}=await B(c,{...t,config:j});p&&r(a,p),A==="json"&&console.log(JSON.stringify({action:"updated",name:c})),D(a,{name:c})}export{C as default};
1
+ import{b as y}from"../../chunk-TD2HGNDY.js";import"../../chunk-S77OAN6Y.js";import{e as w}from"../../chunk-YN2TKPPT.js";import{a as n,b as h,d as i}from"../../chunk-S6KFKBMY.js";import{b as c}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as p,c as D,j as O}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import"../../chunk-OHGCOC5Q.js";import{updateBucket as j}from"@tigrisdata/storage";var o=O("buckets","set");async function B(e){p(o);let A=h(e),a=n(e,["name"]),r=n(e,["access"]),s=n(e,["locations"]),d=n(e,["allow-object-acl","allowObjectAcl"]),l=n(e,["disable-directory-listing","disableDirectoryListing"]),f=n(e,["cache-control","cacheControl"]),u=n(e,["custom-domain","customDomain"]),g=n(e,["enable-delete-protection","enableDeleteProtection"]),m=n(e,["enable-additional-headers","enableAdditionalHeaders"]);a||c(o,"Bucket name is required"),r===void 0&&s===void 0&&d===void 0&&l===void 0&&f===void 0&&u===void 0&&g===void 0&&m===void 0&&c(o,"At least one setting is required");let t={};r!==void 0&&(t.access=r),s!==void 0&&(t.locations=y(s)),d!==void 0&&(t.allowObjectAcl=i(d)),l!==void 0&&(t.disableDirectoryListing=i(l)),f!==void 0&&(t.cacheControl=f),u!==void 0&&(t.customDomain=u),g!==void 0&&(t.enableDeleteProtection=i(g)),m!==void 0&&(t.enableAdditionalHeaders=i(m));let k=await w(),{error:b}=await j(a,{...t,config:k});b&&c(o,b),A==="json"&&console.log(JSON.stringify({action:"updated",name:a})),D(o,{name:a})}export{B as default};
@@ -1,3 +1,3 @@
1
- import{f as k}from"../chunk-JQUG732D.js";import{d as h}from"../chunk-EKLR55EQ.js";import{a,b as p,e as y}from"../chunk-S6KFKBMY.js";import{a as o}from"../chunk-SMBIT5FI.js";import"../chunk-DV3LCXRH.js";import"../chunk-JP3PXFIQ.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";import{bundle as E}from"@tigrisdata/storage";import{createWriteStream as j,existsSync as v,readFileSync as B}from"fs";import{Readable as C}from"stream";import{pipeline as b}from"stream/promises";var z=5e3;function S(t){return t.split(`
1
+ import{e as k}from"../chunk-RXNG56FL.js";import{d as h}from"../chunk-YN2TKPPT.js";import{a,b as p,e as y}from"../chunk-S6KFKBMY.js";import{a as o}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{bundle as E}from"@tigrisdata/storage";import{createWriteStream as j,existsSync as v,readFileSync as B}from"fs";import{Readable as C}from"stream";import{pipeline as b}from"stream/promises";var z=5e3;function S(t){return t.split(`
2
2
  `).map(n=>n.trim()).filter(n=>n.length>0&&!n.startsWith("#"))}function K(t){if(t.endsWith(".tar.gz")||t.endsWith(".tgz"))return"gzip";if(t.endsWith(".tar.zst"))return"zstd";if(t.endsWith(".tar"))return"none"}async function N(t){let n=a(t,["bucket"]),s=a(t,["keys","k"]),i=a(t,["output","o"]),g=a(t,["compression"]),w=a(t,["on-error","onError"],"skip"),l=p(t)==="json",W=!i;n||o("Bucket is required");let{bucket:d,path:c}=k(n);d||o("Invalid bucket");let e;if(s)s.includes(",")?e=s.split(",").map(r=>r.trim()).filter(r=>r.length>0):v(s)?e=S(B(s,"utf-8")):e=[s.trim()];else if(process.stdin.isTTY)o("Keys are required. Provide via --keys or pipe to stdin.");else{let r=await y();e=S(r)}if(c){let r=c.endsWith("/")?c:`${c}/`;e=e.map(A=>`${r}${A}`)}e.length===0&&o("No keys found"),e.length>z&&o(`Too many keys (max ${z}). Got ${e.length}`);let f="none";g?f=g:i&&(f=K(i)??"none"),!W&&!l&&process.stderr.write(`Bundling ${e.length} object(s)...
3
3
  `);let $=await h({withCredentialProvider:!0}),{data:x,error:m}=await E(e,{config:{...$,bucket:d},compression:f,onError:w});m&&o(m);let u=C.fromWeb(x.body);if(i){let r=j(i);await b(u,r),console.log(l?JSON.stringify({action:"bundled",bucket:d,keys:e.length,compression:f,output:i}):`Bundled ${e.length} object(s) from '${d}' to ${i}`)}else await b(u,process.stdout),l&&console.error(JSON.stringify({action:"bundled",bucket:d,keys:e.length,compression:f,output:"stdout"}));process.exit(0)}export{N as default};
@@ -1 +1 @@
1
- import{a as K}from"../../chunk-S77OAN6Y.js";import{a as E}from"../../chunk-EKLR55EQ.js";import{b as S}from"../../chunk-S6KFKBMY.js";import{a as m,b as f,d as p}from"../../chunk-SMBIT5FI.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-JP3PXFIQ.js";import"../../chunk-PPNBQWSR.js";import{a as u}from"../../chunk-ATBINUDP.js";import"../../chunk-KK7FZ7QM.js";import{m as y,q as l}from"../../chunk-OHGCOC5Q.js";import A from"enquirer";import{whoami as w}from"@tigrisdata/iam";var{prompt:q}=A,a=g("configure");async function I(e){n(a);let h=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,t=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,c=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!t||!c){let r=[];s||r.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),t||r.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),c||r.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:u}),K("Provide --access-key, --access-secret, and --endpoint");let i=await q(r);s=s||i.accessKey,t=t||i.accessSecret,c=c||i.endpoint}(!s||!t||!c)&&f(a,"All credentials are required");try{await y({accessKeyId:s,secretAccessKey:t,endpoint:c});try{let r=E(),{data:i}=await w({config:{accessKeyId:s,secretAccessKey:t,iamEndpoint:r.iamEndpoint}});i?.organizationId&&await l(i.organizationId,"saved")}catch{}h==="json"&&console.log(JSON.stringify({action:"configured"})),o(a),p(a)}catch(r){d(a,"Failed to save credentials"),m(r,a)}}export{I as default};
1
+ import{a as K}from"../../chunk-S77OAN6Y.js";import{a as E}from"../../chunk-YN2TKPPT.js";import{b as S}from"../../chunk-S6KFKBMY.js";import{a as m,b as f,d as p}from"../../chunk-UBANDLB4.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-7ZUCJBD5.js";import"../../chunk-PPNBQWSR.js";import{a as u}from"../../chunk-ATBINUDP.js";import"../../chunk-3EAZ2L6H.js";import{m as y,q as l}from"../../chunk-OHGCOC5Q.js";import A from"enquirer";import{whoami as w}from"@tigrisdata/iam";var{prompt:q}=A,a=g("configure");async function I(e){n(a);let h=S(e),s=e["access-key"]||e.accessKey||e.key||e.Key||e.accesskey,t=e["access-secret"]||e.accessSecret||e.secret||e.Secret||e.accesssecret,c=e.endpoint||e.e||e.E||e.Endpoint;if(!s||!t||!c){let r=[];s||r.push({type:"input",name:"accessKey",message:"Tigris Access Key ID:",required:!0}),t||r.push({type:"password",name:"accessSecret",message:"Tigris Secret Access Key:",required:!0}),c||r.push({type:"input",name:"endpoint",message:"Tigris Endpoint:",required:!0,initial:u}),K("Provide --access-key, --access-secret, and --endpoint");let i=await q(r);s=s||i.accessKey,t=t||i.accessSecret,c=c||i.endpoint}(!s||!t||!c)&&f(a,"All credentials are required");try{await y({accessKeyId:s,secretAccessKey:t,endpoint:c});try{let r=E(),{data:i}=await w({config:{accessKeyId:s,secretAccessKey:t,iamEndpoint:r.iamEndpoint}});i?.organizationId&&await l(i.organizationId,"saved")}catch{}h==="json"&&console.log(JSON.stringify({action:"configured"})),o(a),p(a)}catch(r){d(a,"Failed to save credentials"),m(r,a)}}export{I as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as D}from"../chunk-SAAGVLRE.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as C,d as T,g as O,h as J,j}from"../chunk-JQUG732D.js";import{d as G}from"../chunk-EKLR55EQ.js";import{a as x,b as q}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-SMBIT5FI.js";import"../chunk-DV3LCXRH.js";import"../chunk-JP3PXFIQ.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-KK7FZ7QM.js";import"../chunk-OHGCOC5Q.js";import{get as V,head as X,list as tt,put as E}from"@tigrisdata/storage";import{createReadStream as et,createWriteStream as ot,existsSync as Y,mkdirSync as it,readdirSync as z,statSync as L}from"fs";import{homedir as nt}from"os";import{basename as M,dirname as K,join as N,relative as _,resolve as H}from"path";import{Readable as Z}from"stream";import{pipeline as rt}from"stream/promises";var h=!1;function at(n,t){let e=U(n),l=U(t);return!e&&!l&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&l?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function P(n){return n==="~"||n.startsWith("~/")?H(nt(),n.slice(2)):H(n)}function lt(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let l=e.parentPath??e.path;return N(l,e.name)})}function ct(n,t){let e=K(n),l=M(n),s=O(l);return Y(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&s.test(r.name)).map(r=>{let o=r.parentPath??r.path;return N(o,r.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>N(e,o.name)):[]}async function I(n,t,e,l,s=!1){let p;try{p=L(n).size}catch{return{error:`File not found: ${n}`}}let r=et(n),o=Z.toWeb(r),{error:i}=await E(e,o,{...B(p),onUploadProgress:s?({loaded:a})=>{if(p!==void 0&&p>0){let c=Math.round(a/p*100);process.stdout.write(`\rUploading: ${w(a)} / ${w(p)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(a)}`)}:void 0,config:{...l,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),i?{error:i.message}:{}}async function Q(n,t,e,l,s=!1){let p;if(s){let{data:u}=await X(t,{config:{...l,bucket:n}});p=u?.size}let{data:r,error:o}=await V(t,"stream",{config:{...l,bucket:n}});if(o)return{error:o.message};let i=K(e);Y(i)||it(i,{recursive:!0});let a=ot(e),c=Z.fromWeb(r);if(s&&p!==void 0&&p>0){let u=0;c.on("data",m=>{u+=m.length;let g=Math.round(u/p*100);process.stdout.write(`\rDownloading: ${w(u)} / ${w(p)} (${g}%)`)})}return await rt(c,a),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,l,s,p=!1){if(e.endsWith("/")){let{error:c}=await E(s,"",{config:{...n,bucket:l}});return c?{error:c.message}:{}}let r;if(p){let{data:c}=await X(e,{config:{...n,bucket:t}});r=c?.size}let{data:o,error:i}=await V(e,"stream",{config:{...n,bucket:t}});if(i)return{error:i.message};let{error:a}=await E(s,o,{...B(r),onUploadProgress:p?({loaded:c})=>{if(r!==void 0&&r>0){let u=Math.round(c/r*100);process.stdout.write(`\rCopying: ${w(c)} / ${w(r)} (${u}%)`)}else process.stdout.write(`\rCopying: ${w(c)}`)}:void 0,config:{...n,bucket:l}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),a?{error:a.message}:{}}async function st(n,t,e,l){let s=P(n);if(n.includes("*")){let o=ct(s,l);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let i=K(s),a=o.map(m=>async()=>{let g=_(i,m),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,$=await I(m,t.bucket,k,e);return $.error?(console.error(`Failed to upload ${m}: ${$.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),u=(await D(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`);return}let r;try{r=L(s)}catch{f(`Source not found: ${n}`)}if(r.isDirectory()){l||f(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=lt(s);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let i=n.endsWith("/")?"":M(s),a=o.map(m=>async()=>{let g=_(s,m),$=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(m,t.bucket,$,e);return R.error?(console.error(`Failed to upload ${m}: ${R.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${$}`),!0)}),u=(await D(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await T(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let a=await I(s,t.bucket,i,e,!h);a.error&&f(a.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:n,dest:`t3://${t.bucket}/${i}`}):`Uploaded ${n} -> t3://${t.bucket}/${i}`)}}async function pt(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=P(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&p;if(!o&&!i&&(i=await T(t.bucket,t.path,l)),i&&!o&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let a=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",c=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:m}=await j(t.bucket,a||void 0,l);m&&f(m);let g=u.filter(y=>!y.name.endsWith("/"));if(o){let y=t.path.split("/").pop(),b=O(y);g=g.filter(S=>{let d=a?S.name.slice(a.length):S.name;return!s&&d.includes("/")?!1:b.test(d.split("/").pop())})}if(g.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let k=g.map(y=>async()=>{let b=a?y.name.slice(a.length):y.name,S=c?N(r,c,b):N(r,b),d=await Q(t.bucket,y.name,S,l);return d.error?(console.error(`Failed to download ${y.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),R=(await D(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let a=t.path.split("/").pop(),c,u=!1;try{u=L(r).isDirectory()}catch{}u||e.endsWith("/")?c=N(r,a):c=r;let m=await Q(t.bucket,t.path,c,l,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:c}):`Downloaded t3://${t.bucket}/${t.path} -> ${c}`)}}async function ut(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=n.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!r&&!o&&t.path&&(o=await T(t.bucket,t.path,l)),o&&!r&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||o){let i=r?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",a=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",a].filter(Boolean).join("/"),m=u?`${u}/`:"";t.bucket===e.bucket&&i===m&&f("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,l);k&&f(k);let $=g.filter(d=>d.name!==i);if(r){let d=t.path.split("/").pop(),W=O(d);$=$.filter(F=>{let v=i?F.name.slice(i.length):F.name;return!s&&v.includes("/")?!1:W.test(v.split("/").pop())})}let R=$.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=u?`${u}/${W}`:W,v=await A(l,t.bucket,d.name,e.bucket,F);return v.error?(console.error(`Failed to copy ${d.name}: ${v.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${d.name} -> t3://${e.bucket}/${F}`),!0)}),b=(await D(R,8)).filter(Boolean).length,S=!1;if(u&&i){let{data:d}=await tt({prefix:i,limit:1,config:{...l,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${u}/`,F=await A(l,t.bucket,i,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let i=t.path.split("/").pop(),a;e.path?e.path.endsWith("/")?a=`${e.path}${i}`:await T(e.bucket,e.path,l)?a=`${e.path}/${i}`:a=e.path:a=i,t.bucket===e.bucket&&t.path===a&&f("Source and destination are the same");let c=await A(l,t.bucket,t.path,e.bucket,a,!h);c.error&&f(c.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${a}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${a}`)}}async function ft(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let l=!!x(n,["recursive","r"]);h=q(n)==="json";let p=at(t,e),r=await G({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await st(t,o,r,l);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await pt(t,o,e,r,l);break}case"remote-to-remote":{let o=C(t),i=C(e);o.bucket||f("Invalid source path"),i.bucket||f("Invalid destination path"),await ut(t,o,i,r,l);break}}process.exit(0)}export{ft as default};
1
+ import{a as D}from"../chunk-SAAGVLRE.js";import{a as B}from"../chunk-EKW6XTGL.js";import{a as w}from"../chunk-IRDNZN7R.js";import{a as U,b as C,d as T,f as O,g as J,i as j}from"../chunk-RXNG56FL.js";import{d as G}from"../chunk-YN2TKPPT.js";import{a as x,b as q}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-UBANDLB4.js";import"../chunk-DV3LCXRH.js";import"../chunk-7ZUCJBD5.js";import"../chunk-PPNBQWSR.js";import"../chunk-ATBINUDP.js";import"../chunk-3EAZ2L6H.js";import"../chunk-OHGCOC5Q.js";import{get as V,head as X,list as tt,put as E}from"@tigrisdata/storage";import{createReadStream as et,createWriteStream as ot,existsSync as Y,mkdirSync as it,readdirSync as z,statSync as L}from"fs";import{homedir as nt}from"os";import{basename as M,dirname as K,join as N,relative as _,resolve as H}from"path";import{Readable as Z}from"stream";import{pipeline as rt}from"stream/promises";var h=!1;function at(n,t){let e=U(n),l=U(t);return!e&&!l&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&l?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function P(n){return n==="~"||n.startsWith("~/")?H(nt(),n.slice(2)):H(n)}function lt(n){return z(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let l=e.parentPath??e.path;return N(l,e.name)})}function ct(n,t){let e=K(n),l=M(n),s=O(l);return Y(e)?t?z(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&s.test(r.name)).map(r=>{let o=r.parentPath??r.path;return N(o,r.name)}):z(e,{withFileTypes:!0}).filter(o=>o.isFile()&&s.test(o.name)).map(o=>N(e,o.name)):[]}async function I(n,t,e,l,s=!1){let p;try{p=L(n).size}catch{return{error:`File not found: ${n}`}}let r=et(n),o=Z.toWeb(r),{error:i}=await E(e,o,{...B(p),onUploadProgress:s?({loaded:a})=>{if(p!==void 0&&p>0){let c=Math.round(a/p*100);process.stdout.write(`\rUploading: ${w(a)} / ${w(p)} (${c}%)`)}else process.stdout.write(`\rUploading: ${w(a)}`)}:void 0,config:{...l,bucket:t}});return s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),i?{error:i.message}:{}}async function Q(n,t,e,l,s=!1){let p;if(s){let{data:u}=await X(t,{config:{...l,bucket:n}});p=u?.size}let{data:r,error:o}=await V(t,"stream",{config:{...l,bucket:n}});if(o)return{error:o.message};let i=K(e);Y(i)||it(i,{recursive:!0});let a=ot(e),c=Z.fromWeb(r);if(s&&p!==void 0&&p>0){let u=0;c.on("data",m=>{u+=m.length;let g=Math.round(u/p*100);process.stdout.write(`\rDownloading: ${w(u)} / ${w(p)} (${g}%)`)})}return await rt(c,a),s&&process.stdout.write("\r"+" ".repeat(60)+"\r"),{}}async function A(n,t,e,l,s,p=!1){if(e.endsWith("/")){let{error:c}=await E(s,"",{config:{...n,bucket:l}});return c?{error:c.message}:{}}let r;if(p){let{data:c}=await X(e,{config:{...n,bucket:t}});r=c?.size}let{data:o,error:i}=await V(e,"stream",{config:{...n,bucket:t}});if(i)return{error:i.message};let{error:a}=await E(s,o,{...B(r),onUploadProgress:p?({loaded:c})=>{if(r!==void 0&&r>0){let u=Math.round(c/r*100);process.stdout.write(`\rCopying: ${w(c)} / ${w(r)} (${u}%)`)}else process.stdout.write(`\rCopying: ${w(c)}`)}:void 0,config:{...n,bucket:l}});return p&&process.stdout.write("\r"+" ".repeat(60)+"\r"),a?{error:a.message}:{}}async function st(n,t,e,l){let s=P(n);if(n.includes("*")){let o=ct(s,l);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let i=K(s),a=o.map(m=>async()=>{let g=_(i,m),k=t.path?`${t.path.replace(/\/$/,"")}/${g}`:g,$=await I(m,t.bucket,k,e);return $.error?(console.error(`Failed to upload ${m}: ${$.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),u=(await D(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`);return}let r;try{r=L(s)}catch{f(`Source not found: ${n}`)}if(r.isDirectory()){l||f(`${n} is a directory (not copied). Use -r to copy recursively.`);let o=lt(s);if(o.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let i=n.endsWith("/")?"":M(s),a=o.map(m=>async()=>{let g=_(s,m),$=[t.path?.replace(/\/$/,""),i,g].filter(Boolean).join("/"),R=await I(m,t.bucket,$,e);return R.error?(console.error(`Failed to upload ${m}: ${R.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${$}`),!0)}),u=(await D(a,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:u}):`Uploaded ${u} file(s)`)}else{let o=M(s),i;t.path?n.endsWith("/")||t.path.endsWith("/")?i=`${t.path.replace(/\/$/,"")}/${o}`:await T(t.bucket,t.path,e)?i=`${t.path}/${o}`:i=t.path:i=o;let a=await I(s,t.bucket,i,e,!h);a.error&&f(a.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:n,dest:`t3://${t.bucket}/${i}`}):`Uploaded ${n} -> t3://${t.bucket}/${i}`)}}async function pt(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=P(e),o=t.path.includes("*"),i=t.path.endsWith("/")||!t.path&&p;if(!o&&!i&&(i=await T(t.bucket,t.path,l)),i&&!o&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),o||i){let a=o?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",c=!o&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:m}=await j(t.bucket,a||void 0,l);m&&f(m);let g=u.filter(y=>!y.name.endsWith("/"));if(o){let y=t.path.split("/").pop(),b=O(y);g=g.filter(S=>{let d=a?S.name.slice(a.length):S.name;return!s&&d.includes("/")?!1:b.test(d.split("/").pop())})}if(g.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let k=g.map(y=>async()=>{let b=a?y.name.slice(a.length):y.name,S=c?N(r,c,b):N(r,b),d=await Q(t.bucket,y.name,S,l);return d.error?(console.error(`Failed to download ${y.name}: ${d.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),R=(await D(k,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:R}):`Downloaded ${R} file(s)`)}else{let a=t.path.split("/").pop(),c,u=!1;try{u=L(r).isDirectory()}catch{}u||e.endsWith("/")?c=N(r,a):c=r;let m=await Q(t.bucket,t.path,c,l,!h);m.error&&f(m.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:c}):`Downloaded t3://${t.bucket}/${t.path} -> ${c}`)}}async function ut(n,t,e,l,s){let p=n.endsWith("/");!t.path&&!p&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=n.includes("*"),o=t.path.endsWith("/")||!t.path&&p;if(!r&&!o&&t.path&&(o=await T(t.bucket,t.path,l)),o&&!r&&!s&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||o){let i=r?J(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",a=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",a].filter(Boolean).join("/"),m=u?`${u}/`:"";t.bucket===e.bucket&&i===m&&f("Source and destination are the same");let{items:g,error:k}=await j(t.bucket,i||void 0,l);k&&f(k);let $=g.filter(d=>d.name!==i);if(r){let d=t.path.split("/").pop(),W=O(d);$=$.filter(F=>{let v=i?F.name.slice(i.length):F.name;return!s&&v.includes("/")?!1:W.test(v.split("/").pop())})}let R=$.map(d=>async()=>{let W=i?d.name.slice(i.length):d.name,F=u?`${u}/${W}`:W,v=await A(l,t.bucket,d.name,e.bucket,F);return v.error?(console.error(`Failed to copy ${d.name}: ${v.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${d.name} -> t3://${e.bucket}/${F}`),!0)}),b=(await D(R,8)).filter(Boolean).length,S=!1;if(u&&i){let{data:d}=await tt({prefix:i,limit:1,config:{...l,bucket:t.bucket}});if(d?.items?.some(W=>W.name===i)){let W=`${u}/`,F=await A(l,t.bucket,i,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if(b===0&&S&&(b=1),b===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:0}):"No objects to copy");return}console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:b}):`Copied ${b} object(s)`)}else{let i=t.path.split("/").pop(),a;e.path?e.path.endsWith("/")?a=`${e.path}${i}`:await T(e.bucket,e.path,l)?a=`${e.path}/${i}`:a=e.path:a=i,t.bucket===e.bucket&&t.path===a&&f("Source and destination are the same");let c=await A(l,t.bucket,t.path,e.bucket,a,!h);c.error&&f(c.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${a}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${a}`)}}async function ft(n){let t=x(n,["src"]),e=x(n,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let l=!!x(n,["recursive","r"]);h=q(n)==="json";let p=at(t,e),r=await G({withCredentialProvider:!0});switch(p){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await st(t,o,r,l);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await pt(t,o,e,r,l);break}case"remote-to-remote":{let o=C(t),i=C(e);o.bucket||f("Invalid source path"),i.bucket||f("Invalid destination path"),await ut(t,o,i,r,l);break}}process.exit(0)}export{ft as default};