@tigrisdata/cli 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +82 -5
  2. package/dist/auth/iam.js +1 -1
  3. package/dist/auth/provider.js +1 -1
  4. package/dist/{chunk-QFMXV3BK.js → chunk-2CEUCG65.js} +1 -1
  5. package/dist/chunk-3ILNJZ6D.js +1 -0
  6. package/dist/{chunk-HLAGKEX3.js → chunk-3RVILEB4.js} +1 -1
  7. package/dist/{chunk-CB3HWEP5.js → chunk-4HHJ6ZI7.js} +1 -1
  8. package/dist/{chunk-2XSEQJGZ.js → chunk-5JBNZ4C6.js} +1 -1
  9. package/dist/{chunk-HUWHOK4M.js → chunk-6QS6QJ65.js} +1 -1
  10. package/dist/{chunk-XWIL5QBS.js → chunk-DF3BGBKJ.js} +1 -1
  11. package/dist/chunk-E6COPYXK.js +28 -0
  12. package/dist/chunk-HCZGZVF3.js +9 -0
  13. package/dist/chunk-L6I5MSYU.js +5 -0
  14. package/dist/{chunk-B7CB3ST5.js → chunk-U3422EZ6.js} +1 -1
  15. package/dist/{chunk-5Z3OHUTR.js → chunk-UIPN4DNR.js} +1 -1
  16. package/dist/{chunk-EH56YEO2.js → chunk-WXYJJPV2.js} +1 -1
  17. package/dist/{chunk-S3HKXM3M.js → chunk-Z265ZXTU.js} +1 -1
  18. package/dist/{chunk-DLK3GTAJ.js → chunk-ZNUPMP3O.js} +1 -1
  19. package/dist/cli-core.js +1 -1
  20. package/dist/cli.js +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/lib/access-keys/assign.js +1 -1
  23. package/dist/lib/access-keys/attach-policy.js +1 -1
  24. package/dist/lib/access-keys/create.js +1 -1
  25. package/dist/lib/access-keys/delete.js +1 -1
  26. package/dist/lib/access-keys/detach-policy.js +1 -1
  27. package/dist/lib/access-keys/get.js +1 -1
  28. package/dist/lib/access-keys/list-policies.js +1 -1
  29. package/dist/lib/access-keys/list.js +1 -1
  30. package/dist/lib/access-keys/rotate.js +1 -1
  31. package/dist/lib/buckets/create.js +1 -1
  32. package/dist/lib/buckets/delete.js +1 -1
  33. package/dist/lib/buckets/disable-snapshots.js +1 -1
  34. package/dist/lib/buckets/enable-snapshots.js +1 -1
  35. package/dist/lib/buckets/get.js +1 -1
  36. package/dist/lib/buckets/lifecycle/create.js +1 -1
  37. package/dist/lib/buckets/lifecycle/edit.js +1 -1
  38. package/dist/lib/buckets/lifecycle/list.js +1 -1
  39. package/dist/lib/buckets/lifecycle/shared.js +1 -1
  40. package/dist/lib/buckets/list.js +1 -1
  41. package/dist/lib/buckets/merge.js +1 -1
  42. package/dist/lib/buckets/migrate.js +5 -5
  43. package/dist/lib/buckets/rebase.js +1 -1
  44. package/dist/lib/buckets/restore.js +1 -1
  45. package/dist/lib/buckets/set-cors.js +1 -1
  46. package/dist/lib/buckets/set-locations.js +1 -1
  47. package/dist/lib/buckets/set-migration.js +1 -1
  48. package/dist/lib/buckets/set-notifications.js +1 -1
  49. package/dist/lib/buckets/set.js +1 -1
  50. package/dist/lib/bundle.js +1 -1
  51. package/dist/lib/configure/index.js +1 -1
  52. package/dist/lib/cp.js +1 -1
  53. package/dist/lib/credentials/test.js +1 -1
  54. package/dist/lib/iam/policies/create.js +1 -1
  55. package/dist/lib/iam/policies/delete.js +1 -1
  56. package/dist/lib/iam/policies/edit.js +1 -1
  57. package/dist/lib/iam/policies/get.js +1 -1
  58. package/dist/lib/iam/policies/link-key.js +1 -1
  59. package/dist/lib/iam/policies/list-keys.js +1 -1
  60. package/dist/lib/iam/policies/list.js +1 -1
  61. package/dist/lib/iam/policies/select-policy.js +1 -1
  62. package/dist/lib/iam/policies/unlink-key.js +1 -1
  63. package/dist/lib/iam/teams/create.js +1 -1
  64. package/dist/lib/iam/teams/edit.js +1 -1
  65. package/dist/lib/iam/teams/list.js +1 -1
  66. package/dist/lib/iam/teams/shared.js +1 -1
  67. package/dist/lib/iam/users/invite.js +1 -1
  68. package/dist/lib/iam/users/list.js +1 -1
  69. package/dist/lib/iam/users/remove.js +1 -1
  70. package/dist/lib/iam/users/revoke-invitation.js +1 -1
  71. package/dist/lib/iam/users/update-role.js +1 -1
  72. package/dist/lib/init/index.js +1 -1
  73. package/dist/lib/init/interactive.js +1 -1
  74. package/dist/lib/init/plan.js +1 -1
  75. package/dist/lib/init/shared.js +1 -1
  76. package/dist/lib/login/credentials.js +1 -1
  77. package/dist/lib/login/oauth.js +1 -1
  78. package/dist/lib/login/select.js +1 -1
  79. package/dist/lib/logout.js +1 -1
  80. package/dist/lib/ls.js +1 -1
  81. package/dist/lib/mk.js +1 -1
  82. package/dist/lib/mv.js +1 -1
  83. package/dist/lib/objects/delete.js +1 -1
  84. package/dist/lib/objects/get.js +1 -1
  85. package/dist/lib/objects/info.js +1 -1
  86. package/dist/lib/objects/list-versions.js +1 -1
  87. package/dist/lib/objects/list.js +1 -1
  88. package/dist/lib/objects/put.js +1 -1
  89. package/dist/lib/objects/restore-info.js +1 -1
  90. package/dist/lib/objects/restore.js +1 -1
  91. package/dist/lib/objects/set-access.js +1 -1
  92. package/dist/lib/objects/set.js +1 -1
  93. package/dist/lib/organizations/create.js +1 -1
  94. package/dist/lib/organizations/list.js +1 -1
  95. package/dist/lib/organizations/select.js +1 -1
  96. package/dist/lib/presign.js +1 -1
  97. package/dist/lib/rm.js +1 -1
  98. package/dist/lib/snapshots/list.js +1 -1
  99. package/dist/lib/snapshots/take.js +1 -1
  100. package/dist/lib/stat.js +1 -1
  101. package/dist/lib/touch.js +1 -1
  102. package/dist/lib/update.js +1 -1
  103. package/dist/lib/whoami.js +1 -1
  104. package/dist/specs.yaml +5 -1
  105. package/dist/utils/exit.js +1 -1
  106. package/dist/utils/telemetry.js +1 -1
  107. package/dist/utils/update-check.js +1 -1
  108. package/package.json +1 -1
  109. package/dist/chunk-FB54QSI7.js +0 -35
  110. package/dist/chunk-HWAEADX7.js +0 -1
  111. package/dist/chunk-OWYZCGWM.js +0 -8
  112. package/dist/chunk-ZP7AWQAS.js +0 -6
  113. /package/dist/{chunk-5UQUUFCL.js → chunk-A3YRE353.js} +0 -0
