everyapp 0.3.0-rc.2 → 0.3.0-rc.4

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 (138) hide show
  1. package/README.md +1 -1
  2. package/dist/access-YWM4BSBD.js +1 -0
  3. package/dist/activity-RTCAUMQS.js +14 -0
  4. package/dist/ai-UOYQFTAX.js +5 -0
  5. package/dist/apps-PEOBCDNU.js +14 -0
  6. package/dist/chunk-26KS6TD6.js +1 -0
  7. package/dist/chunk-3EADVHFN.js +15 -0
  8. package/dist/chunk-4LKLQOM7.js +7 -0
  9. package/dist/{chunk-PNLU5U3P.js → chunk-5IC3ZN52.js} +1 -1
  10. package/dist/{chunk-H7PDL3X5.js → chunk-AMCNAKYU.js} +1 -1
  11. package/dist/{chunk-23HJ5I2A.js → chunk-ASCNE7GS.js} +1 -1
  12. package/dist/{chunk-6OGVO7QK.js → chunk-BCTEWNN4.js} +1 -1
  13. package/dist/{chunk-W3JCQHHU.js → chunk-BK4NK34C.js} +1 -1
  14. package/dist/chunk-BWNZ6F4F.js +2 -0
  15. package/dist/chunk-DCFHBCCW.js +9 -0
  16. package/dist/{chunk-2Y5Q6A5K.js → chunk-DWTJ4OLZ.js} +1 -1
  17. package/dist/chunk-EP3IQ354.js +20 -0
  18. package/dist/{chunk-OP4DYXYI.js → chunk-EP4HRYXP.js} +1 -1
  19. package/dist/{chunk-HOUHG236.js → chunk-EQLY5I46.js} +1 -1
  20. package/dist/{chunk-YHJZMJYZ.js → chunk-F5XK23HV.js} +1 -1
  21. package/dist/{chunk-5PTNYZK6.js → chunk-FB2OC32C.js} +3 -3
  22. package/dist/chunk-FQ2A7YAP.js +57 -0
  23. package/dist/{chunk-OM2HDWVP.js → chunk-GAPQSINH.js} +1 -1
  24. package/dist/chunk-GJK6GAWO.js +1 -0
  25. package/dist/chunk-H4EZTXIK.js +1 -0
  26. package/dist/chunk-HJGZGZFE.js +32 -0
  27. package/dist/{chunk-CCWBPAKH.js → chunk-I7FNTTUY.js} +3 -3
  28. package/dist/chunk-KOBKGQ27.js +91 -0
  29. package/dist/{chunk-PS7S74DG.js → chunk-KQM6ZUX5.js} +1 -1
  30. package/dist/chunk-KVCL64LI.js +1 -0
  31. package/dist/{chunk-4JRIS6S6.js → chunk-LEEUODYR.js} +1 -1
  32. package/dist/{chunk-6PGUCTJ6.js → chunk-LI3YLKLC.js} +1 -1
  33. package/dist/chunk-MEIWV7FJ.js +20 -0
  34. package/dist/{configure-F7UZCJUG.js → chunk-MLTNW3AM.js} +2 -2
  35. package/dist/chunk-NDOEON54.js +4 -0
  36. package/dist/chunk-NW7SJPSP.js +37 -0
  37. package/dist/chunk-O64FPLGX.js +1 -0
  38. package/dist/chunk-ORGV2NNT.js +8 -0
  39. package/dist/chunk-PDPUGYJW.js +47 -0
  40. package/dist/chunk-QFTBDXLF.js +146 -0
  41. package/dist/{chunk-E3EPK27P.js → chunk-QJRZFIYC.js} +2 -2
  42. package/dist/chunk-QKHLRLK3.js +15 -0
  43. package/dist/{chunk-CZXHKPRZ.js → chunk-R2DF3ENZ.js} +1 -1
  44. package/dist/{chunk-IUOBIB5M.js → chunk-R7JOHK7Y.js} +2 -2
  45. package/dist/chunk-RL72BUT4.js +1 -0
  46. package/dist/chunk-RQBSTNL7.js +1 -0
  47. package/dist/{chunk-H6QQMY7B.js → chunk-S2G4G73L.js} +1 -1
  48. package/dist/{chunk-LXYMDZER.js → chunk-SGRGD7L4.js} +1 -1
  49. package/dist/{chunk-T2GD7RHS.js → chunk-TIYSZWP5.js} +1 -1
  50. package/dist/chunk-TUXKBLLJ.js +10 -0
  51. package/dist/chunk-U4ATZJEU.js +6 -0
  52. package/dist/chunk-V7BWZOSZ.js +26 -0
  53. package/dist/{chunk-J35DDCNU.js → chunk-VVKQJSF3.js} +1 -1
  54. package/dist/chunk-WVHJIYQ3.js +14 -0
  55. package/dist/{chunk-ZEXVHB22.js → chunk-XBD7PQN5.js} +1 -1
  56. package/dist/{chunk-N5GQLGEC.js → chunk-YAZHTVUV.js} +1 -1
  57. package/dist/configure-CAWCTPYY.js +1 -0
  58. package/dist/{create-2E5HVWYK.js → create-3ZWJQXPK.js} +2 -2
  59. package/dist/{db-HEQVTDTM.js → db-B7KO37SV.js} +1 -1
  60. package/dist/delete-CB3EPOU4.js +3 -0
  61. package/dist/deploy-5O7LV5OX.js +1 -0
  62. package/dist/dev-4JYCVVOZ.js +86 -0
  63. package/dist/{email-RLZFUFUN.js → email-SWJQXEUR.js} +1 -1
  64. package/dist/{events-2V5VRBWP.js → events-GJV2KVIU.js} +13 -13
  65. package/dist/{groups-HDG5DVFY.js → groups-NNTLSXMK.js} +1 -1
  66. package/dist/index.js +104 -95
  67. package/dist/install-UAG3CNYW.js +1 -0
  68. package/dist/{login-KHJBC64Z.js → login-QEKMLMUB.js} +1 -1
  69. package/dist/mcp-AFGVOM5D.js +1 -0
  70. package/dist/provider-622VM7UZ.js +29 -0
  71. package/dist/release-CXEX6O7F.js +1 -0
  72. package/dist/{restore-FFGYV7NO.js → restore-PGIVEA5P.js} +1 -1
  73. package/dist/secret-3LUDEDUW.js +1 -0
  74. package/dist/setup-PUD375AM.js +1 -0
  75. package/dist/{signin-AP3D4XM4.js → signin-EP5JLAT5.js} +2 -2
  76. package/dist/status-LK6DNLCI.js +5 -0
  77. package/dist/teardown-6RURRSME.js +22 -0
  78. package/dist/update-YJFTOZEV.js +1 -0
  79. package/dist/{workspace-CJC5I66L.js → workspace-VW7ZZRFP.js} +3 -3
  80. package/package.json +5 -5
  81. package/skills/build-every-app/SKILL.md +22 -13
  82. package/skills/build-every-app/patterns.md +16 -3
  83. package/skills/everyapp/SKILL.md +33 -18
  84. package/skills/everyapp/mcp.md +22 -8
  85. package/skills/everyapp/security-review.md +1 -1
  86. package/skills/everyapp/setup/README.md +18 -1
  87. package/skills/everyapp/setup/access.md +11 -7
  88. package/skills/everyapp/setup/ai-gateway.md +117 -0
  89. package/skills/everyapp/setup/ai.md +139 -0
  90. package/skills/everyapp/setup/context.md +2 -2
  91. package/skills/everyapp/setup/dataforseo.md +3 -3
  92. package/skills/everyapp/setup/email.md +1 -1
  93. package/skills/everyapp/setup/gateway.md +3 -3
  94. package/skills/everyapp/setup/google.md +8 -6
  95. package/skills/everyapp/setup/microsoft-365.md +4 -2
  96. package/skills/everyapp/setup/providers.md +27 -9
  97. package/skills/everyapp/setup/remote-mcp.md +1 -1
  98. package/skills/everyapp/setup/signin-apple.md +3 -3
  99. package/skills/everyapp/setup/signin-cloudflare.md +1 -1
  100. package/skills/everyapp/setup/signin-github.md +1 -1
  101. package/skills/everyapp/setup/signin-google.md +2 -2
  102. package/skills/everyapp/setup/signin-microsoft.md +1 -1
  103. package/skills/everyapp/setup/slack.md +2 -0
  104. package/dist/access-LGEN3ABJ.js +0 -1
  105. package/dist/activity-RSD4D66F.js +0 -12
  106. package/dist/apps-4RCFXT74.js +0 -13
  107. package/dist/chunk-AGTCKFRB.js +0 -22
  108. package/dist/chunk-BHMRY53V.js +0 -2
  109. package/dist/chunk-CB4U7H2G.js +0 -4
  110. package/dist/chunk-CZTEDWZ2.js +0 -22
  111. package/dist/chunk-EGEWRFVY.js +0 -1
  112. package/dist/chunk-ELK7QZ2M.js +0 -1
  113. package/dist/chunk-FJJSSVET.js +0 -33
  114. package/dist/chunk-GKBPYVP3.js +0 -25
  115. package/dist/chunk-IFCPALVC.js +0 -46
  116. package/dist/chunk-J455FAEN.js +0 -7
  117. package/dist/chunk-JYKRUS5C.js +0 -1
  118. package/dist/chunk-LYNBZ7RV.js +0 -57
  119. package/dist/chunk-M2QQ2UD7.js +0 -132
  120. package/dist/chunk-NFU4YFXB.js +0 -1
  121. package/dist/chunk-ONLNJXVQ.js +0 -32
  122. package/dist/chunk-RMF4YGD6.js +0 -98
  123. package/dist/chunk-TLRM3P7V.js +0 -15
  124. package/dist/chunk-WOVS3GV5.js +0 -10
  125. package/dist/chunk-ZECBN24L.js +0 -15
  126. package/dist/chunk-ZFCUH5PK.js +0 -7
  127. package/dist/delete-XCSIQIRS.js +0 -3
  128. package/dist/deploy-3QOZEZHC.js +0 -1
  129. package/dist/dev-JL3ZP5BT.js +0 -86
  130. package/dist/install-Z5FYXUYM.js +0 -1
  131. package/dist/mcp-EFDUKJ5V.js +0 -1
  132. package/dist/provider-EOI5PTFH.js +0 -13
  133. package/dist/release-74J5ZIL3.js +0 -1
  134. package/dist/secret-7FKKTLHB.js +0 -1
  135. package/dist/setup-PAKRCAFO.js +0 -1
  136. package/dist/status-RMWNHOEK.js +0 -4
  137. package/dist/teardown-E4JNKAZJ.js +0 -22
  138. package/dist/update-DWVZFNPS.js +0 -1
