gemi 0.113.0 → 0.114.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +32 -32
- package/dist/ai/index.js.map +3 -5
- package/dist/app/App.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/bin/gemi.js +8 -1
- package/dist/bin/gemi.js.map +3 -3
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/chunk-0n9vs1ad.js +14 -0
- package/dist/{chunk-cqnfp0n9.js.map → chunk-0n9vs1ad.js.map} +4 -4
- package/dist/{chunk-68s1f5d5.js → chunk-1f9sqht5.js} +2 -2
- package/dist/{chunk-68s1f5d5.js.map → chunk-1f9sqht5.js.map} +1 -1
- package/dist/{chunk-qt8nvpqp.js → chunk-1p0dazvk.js} +2 -2
- package/dist/{chunk-qt8nvpqp.js.map → chunk-1p0dazvk.js.map} +1 -1
- package/dist/{chunk-3f1kq32g.js → chunk-2rphhsr7.js} +2 -2
- package/dist/{chunk-3f1kq32g.js.map → chunk-2rphhsr7.js.map} +1 -1
- package/dist/{chunk-qx87cdfg.js → chunk-2z1981d0.js} +2 -2
- package/dist/{chunk-qx87cdfg.js.map → chunk-2z1981d0.js.map} +1 -1
- package/dist/{chunk-zng3qexn.js → chunk-329ggbcw.js} +2 -2
- package/dist/{chunk-zng3qexn.js.map → chunk-329ggbcw.js.map} +1 -1
- package/dist/{chunk-v4gwmhtf.js → chunk-37qk5dh8.js} +2 -2
- package/dist/{chunk-v4gwmhtf.js.map → chunk-37qk5dh8.js.map} +1 -1
- package/dist/{chunk-7jnpnjth.js → chunk-3ma9m432.js} +2 -2
- package/dist/{chunk-7jnpnjth.js.map → chunk-3ma9m432.js.map} +1 -1
- package/dist/{chunk-fnkjmq94.js → chunk-4szjp84e.js} +2 -2
- package/dist/{chunk-fnkjmq94.js.map → chunk-4szjp84e.js.map} +1 -1
- package/dist/{chunk-fr0arqdj.js → chunk-56fgk5rq.js} +2 -2
- package/dist/{chunk-fr0arqdj.js.map → chunk-56fgk5rq.js.map} +1 -1
- package/dist/{chunk-y6v0x869.js → chunk-583vxa2v.js} +2 -2
- package/dist/{chunk-y6v0x869.js.map → chunk-583vxa2v.js.map} +1 -1
- package/dist/{chunk-vqa3agzw.js → chunk-5j76r5q8.js} +3 -3
- package/dist/{chunk-vqa3agzw.js.map → chunk-5j76r5q8.js.map} +1 -1
- package/dist/chunk-60nyk1w8.js +10 -0
- package/dist/chunk-60nyk1w8.js.map +38 -0
- package/dist/{chunk-vwprq300.js → chunk-6h9j3f1x.js} +2 -2
- package/dist/{chunk-vwprq300.js.map → chunk-6h9j3f1x.js.map} +1 -1
- package/dist/{chunk-r7b12dmm.js → chunk-75wk4jxd.js} +2 -2
- package/dist/{chunk-r7b12dmm.js.map → chunk-75wk4jxd.js.map} +1 -1
- package/dist/{chunk-de03dewf.js → chunk-7fwp7vwh.js} +2 -2
- package/dist/{chunk-de03dewf.js.map → chunk-7fwp7vwh.js.map} +1 -1
- package/dist/{chunk-9vsj0ksk.js → chunk-7rmjr8p7.js} +3 -3
- package/dist/{chunk-9vsj0ksk.js.map → chunk-7rmjr8p7.js.map} +1 -1
- package/dist/{chunk-atmzm0z3.js → chunk-7v8sgqen.js} +2 -2
- package/dist/{chunk-atmzm0z3.js.map → chunk-7v8sgqen.js.map} +1 -1
- package/dist/{chunk-4t1pbt9p.js → chunk-8c2fs0n0.js} +3 -3
- package/dist/{chunk-4t1pbt9p.js.map → chunk-8c2fs0n0.js.map} +1 -1
- package/dist/{chunk-vzf5pbx3.js → chunk-8h7dh2h2.js} +2 -2
- package/dist/{chunk-vzf5pbx3.js.map → chunk-8h7dh2h2.js.map} +1 -1
- package/dist/{chunk-c7mp2kyp.js → chunk-8k8534kg.js} +2 -2
- package/dist/{chunk-c7mp2kyp.js.map → chunk-8k8534kg.js.map} +1 -1
- package/dist/{chunk-g8kx549d.js → chunk-8rt4wx8z.js} +3 -3
- package/dist/{chunk-g8kx549d.js.map → chunk-8rt4wx8z.js.map} +1 -1
- package/dist/{chunk-bq5nqqeq.js → chunk-a5sbgffr.js} +1 -1
- package/dist/{chunk-szr1k584.js → chunk-ap5gek56.js} +2 -2
- package/dist/{chunk-szr1k584.js.map → chunk-ap5gek56.js.map} +1 -1
- package/dist/{chunk-4tp2cr02.js → chunk-awp3n119.js} +2 -2
- package/dist/{chunk-4tp2cr02.js.map → chunk-awp3n119.js.map} +1 -1
- package/dist/{chunk-5q4a7yqf.js → chunk-cna105t6.js} +2 -2
- package/dist/{chunk-5q4a7yqf.js.map → chunk-cna105t6.js.map} +1 -1
- package/dist/{chunk-rg4hhxj3.js → chunk-d4m4amy4.js} +2 -2
- package/dist/{chunk-rg4hhxj3.js.map → chunk-d4m4amy4.js.map} +1 -1
- package/dist/{chunk-8mbyyh8j.js → chunk-e6fp6dxx.js} +2 -2
- package/dist/{chunk-8mbyyh8j.js.map → chunk-e6fp6dxx.js.map} +1 -1
- package/dist/{chunk-1se4t9rg.js → chunk-e7axa0d5.js} +3 -3
- package/dist/{chunk-1se4t9rg.js.map → chunk-e7axa0d5.js.map} +1 -1
- package/dist/{chunk-9tpx9ag3.js → chunk-erxv1jz7.js} +2 -2
- package/dist/{chunk-9tpx9ag3.js.map → chunk-erxv1jz7.js.map} +1 -1
- package/dist/chunk-fakvf9wb.js +5 -0
- package/dist/{chunk-fsfbyg5e.js.map → chunk-fakvf9wb.js.map} +1 -1
- package/dist/{chunk-nysqgzp1.js → chunk-fv9mr1t4.js} +2 -2
- package/dist/{chunk-nysqgzp1.js.map → chunk-fv9mr1t4.js.map} +1 -1
- package/dist/{chunk-p3zmc8k8.js → chunk-gdmsn3f5.js} +2 -2
- package/dist/{chunk-p3zmc8k8.js.map → chunk-gdmsn3f5.js.map} +1 -1
- package/dist/{chunk-y6frz1vm.js → chunk-gv91vjeb.js} +1 -1
- package/dist/{chunk-5x0aacrn.js → chunk-h2r2rdhj.js} +2 -2
- package/dist/{chunk-5x0aacrn.js.map → chunk-h2r2rdhj.js.map} +1 -1
- package/dist/{chunk-1p85fdrk.js → chunk-h4pazcgg.js} +2 -2
- package/dist/{chunk-1p85fdrk.js.map → chunk-h4pazcgg.js.map} +1 -1
- package/dist/{chunk-mk0rtgd1.js → chunk-hrvzchxd.js} +2 -2
- package/dist/{chunk-mk0rtgd1.js.map → chunk-hrvzchxd.js.map} +1 -1
- package/dist/{chunk-w45agtch.js → chunk-hytt9qyj.js} +2 -2
- package/dist/{chunk-w45agtch.js.map → chunk-hytt9qyj.js.map} +1 -1
- package/dist/{chunk-5nqkwa2w.js → chunk-hz6yzzbz.js} +1 -1
- package/dist/{chunk-z5hrymvn.js → chunk-j3nr4cg0.js} +3 -3
- package/dist/{chunk-z5hrymvn.js.map → chunk-j3nr4cg0.js.map} +1 -1
- package/dist/{chunk-dbwhgyg3.js → chunk-jk97wv0q.js} +2 -2
- package/dist/{chunk-dbwhgyg3.js.map → chunk-jk97wv0q.js.map} +1 -1
- package/dist/{chunk-x5sert1k.js → chunk-jv4g8grc.js} +2 -2
- package/dist/{chunk-x5sert1k.js.map → chunk-jv4g8grc.js.map} +1 -1
- package/dist/{chunk-yyzexrnb.js → chunk-jyrsd1dn.js} +2 -2
- package/dist/{chunk-yyzexrnb.js.map → chunk-jyrsd1dn.js.map} +1 -1
- package/dist/{chunk-y596ghpz.js → chunk-jzp0fs6h.js} +2 -2
- package/dist/{chunk-y596ghpz.js.map → chunk-jzp0fs6h.js.map} +1 -1
- package/dist/{chunk-kz4yp5n7.js → chunk-kcx468qv.js} +2 -2
- package/dist/{chunk-kz4yp5n7.js.map → chunk-kcx468qv.js.map} +1 -1
- package/dist/{chunk-zyer1g7k.js → chunk-kg1nbxvm.js} +4 -4
- package/dist/{chunk-zyer1g7k.js.map → chunk-kg1nbxvm.js.map} +1 -1
- package/dist/{chunk-qpttgn4k.js → chunk-kqb4s1r0.js} +3 -3
- package/dist/{chunk-qpttgn4k.js.map → chunk-kqb4s1r0.js.map} +1 -1
- package/dist/{chunk-rh2fad7n.js → chunk-m17ktssc.js} +1 -1
- package/dist/{chunk-k2fh4r0p.js → chunk-m2yfvwrn.js} +2 -2
- package/dist/{chunk-k2fh4r0p.js.map → chunk-m2yfvwrn.js.map} +1 -1
- package/dist/{chunk-wr3e4sez.js → chunk-mqcy5vja.js} +2 -2
- package/dist/{chunk-wr3e4sez.js.map → chunk-mqcy5vja.js.map} +1 -1
- package/dist/{chunk-f1y8eggf.js → chunk-n672d4g8.js} +2 -2
- package/dist/{chunk-f1y8eggf.js.map → chunk-n672d4g8.js.map} +1 -1
- package/dist/{chunk-xqwdn9kb.js → chunk-nek1gzz2.js} +3 -3
- package/dist/{chunk-xqwdn9kb.js.map → chunk-nek1gzz2.js.map} +1 -1
- package/dist/{chunk-01qd6xx3.js → chunk-pmywkp1w.js} +3 -3
- package/dist/{chunk-01qd6xx3.js.map → chunk-pmywkp1w.js.map} +1 -1
- package/dist/chunk-q95k1ymq.js +4 -0
- package/dist/{chunk-kp7k4s5c.js.map → chunk-q95k1ymq.js.map} +3 -3
- package/dist/{chunk-vdwagp7y.js → chunk-r4namj39.js} +2 -2
- package/dist/{chunk-vdwagp7y.js.map → chunk-r4namj39.js.map} +1 -1
- package/dist/{chunk-571rvxe6.js → chunk-rrqr1dwq.js} +2 -2
- package/dist/{chunk-571rvxe6.js.map → chunk-rrqr1dwq.js.map} +1 -1
- package/dist/{chunk-sr18y2ck.js → chunk-tp3mzj4v.js} +2 -2
- package/dist/{chunk-sr18y2ck.js.map → chunk-tp3mzj4v.js.map} +1 -1
- package/dist/{chunk-6wymbbes.js → chunk-ty4aj41k.js} +3 -3
- package/dist/{chunk-6wymbbes.js.map → chunk-ty4aj41k.js.map} +1 -1
- package/dist/chunk-v9na3dny.js +46 -0
- package/dist/{chunk-6g20zec2.js.map → chunk-v9na3dny.js.map} +6 -6
- package/dist/{chunk-d04r0hdf.js → chunk-w2fpr99k.js} +2 -2
- package/dist/{chunk-d04r0hdf.js.map → chunk-w2fpr99k.js.map} +1 -1
- package/dist/{chunk-vc9phr57.js → chunk-wwmdqhzy.js} +2 -2
- package/dist/{chunk-vc9phr57.js.map → chunk-wwmdqhzy.js.map} +1 -1
- package/dist/chunk-wysm6qte.js +5 -0
- package/dist/chunk-wysm6qte.js.map +12 -0
- package/dist/{chunk-mepaedy5.js → chunk-x157wrgy.js} +2 -2
- package/dist/{chunk-mepaedy5.js.map → chunk-x157wrgy.js.map} +1 -1
- package/dist/{chunk-nksn6xcd.js → chunk-xrh6k13s.js} +2 -2
- package/dist/{chunk-nksn6xcd.js.map → chunk-xrh6k13s.js.map} +1 -1
- package/dist/{chunk-g8sc6scv.js → chunk-y0wx6w80.js} +2 -2
- package/dist/{chunk-g8sc6scv.js.map → chunk-y0wx6w80.js.map} +1 -1
- package/dist/{chunk-kexsfyjj.js → chunk-yp5979we.js} +2 -2
- package/dist/{chunk-kexsfyjj.js.map → chunk-yp5979we.js.map} +1 -1
- package/dist/{chunk-essqp1ek.js → chunk-z32xfe8c.js} +2 -2
- package/dist/{chunk-essqp1ek.js.map → chunk-z32xfe8c.js.map} +1 -1
- package/dist/{chunk-x5yq097b.js → chunk-zgn0p8qr.js} +3 -3
- package/dist/{chunk-x5yq097b.js.map → chunk-zgn0p8qr.js.map} +1 -1
- package/dist/{chunk-agw3anaf.js → chunk-zns7xcz9.js} +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/HttpRequest.d.ts +31 -0
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/McpRouter.d.ts +54 -1
- package/dist/http/McpRouter.d.ts.map +1 -1
- package/dist/http/RateLimitMiddleware.d.ts +4 -1
- package/dist/http/RateLimitMiddleware.d.ts.map +1 -1
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/http/modelOriginated.d.ts +36 -2
- package/dist/http/modelOriginated.d.ts.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/kernel/Kernel.d.ts +3 -0
- package/dist/kernel/Kernel.d.ts.map +1 -1
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +3 -3
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.d.ts +6 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +44 -9
- package/dist/services/index.js.map +6 -3
- package/dist/services/mcp/McpRegistry.d.ts +190 -29
- package/dist/services/mcp/McpRegistry.d.ts.map +1 -1
- package/dist/services/mcp/http/McpHttpServer.d.ts +153 -0
- package/dist/services/mcp/http/McpHttpServer.d.ts.map +1 -0
- package/dist/services/mcp/http/callers.d.ts +131 -0
- package/dist/services/mcp/http/callers.d.ts.map +1 -0
- package/dist/services/mcp/http/limits.d.ts +11 -0
- package/dist/services/mcp/http/limits.d.ts.map +1 -0
- package/dist/services/mcp/http/oauth/McpOAuthServer.d.ts +150 -0
- package/dist/services/mcp/http/oauth/McpOAuthServer.d.ts.map +1 -0
- package/dist/services/mcp/http/oauth/consentPage.d.ts +14 -0
- package/dist/services/mcp/http/oauth/consentPage.d.ts.map +1 -0
- package/dist/services/mcp/http/oauth/store.d.ts +98 -0
- package/dist/services/mcp/http/oauth/store.d.ts.map +1 -0
- package/dist/services/mcp/http/protocol.d.ts +95 -0
- package/dist/services/mcp/http/protocol.d.ts.map +1 -0
- package/dist/services/mcp/http/signedState.d.ts +25 -0
- package/dist/services/mcp/http/signedState.d.ts.map +1 -0
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/ApiRouteDispatcher.d.ts +29 -0
- package/dist/services/router/ApiRouteDispatcher.d.ts.map +1 -1
- package/dist/services/router/RouteServiceProvider.d.ts +6 -0
- package/dist/services/router/RouteServiceProvider.d.ts.map +1 -1
- package/dist/services/router/config.d.ts +16 -0
- package/dist/services/router/config.d.ts.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/vitest/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3z9vhjd7.js +0 -5
- package/dist/chunk-3z9vhjd7.js.map +0 -10
- package/dist/chunk-5zzhypmt.js +0 -5
- package/dist/chunk-5zzhypmt.js.map +0 -33
- package/dist/chunk-6g20zec2.js +0 -46
- package/dist/chunk-cqnfp0n9.js +0 -14
- package/dist/chunk-fsfbyg5e.js +0 -5
- package/dist/chunk-kp7k4s5c.js +0 -4
- /package/dist/{chunk-bq5nqqeq.js.map → chunk-a5sbgffr.js.map} +0 -0
- /package/dist/{chunk-y6frz1vm.js.map → chunk-gv91vjeb.js.map} +0 -0
- /package/dist/{chunk-5nqkwa2w.js.map → chunk-hz6yzzbz.js.map} +0 -0
- /package/dist/{chunk-rh2fad7n.js.map → chunk-m17ktssc.js.map} +0 -0
- /package/dist/{chunk-agw3anaf.js.map → chunk-zns7xcz9.js.map} +0 -0
package/dist/chunk-cqnfp0n9.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{tg as z,ug as n,vg as i}from"./chunk-r7b12dmm.js";import{yg as C}from"./chunk-y596ghpz.js";import{Fh as x0}from"./chunk-z5hrymvn.js";import{Rh as f}from"./chunk-fr0arqdj.js";import{Yh as PH}from"./chunk-8mbyyh8j.js";class U0{static kind="controller";constructor(){}}class f0 extends U0{}function r(H){let G=new Map;if(!H)return G;for(let Q of H.split(";")){let Z=Q.indexOf("=");if(Z===-1)continue;let X=Q.slice(0,Z).trim();if(!X)continue;G.set(X,Q.slice(Z+1).trim())}return G}function NH(H){return r(H.headers.get("cookie"))}function I(H){if(!/^\d+$/.test(H))return null;let G=Number(H);return Number.isSafeInteger(G)?G:null}function K0(H){if(!H)return null;let G=H.trim();if(!/^bytes=/i.test(G))return null;let Z=G.slice(6).split(",").map((K)=>K.trim()).filter((K)=>K!=="");if(Z.length!==1)return null;let X=Z[0],$=X.indexOf("-");if($===-1)return null;let W=X.slice(0,$),Y=X.slice($+1);if(W===""){let K=I(Y);if(K===null)return null;return{kind:"suffix",suffixLength:K}}let D=I(W);if(D===null)return null;if(Y==="")return{kind:"offset",start:D,end:null};let T=I(Y);if(T===null||T<D)return null;return{kind:"offset",start:D,end:T}}function P0(H,G){if(!Number.isFinite(G)||G<=0)return null;let Q,Z;if(H.kind==="suffix"){if(H.suffixLength<=0)return null;Q=Math.max(0,G-H.suffixLength),Z=G-1}else{if(H.start>=G)return null;if(Q=H.start,Z=H.end===null?G-1:Math.min(H.end,G-1),Z<Q)return null}return{start:Q,end:Z,length:Z-Q+1}}function xH(H){if(H.kind==="suffix")return`bytes=-${H.suffixLength}`;return H.end===null?`bytes=${H.start}-`:`bytes=${H.start}-${H.end}`}function EH(H){if(!H)return null;let G=/^bytes\s+(\d+)-(\d+)\/(\d+)$/i.exec(H.trim());if(!G)return null;let Q=I(G[1]),Z=I(G[2]),X=I(G[3]);if(Q===null||Z===null||X===null||Z<Q)return null;return{start:Q,end:Z,total:X}}function SH(H,G,Q){return`bytes ${H}-${G}/${Q}`}function B0(H){return`bytes */${H}`}class x extends z{errors={};constructor(H){super("Validation error");this.name="ValidationError",this.errors=H,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:H,status:400}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}function v0(H){let[G,Q]=H.match(/\d+|\D+/g)??[];if(!G||!Q)return 0;let Z=Number.parseInt(G);switch(Q){case"B":return Z;case"KB":return Z*1024;case"MB":return Z*1024*1024;case"GB":return Z*1024*1024*1024;case"TB":return Z*1024*1024*1024*1024;default:return 0}}function p0(H){switch(H){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return H}}function z0(H){if(typeof H==="string"||Array.isArray(H))return H.length;return}function s(H){return typeof H==="number"&&!Number.isNaN(H)}var h0=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class L extends Error{name="InvalidValidationRuleError"}function p(H,G){let Q=G===void 0||G.trim()===""?Number.NaN:Number(G);if(Number.isNaN(Q))throw new L(`Validation rule "${H}:${G??""}" needs a number, e.g. "${H}:3"`);return Q}function F0(H){let G=H.indexOf(":"),Q=G===-1?H:H.slice(0,G),Z=G===-1?void 0:H.slice(G+1);switch(Q){case"required":return(X)=>{if(X instanceof Blob)return X.size>0;if(X===null||X===void 0)return!1;if(typeof X==="string"||Array.isArray(X))return X.length>0;return!0};case"string":return(X)=>typeof X==="string";case"boolean":return(X)=>typeof X==="boolean";case"number":return(X)=>s(X);case"password":return(X)=>{return typeof X==="string"&&/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(X)};case"min":{let X=p(Q,Z);return($)=>{let W=z0($);return W!==void 0&&W>=X}}case"max":{let X=p(Q,Z);return($)=>{let W=z0($);return W!==void 0&&W<=X}}case"gte":{let X=p(Q,Z);return($)=>s($)&&$>=X}case"lte":{let X=p(Q,Z);return($)=>s($)&&$<=X}case"email":return(X)=>{return typeof X==="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(X)};case"file":return(X)=>{return X instanceof Blob};case"fileType":{if(!Z)throw new L('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let X=p0(Z);return($)=>$ instanceof Blob&&$.type.startsWith(X)}case"fileSize":{let X=v0(Z??"");if(X===0&&!/^0+(B|KB|MB|GB|TB)$/.test(Z??""))throw new L(`Validation rule "fileSize:${Z??""}" needs a whole size in B, KB, MB, GB or TB, e.g. "fileSize:5MB"`);return($)=>$ instanceof Blob&&$.size<=X}case"array":return(X)=>Array.isArray(X);case"object":return(X)=>typeof X==="object"&&X!==null&&!Array.isArray(X)&&!(X instanceof Blob);case"in":{let X=(Z??"").split(",").filter(($)=>$!=="");if(X.length===0)throw new L('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return($)=>typeof $==="string"&&X.includes($)}default:throw new L(`Unknown validation rule "${H}". Known rules: ${h0.join(", ")}`)}}function q(H){if(!H.definition)throw Error(`gemi/ai: the recursive schema "${H.name}" was used before its definition returned; \`self\` can be nested into the schema, but not parsed or emitted inside the callback`);return H.definition}var o=new WeakMap;function J0(H){return typeof H==="object"&&H!==null&&o.has(H)}function c(H){let G=o.get(H);if(!G)throw Error("gemi/ai: expected a schema built with `s`, got a foreign object");return G}function c0(H){let G={defs:{},cells:new Map},Q=H;if(H.node.kind==="ref"){let X=q(H.node.cell);Q={...X,...H.description?{description:H.description}:{},optional:H.optional,nullable:H.nullable||X.nullable}}let Z=S(Q,G);return Object.keys(G.defs).length>0?{...Z,$defs:G.defs}:Z}function S(H,G){let Q=(H.optional||H.nullable)&&H.node.kind!=="json",Z=u0(m0(H.node,G),Q),X=[H.description,d0(H.node)].filter(Boolean).join(" ");if(X&&Z.$ref!==void 0)Z={anyOf:[Z]};return X?{description:X,...Z}:Z}function d0(H){let G=[];if(H.kind==="string"||H.kind==="enum"){let Q=H.checks;if(Q?.format)G.push(`Format: ${Q.format.name}.`);if(Q?.minLength!==void 0)G.push(`At least ${Q.minLength} characters.`);if(Q?.maxLength!==void 0)G.push(`At most ${Q.maxLength} characters.`)}else if(H.kind==="number"){let Q=H.checks;if(Q?.minimum!==void 0)G.push(`Minimum ${Q.minimum}.`);if(Q?.exclusiveMinimum!==void 0)G.push(`Greater than ${Q.exclusiveMinimum}.`);if(Q?.maximum!==void 0)G.push(`Maximum ${Q.maximum}.`);if(Q?.exclusiveMaximum!==void 0)G.push(`Less than ${Q.exclusiveMaximum}.`)}else if(H.kind==="array"){let Q=H.checks;if(Q?.minItems!==void 0)G.push(`At least ${Q.minItems} items.`);if(Q?.maxItems!==void 0)G.push(`At most ${Q.maxItems} items.`)}return G.join(" ")}function m0(H,G){switch(H.kind){case"string":return{type:"string"};case"number":return{type:H.checks?.integer?"integer":"number"};case"boolean":return{type:"boolean"};case"literal":return{type:typeof H.value,const:H.value};case"enum":return{type:"string",enum:H.values};case"array":return{type:"array",items:S(H.item,G)};case"object":return{type:"object",properties:Object.fromEntries(Object.entries(H.shape).map(([Q,Z])=>[Q,S(Z,G)])),required:Object.keys(H.shape),additionalProperties:!1};case"union":return{anyOf:H.members.map((Q)=>S(Q,G))};case"json":return{};case"ref":{let{cell:Q}=H,Z=G.cells.get(Q.name);if(Z&&Z!==Q)throw Error(`gemi/ai: two different recursive schemas are named "${Q.name}" in one schema; give each s.recursive(...) its own name`);if(!Z)G.cells.set(Q.name,Q),G.defs[Q.name]={},G.defs[Q.name]=S(q(Q),G);return{$ref:`#/$defs/${Q.name}`}}}}function u0(H,G){if(!G)return H;if(H.anyOf)return{...H,anyOf:[...H.anyOf,{type:"null"}]};if(H.enum||H.const!==void 0)return{anyOf:[H,{type:"null"}]};if(typeof H.type==="string")return{...H,type:[H.type,"null"]};return{anyOf:[H,{type:"null"}]}}function o0(H){if(H===null)return"null";if(Array.isArray(H))return"array";return typeof H}function n0(H,G){if(typeof G==="number"&&!Number.isFinite(G))return String(G);if(H.kind==="literal"||H.kind==="enum"){if(typeof G==="string"||typeof G==="number"||typeof G==="boolean")return JSON.stringify(G)}return o0(G)}function L0(H){let G=H.node,Q=(()=>{switch(G.kind){case"number":return G.checks?.integer?"integer":"number";case"string":case"boolean":return G.kind;case"literal":return JSON.stringify(G.value);case"enum":return`one of ${G.values.map((Z)=>JSON.stringify(Z)).join(" | ")}`;case"array":return"array";case"object":return"object";case"union":return"one of the variants";case"json":return"a JSON value";case"ref":return L0({...q(G.cell),optional:!1,nullable:!1})}})();return H.optional||H.nullable?`${Q} or null`:Q}function i0(H){let G="";for(let Q of H)G+=typeof Q==="number"?`[${Q}]`:G?`.${Q}`:Q;return G}function t0(H){let G=i0(H);return G?`${G}: `:""}function a(H){return`${t0(H.path)}${H.message}`}function d(H,G){if(G===null||G===void 0)return H.optional||H.nullable?1:0;let Q=H.node;switch(Q.kind){case"string":return typeof G==="string"?1:0;case"number":return typeof G==="number"?1:0;case"boolean":return typeof G==="boolean"?1:0;case"literal":return G===Q.value?10:0;case"enum":return typeof G==="string"&&Q.values.includes(G)?10:0;case"array":return Array.isArray(G)?1:0;case"object":{if(typeof G!=="object"||Array.isArray(G))return 0;let Z=G,X=1;for(let[$,W]of Object.entries(Q.shape))X+=d(W,Z[$]);return X}case"union":return Q.members.reduce((Z,X)=>Math.max(Z,d(X,G)),0);case"json":return 1;case"ref":return C0(Q.cell,G,()=>1,()=>d(q(Q.cell),G))}}function C0(H,G,Q,Z){if(typeof G!=="object"||G===null)return Z();if(H.active.has(G))return Q();H.active.add(G);try{return Z()}finally{H.active.delete(G)}}function _(H,G,Q,Z){if(H.optional&&(G===null||G===void 0))return{drop:!0,value:void 0};if(H.nullable&&G===null)return{drop:!1,value:null};return{drop:!1,value:l0(H,G,Q,Z)}}function l0(H,G,Q,Z){let X=H.node,$=()=>{let W=G===void 0?"required":X.kind==="literal"?"const":X.kind==="enum"&&typeof G==="string"?"enum":"type",Y=W==="const"?{allowedValue:X.value}:W==="enum"?{allowedValues:X.values}:{};Z.push({path:Q,code:W,message:`expected ${L0(H)}, got ${n0(X,G)}`,params:Y});return};switch(X.kind){case"string":if(typeof G!=="string")return $();return R0(X.checks,G,Q,Z),G;case"number":if(typeof G!=="number"||!Number.isFinite(G))return $();if(X.checks?.integer&&!Number.isInteger(G))return $();return s0(X.checks,G,Q,Z),G;case"boolean":return typeof G==="boolean"?G:$();case"literal":return G===X.value?G:$();case"enum":if(typeof G!=="string"||!X.values.includes(G))return $();return R0(X.checks,G,Q,Z),G;case"array":{if(!Array.isArray(G))return $();let W=G.map((T,K)=>{let w=_(X.item,T,[...Q,K],Z);return w.drop?void 0:w.value}),{minItems:Y,maxItems:D}=X.checks??{};if(Y!==void 0&&G.length<Y)Z.push({path:Q,code:"minItems",message:`expected at least ${Y} items, got ${G.length}`,params:{limit:Y}});if(D!==void 0&&G.length>D)Z.push({path:Q,code:"maxItems",message:`expected at most ${D} items, got ${G.length}`,params:{limit:D}});return W}case"object":{if(typeof G!=="object"||G===null||Array.isArray(G))return $();let W=G,Y={};for(let[D,T]of Object.entries(X.shape)){let K=_(T,W[D],[...Q,D],Z);if(!K.drop)Y[D]=K.value}if(X.unknownKeys)for(let D of Object.keys(W)){if(Object.hasOwn(X.shape,D)||W[D]===void 0)continue;if(X.unknownKeys==="error"){Z.push({path:[...Q,D],code:"additionalProperties",message:"unknown key",params:{additionalProperty:D}});continue}k(W[D],[...Q,D],Z,new Set),Object.defineProperty(Y,D,{value:W[D],enumerable:!0,writable:!0,configurable:!0})}return Y}case"union":{let W;for(let Y of X.members){let D=[],T=_(Y,G,Q,D);if(D.length===0)return T.drop?void 0:T.value;let K=d(Y,G);if(!W||K>W.score)W={issues:D,score:K}}Z.push({path:Q,code:"anyOf",message:`no matching variant; closest: ${W.issues.map(a).join("; ")}`,params:{closest:W.issues}});return}case"json":if(G===void 0)return $();return k(G,Q,Z,new Set),G;case"ref":return C0(X.cell,G,()=>{Z.push({path:Q,code:"type",message:"expected a finite tree, got a circular reference",params:{}});return},()=>_(q(X.cell),G,Q,Z).value)}}function r0(H){let G=0;for(let Q of H)G++;return G}function R0(H,G,Q,Z){if(!H)return;let{minLength:X,maxLength:$,format:W}=H;if(X!==void 0||$!==void 0){let Y=r0(G);if(X!==void 0&&Y<X)Z.push({path:Q,code:"minLength",message:`expected at least ${X} characters, got ${Y}`,params:{limit:X}});if($!==void 0&&Y>$)Z.push({path:Q,code:"maxLength",message:`expected at most ${$} characters, got ${Y}`,params:{limit:$}})}if(W){let Y=!1;try{Y=W.test(G)===!0}catch{}if(!Y)Z.push({path:Q,code:"format",message:`expected a string in format "${W.name}"`,params:{format:W.name}})}}function s0(H,G,Q,Z){if(!H)return;let X=($,W,Y,D)=>{if(W===void 0||Y(W))return;Z.push({path:Q,code:$,message:`expected ${D} ${W}, got ${G}`,params:{limit:W}})};X("minimum",H.minimum,($)=>G>=$,"at least"),X("exclusiveMinimum",H.exclusiveMinimum,($)=>G>$,"more than"),X("maximum",H.maximum,($)=>G<=$,"at most"),X("exclusiveMaximum",H.exclusiveMaximum,($)=>G<$,"less than")}function k(H,G,Q,Z,X=!0){let $=(Y)=>{Q.push({path:G,code:"type",message:`expected a JSON value, got ${Y}`,params:{}})};switch(typeof H){case"undefined":case"string":case"boolean":return;case"number":if(!Number.isFinite(H))$(String(H));return;case"bigint":return $("a bigint");case"function":return $("a function");case"symbol":return $("a symbol")}if(H===null)return;let W=H;if(Z.has(W))return $("a circular reference");Z.add(W);try{let Y=X?W.toJSON:void 0;if(typeof Y==="function"){let D;try{D=Y.call(W)}catch{return $("a toJSON that threw")}if(D===void 0)return $("a toJSON that returns undefined");return k(D,G,Q,Z,!1)}if(Array.isArray(H))H.forEach((D,T)=>k(D,[...G,T],Q,Z));else for(let[D,T]of Object.entries(W))k(T,[...G,D],Q,Z)}finally{Z.delete(W)}}function F(H){return m(H)}function m(H){let G={toJSONSchema:()=>c0(H),parse(Q){let Z=[],X=_(H,Q,[],Z);if(Z.length>0)throw Error(Z.map(a).join("; "));return X.drop?void 0:X.value},safeParse(Q){let Z=[],X=_(H,Q,[],Z);if(Z.length>0)return{ok:!1,errors:Z.map(a)};return{ok:!0,value:X.drop?void 0:X.value}},validate(Q){let Z=[],X=_(H,Q,[],Z);if(Z.length>0)return{ok:!1,issues:Z};return{ok:!0,value:X.drop?void 0:X.value}},describe:(Q)=>m({...H,description:Q}),optional:()=>m({...H,optional:!0}),nullable:()=>m({...H,nullable:!0,optional:!1})};return o.set(G,H),G}function A(H){return{node:H,optional:!1,nullable:!1}}var A0=["strip","error","passthrough"];class V0 extends Error{problems;constructor(H){super(`gemi/ai: s.fromJSONSchema cannot model this schema:
|
|
3
|
-
${H.map((G)=>`- ${G}`).join(`
|
|
4
|
-
`)}`);this.name="JSONSchemaError",this.problems=H}}var a0=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),E={string:["minLength","maxLength","format"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],integer:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],boolean:[],object:["properties","required","additionalProperties"],array:["items","minItems","maxItems"]};function h(H){return typeof H==="object"&&H!==null&&!Array.isArray(H)}function u(H,G,Q,Z){let X=(M,U=Q)=>{Z.push(U?`${U}: ${M}`:M);return},$=(M)=>Q?`${Q}.${M}`:M;if(!h(H))return X("expected a schema object");let W=new Set(G.ignoreKeywords??[]),Y=(M)=>a0.has(M)||M.startsWith("x-")||W.has(M),D=!1,T=H.type;if(Array.isArray(T)){let M=T.filter((U)=>U!=="null");if(M.length!==1)return X(`type ${JSON.stringify(T)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,$("type"));D=M.length<T.length,T=M[0]}if(T!==void 0&&(typeof T!=="string"||!(T in E)))return X(`type ${JSON.stringify(T)} is not supported; expected one of ${Object.keys(E).join(", ")}`,$("type"));let K=new Set(["type","description","enum","const","anyOf",...T?E[T]:[]]),w=!1;for(let M of Object.keys(H)){if(K.has(M)||Y(M))continue;w=!0;let U=Object.entries(E).find(([,B])=>B.includes(M));X(U&&U[0]!==T?`"${M}" applies to type ${U[0]}, and this schema is ${T?`type ${T}`:"untyped"}`:`"${M}" is not supported by s.fromJSONSchema`,$(M))}if(w)return;if(H.description!==void 0&&typeof H.description!=="string")return X("expected a string",$("description"));let v=H.description,J=(M)=>({node:M,optional:!1,nullable:D,...v?{description:v}:{}});if(H.anyOf!==void 0){if(T!==void 0||H.enum!==void 0||H.const!==void 0)return X("anyOf cannot be combined with type, enum or const here",$("anyOf"));if(!Array.isArray(H.anyOf)||H.anyOf.length===0)return X("expected a non-empty array",$("anyOf"));let M=[],U=!1;if(H.anyOf.forEach((B,P)=>{if(h(B)&&B.type==="null"&&Object.keys(B).length===1){D=!0;return}let R=u(B,G,$(`anyOf[${P}]`),Z);if(R)M.push(R);else U=!0}),U)return;if(M.length===0)return X("anyOf has only null in it",$("anyOf"));if(M.length===1){let B=M[0];return{...B,nullable:B.nullable||D,...v?{description:v}:{}}}return J({kind:"union",members:M})}if(H.const!==void 0){let M=H.const;if(typeof M!=="string"&&typeof M!=="number"&&typeof M!=="boolean")return X("only a string, number or boolean const is supported",$("const"));if(T!==void 0&&typeof M!==(T==="integer"?"number":T))return X(`const ${JSON.stringify(M)} is not of type ${T}`,$("const"));return J({kind:"literal",value:M})}let O;if(T==="string"){if(O=e0(H,G,$,Z),O===null)return}if(H.enum!==void 0){if(!Array.isArray(H.enum)||H.enum.length===0)return X("expected a non-empty array",$("enum"));let M=H.enum.filter((P)=>P!==null);if(M.length<H.enum.length)D=!0;let U=M.find((P)=>!(typeof P==="string"||typeof P==="number"||typeof P==="boolean")||T!==void 0&&typeof P!==(T==="integer"?"number":T));if(U!==void 0||M.length===0)return X(T?`every value must be of type ${T}${M.length===0?", and there must be one":`; ${JSON.stringify(U)} is not`}`:"only strings, numbers and booleans are supported",$("enum"));if(M.every((P)=>typeof P==="string"))return J({kind:"enum",values:[...new Set(M)],...O?{checks:O}:{}});let B=[...new Set(M)];if(B.length===1)return J({kind:"literal",value:B[0]});return J({kind:"union",members:B.map((P)=>A({kind:"literal",value:P}))})}switch(T){case void 0:return X("a schema needs a type, an enum, a const or an anyOf");case"string":return J({kind:"string",...O?{checks:O}:{}});case"number":case"integer":{let M=T==="integer"?{integer:!0}:{},U=!1;for(let B of E.number){let P=H[B];if(P===void 0)continue;if(typeof P!=="number"||!Number.isFinite(P)){X("expected a number",$(B)),U=!0;continue}M[B]=P}if(U)return;return J({kind:"number",...Object.keys(M).length>0?{checks:M}:{}})}case"boolean":return J({kind:"boolean"});case"array":{if(!h(H.items))return X('an array needs "items" to be one schema (tuples are not supported)',$("items"));let M={},U=!1;for(let P of["minItems","maxItems"]){let R=H[P];if(R===void 0)continue;if(typeof R!=="number"||!Number.isInteger(R)||R<0){X("expected a non-negative integer",$(P)),U=!0;continue}M[P]=R}let B=u(H.items,G,$("items"),Z);if(!B||U)return;return J({kind:"array",item:B,...Object.keys(M).length>0?{checks:M}:{}})}case"object":{let M=H.properties??{};if(!h(M))return X("expected an object",$("properties"));if(H.additionalProperties!==void 0&&H.additionalProperties!==!1)return X("only false is supported; a record with arbitrary keys has no strict-mode form (use s.json())",$("additionalProperties"));let U=H.required??[];if(!Array.isArray(U)||!U.every((V)=>typeof V==="string"))return X("expected an array of property names",$("required"));let B=U.filter((V)=>!Object.hasOwn(M,V));if(B.length>0)return X(`lists properties the schema doesn't have: ${B.join(", ")}`,$("required"));let P={},R=!1;for(let[V,b0]of Object.entries(M)){let l=u(b0,G,$(`properties.${V}`),Z);if(!l){R=!0;continue}P[V]=U.includes(V)?l:{...l,optional:!0}}if(R)return;let t=G.unknownKeys;return J({kind:"object",shape:P,...t==="error"||t==="passthrough"?{unknownKeys:t}:{}})}}return}function e0(H,G,Q,Z){let X={},$=!1;for(let W of["minLength","maxLength"]){let Y=H[W];if(Y===void 0)continue;if(typeof Y!=="number"||!Number.isInteger(Y)||Y<0){Z.push(`${Q(W)}: expected a non-negative integer`),$=!0;continue}X[W]=Y}if(H.format!==void 0){let W=H.format,Y=typeof W==="string"?G.formats?.[W]:void 0;if(typeof W!=="string")Z.push(`${Q("format")}: expected a string`),$=!0;else if(!Y||!Object.hasOwn(G.formats,W))Z.push(`${Q("format")}: unknown format ${JSON.stringify(W)}; pass a check for it in the formats option`),$=!0;else X.format={name:W,test:HH(Y)}}if($)return null;return Object.keys(X).length>0?X:void 0}function HH(H){if(H===!0)return()=>!0;if(H instanceof RegExp)return(G)=>{return H.lastIndex=0,H.test(G)};return H}var fH={string:()=>F(A({kind:"string"})),number:()=>F(A({kind:"number"})),boolean:()=>F(A({kind:"boolean"})),literal:(H)=>F(A({kind:"literal",value:H})),enum:(H)=>F(A({kind:"enum",values:H})),object:(H)=>F(A({kind:"object",shape:Object.fromEntries(Object.entries(H).map(([G,Q])=>[G,c(Q)]))})),array:(H)=>F(A({kind:"array",item:c(H)})),union:(H)=>F(A({kind:"union",members:H.map(c)})),json:()=>F(A({kind:"json"})),recursive:QH,fromJSONSchema:(H,G={})=>{let Q=[];if(G.unknownKeys!==void 0&&!A0.includes(G.unknownKeys))throw Error(`gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${A0.map((X)=>JSON.stringify(X)).join(", ")}, got ${JSON.stringify(G.unknownKeys)}`);let Z=u(H,G,"",Q);if(!Z||Q.length>0)throw new V0(Q.length>0?Q:["unreadable schema"]);return F(Z)}};function vH(H){let G=o.get(H);if(G)return y(G.node);return g(H.toJSONSchema())}function g(H){if(!(H.$ref!==void 0||H.type!==void 0||H.enum!==void 0||H.const!==void 0||H.anyOf!==void 0||H.properties!==void 0||H.items!==void 0))return!1;for(let Q of Object.values(H.properties??{}))if(!g(Q))return!1;if(H.items&&!g(H.items))return!1;for(let Q of H.anyOf??[])if(!g(Q))return!1;for(let Q of Object.values(H.$defs??{}))if(!g(Q))return!1;return!0}function y(H,G=new Set){switch(H.kind){case"string":case"number":case"boolean":case"literal":case"enum":return!0;case"object":return Object.values(H.shape).every((Q)=>y(Q.node,G));case"array":return y(H.item.node,G);case"union":return H.members.every((Q)=>y(Q.node,G));case"json":return!1;case"ref":if(G.has(H.cell))return!0;return G.add(H.cell),y(q(H.cell).node,G)}}function e(H,G,Q=new Set){let Z=H.node;if(Z.kind==="union")return Z.members.some((X)=>e(X,G,Q));if(Z.kind!=="ref")return!1;if(Z.cell===G)return!0;if(Q.has(Z.cell)||!Z.cell.definition)return!1;return Q.add(Z.cell),e(Z.cell.definition,G,Q)}var GH=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function QH(H,G){if(typeof H!=="string"||!GH.test(H))throw Error(`gemi/ai: s.recursive needs a name of letters, digits, "_" and "-" (starting with a letter or "_", at most 64), got ${JSON.stringify(H)}`);let Q={name:H,active:new Set},Z=()=>A({kind:"ref",cell:Q}),X=c(G(F(Z())));if(X.optional)throw Error(`gemi/ai: the recursive schema "${H}" is optional() as a whole; mark the places that use it optional instead`);if(e(X,Q))throw Error(`gemi/ai: the recursive schema "${H}" refers to itself outside any object or array, so it describes no finite value; nest \`self\` in an s.object(...) field or an s.array(...)`);return Q.definition=X,F(Z())}function _0(H){if(typeof H!=="string")return null;let[G]=H.split(";",1),Q=G.trim().toLowerCase();return Q===""?null:Q}function j0(H){if(H===null)return!1;if(H==="application/json")return!0;let G=H.indexOf("/");return G>0&&H.endsWith("+json")&&H.length>G+1+5}var H0=new WeakMap;function cH(H,G){H0.set(H,{clientAddress:G})}function O0(H){return H0.has(H)}function dH(H){return H0.get(H)?.clientAddress}var I0=new WeakMap;function uH(H,G){I0.set(H,G)}function q0(H){return I0.get(H)??null}var G0=new WeakMap;function oH(H,G){let Q=G0.get(H)??[];if(!Q.includes(G))G0.set(H,[...Q,G])}function nH(H){return G0.get(H)??[]}class N{data;constructor(H){this.data=H}get(H){return this.data[H]}has(H){return this.data[H]!==void 0}toJSON(){return this.data}}function N0(H){return typeof H==="object"&&H!==null&&!(H instanceof Blob)}function XH(H,G){if(!G.includes(".")||Object.hasOwn(H,G))return[{path:[G],value:H[G]}];let Q=[{path:[],value:H}];for(let Z of G.split(".")){let X=[];for(let{path:$,value:W}of Q){if(Z==="*"){if(Array.isArray(W))W.forEach((Y,D)=>X.push({path:[...$,D],value:Y}));else if(N0(W))for(let[Y,D]of Object.entries(W))X.push({path:[...$,Y],value:D});continue}if(Array.isArray(W)&&/^\d+$/.test(Z)){X.push({path:[...$,Number(Z)],value:W[Number(Z)]});continue}X.push({path:[...$,Z],value:N0(W)&&Object.hasOwn(W,Z)?W[Z]:void 0})}Q=X}return Q}function w0(H){return H.join(".")}class ZH{kind;rawRequest;headers;cookies;search;schema={};routePath;params;domain;constructor(H,G,Q,Z){if(!H){let D=C.getStore().req;this.params=D.params,this.rawRequest=D.rawRequest,this.kind=D.kind,this.routePath=D.routePath,this.domain=D.domain??null}else this.params=G,this.rawRequest=H,this.routePath=Z,this.kind=Q??"api",this.domain=q0(H);this.headers=this.rawRequest.headers;let X=r(this.rawRequest.headers.get("Cookie")),$=new URL(this.rawRequest.url),W=new Map;for(let[D,T]of $.searchParams)if(W.has(D)){let K=W.get(D);if(Array.isArray(K))K.push(T),W.set(D,K);else W.set(D,[K,T])}else W.set(D,T);let Y=Object.fromEntries(W.entries());this.search=new N(Y),this.cookies=X}locale(){return C.getStore().locale}ctx(){return C.getStore()}isModelOriginated(){return O0(this.rawRequest)}get signal(){return this.rawRequest.signal}range(){return K0(this.rawRequest.headers.get("Range"))}refine(H){return{}}async parseBody(){let H=_0(this.rawRequest.headers.get("Content-Type"));if(j0(H))return new N(await this.parseJsonBody());if(H==="application/x-www-form-urlencoded"||H==="multipart/form-data"){let G;try{G=await this.rawRequest.formData()}catch(Z){if(Z instanceof z)throw Z;throw new z("The request body could not be read as a form.")}let Q=new Map;for(let[Z,X]of G.entries())if(Q.has(Z)){let $=Q.get(Z);if(Array.isArray($))$.push(X);else Q.set(Z,[$,X])}else Q.set(Z,X);return new N(Object.fromEntries(Q.entries()))}return new N({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let H;try{H=await this.rawRequest.text()}catch(Q){if(Q instanceof z)throw Q;throw new z("The request body could not be read.")}if(H.trim()==="")return{};let G;try{G=JSON.parse(H)}catch{throw new z("The request body is not valid JSON.")}if(G===null||typeof G!=="object")throw new z("The request body must be a JSON object.");return G}validateInput(H){if(J0(this.schema))return this.validateWithSchema(H);let G=H.toJSON()??{},Q={},Z=Object.entries(this.schema).map(([X,$])=>({key:X,rules:Object.entries($).map(([W,Y])=>({rule:W,message:Y,check:typeof Y==="function"?null:this.ruleFor(X,W)}))}));for(let{key:X,rules:$}of Z)for(let{path:W,value:Y}of XH(G,X)){let D=this.checkField(Y,$);if(D.length>0){let T=Q[w0(W)]??=[];for(let K of D)if(!T.includes(K))T.push(K)}}if(this.addRefinements(Q,G),Object.keys(Q).length>0)throw new x(Q);return H}checkField(H,G){let Q=G.some(({rule:$})=>$==="required"),Z=H===void 0||H===null||H==="",X=[];for(let{rule:$,message:W,check:Y}of G){let D=W,T=!1;if(typeof W==="function")D=W(H),T=typeof D>"u";else T=Y(H);if(T)continue;if(Z&&!Q)continue;if($==="required")return[String(D)];if(!X.includes(String(D)))X.push(String(D))}return X}validateWithSchema(H){let G=this.schema.validate(H.toJSON()),Q={};if("issues"in G)for(let X of G.issues){let $=w0(X.path),W=Q[$]??=[];if(!W.includes(X.message))W.push(X.message)}let Z="value"in G?new N(G.value):H;if(this.addRefinements(Q,Z.toJSON()),Object.keys(Q).length>0)throw new x(Q);return Z}addRefinements(H,G){for(let[Q,Z]of Object.entries(this.refine(G)??{})){let X=H[Q]??[];H[Q]=X.includes(Z)?X:[...X,Z]}}ruleFor(H,G){try{return F0(G)}catch(Q){if(Q instanceof L)throw new L(`${this.constructor.name}.schema.${H}: ${Q.message}`);throw Q}}async input(){return this.validateInput(await this.parseBody())}async safeInput(){let H=await this.parseBody();try{return{isValid:!0,errors:{},input:this.validateInput(H)}}catch(G){if(!(G instanceof x))throw G;return{isValid:!1,errors:G.errors,input:H}}}}class $H extends z{error;constructor(H="Not authorized"){super(H);this.name="AuthorizationError",this.error=H,this.payload={api:{status:401,data:{error:i("authorization",this.error,401)}},view:{}}}}class Q0 extends z{static apiStatus=403;error;constructor(H="Insufficient permissions"){super(H);this.name="InsufficientPermissionsError",this.error=H,this.payload={api:{status:Q0.apiStatus,data:{error:i("permission",this.error,Q0.apiStatus)}},view:{status:403}}}}class X0 extends z{total;constructor(H){super("Range not satisfiable");this.total=H;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:n("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":B0(H),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class WH extends z{constructor(H="Not found"){super(H);this.name="NotFoundError",this.payload={api:{status:404,data:{error:n("not_found",H,404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class j extends z{fileName;constructor(H){super("File not found");this.fileName=H;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:n("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{status:404}}}}class YH extends z{constructor(H={}){super("Authentication error");this.name="AuthenticationError";let G=H.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:i("authentication","Authentication error",401)}},viewData:{status:200,data:{},headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate"},directive:{kind:"Redirect",path:G}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:G}}}}}class b{static getFacadeAccessor(){throw Error(`Facade [${this.name}] does not implement getFacadeAccessor().`)}static getFacadeRoot(){return x0(this.getFacadeAccessor())}}class Z0{async delete(H){throw Error(`${this.constructor.name} does not implement delete(). Override it to remove objects from this backend.`)}async read(H){let G=typeof H==="string"?{name:H}:H,Q=await this.fetch({name:G.name,bucket:G.bucket});if(!Q.ok)throw new j(G.name);let Z=Q.headers.get("Content-Type")??"application/octet-stream",X=Q.headers.get("ETag")??void 0,$=Q.headers.get("Last-Modified"),W=$?new Date($):void 0;if(G.range){let T=await Q.blob();return{body:T,start:0,end:T.size-1,total:T.size,partial:!1,type:Z,etag:X,lastModified:W,name:G.name}}let Y=Number(Q.headers.get("Content-Length")),D=Number.isFinite(Y)?Y:0;return{body:Q.body,start:0,end:D-1,total:D,partial:!1,type:Z,etag:X,lastModified:W,name:G.name}}async size(H){let G=typeof H==="string"?H:H.name,Q=typeof H==="string"?void 0:H.bucket,Z=await this.fetch({name:G,bucket:Q});if(!Z.ok)throw new j(G);let X=Number(Z.headers.get("Content-Length"));if(Number.isFinite(X))return await Z.body?.cancel(),X;return(await Z.blob()).size}}function E0(H,G){if(!G)return H;let Q=H.getReader(),Z=!1,X,$=()=>{if(Z=!0,X)G.removeEventListener("abort",X)};return new ReadableStream({start(W){if(X=()=>{if(Z)return;$(),W.error(G.reason),Q.cancel(G.reason).catch(()=>{})},G.aborted)X();else G.addEventListener("abort",X,{once:!0})},async pull(W){let Y;try{Y=await Q.read()}catch(D){if(Z)return;$(),W.error(D);return}if(Z)return;if(Y.done){$(),W.close();return}W.enqueue(Y.value)},cancel(W){return $(),Q.cancel(W)}},{highWaterMark:0})}import{readdir as DH,unlink as TH}from"fs/promises";import{isAbsolute as MH,relative as UH,resolve as S0,sep as KH}from"path";class $0 extends Z0{configured;constructor(H){super();this.configured=H}get folderPath(){return this.configured??`${f()}/storage`}async put(H,{signal:G}={}){G?.throwIfAborted();let Q,Z;if(H instanceof Blob)Q=H,Z=`${Bun.randomUUIDv7()}.${H.type.split("/")[1].split(";")[0]}`;else Q=H.body,Z=H.name;let X=Q instanceof Buffer?Q:Q instanceof Blob||Q instanceof File?Buffer.from(await Q.arrayBuffer()):"",$=`${this.folderPath}/${Z}`;return G?.throwIfAborted(),await Bun.write($,X),Z}async fetch(H,{signal:G}={}){G?.throwIfAborted();let Q=process.env.BUCKET_NAME,Z;if(typeof H==="string")Z=H;else Q=H.bucket??Q,Z=H.name;if(!Z)throw Error("Object name has to be specified");let X=`${this.folderPath}/${Z}`,$=Bun.file(X),W=E0(Bun.file(X).stream(),G),Y=new Date($.lastModified).toUTCString();return new Response(W,{headers:{"Content-Type":$.type,"Content-Length":String($.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":Y}})}async read(H){let G=typeof H==="string"?{name:H}:H,{name:Q,range:Z=null}=G;if(!Q)throw Error("Object name has to be specified");let X=Bun.file(`${this.folderPath}/${Q}`);if(!await X.exists())throw new j(Q);let $=X.size,W=Z?P0(Z,$):null;if(Z&&!W)throw new X0($);let Y=W?.start??0,D=W?W.end:$-1;return{body:W?X.slice(Y,D+1):X,start:Y,end:D,total:$,partial:Boolean(W),type:X.type||"application/octet-stream",lastModified:new Date(X.lastModified),name:Q}}async size(H){let G=typeof H==="string"?H:H.name,Q=Bun.file(`${this.folderPath}/${G}`);if(!await Q.exists())throw new j(G);return Q.size}async delete(H){let G=typeof H==="string"?H:H.name;if(!G)throw Error("Object name has to be specified");let Q=S0(this.folderPath),Z=S0(Q,G),X=UH(Q,Z);if(!X||X===".."||X.startsWith(`..${KH}`)||MH(X))throw Error(`Refusing to delete "${G}": it is outside the storage folder`);try{await TH(Z)}catch($){if($?.code==="ENOENT")return;throw $}}async list(){return await DH(this.folderPath)}}function VG(H){return H}function g0(){return{driver:new $0}}class W0{static token="filesystem";driver;constructor(H={}){this.driver=H.driver??g0().driver}}import{Buffer as BH}from"buffer";async function y0(H){try{return(await import("sharp")).default}catch(G){throw Error(`${H} requires the 'sharp' package. Install it with \`bun add sharp\`.`,{cause:G})}}class zH extends b{static getFacadeAccessor(){return W0}static async put(H,G={}){return this.getFacadeRoot().driver.put(H,G)}static async metadata(H){let G=BH.from(await H.arrayBuffer()),Q=await y0("Storage.metadata()");try{return await Q(G).metadata()}catch{return{}}}static async fetch(H,G={}){return G.signal?.throwIfAborted(),this.getFacadeRoot().driver.fetch(H,G)}static async read(H,G={}){let Q=typeof H==="string"?{name:H}:{...H},Z="range"in G?G.range??null:Q.range!==void 0?Q.range:C.getStore()?.rangeRequest??null;return this.getFacadeRoot().driver.read({...Q,range:Z})}static list(H){return this.getFacadeRoot().driver.list(H)}static async delete(H){return this.getFacadeRoot().driver.delete(H)}}import{mkdir as Y0,readdir as FH,access as RH}from"fs/promises";async function D0(H){try{return await RH(H),!0}catch{return!1}}class T0{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${f()}/storage/logs`}constructor(H){this.config=H}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch((H)=>{console.error("Log storage unavailable, file logging disabled",H)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let H=`${f()}/storage`;if(!await D0(H))await Y0(H);if(!await D0(this.logsDirPath))await Y0(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await D0(this.logsDirPath))await Y0(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let Q=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(Q),this.fileSize=0,this.writerSize=0}let G=(await FH(this.logsDirPath)).sort().reverse()[0];if(G){let Q=Bun.file(`${this.logsDirPath}/${G}`);if(Q.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${G}`,this.writer=Q.writer(),this.writer.write(await Q.text()),this.writer.write(`
|
|
5
|
-
`),this.writer.flush(),this.fileSize=Q.size}if(!this.writer){let Q=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${Q}`;let Z=Bun.file(`${this.logsDirPath}/${Q}`);this.writer=Z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log(H,G,Q={}){if(!this.isReady)await this.boot();let Z=C.getStore(),X={};if(Z)X={url:Z.req.rawRequest.url,method:Z.req.rawRequest.method,headers:Z.req.rawRequest.headers,body:Z.req.rawRequest.body};let $={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:H,message:G,metadata:{...X,...Q}},W="";try{W=JSON.stringify($)}catch(Y){console.log("Error parsing log object",Y)}try{let Y=this.config.onLogCreated($);if(Y instanceof Promise)Y.catch((D)=>console.error("Error in onLogCreated",D))}catch(Y){console.error("Error in onLogCreated",Y)}if(!this.writer)return;this.writerSize+=W.length,this.fileSize+=W.length;try{this.writer.write(W),this.writer.write(`
|
|
6
|
-
`),this.tryFlush()}catch(Y){console.error("Error writing log",Y)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class AH extends b{static getFacadeAccessor(){return T0}static debug(H,G){this.getFacadeRoot().log("debug",H,G)}static info(H,G){this.getFacadeRoot().log("info",H,G)}static notice(H,G){this.getFacadeRoot().log("notice",H,G)}static warning(H,G){this.getFacadeRoot().log("warning",H,G)}static error(H,G){this.getFacadeRoot().log("error",H,G)}static critical(H,G){this.getFacadeRoot().log("critical",H,G)}static alert(H,G){this.getFacadeRoot().log("alert",H,G)}static emergency(H,G){this.getFacadeRoot().log("emergency",H,G)}}class JH{config;static token="redis";instance=null;constructor(H={}){this.config=H}get client(){return this.instance??=new(LH())(this.config.url,this.config.options)}set client(H){this.instance=H}close(){let H=this.instance;this.instance=null,H?.close()}}function LH(){let H=globalThis.Bun?.RedisClient;if(typeof H!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return H}var M0=new TextEncoder;function k0(H){return`id: ${H.seq}
|
|
7
|
-
data: ${JSON.stringify(H.event)}
|
|
8
|
-
|
|
9
|
-
`}var CH=5000,VH=`: keepalive
|
|
10
|
-
|
|
11
|
-
`;function _H(H,G=CH){let Q=null,Z=!1,X=()=>{if(Z)return;if(Q!==null)clearTimeout(Q);Q=setTimeout(()=>{if(Q=null,Z)return;try{H.enqueue(M0.encode(VH))}catch{$();return}X()},G)},$=()=>{if(Z=!0,Q!==null)clearTimeout(Q);Q=null};return X(),{touch:X,stop:$}}function jH(){return{"Content-Type":"text/event-stream","Cache-Control":"no-store, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"}}function cG(H,G=200){let Q=H[Symbol.asyncIterator](),Z=-1,X,$=new ReadableStream({start(W){X=_H(W)},async pull(W){try{let Y=await Q.next();if(Y.done){X.stop(),W.close();return}Z=Y.value.seq,W.enqueue(M0.encode(k0(Y.value))),X.touch()}catch(Y){let D={type:"error",error:IH(Y)};X.stop(),W.enqueue(M0.encode(k0({seq:Z+1,event:D}))),W.close()}},cancel(W){X.stop(),Q.return?.(W)}});return new Response($,{status:G,headers:jH()})}var OH=new Set(["frame_cursor_evicted","live_run_not_found"]);function IH(H){let G=H&&typeof H==="object"?H.code:void 0;if(H instanceof Error&&typeof G==="string"&&OH.has(G))return{code:"unknown",message:H.message,retryable:!1};return console.error("[gemi/ai] agent stream failed",H),{code:"unknown",message:"The run's stream failed.",retryable:!1}}
|
|
12
|
-
export{U0 as Bf,f0 as Cf,NH as Df,_0 as Ef,cH as Ff,dH as Gf,K0 as Hf,P0 as If,xH as Jf,EH as Kf,SH as Lf,B0 as Mf,uH as Nf,q0 as Of,oH as Pf,nH as Qf,x as Rf,L as Sf,V0 as Tf,fH as Uf,vH as Vf,ZH as Wf,$H as Xf,Q0 as Yf,X0 as Zf,WH as _f,j as $f,YH as ag,b as bg,y0 as cg,Z0 as dg,E0 as eg,$0 as fg,VG as gg,g0 as hg,W0 as ig,zH as jg,T0 as kg,AH as lg,JH as mg,VH as ng,_H as og,jH as pg,cG as qg};
|
|
13
|
-
|
|
14
|
-
//# debugId=62B8DD34CFA0983664756E2164756E21
|
package/dist/chunk-fsfbyg5e.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{pc as o}from"./chunk-x5yq097b.js";import{qc as i}from"./chunk-f1y8eggf.js";import{Cg as t}from"./chunk-y6v0x869.js";import{Bh as r}from"./chunk-nysqgzp1.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
|
|
3
|
-
export{n as eb};
|
|
4
|
-
|
|
5
|
-
//# debugId=DFFEE115660B0DB064756E2164756E21
|
package/dist/chunk-kp7k4s5c.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Sh as I}from"./chunk-fnkjmq94.js";class J{kernel;onException;constructor(f){this.kernel=new f.kernel,this.kernel.boot.call(this.kernel),this.onException=f.onException??((A)=>{console.error("Unhandled exception in App:",A)})}async waitForBoot(){await this.kernel.waitForBoot()}getComponentTree(){return this.kernel.viewRoutes().componentTree}getFlatComponentTree(){let f=new Set;for(let A of this.kernel.domains().viewDispatchers())for(let B of A.flatComponentTree)f.add(B);return Array.from(f)}devAllowedHosts(){let f=this.kernel.domains();if(!f.resolver)return[];return f.acceptsCustomDomains?!0:[`.${f.resolver.root}`]}getRouteManifest(){return this.kernel.viewRoutes().routeManifest}globallyGated=new WeakMap;async withGlobalMiddleware(f,A,B){let z;try{z=await this.kernel.run.call(this.kernel,()=>this.kernel.globalMiddleware(f))}catch(D){return await B(D)}if(z.refusal)return z.refusal;return this.globallyGated.set(f,z.carried),z.apply(await A(f))}async fetch(f){let A=new URL(f.url);return this.kernel.run.call(this.kernel,async()=>{let B=this.globallyGated.has(f),z=B?null:await this.kernel.globalMiddleware(f),D=B?this.globallyGated.get(f):z.carried;if(z?.refusal)return z.refusal;let H=this.kernel.domains(),C=await H.ask(f)??await H.route(f);if(C instanceof Response)return z?z.apply(C):C;if(!C){let G=new Response("Unknown host",{status:404});return z?z.apply(G):G}let F=I(A.pathname)?await C.api.handleApiRequest(f,D):await C.view.handleViewRequest(f,D);if(!z)return F;if(typeof F==="function"){let G=F;return async(...L)=>z.apply(await G(...L))}return z.apply(F)})}dispatchJob(f,A){return this.kernel.run.bind(this.kernel)(()=>{return this.kernel.queue().dispatchJob(f,A)})}shutdown(f){return this.kernel.shutdown(f)}destroy(){this.kernel.destroy()}clone(){return Object.assign(Object.create(Object.getPrototypeOf(this)),this)}}export{J as Ha};
|
|
3
|
-
|
|
4
|
-
//# debugId=73B5973568BFE2E964756E2164756E21
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|