@@ -1 +1 @@
1
- import{c as s}from"../../chunk-JNSFDQGG.js";import{f as u}from"../../chunk-AFM3TY2D.js";import"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{e as f}from"../../chunk-5UQUUFCL.js";import{a as p,b as c}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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-JNSFDQGG.js";import{f as u}from"../../chunk-AFM3TY2D.js";import"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{e as f}from"../../chunk-A3YRE353.js";import{a as p,b as c}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as i,j as m}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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 +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-HUWHOK4M.js";import"../../../chunk-JNSFDQGG.js";import"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{f as y}from"../../../chunk-5UQUUFCL.js";import{a as x,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as p,j as g}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-F4AGJWCK.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};
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-6QS6QJ65.js";import"../../../chunk-JNSFDQGG.js";import"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{f as y}from"../../../chunk-A3YRE353.js";import{a as x,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as p,j as g}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-F4AGJWCK.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};
@@ -1 +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-HUWHOK4M.js";import"../../../chunk-JNSFDQGG.js";import"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{f as b}from"../../../chunk-5UQUUFCL.js";import{a as c,b as x}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as y,j as h}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-F4AGJWCK.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};
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-6QS6QJ65.js";import"../../../chunk-JNSFDQGG.js";import"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{f as b}from"../../../chunk-A3YRE353.js";import{a as c,b as x}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as y,j as h}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-F4AGJWCK.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};
@@ -1 +1 @@
1
- import{h,i as b}from"../../../chunk-HUWHOK4M.js";import"../../../chunk-JNSFDQGG.js";import{b as x,d as y,e as k}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{e as g}from"../../../chunk-5UQUUFCL.js";import{a as u,b as d}from"../../../chunk-S6KFKBMY.js";import{b as r}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as m,e as c,j as p}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-F4AGJWCK.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};
1
+ import{h,i as b}from"../../../chunk-6QS6QJ65.js";import"../../../chunk-JNSFDQGG.js";import{b as x,d as y,e as k}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import{e as g}from"../../../chunk-A3YRE353.js";import{a as u,b as d}from"../../../chunk-S6KFKBMY.js";import{b as r}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as m,e as c,j as p}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-F4AGJWCK.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};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i}from"../../../chunk-HUWHOK4M.js";import"../../../chunk-JNSFDQGG.js";import"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-S6KFKBMY.js";import"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.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
+ import{a,b,c,d,e,f,g,h,i}from"../../../chunk-6QS6QJ65.js";import"../../../chunk-JNSFDQGG.js";import"../../../chunk-AFM3TY2D.js";import"../../../chunk-N3Y6RFSK.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-S6KFKBMY.js";import"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.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{g as l}from"../../chunk-AFM3TY2D.js";import{e as j}from"../../chunk-5UQUUFCL.js";import{a as g,b as P,c as S}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as D,c as d,e as k,i as u,j as E}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{listBuckets as A,listForks as B}from"@tigrisdata/storage";var e=E("buckets","list");async function H(o){D(e);let n=P(o),s=g(o,["forks-of","forksOf"]),c=g(o,["deleted"]),{limit:r,pageToken:i}=S(o),p=await j();s&&c&&console.warn("\u26A0 --deleted is ignored when --forks-of is used; use --deleted on its own to list soft-deleted buckets");let b=[{key:"name",header:"Name"},{key:"created",header:"Created"}];if(s){let{data:t,error:x}=await B(s,{...r!==void 0?{limit:r}:{},...i?{paginationToken:i}:{},config:p});if(x&&m(e,x),!t.forks||t.forks.length===0){k(e);return}let f=[];for(let O of t.forks)f.push({name:O.name,created:O.creationDate});let y=t.paginationToken||void 0,F=l(f,n,"forks","fork",b,{paginationToken:y});console.log(F),n!=="json"&&n!=="xml"&&u(y),d(e,{count:f.length});return}let{data:a,error:h}=await A({...r!==void 0?{limit:r}:{},...i?{paginationToken:i}:{},...c?{deleted:c}:{},config:p});if(h&&m(e,h),!a.buckets||a.buckets.length===0){k(e);return}let T=a.buckets.map(t=>({name:t.name,created:t.creationDate})),w=a.paginationToken||void 0,C=l(T,n,"buckets","bucket",b,{paginationToken:w});console.log(C),n!=="json"&&n!=="xml"&&u(w),d(e,{count:T.length})}export{H as default};
1
+ import{g as l}from"../../chunk-AFM3TY2D.js";import{e as j}from"../../chunk-A3YRE353.js";import{a as g,b as P,c as S}from"../../chunk-S6KFKBMY.js";import{b as m}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as D,c as d,e as k,i as u,j as E}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{listBuckets as A,listForks as B}from"@tigrisdata/storage";var e=E("buckets","list");async function H(o){D(e);let n=P(o),s=g(o,["forks-of","forksOf"]),c=g(o,["deleted"]),{limit:r,pageToken:i}=S(o),p=await j();s&&c&&console.warn("\u26A0 --deleted is ignored when --forks-of is used; use --deleted on its own to list soft-deleted buckets");let b=[{key:"name",header:"Name"},{key:"created",header:"Created"}];if(s){let{data:t,error:x}=await B(s,{...r!==void 0?{limit:r}:{},...i?{paginationToken:i}:{},config:p});if(x&&m(e,x),!t.forks||t.forks.length===0){k(e);return}let f=[];for(let O of t.forks)f.push({name:O.name,created:O.creationDate});let y=t.paginationToken||void 0,F=l(f,n,"forks","fork",b,{paginationToken:y});console.log(F),n!=="json"&&n!=="xml"&&u(y),d(e,{count:f.length});return}let{data:a,error:h}=await A({...r!==void 0?{limit:r}:{},...i?{paginationToken:i}:{},...c?{deleted:c}:{},config:p});if(h&&m(e,h),!a.buckets||a.buckets.length===0){k(e);return}let T=a.buckets.map(t=>({name:t.name,created:t.creationDate})),w=a.paginationToken||void 0,C=l(T,n,"buckets","bucket",b,{paginationToken:w});console.log(C),n!=="json"&&n!=="xml"&&u(w),d(e,{count:T.length})}export{H as default};
@@ -1 +1 @@
1
- import{a as b,b as S}from"../../chunk-S77OAN6Y.js";import{e as x}from"../../chunk-5UQUUFCL.js";import{a as c,b as w}from"../../chunk-S6KFKBMY.js";import{b as s,c as h,d as l}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as k,c as p,j as d}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{getBucketInfo as $,mergeFork as F}from"@tigrisdata/storage";var r=d("buckets","merge");async function I(n){k(r);let y=w(n),o=c(n,["fork"]),t=c(n,["into","source"]),f=c(n,["from-snapshot","fromSnapshot","from-snap"]),A=c(n,["yes","y"]);o||s(r,"Fork bucket name is required");let a=await x();if(!t){let{data:e,error:i}=await $(o,{config:a});i&&s(r,i);let u=e?.forkInfo?.parents?.[0]?.bucketName;u||s(r,`'${o}' is not a fork or its source bucket could not be determined. Pass --into <source-bucket>.`),t=u}if(!A&&(b("Use --yes to skip confirmation"),!await S(`Merge fork '${o}' into source '${t}'? This writes the fork's changes into '${t}'.`))){console.log("Aborted");return}let{data:N,error:m}=await F(o,t,{...f?{forkSnapshot:f}:{},config:a});m&&s(r,m);let g=N?.snapshotVersion??"";if(y==="json"){let e=h(r,{fork:o,into:t}),i={action:"merged",fork:o,into:t,snapshotVersion:g};e.length>0&&(i.nextActions=e),console.log(JSON.stringify(i))}p(r,{fork:o,into:t,snapshotVersion:g}),l(r,{fork:o,into:t})}export{I as default};
1
+ import{a as b,b as S}from"../../chunk-S77OAN6Y.js";import{e as x}from"../../chunk-A3YRE353.js";import{a as c,b as w}from"../../chunk-S6KFKBMY.js";import{b as s,c as h,d as l}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as k,c as p,j as d}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{getBucketInfo as $,mergeFork as F}from"@tigrisdata/storage";var r=d("buckets","merge");async function I(n){k(r);let y=w(n),o=c(n,["fork"]),t=c(n,["into","source"]),f=c(n,["from-snapshot","fromSnapshot","from-snap"]),A=c(n,["yes","y"]);o||s(r,"Fork bucket name is required");let a=await x();if(!t){let{data:e,error:i}=await $(o,{config:a});i&&s(r,i);let u=e?.forkInfo?.parents?.[0]?.bucketName;u||s(r,`'${o}' is not a fork or its source bucket could not be determined. Pass --into <source-bucket>.`),t=u}if(!A&&(b("Use --yes to skip confirmation"),!await S(`Merge fork '${o}' into source '${t}'? This writes the fork's changes into '${t}'.`))){console.log("Aborted");return}let{data:N,error:m}=await F(o,t,{...f?{forkSnapshot:f}:{},config:a});m&&s(r,m);let g=N?.snapshotVersion??"";if(y==="json"){let e=h(r,{fork:o,into:t}),i={action:"merged",fork:o,into:t,snapshotVersion:g};e.length>0&&(i.nextActions=e),console.log(JSON.stringify(i))}p(r,{fork:o,into:t,snapshotVersion:g}),l(r,{fork:o,into:t})}export{I as default};
@@ -1,6 +1,6 @@
1
- import{a as F}from"../../chunk-SAAGVLRE.js";import{a as m}from"../../chunk-AFM3TY2D.js";import{e as O}from"../../chunk-7ZCVOA6A.js";import{e as E}from"../../chunk-5UQUUFCL.js";import{a as B}from"../../chunk-S6KFKBMY.js";import{b as M}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{d as v,j as x}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{isMigrated as J,list as G,migrate as H}from"@tigrisdata/storage";var S=x("buckets","migrate"),z=10*1024*1024*1024,C=1e3,y=50,D=5e3,Y=3e4,j=50,R=3,A=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],K=250;function X(e){return e.sort((r,t)=>r.size-t.size),e}function U(e,r){return e.inFlight.length>=C?!0:e.inFlightBytes+r>z&&e.inFlight.length>0}function V(e,r,t,a){return r===0?!1:r>=j||e.inFlight.length+r>=C||e.inFlightBytes+t+a>z}function q(e){let r=null;for(let t of e)(r===null||t.scheduledAt<r.scheduledAt)&&(r=t);return r}function W(e,r,t=40){return e?`migrating ${e.name.length>t?`\u2026${e.name.slice(-Math.max(1,t-1))}`:e.name} (${m(e.size)}, waiting ${$(r-e.scheduledAt)})`:"waiting\u2026"}var _=class{constructor(r,t,a,i){this.bucket=r;this.source=t;this.prefix=a;this.config=i}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:t}=await G({prefix:this.prefix,source:this.source,...this.token?{paginationToken:this.token}:{},config:{...this.config,bucket:this.bucket}});if(t)throw t;this.buffer=r.items??[],this.index=0,this.token=r.paginationToken,!r.paginationToken&&!r.hasMore&&(this._done=!0)}};async function Z(e,r,t,a){let i=new _(e,"shadow",r,t),n=new _(e,"tigris",r,t),c=[],s=await i.current(),l=await n.current();for(;s!==null&&!a?.aborted;){if(l===null){c.push({name:s.name,size:s.size}),i.advance(),s=await i.current();continue}s.name<l.name?(c.push({name:s.name,size:s.size}),i.advance(),s=await i.current()):s.name>l.name?(n.advance(),l=await n.current()):(i.advance(),n.advance(),s=await i.current(),l=await n.current())}return c}function Q(e,r){return new Promise(t=>{if(r?.aborted){t();return}let a=setTimeout(()=>{r?.removeEventListener("abort",i),t()},e);function i(){clearTimeout(a),t()}r?.addEventListener("abort",i,{once:!0})})}function $(e){let r=Math.floor(e/1e3),t=Math.floor(r/60),a=r%60;return t===0?`${a}s`:`${t}m ${a}s`}function ee(e,r){let t=Date.now();e.spinnerFrame=(e.spinnerFrame+1)%A.length;let a=A[e.spinnerFrame],i=e.total>0?Math.floor(e.confirmed/e.total*100):0,n=e.totalBytes>0?Math.floor(e.confirmedBytes/e.totalBytes*100):0,c=$(t-e.startTime),s=q(e.inFlight),l=process.stderr.columns??80;return[`${a} Migrating ${r} \xB7 ${c} elapsed`,` ${e.confirmed.toLocaleString()} / ${e.total.toLocaleString()} files (${i}%) \xB7 ${m(e.confirmedBytes)} / ${m(e.totalBytes)} (${n}%)`,` ${W(s,t,Math.max(20,l-45))} \xB7 in-flight ${e.inFlight.length.toLocaleString()} (${m(e.inFlightBytes)})`]}var h=0;function re(e,r){if(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)return;let t=process.stderr.columns??80,a=ee(e,r).map(n=>n.length>t?`${n.slice(0,Math.max(1,t-1))}\u2026`:n),i="";h>0&&(i+=`\x1B[${h}A`),i+="\x1B[0J",i+=`${a.join(`
1
+ import{a as k}from"../../chunk-SAAGVLRE.js";import{a as m}from"../../chunk-AFM3TY2D.js";import{e as L}from"../../chunk-7ZCVOA6A.js";import{e as N}from"../../chunk-A3YRE353.js";import{a as x}from"../../chunk-S6KFKBMY.js";import{b as I}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{d as E,j as v}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{isMigrated as X,list as j,migrate as U}from"@tigrisdata/storage";var _=v("buckets","migrate"),A=1024*1024*1024,q=50,O=1,R=100,P=1e3,$=50,H=5e3,K=3e4,V=50,z=3,W=10,C=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Z=250;function Q(e){return e.sort((t,n)=>t.size-n.size),e}function ee(e){if(e==null||e==="")return{ok:!0,bytes:q*A};let t=typeof e=="number"?e:typeof e=="string"?Number(e.trim()):Number.NaN;return Number.isFinite(t)?t<O||t>R?{ok:!1,error:`--max-in-flight-gb must be between ${O} and ${R} (got ${t})`}:{ok:!0,bytes:Math.round(t*A)}:{ok:!1,error:"--max-in-flight-gb must be a number of gigabytes"}}function te(e,t){return e.inFlight.length>=P?!0:e.inFlightBytes+t>e.maxInFlightBytes&&e.inFlight.length>0}function ne(e,t,n,a){return t===0?!1:t>=V||e.inFlight.length+t>=P||e.inFlightBytes+n+a>e.maxInFlightBytes}function re(e){return[...e].sort((t,n)=>t.scheduledAt-n.scheduledAt||(t.name<n.name?-1:t.name>n.name?1:0))}function ie(e,t){let n=re(e),a=Math.min(W,Math.max(1,t));if(n.length<=a)return{shown:n,hidden:[]};let r=Math.max(0,a-1);return{shown:n.slice(0,r),hidden:n.slice(r)}}var G=9,oe=15;function se(e,t,n){let a=Math.max(8,n-4-2-G-2-oe),r=e.name.length>a?`\u2026${e.name.slice(-Math.max(1,a-1))}`:e.name.padEnd(a),o=m(e.size).padStart(G),i=`queued ${B(t-e.scheduledAt)}`;return` ${r} ${o} ${i}`}var F=class{constructor(t,n,a,r){this.bucket=t;this.source=n;this.prefix=a;this.config=r}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:t,error:n}=await j({prefix:this.prefix,source:this.source,...this.token?{paginationToken:this.token}:{},config:{...this.config,bucket:this.bucket}});if(n)throw n;this.buffer=t.items??[],this.index=0,this.token=t.paginationToken,!t.paginationToken&&!t.hasMore&&(this._done=!0)}};async function ae(e,t,n,a){let r=new F(e,"shadow",t,n),o=new F(e,"tigris",t,n),i=[],c=await r.current(),l=await o.current();for(;c!==null&&!a?.aborted;){if(l===null){i.push({name:c.name,size:c.size}),r.advance(),c=await r.current();continue}c.name<l.name?(i.push({name:c.name,size:c.size}),r.advance(),c=await r.current()):c.name>l.name?(o.advance(),l=await o.current()):(r.advance(),o.advance(),c=await r.current(),l=await o.current())}return i}function ce(e,t){return new Promise(n=>{if(t?.aborted){n();return}let a=setTimeout(()=>{t?.removeEventListener("abort",r),n()},e);function r(){clearTimeout(a),n()}t?.addEventListener("abort",r,{once:!0})})}function B(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),a=t%60;return n===0?`${a}s`:`${n}m ${a}s`}function le(e,t){let n=Date.now();e.spinnerFrame=(e.spinnerFrame+1)%C.length;let a=C[e.spinnerFrame],r=B(n-e.startTime),o=process.stderr.columns??80,i=[`${a} Migrating ${t} \xB7 ${r} elapsed`,` ${e.confirmed.toLocaleString()} / ${e.total.toLocaleString()} files done \xB7 ${e.failed.toLocaleString()} failed \xB7 ${m(e.confirmedBytes)} confirmed, ${m(e.inFlightBytes)} in flight`],c=e.inFlight.length;if(c===0)return i.push(" 0 in flight"),i;let l=Math.max(1,(process.stderr.rows??24)-1-3),{shown:f,hidden:d}=ie(e.inFlight,l);i.push(d.length===0?` ${c.toLocaleString()} in flight:`:` ${c.toLocaleString()} in flight (showing ${f.length} longest-queued):`);for(let g of f)i.push(se(g,n,o));if(d.length>0){let g=d.reduce((h,S)=>h+S.size,0);i.push(` + ${d.length.toLocaleString()} more in flight (${m(g)})`)}return i}var b=0;function fe(e,t){if(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)return;let n=process.stderr.columns??80,a=le(e,t).map(o=>o.length>n?`${o.slice(0,Math.max(1,n-1))}\u2026`:o),r="";b>0&&(r+=`\x1B[${b}A`),r+="\x1B[0J",r+=`${a.join(`
2
2
  `)}
3
- `,h=a.length,process.stderr.write(i)}function b(){if(!(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)){if(h>0){process.stderr.write(`\x1B[${h}A\x1B[0J`),h=0;return}process.stderr.write("\r\x1B[K")}}async function L(e,r,t,a){let i=await F(e.map(n=>()=>H(n.name,{config:{...t,bucket:a}})),y);for(let n=0;n<i.length;n++){let c=i[n],s=e[n];c.error?(r.failed++,r.errors.push({name:s.name,error:c.error.message})):(r.inFlight.push({...s,checkFailures:0,scheduledAt:Date.now()}),r.inFlightBytes+=s.size,r.scheduled++)}}async function N(e,r,t,a){let i=e.inFlight.length;if(i===0)return;let n=e.drainOffset%i,c=[];for(let d=0;d<Math.min(y,i);d++)c.push(e.inFlight[(n+d)%i]);e.drainOffset=n+c.length;let s=await F(c.map(d=>()=>J(d.name,{config:{...r,bucket:t}})),y),l=new Set;for(let d=0;d<s.length;d++){let p=s[d],f=c[d];p.error?(f.checkFailures++,f.checkFailures>=R&&(l.add(f.name),e.failed++,e.inFlightBytes-=f.size,e.errors.push({name:f.name,error:`Failed to verify migration status after ${R} attempts`}))):p.data&&(l.add(f.name),e.confirmed++,e.confirmedBytes+=f.size,e.inFlightBytes-=f.size)}if(l.size>0){e.inFlight=e.inFlight.filter(d=>!l.has(d.name)),e.drainSweepMisses=0,e.checkBackoffMs=D;return}e.drainSweepMisses+=c.length,e.drainSweepMisses>=i&&(e.drainSweepMisses=0,await Q(e.checkBackoffMs,a),e.checkBackoffMs=Math.min(e.checkBackoffMs*2,Y))}async function te(e){let r=B(e,["path"]);r||M(S,"Bucket name or path is required");let{bucket:t,path:a}=O(r);t||M(S,"Invalid path");let i=await E(),n=!1,c,s=new AbortController,l=()=>{c&&(clearInterval(c),c=void 0)},d=()=>{n&&process.exit(130),n=!0,s.abort(),l(),b()};process.on("SIGINT",d);let p=()=>{b()};process.stderr.on("resize",p);try{process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&process.stderr.write("Discovering objects to migrate...");let f;try{f=await Z(t,a,i,s.signal)}catch(g){b(),M(S,g)}if(b(),n&&(console.error(`
4
- Cancelled.`),process.exit(1)),f.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:t,toMigrate:0,confirmed:0,failed:0}));return}let k=f.reduce((g,I)=>g+I.size,0);process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error(`Found ${f.length.toLocaleString()} objects to migrate (${m(k)})`),X(f);let P=Date.now(),o={total:f.length,totalBytes:k,scheduled:0,confirmed:0,confirmedBytes:0,failed:0,inFlight:[],inFlightBytes:0,drainOffset:0,drainSweepMisses:0,checkBackoffMs:D,spinnerFrame:0,errors:[],startTime:P};process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&(c=setInterval(()=>re(o,t),K),c.unref?.());let u=[],w=0;for(let g of f){if(n)break;for(V(o,u.length,w,g.size)&&(await L(u,o,i,t),u=[],w=0);U(o,g.size)&&!n;)await N(o,i,t,s.signal);if(n)break;u.push(g),w+=g.size}for(u.length>0&&!n&&await L(u,o,i,t);o.inFlight.length>0&&!n;)await N(o,i,t,s.signal);l(),b();let T=$(Date.now()-o.startTime);if(globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:t,toMigrate:o.total,scheduled:o.scheduled,confirmed:o.confirmed,failed:o.failed,elapsed:T,...o.errors.length>0?{errors:o.errors.slice(0,20)}:{}})),n&&(console.error(`
5
- Cancelled \u2014 ${o.confirmed.toLocaleString()} confirmed, ${o.inFlight.length.toLocaleString()} queued for migration, ${(o.total-o.scheduled).toLocaleString()} not scheduled. Re-run migrate to resume.`),process.exit(1)),o.failed>0){if(v(S,`${o.failed} object(s) failed to migrate. ${o.confirmed} migrated successfully in ${T}.`),process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&o.errors.length>0){let g=o.errors.slice(0,10);for(let I of g)console.error(` ${I.name}: ${I.error}`);o.errors.length>10&&console.error(` ... and ${o.errors.length-10} more`)}process.exit(1)}console.error(`
6
- Migration complete: ${o.confirmed.toLocaleString()} object(s) migrated (${m(o.confirmedBytes)}) in ${T}`)}finally{l(),process.removeListener("SIGINT",d),process.stderr.removeListener("resize",p)}}export{W as activityLabel,U as atCapacity,te as default,N as drainCompleted,q as oldestInFlight,X as orderForMigration,V as shouldFlushBatch};
3
+ `,b=a.length,process.stderr.write(r)}function M(){if(!(!process.stderr.isTTY||globalThis.__TIGRIS_JSON_MODE)){if(b>0){process.stderr.write(`\x1B[${b}A\x1B[0J`),b=0;return}process.stderr.write("\r\x1B[K")}}async function D(e,t,n,a){let r=await k(e.map(o=>async()=>({result:await U(o.name,{config:{...n,bucket:a}}),scheduledAt:Date.now()})),$);for(let o=0;o<r.length;o++){let{result:i,scheduledAt:c}=r[o],l=e[o];i.error?(t.failed++,t.errors.push({name:l.name,error:i.error.message})):(t.inFlight.push({...l,checkFailures:0,scheduledAt:c}),t.inFlightBytes+=l.size,t.scheduled++)}}async function J(e,t,n,a){let r=e.inFlight.length;if(r===0)return;let o=e.drainOffset%r,i=[];for(let f=0;f<Math.min($,r);f++)i.push(e.inFlight[(o+f)%r]);e.drainOffset=o+i.length;let c=await k(i.map(f=>()=>X(f.name,{config:{...t,bucket:n}})),$),l=new Set;for(let f=0;f<c.length;f++){let d=c[f],g=i[f];d.error?(g.checkFailures++,g.checkFailures>=z&&(l.add(g.name),e.failed++,e.inFlightBytes-=g.size,e.errors.push({name:g.name,error:`Failed to verify migration status after ${z} attempts`}))):d.data&&(l.add(g.name),e.confirmed++,e.confirmedBytes+=g.size,e.inFlightBytes-=g.size)}if(l.size>0){e.inFlight=e.inFlight.filter(f=>!l.has(f.name)),e.drainSweepMisses=0,e.checkBackoffMs=H;return}e.drainSweepMisses+=i.length,e.drainSweepMisses>=r&&(e.drainSweepMisses=0,await ce(e.checkBackoffMs,a),e.checkBackoffMs=Math.min(e.checkBackoffMs*2,K))}async function ge(e){let t=x(e,["path"]);t||I(_,"Bucket name or path is required");let{bucket:n,path:a}=L(t);n||I(_,"Invalid path");let r=ee(x(e,["max-in-flight-gb","maxInFlightGb"]));r.ok||I(_,r.error);let o=await N(),i=!1,c,l=new AbortController,f=()=>{c&&(clearInterval(c),c=void 0)},d=()=>{i&&process.exit(130),i=!0,l.abort(),f(),M()};process.on("SIGINT",d);let g=()=>{M()};process.stderr.on("resize",g);try{process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&process.stderr.write("Discovering objects to migrate...");let h;try{h=await ae(n,a,o,l.signal)}catch(u){M(),I(_,u)}if(M(),i&&(console.error(`
4
+ Cancelled.`),process.exit(1)),h.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:n,toMigrate:0,confirmed:0,failed:0}));return}let S=h.reduce((u,w)=>u+w.size,0);process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&console.error(`Found ${h.length.toLocaleString()} objects to migrate (${m(S)})`),Q(h);let Y=Date.now(),s={total:h.length,totalBytes:S,scheduled:0,confirmed:0,confirmedBytes:0,failed:0,inFlight:[],inFlightBytes:0,maxInFlightBytes:r.bytes,drainOffset:0,drainSweepMisses:0,checkBackoffMs:H,spinnerFrame:0,errors:[],startTime:Y};process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&(c=setInterval(()=>fe(s,n),Z),c.unref?.());let p=[],T=0;for(let u of h){if(i)break;for(ne(s,p.length,T,u.size)&&(await D(p,s,o,n),p=[],T=0);te(s,u.size)&&!i;)await J(s,o,n,l.signal);if(i)break;p.push(u),T+=u.size}for(p.length>0&&!i&&await D(p,s,o,n);s.inFlight.length>0&&!i;)await J(s,o,n,l.signal);f(),M();let y=B(Date.now()-s.startTime);if(globalThis.__TIGRIS_JSON_MODE&&console.log(JSON.stringify({action:"migrate",bucket:n,toMigrate:s.total,scheduled:s.scheduled,confirmed:s.confirmed,failed:s.failed,elapsed:y,...s.errors.length>0?{errors:s.errors.slice(0,20)}:{}})),i&&(console.error(`
5
+ Cancelled \u2014 ${s.confirmed.toLocaleString()} confirmed, ${s.inFlight.length.toLocaleString()} queued for migration, ${(s.total-s.scheduled).toLocaleString()} not scheduled. Re-run migrate to resume.`),process.exit(1)),s.failed>0){if(E(_,`${s.failed} object(s) failed to migrate. ${s.confirmed} migrated successfully in ${y}.`),process.stderr.isTTY&&!globalThis.__TIGRIS_JSON_MODE&&s.errors.length>0){let u=s.errors.slice(0,10);for(let w of u)console.error(` ${w.name}: ${w.error}`);s.errors.length>10&&console.error(` ... and ${s.errors.length-10} more`)}process.exit(1)}console.error(`
6
+ Migration complete: ${s.confirmed.toLocaleString()} object(s) migrated (${m(s.confirmedBytes)}) in ${y}`)}finally{f(),process.removeListener("SIGINT",d),process.stderr.removeListener("resize",g)}}export{te as atCapacity,ge as default,J as drainCompleted,D as flushScheduleBatch,se as formatInFlightRow,ie as inFlightView,re as orderForDisplay,Q as orderForMigration,ee as parseMaxInFlightBytes,ne as shouldFlushBatch};
@@ -1 +1 @@
1
- import{a as k,b}from"../../chunk-S77OAN6Y.js";import{e as l}from"../../chunk-5UQUUFCL.js";import{a as s,b as d}from"../../chunk-S6KFKBMY.js";import{b as n,c as g,d as p}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as m,j as u}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{rebaseFork as A}from"@tigrisdata/storage";var o=u("buckets","rebase");async function S(r){f(o);let h=d(r),t=s(r,["fork"]),x=s(r,["yes","y"]);t||n(o,"Fork bucket name is required");let w=await l();if(!x&&(k("Use --yes to skip confirmation"),!await b(`Rebase fork '${t}' onto the latest state of its source bucket? This updates '${t}'.`))){console.log("Aborted");return}let{data:y,error:i}=await A(t,{config:w});i&&n(o,i);let c=y?.snapshotVersion??"";if(h==="json"){let e=g(o,{fork:t}),a={action:"rebased",fork:t,snapshotVersion:c};e.length>0&&(a.nextActions=e),console.log(JSON.stringify(a))}m(o,{fork:t,snapshotVersion:c}),p(o,{fork:t})}export{S as default};
1
+ import{a as k,b}from"../../chunk-S77OAN6Y.js";import{e as l}from"../../chunk-A3YRE353.js";import{a as s,b as d}from"../../chunk-S6KFKBMY.js";import{b as n,c as g,d as p}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as f,c as m,j as u}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{rebaseFork as A}from"@tigrisdata/storage";var o=u("buckets","rebase");async function S(r){f(o);let h=d(r),t=s(r,["fork"]),x=s(r,["yes","y"]);t||n(o,"Fork bucket name is required");let w=await l();if(!x&&(k("Use --yes to skip confirmation"),!await b(`Rebase fork '${t}' onto the latest state of its source bucket? This updates '${t}'.`))){console.log("Aborted");return}let{data:y,error:i}=await A(t,{config:w});i&&n(o,i);let c=y?.snapshotVersion??"";if(h==="json"){let e=g(o,{fork:t}),a={action:"rebased",fork:t,snapshotVersion:c};e.length>0&&(a.nextActions=e),console.log(JSON.stringify(a))}m(o,{fork:t,snapshotVersion:c}),p(o,{fork:t})}export{S as default};
@@ -1 +1 @@
1
- import{e as x}from"../../chunk-5UQUUFCL.js";import{a as d,b as l}from"../../chunk-S6KFKBMY.js";import{a as i,b as g,c as u,d as p}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,d as n,j as f}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{restoreBucket as w}from"@tigrisdata/storage";var t=f("buckets","restore");async function A(s){a(t);let k=l(s),o=d(s,["name"]);o||g(t,"Bucket name is required");let{data:S,error:e}=await w(o,{config:await x()});if(e&&(n(t,e.message,{name:o}),i(e,t)),!S.restored){let r="Bucket could not be restored";n(t,r,{name:o}),i(r,t)}if(k==="json"){let r=u(t,{name:o}),c={action:"restored",name:o};r.length>0&&(c.nextActions=r),console.log(JSON.stringify(c))}m(t,{name:o}),p(t,{name:o})}export{A as default};
1
+ import{e as x}from"../../chunk-A3YRE353.js";import{a as d,b as l}from"../../chunk-S6KFKBMY.js";import{a as i,b as g,c as u,d as p}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as m,d as n,j as f}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{restoreBucket as w}from"@tigrisdata/storage";var t=f("buckets","restore");async function A(s){a(t);let k=l(s),o=d(s,["name"]);o||g(t,"Bucket name is required");let{data:S,error:e}=await w(o,{config:await x()});if(e&&(n(t,e.message,{name:o}),i(e,t)),!S.restored){let r="Bucket could not be restored";n(t,r,{name:o}),i(r,t)}if(k==="json"){let r=u(t,{name:o}),c={action:"restored",name:o};r.length>0&&(c.nextActions=r),console.log(JSON.stringify(c))}m(t,{name:o}),p(t,{name:o})}export{A as default};
@@ -1 +1 @@
1
- import{f as x}from"../../chunk-5UQUUFCL.js";import{a as r,b as h}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as b}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=b("buckets","set-cors");async function k(e){c(n);let p=h(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"]),u=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||u)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(Number.isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await x(),{error:g}=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:u??!1,config:w});g&&i(n,g),p==="json"&&console.log(JSON.stringify({action:"updated",bucket:o})),l(n,{name:o})}export{k as default};
1
+ import{f as x}from"../../chunk-A3YRE353.js";import{a as r,b as h}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as c,c as l,j as b}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{setBucketCors as N}from"@tigrisdata/storage";var n=b("buckets","set-cors");async function k(e){c(n);let p=h(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"]),u=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||u)&&i(n,"Cannot use --reset with other options"),!m&&!s&&i(n,"Provide --origins or --reset"),t!==void 0&&(Number.isNaN(Number(t))||Number(t)<=0)&&i(n,"--max-age must be a positive number");let w=await x(),{error:g}=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:u??!1,config:w});g&&i(n,g),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,c as d}from"../../chunk-N3Y6RFSK.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{f as u}from"../../chunk-5UQUUFCL.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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,c as d}from"../../chunk-N3Y6RFSK.js";import{a as g}from"../../chunk-S77OAN6Y.js";import{f as u}from"../../chunk-A3YRE353.js";import{a as e,b as p}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as s,c as f,j as m}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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{f as p}from"../../chunk-5UQUUFCL.js";import{a as t,b as w}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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{f as p}from"../../chunk-A3YRE353.js";import{a as t,b as w}from"../../chunk-S6KFKBMY.js";import{b as r}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as h,c as f,j as y}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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{f as p}from"../../chunk-5UQUUFCL.js";import{a as n,b as w}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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{f as p}from"../../chunk-A3YRE353.js";import{a as n,b as w}from"../../chunk-S6KFKBMY.js";import{b as i}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b,c as h,j as k}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.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{c as S}from"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{f as k}from"../../chunk-5UQUUFCL.js";import{a as n,b as C,d as s}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as O,j as A}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{updateBucket as L}from"@tigrisdata/storage";var i=A("buckets","set");async function q(e){w(i);let j=C(e),d=n(e,["name"]),r=n(e,["access"]),l=n(e,["default-tier","defaultTier"]),c=n(e,["locations"]),f=n(e,["allow-object-acl","allowObjectAcl"]),u=n(e,["disable-directory-listing","disableDirectoryListing"]),b=n(e,["cache-control","cacheControl"]),g=n(e,["custom-domain","customDomain"]),m=n(e,["enable-delete-protection","enableDeleteProtection"]),a=n(e,["soft-delete","softDelete"]),y=n(e,["retention-days","retentionDays"]),D=n(e,["enable-additional-headers","enableAdditionalHeaders"]);d||o(i,"Bucket name is required"),r===void 0&&l===void 0&&c===void 0&&f===void 0&&u===void 0&&b===void 0&&g===void 0&&m===void 0&&a===void 0&&D===void 0&&o(i,"At least one setting is required");let t={};if(r!==void 0&&(t.access=r),l!==void 0&&(t.defaultTier=l),c!==void 0&&(t.locations=S(c)),f!==void 0&&(t.allowObjectAcl=s(f)),u!==void 0&&(t.disableDirectoryListing=s(u)),b!==void 0&&(t.cacheControl=b),g!==void 0&&(t.customDomain=g),m!==void 0&&(t.enableDeleteProtection=s(m)),a!==void 0&&a!=="enable"&&a!=="disable"&&o(i,'--soft-delete must be "enable" or "disable"'),y!==void 0&&a!=="enable"&&o(i,"--retention-days can only be used with --soft-delete enable"),a==="enable"){y===void 0&&o(i,"--retention-days is required when enabling soft delete");let p=Number(y);(!Number.isInteger(p)||p<=0)&&o(i,"--retention-days must be a positive integer"),t.softDelete={enabled:!0,retentionDays:p}}else a==="disable"&&(t.softDelete={enabled:!1});D!==void 0&&(t.enableAdditionalHeaders=s(D));let B=await k(),{error:h}=await L(d,{...t,config:B});h&&o(i,h),j==="json"&&console.log(JSON.stringify({action:"updated",name:d})),O(i,{name:d})}export{q as default};
1
+ import{c as S}from"../../chunk-N3Y6RFSK.js";import"../../chunk-S77OAN6Y.js";import{f as k}from"../../chunk-A3YRE353.js";import{a as n,b as C,d as s}from"../../chunk-S6KFKBMY.js";import{b as o}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as w,c as O,j as A}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{updateBucket as L}from"@tigrisdata/storage";var i=A("buckets","set");async function q(e){w(i);let j=C(e),d=n(e,["name"]),r=n(e,["access"]),l=n(e,["default-tier","defaultTier"]),c=n(e,["locations"]),f=n(e,["allow-object-acl","allowObjectAcl"]),u=n(e,["disable-directory-listing","disableDirectoryListing"]),b=n(e,["cache-control","cacheControl"]),g=n(e,["custom-domain","customDomain"]),m=n(e,["enable-delete-protection","enableDeleteProtection"]),a=n(e,["soft-delete","softDelete"]),y=n(e,["retention-days","retentionDays"]),D=n(e,["enable-additional-headers","enableAdditionalHeaders"]);d||o(i,"Bucket name is required"),r===void 0&&l===void 0&&c===void 0&&f===void 0&&u===void 0&&b===void 0&&g===void 0&&m===void 0&&a===void 0&&D===void 0&&o(i,"At least one setting is required");let t={};if(r!==void 0&&(t.access=r),l!==void 0&&(t.defaultTier=l),c!==void 0&&(t.locations=S(c)),f!==void 0&&(t.allowObjectAcl=s(f)),u!==void 0&&(t.disableDirectoryListing=s(u)),b!==void 0&&(t.cacheControl=b),g!==void 0&&(t.customDomain=g),m!==void 0&&(t.enableDeleteProtection=s(m)),a!==void 0&&a!=="enable"&&a!=="disable"&&o(i,'--soft-delete must be "enable" or "disable"'),y!==void 0&&a!=="enable"&&o(i,"--retention-days can only be used with --soft-delete enable"),a==="enable"){y===void 0&&o(i,"--retention-days is required when enabling soft delete");let p=Number(y);(!Number.isInteger(p)||p<=0)&&o(i,"--retention-days must be a positive integer"),t.softDelete={enabled:!0,retentionDays:p}}else a==="disable"&&(t.softDelete={enabled:!1});D!==void 0&&(t.enableAdditionalHeaders=s(D));let B=await k(),{error:h}=await L(d,{...t,config:B});h&&o(i,h),j==="json"&&console.log(JSON.stringify({action:"updated",name:d})),O(i,{name:d})}export{q as default};
@@ -1,3 +1,3 @@
1
- import{e as k}from"../chunk-7ZCVOA6A.js";import{e as h}from"../chunk-5UQUUFCL.js";import{a,b as p,e as y}from"../chunk-S6KFKBMY.js";import{a as o}from"../chunk-B7CB3ST5.js";import"../chunk-2XSEQJGZ.js";import"../chunk-HWAEADX7.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-6ZZ54RU7.js";import"../chunk-J3MAV7JB.js";import"../chunk-F4AGJWCK.js";import{createWriteStream as E,existsSync as j,readFileSync as v}from"fs";import{Readable as B}from"stream";import{pipeline as b}from"stream/promises";import{bundle as C}from"@tigrisdata/storage";var z=5e3;function S(t){return t.split(`
1
+ import{e as k}from"../chunk-7ZCVOA6A.js";import{e as h}from"../chunk-A3YRE353.js";import{a,b as p,e as y}from"../chunk-S6KFKBMY.js";import{a as o}from"../chunk-U3422EZ6.js";import"../chunk-5JBNZ4C6.js";import"../chunk-3ILNJZ6D.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-6ZZ54RU7.js";import"../chunk-J3MAV7JB.js";import"../chunk-F4AGJWCK.js";import{createWriteStream as E,existsSync as j,readFileSync as v}from"fs";import{Readable as B}from"stream";import{pipeline as b}from"stream/promises";import{bundle as C}from"@tigrisdata/storage";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):j(s)?e=S(v(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 C(e,{config:{...$,bucket:d},compression:f,onError:w});m&&o(m);let u=B.fromWeb(x.body);if(i){let r=E(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-5UQUUFCL.js";import{b as S}from"../../chunk-S6KFKBMY.js";import{a as f,b as p,d as u}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import{a as m}from"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import{m as y,q as l}from"../../chunk-F4AGJWCK.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:m}),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)&&p(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),u(a)}catch(r){d(a,"Failed to save credentials"),f(r,a)}}export{I as default};
1
+ import{a as K}from"../../chunk-S77OAN6Y.js";import{a as E}from"../../chunk-A3YRE353.js";import{b as S}from"../../chunk-S6KFKBMY.js";import{a as f,b as p,d as u}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as n,c as o,d,j as g}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import{a as m}from"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import{m as y,q as l}from"../../chunk-F4AGJWCK.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:m}),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)&&p(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),u(a)}catch(r){d(a,"Failed to save credentials"),f(r,a)}}export{I as default};
package/dist/lib/cp.js CHANGED
@@ -1 +1 @@
1
- import{a as G}from"../chunk-EKW6XTGL.js";import{a as x}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-AFM3TY2D.js";import{a as U,b as C,d as D,f as O,g as j,i as A}from"../chunk-7ZCVOA6A.js";import{e as K}from"../chunk-5UQUUFCL.js";import{a as N,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-B7CB3ST5.js";import"../chunk-2XSEQJGZ.js";import"../chunk-HWAEADX7.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-6ZZ54RU7.js";import"../chunk-J3MAV7JB.js";import"../chunk-F4AGJWCK.js";import{createReadStream as P,createWriteStream as tt,existsSync as V,mkdirSync as et,readdirSync as I,statSync as z}from"fs";import{homedir as ot}from"os";import{basename as E,dirname as L,join as v,relative as _,resolve as H}from"path";import{Readable as X}from"stream";import{pipeline as it}from"stream/promises";import{copy as nt,get as rt,head as at,list as lt,put as Y}from"@tigrisdata/storage";var h=!1;function ct(i,t){let e=U(i),a=U(t);return!e&&!a&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&a?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(ot(),i.slice(2)):H(i)}function st(i){return I(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let a=e.parentPath??e.path;return v(a,e.name)})}function pt(i,t){let e=L(i),a=E(i),p=O(a);return V(e)?t?I(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&p.test(r.name)).map(r=>{let l=r.parentPath??r.path;return v(l,r.name)}):I(e,{withFileTypes:!0}).filter(l=>l.isFile()&&p.test(l.name)).map(l=>v(e,l.name)):[]}async function J(i,t,e,a,p=!1,c){let r;try{r=z(i).size}catch{return{error:`File not found: ${i}`}}let l=P(i),n=X.toWeb(l),o=q(i),{error:s}=await Y(e,n,{...G(r),...o?{contentType:o}:{},...c?{access:c}:{},onUploadProgress:p?({loaded:u})=>{if(r!==void 0&&r>0){let d=Math.round(u/r*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(r)} (${d}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...a,bucket:t}});return p&&process.stdout.write(`\r${" ".repeat(60)}\r`),s?{error:s.message}:{}}async function Q(i,t,e,a,p=!1){let c;if(p){let{data:u}=await at(t,{config:{...a,bucket:i}});c=u?.size}let{data:r,error:l}=await rt(t,"stream",{config:{...a,bucket:i}});if(l)return{error:l.message};let n=L(e);V(n)||et(n,{recursive:!0});let o=tt(e),s=X.fromWeb(r);if(p&&c!==void 0&&c>0){let u=0;s.on("data",d=>{u+=d.length;let m=Math.round(u/c*100);process.stdout.write(`\rDownloading: ${R(u)} / ${R(c)} (${m}%)`)})}return await it(s,o),p&&process.stdout.write(`\r${" ".repeat(60)}\r`),{}}async function B(i,t,e,a,p){if(e.endsWith("/")){let{error:r}=await Y(p,"",{config:{...i,bucket:a}});return r?{error:r.message}:{}}let{error:c}=await nt(e,p,{srcBucket:t,destBucket:a,config:{...i,bucket:a}});return c?{error:c.message}:{}}async function ut(i,t,e,a,p){let c=Z(i);if(i.includes("*")){let n=pt(c,a);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let o=L(c),s=n.map(m=>async()=>{let w=_(o,m),k=t.path?`${t.path.replace(/\/$/,"")}/${w}`:w,b=await J(m,t.bucket,k,e,!1,p);return b.error?(console.error(`Failed to upload ${m}: ${b.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`);return}let l;try{l=z(c)}catch{f(`Source not found: ${i}`)}if(l.isDirectory()){a||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let n=st(c);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let o=i.endsWith("/")?"":E(c),s=n.map(m=>async()=>{let w=_(c,m),b=[t.path?.replace(/\/$/,""),o,w].filter(Boolean).join("/"),y=await J(m,t.bucket,b,e,!1,p);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${b}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`)}else{let n=E(c),o;t.path?i.endsWith("/")||t.path.endsWith("/")?o=`${t.path.replace(/\/$/,"")}/${n}`:await D(t.bucket,t.path,e)?o=`${t.path}/${n}`:o=t.path:o=n;let s=await J(c,t.bucket,o,e,!h,p);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${o}`}):`Uploaded ${i} -> t3://${t.bucket}/${o}`)}}async function ft(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=Z(e),l=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&c;if(!l&&!n&&(n=await D(t.bucket,t.path,a)),n&&!l&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),l||n){let o=l?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",s=!l&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:d}=await A(t.bucket,o||void 0,a);d&&f(d);let m=u.filter(y=>!y.name.endsWith("/"));if(l){let y=t.path.split("/").pop(),$=O(y);m=m.filter(S=>{let g=o?S.name.slice(o.length):S.name;return!p&&g.includes("/")?!1:$.test(g.split("/").pop())})}if(m.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=m.map(y=>async()=>{let $=o?y.name.slice(o.length):y.name,S=s?v(r,s,$):v(r,$),g=await Q(t.bucket,y.name,S,a);return g.error?(console.error(`Failed to download ${y.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),b=(await x(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:b}):`Downloaded ${b} file(s)`)}else{let o=t.path.split("/").pop(),s,u=!1;try{u=z(r).isDirectory()}catch{}u||e.endsWith("/")?s=v(r,o):s=r;let d=await Q(t.bucket,t.path,s,a,!h);d.error&&f(d.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:s}):`Downloaded t3://${t.bucket}/${t.path} -> ${s}`)}}async function mt(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=i.includes("*"),l=t.path.endsWith("/")||!t.path&&c;if(!r&&!l&&t.path&&(l=await D(t.bucket,t.path,a)),l&&!r&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||l){let n=r?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",o=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),d=u?`${u}/`:"";t.bucket===e.bucket&&n===d&&f("Source and destination are the same");let{items:m,error:w}=await A(t.bucket,n||void 0,a);w&&f(w);let k=m.filter(g=>g.name!==n);if(r){let g=t.path.split("/").pop(),W=O(g);k=k.filter(F=>{let T=n?F.name.slice(n.length):F.name;return!p&&T.includes("/")?!1:W.test(T.split("/").pop())})}let b=k.map(g=>async()=>{let W=n?g.name.slice(n.length):g.name,F=u?`${u}/${W}`:W,T=await B(a,t.bucket,g.name,e.bucket,F);return T.error?(console.error(`Failed to copy ${g.name}: ${T.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${F}`),!0)}),$=(await x(b,8)).filter(Boolean).length,S=!1;if(u&&n){let{data:g}=await lt({prefix:n,limit:1,config:{...a,bucket:t.bucket}});if(g?.items?.some(W=>W.name===n)){let W=`${u}/`,F=await B(a,t.bucket,n,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if($===0&&S&&($=1),$===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:$}):`Copied ${$} object(s)`)}else{let n=t.path.split("/").pop(),o;e.path?e.path.endsWith("/")?o=`${e.path}${n}`:await D(e.bucket,e.path,a)?o=`${e.path}/${n}`:o=e.path:o=n,t.bucket===e.bucket&&t.path===o&&f("Source and destination are the same");let s=await B(a,t.bucket,t.path,e.bucket,o);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${o}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${o}`)}}async function ht(i){let t=N(i,["src"]),e=N(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let a=!!N(i,["recursive","r"]),p=N(i,["access","a","A"]);h=M(i)==="json";let r;p===void 0?r=void 0:p==="public"||p==="private"?r=p:f('Access level must be either "public" or "private"');let l=ct(t,e);r!==void 0&&l!=="local-to-remote"&&f('--access only applies to local-to-remote uploads. Use "tigris objects set-access" to change access on existing objects.');let n=await K({withCredentialProvider:!0});switch(l){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await ut(t,o,n,a,r);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await ft(t,o,e,n,a);break}case"remote-to-remote":{let o=C(t),s=C(e);o.bucket||f("Invalid source path"),s.bucket||f("Invalid destination path"),await mt(t,o,s,n,a);break}}process.exit(0)}export{ht as default};
1
+ import{a as G}from"../chunk-EKW6XTGL.js";import{a as x}from"../chunk-SAAGVLRE.js";import{a as q}from"../chunk-HPICBIXL.js";import{a as R}from"../chunk-AFM3TY2D.js";import{a as U,b as C,d as D,f as O,g as j,i as A}from"../chunk-7ZCVOA6A.js";import{e as K}from"../chunk-A3YRE353.js";import{a as N,b as M}from"../chunk-S6KFKBMY.js";import{a as f}from"../chunk-U3422EZ6.js";import"../chunk-5JBNZ4C6.js";import"../chunk-3ILNJZ6D.js";import"../chunk-DV3LCXRH.js";import"../chunk-D7WXNA2O.js";import"../chunk-NI4EYBQH.js";import"../chunk-6ZZ54RU7.js";import"../chunk-J3MAV7JB.js";import"../chunk-F4AGJWCK.js";import{createReadStream as P,createWriteStream as tt,existsSync as V,mkdirSync as et,readdirSync as I,statSync as z}from"fs";import{homedir as ot}from"os";import{basename as E,dirname as L,join as v,relative as _,resolve as H}from"path";import{Readable as X}from"stream";import{pipeline as it}from"stream/promises";import{copy as nt,get as rt,head as at,list as lt,put as Y}from"@tigrisdata/storage";var h=!1;function ct(i,t){let e=U(i),a=U(t);return!e&&!a&&f("At least one path must be a remote Tigris path (t3:// or tigris://)"),e&&a?"remote-to-remote":e?"remote-to-local":"local-to-remote"}function Z(i){return i==="~"||i.startsWith("~/")?H(ot(),i.slice(2)):H(i)}function st(i){return I(i,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>{let a=e.parentPath??e.path;return v(a,e.name)})}function pt(i,t){let e=L(i),a=E(i),p=O(a);return V(e)?t?I(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()&&p.test(r.name)).map(r=>{let l=r.parentPath??r.path;return v(l,r.name)}):I(e,{withFileTypes:!0}).filter(l=>l.isFile()&&p.test(l.name)).map(l=>v(e,l.name)):[]}async function J(i,t,e,a,p=!1,c){let r;try{r=z(i).size}catch{return{error:`File not found: ${i}`}}let l=P(i),n=X.toWeb(l),o=q(i),{error:s}=await Y(e,n,{...G(r),...o?{contentType:o}:{},...c?{access:c}:{},onUploadProgress:p?({loaded:u})=>{if(r!==void 0&&r>0){let d=Math.round(u/r*100);process.stdout.write(`\rUploading: ${R(u)} / ${R(r)} (${d}%)`)}else process.stdout.write(`\rUploading: ${R(u)}`)}:void 0,config:{...a,bucket:t}});return p&&process.stdout.write(`\r${" ".repeat(60)}\r`),s?{error:s.message}:{}}async function Q(i,t,e,a,p=!1){let c;if(p){let{data:u}=await at(t,{config:{...a,bucket:i}});c=u?.size}let{data:r,error:l}=await rt(t,"stream",{config:{...a,bucket:i}});if(l)return{error:l.message};let n=L(e);V(n)||et(n,{recursive:!0});let o=tt(e),s=X.fromWeb(r);if(p&&c!==void 0&&c>0){let u=0;s.on("data",d=>{u+=d.length;let m=Math.round(u/c*100);process.stdout.write(`\rDownloading: ${R(u)} / ${R(c)} (${m}%)`)})}return await it(s,o),p&&process.stdout.write(`\r${" ".repeat(60)}\r`),{}}async function B(i,t,e,a,p){if(e.endsWith("/")){let{error:r}=await Y(p,"",{config:{...i,bucket:a}});return r?{error:r.message}:{}}let{error:c}=await nt(e,p,{srcBucket:t,destBucket:a,config:{...i,bucket:a}});return c?{error:c.message}:{}}async function ut(i,t,e,a,p){let c=Z(i);if(i.includes("*")){let n=pt(c,a);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files matching pattern");return}let o=L(c),s=n.map(m=>async()=>{let w=_(o,m),k=t.path?`${t.path.replace(/\/$/,"")}/${w}`:w,b=await J(m,t.bucket,k,e,!1,p);return b.error?(console.error(`Failed to upload ${m}: ${b.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${k}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`);return}let l;try{l=z(c)}catch{f(`Source not found: ${i}`)}if(l.isDirectory()){a||f(`${i} is a directory (not copied). Use -r to copy recursively.`);let n=st(c);if(n.length===0){console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:0}):"No files to upload");return}let o=i.endsWith("/")?"":E(c),s=n.map(m=>async()=>{let w=_(c,m),b=[t.path?.replace(/\/$/,""),o,w].filter(Boolean).join("/"),y=await J(m,t.bucket,b,e,!1,p);return y.error?(console.error(`Failed to upload ${m}: ${y.error}`),!1):(h||console.log(`Uploaded ${m} -> t3://${t.bucket}/${b}`),!0)}),d=(await x(s,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:d}):`Uploaded ${d} file(s)`)}else{let n=E(c),o;t.path?i.endsWith("/")||t.path.endsWith("/")?o=`${t.path.replace(/\/$/,"")}/${n}`:await D(t.bucket,t.path,e)?o=`${t.path}/${n}`:o=t.path:o=n;let s=await J(c,t.bucket,o,e,!h,p);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"local-to-remote",count:1,src:i,dest:`t3://${t.bucket}/${o}`}):`Uploaded ${i} -> t3://${t.bucket}/${o}`)}}async function ft(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=Z(e),l=t.path.includes("*"),n=t.path.endsWith("/")||!t.path&&c;if(!l&&!n&&(n=await D(t.bucket,t.path,a)),n&&!l&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),l||n){let o=l?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",s=!l&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",{items:u,error:d}=await A(t.bucket,o||void 0,a);d&&f(d);let m=u.filter(y=>!y.name.endsWith("/"));if(l){let y=t.path.split("/").pop(),$=O(y);m=m.filter(S=>{let g=o?S.name.slice(o.length):S.name;return!p&&g.includes("/")?!1:$.test(g.split("/").pop())})}if(m.length===0){console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:0}):"No objects to download");return}let w=m.map(y=>async()=>{let $=o?y.name.slice(o.length):y.name,S=s?v(r,s,$):v(r,$),g=await Q(t.bucket,y.name,S,a);return g.error?(console.error(`Failed to download ${y.name}: ${g.error}`),!1):(h||console.log(`Downloaded t3://${t.bucket}/${y.name} -> ${S}`),!0)}),b=(await x(w,8)).filter(Boolean).length;console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:b}):`Downloaded ${b} file(s)`)}else{let o=t.path.split("/").pop(),s,u=!1;try{u=z(r).isDirectory()}catch{}u||e.endsWith("/")?s=v(r,o):s=r;let d=await Q(t.bucket,t.path,s,a,!h);d.error&&f(d.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-local",count:1,src:`t3://${t.bucket}/${t.path}`,dest:s}):`Downloaded t3://${t.bucket}/${t.path} -> ${s}`)}}async function mt(i,t,e,a,p){let c=i.endsWith("/");!t.path&&!c&&f("Cannot copy a bucket. Provide a path within the bucket.");let r=i.includes("*"),l=t.path.endsWith("/")||!t.path&&c;if(!r&&!l&&t.path&&(l=await D(t.bucket,t.path,a)),l&&!r&&!p&&f("Source is a remote folder (not copied). Use -r to copy recursively."),r||l){let n=r?j(t.path):t.path?t.path.endsWith("/")?t.path:`${t.path}/`:"",o=!r&&t.path&&!t.path.endsWith("/")?t.path.split("/").filter(Boolean).pop()??"":"",u=[e.path?.replace(/\/$/,"")||"",o].filter(Boolean).join("/"),d=u?`${u}/`:"";t.bucket===e.bucket&&n===d&&f("Source and destination are the same");let{items:m,error:w}=await A(t.bucket,n||void 0,a);w&&f(w);let k=m.filter(g=>g.name!==n);if(r){let g=t.path.split("/").pop(),W=O(g);k=k.filter(F=>{let T=n?F.name.slice(n.length):F.name;return!p&&T.includes("/")?!1:W.test(T.split("/").pop())})}let b=k.map(g=>async()=>{let W=n?g.name.slice(n.length):g.name,F=u?`${u}/${W}`:W,T=await B(a,t.bucket,g.name,e.bucket,F);return T.error?(console.error(`Failed to copy ${g.name}: ${T.error}`),!1):(h||console.log(`Copied t3://${t.bucket}/${g.name} -> t3://${e.bucket}/${F}`),!0)}),$=(await x(b,8)).filter(Boolean).length,S=!1;if(u&&n){let{data:g}=await lt({prefix:n,limit:1,config:{...a,bucket:t.bucket}});if(g?.items?.some(W=>W.name===n)){let W=`${u}/`,F=await B(a,t.bucket,n,e.bucket,W);F.error?console.error(`Failed to copy folder marker: ${F.error}`):S=!0}}if($===0&&S&&($=1),$===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:$}):`Copied ${$} object(s)`)}else{let n=t.path.split("/").pop(),o;e.path?e.path.endsWith("/")?o=`${e.path}${n}`:await D(e.bucket,e.path,a)?o=`${e.path}/${n}`:o=e.path:o=n,t.bucket===e.bucket&&t.path===o&&f("Source and destination are the same");let s=await B(a,t.bucket,t.path,e.bucket,o);s.error&&f(s.error),console.log(h?JSON.stringify({action:"copied",direction:"remote-to-remote",count:1,src:`t3://${t.bucket}/${t.path}`,dest:`t3://${e.bucket}/${o}`}):`Copied t3://${t.bucket}/${t.path} -> t3://${e.bucket}/${o}`)}}async function ht(i){let t=N(i,["src"]),e=N(i,["dest"]);(!t||!e)&&f("Both src and dest arguments are required");let a=!!N(i,["recursive","r"]),p=N(i,["access","a","A"]);h=M(i)==="json";let r;p===void 0?r=void 0:p==="public"||p==="private"?r=p:f('Access level must be either "public" or "private"');let l=ct(t,e);r!==void 0&&l!=="local-to-remote"&&f('--access only applies to local-to-remote uploads. Use "tigris objects set-access" to change access on existing objects.');let n=await K({withCredentialProvider:!0});switch(l){case"local-to-remote":{let o=C(e);o.bucket||f("Invalid destination path"),await ut(t,o,n,a,r);break}case"remote-to-local":{let o=C(t);o.bucket||f("Invalid source path"),await ft(t,o,e,n,a);break}case"remote-to-remote":{let o=C(t),s=C(e);o.bucket||f("Invalid source path"),s.bucket||f("Invalid destination path"),await mt(t,o,s,n,a);break}}process.exit(0)}export{ht as default};
@@ -1 +1 @@
1
- import{f as k}from"../../chunk-5UQUUFCL.js";import{a as d,b as m}from"../../chunk-S6KFKBMY.js";import{a as s,b as u}from"../../chunk-B7CB3ST5.js";import"../../chunk-2XSEQJGZ.js";import"../../chunk-HWAEADX7.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as f,d as r,j as g}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{list as p,listBuckets as b}from"@tigrisdata/storage";var t=g("credentials","test");async function h(n){a(t);let c=m(n),e=d(n,["bucket","b"]),i=await k();if(!i.accessKeyId&&!i.sessionToken&&u(t,'No credentials found. Run "tigris configure" or "tigris login" first.'),e){let{error:o}=await p({config:{...i,bucket:e},limit:1});o&&(r(t,`Current credentials don't have access to bucket "${e}"`),s(o,t)),c==="json"?console.log(JSON.stringify({valid:!0,bucket:e})):(console.log(` Bucket: ${e}`),console.log(" Access verified."))}else{let{data:o,error:l}=await b({config:i});l&&(r(t,"Current credentials don't have sufficient access"),s(l,t)),console.log(c==="json"?JSON.stringify({valid:!0,bucketCount:o.buckets.length}):` Access verified. Found ${o.buckets.length} bucket(s).`)}f(t)}export{h as default};
1
+ import{f as k}from"../../chunk-A3YRE353.js";import{a as d,b as m}from"../../chunk-S6KFKBMY.js";import{a as s,b as u}from"../../chunk-U3422EZ6.js";import"../../chunk-5JBNZ4C6.js";import"../../chunk-3ILNJZ6D.js";import"../../chunk-DV3LCXRH.js";import{b as a,c as f,d as r,j as g}from"../../chunk-D7WXNA2O.js";import"../../chunk-NI4EYBQH.js";import"../../chunk-6ZZ54RU7.js";import"../../chunk-J3MAV7JB.js";import"../../chunk-F4AGJWCK.js";import{list as p,listBuckets as b}from"@tigrisdata/storage";var t=g("credentials","test");async function h(n){a(t);let c=m(n),e=d(n,["bucket","b"]),i=await k();if(!i.accessKeyId&&!i.sessionToken&&u(t,'No credentials found. Run "tigris configure" or "tigris login" first.'),e){let{error:o}=await p({config:{...i,bucket:e},limit:1});o&&(r(t,`Current credentials don't have access to bucket "${e}"`),s(o,t)),c==="json"?console.log(JSON.stringify({valid:!0,bucket:e})):(console.log(` Bucket: ${e}`),console.log(" Access verified."))}else{let{data:o,error:l}=await b({config:i});l&&(r(t,"Current credentials don't have sufficient access"),s(l,t)),console.log(c==="json"?JSON.stringify({valid:!0,bucketCount:o.buckets.length}):` Access verified. Found ${o.buckets.length} bucket(s).`)}f(t)}export{h as default};
@@ -1 +1 @@
1
- import{a as y}from"../../../chunk-TUDALPGD.js";import{a as g}from"../../../chunk-5Z3OHUTR.js";import"../../../chunk-5UQUUFCL.js";import{a as c,b as u,e as p}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as l,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{existsSync as h,readFileSync as w}from"fs";import{addPolicy as O}from"@tigrisdata/iam";var e=f("iam policies","create");async function A(o){d(e);let P=u(o),a=c(o,["name"]),i=c(o,["document","d"]),S=c(o,["description"])??"";a||t(e,"Policy name is required"),/^[a-zA-Z0-9=,.@_-]+$/.test(a)||t(e,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed.");let v=await g(e),n;i?h(i)?n=w(i,"utf-8"):n=i:process.stdin.isTTY?t(e,"Policy document is required. Provide via --document or pipe to stdin."):n=await p();let m;try{m=y(n)}catch{t(e,"Invalid JSON in policy document")}let{data:r,error:s}=await O(a,{document:m,description:S,config:v});s&&t(e,s),P==="json"&&console.log(JSON.stringify({action:"created",name:r.name,arn:r.resource})),l(e,{name:r.name}),console.log(`Resource: ${r.resource}`)}export{A as default};
1
+ import{a as y}from"../../../chunk-TUDALPGD.js";import{a as g}from"../../../chunk-UIPN4DNR.js";import"../../../chunk-A3YRE353.js";import{a as c,b as u,e as p}from"../../../chunk-S6KFKBMY.js";import{b as t}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as l,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{existsSync as h,readFileSync as w}from"fs";import{addPolicy as O}from"@tigrisdata/iam";var e=f("iam policies","create");async function A(o){d(e);let P=u(o),a=c(o,["name"]),i=c(o,["document","d"]),S=c(o,["description"])??"";a||t(e,"Policy name is required"),/^[a-zA-Z0-9=,.@_-]+$/.test(a)||t(e,"Invalid policy name. Only alphanumeric characters and =,.@_- are allowed.");let v=await g(e),n;i?h(i)?n=w(i,"utf-8"):n=i:process.stdin.isTTY?t(e,"Policy document is required. Provide via --document or pipe to stdin."):n=await p();let m;try{m=y(n)}catch{t(e,"Invalid JSON in policy document")}let{data:r,error:s}=await O(a,{document:m,description:S,config:v});s&&t(e,s),P==="json"&&console.log(JSON.stringify({action:"created",name:r.name,arn:r.resource})),l(e,{name:r.name}),console.log(`Resource: ${r.resource}`)}export{A as default};
@@ -1 +1 @@
1
- import{a as u}from"../../../chunk-S3HKXM3M.js";import{a as g}from"../../../chunk-5Z3OHUTR.js";import{a as l,b as p}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as i,b as d}from"../../../chunk-S6KFKBMY.js";import{b as a}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as s,j as m}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{deletePolicy as S}from"@tigrisdata/iam";var e=m("iam policies","delete");async function A(t){f(e);let y=d(t),o=i(t,["resource"]),w=i(t,["yes","y","force"]),n=await g(e);if(!o){let r=await u(n,e,"Select a policy to delete:");if(!r)return;o=r}if(!w&&(l("Use --yes to skip confirmation"),!await p(`Delete policy '${o}'?`))){console.log("Aborted");return}let{error:c}=await S(o,{config:n});c&&a(e,c),y==="json"&&console.log(JSON.stringify({action:"deleted",arn:o})),s(e,{resource:o})}export{A as default};
1
+ import{a as u}from"../../../chunk-Z265ZXTU.js";import{a as g}from"../../../chunk-UIPN4DNR.js";import{a as l,b as p}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as i,b as d}from"../../../chunk-S6KFKBMY.js";import{b as a}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as s,j as m}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{deletePolicy as S}from"@tigrisdata/iam";var e=m("iam policies","delete");async function A(t){f(e);let y=d(t),o=i(t,["resource"]),w=i(t,["yes","y","force"]),n=await g(e);if(!o){let r=await u(n,e,"Select a policy to delete:");if(!r)return;o=r}if(!w&&(l("Use --yes to skip confirmation"),!await p(`Delete policy '${o}'?`))){console.log("Aborted");return}let{error:c}=await S(o,{config:n});c&&a(e,c),y==="json"&&console.log(JSON.stringify({action:"deleted",arn:o})),s(e,{resource:o})}export{A as default};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-TUDALPGD.js";import{a as J}from"../../../chunk-S3HKXM3M.js";import{a as h}from"../../../chunk-5Z3OHUTR.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
1
+ import{a}from"../../../chunk-TUDALPGD.js";import{a as J}from"../../../chunk-Z265ZXTU.js";import{a as h}from"../../../chunk-UIPN4DNR.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as s,b as w,e as P}from"../../../chunk-S6KFKBMY.js";import{b as e}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as y,j as S}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{existsSync as x,readFileSync as A}from"fs";import{editPolicy as D,getPolicy as N}from"@tigrisdata/iam";var t=S("iam policies","edit");async function T(o){g(t);let O=w(o),r=s(o,["resource"]),n=s(o,["document","d"]),d=s(o,["description"]),m=await h(t);if(!r){process.stdin.isTTY||e(t,"Policy ARN is required when piping document via stdin.");let i=await J(m,t,"Select a policy to edit:");if(!i)return;r=i}let c;if(n){let i;x(n)?i=A(n,"utf-8"):i=n;try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}else if(!process.stdin.isTTY&&!d){let i=await P();try{c=a(i)}catch{e(t,"Invalid JSON in policy document")}}!c&&!d&&e(t,"Either --document or --description is required.");let{data:u,error:f}=await N(r,{config:m});f&&e(t,f);let{data:l,error:p}=await D(r,{document:c??u.document,description:d??u.description,config:m});p&&e(t,p),O==="json"&&console.log(JSON.stringify({action:"updated",arn:l.resource})),y(t,{resource:l.resource})}export{T as default};
@@ -1 +1 @@
1
- import{a as y}from"../../../chunk-S3HKXM3M.js";import{a as g}from"../../../chunk-5Z3OHUTR.js";import{f as p}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as m,b as d}from"../../../chunk-S6KFKBMY.js";import{b as u}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{getPolicy as A}from"@tigrisdata/iam";var t=f("iam policies","get");async function S(n){a(t);let r=m(n,["resource"]),s=d(n),l=await g(t);if(!r){let o=await y(l,t);if(!o)return;r=o}let{data:e,error:c}=await A(r,{config:l});if(c&&u(t,c),s==="json"){console.log(JSON.stringify(e,null,2)),i(t);return}let v=[{field:"Name",value:e.name},{field:"ID",value:e.id},{field:"Resource",value:e.resource},{field:"Description",value:e.description||"-"},{field:"Path",value:e.path},{field:"Version",value:e.defaultVersionId},{field:"Attachments",value:String(e.attachmentCount)},{field:"Created",value:e.createDate.toISOString()},{field:"Updated",value:e.updateDate.toISOString()}],h=p(v,s,"policy","field",[{key:"field",header:"Field"},{key:"value",header:"Value"}]);if(console.log(h),e.users&&e.users.length>0){console.log("Attached Users:");for(let o of e.users)console.log(` - ${o.name} (${o.id})`);console.log()}console.log("Policy Document:"),console.log(` Version: ${e.document.version}`),console.log(" Statements:");for(let o of e.document.statements)console.log(` - Effect: ${o.effect}`),console.log(` Action: ${Array.isArray(o.action)?o.action.join(", "):o.action}`),console.log(` Resource: ${Array.isArray(o.resource)?o.resource.join(", "):o.resource}`);i(t)}export{S as default};
1
+ import{a as y}from"../../../chunk-Z265ZXTU.js";import{a as g}from"../../../chunk-UIPN4DNR.js";import{f as p}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as m,b as d}from"../../../chunk-S6KFKBMY.js";import{b as u}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{getPolicy as A}from"@tigrisdata/iam";var t=f("iam policies","get");async function S(n){a(t);let r=m(n,["resource"]),s=d(n),l=await g(t);if(!r){let o=await y(l,t);if(!o)return;r=o}let{data:e,error:c}=await A(r,{config:l});if(c&&u(t,c),s==="json"){console.log(JSON.stringify(e,null,2)),i(t);return}let v=[{field:"Name",value:e.name},{field:"ID",value:e.id},{field:"Resource",value:e.resource},{field:"Description",value:e.description||"-"},{field:"Path",value:e.path},{field:"Version",value:e.defaultVersionId},{field:"Attachments",value:String(e.attachmentCount)},{field:"Created",value:e.createDate.toISOString()},{field:"Updated",value:e.updateDate.toISOString()}],h=p(v,s,"policy","field",[{key:"field",header:"Field"},{key:"value",header:"Value"}]);if(console.log(h),e.users&&e.users.length>0){console.log("Attached Users:");for(let o of e.users)console.log(` - ${o.name} (${o.id})`);console.log()}console.log("Policy Document:"),console.log(` Version: ${e.document.version}`),console.log(" Statements:");for(let o of e.document.statements)console.log(` - Effect: ${o.effect}`),console.log(` Action: ${Array.isArray(o.action)?o.action.join(", "):o.action}`),console.log(` Resource: ${Array.isArray(o.resource)?o.resource.join(", "):o.resource}`);i(t)}export{S as default};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-S3HKXM3M.js";import{a as k}from"../../../chunk-5Z3OHUTR.js";import{a as g}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as l,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as y,j as p}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{attachPolicyToAccessKey as P,getPolicy as v,listAccessKeys as O}from"@tigrisdata/iam";var{prompt:K}=I,e=p("iam policies","link-key");async function R(a){d(e);let w=u(a),r=l(a,["resource"]),s=l(a,["id"]),c=await k(e);if(!r){let i=await h(c,e);if(!i)return;r=i}if(!s){g("Use --id to specify the access key ID");let[i,n]=await Promise.all([O({config:c}),v(r,{config:c})]);i.error&&o(e,i.error),n.error&&o(e,n.error);let A=new Set((n.data.users??[]).map(t=>t.id)),f=i.data.accessKeys.filter(t=>!A.has(t.id));f.length===0&&o(e,"No unlinked access keys available. All access keys are already linked to this policy.");let{selected:S}=await K({type:"select",name:"selected",message:"Select an access key to link:",choices:f.map(t=>({name:t.id,message:`${t.name} (${t.id})`}))});s=S}let{error:m}=await P(s,r,{config:c});m&&o(e,m),w==="json"&&console.log(JSON.stringify({action:"linked",policyArn:r,id:s})),y(e)}export{R as default};
1
+ import{a as h}from"../../../chunk-Z265ZXTU.js";import{a as k}from"../../../chunk-UIPN4DNR.js";import{a as g}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as l,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as y,j as p}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{attachPolicyToAccessKey as P,getPolicy as v,listAccessKeys as O}from"@tigrisdata/iam";var{prompt:K}=I,e=p("iam policies","link-key");async function R(a){d(e);let w=u(a),r=l(a,["resource"]),s=l(a,["id"]),c=await k(e);if(!r){let i=await h(c,e);if(!i)return;r=i}if(!s){g("Use --id to specify the access key ID");let[i,n]=await Promise.all([O({config:c}),v(r,{config:c})]);i.error&&o(e,i.error),n.error&&o(e,n.error);let A=new Set((n.data.users??[]).map(t=>t.id)),f=i.data.accessKeys.filter(t=>!A.has(t.id));f.length===0&&o(e,"No unlinked access keys available. All access keys are already linked to this policy.");let{selected:S}=await K({type:"select",name:"selected",message:"Select an access key to link:",choices:f.map(t=>({name:t.id,message:`${t.name} (${t.id})`}))});s=S}let{error:m}=await P(s,r,{config:c});m&&o(e,m),w==="json"&&console.log(JSON.stringify({action:"linked",policyArn:r,id:s})),y(e)}export{R as default};
@@ -1 +1 @@
1
- import{a as k}from"../../../chunk-S3HKXM3M.js";import{a as y}from"../../../chunk-5Z3OHUTR.js";import{f as d}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as p,b as g}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as a,e as f,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{getPolicy as O}from"@tigrisdata/iam";var t=u("iam policies","list-keys");async function x(i){c(t);let h=g(i),e=p(i,["resource"]),n=await y(t);if(!e){let o=await k(n,t);if(!o)return;e=o}let{data:r,error:s}=await O(e,{config:n});if(s&&l(t,s),!r.users||r.users.length===0){f(t);return}let m=r.users.map(o=>({name:o.name,id:o.id})),w=d(m,h,"keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"}]);console.log(w),a(t,{count:m.length})}export{x as default};
1
+ import{a as k}from"../../../chunk-Z265ZXTU.js";import{a as y}from"../../../chunk-UIPN4DNR.js";import{f as d}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as p,b as g}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as a,e as f,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{getPolicy as O}from"@tigrisdata/iam";var t=u("iam policies","list-keys");async function x(i){c(t);let h=g(i),e=p(i,["resource"]),n=await y(t);if(!e){let o=await k(n,t);if(!o)return;e=o}let{data:r,error:s}=await O(e,{config:n});if(s&&l(t,s),!r.users||r.users.length===0){f(t);return}let m=r.users.map(o=>({name:o.name,id:o.id})),w=d(m,h,"keys","key",[{key:"name",header:"Name"},{key:"id",header:"ID"}]);console.log(w),a(t,{count:m.length})}export{x as default};
@@ -1 +1 @@
1
- import{a as x}from"../../../chunk-5Z3OHUTR.js";import{g as y}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-5UQUUFCL.js";import{b as l,c as T}from"../../../chunk-S6KFKBMY.js";import{b as k}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as u,e as g,i as f,j as h}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listPolicies as E}from"@tigrisdata/iam";var t=h("iam policies","list");async function I(a){p(t);let i=l(a),{limit:r,pageToken:s}=T(a),o=await x(t),{data:n,error:c}=await E({...r!==void 0?{limit:r}:{},...s?{paginationToken:s}:{},config:{sessionToken:o.sessionToken,organizationId:o.organizationId,iamEndpoint:o.iamEndpoint}});if(c&&k(t,c),!n.policies||n.policies.length===0){g(t);return}let d=n.policies.map(e=>({name:e.name,id:e.id,resource:e.resource,description:e.description||"-",attachments:e.attachmentCount,created:e.createDate,updated:e.updateDate})),C=[{key:"id",header:"ID"},{key:"resource",header:"Resource"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"attachments",header:"Attachments"},{key:"created",header:"Created"},{key:"updated",header:"Updated"}],m=n.paginationToken||void 0,D=y(d,i,"policies","policy",C,{paginationToken:m});console.log(D),i!=="json"&&i!=="xml"&&f(m),u(t,{count:d.length})}export{I as default};
1
+ import{a as x}from"../../../chunk-UIPN4DNR.js";import{g as y}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-A3YRE353.js";import{b as l,c as T}from"../../../chunk-S6KFKBMY.js";import{b as k}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as p,c as u,e as g,i as f,j as h}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listPolicies as E}from"@tigrisdata/iam";var t=h("iam policies","list");async function I(a){p(t);let i=l(a),{limit:r,pageToken:s}=T(a),o=await x(t),{data:n,error:c}=await E({...r!==void 0?{limit:r}:{},...s?{paginationToken:s}:{},config:{sessionToken:o.sessionToken,organizationId:o.organizationId,iamEndpoint:o.iamEndpoint}});if(c&&k(t,c),!n.policies||n.policies.length===0){g(t);return}let d=n.policies.map(e=>({name:e.name,id:e.id,resource:e.resource,description:e.description||"-",attachments:e.attachmentCount,created:e.createDate,updated:e.updateDate})),C=[{key:"id",header:"ID"},{key:"resource",header:"Resource"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"attachments",header:"Attachments"},{key:"created",header:"Created"},{key:"updated",header:"Updated"}],m=n.paginationToken||void 0,D=y(d,i,"policies","policy",C,{paginationToken:m});console.log(D),i!=="json"&&i!=="xml"&&f(m),u(t,{count:d.length})}export{I as default};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-S3HKXM3M.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";export{a as selectPolicy};
1
+ import{a}from"../../../chunk-Z265ZXTU.js";import"../../../chunk-S77OAN6Y.js";import"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";export{a as selectPolicy};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-S3HKXM3M.js";import{a as k}from"../../../chunk-5Z3OHUTR.js";import{a as f,b as d}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as c}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as y,c as p,j as g}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import $ from"enquirer";import{detachPolicyFromAccessKey as O,getPolicy as P}from"@tigrisdata/iam";var{prompt:I}=$,o=g("iam policies","unlink-key");async function U(r){y(o);let w=u(r),i=n(r,["resource"]),t=n(r,["id"]),A=n(r,["yes","y","force"]),s=await k(o);if(!i){let e=await h(s,o);if(!e)return;i=e}if(!t){f("Use --id to specify the access key ID");let{data:e,error:l}=await P(i,{config:s});l&&c(o,l),(!e.users||e.users.length===0)&&c(o,"No access keys are linked to this policy.");let{selected:S}=await I({type:"select",name:"selected",message:"Select an access key to unlink:",choices:e.users.map(a=>({name:a.id,message:`${a.name} (${a.id})`}))});t=S}if(!A&&(f("Use --yes to skip confirmation"),!await d(`Unlink access key '${t}' from policy '${i}'?`))){console.log("Aborted");return}let{error:m}=await O(t,i,{config:s});m&&c(o,m),w==="json"&&console.log(JSON.stringify({action:"unlinked",policyArn:i,id:t})),p(o)}export{U as default};
1
+ import{a as h}from"../../../chunk-Z265ZXTU.js";import{a as k}from"../../../chunk-UIPN4DNR.js";import{a as f,b as d}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as c}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as y,c as p,j as g}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import $ from"enquirer";import{detachPolicyFromAccessKey as O,getPolicy as P}from"@tigrisdata/iam";var{prompt:I}=$,o=g("iam policies","unlink-key");async function U(r){y(o);let w=u(r),i=n(r,["resource"]),t=n(r,["id"]),A=n(r,["yes","y","force"]),s=await k(o);if(!i){let e=await h(s,o);if(!e)return;i=e}if(!t){f("Use --id to specify the access key ID");let{data:e,error:l}=await P(i,{config:s});l&&c(o,l),(!e.users||e.users.length===0)&&c(o,"No access keys are linked to this policy.");let{selected:S}=await I({type:"select",name:"selected",message:"Select an access key to unlink:",choices:e.users.map(a=>({name:a.id,message:`${a.name} (${a.id})`}))});t=S}if(!A&&(f("Use --yes to skip confirmation"),!await d(`Unlink access key '${t}' from policy '${i}'?`))){console.log("Aborted");return}let{error:m}=await O(t,i,{config:s});m&&c(o,m),w==="json"&&console.log(JSON.stringify({action:"unlinked",policyArn:i,id:t})),p(o)}export{U as default};
@@ -1 +1 @@
1
- import{a as b}from"../../../chunk-XWIL5QBS.js";import{a as l}from"../../../chunk-5Z3OHUTR.js";import"../../../chunk-5UQUUFCL.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as g,j as d}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as p}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{createTeam as y}from"@tigrisdata/iam";var t=d("iam teams","create");async function O(e){f(t);let I=u(e);if(p("Team management"))return;let r=n(e,["name"]),i=n(e,["description","d"]),a=typeof i=="string"?i:void 0,m=b(t,n(e,["members","m"]));r||o(t,"Team name is required");let w=await l(t),{data:s,error:c}=await y({name:r,...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:w});if(c&&o(t,c),I==="json"){console.log(JSON.stringify({action:"created",teamId:s.teamId,name:r}));return}g(t,{name:r}),console.log(`Team ID: ${s.teamId}`)}export{O as default};
1
+ import{a as b}from"../../../chunk-DF3BGBKJ.js";import{a as l}from"../../../chunk-UIPN4DNR.js";import"../../../chunk-A3YRE353.js";import{a as n,b as u}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as f,c as g,j as d}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as p}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{createTeam as y}from"@tigrisdata/iam";var t=d("iam teams","create");async function O(e){f(t);let I=u(e);if(p("Team management"))return;let r=n(e,["name"]),i=n(e,["description","d"]),a=typeof i=="string"?i:void 0,m=b(t,n(e,["members","m"]));r||o(t,"Team name is required");let w=await l(t),{data:s,error:c}=await y({name:r,...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:w});if(c&&o(t,c),I==="json"){console.log(JSON.stringify({action:"created",teamId:s.teamId,name:r}));return}g(t,{name:r}),console.log(`Team ID: ${s.teamId}`)}export{O as default};
@@ -1 +1 @@
1
- import{a as w}from"../../../chunk-XWIL5QBS.js";import{a as b}from"../../../chunk-5Z3OHUTR.js";import"../../../chunk-5UQUUFCL.js";import{a as t,b as l}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as g,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as p}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{editTeam as I}from"@tigrisdata/iam";var e=u("iam teams","edit");async function R(n){c(e);let y=l(n);if(p("Team management"))return;let i=t(n,["id"]);i||o(e,"Team ID is required");let s=t(n,["name","n"]),r=typeof s=="string"?s:void 0,d=t(n,["description","d"]),a=typeof d=="string"?d:void 0,m=w(e,t(n,["members","m"]));r===void 0&&a===void 0&&m===void 0&&o(e,"Provide at least one of --name, --description, or --members to update");let O=await b(e),{error:f}=await I(i,{...r!==void 0?{name:r}:{},...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:O});f&&o(e,f),y==="json"&&console.log(JSON.stringify({action:"updated",teamId:i})),g(e,{id:i})}export{R as default};
1
+ import{a as w}from"../../../chunk-DF3BGBKJ.js";import{a as b}from"../../../chunk-UIPN4DNR.js";import"../../../chunk-A3YRE353.js";import{a as t,b as l}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as c,c as g,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as p}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{editTeam as I}from"@tigrisdata/iam";var e=u("iam teams","edit");async function R(n){c(e);let y=l(n);if(p("Team management"))return;let i=t(n,["id"]);i||o(e,"Team ID is required");let s=t(n,["name","n"]),r=typeof s=="string"?s:void 0,d=t(n,["description","d"]),a=typeof d=="string"?d:void 0,m=w(e,t(n,["members","m"]));r===void 0&&a===void 0&&m===void 0&&o(e,"Provide at least one of --name, --description, or --members to update");let O=await b(e),{error:f}=await I(i,{...r!==void 0?{name:r}:{},...a!==void 0?{description:a}:{},...m?{members:m}:{}},{config:O});f&&o(e,f),y==="json"&&console.log(JSON.stringify({action:"updated",teamId:i})),g(e,{id:i})}export{R as default};
@@ -1 +1 @@
1
- import{a as p}from"../../../chunk-5Z3OHUTR.js";import{b as g,d as u,e as h}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-5UQUUFCL.js";import{b as d}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,e as s,j as c}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as f}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listTeams as k}from"@tigrisdata/iam";var t=c("iam teams","list");async function C(y){a(t);let r=d(y);if(f("Team management"))return;let b=await p(t),{data:o,error:m}=await k({config:b});if(m&&l(t,m),o.teams.length===0){s(t);return}let n=o.teams.map(e=>({id:e.id,name:e.name,description:e.description||"-",members:e.members.length,created:e.createdAt}));console.log(r==="json"?g({teams:o.teams}):r==="xml"?u(n,"teams","team"):h(n,[{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"members",header:"Members"},{key:"created",header:"Created"}])),i(t,{count:o.teams.length})}export{C as default};
1
+ import{a as p}from"../../../chunk-UIPN4DNR.js";import{b as g,d as u,e as h}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-A3YRE353.js";import{b as d}from"../../../chunk-S6KFKBMY.js";import{b as l}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as a,c as i,e as s,j as c}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as f}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listTeams as k}from"@tigrisdata/iam";var t=c("iam teams","list");async function C(y){a(t);let r=d(y);if(f("Team management"))return;let b=await p(t),{data:o,error:m}=await k({config:b});if(m&&l(t,m),o.teams.length===0){s(t);return}let n=o.teams.map(e=>({id:e.id,name:e.name,description:e.description||"-",members:e.members.length,created:e.createdAt}));console.log(r==="json"?g({teams:o.teams}):r==="xml"?u(n,"teams","team"):h(n,[{key:"id",header:"ID"},{key:"name",header:"Name"},{key:"description",header:"Description"},{key:"members",header:"Members"},{key:"created",header:"Created"}])),i(t,{count:o.teams.length})}export{C as default};
@@ -1 +1 @@
1
- import{a}from"../../../chunk-XWIL5QBS.js";import"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";export{a as parseMembers};
1
+ import{a}from"../../../chunk-DF3BGBKJ.js";import"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";export{a as parseMembers};
@@ -1 +1 @@
1
- import{a as u}from"../../../chunk-5Z3OHUTR.js";import"../../../chunk-5UQUUFCL.js";import{a as s,b as p}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as g}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{inviteUser as b}from"@tigrisdata/iam";var i=f("iam users","invite");async function j(e){l(i);let d=p(e);if(g("User management"))return;let o=s(e,["email"]),r=s(e,["role","r"])??"member",t=Array.isArray(o)?o:o?[o]:[];t.length===0&&n(i,"Email address is required");let a=["admin","member"];a.includes(r)||n(i,`Invalid role "${r}". Must be one of: ${a.join(", ")}`);let v=r,y=await u(i),R=t.map(O=>({email:O,role:v})),{error:m}=await b(R,{config:y});m&&n(i,m),d==="json"&&console.log(JSON.stringify({action:"invited",email:t.join(", ")})),c(i,{email:t.join(", ")})}export{j as default};
1
+ import{a as u}from"../../../chunk-UIPN4DNR.js";import"../../../chunk-A3YRE353.js";import{a as s,b as p}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c,j as f}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as g}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{inviteUser as b}from"@tigrisdata/iam";var i=f("iam users","invite");async function j(e){l(i);let d=p(e);if(g("User management"))return;let o=s(e,["email"]),r=s(e,["role","r"])??"member",t=Array.isArray(o)?o:o?[o]:[];t.length===0&&n(i,"Email address is required");let a=["admin","member"];a.includes(r)||n(i,`Invalid role "${r}". Must be one of: ${a.join(", ")}`);let v=r,y=await u(i),R=t.map(O=>({email:O,role:v})),{error:m}=await b(R,{config:y});m&&n(i,m),d==="json"&&console.log(JSON.stringify({action:"invited",email:t.join(", ")})),c(i,{email:t.join(", ")})}export{j as default};
@@ -1,4 +1,4 @@
1
- import{a as p}from"../../../chunk-5Z3OHUTR.js";import{b as y,d as i,e as a}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-5UQUUFCL.js";import{b as h}from"../../../chunk-S6KFKBMY.js";import{b as d}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as g,e as c,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as f}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listUsers as v}from"@tigrisdata/iam";var n=u("iam users","list");async function w(k){m(n);let r=h(k);if(f("User management"))return;let C=await p(n),{data:l,error:s}=await v({config:C});s&&d(n,s);let o=l.users.map(e=>({email:e.email,name:e.userName||"-",role:e.isOrgOwner?"owner":e.role,userId:e.userId})),t=l.invitations.map(e=>({id:e.id,email:e.email,role:e.role,status:e.status,validUntil:e.validUntil.toLocaleDateString()}));if(o.length===0&&t.length===0){c(n);return}let I=[{key:"email",header:"Email"},{key:"name",header:"Name"},{key:"role",header:"Role"},{key:"userId",header:"User ID"}],U=[{key:"id",header:"ID"},{key:"email",header:"Email"},{key:"role",header:"Role"},{key:"status",header:"Status"},{key:"validUntil",header:"Valid Until"}];if(r==="json")console.log(y({users:o,invitations:t}));else if(r==="xml"){let e=["<organization>"];e.push(` ${i(o,"users","user").replace(/\n/g,`
1
+ import{a as p}from"../../../chunk-UIPN4DNR.js";import{b as y,d as i,e as a}from"../../../chunk-AFM3TY2D.js";import"../../../chunk-A3YRE353.js";import{b as h}from"../../../chunk-S6KFKBMY.js";import{b as d}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as m,c as g,e as c,j as u}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as f}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import{listUsers as v}from"@tigrisdata/iam";var n=u("iam users","list");async function w(k){m(n);let r=h(k);if(f("User management"))return;let C=await p(n),{data:l,error:s}=await v({config:C});s&&d(n,s);let o=l.users.map(e=>({email:e.email,name:e.userName||"-",role:e.isOrgOwner?"owner":e.role,userId:e.userId})),t=l.invitations.map(e=>({id:e.id,email:e.email,role:e.role,status:e.status,validUntil:e.validUntil.toLocaleDateString()}));if(o.length===0&&t.length===0){c(n);return}let I=[{key:"email",header:"Email"},{key:"name",header:"Name"},{key:"role",header:"Role"},{key:"userId",header:"User ID"}],U=[{key:"id",header:"ID"},{key:"email",header:"Email"},{key:"role",header:"Role"},{key:"status",header:"Status"},{key:"validUntil",header:"Valid Until"}];if(r==="json")console.log(y({users:o,invitations:t}));else if(r==="xml"){let e=["<organization>"];e.push(` ${i(o,"users","user").replace(/\n/g,`
2
2
  `)}`),e.push(" "+i(t,"invitations","invitation").replace(/\n/g,`
3
3
  `)),e.push("</organization>"),console.log(e.join(`
4
4
  `))}else o.length>0&&(console.log(`
@@ -1 +1 @@
1
- import{a as O}from"../../../chunk-5Z3OHUTR.js";import{a,b as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as m,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c as u,e as p,j as d}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as y}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{listUsers as E,removeUser as F}from"@tigrisdata/iam";var{prompt:S}=I,e=d("iam users","remove");async function $(s){l(e);let h=w(s),t=m(s,["resource"]),U=m(s,["yes","y","force"]);if(y("User management"))return;let c=await O(e),r=Array.isArray(t)?t:t?[t]:[];if(r.length===0){let{data:i,error:g}=await E({config:c});if(g&&n(e,g),i.users.length===0){p(e);return}a("Provide user ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select user(s) to remove (space to select, enter to confirm):",choices:i.users.map(o=>({name:o.userId,message:`${o.email} (${o.isOrgOwner?"owner":o.role})`}))});r=A}if(!U&&(a("Use --yes to skip confirmation"),!await v(`Remove ${r.length} user(s)?`))){console.log("Aborted");return}let{error:f}=await F(r,{config:c});f&&n(e,f),h==="json"&&console.log(JSON.stringify({action:"removed",users:r})),u(e)}export{$ as default};
1
+ import{a as O}from"../../../chunk-UIPN4DNR.js";import{a,b as v}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as m,b as w}from"../../../chunk-S6KFKBMY.js";import{b as n}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as l,c as u,e as p,j as d}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as y}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{listUsers as E,removeUser as F}from"@tigrisdata/iam";var{prompt:S}=I,e=d("iam users","remove");async function $(s){l(e);let h=w(s),t=m(s,["resource"]),U=m(s,["yes","y","force"]);if(y("User management"))return;let c=await O(e),r=Array.isArray(t)?t:t?[t]:[];if(r.length===0){let{data:i,error:g}=await E({config:c});if(g&&n(e,g),i.users.length===0){p(e);return}a("Provide user ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select user(s) to remove (space to select, enter to confirm):",choices:i.users.map(o=>({name:o.userId,message:`${o.email} (${o.isOrgOwner?"owner":o.role})`}))});r=A}if(!U&&(a("Use --yes to skip confirmation"),!await v(`Remove ${r.length} user(s)?`))){console.log("Aborted");return}let{error:f}=await F(r,{config:c});f&&n(e,f),h==="json"&&console.log(JSON.stringify({action:"removed",users:r})),u(e)}export{$ as default};
@@ -1 +1 @@
1
- import{a as h}from"../../../chunk-5Z3OHUTR.js";import{a,b as y}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as c,b as k}from"../../../chunk-S6KFKBMY.js";import{b as s}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as p,e as u,j as v}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as d}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import O from"enquirer";import{listUsers as $,revokeInvitation as E}from"@tigrisdata/iam";var{prompt:S}=O,t=v("iam users","revoke-invitation");async function U(r){g(t);let w=k(r),o=c(r,["resource"]),I=c(r,["yes","y","force"]);if(d("User management"))return;let m=await h(t),e=Array.isArray(o)?o:o?[o]:[];if(e.length===0){let{data:n,error:l}=await $({config:m});if(l&&s(t,l),n.invitations.length===0){u(t);return}a("Provide invitation ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select invitation(s) to revoke (space to select, enter to confirm):",choices:n.invitations.map(i=>({name:i.id,message:`${i.email} (${i.role} - ${i.status})`}))});e=A}if(!I&&(a("Use --yes to skip confirmation"),!await y(`Revoke ${e.length} invitation(s)?`))){console.log("Aborted");return}let{error:f}=await E(e,{config:m});f&&s(t,f),w==="json"&&console.log(JSON.stringify({action:"revoked",invitations:e})),p(t)}export{U as default};
1
+ import{a as h}from"../../../chunk-UIPN4DNR.js";import{a,b as y}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as c,b as k}from"../../../chunk-S6KFKBMY.js";import{b as s}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as g,c as p,e as u,j as v}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as d}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import O from"enquirer";import{listUsers as $,revokeInvitation as E}from"@tigrisdata/iam";var{prompt:S}=O,t=v("iam users","revoke-invitation");async function U(r){g(t);let w=k(r),o=c(r,["resource"]),I=c(r,["yes","y","force"]);if(d("User management"))return;let m=await h(t),e=Array.isArray(o)?o:o?[o]:[];if(e.length===0){let{data:n,error:l}=await $({config:m});if(l&&s(t,l),n.invitations.length===0){u(t);return}a("Provide invitation ID(s) as a positional argument");let{selected:A}=await S({type:"multiselect",name:"selected",message:"Select invitation(s) to revoke (space to select, enter to confirm):",choices:n.invitations.map(i=>({name:i.id,message:`${i.email} (${i.role} - ${i.status})`}))});e=A}if(!I&&(a("Use --yes to skip confirmation"),!await y(`Revoke ${e.length} invitation(s)?`))){console.log("Aborted");return}let{error:f}=await E(e,{config:m});f&&s(t,f),w==="json"&&console.log(JSON.stringify({action:"revoked",invitations:e})),p(t)}export{U as default};
@@ -1 +1 @@
1
- import{a as v}from"../../../chunk-5Z3OHUTR.js";import{a as w}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-5UQUUFCL.js";import{a as c,b}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-B7CB3ST5.js";import"../../../chunk-2XSEQJGZ.js";import"../../../chunk-HWAEADX7.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as h,e as y,j as R}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as O}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{listUsers as S,updateUserRole as q}from"@tigrisdata/iam";var{prompt:U}=I,e=R("iam users","update-role");async function E(m){d(e);let A=b(m);if(O("User management"))return;let f=["admin","member"],i=c(m,["role","r"]);i||o(e,"Role is required. Use --role admin or --role member");let r=Array.isArray(i)?i:[i];for(let t of r)f.includes(t)||o(e,`Invalid role "${t}". Must be one of: ${f.join(", ")}`);let n=c(m,["resource"]),s=Array.isArray(n)?n:n?[n]:[],u=await v(e);if(s.length===0){let{data:t,error:a}=await S({config:u});if(a&&o(e,a),t.users.length===0){y(e);return}w("Provide user ID(s) as a positional argument");let{selected:$}=await U({type:"multiselect",name:"selected",message:"Select user(s) to update (space to select, enter to confirm):",choices:t.users.map(l=>({name:l.userId,message:`${l.email} (${l.isOrgOwner?"owner":l.role})`}))});s=$}r.length>1&&r.length!==s.length&&o(e,`Number of roles (${r.length}) must match number of users (${s.length}), or provide a single role for all users`);let g=s.map((t,a)=>({userId:t,role:r.length===1?r[0]:r[a]})),{error:p}=await q(g,{config:u});p&&o(e,p),A==="json"&&console.log(JSON.stringify({action:"updated",users:g})),h(e)}export{E as default};
1
+ import{a as v}from"../../../chunk-UIPN4DNR.js";import{a as w}from"../../../chunk-S77OAN6Y.js";import"../../../chunk-A3YRE353.js";import{a as c,b}from"../../../chunk-S6KFKBMY.js";import{b as o}from"../../../chunk-U3422EZ6.js";import"../../../chunk-5JBNZ4C6.js";import"../../../chunk-3ILNJZ6D.js";import"../../../chunk-DV3LCXRH.js";import{b as d,c as h,e as y,j as R}from"../../../chunk-D7WXNA2O.js";import"../../../chunk-NI4EYBQH.js";import"../../../chunk-6ZZ54RU7.js";import"../../../chunk-J3MAV7JB.js";import{a as O}from"../../../chunk-KJBSIIND.js";import"../../../chunk-F4AGJWCK.js";import I from"enquirer";import{listUsers as S,updateUserRole as q}from"@tigrisdata/iam";var{prompt:U}=I,e=R("iam users","update-role");async function E(m){d(e);let A=b(m);if(O("User management"))return;let f=["admin","member"],i=c(m,["role","r"]);i||o(e,"Role is required. Use --role admin or --role member");let r=Array.isArray(i)?i:[i];for(let t of r)f.includes(t)||o(e,`Invalid role "${t}". Must be one of: ${f.join(", ")}`);let n=c(m,["resource"]),s=Array.isArray(n)?n:n?[n]:[],u=await v(e);if(s.length===0){let{data:t,error:a}=await S({config:u});if(a&&o(e,a),t.users.length===0){y(e);return}w("Provide user ID(s) as a positional argument");let{selected:$}=await U({type:"multiselect",name:"selected",message:"Select user(s) to update (space to select, enter to confirm):",choices:t.users.map(l=>({name:l.userId,message:`${l.email} (${l.isOrgOwner?"owner":l.role})`}))});s=$}r.length>1&&r.length!==s.length&&o(e,`Number of roles (${r.length}) must match number of users (${s.length}), or provide a single role for all users`);let g=s.map((t,a)=>({userId:t,role:r.length===1?r[0]:r[a]})),{error:p}=await q(g,{config:u});p&&o(e,p),A==="json"&&console.log(JSON.stringify({action:"updated",users:g})),h(e)}export{E as default};