@@ -1,4 +1,4 @@
1
- import"./chunk-5PTNYZK6.js";import{a as ee,b as ne,d as te,g as O}from"./chunk-PS7S74DG.js";import"./chunk-YHJZMJYZ.js";import"./chunk-N5GQLGEC.js";import"./chunk-W3JCQHHU.js";import{b as Z}from"./chunk-ZECBN24L.js";import{g as q}from"./chunk-HOUHG236.js";import{ha as B,ia as W,ja as z,ka as J,qa as K,sa as Q}from"./chunk-RMF4YGD6.js";import"./chunk-NFU4YFXB.js";import"./chunk-T2GD7RHS.js";import{c as G}from"./chunk-H7PDL3X5.js";import{a as P}from"./chunk-CCWBPAKH.js";import"./chunk-JYKRUS5C.js";import{Bb as h,Ea as k,Fb as H,c as u,d as V,pc as X,rc as Y,wc as D}from"./chunk-LYNBZ7RV.js";import ce from"node:path";import{stripVTControlCharacters as me}from"node:util";import d from"chalk";var se="email.update";async function Me(e){await D(e,n=>pe({flags:e,out:n,senders:e.sender?.length?e.sender:void 0,inbound:e.inbound?.length?e.inbound:void 0,enableRouting:e["enable-email-routing"]}))}async function De(e,...n){await D(e,s=>ue({flags:e,out:s,lists:n}))}async function Oe(e){await D(e,n=>fe({flags:e,out:n}))}function ie(e,n){let s=[...new Set(k(e,n))];if(s.length===0)return;let a=e==="senders"?"--sender":"--inbound",t=e==="senders"?"EMAIL_SENDER_INVALID":"EMAIL_INBOUND_INVALID";if(s.length>1)throw new h(t,[`${s.length} problems with ${a}`,...s.map(l=>`\u2022 ${l}`)].join(`
1
+ import"./chunk-FB2OC32C.js";import{a as ee,b as ne,d as te,g as O}from"./chunk-KQM6ZUX5.js";import"./chunk-F5XK23HV.js";import"./chunk-YAZHTVUV.js";import"./chunk-BK4NK34C.js";import{b as Z}from"./chunk-3EADVHFN.js";import{g as q}from"./chunk-EQLY5I46.js";import{c as K,e as Q}from"./chunk-DCFHBCCW.js";import{ga as B,ha as W,ia as z,ja as J}from"./chunk-KOBKGQ27.js";import"./chunk-RL72BUT4.js";import"./chunk-TIYSZWP5.js";import{c as G}from"./chunk-AMCNAKYU.js";import{a as P}from"./chunk-I7FNTTUY.js";import"./chunk-RQBSTNL7.js";import{Ja as k,Rc as X,Tc as Y,Yc as D,bc as h,c as u,d as V,fc as H}from"./chunk-FQ2A7YAP.js";import ce from"node:path";import{stripVTControlCharacters as me}from"node:util";import d from"chalk";var se="email.update";async function Me(e){await D(e,n=>pe({flags:e,out:n,senders:e.sender?.length?e.sender:void 0,inbound:e.inbound?.length?e.inbound:void 0,enableRouting:e["enable-email-routing"]}))}async function De(e,...n){await D(e,s=>ue({flags:e,out:s,lists:n}))}async function Oe(e){await D(e,n=>fe({flags:e,out:n}))}function ie(e,n){let s=[...new Set(k(e,n))];if(s.length===0)return;let a=e==="senders"?"--sender":"--inbound",t=e==="senders"?"EMAIL_SENDER_INVALID":"EMAIL_INBOUND_INVALID";if(s.length>1)throw new h(t,[`${s.length} problems with ${a}`,...s.map(l=>`\u2022 ${l}`)].join(`
2
2
  `),{data:{problems:s}});let[p,c]=s[0].split(": "),A=k(e,n.map(l=>l.toLowerCase())).length===0;throw new h(t,c?`${p}
3
3
  ${c.charAt(0).toUpperCase()}${c.slice(1)}`:p,{...A?{rerun:V([],{argv:process.argv.slice(2).map(l=>n.includes(l)?l.toLowerCase():l)})}:{},data:{problems:s}})}async function pe(e){let{senders:n,inbound:s}=e;if(n===void 0&&s===void 0)throw new h("EMAIL_NOTHING_TO_SET","Name what to set: --sender, --inbound, or both",{rerun:`${u} email set --help`});n!==void 0&&ie("senders",n),s!==void 0&&ie("inbound",s);let a=await F(e),t=O(a),p={rerun:`${u} deploy`,rerunNote:"then this command again"};if(n!==void 0&&!t.sends)throw new h("EMAIL_NOT_DECLARED",`${a.id} can't send mail yet
4
4
  everyapp.config.ts doesn't list email in its capabilities.`,{fix:'add capabilities: { email: { access: "write" } } to everyapp.config.ts',...p});if(s!==void 0&&!t.receives)throw new h("EMAIL_INBOUND_NOT_DECLARED",`${a.id} can't receive mail yet
@@ -1,15 +1,15 @@
1
- import{a as g,b as re,c as S,d as O,e as E,f as l,g as L,h as b,j as de,k as me}from"./chunk-CB4U7H2G.js";import"./chunk-M2QQ2UD7.js";import{a as z}from"./chunk-4JRIS6S6.js";import{D as W,E as Y,F as H,G as K,H as Q,I as X,J as B,K as J,L as Z,M as ee,N as te,O as ie,S as ne,T as se,U as ae,x as j,y as q}from"./chunk-RMF4YGD6.js";import"./chunk-NFU4YFXB.js";import"./chunk-T2GD7RHS.js";import{a as V,g as U}from"./chunk-CCWBPAKH.js";import"./chunk-JYKRUS5C.js";import{Bb as y,Ja as I,Ma as P,Sa as G,c,f as $,lc as F,oc as oe,pc as D,qb as M,wc as u}from"./chunk-LYNBZ7RV.js";import{text as ge}from"node:stream/consumers";import he from"chalk";var R="events.add",Ee=/^[a-z][a-z0-9+.-]*:\/\//i;async function be(){return process.stdin.isTTY?null:ge(process.stdin)}async function Te(e){let i=e.flags["secret-from-env"];if(i){let n=(e.env??process.env)[i];if(!n)throw new y("SECRET_EMPTY",`$${i} is empty or not set`,{fix:`export ${i} first, or name another variable with --secret-from-env`});return n}let t=await(e.readStdin??be)();if(t!==null){let n=t.replace(/\r?\n$/,"");if(n)return n}let o=e.interactive??V(e.flags.json??!1);if(t!==null||!o)throw new y("SECRET_VALUE_REQUIRED",`Can't ask for the signing secret without a terminal
2
- Pipe it in, or name the environment variable holding it with --secret-from-env.`,{fix:"leave --secret out to have one made, or add --secret-from-env <VAR>"});return(e.prompt??(()=>U("Signing secret",{context:["16 to 128 printable characters. Receivers check X-EveryApp-Signature with it."]})))()}async function pe(e,i){let{flags:t,out:o}=e,n=t.secret===!0||t["secret-from-env"]!==void 0;if(n&&i!==void 0&&!Ee.test(i.trim()))throw new y("VALUE_ON_COMMAND_LINE",`--secret takes no value on the command line
3
- It lands in the shell's history and the process list: rotate it if it was real. Nothing was added.`,{fix:"give --secret alone: it asks at a hidden prompt, or reads the secret piped in or from --secret-from-env <VAR>"});if(i!==void 0&&t.email!==void 0)throw new y("EVENT_SINK_CONFLICT",`Give a webhook URL or --email, not both
4
- A subscription delivers one way: a signed POST to a URL, or mail to the organization's owners (and admins).`,{fix:"add one subscription for each"});if(t.email!==void 0&&n)throw new y("EVENT_SINK_CONFLICT",`An email subscription has no signing secret
5
- Only a webhook is signed; mail goes from the Gateway's own sender to the organization's members.`,{fix:"leave --secret out"});if(i===void 0&&t.email===void 0)throw new y("EVENT_SINK_CONFLICT","Name where events go: a webhook URL, or --email owners|admins",{rerun:`${c} events add https://hooks.example.com/everyapp`,rerunNote:"or --email admins"});let d=H(t.events),a=B(t.name),{gateway:s,organization:v}=await g(e),w=await z(s.cf,M),r,h=!1;if(i!==void 0){let T=K(i,{gatewayHost:s.install.gatewayHost,appBaseDomain:s.install.appBaseDomain,allowPrivate:w.includes(G)}),f=n?Q(await Te(e)):X();h=!n,r={sink:"webhook",url:T,secret:f}}else r={sink:"email",recipients:t.email},w.includes("EMAIL_FROM")||o.emit({type:"warning",code:"EVENT_EMAIL_NOT_CONFIGURED",step:R,message:`The Gateway has no sender (EMAIL_FROM), so these mails can't go out yet
1
+ import{a as g,b as re,c as S,d as O,e as E,f as l,g as L,h as b,j as de,k as me}from"./chunk-NDOEON54.js";import"./chunk-QFTBDXLF.js";import"./chunk-GAPQSINH.js";import{a as z}from"./chunk-LEEUODYR.js";import"./chunk-DCFHBCCW.js";import{C as W,D as Y,E as H,F as K,G as Q,H as X,I as B,J,K as Z,L as ee,M as te,N as ie,R as ne,S as se,T as ae,v as j,w as q}from"./chunk-KOBKGQ27.js";import"./chunk-RL72BUT4.js";import"./chunk-TIYSZWP5.js";import{a as V,g as U}from"./chunk-I7FNTTUY.js";import"./chunk-RQBSTNL7.js";import{Hb as M,Hc as F,Qc as oe,Rc as D,Wa as I,Yc as u,_a as P,bc as f,c,f as $,fb as G}from"./chunk-FQ2A7YAP.js";import{text as ge}from"node:stream/consumers";import he from"chalk";var R="events.add",Ee=/^[a-z][a-z0-9+.-]*:\/\//i;async function be(){return process.stdin.isTTY?null:ge(process.stdin)}async function Te(e){let i=e.flags["secret-from-env"];if(i){let n=(e.env??process.env)[i];if(!n)throw new f("SECRET_EMPTY",`$${i} is empty or not set`,{fix:`export ${i} first, or name another variable with --secret-from-env`});return n}let t=await(e.readStdin??be)();if(t!==null){let n=t.replace(/\r?\n$/,"");if(n)return n}let o=e.interactive??V(e.flags.json??!1);if(t!==null||!o)throw new f("SECRET_VALUE_REQUIRED",`Can't ask for the signing secret without a terminal
2
+ Pipe it in, or name the environment variable holding it with --secret-from-env.`,{fix:"leave --secret out to have one made, or add --secret-from-env <VAR>"});return(e.prompt??(()=>U("Signing secret",{context:["16 to 128 printable characters. Receivers check X-EveryApp-Signature with it."]})))()}async function pe(e,i){let{flags:t,out:o}=e,n=t.secret===!0||t["secret-from-env"]!==void 0;if(n&&i!==void 0&&!Ee.test(i.trim()))throw new f("VALUE_ON_COMMAND_LINE",`--secret takes no value on the command line
3
+ It lands in the shell's history and the process list: rotate it if it was real. Nothing was added.`,{fix:"give --secret alone: it asks at a hidden prompt, or reads the secret piped in or from --secret-from-env <VAR>"});if(i!==void 0&&t.email!==void 0)throw new f("EVENT_SINK_CONFLICT",`Give a webhook URL or --email, not both
4
+ A subscription delivers one way: a signed POST to a URL, or mail to the organization's owners (and admins).`,{fix:"add one subscription for each"});if(t.email!==void 0&&n)throw new f("EVENT_SINK_CONFLICT",`An email subscription has no signing secret
5
+ Only a webhook is signed; mail goes from the Gateway's own sender to the organization's members.`,{fix:"leave --secret out"});if(i===void 0&&t.email===void 0)throw new f("EVENT_SINK_CONFLICT","Name where events go: a webhook URL, or --email owners|admins",{rerun:`${c} events add https://hooks.example.com/everyapp`,rerunNote:"or --email admins"});let d=H(t.events),a=B(t.name),{gateway:s,organization:v}=await g(e),w=await z(s.cf,M),r,h=!1;if(i!==void 0){let T=K(i,{gatewayHost:s.install.gatewayHost,appBaseDomain:s.install.appBaseDomain,allowPrivate:w.includes(G)}),y=n?Q(await Te(e)):X();h=!n,r={sink:"webhook",url:T,secret:y}}else r={sink:"email",recipients:t.email},w.includes("EMAIL_FROM")||o.emit({type:"warning",code:"EVENT_EMAIL_NOT_CONFIGURED",step:R,message:`The Gateway has no sender (EMAIL_FROM), so these mails can't go out yet
6
6
  Each one is dead at once with email_not_configured until a sender is set.`,data:{rerun:`${c} secret set EMAIL_FROM EMAIL_FROM_NAME`}});o.emit({type:"step",step:R,status:"start",message:"Adding the subscription..."});let m=await J(s.db,{organization:v,name:a??(r.sink==="webhook"?j(r.url):r.recipients==="owners"?"Email owners":"Email owners and admins"),events:d,target:r,deployer:s.deployer,now:e.now?.()});o.emit({type:"step",step:R,status:"ok",message:`Added ${l(m)}`,data:{id:m.id}});let x=`${c} events test ${m.id}`,A=`Added ${l(m)} for ${v.name}.`,_=oe([{label:"Events",value:O(m.events)},{label:"Target",value:S(m)},...r.sink==="webhook"&&h?[{label:"Secret",value:r.secret}]:[]]),k=[...r.sink==="webhook"?[h?"Copy it now: it isn't shown again. Each delivery is signed with it (X-EveryApp-Signature); the receiver checks it.":"Each delivery is signed with your secret (X-EveryApp-Signature); the receiver checks it."]:[],"The Gateway delivers within a minute of each event."];o.emit({type:"done",message:`${A} ${k.at(-1)}`,display:[A,..._,...k.map(T=>he.dim(T))].join(`
7
7
  `),data:{subscription:E(m),organization:b(v),secretGenerated:h,...r.sink==="webhook"&&h?{secret:r.secret}:{},next:[{command:x,note:"sends a test event and waits for the delivery"}]}})}import p from"chalk";function $e(e){if(e.lastDeliveryAt===null)return p.dim("never");let i=e.lastDeliveryStatus??"unknown",t=i==="delivered"?p.green(i):i==="dead"?p.red(i):p.yellow(i),o=e.consecutiveFailures>0?p.yellow(` \xB7 ${$(e.consecutiveFailures,"failure")} in a row`):"";return`${t} ${re(e.lastDeliveryAt)}${o}`}async function ce(e){let{out:i}=e,{gateway:t,organization:o}=await g(e),n=await W(t.db,o.id),d=`${$(n.length,"subscription")} in ${o.name} (at most ${P})`,a=n.length===0?[p.dim(`${o.name} has no event subscriptions.`),p.dim(`Add a webhook: ${c} events add https://hooks.example.com/everyapp --events member.*`),p.dim(`Or mail the owners and admins: ${c} events add --email admins --events cap.*`)]:[...D(["ID","NAME","TARGET","EVENTS","ON","LAST DELIVERY"],n.map(s=>[s.id,`${s.name}${s.builtin?p.dim(" (built-in)"):""}`,S(s),O(s.events),s.enabled?p.green("on"):p.dim("off"),$e(s)])),"",p.dim(d)];i.emit({type:"done",message:d,display:a.join(`
8
- `),data:{organization:b(o),subscriptions:n.map(E),max:P}})}function le({out:e}){let i=["An app's own events are app.<app id>.<name> (app.crm.invoice.paid): subscribe with app.crm.* or app.*.","--events takes types, prefixes with .* (member.*), or * for everything but test pings (the default)."];e.emit({type:"done",message:`${$(I.length,"event type")}`,display:[...D(["TYPE","V","WHAT"],I.map(t=>[t.type,String(t.version),p.dim(t.description)])),"",...i.map(t=>p.dim(t))].join(`
9
- `),data:{types:I.map(t=>({type:t.type,version:t.version,group:t.group,description:t.description})),patterns:["*","<group>.*","app.<app id>.*","app.<app id>.<name>"]}})}import{stripVTControlCharacters as Se}from"node:util";import ve from"chalk";async function ue(e,i){let{out:t}=e,{gateway:o,organization:n}=await g(e),{subscription:d,outcome:a}=await Z(o.db,n,i,e.now?.()),s=a==="disabled"?[`${l(d)} is built in, so it was disabled instead of removed.`,`The Gateway won't make it again. Turn it back on: ${c} events enable ${d.id}`]:[`Removed ${l(d)} from ${n.name}.`,"Nothing more is delivered to it; its delivery log stays for 30 days."];t.emit({type:"done",message:s.join(" "),display:[s[0],ve.dim(s[1])].join(`
10
- `),data:{id:d.id,outcome:a,subscription:E(d),organization:b(n)}})}async function C(e,i,t){let{out:o}=e,{gateway:n,organization:d}=await g(e),{subscription:a,changed:s}=await ee(n.db,d,i,t,e.now?.()),v=s?`${t?"Enabled":"Disabled"} ${l(a)}.`:`${l(a)} is ${t?"enabled":"disabled"} already.`,w=s?t?"New events are queued for it again; what happened while it was off isn't sent.":"No new events are queued for it, and the Gateway drops what is queued.":"Nothing changed.";o.emit({type:"done",message:Se(`${v} ${w}`),display:[v,ve.dim(w)].join(`
11
- `),data:{id:a.id,enabled:t,changed:s,subscription:E(a),organization:b(d)}})}import N from"chalk";var we="events.test";function fe(e,i,t){let o=i.lastError?.split(`
12
- `)[0]?.slice(0,200),n=i.lastStatusCode!==null&&i.lastStatusCode>0?i.lastStatusCode:null;return t==="email"?`${e}, ${n!==null?`${$(n,"recipient")} mailed`:o??"no answer"}`:n!==null?`${e} answered HTTP ${n}${o?` (${o})`:""}`:`${e} answered ${o??"no answer"}`}async function ye(e,i){let{out:t,flags:o}=e,{gateway:n,organization:d}=await g(e),a=await Y(n.db,d,i);if(!a.enabled)throw te(a,"a test");t.emit({type:"step",step:we,status:"start",message:`Queuing a test event for ${l(a)}...`});let s=await ne(n.db,{organizationId:d.id,subscription:a,actor:q(n.deployer),now:e.now?.()});t.emit({type:"step",step:we,status:"ok",message:`Queued ping ${s.eventId} as delivery ${s.deliveryId}`,data:s});let v=S(a),w=`${c} events deliveries ${a.id}`;if(o["no-wait"]){let f=`Queued a test event for ${l(a)}. The Gateway sends it to ${v} within a minute.`;t.emit({type:"done",message:f,display:[f,N.dim(`See how it went: ${w}`)].join(`
13
- `),data:{outcome:"queued",subscriptionId:a.id,...s,next:[{command:w,note:"how it went"}]}});return}let r=e.now??Date.now,h=r();t.emit({type:"step",step:"events.deliver",status:"start",message:"Waiting for the Gateway to send it (it sends queued events every minute)..."});let m=await ae(n.db,d.id,s.deliveryId,{now:r,...e.wait});if(!m){let f=F(e.wait?.timeoutMs??se);throw new y("EVENT_TEST_TIMEOUT",`The Gateway hasn't sent the test event in ${f}
14
- It stays queued. The Gateway sends queued events every minute; one installed before events were added sends them hourly at best until it is updated.`,{fix:`if the Gateway is older than this CLI, update it (${c} update)`,rerun:w,rerunNote:"shows whether it went since",data:{subscriptionId:a.id,...s}})}let x=ie(m,r()),A=F(r()-h);if(x==="delivered"){t.emit({type:"step",step:"events.deliver",status:"ok",message:`Delivered in ${A}`});let f=`Delivered: ${fe(v,m,a.sink)}.`;t.emit({type:"done",message:f,display:N.green(f),data:{outcome:"delivered",subscriptionId:a.id,delivery:L(m,r())}});return}t.emit({type:"step",step:"events.deliver",status:"fail",message:`Failed after ${A}`});let _=x==="failed",k=`The test event wasn't delivered: ${fe(v,m,a.sink)}.`,T=_?"The Gateway retries it (in a minute, then 5, 30, \u2026). Fix the receiver, then send another test.":"It is dead: the Gateway won't try it again.";t.emit({type:"done",message:`${k} ${T}`,display:[N.yellow(k),N.dim(T)].join(`
15
- `),data:{outcome:"failed",subscriptionId:a.id,delivery:L(m,r()),next:[{command:`${c} events test ${a.id}`,note:"once the receiver is fixed"}]}})}async function lt(e,i){await u(e,t=>pe({flags:e,out:t},i))}async function vt(e){await u(e,i=>ce({flags:e,out:i}))}async function ut(e,i){await u(e,t=>ue({flags:e,out:t},i))}async function wt(e,i){await u(e,t=>C({flags:e,out:t},i,!0))}async function ft(e,i){await u(e,t=>C({flags:e,out:t},i,!1))}async function yt(e,i){await u(e,t=>ye({flags:e,out:t},i))}async function gt(e,i){await u(e,t=>de({flags:e,out:t},i))}async function ht(e,i){await u(e,t=>me({flags:e,out:t},i))}async function Et(e){await u(e,async i=>le({out:i}))}export{lt as add,gt as deliveries,ft as disable,wt as enable,vt as list,ht as redeliverDelivery,ut as remove,yt as test,Et as types};
8
+ `),data:{organization:b(o),subscriptions:n.map(E),max:P}})}function le({out:e}){let i=["An app's own events are app.<app id>.<name> (app.crm.invoice.paid): subscribe with app.crm.* or app.*.","--events takes types, prefixes with .* (member.*), or * for everything but test pings and subscription.* (the default)."];e.emit({type:"done",message:`${$(I.length,"event type")}`,display:[...D(["TYPE","V","WHAT"],I.map(t=>[t.type,String(t.version),p.dim(t.description)])),"",...i.map(t=>p.dim(t))].join(`
9
+ `),data:{types:I.map(t=>({type:t.type,version:t.version,group:t.group,description:t.description})),patterns:["*","<group>.*","app.<app id>.*","app.<app id>.<name>"]}})}import{stripVTControlCharacters as Se}from"node:util";import ve from"chalk";async function ue(e,i){let{out:t}=e,{gateway:o,organization:n}=await g(e),{subscription:d,outcome:a}=await Z(o.db,n,i,e.now?.(),o.deployer),s=a==="disabled"?[`${l(d)} is built in, so it was disabled instead of removed.`,`The Gateway won't make it again. Turn it back on: ${c} events enable ${d.id}`]:[`Removed ${l(d)} from ${n.name}.`,"Nothing more is delivered to it; its delivery log stays for 30 days."];t.emit({type:"done",message:s.join(" "),display:[s[0],ve.dim(s[1])].join(`
10
+ `),data:{id:d.id,outcome:a,subscription:E(d),organization:b(n)}})}async function C(e,i,t){let{out:o}=e,{gateway:n,organization:d}=await g(e),{subscription:a,changed:s}=await ee(n.db,d,i,t,e.now?.(),n.deployer),v=s?`${t?"Enabled":"Disabled"} ${l(a)}.`:`${l(a)} is ${t?"enabled":"disabled"} already.`,w=s?t?"New events are queued for it again; what happened while it was off isn't sent.":"No new events are queued for it, and the Gateway drops what is queued.":"Nothing changed.";o.emit({type:"done",message:Se(`${v} ${w}`),display:[v,ve.dim(w)].join(`
11
+ `),data:{id:a.id,enabled:t,changed:s,subscription:E(a),organization:b(d)}})}import N from"chalk";var we="events.test";function ye(e,i,t){let o=i.lastError?.split(`
12
+ `)[0]?.slice(0,200),n=i.lastStatusCode!==null&&i.lastStatusCode>0?i.lastStatusCode:null;return t==="email"?`${e}, ${n!==null?`${$(n,"recipient")} mailed`:o??"no answer"}`:n!==null?`${e} answered HTTP ${n}${o?` (${o})`:""}`:`${e} answered ${o??"no answer"}`}async function fe(e,i){let{out:t,flags:o}=e,{gateway:n,organization:d}=await g(e),a=await Y(n.db,d,i);if(!a.enabled)throw te(a,"a test");t.emit({type:"step",step:we,status:"start",message:`Queuing a test event for ${l(a)}...`});let s=await ne(n.db,{organizationId:d.id,subscription:a,actor:q(n.deployer),now:e.now?.()});t.emit({type:"step",step:we,status:"ok",message:`Queued ping ${s.eventId} as delivery ${s.deliveryId}`,data:s});let v=S(a),w=`${c} events deliveries ${a.id}`;if(o["no-wait"]){let y=`Queued a test event for ${l(a)}. The Gateway sends it to ${v} within a minute.`;t.emit({type:"done",message:y,display:[y,N.dim(`See how it went: ${w}`)].join(`
13
+ `),data:{outcome:"queued",subscriptionId:a.id,...s,next:[{command:w,note:"how it went"}]}});return}let r=e.now??Date.now,h=r();t.emit({type:"step",step:"events.deliver",status:"start",message:"Waiting for the Gateway to send it (it sends queued events every minute)..."});let m=await ae(n.db,d.id,s.deliveryId,{now:r,...e.wait});if(!m){let y=F(e.wait?.timeoutMs??se);throw new f("EVENT_TEST_TIMEOUT",`The Gateway hasn't sent the test event in ${y}
14
+ It stays queued. The Gateway sends queued events every minute; one installed before events were added sends them hourly at best until it is updated.`,{fix:`if the Gateway is older than this CLI, update it (${c} update)`,rerun:w,rerunNote:"shows whether it went since",data:{subscriptionId:a.id,...s}})}let x=ie(m,r()),A=F(r()-h);if(x==="delivered"){t.emit({type:"step",step:"events.deliver",status:"ok",message:`Delivered in ${A}`});let y=`Delivered: ${ye(v,m,a.sink)}.`;t.emit({type:"done",message:y,display:N.green(y),data:{outcome:"delivered",subscriptionId:a.id,delivery:L(m,r())}});return}t.emit({type:"step",step:"events.deliver",status:"fail",message:`Failed after ${A}`});let _=x==="failed",k=`The test event wasn't delivered: ${ye(v,m,a.sink)}.`,T=_?"The Gateway retries it (in a minute, then 5, 30, \u2026). Fix the receiver, then send another test.":"It is dead: the Gateway won't try it again.";t.emit({type:"done",message:`${k} ${T}`,display:[N.yellow(k),N.dim(T)].join(`
15
+ `),data:{outcome:"failed",subscriptionId:a.id,delivery:L(m,r()),next:[{command:`${c} events test ${a.id}`,note:"once the receiver is fixed"}]}})}async function lt(e,i){await u(e,t=>pe({flags:e,out:t},i))}async function vt(e){await u(e,i=>ce({flags:e,out:i}))}async function ut(e,i){await u(e,t=>ue({flags:e,out:t},i))}async function wt(e,i){await u(e,t=>C({flags:e,out:t},i,!0))}async function yt(e,i){await u(e,t=>C({flags:e,out:t},i,!1))}async function ft(e,i){await u(e,t=>fe({flags:e,out:t},i))}async function gt(e,i){await u(e,t=>de({flags:e,out:t},i))}async function ht(e,i){await u(e,t=>me({flags:e,out:t},i))}async function Et(e){await u(e,async i=>le({out:i}))}export{lt as add,gt as deliveries,yt as disable,wt as enable,vt as list,ht as redeliverDelivery,ut as remove,ft as test,Et as types};
@@ -1,4 +1,4 @@
1
- import{a as h,b as D,e as E,g as M,h as v,j as G}from"./chunk-ELK7QZ2M.js";import{A as j,h as C,t as W,u as I,v as z,w as A,x as O,y as x,z as F}from"./chunk-M2QQ2UD7.js";import"./chunk-RMF4YGD6.js";import"./chunk-NFU4YFXB.js";import"./chunk-T2GD7RHS.js";import{i as P}from"./chunk-CCWBPAKH.js";import"./chunk-JYKRUS5C.js";import{Bb as S,c as y,f as g,pc as f,wc as w}from"./chunk-LYNBZ7RV.js";import u from"chalk";var c="workspace.update";async function ee(e){await w(e,n=>N({flags:e,out:n}))}async function te(e,n){await w(e,o=>U({flags:e,out:o},n))}async function ae(e,n){await w(e,o=>R({flags:e,out:o},n))}async function oe(e,n){await w(e,o=>L({flags:e,out:o},n))}async function ne(e,n){await w(e,o=>q({flags:e,out:o},n))}async function se(e,n){await w(e,o=>_({flags:e,out:o},n))}var $=e=>({id:e.id,name:e.name,description:e.description,members:e.memberCount,apps:e.appCount,createdAt:new Date(e.createdAt).toISOString()});async function N(e){let{out:n}=e,{ws:o}=await h(e),r=await W(o),s=f(["GROUP","MEMBERS","APPS","DESCRIPTION","ID"],r.map(t=>[t.name,String(t.memberCount),String(t.appCount),t.description??u.dim("\u2013"),u.dim(t.id)]));n.emit({type:"done",message:`${g(r.length,"group")} in ${o.organization.name}`,display:r.length>0?s.join(`
1
+ import{a as h,b as D,e as E,g as M,h as v,j as G}from"./chunk-H4EZTXIK.js";import{A as z,B as A,C as O,D as x,E as F,F as j,m as C,y as W,z as I}from"./chunk-QFTBDXLF.js";import"./chunk-GAPQSINH.js";import"./chunk-LEEUODYR.js";import"./chunk-DCFHBCCW.js";import"./chunk-KOBKGQ27.js";import"./chunk-RL72BUT4.js";import"./chunk-TIYSZWP5.js";import{i as P}from"./chunk-I7FNTTUY.js";import"./chunk-RQBSTNL7.js";import{Rc as f,Yc as w,bc as S,c as y,f as g}from"./chunk-FQ2A7YAP.js";import u from"chalk";var c="workspace.update";async function ee(e){await w(e,n=>N({flags:e,out:n}))}async function te(e,n){await w(e,o=>U({flags:e,out:o},n))}async function ae(e,n){await w(e,o=>R({flags:e,out:o},n))}async function oe(e,n){await w(e,o=>L({flags:e,out:o},n))}async function ne(e,n){await w(e,o=>q({flags:e,out:o},n))}async function se(e,n){await w(e,o=>_({flags:e,out:o},n))}var $=e=>({id:e.id,name:e.name,description:e.description,members:e.memberCount,apps:e.appCount,createdAt:new Date(e.createdAt).toISOString()});async function N(e){let{out:n}=e,{ws:o}=await h(e),r=await W(o),s=f(["GROUP","MEMBERS","APPS","DESCRIPTION","ID"],r.map(t=>[t.name,String(t.memberCount),String(t.appCount),t.description??u.dim("\u2013"),u.dim(t.id)]));n.emit({type:"done",message:`${g(r.length,"group")} in ${o.organization.name}`,display:r.length>0?s.join(`
2
2
  `):u.dim(`No groups in ${o.organization.name} yet: ${y} workspace group create <name>`),data:{organization:o.organization,groups:r.map($)}})}async function U(e,n){let{out:o,flags:r}=e,{ws:s}=await h(e);o.emit({type:"step",step:c,status:"start",message:`Creating the group ${n}...`});let t=await I(s,{name:n,description:r.description});o.emit({type:"step",step:c,status:"ok",message:`Created ${t.name}`,data:{groupId:t.id}}),o.emit({type:"done",message:`Created the group ${t.name} (${t.id}) in ${s.organization.name}.`,data:{organization:s.organization,group:$(t),next:[{command:`${y} workspace group members ${T(t.name)} --add <email>`,note:"who is in it"},{command:`${y} workspace group apps ${T(t.name)} --add <app>`,note:"which apps it opens"}]}})}var T=e=>/^[\w.-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`;async function R(e,n){let{out:o,flags:r}=e;if(r.name===void 0&&r.description===void 0)throw new S("NOTHING_TO_SET","Nothing to set: give --name or --description");let{ws:s}=await h(e);o.emit({type:"step",step:c,status:"start",message:`Updating ${n}...`});let t=await z(s,n,{name:r.name,description:r.description});o.emit({type:"step",step:c,status:"ok",message:`Updated ${t.name}`,data:{groupId:t.id}}),o.emit({type:"done",message:`${t.name} (${t.id}): ${t.description?`"${t.description}"`:"no description"}.`,data:{organization:s.organization,group:$(t)}})}async function L(e,n){let{out:o,flags:r}=e,{ws:s}=await h(e),t=await C(s,n);await P({yes:r.yes,interactive:D(e),confirm:e.confirm,question:`Delete the group ${t.name}?`,unattended:"Deleting a group needs confirmation at a terminal, or --yes",context:[`It has ${g(t.memberCount,"member")} and opens ${g(t.appCount,"app")}; what it granted ends with it.`],cancelled:"Cancelled. Nothing deleted.",data:{groupId:t.id,name:t.name}}),o.emit({type:"step",step:c,status:"start",message:`Deleting ${t.name}...`}),await A(s,t.id),o.emit({type:"step",step:c,status:"ok",message:`Deleted ${t.name}`,data:{groupId:t.id}});let i=[`Deleted the group ${t.name} from ${s.organization.name}.`,`Its ${g(t.memberCount,"member")} keep their direct grants and other groups; the ${g(t.appCount,"app")} it opened are no longer open through it.`];o.emit({type:"done",message:i.join(`
3
3
  `),display:[i[0],u.dim(i[1])].join(`
4
4
  `),data:{organization:s.organization,group:$(t)}})}async function q(e,n){let{out:o,flags:r}=e,{change:s}=G(r),{ws:t}=await h(e),i=await C(t,n),p=[],m=[],d;s?(o.emit({type:"step",step:c,status:"start",message:`Changing who is in ${i.name}...`}),{added:p,removed:m,members:d}=await x(t,i,s),o.emit({type:"step",step:c,status:"ok",message:`${i.name}: ${g(p.length,"member")} added, ${m.length} removed`,data:{groupId:i.id,added:p.length,removed:m.length}})):d=await O(t,i);let l=d.filter(a=>a.inGroup),b=f(["EMAIL","ROLE","STATUS","IN GROUP"],d.map(a=>[a.email,a.primaryRole??a.role,M(a),a.inGroup?u.green("yes"):u.dim("no")])),k=s?`${i.name}: added ${p.length>0?p.map(a=>a.email).join(", "):"nobody"}, removed ${m.length>0?m.map(a=>a.email).join(", "):"nobody"}; ${g(l.length,"member")} in it now.`:`${g(l.length,"member")} in ${i.name}, of ${d.length} in ${t.organization.name}.`;o.emit({type:"done",message:k,display:[k,b.join(`