everyapp 0.3.0-rc.4 → 0.3.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-Z4V433V3.js +1 -0
- package/dist/{activity-RTCAUMQS.js → activity-DI4EQK5D.js} +1 -1
- package/dist/ai-2CSPD7BE.js +5 -0
- package/dist/{apps-PEOBCDNU.js → apps-ZRJ4E67Y.js} +1 -1
- package/dist/{chunk-DCFHBCCW.js → chunk-237YEYW3.js} +1 -1
- package/dist/chunk-2R4OIXLG.js +2 -0
- package/dist/{chunk-YAZHTVUV.js → chunk-2TJPAUI2.js} +1 -1
- package/dist/{chunk-H4EZTXIK.js → chunk-3N3EVZIL.js} +1 -1
- package/dist/chunk-4HAZIQNG.js +2 -0
- package/dist/chunk-4PL6QFR7.js +8 -0
- package/dist/chunk-4YVIPUTR.js +45 -0
- package/dist/chunk-5D7AKUE4.js +5 -0
- package/dist/chunk-5XZAJC2Z.js +37 -0
- package/dist/chunk-7JWJE5CC.js +1 -0
- package/dist/{chunk-V7BWZOSZ.js → chunk-7QXX37OH.js} +17 -17
- package/dist/{chunk-RL72BUT4.js → chunk-7WF744VP.js} +1 -1
- package/dist/{chunk-O64FPLGX.js → chunk-AH6OKF3W.js} +1 -1
- package/dist/chunk-AKXMJN76.js +1 -0
- package/dist/{chunk-TIYSZWP5.js → chunk-BLBD5NRZ.js} +1 -1
- package/dist/chunk-CDTGQRJK.js +9 -0
- package/dist/chunk-CQH4GPRR.js +14 -0
- package/dist/chunk-D5HKHQTL.js +1 -0
- package/dist/{chunk-BK4NK34C.js → chunk-DCUHPZ7L.js} +1 -1
- package/dist/{chunk-MEIWV7FJ.js → chunk-DUC3C3VQ.js} +1 -1
- package/dist/{chunk-GAPQSINH.js → chunk-FMEACXUH.js} +1 -1
- package/dist/{chunk-KQM6ZUX5.js → chunk-GZSHACXB.js} +1 -1
- package/dist/{chunk-ORGV2NNT.js → chunk-IC3GMQUY.js} +1 -1
- package/dist/chunk-KD7Z3NZM.js +19 -0
- package/dist/{chunk-LI3YLKLC.js → chunk-KG5PJBQO.js} +1 -1
- package/dist/{chunk-SGRGD7L4.js → chunk-KJVVTOL3.js} +1 -1
- package/dist/{chunk-VVKQJSF3.js → chunk-KOMQQDE4.js} +1 -1
- package/dist/chunk-L5OM5ERO.js +1 -0
- package/dist/{chunk-KOBKGQ27.js → chunk-L7P5IFQO.js} +35 -33
- package/dist/{chunk-QKHLRLK3.js → chunk-LPXDP2TG.js} +1 -1
- package/dist/{chunk-I7FNTTUY.js → chunk-N7J2Y6YM.js} +1 -1
- package/dist/{chunk-AMCNAKYU.js → chunk-NSDEURVV.js} +1 -1
- package/dist/{chunk-3EADVHFN.js → chunk-O7TM3TQQ.js} +1 -1
- package/dist/chunk-QWBCJXRO.js +2 -0
- package/dist/chunk-RJW7E7KW.js +1 -0
- package/dist/{chunk-PDPUGYJW.js → chunk-ROVVRUPW.js} +27 -27
- package/dist/{chunk-HJGZGZFE.js → chunk-SSDMYDPY.js} +3 -3
- package/dist/chunk-SSHOF4SN.js +1 -0
- package/dist/{chunk-TUXKBLLJ.js → chunk-TBFAT4IO.js} +1 -1
- package/dist/chunk-TMJCBQDC.js +18 -0
- package/dist/{chunk-EQLY5I46.js → chunk-TPRTRAMO.js} +1 -1
- package/dist/{chunk-FB2OC32C.js → chunk-TTRQFVAM.js} +3 -3
- package/dist/chunk-UORW6LDA.js +2 -0
- package/dist/chunk-V6YIWV7B.js +2 -0
- package/dist/{chunk-WVHJIYQ3.js → chunk-W7YJMRYJ.js} +1 -1
- package/dist/chunk-YHLXCGDS.js +8 -0
- package/dist/{chunk-R7JOHK7Y.js → chunk-YRVHVI5U.js} +1 -1
- package/dist/{chunk-QFTBDXLF.js → chunk-YUHQSSAS.js} +1 -1
- package/dist/{chunk-NDOEON54.js → chunk-ZCGZPCNA.js} +1 -1
- package/dist/chunk-ZNQCJL74.js +1 -0
- package/dist/{chunk-MLTNW3AM.js → chunk-ZWD6IOFM.js} +1 -1
- package/dist/configure-M52NNYON.js +1 -0
- package/dist/create-KXSWFSHW.js +15 -0
- package/dist/{db-B7KO37SV.js → db-ECRVCE3X.js} +1 -1
- package/dist/{delete-CB3EPOU4.js → delete-T7NUPMGS.js} +1 -1
- package/dist/deploy-GTTVOFEL.js +1 -0
- package/dist/{dev-4JYCVVOZ.js → dev-DYR4EJG5.js} +35 -35
- package/dist/{email-SWJQXEUR.js → email-5WYLGMB3.js} +1 -1
- package/dist/{events-GJV2KVIU.js → events-RTGGQ5AC.js} +1 -1
- package/dist/{groups-NNTLSXMK.js → groups-QKSGV4S5.js} +1 -1
- package/dist/index.js +93 -92
- package/dist/install-ZBKQD6ON.js +1 -0
- package/dist/login-OY4PIWPD.js +1 -0
- package/dist/mcp-S24EVYO7.js +1 -0
- package/dist/{provider-622VM7UZ.js → provider-RYICILOF.js} +1 -1
- package/dist/release-BL36NMEE.js +1 -0
- package/dist/restore-DGPJTJJ7.js +3 -0
- package/dist/secret-S7AI7QK5.js +1 -0
- package/dist/setup-BA3IKUNN.js +1 -0
- package/dist/{signin-EP5JLAT5.js → signin-ZQBMQKPM.js} +1 -1
- package/dist/skills-QKFZPA6Y.js +2 -0
- package/dist/status-QB4N64YZ.js +5 -0
- package/dist/{teardown-6RURRSME.js → teardown-WS6FJFM3.js} +1 -1
- package/dist/update-7UICSOEW.js +1 -0
- package/dist/{workspace-VW7ZZRFP.js → workspace-EX5XC2J4.js} +1 -1
- package/package.json +6 -5
- package/skills/build-every-app/SKILL.md +14 -10
- package/skills/build-every-app/patterns.md +30 -30
- package/skills/everyapp/SKILL.md +5 -1
- package/skills/everyapp/setup/README.md +5 -5
- package/skills/everyapp/setup/access.md +1 -1
- package/skills/everyapp/setup/ai-gateway.md +1 -1
- package/skills/everyapp/setup/ai.md +2 -2
- package/skills/everyapp/setup/email.md +5 -5
- package/skills/everyapp/setup/gateway.md +6 -7
- package/skills/everyapp/setup/google.md +16 -11
- package/skills/everyapp/setup/openai.md +1 -1
- package/skills/everyapp/setup/openrouter.md +16 -16
- package/skills/everyapp/setup/workers-ai.md +11 -11
- package/starter/.prettierignore +8 -0
- package/starter/AGENTS.md +34 -0
- package/starter/CLAUDE.md +1 -0
- package/starter/README.md +35 -0
- package/starter/cloudflare.config.ts +11 -0
- package/starter/drizzle/0000_todos.sql +7 -0
- package/starter/drizzle/meta/0000_snapshot.json +65 -0
- package/starter/drizzle/meta/_journal.json +13 -0
- package/starter/drizzle.config.ts +7 -0
- package/starter/everyapp.config.ts +15 -0
- package/starter/gitignore +23 -0
- package/starter/knip.jsonc +20 -0
- package/starter/package.json +48 -0
- package/starter/public/apple-touch-icon.png +0 -0
- package/starter/public/favicon.ico +0 -0
- package/starter/src/db/index.ts +5 -0
- package/starter/src/db/schema.ts +13 -0
- package/starter/src/entry.worker.ts +9 -0
- package/starter/src/env.d.ts +8 -0
- package/starter/src/middleware/ensureUser.ts +13 -0
- package/starter/src/routeTree.gen.ts +86 -0
- package/starter/src/router.tsx +6 -0
- package/starter/src/routes/__root.tsx +35 -0
- package/starter/src/routes/health.ts +18 -0
- package/starter/src/routes/index.tsx +260 -0
- package/starter/src/server/events.test.ts +53 -0
- package/starter/src/server/events.ts +31 -0
- package/starter/src/server/todos.test.ts +49 -0
- package/starter/src/server/todos.ts +74 -0
- package/starter/src/serverFunctions/home.ts +72 -0
- package/starter/src/serverFunctions/todos.ts +31 -0
- package/starter/src/styles/app.css +5 -0
- package/starter/src/tools.ts +59 -0
- package/starter/tsconfig.json +18 -0
- package/starter/vite.config.ts +33 -0
- package/starter/vitest.config.ts +8 -0
- package/dist/access-YWM4BSBD.js +0 -1
- package/dist/ai-UOYQFTAX.js +0 -5
- package/dist/chunk-26KS6TD6.js +0 -1
- package/dist/chunk-4LKLQOM7.js +0 -7
- package/dist/chunk-5IC3ZN52.js +0 -1
- package/dist/chunk-ASCNE7GS.js +0 -2
- package/dist/chunk-BCTEWNN4.js +0 -6
- package/dist/chunk-DWTJ4OLZ.js +0 -6
- package/dist/chunk-EP3IQ354.js +0 -20
- package/dist/chunk-EP4HRYXP.js +0 -2
- package/dist/chunk-F5XK23HV.js +0 -1
- package/dist/chunk-FQ2A7YAP.js +0 -57
- package/dist/chunk-GJK6GAWO.js +0 -1
- package/dist/chunk-KVCL64LI.js +0 -1
- package/dist/chunk-LEEUODYR.js +0 -1
- package/dist/chunk-NW7SJPSP.js +0 -37
- package/dist/chunk-R2DF3ENZ.js +0 -2
- package/dist/chunk-S2G4G73L.js +0 -18
- package/dist/chunk-XBD7PQN5.js +0 -2
- package/dist/configure-CAWCTPYY.js +0 -1
- package/dist/create-3ZWJQXPK.js +0 -22
- package/dist/deploy-5O7LV5OX.js +0 -1
- package/dist/install-UAG3CNYW.js +0 -1
- package/dist/login-QEKMLMUB.js +0 -1
- package/dist/mcp-AFGVOM5D.js +0 -1
- package/dist/release-CXEX6O7F.js +0 -1
- package/dist/restore-PGIVEA5P.js +0 -3
- package/dist/secret-3LUDEDUW.js +0 -1
- package/dist/setup-PUD375AM.js +0 -1
- package/dist/status-LK6DNLCI.js +0 -5
- package/dist/update-YJFTOZEV.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,b as e,c as f,d as g,e as h,f as i}from"./chunk-DUC3C3VQ.js";import"./chunk-QJRZFIYC.js";import{a,b,c}from"./chunk-TBFAT4IO.js";import"./chunk-ROVVRUPW.js";import"./chunk-W7YJMRYJ.js";import"./chunk-FMEACXUH.js";import"./chunk-LPXDP2TG.js";import"./chunk-IC3GMQUY.js";import"./chunk-ZNQCJL74.js";import"./chunk-L5OM5ERO.js";import"./chunk-O7TM3TQQ.js";import"./chunk-TPRTRAMO.js";import"./chunk-237YEYW3.js";import"./chunk-L7P5IFQO.js";import"./chunk-5D7AKUE4.js";import"./chunk-7WF744VP.js";import"./chunk-BLBD5NRZ.js";import"./chunk-NSDEURVV.js";import"./chunk-N7J2Y6YM.js";import"./chunk-RQBSTNL7.js";import"./chunk-CQH4GPRR.js";import"./chunk-4YVIPUTR.js";export{c as APPS_APPLICATION_NAME,b as GATEWAY_APPLICATION_NAME,a as POLICY_NAME,e as off,d as on,f as show,i as showAccess,h as turnAccessOff,g as turnAccessOn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as v,c as w,d as x,e as A,f as g}from"./chunk-
|
|
1
|
+
import{a as v,c as w,d as x,e as A,f as g}from"./chunk-3N3EVZIL.js";import{O as L,P as R,R as U,U as z,V as D,W as j,X as B,Y as H,k as F,l as N}from"./chunk-YUHQSSAS.js";import"./chunk-FMEACXUH.js";import"./chunk-L5OM5ERO.js";import"./chunk-237YEYW3.js";import"./chunk-L7P5IFQO.js";import"./chunk-5D7AKUE4.js";import"./chunk-7WF744VP.js";import"./chunk-BLBD5NRZ.js";import"./chunk-N7J2Y6YM.js";import"./chunk-RQBSTNL7.js";import"./chunk-CQH4GPRR.js";import{$b as W,Kc as y,Rc as $,a as f,d as k,kb as I,nb as M}from"./chunk-4YVIPUTR.js";import t from"chalk";var C="workspace.update";async function ue(e){await $(e,n=>J({flags:e,out:n}))}async function ge(e){await $(e,n=>V({flags:e,out:n}))}async function fe(e){await $(e,n=>Q({flags:e,out:n}))}async function ke(e){await $(e,n=>Z({flags:e,out:n}))}async function ye(e,n){await $(e,o=>ee({flags:e,out:o},n))}async function $e(e){await $(e,n=>te({flags:e,out:n}))}async function ve(e,n){await $(e,o=>ae({flags:e,out:o},n))}var u=e=>e.toLocaleString("en-US"),T=e=>e===0?t.dim("\u2013"):`$${(e/1e6).toFixed(4)}`,K=e=>`$${(e/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`;async function J(e){let{out:n,flags:o}=e,{ws:r}=await v(e),i=o.month??L(new Date(r.now)),s=await R(r,i),l=a=>{if(!a.callable)return t.dim("removed");if(a.capUnlimited)return t.dim("none (unlimited)");let h=[a.effectiveMonthlyCallCap===null?null:{kind:"calls",cap:u(a.effectiveMonthlyCallCap),source:a.capSource},a.effectiveMonthlyCostCapMicros===null?null:{kind:"cost",cap:K(a.effectiveMonthlyCostCapMicros),source:a.costCapSource}].filter(b=>b!==null);return h.length===0?t.dim("none"):h.map(b=>{let P=b.source==="default"?`${b.cap} ${t.dim("(default)")}`:b.cap;return a.pausedBy===b.kind?`${P} ${t.yellow("paused")}`:P}).join(" / ")},m=y(["APP","CALLS","FAILED","TOOL CALLS","TOKENS IN/OUT","COST","CAP"],s.byApp.map(a=>[a.appSlug??a.appRowId,u(a.calls),a.failures>0?t.yellow(u(a.failures)):t.dim("0"),u(a.toolCalls),`${u(a.inputTokens)}/${u(a.outputTokens)}`,T(a.costMicros),l(a)])),p=y(["MEMBER","CALLS","FAILED","TOOL CALLS","TOKENS IN/OUT","COST"],s.byMember.map(a=>[a.userId===""?t.dim("the apps themselves"):a.email??t.dim(`${a.userId} (no longer a member)`),u(a.calls),a.failures>0?t.yellow(u(a.failures)):t.dim("0"),u(a.toolCalls),`${u(a.inputTokens)}/${u(a.outputTokens)}`,T(a.costMicros)])),c=y(["PROVIDER","KIND","CALLS","FAILED","TOKENS IN/OUT","COST"],s.byTarget.map(a=>[a.target,a.kind,u(a.calls),a.failures>0?t.yellow(u(a.failures)):t.dim("0"),`${u(a.inputTokens)}/${u(a.outputTokens)}`,T(a.costMicros)])),d=s.byApp.reduce((a,h)=>a+h.calls,0),X=s.byApp.reduce((a,h)=>a+h.toolCalls,0),S=s.byApp.filter(a=>a.paused).length,E=`${r.organization.name}, ${i}: ${k(d,"provider call")} and ${k(X,"tool call")} across ${k(s.byApp.length,"app")}${S>0?`, ${S} paused`:""}`,O=[s.defaultMonthlyCallCap===null?null:`${u(s.defaultMonthlyCallCap)} calls a month`,s.defaultMonthlyCostCapMicros===null?null:`${K(s.defaultMonthlyCostCapMicros)} a month`].filter(a=>a!==null),G=O.length===0?"No workspace default cap.":`Workspace default cap: ${O.join(" or ")} for every app without its own.`;n.emit({type:"done",message:E,display:[E,t.dim(G),"",t.bold("By app"),...s.byApp.length>0?m:[t.dim("no apps")],"",t.bold("By member"),...s.byMember.length>0?p:[t.dim("no calls")],"",t.bold("By provider"),...s.byTarget.length>0?c:[t.dim("no calls")],"",t.dim(`Cap an app: ${f} workspace app cap <app> [<n|off>] [--usd <dollars|off>] [--unlimited]; the default: ${f} workspace cap default [<n|off>] [--usd <dollars|off>]`)].join(`
|
|
2
2
|
`),data:{organization:r.organization,...s}})}async function V(e){let{out:n,flags:o}=e,{ws:r}=await v(e),i=o.app===void 0?void 0:await N(r,o.app,{callable:!0}),s=o.user===void 0?void 0:await w(r,o.user),l=await U(r,{limit:o.limit,before:o.before,appRowId:i?.id,userId:s?.id,decision:o.decision,risk:o.risk,since:o.since}),m=y(["WHEN (UTC)","WHO","APP","TOOL","RISK","DECISION","OUTCOME","MS","CLIENT"],l.calls.map(d=>[A(d.createdAt),d.user.email??t.dim(d.user.id),d.app.slug?`${d.app.slug}${d.app.removed?t.dim(" (removed)"):""}`:t.dim("gateway"),d.tool.via?`${d.tool.name} ${t.dim(`via ${d.tool.via}`)}`:d.tool.name,d.tool.risk??t.dim("\u2013"),d.decision==="allowed"?t.green("allowed"):t.red(`blocked${d.reason?t.dim(` (${d.reason})`):""}`),d.outcome,d.durationMs===null?t.dim("\u2013"):String(d.durationMs),d.credential.clientName??d.credential.clientInfo??t.dim(d.credential.kind)])),p=l.nextBefore?`${l.nextBefore.createdAt}:${l.nextBefore.id}`:null,c=`${k(l.calls.length,"tool call")} in ${r.organization.name}${l.nextBefore?" (more before this page)":""}`;n.emit({type:"done",message:c,display:[l.calls.length>0?m.join(`
|
|
3
3
|
`):t.dim("No tool calls match."),...p?[t.dim(`Next page: ${f} workspace activity --before ${p}`)]:[]].join(`
|
|
4
4
|
`),data:{organization:r.organization,calls:l.calls.map(d=>({...d,createdAt:g(d.createdAt)})),nextBefore:p,...p?{next:[{command:`${f} workspace activity --before ${p}`,note:"the next page"}]}:{}}})}async function Y(e,n){try{return(await F(e,n)).id}catch(o){if(!(o instanceof W)||o.code!=="USER_NOT_FOUND")throw o;return n.trim()}}async function Q(e){let{out:n,flags:o}=e,{ws:r}=await v(e),i=o.actor===void 0?void 0:await Y(r,o.actor),s=await z(r,{limit:o.limit,before:o.before,actorId:i,type:o.type,since:o.since}),l=y(["WHEN (UTC)","WHO","WHAT","SUBJECT","TYPE"],s.events.map(c=>[A(c.time),I(c.actor),c.label,M(c.subject)||t.dim("\u2013"),t.dim(c.type)])),m=s.nextBefore?`${s.nextBefore.time}:${s.nextBefore.id}`:null,p=`${k(s.events.length,"audit event")} in ${r.organization.name}${s.nextBefore?" (more before this page)":""}`;n.emit({type:"done",message:p,display:[s.events.length>0?l.join(`
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{c as P,d as u,e as T,j as k}from"./chunk-YUHQSSAS.js";import{B as h}from"./chunk-ROVVRUPW.js";import"./chunk-W7YJMRYJ.js";import"./chunk-FMEACXUH.js";import{a as E,f as D}from"./chunk-AKXMJN76.js";import"./chunk-IC3GMQUY.js";import"./chunk-ZNQCJL74.js";import"./chunk-L5OM5ERO.js";import"./chunk-O7TM3TQQ.js";import"./chunk-SSDMYDPY.js";import"./chunk-TPRTRAMO.js";import{c as _,e as b}from"./chunk-237YEYW3.js";import"./chunk-L7P5IFQO.js";import"./chunk-5D7AKUE4.js";import"./chunk-7WF744VP.js";import"./chunk-BLBD5NRZ.js";import"./chunk-NSDEURVV.js";import{a as I}from"./chunk-N7J2Y6YM.js";import"./chunk-RQBSTNL7.js";import"./chunk-CQH4GPRR.js";import{$b as $,Jc as C,Kc as f,N as g,Rc as c,a as r,i as w}from"./chunk-4YVIPUTR.js";import d from"chalk";var j="everyapp",x="ai.update";async function te(t){await c(t,e=>F({flags:t,out:e}))}async function ae(t){await c(t,e=>O({flags:t,out:e}))}async function oe(t,e){await c(t,a=>S({flags:t,out:a},e))}async function ne(t){await c(t,e=>N({flags:t,out:e},t.id))}async function ie(t){await c(t,e=>K({flags:t,out:e}))}async function m(t){let{flags:e,out:a,createCf:n}=t,s=await b({gateway:_(e.gateway),accountId:e["account-id"],interactive:I(e.json??!1),login:{json:e.json,out:a,step:"login"},createCf:n}),o=await k(s.db,s.deployer,{now:t.now?.()});return{gateway:s,ws:o}}function Y(t){let{resolution:e,aiGateway:a}=t;return{provider:e.provider,label:e.label,model:e.model,source:e.source,configured:e.configured,settings:e.settings,via:e.via,chat:e.chat,...e.embeddings?{embeddings:e.embeddings}:{},candidates:e.candidates,...e.problem?{problem:e.problem}:{},aiGateway:a}}var A=t=>`${t.label} (${t.model})`;function W(t,e){return t.map(a=>[a.id===e?d.bold(a.id):a.id,a.label,a.configured?d.green("set"):d.dim("not set"),a.settings.join(" "),a.model,a.id===e?d.green("\u2190 the default"):""])}function R(t){let{resolution:e}=t;switch(e.source){case"setting":return e.configured?`Chosen with ${r} ai default; ${e.settings.join(" and ")} ${e.settings.length===1?"is":"are"} set.`:`Chosen with ${r} ai default, but ${w(e.settings)} ${e.settings.length===1?"isn't":"aren't"} set: apps get ai_default_not_configured until ${r} secret set ${e.settings.join(" ")}.`;case"order":return`Nothing chosen: the first provider of the order whose key is set. ${r} ai default <provider> picks another.`;case"none":return`Nothing is set yet: apps that need a chat model show "Needs setup" until one key is set (${r} secret set ${e.settings.join(" ")}, or any provider's below).`}}async function F(t){let{out:e}=t,{gateway:a,ws:n}=await m(t),s=await u(a.cf,n),{resolution:o,aiGateway:i}=s,p=[...C([{label:"Default",value:o.configured?A(o):`${A(o)} ${d.yellow("not configured")}`},{label:"Route",value:`/api/ai/default/v1/chat/completions \u2192 ${o.chat.path}${o.embeddings?`; /v1/embeddings \u2192 ${o.embeddings.path}`:""}`},{label:"Through",value:i.on?"Cloudflare AI Gateway":`direct (${r} ai gateway on puts AI Gateway in front)`}]),"",R(s),...o.problem?[d.yellow(`The stored choice can't serve: ${o.problem}.`)]:[],"",...f(["Provider","Name","Key","Setting","Model",""],W(o.candidates,o.provider))];e.emit({type:"done",message:p.join(`
|
|
2
|
+
`),data:Y(s)})}async function O(t){let{out:e}=t,{gateway:a,ws:n}=await m(t),s=await u(a.cf,n),{resolution:o}=s;e.emit({type:"done",message:[...f(["Provider","Name","Key","Setting","Model",""],W(o.candidates,o.provider)),"",`An app that pins a provider lists it under providers; one that takes the default says ai: { chat: true }. ${r} ai default <provider>[/<model>] chooses.`].join(`
|
|
3
|
+
`),data:{candidates:o.candidates,provider:o.provider,aiGateway:s.aiGateway}})}async function S(t,e){let{out:a}=t,n=T(e),{gateway:s,ws:o}=await m(t);a.emit({type:"step",step:x,status:"start",message:"Setting the default model provider..."});let i=await P(o,n),p=await u(s.cf,o),{resolution:l}=p,y=v=>v===null?"the shipped order":g(v);a.emit({type:"step",step:x,status:"ok",message:`${o.organization.name}: the default model provider is ${y(n)}`,data:{choice:n===null?null:g(n),was:i.was===null?null:g(i.was)}});let G=[i.changed?`${o.organization.name}: the default is ${y(n)} (was ${y(i.was)}).`:`${o.organization.name} had ${y(n)} already. Nothing changed.`,`Apps that ask for the default get ${A(l)} on the Gateway within 30 seconds.`];l.configured||G.push(d.yellow(`${w(l.settings)} ${l.settings.length===1?"isn't":"aren't"} set: until then those apps get ai_default_not_configured. Set it: ${r} secret set ${l.settings.join(" ")}`)),a.emit({type:"done",message:G.join(`
|
|
4
|
+
`),data:Y(p)})}async function N(t,e=j){let{out:a}=t,n=e.trim().toLowerCase();if(!E(n))throw new $("AI_GATEWAY_ID_INVALID",`${e} isn't a valid AI Gateway id: lowercase letters, digits and single hyphens, 64 characters at most`,{fix:`${r} ai gateway on --id <name>`});let s=await m(t),o=t.ensureAiGateway??D;a.emit({type:"step",step:"ai.gateway",status:"start",message:`Finding AI Gateway ${n}...`});let i=await o(s.gateway.cf,{id:n,accountId:s.gateway.accountId});a.emit({type:"step",step:"ai.gateway",status:"ok",message:i.created?`Made AI Gateway ${i.id}`:`AI Gateway ${i.id} exists`,data:{id:i.id,url:i.url,created:i.created}}),await h(s.gateway,{AI_GATEWAY_ID:i.id},{flags:t.flags,out:a}),a.emit({type:"done",message:[`Every model call to a provider AI Gateway fronts goes through ${i.url} from the Gateway's next request, the provider's own key still on it.`,`Logs: Cloudflare dashboard \u2192 AI \u2192 AI Gateway \u2192 ${i.id}. For an authenticated gateway: ${r} secret set AI_GATEWAY_API_KEY.`].join(`
|
|
5
|
+
`),data:{id:i.id,url:i.url,created:i.created}})}async function K(t){let{out:e}=t,a=await m(t),n=await u(a.gateway.cf,a.ws);if(!n.names.includes("AI_GATEWAY_ID")){e.emit({type:"done",message:"AI Gateway isn't in front: AI_GATEWAY_ID isn't set. Nothing changed.",data:{on:!1,changed:!1}});return}await h(a.gateway,{AI_GATEWAY_ID:null},{flags:t.flags,out:e}),e.emit({type:"done",message:`Model calls go direct from the Gateway's next request. The AI Gateway and its logs stay in the account${n.names.includes("AI_GATEWAY_API_KEY")?`; AI_GATEWAY_API_KEY stays until ${r} secret unset AI_GATEWAY_API_KEY`:""}.`,data:{on:!1,changed:!0}})}export{S as chooseDefault,ie as gatewayOff,ne as gatewayOn,ae as list,O as listCandidates,oe as setDefault,te as show,F as showDefault,K as turnGatewayOff,N as turnGatewayOn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as v,g as X,h as O,j as Y}from"./chunk-
|
|
1
|
+
import{a as v,g as X,h as O,j as Y}from"./chunk-3N3EVZIL.js";import{G as H,I as J,J as K,K as q,L as B,M as Q,l as V}from"./chunk-YUHQSSAS.js";import{a as D,d as _,e as L}from"./chunk-FMEACXUH.js";import"./chunk-L5OM5ERO.js";import"./chunk-237YEYW3.js";import"./chunk-L7P5IFQO.js";import"./chunk-5D7AKUE4.js";import{a as R}from"./chunk-7WF744VP.js";import"./chunk-BLBD5NRZ.js";import"./chunk-N7J2Y6YM.js";import"./chunk-RQBSTNL7.js";import"./chunk-CQH4GPRR.js";import{$b as N,Kc as E,Rc as $,a as C,d as w,dc as F}from"./chunk-4YVIPUTR.js";import m from"chalk";var h="workspace.update";async function ke(e){await $(e,n=>re({flags:e,out:n}))}async function Ce(e,n){await $(e,a=>pe({flags:e,out:a},n))}async function Se(e,n){await $(e,a=>ce({flags:e,out:a},n))}var ee=e=>e==="off"?null:e;async function Ae(e,n,a){await $(e,r=>le({flags:e,out:r},n,a===void 0?void 0:ee(a),e.unlimited??!1,e.usd))}async function Me(e,n){await $(e,a=>ue({flags:e,out:a},n===void 0?void 0:ee(n),e.usd))}function se(e){if(!e)return null;try{let n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function ie(e,n){let a=se(e.manifest);if(!a||e.tier==="dispatch"||e.status==="pending")return null;try{return L(a)?_({manifest:a,appId:e.appSlug,gatewayNames:n,secretNames:R(e.secretNames)}).setup:null}catch{return null}}var P=(e,n)=>({id:e.id,appId:e.appSlug,name:e.name,description:e.description,status:e.status,scope:e.scope,tier:e.tier,hostname:e.hostname,everyone:e.everyone,accessCount:e.accessCount,...n===void 0?{}:{setup:n}});async function re(e){let{out:n}=e,{gateway:a,ws:r}=await v(e),u=await H(r),s=null;try{s=await D(a.cf)}catch(t){n.emit({type:"warning",code:"SETTINGS_UNKNOWN",message:`Couldn't list the Gateway's settings, so what each app needs set is unknown
|
|
2
2
|
${F(t)}`})}let p=u.map(t=>({app:t,setup:ie(t,s)})),l=E(["APP","NAME","STATUS","WHO CAN OPEN","SETUP"],p.map(({app:t,setup:o})=>[t.appSlug,t.name,t.status==="active"?m.green(t.status):m.yellow(t.status),t.scope==="shared"?"everyone, every organization":t.everyone?`everyone ${m.dim(`(${t.accessCount})`)}`:w(t.accessCount,"member"),o===null?m.dim("\u2013"):o.ready?m.green("ready"):m.yellow(`needs ${o.unmet.map(g=>g.names.join(" or ")).join(", ")}`)])),c=p.filter(({setup:t})=>t&&!t.ready);n.emit({type:"done",message:`${w(u.length,"app")} in ${r.organization.name}${c.length>0?`, ${c.length} needing setup`:""}`,display:u.length>0?l.join(`
|
|
3
3
|
`):m.dim(`No apps in ${r.organization.name} yet.`),data:{organization:r.organization,apps:p.map(({app:t,setup:o})=>P(t,o)),...c.length>0?{next:c.flatMap(({app:t,setup:o})=>o?.command?[{command:o.command.command,note:t.appSlug}]:[])}:{}}})}async function pe(e,n){let{out:a,flags:r}=e,{ws:u}=await v(e);a.emit({type:"step",step:h,status:"start",message:`Updating ${n}...`});let{app:s,granted:p}=await J(u,n,{name:r.name,description:r.description,everyone:r.everyone===void 0?void 0:r.everyone==="on"});a.emit({type:"step",step:h,status:"ok",message:`Updated ${s.appSlug}`,data:{appRowId:s.id,granted:p}});let l=[`${s.appSlug} is "${s.name}"${s.description?`: ${s.description}`:""}.`,s.scope==="shared"?"A shared app: every member of every organization can open it.":s.everyone?`Available to everyone in ${u.organization.name}${p>0?` (${w(p,"member")} granted now)`:""}; new members get it on joining.`:`Private: ${w(s.accessCount,"member")} can open it (workspace app access ${s.appSlug}).`];a.emit({type:"done",message:l.join(`
|
|
4
4
|
`),display:[l[0],m.dim(l[1])].join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{U as F,a as R,j as v,k as _,t as T}from"./chunk-
|
|
1
|
+
import{U as F,a as R,j as v,k as _,t as T}from"./chunk-L7P5IFQO.js";import{c as C,d as L}from"./chunk-BLBD5NRZ.js";import{a as I,e as E}from"./chunk-N7J2Y6YM.js";import{k as $}from"./chunk-CQH4GPRR.js";import{$b as f,a as m,ac as h,b as D,c as y,fc as g}from"./chunk-4YVIPUTR.js";async function U({whoami:t,createCf:n,accountId:e,host:o,hostFlag:a,interactive:i,pick:c=H}){let s=e||process.env.CLOUDFLARE_ACCOUNT_ID||void 0,l=(t.accounts??[]).map(r=>({id:r.id,name:r.name??null})),u=s&&!l.some(r=>r.id===s)?[...l,{id:s,name:null}]:l,d=(await Promise.all(u.map(r=>x(r,n)))).filter(r=>r!==null),w={probed:u,found:d,...s?{requestedAccountId:s}:{}};if(s)return{...w,gateway:d.find(r=>r.account.id===s)??null};if(d.length<=1)return{...w,gateway:d[0]??null};let A=o?d.filter(r=>r.install?.gatewayHost.toLowerCase()===o.toLowerCase()):[];if(A.length===1)return{...w,gateway:A[0]};if(i)return{...w,gateway:await c(d,t)};throw new h("choose_account",`Choose which Gateway to use
|
|
2
2
|
${t.email??"This login"} sees a Gateway in ${d.length} Cloudflare accounts. Run one of:`,void 0,{rerun:null,data:{choices:d.map(r=>{let p=r.install?.gatewayHost,b=a&&p;return{accountId:r.account.id,accountName:r.account.name,gatewayUrl:p?`https://${p}`:null,label:b?r.account.name??r.account.id:[r.account.name,p].filter(Boolean).join(" \xB7 "),rerun:b?`${y(a)} ${a} ${p}`:D(["--account-id",r.account.id])}})}})}async function x(t,n){let e=n(t.id);try{let o=await T(e);if(!o)return null;let a=R(e,o);return{account:t,cf:e,databaseId:o,db:a,install:await _(a)}}catch(o){if(g(o,"auth")||g(o,"not_found"))return null;throw o}}function G(t,n){if(t.gateway)return t.gateway;let e=n.email?[`Logged in to Cloudflare as ${n.email}.`]:[],o={accounts:t.probed};if(t.requestedAccountId&&t.found.length>0)throw new f("GATEWAY_NOT_FOUND",[`Cloudflare account ${t.requestedAccountId} has no Gateway`,`This login's Gateway${t.found.length===1?" is":"s are"} in ${t.found.map(Y).join("; ")}.`].join(`
|
|
3
3
|
`),{fix:"pass that account's id to --account-id (or CLOUDFLARE_ACCOUNT_ID), or drop it",data:o});if(t.probed.length===0)throw new f("GATEWAY_NOT_FOUND",["This Cloudflare login lists no accounts",...e].join(`
|
|
4
4
|
`),{fix:"pass the Gateway's account with --account-id, or set CLOUDFLARE_ACCOUNT_ID",data:o});let a=t.probed.map(i=>i.name??i.id);throw new f("GATEWAY_NOT_FOUND",[a.length===1?`No Gateway in ${a[0]}, the only account this login sees`:`No Gateway in the ${a.length} accounts this login sees`,...a.length===1?[]:[`${a.join(", ")}.`],...e,`Or log in to the Gateway's account: ${m} login`].join(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as v,b as I}from"./chunk-7QXX37OH.js";import{a as E}from"./chunk-CDTGQRJK.js";import{a as f}from"./chunk-N7J2Y6YM.js";import{b as y}from"./chunk-CQH4GPRR.js";import{Jc as g,Rc as A,a,zc as w}from"./chunk-4YVIPUTR.js";import S from"chalk";async function x(t){await _(t,(e,o)=>I(t,e,o))}async function _(t,e){let o=Date.now();await A(t,async n=>{let r=E({release:t.release,out:n,verbose:t.verbose,cliVersion:y}),i=await e(n,v({gateway:{openRelease:r.open,source:r.describe},interactive:f(t.json??!1)}));O(n,i,o)})}function O(t,e,o){let{gatewayUrl:n,organizationName:r,release:i,releaseName:p,owner:c,mode:d}=e,l=`${n}/admin`,s={gatewayUrl:n,adminUrl:l,organizationName:r,owner:c,release:i,mode:d,gateway:e.gateway,accessOn:e.accessOn},m={label:"Gateway",value:n},u=e.accessOn?[{label:"Access",value:"on",note:"everyone signs in through Cloudflare Access first"}]:[];if(e.gateway==="upgraded"&&!e.ownerCreated){t.emit({type:"done",message:`Upgraded to ${p}`,data:s,display:[...g([{label:"Gateway",value:S.cyan(n)}]),S.dim(`Upgraded to ${p} in ${w(Date.now()-o)}`)].join(`
|
|
2
|
+
`)});return}if(!c){t.emit({type:"done",data:{...s,facts:[m]}});return}if(e.gateway==="installed"||e.ownerCreated){t.emit({type:"done",data:{...s,facts:[m,{label:"Admin",value:l,note:"invite people, choose who opens which app"},...u],next:R(d,e.accessOn===!0)}});return}t.emit({type:"done",data:{...s,facts:[m,...u],...e.gateway==="up-to-date"?{next:[{command:`${a} status`,note:"see apps, domains and certificates"}]}:{}}})}function R(t,e){return t==="hosted"?[{command:`${a} create my-app`,note:"start your first app"},{command:`${a} secret set OPENAI_API_KEY`,note:"turn on AI for apps"},{command:`${a} secret set EMAIL_FROM EMAIL_FROM_NAME`,note:"email invites; needs Cloudflare Email Sending"}]:[{command:`${a} create my-app`,note:"start your first app"},...e?[]:[{command:`${a} access on`,note:"put Cloudflare Access in front of your Gateway (recommended)"}],{command:`${a} secret set OPENAI_API_KEY`,note:"AI for apps (or OPENROUTER_API_KEY, WORKERS_AI_API_TOKEN)"},{command:`${a} secret set EMAIL_FROM EMAIL_FROM_NAME`,note:"email invites and password resets; needs Cloudflare Email Sending"}]}export{x as a,_ as b,O as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d}from"./chunk-
|
|
1
|
+
import{d}from"./chunk-DCUHPZ7L.js";import{o as u,p as f}from"./chunk-RQBSTNL7.js";import{l as i,m as l}from"./chunk-CQH4GPRR.js";import{$b as a,b as c}from"./chunk-4YVIPUTR.js";function $(n,t,r){return i(n,{plane:"account",args:["dns","records","list","-z",t,"--name-exact",r,"--per-page","100"]},f)}async function v(n,t,r){await n.run({plane:"account",mode:"json",args:["dns","records","delete",r,"-z",t,"--force"]})}function y(n){return`*.${n.slice(n.indexOf(".")+1)}`}function z(n){return`${n.type}${n.content?` ${n.content}`:""}`}var p=50,g=20;function C(n){return`https://dash.cloudflare.com/${n}/domains/overview`}async function _(n,t,r){let o=d(t),e=await w(n,t,r);if(!e)throw new a("ZONE_NOT_FOUND",`No zone in this Cloudflare account holds ${t}
|
|
2
2
|
Looked for ${o.join(", ")}. Buy a domain in the dashboard (Domains, ${C(r)}), or add one you own and point its nameservers at Cloudflare.`,{fix:"use a domain that is on Cloudflare in this account"});if(e.status&&e.status!=="active")throw new a("ZONE_NOT_ACTIVE",`The Cloudflare zone ${e.name} is ${e.status}, not active`,{fix:`finish its nameserver setup (Cloudflare dashboard \u2192 ${e.name} \u2192 Overview)`,rerun:c()});return{id:e.id,name:e.name}}async function w(n,t,r){let e=(await Promise.all(d(t).map(async s=>(await i(n,{plane:"account",args:["zones","list","--name",s,"--account-id",r]},u)).find(m=>m.name.toLowerCase()===s)??null))).find(s=>s!==null);return e?{id:e.id,name:e.name.toLowerCase(),status:e.status??null}:null}function A(n,t){return`https://dash.cloudflare.com/${n}/${t}`}async function D(n,t){return(await l(n,["zones","list","--account-id",t],u,{perPage:p,maxPages:g})).map(o=>({id:o.id,name:o.name.toLowerCase(),status:o.status??null}))}export{$ as a,v as b,y as c,z as d,C as e,_ as f,w as g,A as h,D as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as m,k as d}from"./chunk-
|
|
1
|
+
import{j as m,k as d}from"./chunk-YUHQSSAS.js";import{c as l,e as p}from"./chunk-237YEYW3.js";import{a as i}from"./chunk-N7J2Y6YM.js";import{$b as o}from"./chunk-4YVIPUTR.js";import s from"chalk";async function b(e){let{flags:t,out:r,createCf:n}=e,a=await p({gateway:l(t.gateway),accountId:t["account-id"],interactive:i(t.json??!1),login:{json:t.json,out:r,step:"login"},createCf:n}),g=await m(a.db,a.deployer,{org:t.org,now:e.now?.()});return{gateway:a,ws:g,gatewayUrl:a.gatewayUrl}}function x(e){return e.interactive??i(e.flags.json??!1)}async function W(e,t){try{let r=await d(e,t);return{id:r.id,email:r.email,member:!0}}catch(r){if(!(r instanceof o)||r.code!=="USER_NOT_FOUND"||t.includes("@"))throw r;return{id:t.trim(),email:null,member:!1}}}var v=e=>e.member?e.email??e.id:`${e.id} (no longer a member)`;function F(e){return e===null?s.dim("never"):new Date(e).toISOString().slice(0,16).replace("T"," ")}var c=e=>e===null?null:new Date(e).toISOString();function C(e){return e.deactivated?s.yellow("deactivated"):s.green("active")}function h(e){return{id:e.id,email:e.email,name:e.name,role:e.primaryRole??e.role,deactivated:e.deactivated,createdAt:c(e.createdAt)}}function O(e){return{id:e.id,email:e.email,role:e.role,status:e.status,expiresAt:c(e.expiresAt),expired:!e.live&&e.status==="pending",createdAt:c(e.createdAt)}}function A(e){let{add:t,remove:r,set:n}=e;if(n&&(t||r))throw new o("FLAGS_CONFLICT","--set replaces the whole list: give it alone, or --add and --remove without it");return!t&&!r&&!n?{change:null}:{change:{add:t,remove:r,set:n}}}export{b as a,x as b,W as c,v as d,F as e,c as f,C as g,h,O as i,A as j};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as y}from"./chunk-DCUHPZ7L.js";import{h as w}from"./chunk-SSDMYDPY.js";import{$b as a,Zb as d,_b as c}from"./chunk-4YVIPUTR.js";import m from"node:fs/promises";import s from"node:path";import{OutputWorkerSchema as E}from"@cloudflare/config";import f from"node:fs/promises";import p from"node:path";var D=p.join(".cloudflare","output","v0"),g=p.join(D,"workers"),A="default";async function*j(t){let e=p.join(t,g);for(let r of await f.readdir(e,{withFileTypes:!0})){if(!r.isDirectory())continue;let o=p.join(e,r.name),n=p.join(o,"worker.config.json"),l=JSON.parse(await f.readFile(n,"utf8"));yield{name:r.name,directory:o,file:n,config:l}}}async function W(t){let e=JSON.parse(await f.readFile(p.join(t,"config.json"),"utf8"));return e.buildContext?.mode==="production"&&!e.buildContext.isPreview}var _=s.join(g,A),I=s.join(_,"worker.config.json"),R=s.join(_,"bundle"),O="__EVERYAPP_PATCH__",v="every-app-gateway";function k(t){return[t.gatewayHost,...[...new Set(t.appHosts)].filter(e=>e!==t.gatewayHost).sort()]}async function G(t,e){let r=s.join(t,I),o=JSON.parse(await m.readFile(r,"utf8")),n={...o.env??{}};for(let i of Object.keys(n))i.startsWith(d)&&delete n[i];delete n.KV,n.DB={type:"d1",name:v,id:e.d1Id},n.OAUTH_KV={type:"kv",id:e.oauthKvId},n.EVERYAPP_RELEASE={type:"json",value:e.release},n.CF_VERSION_METADATA={type:"version-metadata"};for(let i of[...new Set(e.appWorkers)].sort())n[c(i)]={type:"worker",worker:i};if(o.env=n,e.gatewayHost!==e.appBaseDomain)throw new a("INVALID_APP_BASE_DOMAIN",`Apps live one label below the gateway host ${e.gatewayHost}, so APP_BASE_DOMAIN must be ${e.gatewayHost}, not ${e.appBaseDomain}.`);let l=e.appHosts.filter(i=>!y(i,e.appBaseDomain));if(l.length>0)throw new a("INVALID_APP_HOST",`Refusing to publish ${l.join(", ")} on the gateway: app hosts are one label below ${e.appBaseDomain}.`);n.APP_BASE_DOMAIN={type:"text",value:e.appBaseDomain},o.domains=k(e);let u=(o.triggers??[]).filter(i=>i.type!=="fetch");if(u.length>0?o.triggers=u:delete o.triggers,o.workersDev=!1,o.previewUrls=!1,o.observability??=structuredClone(w),o.manifest){let i={...o.manifest.modules??{}};for(let P of await h(s.join(t,R)))i[P]={type:"sourcemap"};o.manifest={...o.manifest,modules:i}}return T(o,{requireDomain:!0}),await m.writeFile(r,`${JSON.stringify(o,null,2)}
|
|
2
|
+
`),o}function T(t,{requireDomain:e=!1}={}){let r=E.safeParse(t);if(!r.success)throw new a("INVALID_BUILD_OUTPUT",`The patched Worker config isn't valid Build Output: ${r.error.issues.map(o=>`${o.path.join(".")||"(root)"}: ${o.message}`).join("; ")}`);if(JSON.stringify(t).includes(O))throw new a("INVALID_BUILD_OUTPUT","The Worker config still has a deploy-time placeholder.");if(e&&!r.data.domains?.length)throw new a("INVALID_BUILD_OUTPUT","The gateway has no domain to deploy to.")}async function h(t){let e;try{e=await m.readdir(t,{recursive:!0,withFileTypes:!0})}catch{return[]}return e.filter(r=>r.isFile()&&r.name.endsWith(".map")).map(r=>s.relative(t,s.join(r.parentPath,r.name)).split(s.sep).join("/")).sort()}export{D as a,A as b,j as c,W as d,k as e,G as f,T as g,h};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as B,b as H,d as z,e as j,f as q}from"./chunk-CDTGQRJK.js";import{a as x,b as M}from"./chunk-QWBCJXRO.js";import{a as U}from"./chunk-TMJCBQDC.js";import{a as F}from"./chunk-D5HKHQTL.js";import{aa as V,ea as O,k as I}from"./chunk-L7P5IFQO.js";import{a as G,e as N,g as v,k as W}from"./chunk-5D7AKUE4.js";import{e as C}from"./chunk-7WF744VP.js";import{b as D}from"./chunk-CQH4GPRR.js";import{$b as b,Ac as E,_b as A,a as L}from"./chunk-4YVIPUTR.js";import $ from"node:fs";import P from"node:path";function K({install:e,out:t,verbose:i,cliVersion:a,checkoutRoot:s=F,fetch:c}){let m=B({out:t,verbose:i,cliVersion:a,checkoutRoot:s,fetch:c});if(!e)return m;let u=s(),r=e.releaseOrigin??{kind:"checkout"},g={version:e.releaseVersion,sha256:e.releaseSha256,order:e.releaseOrder,treeSha256:e.sourceTreeSha256,origin:r},f=r.kind==="checkout"&&u&&e.sourceTreeSha256?P.join(U(u),`${e.sourceTreeSha256}.tar.gz`):null,y=()=>{switch(r.kind){case"github":case"url":return!0;case"file":return $.existsSync(r.path);case"checkout":return f!==null&&$.existsSync(f)}},d=!1,l=o=>(d||(d=!0,t.emit({type:"step",step:"gateway.release",status:"start",message:`The live Gateway ${e.releaseVersion} (from ${v(r)}) can't be taken again: ${o}. Deploying ${u?"this checkout's Gateway":"the published release for this everyapp"} instead.`,data:{live:e.releaseVersion,origin:r,why:o}})),m),h=null,p=()=>h??=(async()=>{switch(r.kind){case"github":{let o=await x({repo:r.repo,asset:G,tag:r.tag,fetch:c});return process.once("exit",()=>$.rmSync(P.dirname(o.tarball),{recursive:!0,force:!0})),o}case"url":{let o=await M(r.url,{fetch:c});return process.once("exit",()=>$.rmSync(P.dirname(o.tarball),{recursive:!0,force:!0})),o}case"file":return{tarball:r.path,cleanup:async()=>{}};case"checkout":return{tarball:f,cleanup:async()=>{}}}})(),n=async()=>{let{tarball:o}=await p(),k=r.kind==="checkout"?{origin:r,treeSha256:e.sourceTreeSha256,committedAt:e.releaseOrder.committedAt}:{origin:r},w=await W(o,k);return w.manifest.sha256!==e.releaseSha256?t.emit({type:"warning",code:"GATEWAY_RELEASE_DIFFERS",step:"gateway.release",message:`The Gateway release at ${v(r)} isn't the one that is live any more (its SHA-256 changed)
|
|
2
|
+
Deploying it as an update; a Gateway older than the live one is refused.`,data:{origin:r,live:e.releaseSha256,found:w.manifest.sha256}}):t.emit({type:"step",step:"gateway.release",status:"ok",message:`Using the live Gateway ${w.manifest.version} from ${v(r)}`,data:{release:w.manifest.version,origin:r,sha256:w.manifest.sha256,live:!0}}),w};return{async describe(){return y()?g:l(Y(r,u)).describe()},async open(){if(!y())return l(Y(r,u)).open();try{return await n()}catch(o){if(Q(o))return l(`${v(r)} can't be downloaded any more`).open();throw o}}}}function Y(e,t){switch(e.kind){case"file":return`${e.path} is gone`;case"checkout":return t?"this checkout hasn't built that tree (its build cache keeps the last few builds)":"it was built from a checkout, and this everyapp isn't running from one";default:return"it is out of reach"}}function Q(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="RELEASE_NOT_FOUND"}var R="app.live",Z=6e5,ee=3e3,te=15e3;var T={["deploy"]:"uploaded and bound"};async function J({db:e,appRowId:t,appId:i,hostname:a,out:s,verb:c,fetch:m,localDns:u=m?void 0:j,sleep:r=d=>new Promise(l=>setTimeout(l,d)),maxWaitMs:g=Z,intervalMs:f=ee,now:y=Date.now}){let d=`https://${a}/`,l=y(),h=!1,p=!1,n=null,o,k=async()=>(h&&u&&await q({host:a,lead:`${i} is live at https://${a}`,out:s,step:R,localDns:u}),{outcome:"live",waited:o});for(;;){let w=await X(e,t,i);if(w==="active")return k();if(w==="disabled")return s.emit({type:"warning",code:"APP_DISABLED",step:R,message:`${i} is switched off in Admin \u2192 Apps
|
|
3
|
+
It's ${T[c]}; the Gateway serves it once an admin turns it on.`}),{outcome:"disabled"};if(!p){let _=await z(d,m);if(_.answered){if(h=!0,_.access)p=!0,n=null;else if(await X(e,t,i)==="active")return k()}}let S=y()-l;if(S>=g){if(!h)return s.emit({type:"warning",code:"CERT_PENDING",step:R,message:`No certificate for ${a} after ${E(S)}
|
|
4
|
+
It usually comes within 5 minutes; ${i} goes live on its first visit once it has one.`,data:{hostname:a,fix:"if it never comes, check the zone's CAA records allow Cloudflare's certificate authorities"}}),{outcome:"first_visit"};if(p)return s.emit({type:"warning",code:"ACCESS_IN_FRONT",step:R,message:`Cloudflare Access answers before the Gateway, and the Gateway hasn't made ${i} live after ${E(S)}
|
|
5
|
+
The deploy stalled: the Gateway should have reached ${i}'s Worker within a minute of the upload. ${i} stays ${T[c]}; opening https://${a} signed in through Access finishes it when the Gateway can reach it.`,data:{hostname:a,rerun:`${L} status`,rerunNote:`then ${c} again`}}),{outcome:"first_visit"};throw new b("APP_NOT_LIVE",`${i} isn't live after ${E(S)}: the Gateway can't reach its Worker yet
|
|
6
|
+
${i} stays ${T[c]}.`,{retryable:!0,rerun:`${L} status`,rerunNote:`then ${c} again`})}(n===null||y()-n>=te)&&(o=h?"live":"certificate",s.emit({type:"progress",step:R,message:p?`Cloudflare Access answers before the Gateway; waiting for the Gateway to make ${i} live (it looks every minute)`:h?`Waiting for ${i} to go live`:`Waiting for the certificate for ${a} (usually under 5m)`,data:{hostname:a,waitedMs:S,answered:h,...p?{access:!0}:{}}}),n=y()),await r(f)}}async function X(e,t,i){let a=await O(e,t);if(!a||a.status===C)throw new b("APP_NOT_FOUND",`${i} was deleted during this run
|
|
7
|
+
Someone removed it from the Gateway while this run waited for it to go live.`,{retryable:!0,rerunNote:"to put it back"});return a.status}function Te(e,t,i,a){let s=K({install:t,out:i,verbose:a,cliVersion:D});return{openRelease:e?.openRelease??s.open,source:e?.source??s.describe}}function ae(e,t){return e.sha256!==void 0?e.sha256===t.releaseSha256||e.treeSha256!==null&&e.treeSha256===t.sourceTreeSha256:e.treeSha256!==null?e.treeSha256===t.sourceTreeSha256:e.version===t.releaseVersion}function _e(e,{manifest:t,install:i,deployer:a,accountName:s}){return V(e,{appSlug:t.id,name:t.name??t.id,description:t.description??t.id,manifest:t,appBaseDomain:i.appBaseDomain,deployer:a,organizationName:s??""})}var re={["deploy"]:"This app's upload is kept; deploying again binds it and makes it live."};async function Ge({cf:e,db:t,databaseId:i,out:a,accountId:s,appId:c,workerName:m,publishHost:u,interactive:r,forceDns:g,seams:f,verb:y}){let d=await I(t);if(d?.liveAppWorkers.includes(m)&&!u)return;a.emit({type:"step",step:"app.bind",status:"start",message:`Binding ${A(m)} on the gateway${u?" and publishing its hostname":""}...`,data:{appId:c}});let l=await f.source?.(),h=l!==void 0&&d!==null&&!ae(l,d),p=l?.version;if(h){let n=p===d.releaseVersion;a.emit({type:"step",step:"gateway.upgrade",status:"start",message:n?`Redeploying the Gateway ${p} from ${v(l.origin)} (${N(l)}; not the live release)...`:`Upgrading the Gateway ${d.releaseVersion} \u2192 ${p}...`,data:{from:d.releaseVersion,to:p,origin:l.origin,sameVersion:n}})}try{let n=await H({cf:e,out:a,accountId:s,databaseId:i,interactive:r,cliVersion:D,force:!0,forceDns:g,...f});h&&a.emit({type:"step",step:"gateway.upgrade",status:"ok",data:{to:p}}),a.emit({type:"step",step:"app.bind",status:"ok",message:`The gateway binds ${A(m)} (gateway version ${n.versionId??"unknown"}).`,data:{versionId:n.versionId,newHosts:n.newHosts}})}catch(n){throw n instanceof b&&n.code==="LEASE_HELD"?new b("LEASE_HELD",`${n.message}
|
|
8
|
+
${re[y]}`,{retryable:!0,rerunNote:"once the other deploy finishes",data:n.data}):n}}async function Ne({wait:e,db:t,appRowId:i,appId:a,hostname:s,out:c,seams:m,message:u,verb:r}){if(!e)return!1;let{outcome:g,waited:f}=await J({db:t,appRowId:i,appId:a,hostname:s,out:c,verb:r,...m});return g!=="live"?!1:(c.emit({type:"step",step:"app.live",status:"ok",message:u,data:{hostname:s,url:`https://${s}`,...f?{waited:f}:{}}}),!0)}function We(e){return{url:e.liveUrl,workerName:e.workerName,versionId:e.versionId,live:e.live}}export{Te as a,_e as b,Ge as c,Ne as d,We as e};
|