gemi 0.110.0 → 0.112.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/Agent.d.ts +65 -1
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/AgentController.d.ts +48 -0
- package/dist/ai/AgentController.d.ts.map +1 -1
- package/dist/ai/client/index.d.ts +1 -1
- package/dist/ai/client/index.d.ts.map +1 -1
- package/dist/ai/contextCompaction.d.ts +247 -0
- package/dist/ai/contextCompaction.d.ts.map +1 -0
- package/dist/ai/contextWindow.d.ts +18 -0
- package/dist/ai/contextWindow.d.ts.map +1 -1
- package/dist/ai/index.d.ts +5 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +93 -14
- package/dist/ai/index.js.map +16 -10
- package/dist/ai/jobs/AgentJob.d.ts +259 -0
- package/dist/ai/jobs/AgentJob.d.ts.map +1 -0
- package/dist/ai/jobs/AgentJobDeadlineSweep.d.ts +18 -0
- package/dist/ai/jobs/AgentJobDeadlineSweep.d.ts.map +1 -0
- package/dist/ai/jobs/AgentJobStore.d.ts +141 -0
- package/dist/ai/jobs/AgentJobStore.d.ts.map +1 -0
- package/dist/ai/jobs/DatabaseAgentJobStore.d.ts +82 -0
- package/dist/ai/jobs/DatabaseAgentJobStore.d.ts.map +1 -0
- package/dist/ai/jobs/contextBlock.d.ts +31 -0
- package/dist/ai/jobs/contextBlock.d.ts.map +1 -0
- package/dist/ai/jobs/index.d.ts +6 -0
- package/dist/ai/jobs/index.d.ts.map +1 -0
- package/dist/ai/jobs/overlay.d.ts +49 -0
- package/dist/ai/jobs/overlay.d.ts.map +1 -0
- package/dist/ai/providers/request.d.ts.map +1 -1
- package/dist/ai/store/Attachments.d.ts +6 -0
- package/dist/ai/store/Attachments.d.ts.map +1 -1
- package/dist/ai/store/MemoryAgentStore.d.ts +3 -0
- package/dist/ai/store/MemoryAgentStore.d.ts.map +1 -1
- package/dist/ai/types.d.ts +28 -0
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/bin/gemi.js +13 -2
- package/dist/bin/gemi.js.map +4 -4
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-30xjcyzh.js → chunk-0z2h35d7.js} +2 -2
- package/dist/{chunk-30xjcyzh.js.map → chunk-0z2h35d7.js.map} +1 -1
- package/dist/{chunk-358sdcx9.js → chunk-15a1mrdv.js} +2 -2
- package/dist/{chunk-358sdcx9.js.map → chunk-15a1mrdv.js.map} +1 -1
- package/dist/{chunk-hf7a51s3.js → chunk-18c3y8m3.js} +2 -2
- package/dist/{chunk-hf7a51s3.js.map → chunk-18c3y8m3.js.map} +1 -1
- package/dist/{chunk-tq85n8zh.js → chunk-1pvkw2pq.js} +2 -2
- package/dist/{chunk-tq85n8zh.js.map → chunk-1pvkw2pq.js.map} +1 -1
- package/dist/{chunk-8afxrmdc.js → chunk-2taa0brj.js} +2 -2
- package/dist/{chunk-8afxrmdc.js.map → chunk-2taa0brj.js.map} +1 -1
- package/dist/{chunk-5cygrbxv.js → chunk-30yg31sz.js} +2 -2
- package/dist/{chunk-5cygrbxv.js.map → chunk-30yg31sz.js.map} +1 -1
- package/dist/{chunk-3y8q8x11.js → chunk-3z9vhjd7.js} +2 -2
- package/dist/{chunk-3y8q8x11.js.map → chunk-3z9vhjd7.js.map} +1 -1
- package/dist/chunk-4sb1484x.js +46 -0
- package/dist/{chunk-h3864a8z.js.map → chunk-4sb1484x.js.map} +13 -4
- package/dist/{chunk-0sjh5v1n.js → chunk-53bek7sp.js} +1 -1
- package/dist/{chunk-xkc7ftnq.js → chunk-57edag57.js} +3 -3
- package/dist/{chunk-xkc7ftnq.js.map → chunk-57edag57.js.map} +1 -1
- package/dist/{chunk-ddr4qvvt.js → chunk-5az0mq4p.js} +3 -3
- package/dist/{chunk-ddr4qvvt.js.map → chunk-5az0mq4p.js.map} +1 -1
- package/dist/{chunk-nsvktvp4.js → chunk-5waxjsvv.js} +2 -2
- package/dist/{chunk-nsvktvp4.js.map → chunk-5waxjsvv.js.map} +1 -1
- package/dist/{chunk-rfcygmf5.js → chunk-6w79zajj.js} +3 -3
- package/dist/{chunk-rfcygmf5.js.map → chunk-6w79zajj.js.map} +1 -1
- package/dist/{chunk-gb37722w.js → chunk-75ptmewf.js} +3 -3
- package/dist/{chunk-gb37722w.js.map → chunk-75ptmewf.js.map} +1 -1
- package/dist/{chunk-pyj7cd9t.js → chunk-851k0b26.js} +2 -2
- package/dist/{chunk-pyj7cd9t.js.map → chunk-851k0b26.js.map} +1 -1
- package/dist/{chunk-m6ystvtk.js → chunk-8reepafh.js} +2 -2
- package/dist/{chunk-m6ystvtk.js.map → chunk-8reepafh.js.map} +1 -1
- package/dist/{chunk-nvv9wej6.js → chunk-9hr0bcfy.js} +3 -3
- package/dist/{chunk-nvv9wej6.js.map → chunk-9hr0bcfy.js.map} +1 -1
- package/dist/{chunk-yqavgpwd.js → chunk-a9q2cr4w.js} +2 -2
- package/dist/{chunk-yqavgpwd.js.map → chunk-a9q2cr4w.js.map} +1 -1
- package/dist/{chunk-cy5qp6mz.js → chunk-amvy4r59.js} +2 -2
- package/dist/{chunk-cy5qp6mz.js.map → chunk-amvy4r59.js.map} +1 -1
- package/dist/{chunk-twnn7r66.js → chunk-b1mk12xg.js} +2 -2
- package/dist/{chunk-twnn7r66.js.map → chunk-b1mk12xg.js.map} +1 -1
- package/dist/{chunk-a6453d9s.js → chunk-b7cqwcbm.js} +2 -2
- package/dist/{chunk-a6453d9s.js.map → chunk-b7cqwcbm.js.map} +1 -1
- package/dist/{chunk-nncz308h.js → chunk-b7qjp7r1.js} +2 -2
- package/dist/{chunk-nncz308h.js.map → chunk-b7qjp7r1.js.map} +1 -1
- package/dist/chunk-beks65me.js +19 -0
- package/dist/{chunk-mb7q7s0a.js.map → chunk-beks65me.js.map} +3 -4
- package/dist/chunk-bf1ets45.js +5 -0
- package/dist/{chunk-11fsn5mr.js.map → chunk-bf1ets45.js.map} +4 -3
- package/dist/{chunk-9rchedr4.js → chunk-bhw7k8vp.js} +2 -2
- package/dist/{chunk-9rchedr4.js.map → chunk-bhw7k8vp.js.map} +1 -1
- package/dist/{chunk-k1vw22t2.js → chunk-ck0v2kzw.js} +2 -2
- package/dist/{chunk-k1vw22t2.js.map → chunk-ck0v2kzw.js.map} +1 -1
- package/dist/{chunk-e1n8zs3h.js → chunk-cptzbdn6.js} +2 -2
- package/dist/{chunk-e1n8zs3h.js.map → chunk-cptzbdn6.js.map} +1 -1
- package/dist/{chunk-6vr7f5fq.js → chunk-csbc1fxa.js} +3 -3
- package/dist/{chunk-6vr7f5fq.js.map → chunk-csbc1fxa.js.map} +1 -1
- package/dist/{chunk-kf71mjxa.js → chunk-d0trs736.js} +3 -3
- package/dist/{chunk-kf71mjxa.js.map → chunk-d0trs736.js.map} +1 -1
- package/dist/{chunk-zhs1r1z0.js → chunk-d8ekyng4.js} +3 -3
- package/dist/{chunk-zhs1r1z0.js.map → chunk-d8ekyng4.js.map} +1 -1
- package/dist/chunk-d9an2nra.js +5 -0
- package/dist/{chunk-hn67spz6.js.map → chunk-d9an2nra.js.map} +1 -1
- package/dist/{chunk-0d9qsmx2.js → chunk-dan79jab.js} +2 -2
- package/dist/{chunk-0d9qsmx2.js.map → chunk-dan79jab.js.map} +1 -1
- package/dist/{chunk-1yx2e0bh.js → chunk-ddad3902.js} +2 -2
- package/dist/{chunk-1yx2e0bh.js.map → chunk-ddad3902.js.map} +1 -1
- package/dist/{chunk-3cg7y62b.js → chunk-dm59ze55.js} +2 -2
- package/dist/{chunk-3cg7y62b.js.map → chunk-dm59ze55.js.map} +1 -1
- package/dist/{chunk-wvsv1jgg.js → chunk-dx7wpz5b.js} +2 -2
- package/dist/{chunk-wvsv1jgg.js.map → chunk-dx7wpz5b.js.map} +1 -1
- package/dist/{chunk-q9s7kwgt.js → chunk-eazqda9z.js} +3 -3
- package/dist/{chunk-q9s7kwgt.js.map → chunk-eazqda9z.js.map} +1 -1
- package/dist/{chunk-td8tha3j.js → chunk-es487acc.js} +1 -1
- package/dist/{chunk-9s851qz8.js → chunk-et3vhkbf.js} +2 -2
- package/dist/{chunk-9s851qz8.js.map → chunk-et3vhkbf.js.map} +1 -1
- package/dist/{chunk-qd2v93y4.js → chunk-f1y8eggf.js} +2 -2
- package/dist/{chunk-qd2v93y4.js.map → chunk-f1y8eggf.js.map} +1 -1
- package/dist/{chunk-1pem26zc.js → chunk-ga7c7tq0.js} +3 -3
- package/dist/{chunk-1pem26zc.js.map → chunk-ga7c7tq0.js.map} +1 -1
- package/dist/{chunk-c098fzvk.js → chunk-gcs9ydjv.js} +2 -2
- package/dist/{chunk-c098fzvk.js.map → chunk-gcs9ydjv.js.map} +1 -1
- package/dist/{chunk-bn5yn731.js → chunk-hfyxvdjj.js} +2 -2
- package/dist/{chunk-bn5yn731.js.map → chunk-hfyxvdjj.js.map} +1 -1
- package/dist/chunk-j0sncgxc.js +14 -0
- package/dist/{chunk-mn5xw79b.js.map → chunk-j0sncgxc.js.map} +6 -5
- package/dist/{chunk-p7r2w4qw.js → chunk-j9jqxv1d.js} +3 -3
- package/dist/{chunk-p7r2w4qw.js.map → chunk-j9jqxv1d.js.map} +1 -1
- package/dist/{chunk-jbrwt3cs.js → chunk-jdtn0zk2.js} +4 -4
- package/dist/{chunk-jbrwt3cs.js.map → chunk-jdtn0zk2.js.map} +1 -1
- package/dist/{chunk-s6jjy4y9.js → chunk-jn59bsww.js} +2 -2
- package/dist/{chunk-s6jjy4y9.js.map → chunk-jn59bsww.js.map} +1 -1
- package/dist/{chunk-he7z7y9j.js → chunk-kk502yk2.js} +2 -2
- package/dist/{chunk-he7z7y9j.js.map → chunk-kk502yk2.js.map} +1 -1
- package/dist/{chunk-wsttx9rg.js → chunk-mrdarm2q.js} +2 -2
- package/dist/{chunk-wsttx9rg.js.map → chunk-mrdarm2q.js.map} +1 -1
- package/dist/chunk-mvtgx1mr.js +4 -0
- package/dist/{chunk-x78jrs4y.js.map → chunk-mvtgx1mr.js.map} +2 -2
- package/dist/{chunk-et4pv1b1.js → chunk-mx9y9mtx.js} +1 -1
- package/dist/chunk-nv7mv51r.js +6 -0
- package/dist/{chunk-61f4m5px.js.map → chunk-nv7mv51r.js.map} +2 -2
- package/dist/{chunk-cttmy1jp.js → chunk-p2fhtf5r.js} +3 -3
- package/dist/{chunk-cttmy1jp.js.map → chunk-p2fhtf5r.js.map} +1 -1
- package/dist/{chunk-w7jsh3xd.js → chunk-qtbf3w6w.js} +2 -2
- package/dist/{chunk-w7jsh3xd.js.map → chunk-qtbf3w6w.js.map} +1 -1
- package/dist/chunk-qx87cdfg.js +5 -0
- package/dist/chunk-qx87cdfg.js.map +10 -0
- package/dist/{chunk-1kr25rcg.js → chunk-qyp652jz.js} +3 -3
- package/dist/{chunk-1kr25rcg.js.map → chunk-qyp652jz.js.map} +1 -1
- package/dist/{chunk-8b2tw2yp.js → chunk-rend2sbk.js} +1 -1
- package/dist/chunk-rx2shb3t.js +25 -0
- package/dist/chunk-rx2shb3t.js.map +19 -0
- package/dist/{chunk-mwqg079k.js → chunk-ryzcfxq7.js} +2 -2
- package/dist/{chunk-mwqg079k.js.map → chunk-ryzcfxq7.js.map} +1 -1
- package/dist/{chunk-7tx5y712.js → chunk-s9rfgxj5.js} +2 -2
- package/dist/{chunk-7tx5y712.js.map → chunk-s9rfgxj5.js.map} +1 -1
- package/dist/{chunk-1c1d0e60.js → chunk-scbvv2e4.js} +3 -3
- package/dist/{chunk-1c1d0e60.js.map → chunk-scbvv2e4.js.map} +1 -1
- package/dist/chunk-sj8jp4p9.js +24 -0
- package/dist/{chunk-k9wgtrc5.js.map → chunk-sj8jp4p9.js.map} +2 -2
- package/dist/{chunk-pwmgqq7z.js → chunk-teny6xkw.js} +2 -2
- package/dist/{chunk-pwmgqq7z.js.map → chunk-teny6xkw.js.map} +1 -1
- package/dist/{chunk-09ypnhjv.js → chunk-tmrmwthr.js} +2 -2
- package/dist/{chunk-09ypnhjv.js.map → chunk-tmrmwthr.js.map} +1 -1
- package/dist/{chunk-h4sw6nt3.js → chunk-vgdcz7tk.js} +3 -3
- package/dist/{chunk-h4sw6nt3.js.map → chunk-vgdcz7tk.js.map} +1 -1
- package/dist/{chunk-xk930yaw.js → chunk-wexs11yy.js} +2 -2
- package/dist/{chunk-xk930yaw.js.map → chunk-wexs11yy.js.map} +1 -1
- package/dist/{chunk-k1xt2tw7.js → chunk-xs4c2nvz.js} +2 -2
- package/dist/{chunk-k1xt2tw7.js.map → chunk-xs4c2nvz.js.map} +1 -1
- package/dist/{chunk-1va15sfq.js → chunk-xv74rhay.js} +2 -2
- package/dist/{chunk-1va15sfq.js.map → chunk-xv74rhay.js.map} +1 -1
- package/dist/{chunk-sq2wkynk.js → chunk-yv1psptb.js} +2 -2
- package/dist/{chunk-sq2wkynk.js.map → chunk-yv1psptb.js.map} +1 -1
- package/dist/{chunk-tk5q8hkv.js → chunk-zfter1x0.js} +4 -4
- package/dist/{chunk-tk5q8hkv.js.map → chunk-zfter1x0.js.map} +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +214 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/useSubscription.d.ts +70 -0
- package/dist/client/useSubscription.d.ts.map +1 -0
- package/dist/config/index.js +1 -1
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +2 -2
- 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/ChangeFeed.d.ts +42 -0
- package/dist/facades/ChangeFeed.d.ts.map +1 -0
- package/dist/facades/index.d.ts +1 -0
- package/dist/facades/index.d.ts.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/ResourcePolicy.d.ts +141 -0
- package/dist/http/ResourcePolicy.d.ts.map +1 -0
- package/dist/http/errors.d.ts +13 -0
- package/dist/http/errors.d.ts.map +1 -1
- package/dist/http/index.d.ts +2 -1
- 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/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 +2 -2
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +3 -3
- package/dist/kernel/providers.d.ts.map +1 -1
- 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/change-feed/ChangeFeedDriver.d.ts +94 -0
- package/dist/services/change-feed/ChangeFeedDriver.d.ts.map +1 -0
- package/dist/services/change-feed/ChangeFeedManager.d.ts +166 -0
- package/dist/services/change-feed/ChangeFeedManager.d.ts.map +1 -0
- package/dist/services/change-feed/ChangeFeedServiceProvider.d.ts +11 -0
- package/dist/services/change-feed/ChangeFeedServiceProvider.d.ts.map +1 -0
- package/dist/services/change-feed/DatabaseChangeFeedDriver.d.ts +84 -0
- package/dist/services/change-feed/DatabaseChangeFeedDriver.d.ts.map +1 -0
- package/dist/services/change-feed/MemoryChangeFeedDriver.d.ts +26 -0
- package/dist/services/change-feed/MemoryChangeFeedDriver.d.ts.map +1 -0
- package/dist/services/change-feed/changeFeedDriverContract.d.ts +8 -0
- package/dist/services/change-feed/changeFeedDriverContract.d.ts.map +1 -0
- package/dist/services/change-feed/config.d.ts +42 -0
- package/dist/services/change-feed/config.d.ts.map +1 -0
- package/dist/services/change-feed/cursor.d.ts +17 -0
- package/dist/services/change-feed/cursor.d.ts.map +1 -0
- package/dist/services/change-feed/postgresListen.d.ts +30 -0
- package/dist/services/change-feed/postgresListen.d.ts.map +1 -0
- package/dist/services/change-feed/stream.d.ts +16 -0
- package/dist/services/change-feed/stream.d.ts.map +1 -0
- package/dist/services/change-feed/wire.d.ts +20 -0
- package/dist/services/change-feed/wire.d.ts.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -3
- package/dist/services/index.js.map +2 -2
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/router/ViewRouteDispatcher.d.ts +16 -0
- package/dist/services/router/ViewRouteDispatcher.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 +6 -2
- package/skills/gemi-react-best-practices/rules/controller-authorize-every-tenant-read.md +16 -1
- package/dist/chunk-11fsn5mr.js +0 -5
- package/dist/chunk-61f4m5px.js +0 -6
- package/dist/chunk-h3864a8z.js +0 -17
- package/dist/chunk-hn67spz6.js +0 -5
- package/dist/chunk-k9wgtrc5.js +0 -24
- package/dist/chunk-mb7q7s0a.js +0 -19
- package/dist/chunk-mn5xw79b.js +0 -9
- package/dist/chunk-x78jrs4y.js +0 -4
- /package/dist/{chunk-0sjh5v1n.js.map → chunk-53bek7sp.js.map} +0 -0
- /package/dist/{chunk-td8tha3j.js.map → chunk-es487acc.js.map} +0 -0
- /package/dist/{chunk-et4pv1b1.js.map → chunk-mx9y9mtx.js.map} +0 -0
- /package/dist/{chunk-8b2tw2yp.js.map → chunk-rend2sbk.js.map} +0 -0
package/dist/chunk-k9wgtrc5.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{E as D,F as KJ,G as OJ}from"./chunk-61f4m5px.js";import{na as B,ra as L,sa as UJ}from"./chunk-frerzsxq.js";import{Ca as e}from"./chunk-4mfrgd5m.js";import"./chunk-5stgtwqw.js";import{Jd as QJ,Kd as A,rc as a}from"./chunk-h3864a8z.js";import"./chunk-nvv9wej6.js";import"./chunk-tq85n8zh.js";import{sf as o,tf as n,wf as i}from"./chunk-mn5xw79b.js";import{bg as WJ}from"./chunk-pwmgqq7z.js";import"./chunk-sq2wkynk.js";import"./chunk-twnn7r66.js";import"./chunk-bn5yn731.js";import"./chunk-xkc7ftnq.js";import"./chunk-s6jjy4y9.js";import"./chunk-wvsv1jgg.js";import"./chunk-7tx5y712.js";import"./chunk-q9s7kwgt.js";import"./chunk-3cg7y62b.js";import{xh as YJ}from"./chunk-m6ystvtk.js";import{yh as N}from"./chunk-nsvktvp4.js";import"./chunk-1yx2e0bh.js";import{join as w,resolve as VJ,sep as zJ}from"path";import{Duplex as qJ}from"stream";import{constants as P,createBrotliCompress as TJ,createGzip as RJ}from"zlib";var bJ=["br","gzip"],kJ=1024,SJ=5,wJ=19,vJ=6;function EJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function yJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[X,...Q]=Z.split(";"),W=X.trim().toLowerCase();if(W==="")continue;let j=1;for(let Y of Q){let K=Y.indexOf("=");if(K===-1)continue;if(Y.slice(0,K).trim().toLowerCase()==="q"){j=EJ(Y.slice(K+1));break}}$.set(W,j)}return $}function b(J,$=bJ){let Z=yJ(J);if(!Z)return null;let X=Z.get("*"),Q=null,W=0;for(let j of $){let Y=Z.get(j)??X??0;if(Y>W)Q=j,W=Y}return Q}function gJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function fJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let X=$.headers.get("Content-Encoding");if(X&&X.trim().toLowerCase()!=="identity")return!1;if(gJ($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<kJ)return!1;return!0}function mJ(J){let $=J==="br"?TJ({params:{[P.BROTLI_PARAM_QUALITY]:SJ,[P.BROTLI_PARAM_LGWIN]:wJ},flush:P.BROTLI_OPERATION_FLUSH}):RJ({level:vJ,flush:P.Z_SYNC_FLUSH});return qJ.toWeb($)}function uJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((X)=>X.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function c(J,$){if(!fJ(J.method,$))return $;let Z=new Headers($.headers);uJ(Z);let X=b(J.headers.get("Accept-Encoding"));if(!X)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let Q;try{Q=mJ(X)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",X),Z.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as nJ,stat as t}from"fs/promises";import{join as iJ}from"path";import{mkdir as U2,readFile as hJ,stat as K2,writeFile as O2}from"fs/promises";import{dirname as z2,join as cJ}from"path";import{promisify as p}from"util";import{brotliCompress as pJ,constants as C2,gzip as dJ}from"zlib";var lJ=".vite/static-assets.json";var d={br:".br",gzip:".gz"},oJ=["br","gzip"],I2=p(pJ),F2=p(dJ);async function l(J){let $;try{$=await hJ(cJ(J,lJ),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let X={files:{}};for(let[Q,W]of Object.entries(Z)){if(!Array.isArray(W))continue;X.files[Q]=oJ.filter((j)=>W.includes(j))}return X}function k(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function r(J){let $=new Set;async function Z(X,Q){let W;try{W=await nJ(X,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let Y=iJ(X,j.name),K=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let I=await t(Y);K=I.isDirectory(),V=I.isFile()}catch{continue}if(V)$.add(Y);else if(K&&!j.isSymbolicLink())await Z(Y,!1)}}return await Z(J,!0),$}var aJ="public, max-age=31536000, must-revalidate",tJ="public, max-age=31536000, immutable";async function rJ(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let X=b(J.headers.get("Accept-Encoding"),Z);if(!X)return null;let Q=$+d[X];try{let W=await t(Q);return W.isFile()?{encoding:X,path:Q,size:W.size}:null}catch{return null}}async function s(J,$,Z={}){let X=Bun.file($),Q=Z.encodings??[],W={"Content-Type":X.type||"application/octet-stream","Cache-Control":Z.immutable?tJ:aJ,"Accept-Ranges":"bytes"};if(Q.length>0)W.Vary="Accept-Encoding";let j=await rJ(J,$,Q);if(j){let V=Bun.file(j.path);return new Response(V.stream(),{headers:{...W,"Content-Encoding":j.encoding,"Content-Length":String(j.size),ETag:`${k(V.lastModified)}-${j.encoding}`}})}let Y=X.size;W.ETag=k(X.lastModified);let K=o(J.headers.get("Range"));if(K){let V=n(K,Y);if(!V)return a(Y);return new Response(X.slice(V.start,V.end+1).stream(),{status:206,headers:{...W,"Content-Range":i(V.start,V.end,Y),"Content-Length":String(V.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Y)}})}import{stat as Z2}from"fs/promises";var _="app/client.tsx";function JJ(J,$=B){let Z=J[_]?.file;if(!Z)return;return{module:L(Z,$),preload:M(J,_,$)}}function M(J,$,Z=B){let X=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y?.file)return;X.push(L(Y.file,Z));for(let K of Y.imports??[])W(K)};return W($),X}function $J(J,$){let Z=[],X=new Set,Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y)return;for(let K of Y.imports??[])W(K);for(let K of Y.css??[])if(!X.has(K))X.add(K),Z.push(K)};return W($),Z}function ZJ(J,$=B){let Z=new Map;return(X)=>{if(!Z.has(X)){let Q=`${X}${e}`,W=J[Q]?.file;Z.set(X,W?{src:L(W,$),preload:M(J,Q,$)}:void 0)}return Z.get(X)}}function XJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),X=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${Z})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${Z},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${X});export {}`}var sJ=new RegExp(`^${QJ}/.+\\.m?js$`);function eJ(J){return sJ.test(J)}function HJ(J){if(eJ(J))return new Response(XJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(A(J))return new Response("Not found",{status:404});return}var J2=`<!DOCTYPE html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Internal Server Error</title>
|
|
8
|
-
<style>
|
|
9
|
-
body { font-family: system-ui, sans-serif; margin: 0; min-height: 100vh; display: grid; place-items: center; }
|
|
10
|
-
main { text-align: center; padding: 16px; }
|
|
11
|
-
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
|
|
12
|
-
p { margin: 0; opacity: 0.7; }
|
|
13
|
-
</style>
|
|
14
|
-
</head>
|
|
15
|
-
<body>
|
|
16
|
-
<main>
|
|
17
|
-
<h1>Something went wrong</h1>
|
|
18
|
-
<p>Please try again later.</p>
|
|
19
|
-
</main>
|
|
20
|
-
</body>
|
|
21
|
-
</html>`;function S(J,$,Z){if(!Z)console.error(J);else try{Z(J instanceof Error?J:Error(String(J),{cause:J}))}catch(X){console.error(J),console.error(X)}if(N($))return new Response(JSON.stringify({error:WJ("server_error","Internal Server Error",500)}),{status:500,headers:{"Content-Type":"application/json"}});return new Response(J2,{status:500,headers:{"Content-Type":"text/html; charset=utf-8"}})}var $2={kind:"none"};function jJ(J){let $=(J??"").trim().toLowerCase();if($===""||$==="false"||$==="off"||$==="0")return $2;if($==="true")return{kind:"all"};if(/^[1-9]\d*$/.test($))return{kind:"hops",hops:Number($)};throw Error(`GEMI_TRUST_PROXY must be "false", "true" or the number of proxies in front of the app (e.g. 1). Got ${JSON.stringify(J)}.`)}function GJ(J,$,Z){if(Z.kind==="all"){if(!J.get("x-forwarded-for")&&$)J.set("x-forwarded-for",$);return}J.delete("x-real-ip");let X=$;if(Z.kind==="hops"){let Q=(J.get("x-forwarded-for")??"").split(",").map((j)=>j.trim()).filter(Boolean),W=Q.length-Z.hops;X=W>=0?Q[W]:Q[0]??$}if(X)J.set("x-forwarded-for",X);else J.delete("x-forwarded-for")}var q=YJ(),X2=w(q,"app"),x=w(q,"dist"),C=w(x,"client");function Q2(J){let $;try{$=decodeURIComponent(J)}catch{return null}let Z=VJ(C,"."+$.replace("/assets/assets","/assets"));return Z.startsWith(C+zJ)?Z:null}async function H2(J){try{return(await Z2(J)).isFile()}catch{return!1}}async function Z3(J,$){let Z=await import(`${x}/client/.vite/manifest.json`),X=await import(`${x}/server/.vite/manifest.json`),Q=await UJ(`${x}/client`);process.env.ROOT_DIR=q,process.env.APP_DIR=X2,process.env.DIST_DIR=x;let W={},j={},Y={},K={},V={},I=(H,G)=>`"${H}": () => import("${G}")`,v=[];for(let H of["404",...J.getFlatComponentTree.call(J)]){let G=X[`app/views/${H}.tsx`];if(!G?.file){console.log(`Server file not found for ${H}`),console.log(G);let z=Object.keys(X),F=`app/views/${H}.tsx`;console.log(`${F} not found in server manifest`),console.log(z)}let U=await import(`${process.env.DIST_DIR}/server/${G?.file}`);W[H]=U.default,j[H]=U.OpenGraph,Y[H]=U;let O=Z[`app/views/${H}.tsx`];if(O?.css&&O?.css.length>0)K[H]=O?.css;if(O)v.push(I(H,L(O?.file,Q))),V[H]=M(Z,`app/views/${H}.tsx`,Q)}let xJ=`{${v.join(",")}}`,E=JJ(Z,Q);if(!E)console.error(`Client manifest has no "${_}" entry \u2014 dist/client is incomplete, so documents will render but never hydrate.`);let LJ=Z["app/client.tsx"]?.css??[],y=(await Promise.all(LJ.map((H)=>Bun.file(`${x}/client/${H}`).text()))).join(`
|
|
22
|
-
`),CJ=ZJ(Z,Q),g=new Map,IJ=(H)=>{let G=g.get(H);if(!G)G=Bun.file(`${x}/client/${H}`).text(),g.set(H,G);return G},FJ=async(H,G)=>{let U=new Set;for(let z of G?[G,...H]:H)for(let F of $J(Z,`app/views/${z}.tsx`))U.add(F);let O=await Promise.all([...U].map(async(z)=>({id:z,content:await IJ(z)})));return D(G?O:[{content:y},...O])},PJ=await r(C),f=new Map;for(let[H,G]of Object.entries((await l(C))?.files??{})){let U=VJ(C,H);if(U.startsWith(C+zJ))f.set(U,{immutable:!0,encodings:G})}async function _J(H){let{pathname:G}=new URL(H.url);if(N(G))return await T(H,G);let U=Q2(G);if(A(G)||G.startsWith("/.well-known")||U!==null&&PJ.has(U)){if(!U||!await H2(U))return HJ(G)??await T(H,G);try{return await s(H,U,f.get(U))}catch(z){return J.onException?.(z),new Response("Not found",{status:404})}}return await T(H,G)}async function T(H,G){let U=J.fetch.bind(J);try{let O=await U(H);if(O instanceof Response)return O;else{let z=[];return z.push({content:y}),await O({getStyles:async(R,u)=>{if(!R)return D([]);if(u?.static)return FJ(R,u.layout);for(let AJ of R){let NJ=Z[`app/views/${AJ}.tsx`];for(let h of NJ?.css??[]){let DJ=Bun.file(`${process.env.DIST_DIR}/client/${h}`);z.push({id:h,content:await DJ.text()})}}return D(z)},clientEntry:E,modulePreloadManifest:V,loaders:xJ,viewImportMap:W,viewModules:Y,ogMap:j,cssManifest:K,assetBase:Q,resolveIsland:CJ})}}catch(O){return S(O,G,J.onException)}}let BJ=(process.env.GEMI_COMPRESSION??"auto").toLowerCase()!=="off",MJ=jJ(process.env.GEMI_TRUST_PROXY),m=Bun.serve({maxRequestBodySize:10737418240,fetch:async(H,G)=>{GJ(H.headers,G.requestIP(H)?.address??null,MJ);let U=await $(H,(O)=>J.withGlobalMiddleware(O,_J,(z)=>S(z,new URL(O.url).pathname,J.onException)));return BJ?c(H,U):U},idleTimeout:OJ(),port:process.env.PORT||5173});return KJ({port:m.port,rootDir:q}),m}export{Z3 as httpProd};
|
|
23
|
-
|
|
24
|
-
//# debugId=682A3A7756A94FE864756E2164756E21
|
package/dist/chunk-mb7q7s0a.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{ec as B,gc as T}from"./chunk-1pem26zc.js";import{vh as _,wh as $,xh as L}from"./chunk-m6ystvtk.js";class D extends Error{code;constructor(q,z=1){super(q);this.code=z;this.name="CommandFailed"}}class Y{static commandName="unset";static description="";static args=[];static options=[];run(q){}}function u(q){return q}function A(){return{commands:[],commandsDir:"app/commands"}}var S=Symbol.for("gemi.console.builder");function E(q){if(q.trim()==="")throw Error("A command name cannot be empty.");if(/[{}]/.test(q)||/\s/.test(q))throw Error(`Invalid command name ${JSON.stringify(q)}. gemi does not parse a signature string; the name is the whole of it. Declare arguments with .arg() and flags with .option():
|
|
3
|
-
|
|
4
|
-
defineCommand("mail:send")
|
|
5
|
-
.arg("user", { required: true })
|
|
6
|
-
.option("queue", { type: "boolean" })
|
|
7
|
-
.handle(async ({ args, options }) => { ... })`)}function p(q){E(q);let z=[],F=[],J="",V={[S]:q,describe(G){return J=G,V},arg(G,H={}){if(H.required&&H.default!==void 0)throw Error(`Argument "${G}" of command "${q}" is both required and has a default. An argument that is supplied when absent cannot also be `+"absent \u2014 drop one.");if(H.variadic&&H.default!==void 0)throw Error(`Argument "${G}" of command "${q}" is variadic and has a default. A variadic argument collects the remaining values and is an empty list when there are none, so the default could never `+"apply \u2014 drop it, or drop `variadic`.");let Q=z.find((P)=>P.variadic);if(Q)throw Error(`Argument "${G}" of command "${q}" is declared after the variadic argument "${Q.name}", which collects everything that follows, so "${G}" could never receive a value. A variadic argument must be declared last.`);if(z.some((P)=>P.name===G))throw Error(`Command "${q}" declares the argument "${G}" twice.`);return z.push({...H,name:G}),V},option(G,H){if(F.some((X)=>X.name===G))throw Error(`Command "${q}" declares the option "${G}" twice.`);let Q="alias"in H?H.alias:void 0,P=Q===void 0?void 0:F.find((X)=>("alias"in X)&&X.alias===Q);if(P)throw Error(`Options "${P.name}" and "${G}" of command "${q}" both use the alias "-${Q}".`);return F.push({...H,name:G}),V},handle(G){let H=q,Q=J,P=class extends Y{static commandName=H;static description=Q;static args=[...z];static options=[...F];run(X){return G(X)}};return delete V[S],Object.defineProperty(P,"name",{value:H,configurable:!0}),P}};return V}function C(q){return typeof q==="object"&&q!==null&&typeof q[S]==="string"}class Z{name;cron;withoutOverlapping=!1;onOneServer=!1;shouldRun(){return!0}callback(q){}onTick(){}onComplete(){}static exp(q){return q}}function d(q){return q}function I(){return{jobs:[],jobsDir:"app/cron"}}function o(q){return q}function U(){return{listeners:[],listenersDir:"app/listeners"}}class M{static name="unset";static event;queued=!1;maxAttempts=3;backoff=0;worker=!1}import{existsSync as W}from"fs";import{dirname as R,isAbsolute as k,join as j}from"path";function K(q){return k(q)?q:j(L(),q)}function O(q,z,F){if(W(q)||W(R(q)))return;console.warn(`No ${z} were discovered: neither ${q} nor the directory above it exists, so this process cannot see the application's source. If this is a deploy that ships only the build output, list the classes explicitly in app/config/${F}.ts so they travel with it.`)}async function Vq(q=T().jobsDir){let z=K(q);O(z,"queue jobs","queue");let F=await $(z,B);return x(F),F}function x(q){for(let z of q){if(Object.getOwnPropertyDescriptor(z,"name")?.writable)continue;console.warn(`Queued job ${z.name} does not declare \`static name\`, so it is registered under its class name. A production build minifies the class that dispatches it and renames it, while discovery reads this `+"file from source and does not \u2014 so the dispatch would be dropped in "+`production and nowhere else. Add: static name = "${z.name}";`)}}async function Xq(q=I().jobsDir){let z=K(q);return O(z,"cron jobs","schedule"),await $(z,Z)}async function Yq(q=A().commandsDir){let z=K(q);O(z,"commands","command");let F=[],J=await $(z,Y,[],(V,G)=>{if(C(V))F.push(G)});return y(F),J}function y(q){if(q.length===0)return;let z=q.length===1?`${q[0]} exports a command builder that never called \`.handle()\``:`${q.length} files export a command builder that never called \`.handle()\`:
|
|
8
|
-
${q.join(`
|
|
9
|
-
`)}`;throw new _(`${z}, so there is no command to run. \`.handle()\` is what turns `+`the chain into a command \u2014 finish it:
|
|
10
|
-
|
|
11
|
-
`+` export default defineCommand("my-command")
|
|
12
|
-
.handle(async ({ line }) => { line("hello") })`)}async function $q(q=U().listenersDir){let z=K(q);O(z,"event listeners","events");let F=await $(z,M);return w(F),N(F),f(F),F}function w(q){let z=q.filter((F)=>!F.event);if(z.length===0)return;throw new _(`${z.map((F)=>F.name).join(", ")} declare no \`static event\`, so there is no event name to register them under and their \`handle\` would never run. Every listener binds to exactly one event:
|
|
13
|
-
|
|
14
|
-
static event = UserRegistered;
|
|
15
|
-
|
|
16
|
-
If this is an abstract base its subclasses extend, move it out of the `+"listeners directory \u2014 the walk excludes gemi's `Listener` and "+"nothing else, so a base sitting beside its subclasses is registered and run like one of them.")}function N(q){for(let z of q){if(Object.getOwnPropertyDescriptor(z,"name")?.writable)continue;console.warn(`Event listener ${z.name} does not declare \`static name\`, so it is registered under its class name, which a production build renames. Nothing reads that name across a build boundary while the `+"listener is sync, which is why this is a warning \u2014 but adding "+`\`queued = true\` to it is refused at boot for the same reason, because the queue's key is that string. Add: static name = "${z.name}";`)}}function f(q){let z=new Set;for(let{event:F}of q){if(z.has(F))continue;if(Object.getOwnPropertyDescriptor(F,"name")?.writable)continue;z.add(F),console.warn(`Event ${F.name} does not declare \`static name\`, so it is dispatched under its class name. A production build minifies the code that dispatches it and renames the class, while discovery reads `+"the listener's copy from source and does not \u2014 so the dispatch would "+`reach no listener in production and nowhere else. Add: static name = "${F.name}";`)}}
|
|
17
|
-
export{D as Ob,Y as Pb,u as Qb,A as Rb,p as Sb,Z as Tb,d as Ub,I as Vb,o as Wb,U as Xb,M as Yb,Vq as Zb,Xq as _b,Yq as $b,$q as ac};
|
|
18
|
-
|
|
19
|
-
//# debugId=CD91943D947C5AF864756E2164756E21
|
package/dist/chunk-mn5xw79b.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$f as B,ag as QH,bg as n}from"./chunk-pwmgqq7z.js";import{eg as C}from"./chunk-sq2wkynk.js";import{lh as NH}from"./chunk-q9s7kwgt.js";import{xh as f}from"./chunk-m6ystvtk.js";import{Eh as Y0}from"./chunk-1yx2e0bh.js";class YH{static kind="controller";constructor(){}}class kH extends YH{}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 L0(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 UH(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 T=X.slice(0,$),M=X.slice($+1);if(T===""){let K=I(M);if(K===null)return null;return{kind:"suffix",suffixLength:K}}let D=I(T);if(D===null)return null;if(M==="")return{kind:"offset",start:D,end:null};let W=I(M);if(W===null||W<D)return null;return{kind:"offset",start:D,end:W}}function KH(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 C0(H){if(H.kind==="suffix")return`bytes=-${H.suffixLength}`;return H.end===null?`bytes=${H.start}-`:`bytes=${H.start}-${H.end}`}function V0(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 _0(H,G,Q){return`bytes ${H}-${G}/${Q}`}function PH(H){return`bytes */${H}`}class x extends B{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 bH(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 fH(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 AH(H){if(typeof H==="string"||Array.isArray(H))return H.length;return}function l(H){return typeof H==="number"&&!Number.isNaN(H)}var vH=["required","string","boolean","number","email","password","min","max","gte","lte","file","fileType","fileSize","array","object","in"];class J 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 J(`Validation rule "${H}:${G??""}" needs a number, e.g. "${H}:3"`);return Q}function BH(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)=>l(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 T=AH($);return T!==void 0&&T>=X}}case"max":{let X=p(Q,Z);return($)=>{let T=AH($);return T!==void 0&&T<=X}}case"gte":{let X=p(Q,Z);return($)=>l($)&&$>=X}case"lte":{let X=p(Q,Z);return($)=>l($)&&$<=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 J('Validation rule "fileType" needs a type, e.g. "fileType:png" or "fileType:image"');let X=fH(Z);return($)=>$ instanceof Blob&&$.type.startsWith(X)}case"fileSize":{let X=bH(Z??"");if(X===0&&!/^0+(B|KB|MB|GB|TB)$/.test(Z??""))throw new J(`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 J('Validation rule "in" needs a comma-separated list, e.g. "in:draft,published"');return($)=>typeof $==="string"&&X.includes($)}default:throw new J(`Unknown validation rule "${H}". Known rules: ${vH.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 zH(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 pH(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=mH(cH(H.node,G),Q),X=[H.description,hH(H.node)].filter(Boolean).join(" ");if(X&&Z.$ref!==void 0)Z={anyOf:[Z]};return X?{description:X,...Z}:Z}function hH(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 cH(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 mH(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 dH(H){if(H===null)return"null";if(Array.isArray(H))return"array";return typeof H}function uH(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 dH(G)}function LH(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 LH({...q(G.cell),optional:!1,nullable:!1})}})();return H.optional||H.nullable?`${Q} or null`:Q}function oH(H){let G="";for(let Q of H)G+=typeof Q==="number"?`[${Q}]`:G?`.${Q}`:Q;return G}function nH(H){let G=oH(H);return G?`${G}: `:""}function s(H){return`${nH(H.path)}${H.message}`}function m(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[$,T]of Object.entries(Q.shape))X+=m(T,Z[$]);return X}case"union":return Q.members.reduce((Z,X)=>Math.max(Z,m(X,G)),0);case"json":return 1;case"ref":return JH(Q.cell,G,()=>1,()=>m(q(Q.cell),G))}}function JH(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:iH(H,G,Q,Z)}}function iH(H,G,Q,Z){let X=H.node,$=()=>{let T=G===void 0?"required":X.kind==="literal"?"const":X.kind==="enum"&&typeof G==="string"?"enum":"type",M=T==="const"?{allowedValue:X.value}:T==="enum"?{allowedValues:X.values}:{};Z.push({path:Q,code:T,message:`expected ${LH(H)}, got ${uH(X,G)}`,params:M});return};switch(X.kind){case"string":if(typeof G!=="string")return $();return FH(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 rH(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 FH(X.checks,G,Q,Z),G;case"array":{if(!Array.isArray(G))return $();let T=G.map((W,K)=>{let N=_(X.item,W,[...Q,K],Z);return N.drop?void 0:N.value}),{minItems:M,maxItems:D}=X.checks??{};if(M!==void 0&&G.length<M)Z.push({path:Q,code:"minItems",message:`expected at least ${M} items, got ${G.length}`,params:{limit:M}});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 T}case"object":{if(typeof G!=="object"||G===null||Array.isArray(G))return $();let T=G,M={};for(let[D,W]of Object.entries(X.shape)){let K=_(W,T[D],[...Q,D],Z);if(!K.drop)M[D]=K.value}if(X.unknownKeys)for(let D of Object.keys(T)){if(Object.hasOwn(X.shape,D)||T[D]===void 0)continue;if(X.unknownKeys==="error"){Z.push({path:[...Q,D],code:"additionalProperties",message:"unknown key",params:{additionalProperty:D}});continue}k(T[D],[...Q,D],Z,new Set),Object.defineProperty(M,D,{value:T[D],enumerable:!0,writable:!0,configurable:!0})}return M}case"union":{let T;for(let M of X.members){let D=[],W=_(M,G,Q,D);if(D.length===0)return W.drop?void 0:W.value;let K=m(M,G);if(!T||K>T.score)T={issues:D,score:K}}Z.push({path:Q,code:"anyOf",message:`no matching variant; closest: ${T.issues.map(s).join("; ")}`,params:{closest:T.issues}});return}case"json":if(G===void 0)return $();return k(G,Q,Z,new Set),G;case"ref":return JH(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 tH(H){let G=0;for(let Q of H)G++;return G}function FH(H,G,Q,Z){if(!H)return;let{minLength:X,maxLength:$,format:T}=H;if(X!==void 0||$!==void 0){let M=tH(G);if(X!==void 0&&M<X)Z.push({path:Q,code:"minLength",message:`expected at least ${X} characters, got ${M}`,params:{limit:X}});if($!==void 0&&M>$)Z.push({path:Q,code:"maxLength",message:`expected at most ${$} characters, got ${M}`,params:{limit:$}})}if(T){let M=!1;try{M=T.test(G)===!0}catch{}if(!M)Z.push({path:Q,code:"format",message:`expected a string in format "${T.name}"`,params:{format:T.name}})}}function rH(H,G,Q,Z){if(!H)return;let X=($,T,M,D)=>{if(T===void 0||M(T))return;Z.push({path:Q,code:$,message:`expected ${D} ${T}, got ${G}`,params:{limit:T}})};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 $=(M)=>{Q.push({path:G,code:"type",message:`expected a JSON value, got ${M}`,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 T=H;if(Z.has(T))return $("a circular reference");Z.add(T);try{let M=X?T.toJSON:void 0;if(typeof M==="function"){let D;try{D=M.call(T)}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,W)=>k(D,[...G,W],Q,Z));else for(let[D,W]of Object.entries(T))k(W,[...G,D],Q,Z)}finally{Z.delete(T)}}function F(H){return d(H)}function d(H){let G={toJSONSchema:()=>pH(H),parse(Q){let Z=[],X=_(H,Q,[],Z);if(Z.length>0)throw Error(Z.map(s).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(s)};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)=>d({...H,description:Q}),optional:()=>d({...H,optional:!0}),nullable:()=>d({...H,nullable:!0,optional:!1})};return o.set(G,H),G}function z(H){return{node:H,optional:!1,nullable:!1}}var RH=["strip","error","passthrough"];class CH 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 lH=new Set(["title","$schema","$id","$comment","examples","default","deprecated","readOnly","writeOnly"]),w={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=(Y,U=Q)=>{Z.push(U?`${U}: ${Y}`:Y);return},$=(Y)=>Q?`${Q}.${Y}`:Y;if(!h(H))return X("expected a schema object");let T=new Set(G.ignoreKeywords??[]),M=(Y)=>lH.has(Y)||Y.startsWith("x-")||T.has(Y),D=!1,W=H.type;if(Array.isArray(W)){let Y=W.filter((U)=>U!=="null");if(Y.length!==1)return X(`type ${JSON.stringify(W)} is not supported; only one type, optionally with "null". Use anyOf for alternatives`,$("type"));D=Y.length<W.length,W=Y[0]}if(W!==void 0&&(typeof W!=="string"||!(W in w)))return X(`type ${JSON.stringify(W)} is not supported; expected one of ${Object.keys(w).join(", ")}`,$("type"));let K=new Set(["type","description","enum","const","anyOf",...W?w[W]:[]]),N=!1;for(let Y of Object.keys(H)){if(K.has(Y)||M(Y))continue;N=!0;let U=Object.entries(w).find(([,A])=>A.includes(Y));X(U&&U[0]!==W?`"${Y}" applies to type ${U[0]}, and this schema is ${W?`type ${W}`:"untyped"}`:`"${Y}" is not supported by s.fromJSONSchema`,$(Y))}if(N)return;if(H.description!==void 0&&typeof H.description!=="string")return X("expected a string",$("description"));let v=H.description,L=(Y)=>({node:Y,optional:!1,nullable:D,...v?{description:v}:{}});if(H.anyOf!==void 0){if(W!==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 Y=[],U=!1;if(H.anyOf.forEach((A,P)=>{if(h(A)&&A.type==="null"&&Object.keys(A).length===1){D=!0;return}let R=u(A,G,$(`anyOf[${P}]`),Z);if(R)Y.push(R);else U=!0}),U)return;if(Y.length===0)return X("anyOf has only null in it",$("anyOf"));if(Y.length===1){let A=Y[0];return{...A,nullable:A.nullable||D,...v?{description:v}:{}}}return L({kind:"union",members:Y})}if(H.const!==void 0){let Y=H.const;if(typeof Y!=="string"&&typeof Y!=="number"&&typeof Y!=="boolean")return X("only a string, number or boolean const is supported",$("const"));if(W!==void 0&&typeof Y!==(W==="integer"?"number":W))return X(`const ${JSON.stringify(Y)} is not of type ${W}`,$("const"));return L({kind:"literal",value:Y})}let O;if(W==="string"){if(O=sH(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 Y=H.enum.filter((P)=>P!==null);if(Y.length<H.enum.length)D=!0;let U=Y.find((P)=>!(typeof P==="string"||typeof P==="number"||typeof P==="boolean")||W!==void 0&&typeof P!==(W==="integer"?"number":W));if(U!==void 0||Y.length===0)return X(W?`every value must be of type ${W}${Y.length===0?", and there must be one":`; ${JSON.stringify(U)} is not`}`:"only strings, numbers and booleans are supported",$("enum"));if(Y.every((P)=>typeof P==="string"))return L({kind:"enum",values:[...new Set(Y)],...O?{checks:O}:{}});let A=[...new Set(Y)];if(A.length===1)return L({kind:"literal",value:A[0]});return L({kind:"union",members:A.map((P)=>z({kind:"literal",value:P}))})}switch(W){case void 0:return X("a schema needs a type, an enum, a const or an anyOf");case"string":return L({kind:"string",...O?{checks:O}:{}});case"number":case"integer":{let Y=W==="integer"?{integer:!0}:{},U=!1;for(let A of w.number){let P=H[A];if(P===void 0)continue;if(typeof P!=="number"||!Number.isFinite(P)){X("expected a number",$(A)),U=!0;continue}Y[A]=P}if(U)return;return L({kind:"number",...Object.keys(Y).length>0?{checks:Y}:{}})}case"boolean":return L({kind:"boolean"});case"array":{if(!h(H.items))return X('an array needs "items" to be one schema (tuples are not supported)',$("items"));let Y={},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}Y[P]=R}let A=u(H.items,G,$("items"),Z);if(!A||U)return;return L({kind:"array",item:A,...Object.keys(Y).length>0?{checks:Y}:{}})}case"object":{let Y=H.properties??{};if(!h(Y))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 A=U.filter((V)=>!Object.hasOwn(Y,V));if(A.length>0)return X(`lists properties the schema doesn't have: ${A.join(", ")}`,$("required"));let P={},R=!1;for(let[V,yH]of Object.entries(Y)){let t=u(yH,G,$(`properties.${V}`),Z);if(!t){R=!0;continue}P[V]=U.includes(V)?t:{...t,optional:!0}}if(R)return;let i=G.unknownKeys;return L({kind:"object",shape:P,...i==="error"||i==="passthrough"?{unknownKeys:i}:{}})}}return}function sH(H,G,Q,Z){let X={},$=!1;for(let T of["minLength","maxLength"]){let M=H[T];if(M===void 0)continue;if(typeof M!=="number"||!Number.isInteger(M)||M<0){Z.push(`${Q(T)}: expected a non-negative integer`),$=!0;continue}X[T]=M}if(H.format!==void 0){let T=H.format,M=typeof T==="string"?G.formats?.[T]:void 0;if(typeof T!=="string")Z.push(`${Q("format")}: expected a string`),$=!0;else if(!M||!Object.hasOwn(G.formats,T))Z.push(`${Q("format")}: unknown format ${JSON.stringify(T)}; pass a check for it in the formats option`),$=!0;else X.format={name:T,test:aH(M)}}if($)return null;return Object.keys(X).length>0?X:void 0}function aH(H){if(H===!0)return()=>!0;if(H instanceof RegExp)return(G)=>{return H.lastIndex=0,H.test(G)};return H}var E0={string:()=>F(z({kind:"string"})),number:()=>F(z({kind:"number"})),boolean:()=>F(z({kind:"boolean"})),literal:(H)=>F(z({kind:"literal",value:H})),enum:(H)=>F(z({kind:"enum",values:H})),object:(H)=>F(z({kind:"object",shape:Object.fromEntries(Object.entries(H).map(([G,Q])=>[G,c(Q)]))})),array:(H)=>F(z({kind:"array",item:c(H)})),union:(H)=>F(z({kind:"union",members:H.map(c)})),json:()=>F(z({kind:"json"})),recursive:H0,fromJSONSchema:(H,G={})=>{let Q=[];if(G.unknownKeys!==void 0&&!RH.includes(G.unknownKeys))throw Error(`gemi/ai: s.fromJSONSchema's unknownKeys option must be one of ${RH.map((X)=>JSON.stringify(X)).join(", ")}, got ${JSON.stringify(G.unknownKeys)}`);let Z=u(H,G,"",Q);if(!Z||Q.length>0)throw new CH(Q.length>0?Q:["unreadable schema"]);return F(Z)}};function N0(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 a(H,G,Q=new Set){let Z=H.node;if(Z.kind==="union")return Z.members.some((X)=>a(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),a(Z.cell.definition,G,Q)}var eH=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function H0(H,G){if(typeof H!=="string"||!eH.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=()=>z({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(a(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 VH(H){if(typeof H!=="string")return null;let[G]=H.split(";",1),Q=G.trim().toLowerCase();return Q===""?null:Q}function _H(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 e=new WeakMap;function S0(H,G){e.set(H,{clientAddress:G})}function jH(H){return e.has(H)}function g0(H){return e.get(H)?.clientAddress}var OH=new WeakMap;function k0(H,G){OH.set(H,G)}function IH(H){return OH.get(H)??null}var HH=new WeakMap;function b0(H,G){let Q=HH.get(H)??[];if(!Q.includes(G))HH.set(H,[...Q,G])}function f0(H){return HH.get(H)??[]}class E{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 qH(H){return typeof H==="object"&&H!==null&&!(H instanceof Blob)}function G0(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:T}of Q){if(Z==="*"){if(Array.isArray(T))T.forEach((M,D)=>X.push({path:[...$,D],value:M}));else if(qH(T))for(let[M,D]of Object.entries(T))X.push({path:[...$,M],value:D});continue}if(Array.isArray(T)&&/^\d+$/.test(Z)){X.push({path:[...$,Number(Z)],value:T[Number(Z)]});continue}X.push({path:[...$,Z],value:qH(T)&&Object.hasOwn(T,Z)?T[Z]:void 0})}Q=X}return Q}function EH(H){return H.join(".")}class Q0{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=IH(H);this.headers=this.rawRequest.headers;let X=r(this.rawRequest.headers.get("Cookie")),$=new URL(this.rawRequest.url),T=new Map;for(let[D,W]of $.searchParams)if(T.has(D)){let K=T.get(D);if(Array.isArray(K))K.push(W),T.set(D,K);else T.set(D,[K,W])}else T.set(D,W);let M=Object.fromEntries(T.entries());this.search=new E(M),this.cookies=X}locale(){return C.getStore().locale}ctx(){return C.getStore()}isModelOriginated(){return jH(this.rawRequest)}get signal(){return this.rawRequest.signal}range(){return UH(this.rawRequest.headers.get("Range"))}refine(H){return{}}async parseBody(){let H=VH(this.rawRequest.headers.get("Content-Type"));if(_H(H))return new E(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 B)throw Z;throw new B("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 E(Object.fromEntries(Q.entries()))}return new E({})}async parseJsonBody(){if(!this.rawRequest.body)return{};let H;try{H=await this.rawRequest.text()}catch(Q){if(Q instanceof B)throw Q;throw new B("The request body could not be read.")}if(H.trim()==="")return{};let G;try{G=JSON.parse(H)}catch{throw new B("The request body is not valid JSON.")}if(G===null||typeof G!=="object")throw new B("The request body must be a JSON object.");return G}validateInput(H){if(zH(this.schema))return this.validateWithSchema(H);let G=H.toJSON()??{},Q={},Z=Object.entries(this.schema).map(([X,$])=>({key:X,rules:Object.entries($).map(([T,M])=>({rule:T,message:M,check:typeof M==="function"?null:this.ruleFor(X,T)}))}));for(let{key:X,rules:$}of Z)for(let{path:T,value:M}of G0(G,X)){let D=this.checkField(M,$);if(D.length>0){let W=Q[EH(T)]??=[];for(let K of D)if(!W.includes(K))W.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:T,check:M}of G){let D=T,W=!1;if(typeof T==="function")D=T(H),W=typeof D>"u";else W=M(H);if(W)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 $=EH(X.path),T=Q[$]??=[];if(!T.includes(X.message))T.push(X.message)}let Z="value"in G?new E(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 BH(G)}catch(Q){if(Q instanceof J)throw new J(`${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 X0 extends B{error;constructor(H="Not authorized"){super(H);this.name="AuthorizationError",this.error=H,this.payload={api:{status:401,data:{error:n("authorization",this.error,401)}},view:{}}}}class GH extends B{static apiStatus=403;error;constructor(H="Insufficient permissions"){super(H);this.name="InsufficientPermissionsError",this.error=H,this.payload={api:{status:GH.apiStatus,data:{error:n("permission",this.error,GH.apiStatus)}},view:{status:403}}}}class XH extends B{total;constructor(H){super("Range not satisfiable");this.total=H;this.name="RangeNotSatisfiableError",this.payload={api:{status:416,data:{error:QH("range_not_satisfiable","Range not satisfiable",416)},headers:{"Content-Range":PH(H),"Accept-Ranges":"bytes","Cache-Control":"no-store"}},view:{}}}}class j extends B{fileName;constructor(H){super("File not found");this.fileName=H;this.name="FileNotFoundError",this.payload={api:{status:404,data:{error:QH("not_found","Not found",404)},headers:{"Cache-Control":"no-store"}},view:{}}}}class Z0 extends B{constructor(H={}){super("Authentication error");this.name="AuthenticationError";let G=H.redirectTo??"/auth/sign-in";this.payload={api:{status:401,data:{error:n("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 NH(this.getFacadeAccessor())}}class ZH{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"),T=$?new Date($):void 0;if(G.range){let W=await Q.blob();return{body:W,start:0,end:W.size-1,total:W.size,partial:!1,type:Z,etag:X,lastModified:T,name:G.name}}let M=Number(Q.headers.get("Content-Length")),D=Number.isFinite(M)?M:0;return{body:Q.body,start:0,end:D-1,total:D,partial:!1,type:Z,etag:X,lastModified:T,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 xH(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(T){if(X=()=>{if(Z)return;$(),T.error(G.reason),Q.cancel(G.reason).catch(()=>{})},G.aborted)X();else G.addEventListener("abort",X,{once:!0})},async pull(T){let M;try{M=await Q.read()}catch(D){if(Z)return;$(),T.error(D);return}if(Z)return;if(M.done){$(),T.close();return}T.enqueue(M.value)},cancel(T){return $(),Q.cancel(T)}},{highWaterMark:0})}import{readdir as $0,unlink as T0}from"fs/promises";import{isAbsolute as M0,relative as D0,resolve as wH,sep as W0}from"path";class $H extends ZH{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),T=xH(Bun.file(X).stream(),G),M=new Date($.lastModified).toUTCString();return new Response(T,{headers:{"Content-Type":$.type,"Content-Length":String($.size),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":M}})}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,T=Z?KH(Z,$):null;if(Z&&!T)throw new XH($);let M=T?.start??0,D=T?T.end:$-1;return{body:T?X.slice(M,D+1):X,start:M,end:D,total:$,partial:Boolean(T),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=wH(this.folderPath),Z=wH(Q,G),X=D0(Q,Z);if(!X||X===".."||X.startsWith(`..${W0}`)||M0(X))throw Error(`Refusing to delete "${G}": it is outside the storage folder`);try{await T0(Z)}catch($){if($?.code==="ENOENT")return;throw $}}async list(){return await $0(this.folderPath)}}function P4(H){return H}function SH(){return{driver:new $H}}class TH{static token="filesystem";driver;constructor(H={}){this.driver=H.driver??SH().driver}}import{Buffer as U0}from"buffer";async function gH(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 K0 extends b{static getFacadeAccessor(){return TH}static async put(H,G={}){return this.getFacadeRoot().driver.put(H,G)}static async metadata(H){let G=U0.from(await H.arrayBuffer()),Q=await gH("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 MH,readdir as P0,access as A0}from"fs/promises";async function DH(H){try{return await A0(H),!0}catch{return!1}}class WH{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 DH(H))await MH(H);if(!await DH(this.logsDirPath))await MH(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await DH(this.logsDirPath))await MH(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 P0(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}},T="";try{T=JSON.stringify($)}catch(M){console.log("Error parsing log object",M)}try{let M=this.config.onLogCreated($);if(M instanceof Promise)M.catch((D)=>console.error("Error in onLogCreated",D))}catch(M){console.error("Error in onLogCreated",M)}if(!this.writer)return;this.writerSize+=T.length,this.fileSize+=T.length;try{this.writer.write(T),this.writer.write(`
|
|
6
|
-
`),this.tryFlush()}catch(M){console.error("Error writing log",M)}}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 B0 extends b{static getFacadeAccessor(){return WH}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 F0{config;static token="redis";instance=null;constructor(H={}){this.config=H}get client(){return this.instance??=new(R0())(this.config.url,this.config.options)}set client(H){this.instance=H}close(){let H=this.instance;this.instance=null,H?.close()}}function R0(){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}
|
|
7
|
-
export{YH as mf,kH as nf,L0 as of,VH as pf,S0 as qf,g0 as rf,UH as sf,KH as tf,C0 as uf,V0 as vf,_0 as wf,PH as xf,k0 as yf,IH as zf,b0 as Af,f0 as Bf,x as Cf,J as Df,CH as Ef,E0 as Ff,N0 as Gf,Q0 as Hf,X0 as If,GH as Jf,XH as Kf,j as Lf,Z0 as Mf,b as Nf,gH as Of,ZH as Pf,xH as Qf,$H as Rf,P4 as Sf,SH as Tf,TH as Uf,K0 as Vf,WH as Wf,B0 as Xf,F0 as Yf};
|
|
8
|
-
|
|
9
|
-
//# debugId=63553E03439F70CE64756E2164756E21
|
package/dist/chunk-x78jrs4y.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{I as _}from"./chunk-ddr4qvvt.js";import{V as ue}from"./chunk-h4sw6nt3.js";import{W as w}from"./chunk-gb37722w.js";import"./chunk-8afxrmdc.js";import{aa as l}from"./chunk-a6453d9s.js";import{Ah as o,Eh as d}from"./chunk-1yx2e0bh.js";var g=o(_(),1);var ie=o(l(),1);var O=o(w(),1),R=o(l(),1),J=o(_(),1);var j=o(w(),1),E=o(l(),1),U=(e,s,t)=>{let n={EcsContainer:async(r)=>{let{fromHttp:a}=await import("./chunk-1va15sfq.js"),{fromContainerMetadata:c}=await import("./chunk-xk930yaw.js");return t?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>E.chain(a(r??{}),c(r))().then(L)},Ec2InstanceMetadata:async(r)=>{t?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");let{fromInstanceMetadata:a}=await import("./chunk-xk930yaw.js");return async()=>a(r)().then(L)},Environment:async(r)=>{t?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");let{fromEnv:a}=await import("./chunk-8b2tw2yp.js");return async()=>a(r)().then(L)}};if(e in n)return n[e];else throw new E.CredentialsProviderError(`Unsupported credential source in profile ${s}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:t})},L=(e)=>j.setCredentialFeature(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p");var N=(e,{profile:s="default",logger:t}={})=>{return Boolean(e)&&typeof e==="object"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(he(e,{profile:s,logger:t})||ye(e,{profile:s,logger:t}))},he=(e,{profile:s,logger:t})=>{let n=typeof e.source_profile==="string"&&typeof e.credential_source>"u";if(n)t?.debug?.(` ${s} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`);return n},ye=(e,{profile:s,logger:t})=>{let n=typeof e.credential_source==="string"&&typeof e.source_profile>"u";if(n)t?.debug?.(` ${s} isCredentialSourceProfile credential_source=${e.credential_source}`);return n},v=async(e,s,t,n,r={},a)=>{t.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");let c=s[e],{source_profile:h,region:I}=c;if(!t.roleAssumer){let{getDefaultRoleAssumer:i}=await import("./chunk-9rchedr4.js").then((m)=>o(m.default,1));t.roleAssumer=i({...t.clientConfig,credentialProviderLogger:t.logger,parentClientConfig:{...n,...t?.parentClientConfig,region:I??t?.parentClientConfig?.region??n?.region}},t.clientPlugins)}if(h&&h in r)throw new R.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${J.getProfileName(t)}. Profiles visited: `+Object.keys(r).join(", "),{logger:t.logger});t.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${h?`source_profile=[${h}]`:`profile=[${e}]`}`);let T=h?a(h,s,t,n,{...r,[h]:!0},G(s[h]??{})):(await U(c.credential_source,e,t.logger)(t))();if(G(c))return T.then((i)=>O.setCredentialFeature(i,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"));else{let i={RoleArn:c.role_arn,RoleSessionName:c.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:c.external_id,DurationSeconds:parseInt(c.duration_seconds||"3600",10)},{mfa_serial:u}=c;if(u){if(!t.mfaCodeProvider)throw new R.CredentialsProviderError(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:t.logger,tryNextLink:!1});i.SerialNumber=u,i.TokenCode=await t.mfaCodeProvider(u)}let y=await T;return t.roleAssumer(y,i).then((m)=>O.setCredentialFeature(m,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"))}},G=(e)=>{return!e.role_arn&&!!e.credential_source};var V=o(w(),1);var C=o(w(),1),X=o(l(),1),K=o(_(),1);var k=o(l(),1),W=o(ue(),1),z=o(_(),1);import{createHash as de,createPrivateKey as we,createPublicKey as ke,sign as me}from"crypto";import{promises as D}from"fs";import{homedir as fe}from"os";import{dirname as Ie,join as Y}from"path";class b{profileData;init;callerClientConfig;static REFRESH_THRESHOLD=300000;constructor(e,s,t){this.profileData=e,this.init=s,this.callerClientConfig=t}async loadCredentials(){let e=await this.loadToken();if(!e)throw new k.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`,{tryNextLink:!1,logger:this.logger});let s=e.accessToken,t=Date.now();if(new Date(s.expiresAt).getTime()-t<=b.REFRESH_THRESHOLD)return this.refresh(e);return{accessKeyId:s.accessKeyId,secretAccessKey:s.secretAccessKey,sessionToken:s.sessionToken,accountId:s.accountId,expiration:new Date(s.expiresAt)}}get logger(){return this.init?.logger}get loginSession(){return this.profileData.login_session}async refresh(e){let{SigninClient:s,CreateOAuth2TokenCommand:t}=await import("./chunk-k1vw22t2.js").then((m)=>o(m.default,1)),{logger:n,userAgentAppId:r}=this.callerClientConfig??{},c=((i)=>{return i?.metadata?.handlerProtocol==="h2"})(this.callerClientConfig?.requestHandler)?void 0:this.callerClientConfig?.requestHandler,h=this.profileData.region??await this.callerClientConfig?.region?.()??process.env.AWS_REGION,I=new s({credentials:{accessKeyId:"",secretAccessKey:""},region:h,requestHandler:c,logger:n,userAgentAppId:r,...this.init?.clientConfig});this.createDPoPInterceptor(I.middlewareStack);let T={tokenInput:{clientId:e.clientId,refreshToken:e.refreshToken,grantType:"refresh_token"}};try{let i=await I.send(new t(T)),{accessKeyId:u,secretAccessKey:y,sessionToken:m}=i.tokenOutput?.accessToken??{},{refreshToken:x,expiresIn:H}=i.tokenOutput??{};if(!u||!y||!m||!x)throw new k.CredentialsProviderError("Token refresh response missing required fields",{logger:this.logger,tryNextLink:!1});let A=(H??900)*1000,f=new Date(Date.now()+A),q={...e,accessToken:{...e.accessToken,accessKeyId:u,secretAccessKey:y,sessionToken:m,expiresAt:f.toISOString()},refreshToken:x};await this.saveToken(q);let S=q.accessToken;return{accessKeyId:S.accessKeyId,secretAccessKey:S.secretAccessKey,sessionToken:S.sessionToken,accountId:S.accountId,expiration:f}}catch(i){if(i.name==="AccessDeniedException"){let u=i.error,y;switch(u){case"TOKEN_EXPIRED":y="Your session has expired. Please reauthenticate.";break;case"USER_CREDENTIALS_CHANGED":y="Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";break;case"INSUFFICIENT_PERMISSIONS":y="Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";break;default:y=`Failed to refresh token: ${String(i)}. Please re-authenticate using \`aws login\``}throw new k.CredentialsProviderError(y,{logger:this.logger,tryNextLink:!1})}throw new k.CredentialsProviderError(`Failed to refresh token: ${String(i)}. Please re-authenticate using aws login`,{logger:this.logger})}}async loadToken(){let e=this.getTokenFilePath();try{let s;try{s=await z.readFile(e,{ignoreCache:this.init?.ignoreCache})}catch{s=await D.readFile(e,"utf8")}let t=JSON.parse(s),n=["accessToken","clientId","refreshToken","dpopKey"].filter((r)=>!t[r]);if(!t.accessToken?.accountId)n.push("accountId");if(n.length>0)throw new k.CredentialsProviderError(`Token validation failed, missing fields: ${n.join(", ")}`,{logger:this.logger,tryNextLink:!1});return t}catch(s){throw new k.CredentialsProviderError(`Failed to load token from ${e}: ${String(s)}`,{logger:this.logger,tryNextLink:!1})}}async saveToken(e){let s=this.getTokenFilePath(),t=Ie(s);try{await D.mkdir(t,{recursive:!0})}catch(n){}await D.writeFile(s,JSON.stringify(e,null,2),"utf8")}getTokenFilePath(){let e=process.env.AWS_LOGIN_CACHE_DIRECTORY??Y(fe(),".aws","login","cache"),s=Buffer.from(this.loginSession,"utf8"),t=de("sha256").update(s).digest("hex");return Y(e,`${t}.json`)}derToRawSignature(e){let s=2;if(e[s]!==2)throw Error("Invalid DER signature");s++;let t=e[s++],n=e.subarray(s,s+t);if(s+=t,e[s]!==2)throw Error("Invalid DER signature");s++;let r=e[s++],a=e.subarray(s,s+r);n=n[0]===0?n.subarray(1):n,a=a[0]===0?a.subarray(1):a;let c=Buffer.concat([Buffer.alloc(32-n.length),n]),h=Buffer.concat([Buffer.alloc(32-a.length),a]);return Buffer.concat([c,h])}createDPoPInterceptor(e){e.add((s)=>async(t)=>{if(W.HttpRequest.isInstance(t.request)){let n=t.request,r=`${n.protocol}//${n.hostname}${n.port?`:${n.port}`:""}${n.path}`,a=await this.generateDpop(n.method,r);n.headers={...n.headers,DPoP:a}}return s(t)},{step:"finalizeRequest",name:"dpopInterceptor",override:!0})}async generateDpop(e="POST",s){let t=await this.loadToken();try{let n=we({key:t.dpopKey,format:"pem",type:"sec1"}),a=ke(n).export({format:"der",type:"spki"}),c=-1;for(let f=0;f<a.length;f++)if(a[f]===4){c=f;break}let h=a.slice(c+1,c+33),I=a.slice(c+33,c+65),T={alg:"ES256",typ:"dpop+jwt",jwk:{kty:"EC",crv:"P-256",x:h.toString("base64url"),y:I.toString("base64url")}},i={jti:crypto.randomUUID(),htm:e,htu:s,iat:Math.floor(Date.now()/1000)},u=Buffer.from(JSON.stringify(T)).toString("base64url"),y=Buffer.from(JSON.stringify(i)).toString("base64url"),m=`${u}.${y}`,x=me("sha256",Buffer.from(m),n),A=this.derToRawSignature(x).toString("base64url");return`${m}.${A}`}catch(n){throw new k.CredentialsProviderError(`Failed to generate Dpop proof: ${n instanceof Error?n.message:String(n)}`,{logger:this.logger,tryNextLink:!1})}}}var Q=(e)=>async({callerClientConfig:s}={})=>{e?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");let t=await K.parseKnownFiles(e||{}),n=K.getProfileName({profile:e?.profile??s?.profile}),r=t[n];if(!r?.login_session)throw new X.CredentialsProviderError(`Profile ${n} does not contain login_session.`,{tryNextLink:!0,logger:e?.logger});let c=await new b(r,e,s).loadCredentials();return C.setCredentialFeature(c,"CREDENTIALS_LOGIN","AD")};var Z=(e)=>{return Boolean(e&&e.login_session)},M=async(e,s,t)=>{let n=await Q({...s,profile:e})({callerClientConfig:t});return V.setCredentialFeature(n,"CREDENTIALS_PROFILE_LOGIN","AC")};var p=o(w(),1),ee=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.credential_process==="string",te=async(e,s)=>import("./chunk-k1xt2tw7.js").then(({fromProcess:t})=>t({...e,profile:s})().then((n)=>p.setCredentialFeature(n,"CREDENTIALS_PROFILE_PROCESS","v")));var $=o(w(),1),se=async(e,s,t={},n)=>{let{fromSSO:r}=await import("./chunk-w7jsh3xd.js");return r({profile:e,logger:t.logger,parentClientConfig:t.parentClientConfig,clientConfig:t.clientConfig})({callerClientConfig:n}).then((a)=>{if(s.sso_session)return $.setCredentialFeature(a,"CREDENTIALS_PROFILE_SSO","r");else return $.setCredentialFeature(a,"CREDENTIALS_PROFILE_SSO_LEGACY","t")})},ne=(e)=>e&&(typeof e.sso_start_url==="string"||typeof e.sso_account_id==="string"||typeof e.sso_session==="string"||typeof e.sso_region==="string"||typeof e.sso_role_name==="string");var ce=o(w(),1),P=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.aws_access_key_id==="string"&&typeof e.aws_secret_access_key==="string"&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,F=async(e,s)=>{s?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");let t={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return ce.setCredentialFeature(t,"CREDENTIALS_PROFILE","n")};var re=o(w(),1),ae=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.web_identity_token_file==="string"&&typeof e.role_arn==="string"&&["undefined","string"].indexOf(typeof e.role_session_name)>-1,oe=async(e,s,t)=>import("./chunk-pyj7cd9t.js").then(({fromTokenFile:n})=>n({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:s.roleAssumerWithWebIdentity,logger:s.logger,parentClientConfig:s.parentClientConfig})({callerClientConfig:t}).then((r)=>re.setCredentialFeature(r,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q")));var B=async(e,s,t,n,r={},a=!1)=>{let c=s[e];if(Object.keys(r).length>0&&P(c))return F(c,t);if(a||N(c,{profile:e,logger:t.logger}))return v(e,s,t,n,r,B);if(P(c))return F(c,t);if(ae(c))return oe(c,t,n);if(ee(c))return te(t,e);if(ne(c))return await se(e,c,t,n);if(Z(c))return M(e,t,n);throw new ie.CredentialsProviderError(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:t.logger})};var Ne=(e={})=>async({callerClientConfig:s}={})=>{e.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");let t=await g.parseKnownFiles(e);return B(g.getProfileName({profile:e.profile??s?.profile}),t,e,s)};export{Ne as fromIni};
|
|
3
|
-
|
|
4
|
-
//# debugId=EA8E63FED3F51C5664756E2164756E21
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|