gemi 0.63.0 → 0.65.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 +73 -0
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/AgentController.d.ts +75 -6
- package/dist/ai/AgentController.d.ts.map +1 -1
- package/dist/ai/AgentProvider.d.ts +5 -1
- package/dist/ai/AgentProvider.d.ts.map +1 -1
- package/dist/ai/Schema.d.ts +62 -0
- package/dist/ai/Schema.d.ts.map +1 -1
- package/dist/ai/client/index.js +10 -4
- package/dist/ai/client/index.js.map +1 -1
- package/dist/ai/client/reducer.d.ts.map +1 -1
- package/dist/ai/index.d.ts +2 -1
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +12 -12
- package/dist/ai/index.js.map +6 -6
- package/dist/ai/live/harness.d.ts +5 -3
- package/dist/ai/live/harness.d.ts.map +1 -1
- package/dist/ai/types.d.ts +29 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/useChat.d.ts +60 -4
- package/dist/ai/useChat.d.ts.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/auth/AuthController.d.ts.map +1 -1
- package/dist/auth/AuthManager.d.ts +38 -4
- package/dist/auth/AuthManager.d.ts.map +1 -1
- package/dist/auth/UserProvider.d.ts.map +1 -1
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/auth/sessionToken.d.ts +38 -0
- package/dist/auth/sessionToken.d.ts.map +1 -0
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/bin/gemi.js +9 -1
- package/dist/bin/gemi.js.map +3 -3
- package/dist/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-jv9k1qfr.js → chunk-2bb3rdqq.js} +3 -3
- package/dist/{chunk-jv9k1qfr.js.map → chunk-2bb3rdqq.js.map} +1 -1
- package/dist/{chunk-e785380d.js → chunk-2dvjj3ad.js} +2 -2
- package/dist/{chunk-e785380d.js.map → chunk-2dvjj3ad.js.map} +1 -1
- package/dist/{chunk-rj3fnc4h.js → chunk-2ghpxrw1.js} +1 -1
- package/dist/{chunk-dqbm9vd0.js → chunk-3mp9p38x.js} +2 -2
- package/dist/{chunk-dqbm9vd0.js.map → chunk-3mp9p38x.js.map} +1 -1
- package/dist/{chunk-cdpeh7tt.js → chunk-3pwn2r6s.js} +2 -2
- package/dist/{chunk-cdpeh7tt.js.map → chunk-3pwn2r6s.js.map} +1 -1
- package/dist/{chunk-7qfzrkab.js → chunk-45g3hd0e.js} +2 -2
- package/dist/{chunk-7qfzrkab.js.map → chunk-45g3hd0e.js.map} +1 -1
- package/dist/{chunk-wqmzad46.js → chunk-5g1j29p2.js} +2 -2
- package/dist/{chunk-wqmzad46.js.map → chunk-5g1j29p2.js.map} +1 -1
- package/dist/{chunk-bxtx4y4w.js → chunk-5pm9zvtp.js} +2 -2
- package/dist/{chunk-bxtx4y4w.js.map → chunk-5pm9zvtp.js.map} +1 -1
- package/dist/{chunk-pbx9p6g0.js → chunk-6waph5k8.js} +1 -1
- package/dist/{chunk-nnc40mf3.js → chunk-70y8wajy.js} +2 -2
- package/dist/{chunk-nnc40mf3.js.map → chunk-70y8wajy.js.map} +1 -1
- package/dist/{chunk-71yhw8aw.js → chunk-731etrh2.js} +2 -2
- package/dist/{chunk-71yhw8aw.js.map → chunk-731etrh2.js.map} +1 -1
- package/dist/{chunk-1s1cd1e8.js → chunk-7438nrkm.js} +3 -3
- package/dist/{chunk-1s1cd1e8.js.map → chunk-7438nrkm.js.map} +1 -1
- package/dist/{chunk-ssg20z9s.js → chunk-7wgk7q33.js} +3 -3
- package/dist/{chunk-ssg20z9s.js.map → chunk-7wgk7q33.js.map} +1 -1
- package/dist/chunk-7xc64j6p.js +5 -0
- package/dist/chunk-7xc64j6p.js.map +14 -0
- package/dist/{chunk-jmse5hec.js → chunk-7zg1mt1g.js} +2 -2
- package/dist/{chunk-jmse5hec.js.map → chunk-7zg1mt1g.js.map} +1 -1
- package/dist/{chunk-0qchadp1.js → chunk-87c0cy5v.js} +2 -2
- package/dist/{chunk-0qchadp1.js.map → chunk-87c0cy5v.js.map} +1 -1
- package/dist/{chunk-773qa4av.js → chunk-8bjxk57p.js} +2 -2
- package/dist/{chunk-773qa4av.js.map → chunk-8bjxk57p.js.map} +1 -1
- package/dist/{chunk-81yzec62.js → chunk-8jpvj3cj.js} +2 -2
- package/dist/{chunk-81yzec62.js.map → chunk-8jpvj3cj.js.map} +1 -1
- package/dist/{chunk-9e5c5e15.js → chunk-9ch1q7nd.js} +2 -2
- package/dist/{chunk-9e5c5e15.js.map → chunk-9ch1q7nd.js.map} +1 -1
- package/dist/{chunk-9e5v1t73.js → chunk-9x5eefh0.js} +2 -2
- package/dist/{chunk-9e5v1t73.js.map → chunk-9x5eefh0.js.map} +1 -1
- package/dist/{chunk-62xjrz5e.js → chunk-9zmcz7yq.js} +2 -2
- package/dist/{chunk-62xjrz5e.js.map → chunk-9zmcz7yq.js.map} +1 -1
- package/dist/{chunk-0amv13g6.js → chunk-a85fn4zf.js} +3 -3
- package/dist/{chunk-0amv13g6.js.map → chunk-a85fn4zf.js.map} +1 -1
- package/dist/chunk-adj6dnvj.js +5 -0
- package/dist/{chunk-dq2hgzje.js.map → chunk-adj6dnvj.js.map} +1 -1
- package/dist/{chunk-exwbtfe9.js → chunk-aq09ta7k.js} +2 -2
- package/dist/{chunk-exwbtfe9.js.map → chunk-aq09ta7k.js.map} +1 -1
- package/dist/{chunk-43xw9n4f.js → chunk-dmr7yzyr.js} +2 -2
- package/dist/{chunk-43xw9n4f.js.map → chunk-dmr7yzyr.js.map} +1 -1
- package/dist/{chunk-q4wdg0y3.js → chunk-e0v4byjp.js} +2 -2
- package/dist/{chunk-ptjexzn1.js.map → chunk-e0v4byjp.js.map} +1 -1
- package/dist/{chunk-8wpccvbt.js → chunk-e1fkxt82.js} +2 -2
- package/dist/{chunk-8wpccvbt.js.map → chunk-e1fkxt82.js.map} +1 -1
- package/dist/{chunk-xadk41cs.js → chunk-ex9ns7pf.js} +4 -4
- package/dist/{chunk-xadk41cs.js.map → chunk-ex9ns7pf.js.map} +1 -1
- package/dist/{chunk-95d8jj11.js → chunk-fd7wfcft.js} +2 -2
- package/dist/{chunk-95d8jj11.js.map → chunk-fd7wfcft.js.map} +1 -1
- package/dist/{chunk-maxd55a0.js → chunk-fk127cwf.js} +2 -2
- package/dist/{chunk-maxd55a0.js.map → chunk-fk127cwf.js.map} +2 -2
- package/dist/{chunk-kx7vgcjp.js → chunk-fmcq21hg.js} +3 -3
- package/dist/{chunk-kx7vgcjp.js.map → chunk-fmcq21hg.js.map} +1 -1
- package/dist/{chunk-k1wkvrj0.js → chunk-ftaxfq7p.js} +3 -3
- package/dist/{chunk-k1wkvrj0.js.map → chunk-ftaxfq7p.js.map} +1 -1
- package/dist/{chunk-zdj2wmbj.js → chunk-fxkh2rfd.js} +2 -2
- package/dist/{chunk-zdj2wmbj.js.map → chunk-fxkh2rfd.js.map} +1 -1
- package/dist/{chunk-9k5daets.js → chunk-g2ywq30n.js} +2 -2
- package/dist/{chunk-9k5daets.js.map → chunk-g2ywq30n.js.map} +1 -1
- package/dist/chunk-hq496pa4.js +5 -0
- package/dist/chunk-hq496pa4.js.map +10 -0
- package/dist/{chunk-4sv5zpb4.js → chunk-hrtkjv41.js} +2 -2
- package/dist/{chunk-4sv5zpb4.js.map → chunk-hrtkjv41.js.map} +1 -1
- package/dist/{chunk-tq92xqkk.js → chunk-j3b3qerv.js} +2 -2
- package/dist/{chunk-tq92xqkk.js.map → chunk-j3b3qerv.js.map} +1 -1
- package/dist/{chunk-dhe1hsyz.js → chunk-jkjt3e06.js} +2 -2
- package/dist/{chunk-dhe1hsyz.js.map → chunk-jkjt3e06.js.map} +1 -1
- package/dist/{chunk-5wzyx4ts.js → chunk-ks94h71z.js} +2 -2
- package/dist/{chunk-5wzyx4ts.js.map → chunk-ks94h71z.js.map} +1 -1
- package/dist/{chunk-rhr8qavq.js → chunk-m44ar4he.js} +2 -2
- package/dist/{chunk-rhr8qavq.js.map → chunk-m44ar4he.js.map} +1 -1
- package/dist/{chunk-0081bz9c.js → chunk-nxg51m0q.js} +2 -2
- package/dist/{chunk-0081bz9c.js.map → chunk-nxg51m0q.js.map} +1 -1
- package/dist/{chunk-qrfp7pg2.js → chunk-nxh5a3eb.js} +3 -3
- package/dist/{chunk-qrfp7pg2.js.map → chunk-nxh5a3eb.js.map} +1 -1
- package/dist/{chunk-qcbtr7hm.js → chunk-p0m3qgs5.js} +2 -2
- package/dist/{chunk-qcbtr7hm.js.map → chunk-p0m3qgs5.js.map} +1 -1
- package/dist/{chunk-jk8mn861.js → chunk-p5m0da00.js} +2 -2
- package/dist/{chunk-jk8mn861.js.map → chunk-p5m0da00.js.map} +1 -1
- package/dist/{chunk-fv223805.js → chunk-pb0m0ryf.js} +3 -3
- package/dist/{chunk-fv223805.js.map → chunk-pb0m0ryf.js.map} +1 -1
- package/dist/{chunk-7hbhbht2.js → chunk-pcxxnnad.js} +3 -3
- package/dist/{chunk-7hbhbht2.js.map → chunk-pcxxnnad.js.map} +1 -1
- package/dist/{chunk-2d92pev2.js → chunk-pxc51549.js} +2 -2
- package/dist/{chunk-2d92pev2.js.map → chunk-pxc51549.js.map} +1 -1
- package/dist/{chunk-454c7vn3.js → chunk-q1nq7n6y.js} +2 -2
- package/dist/{chunk-454c7vn3.js.map → chunk-q1nq7n6y.js.map} +1 -1
- package/dist/{chunk-48qybp63.js → chunk-qqchc40s.js} +2 -2
- package/dist/{chunk-48qybp63.js.map → chunk-qqchc40s.js.map} +1 -1
- package/dist/{chunk-feyr4851.js → chunk-r069158p.js} +2 -2
- package/dist/{chunk-feyr4851.js.map → chunk-r069158p.js.map} +1 -1
- package/dist/{chunk-ptjexzn1.js → chunk-r6v21jn6.js} +2 -2
- package/dist/{chunk-q4wdg0y3.js.map → chunk-r6v21jn6.js.map} +1 -1
- package/dist/{chunk-6j129573.js → chunk-r77f1482.js} +2 -2
- package/dist/{chunk-6j129573.js.map → chunk-r77f1482.js.map} +1 -1
- package/dist/{chunk-jmbdr550.js → chunk-rnjbja88.js} +2 -2
- package/dist/{chunk-jmbdr550.js.map → chunk-rnjbja88.js.map} +1 -1
- package/dist/{chunk-q8msf1gf.js → chunk-rq2k9frr.js} +2 -2
- package/dist/{chunk-q8msf1gf.js.map → chunk-rq2k9frr.js.map} +1 -1
- package/dist/chunk-se5ekvgb.js +19 -0
- package/dist/{chunk-anfs5mwm.js.map → chunk-se5ekvgb.js.map} +12 -11
- package/dist/{chunk-v6v03hy7.js → chunk-sqc6fkqt.js} +2 -2
- package/dist/{chunk-v6v03hy7.js.map → chunk-sqc6fkqt.js.map} +1 -1
- package/dist/{chunk-78cvy4je.js → chunk-tn71d46d.js} +2 -2
- package/dist/{chunk-78cvy4je.js.map → chunk-tn71d46d.js.map} +1 -1
- package/dist/{chunk-hkhxkeeb.js → chunk-v6q4990x.js} +3 -3
- package/dist/{chunk-hkhxkeeb.js.map → chunk-v6q4990x.js.map} +1 -1
- package/dist/{chunk-e41vdprh.js → chunk-w34j3cd3.js} +3 -3
- package/dist/{chunk-e41vdprh.js.map → chunk-w34j3cd3.js.map} +1 -1
- package/dist/{chunk-35fbxgjh.js → chunk-wzqxtrpt.js} +2 -2
- package/dist/{chunk-35fbxgjh.js.map → chunk-wzqxtrpt.js.map} +1 -1
- package/dist/{chunk-39p7ge47.js → chunk-x917yccy.js} +2 -2
- package/dist/{chunk-39p7ge47.js.map → chunk-x917yccy.js.map} +1 -1
- package/dist/{chunk-z2fnf49p.js → chunk-xzexftx1.js} +1 -1
- package/dist/{chunk-dfv5eqma.js → chunk-z4k18gnp.js} +2 -2
- package/dist/{chunk-dfv5eqma.js.map → chunk-z4k18gnp.js.map} +1 -1
- package/dist/{chunk-b6948dnh.js → chunk-z6gzasra.js} +2 -2
- package/dist/{chunk-b6948dnh.js.map → chunk-z6gzasra.js.map} +1 -1
- package/dist/{chunk-p57x55qd.js → chunk-zqpskwk9.js} +2 -2
- package/dist/{chunk-p57x55qd.js.map → chunk-zqpskwk9.js.map} +1 -1
- package/dist/chunks/ThemeProvider-Bz-y1g2i.js.map +1 -1
- package/dist/client/ClientRouter.d.ts.map +1 -1
- package/dist/client/Link.d.ts +3 -2
- package/dist/client/Link.d.ts.map +1 -1
- package/dist/client/Redirect.d.ts +3 -3
- package/dist/client/Redirect.d.ts.map +1 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -7
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +72 -2
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/useNavigate.d.ts +29 -6
- package/dist/client/useNavigate.d.ts.map +1 -1
- package/dist/client/usePrefetch.d.ts +13 -3
- package/dist/client/usePrefetch.d.ts.map +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/Connection.d.ts.map +1 -1
- package/dist/database/index.d.ts +1 -0
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/database/sqlitePath.d.ts +46 -0
- package/dist/database/sqlitePath.d.ts.map +1 -0
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Auth.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/ApiRouter.d.ts +1 -1
- package/dist/http/ApiRouter.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 +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.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/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/ai/Agent.test-d.d.ts +0 -2
- package/dist/ai/Agent.test-d.d.ts.map +0 -1
- package/dist/ai/Schema.test-d.d.ts +0 -2
- package/dist/ai/Schema.test-d.d.ts.map +0 -1
- package/dist/ai/client/reducer.test-d.d.ts +0 -2
- package/dist/ai/client/reducer.test-d.d.ts.map +0 -1
- package/dist/ai/example.d.ts +0 -129
- package/dist/ai/example.d.ts.map +0 -1
- package/dist/chunk-4728yrmt.js +0 -5
- package/dist/chunk-4728yrmt.js.map +0 -10
- package/dist/chunk-anfs5mwm.js +0 -19
- package/dist/chunk-dq2hgzje.js +0 -5
- package/dist/chunk-f9ccncar.js +0 -5
- package/dist/chunk-f9ccncar.js.map +0 -13
- package/dist/client/useDictionary.test-d.d.ts +0 -2
- package/dist/client/useDictionary.test-d.d.ts.map +0 -1
- package/dist/console/builder.test-d.d.ts +0 -2
- package/dist/console/builder.test-d.d.ts.map +0 -1
- package/dist/http/ApiRouter.test-d.d.ts +0 -2
- package/dist/http/ApiRouter.test-d.d.ts.map +0 -1
- package/dist/http/McpRouter.test-d.d.ts +0 -2
- package/dist/http/McpRouter.test-d.d.ts.map +0 -1
- package/dist/services/events/FakeEventManager.test-d.d.ts +0 -2
- package/dist/services/events/FakeEventManager.test-d.d.ts.map +0 -1
- package/dist/services/events/Listener.test-d.d.ts +0 -2
- package/dist/services/events/Listener.test-d.d.ts.map +0 -1
- /package/dist/{chunk-rj3fnc4h.js.map → chunk-2ghpxrw1.js.map} +0 -0
- /package/dist/{chunk-pbx9p6g0.js.map → chunk-6waph5k8.js.map} +0 -0
- /package/dist/{chunk-z2fnf49p.js.map → chunk-xzexftx1.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{if as C}from"./chunk-87c0cy5v.js";import{kf as W,lf as S,of as A,pf as U}from"./chunk-ftaxfq7p.js";import{If as I}from"./chunk-7xc64j6p.js";import{eg as E}from"./chunk-p5m0da00.js";import{hg as N}from"./chunk-731etrh2.js";class K{table;sql;dialect;connection;busyTimeout;configured;constructor(z,G={}){let V=G.table??"gemi_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(V))throw Error(`The queue table name "${V}" is not a plain identifier. Use letters, digits and underscores.`);let Y=G.busyTimeout??1000;if(!Number.isInteger(Y)||Y<0)throw Error(`The queue's busyTimeout must be a whole number of milliseconds, 0 or more; got ${Y}.`);this.table=V,this.sql=z.sql,this.dialect=z.dialect,this.connection=z.name,this.busyTimeout=Y}configure(){if(this.dialect!=="sqlite"||this.busyTimeout===0)return Promise.resolve();return this.configured??=(async()=>{let[z]=await this.sql.unsafe("PRAGMA busy_timeout");if(Number(z?.timeout??0)!==0)return;await this.sql.unsafe(`PRAGMA busy_timeout = ${this.busyTimeout}`)})().catch((z)=>{throw this.configured=void 0,z}),this.configured}async createTable(){await this.configure();for(let z of R(this.dialect,this.table))await this.sql.unsafe(z)}enqueue(z){let G=this.transaction(),V=this.insert(G??this.sql,z);if(G)U(V);return V}async insert(z,{name:G,args:V,delayMs:Y=0,id:Z=Bun.randomUUIDv7()}){await this.configure();let $=this.now(z);return await z`
|
|
3
3
|
INSERT INTO ${this.name(z)}
|
|
4
4
|
(id, name, payload, status, attempts, available_at, created_at, updated_at)
|
|
5
5
|
VALUES
|
|
@@ -137,6 +137,6 @@ import{hf as C}from"./chunk-0qchadp1.js";import{jf as W,kf as S,nf as A,of as U}
|
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
`],"worker.ts"),Z=URL.createObjectURL(Y);return new Worker(Z)}async function T(z,G){let V=M();return V.postMessage({jobName:z,args:G}),await new Promise((Y,Z)=>{V.onmessage=($)=>{let B=$.data;if("error"in B)Z(B.error);else Y(B.result)}})}var D=new P("gemi.queue"),k=60000;class x{static token="queue";jobs={};config;driver;application;inFlight=new Map;state="idle";looping=!1;claiming;woken=!1;claimFailures=0;resume;unsubscribe;heartbeatTimer;releasedNames=new Set;constructor(z={},G={}){this.config=C(_(),z),this.application=G.application,this.driver=q(this.config.driver,this.application),this.useJobs(this.config.jobs)}useJobs(z){this.config.jobs=z,this.jobs={};for(let G of z)this.claim(G)}registerJob(z){this.config.jobs=[...this.config.jobs,z],this.claim(z)}claim(z){if(this.jobs[z.name]){console.error(`Two queued jobs are named "${z.name}" \u2014 the first is registered `+"and this one is not, so dispatching either would have run one of them. A class name is the queue's key, so only one job can hold it. Rename one.");return}this.jobs[z.name]=z}get registeredJobs(){return[...this.config.jobs]}dispatchJob(z,G){if(this.jobs[z])return new this.jobs[z]().run(JSON.parse(G))}push(z,G,V={}){let Y=this.driver.joinsTransaction?.()===!0;if(!Y){let Z=Bun.randomUUIDv7();if(A(()=>this.record(z,G,{id:Z,reportFailure:!0,committed:!0}).then(()=>{},()=>{})))return Promise.resolve(Z)}return this.record(z,G,{reportFailure:V.reportFailure,joins:Y})}record(z,G,V){let Y=this.driver.enqueue({name:z.name,args:G,...V.id===void 0?{}:{id:V.id}});this.startIfIdle();let Z=()=>!this.driver.subscribe&&this.state==="running"&&this.wake(),$=V.joins===!0&&A(Z);return Y.then(()=>$||Z(),(B)=>{if(V.reportFailure===!1)return;console.error(`[gemi] The queue driver could not record ${z.name}`+(V.committed?", which was held until its transaction committed. The transaction stays committed; the job did not run and will not be retried.":", so it did not run and will not be retried."),B)}),Y}async retryDead(z){if(!this.driver.retryDead)throw Error("This queue's driver keeps nothing of a dead-lettered job, so there is nothing to retry. The database driver keeps them.");let G=await this.driver.retryDead(z);if(G)this.claimSoon();return G}startIfIdle(){if(this.state==="idle"&&(!this.durable||this.mayClaimHere()))this.start()}claimSoon(){if(this.startIfIdle(),!this.driver.subscribe&&this.state==="running")this.wake()}start(){if(this.state==="running")return;if(this.state="running",this.durable&&this.application&&this.mayClaimHere()&&!v())globalThis.__gemiDevQueue=this;if(this.unsubscribe=this.driver.subscribe?.(()=>this.wake()),this.looping)return this.wake();D.runInAsyncScope(()=>void this.loop())}async drain(z=1/0){if(this.state="stopped",globalThis.__gemiDevQueue===this)globalThis.__gemiDevQueue=void 0;this.unsubscribe?.(),this.unsubscribe=void 0,this.wake();let G,V=new Promise((Z)=>{if(z!==1/0)G=setTimeout(Z,z)}),Y=(async()=>{await this.claiming?.catch(()=>{}),await Promise.allSettled([...this.inFlight.values()].map((Z)=>Z.done))})();return await Promise.race([Y,V]),clearTimeout(G),{unfinished:[...this.inFlight.values()].map((Z)=>({...Z.job}))}}stop(){return this.drain(0)}get running(){return this.inFlight.size}async loop(){this.looping=!0;try{await this.claimWhileRunning()}finally{this.looping=!1}}async claimWhileRunning(){while(this.state==="running"){let z=this.durable&&N()?0:this.config.concurrency-this.inFlight.size;if(z>0){this.woken=!1;let G=this.driver.claim(z,{...this.lease(),registered:{names:Object.keys(this.jobs),graceMs:this.config.unknownJobGrace}});this.claiming=G;let V=[];try{V=await G,this.claimFailures=0}catch(Y){this.claimFailures++,console.error(`The queue could not claim jobs from its driver; it will try again in ${this.retryDelay()}ms.`,Y)}finally{this.claiming=void 0}for(let Y of V)this.execute(Y);if(V.length===z)continue;if(this.woken&&this.inFlight.size<this.config.concurrency)continue}await this.sleep()}}sleep(){return new Promise((z)=>{let G,V=this.claimFailures>0?this.retryDelay():this.driver.subscribe?void 0:this.config.pollInterval;if(V!==void 0)G=setTimeout(()=>this.wake(),V),G.unref?.();this.resume=()=>{clearTimeout(G),z()}})}retryDelay(){let z=Math.min(Math.max(0,this.claimFailures-1),30);return Math.min(this.config.pollInterval*2**z,k)}wake(){this.woken=!0;let z=this.resume;this.resume=void 0,z?.()}get durable(){return!(this.driver instanceof X)}mayClaimHere(){return!this.application||g()}lease(){return{visibilityTimeoutMs:this.config.visibilityTimeout}}execute(z){let G=`${z.id}:${z.attempt}`,V=()=>this.run(z),Y=(this.application?E.run(this.application,V):V()).catch((Z)=>{console.error(`The queue could not record the outcome of ${z.name}.`,Z)}).finally(()=>{this.inFlight.delete(G),this.wake()});this.inFlight.set(G,{job:z,done:Y}),this.heartbeat()}heartbeat(){let z=this.driver;if(!z.heartbeat||this.heartbeatTimer)return;this.heartbeatTimer=setInterval(()=>{if(this.inFlight.size===0){clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0;return}let G=[...this.inFlight.values()].map((V)=>V.job);z.heartbeat(G,this.lease()).catch((V)=>{console.error("The queue could not extend its job leases.",V)})},Math.max(1,Math.floor(this.config.visibilityTimeout/3))),this.heartbeatTimer.unref?.()}async run(z){let G=this.jobs[z.name];if(!G){let Z=Date.now()-z.createdAt;if(this.durable&&Z<this.config.unknownJobGrace){if(!this.releasedNames.has(z.name))this.releasedNames.add(z.name),console.error(`Left a queued "${z.name}" for another replica: nothing is registered here under that name. It is dead-lettered if no replica has run it within unknownJobGrace (${this.config.unknownJobGrace}ms) of its dispatch.`);await this.driver.release(z,{retryInMs:Math.round(this.config.pollInterval*(1+Math.random()))});return}console.error(`Dropped a queued job: nothing is registered under the name "${z.name}". If the class exists, it was not `+"discovered \u2014 check that it is under the queue slice's jobsDir "+"(app/jobs by default), or list it in app/config/queue.ts."),await this.driver.fail(z,{error:`No job is registered under the name "${z.name}".`,retryInMs:null});return}let V;try{V=new G}catch(Z){console.error(`Dropped a queued ${z.name}: it could not be constructed.`,Z),await this.driver.fail(z,{error:`The job could not be constructed: ${String(Z)}`,retryInMs:null});return}let Y;try{Y=JSON.parse(z.args)}catch(Z){console.error(`Dropped a queued ${z.name}: its arguments are not JSON.`,Z),await this.driver.fail(z,{error:`The arguments are not JSON: ${String(Z)}`,retryInMs:null});return}if(z.attempt>Math.max(1,V.maxAttempts)){let Z=Error(`${z.name} was claimed for attempt ${z.attempt} of ${V.maxAttempts}: an earlier attempt never finished, most likely because the process running it exited. Dead-lettered without running it again.`);L(`${z.name}.onDeadletter`,()=>V.onDeadletter(Z,...Y)),await this.driver.fail(z,{error:Z.message,retryInMs:null});return}try{let Z=await(V.worker?T(z.name,z.args):V.run(...Y));V.onSuccess(Z,...Y)}catch(Z){let $=Z,B=String($?.stack??$);if(L(`${z.name}.onFail`,()=>V.onFail($,...Y)),z.attempt>=V.maxAttempts)L(`${z.name}.onDeadletter`,()=>V.onDeadletter($,...Y)),await this.driver.fail(z,{error:B,retryInMs:null});else await this.driver.fail(z,{error:B,retryInMs:f(V.backoff,z.attempt)});return}await this.driver.complete(z)}}function L(z,G){try{G()}catch(V){console.error(`${z} threw; the job's claim was ended anyway.`,V)}}function v(){return Bun.env.NODE_ENV==="production"}function g(){if(!Q)return!1;if(h())return!0;return process.env.ROOT_DIR!==void 0&&!y()}function y(z=process.env){return(z.GEMI_QUEUE_CLAIM??"").trim().toLowerCase()==="off"}var O=Symbol.for("gemi.queue.worker");function o(z=!0){globalThis[O]=z}function h(){return globalThis[O]===!0}function f(z,G){let V=Array.isArray(z)?z[Math.min(G,z.length)-1]:z;return Math.max(0,V??0)}function q(z,G){if(z==="memory")return new X;if(z==="database"||typeof z==="function"){if(!G&&(z==="database"||z.length>0))throw Error("The queue driver needs the application it belongs to, and this QueueManager was built without one. Pass { application }.");if(z==="database")return new K(G.make(I));return z(G)}if(typeof z==="string")throw Error(`Unknown queue driver "${z}". The queue slice's driver is "memory", "database", a QueueDriver, or a function returning one.`);return z}
|
|
140
|
-
export{K as
|
|
140
|
+
export{K as _b,j as $b,_ as ac,X as bc,x as cc,g as dc,y as ec,o as fc,h as gc};
|
|
141
141
|
|
|
142
|
-
//# debugId=
|
|
142
|
+
//# debugId=E925071390E1B74564756E2164756E21
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"import { AsyncResource } from \"node:async_hooks\";\nimport { isMainThread } from \"node:worker_threads\";\n\nimport type { Application } from \"../../foundation/Application\";\nimport { DatabaseManager } from \"../../database/DatabaseManager\";\nimport { kernelContext } from \"../../kernel/context\";\nimport { deferUntilCommit } from \"../../orm/context\";\nimport { isShuttingDown } from \"../../server/shutdown\";\nimport { DatabaseQueueDriver } from \"./DatabaseQueueDriver\";\nimport { Job } from \"./Job\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { MemoryQueueDriver } from \"./MemoryQueueDriver\";\nimport type { ClaimOptions, ClaimedJob, QueueDriver } from \"./QueueDriver\";\nimport { withDefaults } from \"../../support/withDefaults\";\n\n/**\n * The thread a `worker = true` job runs in.\n *\n * The `await` on `dispatchJob` is load-bearing and its absence was a hang.\n * `postMessage` structured-clones its argument and a Promise is not cloneable,\n * so an un-awaited `dispatchJob` posted the pending promise, threw\n * `DataCloneError` inside this handler, and posted nothing at all. `runInWorker`\n * then never settled: `run` below never returned, its concurrency slot was\n * never decremented, and neither the retry path nor `onDeadletter` ever fired —\n * after `concurrency` such jobs the queue sits at its limit forever, with no\n * error anywhere. Any job whose `run` is `async` hit it, which is every job\n * that touches IO; a queued listener hits it unconditionally, because the\n * synthetic job's `run` awaits `handle`.\n *\n * The await earns two more things. A rejecting job now reaches the `catch` and\n * comes back as `{error}`, where the queue's ordinary retry-then-dead-letter\n * path can have it, instead of being lost with the promise. And `destroy()` now\n * runs after the job rather than under it, so the cloned kernel — its database\n * connections included — outlives the work it was cloned for.\n */\nfunction createWorker() {\n const APP_DIR = process.env.APP_DIR;\n const ROOT_DIR = process.env.ROOT_DIR;\n\n const appPath =\n process.env.NODE_ENV === \"production\"\n ? `${ROOT_DIR}/dist/server/bootstrap.mjs`\n : `${APP_DIR}/bootstrap.ts`;\n\n const file = new File(\n [\n `\n import { app } from \"${appPath}\"\n self.onmessage = async (event) => {\n const clone = app.clone()\n let result = null;\n let error = null;\n try {\n result = await clone.dispatchJob(event.data.jobName, event.data.args)\n } catch (err) {\n error = err\n }\n clone.destroy()\n if(error) {\n self.postMessage({error});\n } else {\n self.postMessage({result});\n }\n };\n `,\n ],\n \"worker.ts\",\n );\n const url = URL.createObjectURL(file);\n return new Worker(url);\n}\n\n// TODO: terminate worker after the job is done\nasync function runInWorker(jobName: string, args: string) {\n const worker = createWorker();\n worker.postMessage({ jobName, args });\n return await new Promise((resolve, reject) => {\n worker.onmessage = (e) => {\n const data = e.data;\n if (\"error\" in data) {\n reject(data.error);\n } else {\n resolve(data.result);\n }\n };\n });\n}\n\n/**\n * The async context every job runs in: the one this module was evaluated in,\n * which is boot, outside any request.\n *\n * The worker loop is long-lived and started lazily, by the first dispatch, and\n * an async function keeps the context it was started in across every `await`.\n * Started from a request, it would run every later job — dispatched by any\n * request at all — inside the first one's `RequestContext`, and with its ORM\n * transaction handle if it had one open: one user's identity leaking into\n * another's work. Captured here, where no request exists, and entered by `start()`, a job\n * sees no request at all; the Application is entered separately, per job.\n */\nconst bootScope = new AsyncResource(\"gemi.queue\");\n\n/**\n * The longest the loop waits between retries while `claim` keeps rejecting.\n *\n * Long enough that a database which is properly down is not asked once a\n * second by every worker process for as long as it stays down, short enough\n * that the queue is claiming again within a minute of it coming back.\n */\nconst maxClaimBackoff = 60_000;\n\ndeclare global {\n /**\n * The queue loop a `gemi dev` server is running over a driver that outlives\n * the process, kept where a `bun --hot` reload cannot lose it. A reload\n * re-evaluates every module and boots a new application, but the previous\n * application's loop is a live closure and keeps claiming — from the same\n * table, with the code it was loaded with. This is how the next\n * application finds it to stop it; see `startClaimingIfServing`.\n *\n * Typed by what is called on it, not as `QueueManager`: after a reload the\n * one held here is an instance of the previous module graph's class.\n */\n var __gemiDevQueue: { stop(): Promise<unknown> } | undefined;\n}\n\n/** What `drain` could not wait out. */\nexport type DrainResult = {\n /**\n * Jobs still running when the timeout elapsed. They keep running, and keep\n * their leases, until they settle or the process exits; with a driver that\n * outlives the process, an exit leaves them to be reclaimed once their lease\n * runs out. Waiting jobs are not listed — they were never taken, and are\n * wherever the driver keeps them.\n */\n unfinished: ClaimedJob[];\n};\n\nexport class QueueManager {\n static token = \"queue\";\n\n jobs: Record<string, new () => Job> = {};\n\n readonly config: Required<QueueConfig>;\n readonly driver: QueueDriver;\n\n private readonly application: Application | undefined;\n /**\n * Keyed by claim, `id:attempt`, not by job id. A lease that lapses while\n * its job is still running here — heartbeats failing through a database\n * blip, or an event loop blocked past the visibility timeout — lets this\n * same process claim the job again. Both runs are then really running, so\n * both take a slot. Keyed by id alone, the second claim overwrote the first\n * and the first one's `finally` then deleted it: the live run stopped being\n * counted, drained or heartbeated, so its lease lapsed in turn and the job\n * was claimed again into a slot that was never free.\n */\n private readonly inFlight = new Map<\n string,\n { job: ClaimedJob; done: Promise<void> }\n >();\n private state: \"idle\" | \"running\" | \"stopped\" = \"idle\";\n private looping = false;\n private claiming: Promise<unknown> | undefined;\n private woken = false;\n /** Consecutive `claim` rejections; see `sleep`. Cleared by a claim that returns. */\n private claimFailures = 0;\n private resume: (() => void) | undefined;\n private unsubscribe: (() => void) | undefined;\n private heartbeatTimer: ReturnType<typeof setInterval> | undefined;\n /** Unknown names already reported as left for another replica; see `run`. */\n private readonly releasedNames = new Set<string>();\n\n /**\n * `application` is entered around every job, so `app()` inside one resolves\n * to it rather than to whichever application happens to be the static\n * fallback. The provider always passes it; a manager built bare, as the unit\n * tests do, runs jobs with no application entered.\n */\n constructor(\n config: QueueConfig = {},\n options: { application?: Application } = {},\n ) {\n this.config = withDefaults(queueConfigDefaults(), config);\n this.application = options.application;\n this.driver = resolveDriver(this.config.driver, this.application);\n this.useJobs(this.config.jobs);\n }\n\n /**\n * Replaces the registered set, for the provider to hand over what it found\n * under `app/jobs`.\n *\n * This exists because the two phases disagree about when the answer is\n * knowable. The manager is constructed in `register()`, which is synchronous\n * and must resolve nothing; reading a directory and importing what is in it is\n * neither. So the manager is built from whatever the config slice declared —\n * nothing, when the app left `jobs` out — and the discovered set arrives in\n * `boot()`.\n *\n * The consequence worth knowing: anything that constructs an application and\n * skips phase two sees an empty registry, and every dispatch against an empty\n * registry is dropped — loudly on stderr, but after `Job.dispatch` has already\n * returned, so no caller finds out. On a durable driver not even that is\n * immediate: the job is left for another replica, and the stderr line comes\n * only once `unknownJobGrace` has passed. An app that lists its jobs explicitly is\n * unaffected, because that list is already in place by the end of `register()`.\n */\n useJobs(jobs: Array<new () => Job>) {\n this.config.jobs = jobs;\n\n // Built one at a time rather than by `Object.fromEntries`, which resolves a\n // repeated key by keeping the last and saying nothing.\n //\n // Two classes with one name is the worst failure in this subsystem, and it\n // is worse than the dropped dispatch the rest of this file is about: the\n // registry is keyed by class name, a dispatch carries a class name, so\n // `SendEmail.dispatch(...)` on the one under `app/jobs/auth` would run the\n // body of the one under `app/jobs/billing`. Nothing is dropped and nothing\n // errors — the wrong work happens and reports success.\n //\n // Discovery is what makes it ordinary. A hand-written list forces an import\n // alias in one visible file the moment two names clash; a directory walk\n // does not, and `auth/SendEmail.ts` beside `billing/SendEmail.ts` is a\n // perfectly natural thing to write. So the first claim wins and the second\n // is refused out loud — the same rule `Scheduler.start` applies to a cron\n // name, and the reverse of the silent last-wins this replaces.\n this.jobs = {};\n for (const job of jobs) {\n this.claim(job);\n }\n }\n\n /**\n * Registers one more job beside whatever `useJobs` already took.\n *\n * This exists for the queued-listener adapter, which registers a synthetic\n * job per queued listener from `EventServiceProvider.boot()` — after the\n * queue's own `boot()` has filled the registry. `useJobs` cannot serve that\n * caller: it *replaces* the registry, so a second call would discard every\n * job the app wrote and leave the queue holding listeners alone. Reading\n * `registeredJobs` back, concatenating and calling `useJobs` again avoids\n * that and is still the wrong shape — it re-runs the collision check over\n * jobs that already passed it, so a duplicate the author has already been\n * told about is reported a second time on every boot.\n *\n * Same rule as `useJobs`, deliberately: the first claim on a name wins and\n * the second is refused out loud. And recorded in `config.jobs` either way,\n * so `registeredJobs` keeps reporting everything the manager was handed\n * rather than what it accepted — a refused job is visible to a test there.\n *\n * A new array rather than a `push`, because `useJobs` keeps the caller's\n * array by reference and appending to it would edit the config slice or the\n * discovered list under whoever else is holding it.\n */\n registerJob(job: new () => Job) {\n this.config.jobs = [...this.config.jobs, job];\n this.claim(job);\n }\n\n /**\n * Puts one job in the registry, or refuses it because the name is taken.\n *\n * The rule and the reason are in `useJobs` above; this is only the shape both\n * entry points share, so that a job arriving one at a time cannot be admitted\n * on terms the batch would have refused.\n */\n private claim(job: new () => Job) {\n if (this.jobs[job.name]) {\n console.error(\n `Two queued jobs are named \"${job.name}\" — the first is registered ` +\n `and this one is not, so dispatching either would have run one of ` +\n `them. A class name is the queue's key, so only one job can hold ` +\n `it. Rename one.`,\n );\n return;\n }\n this.jobs[job.name] = job;\n }\n\n /**\n * What the manager was handed, discovered or declared.\n *\n * The registry is keyed by name, and a name is exactly what a dispatch\n * carries, so \"is this job registered?\" is a question with a silent wrong\n * answer — `run()` drops an unknown name long after the caller moved on.\n * This is where a test asks it out loud.\n *\n * It reports what came in, not what the registry accepted, so a name claimed\n * twice appears twice here — deliberately, the same way `Scheduler.jobs`\n * does. A test walking this should see the collision rather than have it\n * tidied away. A copy, so that walk cannot edit the registry underneath it.\n */\n get registeredJobs(): ReadonlyArray<new () => Job> {\n return [...this.config.jobs];\n }\n\n dispatchJob(jobName: string, args: string) {\n if (this.jobs[jobName]) {\n const job = new this.jobs[jobName]();\n return job.run(JSON.parse(args));\n }\n }\n\n /**\n * Queues a job and resolves to its id once the driver has recorded it, then\n * makes sure the worker loop is running — unless `drain` stopped it, in which\n * case the job waits in the driver for whichever process claims next. With\n * the memory driver that is nobody; see `drain`. A durable driver's job also\n * waits there when this process does not claim: it is not a server, or it is\n * one started with `GEMI_QUEUE_CLAIM=off`; see `claimsInThisProcess`.\n *\n * Inside an open ORM transaction the job belongs to the transaction. A\n * driver that can write it on the transaction does (`joinsTransaction`);\n * for any other, it is held and recorded once the transaction commits, and\n * never if it rolls back. Either way no claimer can see the job before the\n * data it was dispatched about exists. A held dispatch resolves at once, to\n * the id the job will be recorded under: the transaction does not commit\n * until its callback returns, so a caller awaiting a promise that waited for\n * the commit would never return.\n */\n push(\n job: new () => Job,\n args: string,\n options: {\n /**\n * Whether a driver that cannot record the job is reported from here.\n * On by default, because the usual caller is a fire-and-forget\n * `Job.dispatch(...)` whose promise nobody reads. A caller with\n * something better to say — `EventManager`, which knows the event and\n * the listener — turns it off and says that instead. A held dispatch is\n * reported here whatever this says, because its promise has already\n * resolved and the caller has nothing left to catch.\n */\n reportFailure?: boolean;\n } = {},\n ): Promise<string> {\n // Asked before anything is written, and in the caller's async context,\n // which is where the transaction is. The held branch is the fallback\n // rather than the rule because it loses the job to a crash between the\n // commit and the enqueue; written on the transaction, the job commits\n // with the rows or not at all.\n const joins = this.driver.joinsTransaction?.() === true;\n if (!joins) {\n // `deferUntilCommit` is the ORM's commit hook, and the same one an\n // `afterCommit` event waits on: a savepoint that rolls back takes its\n // held dispatches with it, and the callback runs outside the\n // transaction, so the enqueue cannot be pulled back into it.\n const id = Bun.randomUUIDv7();\n const held = deferUntilCommit(() =>\n // Awaited, so the transaction's own promise waits for the enqueue and\n // a script that exits after its last transaction does not exit under\n // it. The rejection is swallowed only because `record` has already\n // reported it; rethrown, the drain would report it a second time.\n this.record(job, args, {\n id,\n reportFailure: true,\n committed: true,\n }).then(\n () => {},\n () => {},\n ),\n );\n if (held) return Promise.resolve(id);\n }\n return this.record(job, args, {\n reportFailure: options.reportFailure,\n joins,\n });\n }\n\n /** `push`, once it is known that the job is recorded now. */\n private record(\n job: new () => Job,\n args: string,\n options: {\n id?: string;\n reportFailure?: boolean;\n /** Written on the caller's open transaction; see `push`. */\n joins?: boolean;\n /** Held until a transaction committed; changes only the error line. */\n committed?: boolean;\n },\n ): Promise<string> {\n const id = this.driver.enqueue({\n name: job.name,\n args,\n ...(options.id === undefined ? {} : { id: options.id }),\n });\n // A driver that outlives the process is shared with every other one, so\n // a script or console command that dispatches would otherwise claim up to\n // `concurrency` of the table's jobs — other replicas' included — and exit\n // under them, costing each an attempt and a lease's wait. There the job\n // waits in the driver for a server or a worker. A manager built by hand,\n // with no application, is its caller's to run and keeps starting.\n this.startIfIdle();\n // A driver without `subscribe` is only polled, so without the wake a job\n // dispatched here would wait up to `pollInterval` in a queue with room.\n // A spurious wake just claims nothing.\n //\n // A job written on the caller's transaction is not claimable until that\n // commits, so its wake waits for the commit too — woken now, the loop\n // would claim nothing and then sleep a whole `pollInterval` past it.\n // Registered here, synchronously, because the commit hook is found\n // through the caller's async context, and this is the one place that is\n // certainly still current.\n const wake = () =>\n !this.driver.subscribe && this.state === \"running\" && this.wake();\n const wakeAtCommit = options.joins === true && deferUntilCommit(wake);\n\n // The rejection is reported here unless the caller says it will do it\n // itself, and whatever the driver is. It used to depend on both, and was\n // lost either way: a polled driver got an empty rejection arm, which marks\n // `id` handled — and `id` is what `push` returns — so a fire-and-forget\n // `SendReceiptJob.dispatch(...)` whose INSERT failed (a failover, a pool\n // timeout, a table not migrated yet) produced no unhandled rejection and\n // no line anywhere, and the job simply never ran. A subscribing driver got\n // no arm at all, so the same failure surfaced as a bare unhandled\n // rejection. A caller that awaits still gets the rejection either way and\n // can still decide what to do about it.\n id.then(\n () => wakeAtCommit || wake(),\n (error: unknown) => {\n if (options.reportFailure === false) return;\n console.error(\n `[gemi] The queue driver could not record ${job.name}` +\n (options.committed\n ? `, which was held until its transaction committed. The ` +\n `transaction stays committed; the job did not run and will ` +\n `not be retried.`\n : `, so it did not run and will not be retried.`),\n error,\n );\n },\n );\n return id;\n }\n\n /**\n * Runs a dead-lettered job again, from attempt 1 with its whole\n * `maxAttempts`, and resolves to whether a dead job was found under `id`.\n * `false` for an id that is waiting, running, finished or unknown: only a\n * dead job is brought back, so this cannot restart one that is running\n * somewhere.\n *\n * The job is claimed the way a dispatch's is. On a server it is run here as\n * soon as there is room; from a console command it waits in the driver for\n * a server or a worker, which with a polling driver means up to\n * `pollInterval`.\n *\n * Refused for a driver without `retryDead`. The memory driver keeps nothing\n * of a dead job, so there is no id it could bring back, and resolving\n * `false` would read as \"no such job\" to someone holding an id they just saw\n * in a log.\n */\n async retryDead(id: string): Promise<boolean> {\n if (!this.driver.retryDead) {\n throw new Error(\n `This queue's driver keeps nothing of a dead-lettered job, so there ` +\n `is nothing to retry. The database driver keeps them.`,\n );\n }\n const found = await this.driver.retryDead(id);\n if (found) this.claimSoon();\n return found;\n }\n\n /**\n * Starts the loop unless `drain` stopped it or this process should leave a\n * shared driver's jobs to a server — the rule `push` explains.\n */\n private startIfIdle() {\n if (this.state === \"idle\" && (!this.durable || this.mayClaimHere())) {\n this.start();\n }\n }\n\n /**\n * For a job the driver has just made claimable: start the loop, or wake a\n * running one that only polls, as `push` does for a dispatch.\n */\n private claimSoon() {\n this.startIfIdle();\n if (!this.driver.subscribe && this.state === \"running\") this.wake();\n }\n\n /**\n * Starts claiming. Idempotent, and called by the first `push`, so an app\n * does not need to; it is public for a process that should run jobs it\n * never dispatched — ones a driver kept across a restart — and for resuming\n * after `drain`.\n */\n start() {\n if (this.state === \"running\") return;\n this.state = \"running\";\n // Only a development server's loop over a shared driver: a memory queue\n // is only ever fed by its own application, and a hand-built manager or a\n // test's is its caller's to stop.\n if (this.durable && this.application && this.mayClaimHere() && !isProduction()) {\n globalThis.__gemiDevQueue = this;\n }\n this.unsubscribe = this.driver.subscribe?.(() => this.wake());\n // A loop a `drain` has not yet seen off picks the new state up itself;\n // starting a second would claim twice per wake.\n if (this.looping) return this.wake();\n bootScope.runInAsyncScope(() => void this.loop());\n }\n\n /**\n * Stops claiming, waits up to `timeoutMs` for the jobs already running, and\n * reports the ones that did not finish.\n *\n * Nothing is cancelled — a job has no way to be told — so an unfinished job\n * keeps running after this resolves. What happens to it then is the\n * driver's: the memory driver loses it with the process, along with every\n * job still waiting; one that outlives the process lets another claim it\n * once the lease runs out.\n *\n * A later `push` records its job but does not restart the loop. `start()`\n * does.\n */\n async drain(timeoutMs = Infinity): Promise<DrainResult> {\n this.state = \"stopped\";\n if (globalThis.__gemiDevQueue === this) globalThis.__gemiDevQueue = undefined;\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n this.wake();\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<void>((resolve) => {\n if (timeoutMs !== Infinity) timer = setTimeout(resolve, timeoutMs);\n });\n // The claim in progress first, because what it returns is run: those jobs\n // are leased to this process already, and handing them back would cost\n // each of them an attempt it never made.\n const settled = (async () => {\n await this.claiming?.catch(() => {});\n await Promise.allSettled([...this.inFlight.values()].map((e) => e.done));\n })();\n await Promise.race([settled, deadline]);\n clearTimeout(timer);\n\n return {\n unfinished: [...this.inFlight.values()].map((e) => ({ ...e.job })),\n };\n }\n\n /** `drain(0)`: stop claiming, and report what is running without waiting. */\n stop(): Promise<DrainResult> {\n return this.drain(0);\n }\n\n /** How many jobs this process is running right now. */\n get running(): number {\n return this.inFlight.size;\n }\n\n /**\n * Claims while there is room, runs what it claims, and otherwise sleeps\n * until something changes: a job finishing frees a slot, or the driver's\n * `subscribe` says there is work. A driver without `subscribe` is polled\n * every `pollInterval` instead. This replaces a one-second timer that\n * spun while the queue was full.\n *\n * `woken` records a wake that arrived while a claim was in flight, when\n * there was nothing yet to resume; without it that job would wait for the\n * next unrelated wake.\n */\n private async loop() {\n this.looping = true;\n try {\n await this.claimWhileRunning();\n } finally {\n this.looping = false;\n }\n }\n\n private async claimWhileRunning() {\n while (this.state === \"running\") {\n // Once the server has been told to stop, a driver that outlives the\n // process gets nothing new taken from it: a job claimed now would likely\n // be cut off by the exit, and cost an attempt and a lease's wait, when\n // another replica can run it instead. The memory driver keeps claiming\n // until the provider's `drain()` stops it, because nobody else can run\n // its jobs — one waiting at the signal, or dispatched by a request\n // still draining, is run here or not at all.\n const room = this.durable && isShuttingDown()\n ? 0\n : this.config.concurrency - this.inFlight.size;\n\n if (room > 0) {\n this.woken = false;\n const claim = this.driver.claim(room, {\n ...this.lease(),\n registered: {\n names: Object.keys(this.jobs),\n graceMs: this.config.unknownJobGrace,\n },\n });\n this.claiming = claim;\n let claimed: ClaimedJob[] = [];\n try {\n claimed = await claim;\n this.claimFailures = 0;\n } catch (error) {\n this.claimFailures++;\n console.error(\n `The queue could not claim jobs from its driver; it will try ` +\n `again in ${this.retryDelay()}ms.`,\n error,\n );\n } finally {\n this.claiming = undefined;\n }\n for (const job of claimed) this.execute(job);\n\n // A full batch may have left more behind; the next pass either claims\n // it or, with no room left, sleeps until a slot frees.\n if (claimed.length === room) continue;\n if (this.woken && this.inFlight.size < this.config.concurrency) {\n continue;\n }\n }\n\n await this.sleep();\n }\n }\n\n /**\n * Waits for the next thing worth waking for: a slot freeing, a `subscribe`\n * driver saying there is work, or the poll timer a driver without\n * `subscribe` gets.\n *\n * A claim that rejected arms a timer whatever the driver does, and that is\n * the whole reason this is not just the `subscribe` test. The wake that\n * prompted the lost claim has already been consumed, so a driver that only\n * speaks up on an enqueue — LISTEN/NOTIFY, say — has nothing left to\n * announce: an idle worker whose one claim died on a connection reset would\n * sit there, with every job already waiting, until some unrelated process\n * enqueued again. On a busy worker an in-flight job's `wake` covers it; an\n * idle one has nothing to be rescued by.\n *\n * The delay doubles per consecutive failure so that storage which is\n * properly down is not asked once a `pollInterval` for as long as it stays\n * down, and the first claim that returns clears the count.\n */\n private sleep() {\n return new Promise<void>((resolve) => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const delay = this.claimFailures > 0\n ? this.retryDelay()\n : this.driver.subscribe\n ? undefined\n : this.config.pollInterval;\n if (delay !== undefined) {\n // Unref'd: a polling queue alone should not hold the process open.\n timer = setTimeout(() => this.wake(), delay);\n timer.unref?.();\n }\n this.resume = () => {\n clearTimeout(timer);\n resolve();\n };\n });\n }\n\n /** `pollInterval`, doubled once per consecutive claim failure, capped. */\n private retryDelay() {\n const doublings = Math.min(Math.max(0, this.claimFailures - 1), 30);\n return Math.min(this.config.pollInterval * 2 ** doublings, maxClaimBackoff);\n }\n\n private wake() {\n this.woken = true;\n const resume = this.resume;\n this.resume = undefined;\n resume?.();\n }\n\n /**\n * Whether the driver keeps jobs past this process: anything but memory.\n * Only such a queue can be fed by one process and drained by another.\n */\n get durable() {\n return !(this.driver instanceof MemoryQueueDriver);\n }\n\n /** See `claimsInThisProcess`. A manager built by hand always may. */\n private mayClaimHere() {\n return !this.application || claimsInThisProcess();\n }\n\n private lease(): ClaimOptions {\n return { visibilityTimeoutMs: this.config.visibilityTimeout };\n }\n\n private execute(claimed: ClaimedJob) {\n const key = `${claimed.id}:${claimed.attempt}`;\n const attempt = () => this.run(claimed);\n const done = (\n this.application\n ? kernelContext.run(this.application, attempt)\n : attempt()\n )\n .catch((error) => {\n // Only the driver's own reports reach here. The claim was not ended,\n // so its lease runs out and the job is claimed again.\n console.error(\n `The queue could not record the outcome of ${claimed.name}.`,\n error,\n );\n })\n .finally(() => {\n this.inFlight.delete(key);\n this.wake();\n });\n this.inFlight.set(key, { job: claimed, done });\n this.heartbeat();\n }\n\n /**\n * Keeps every running job's lease alive, at a third of the visibility\n * timeout so one late tick does not lose it. Stops itself once nothing is\n * running, and is unref'd, like the poll.\n */\n private heartbeat() {\n const driver = this.driver;\n if (!driver.heartbeat || this.heartbeatTimer) return;\n this.heartbeatTimer = setInterval(\n () => {\n if (this.inFlight.size === 0) {\n clearInterval(this.heartbeatTimer);\n this.heartbeatTimer = undefined;\n return;\n }\n const jobs = [...this.inFlight.values()].map((e) => e.job);\n driver.heartbeat!(jobs, this.lease()).catch((error) => {\n console.error(`The queue could not extend its job leases.`, error);\n });\n },\n Math.max(1, Math.floor(this.config.visibilityTimeout / 3)),\n );\n this.heartbeatTimer.unref?.();\n }\n\n /**\n * One attempt at one claimed job, ending the claim either way.\n *\n * `onSuccess` is inside the `try`, as it always was, so a throw from it is a\n * failed attempt and is retried. `onFail` and `onDeadletter` are not: a\n * throw from either is logged and the claim still ends, where it used to\n * escape the queue with the job's slot still counted as taken.\n */\n private async run(claimed: ClaimedJob) {\n const Job = this.jobs[claimed.name];\n\n if (!Job) {\n // A driver other processes share may have handed this out because it\n // cannot filter by name, and while a blue/green ramp has both releases\n // claiming from one table, a name this replica lacks is usually one only\n // the other release has. So it goes back, without spending an attempt,\n // for a replica that has the class — until `unknownJobGrace` has passed\n // since the dispatch, after which the name is taken to be gone. Measured\n // from `createdAt` because that is all a claim carries; it is the\n // driver's clock against this one, and the skew is seconds against a\n // window of minutes. A driver that does filter only hands out an unknown\n // name once it has waited out the same window, so it normally lands\n // below; with this clock a few seconds behind the driver's, one handed\n // out right at the boundary is released instead, and — its window now\n // restarting from the release — waits one more `unknownJobGrace`. Late,\n // not lost, so no slack is subtracted for it.\n const age = Date.now() - claimed.createdAt;\n if (this.durable && age < this.config.unknownJobGrace) {\n // Once per name: with a driver that cannot filter, every poll can\n // claim the same job again, and a line per poll would bury the one\n // that matters — a replica whose discovery missed a job, say.\n if (!this.releasedNames.has(claimed.name)) {\n this.releasedNames.add(claimed.name);\n console.error(\n `Left a queued \"${claimed.name}\" for another replica: nothing is ` +\n `registered here under that name. It is dead-lettered if no ` +\n `replica has run it within unknownJobGrace ` +\n `(${this.config.unknownJobGrace}ms) of its dispatch.`,\n );\n }\n // Off this replica's own rhythm, and differently each time. It claims\n // again the moment the release lands, finds nothing due, and then\n // polls every `pollInterval`; a delay of exactly one interval made the\n // job due at the instant of that next poll, so the replica that could\n // not run it won the race for it every time. Any fixed fraction has\n // the same flaw for a replica whose polls happen to fall just before\n // the due moment each cycle — it loses every race, for good. Random\n // within one interval, every other replica's next poll has a chance.\n await this.driver.release(claimed, {\n retryInMs: Math.round(\n this.config.pollInterval * (1 + Math.random()),\n ),\n });\n return;\n }\n\n // The one place this is observable. A dispatch carries a name, the\n // registry is keyed by name, and a name nobody registered matches\n // nothing — which is exactly the silence #322 is about, except here it\n // has already happened and the work is gone. Saying so is all that is\n // left to do about it. Dead-lettered, which for the memory driver is the\n // drop it always was and for a durable one leaves a record to find.\n console.error(\n `Dropped a queued job: nothing is registered under the name ` +\n `\"${claimed.name}\". If the class exists, it was not ` +\n `discovered — check that it is under the queue slice's jobsDir ` +\n `(app/jobs by default), or list it in app/config/queue.ts.`,\n );\n await this.driver.fail(claimed, {\n error: `No job is registered under the name \"${claimed.name}\".`,\n retryInMs: null,\n });\n return;\n }\n\n let job: InstanceType<typeof Job>;\n try {\n job = new Job();\n } catch (error) {\n // A constructor or a class field that throws — `private mailer =\n // app(Mailer)` with nothing bound, say. Every other failure in here is\n // reported against the instance, and this one has no instance to report\n // against, which is exactly why it has to be caught here rather than\n // left to the generic path: that path never ends the claim, so the lease\n // lapses, the job is claimed again, and the constructor throws again,\n // once per visibility timeout, forever. The `maxAttempts` guard below\n // would normally stop that, and it cannot — answering \"how many attempts\n // does this job get?\" needs the instance that cannot be built. So it is\n // dead-lettered unrun, like a job whose arguments are not JSON: no\n // attempt of it can ever do anything but this.\n console.error(\n `Dropped a queued ${claimed.name}: it could not be constructed.`,\n error,\n );\n await this.driver.fail(claimed, {\n error: `The job could not be constructed: ${String(error)}`,\n retryInMs: null,\n });\n return;\n }\n\n let args: any[];\n try {\n args = JSON.parse(claimed.args);\n } catch (error) {\n // Not something `Job.dispatch` writes, so a driver changed it. Left\n // alone, the claim would never end and the job would be reclaimed,\n // unparseable, forever.\n console.error(\n `Dropped a queued ${claimed.name}: its arguments are not JSON.`,\n error,\n );\n await this.driver.fail(claimed, {\n error: `The arguments are not JSON: ${String(error)}`,\n retryInMs: null,\n });\n return;\n }\n\n // Claimed past its last attempt: an earlier claim used that attempt up and\n // never reported, which is what a process exiting mid-run looks like from\n // here. Running it again would exceed `maxAttempts`, so it is dead-lettered\n // unrun. `Math.max` keeps a `maxAttempts` below one meaning what it always\n // did — one attempt.\n if (claimed.attempt > Math.max(1, job.maxAttempts)) {\n const error = new Error(\n `${claimed.name} was claimed for attempt ${claimed.attempt} of ` +\n `${job.maxAttempts}: an earlier attempt never finished, most likely ` +\n `because the process running it exited. Dead-lettered without ` +\n `running it again.`,\n );\n hook(`${claimed.name}.onDeadletter`, () =>\n job.onDeadletter(error, ...args),\n );\n await this.driver.fail(claimed, {\n error: error.message,\n retryInMs: null,\n });\n return;\n }\n\n try {\n const result = await (job.worker\n ? runInWorker(claimed.name, claimed.args)\n : job.run(...args));\n\n job.onSuccess(result, ...args);\n } catch (err) {\n const error = err as Error;\n const recorded = String(error?.stack ?? error);\n hook(`${claimed.name}.onFail`, () => job.onFail(error, ...args));\n\n if (claimed.attempt >= job.maxAttempts) {\n hook(`${claimed.name}.onDeadletter`, () =>\n job.onDeadletter(error, ...args),\n );\n await this.driver.fail(claimed, { error: recorded, retryInMs: null });\n } else {\n await this.driver.fail(claimed, {\n error: recorded,\n retryInMs: backoffFor(job.backoff, claimed.attempt),\n });\n }\n return;\n }\n\n await this.driver.complete(claimed);\n }\n}\n\nfunction hook(name: string, fn: () => void) {\n try {\n fn();\n } catch (error) {\n console.error(`${name} threw; the job's claim was ended anyway.`, error);\n }\n}\n\nfunction isProduction() {\n return process.env.NODE_ENV === \"production\";\n}\n\n/**\n * Whether this process should claim from a driver shared with other\n * processes: a `gemi queue:work` worker, or a server's main thread unless\n * `GEMI_QUEUE_CLAIM=off` hands its jobs to workers. `ROOT_DIR` is set only by\n * a starting server or worker, so a console command, a seed\n * or a migration — which boot the same providers — is not one, and neither is\n * a `worker` job's thread, which clones the application and exits after it.\n *\n * A worker claims whatever `GEMI_QUEUE_CLAIM` says, because the variable is\n * for the web process, and a deploy that sets it once for every container\n * would otherwise leave nothing claiming at all.\n */\nexport function claimsInThisProcess() {\n if (!isMainThread) return false;\n if (isQueueWorker()) return true;\n return process.env.ROOT_DIR !== undefined && !claimingTurnedOff();\n}\n\n/**\n * `GEMI_QUEUE_CLAIM=off` (any case): this server dispatches into a shared\n * driver and leaves the claiming to `gemi queue:work` processes. Anything else\n * claims, as before. An environment variable rather than a config field for\n * the reason `GEMI_NO_SCHEDULE` is one: the web and the worker run the same\n * build with the same config, and only the process knows which it is.\n */\nexport function claimingTurnedOff(env: Record<string, string | undefined> = process.env) {\n return (env.GEMI_QUEUE_CLAIM ?? \"\").trim().toLowerCase() === \"off\";\n}\n\n// On `globalThis` under a registry symbol, like the shutdown flag, so the mark\n// the worker entry sets is the one this module reads if two copies of it are\n// loaded. Not an environment variable: a job that spawns a child process\n// would hand it on, and the child, a script, would start claiming.\nconst QUEUE_WORKER = Symbol.for(\"gemi.queue.worker\");\n\n/** Marks this process as a `gemi queue:work` worker; see `claimsInThisProcess`. */\nexport function markQueueWorker(worker = true) {\n (globalThis as { [QUEUE_WORKER]?: boolean })[QUEUE_WORKER] = worker;\n}\n\nexport function isQueueWorker(): boolean {\n return (globalThis as { [QUEUE_WORKER]?: boolean })[QUEUE_WORKER] === true;\n}\n\n/**\n * The delay before the retry that follows attempt `attempt`: the number\n * itself, or the array's entry for that retry with its last entry repeated.\n */\nexport function backoffFor(backoff: number | number[], attempt: number) {\n const delay = Array.isArray(backoff)\n ? backoff[Math.min(attempt, backoff.length) - 1]\n : backoff;\n return Math.max(0, delay ?? 0);\n}\n\nfunction resolveDriver(\n driver: Required<QueueConfig>[\"driver\"],\n application: Application | undefined,\n): QueueDriver {\n if (driver === \"memory\") return new MemoryQueueDriver();\n if (driver === \"database\" || typeof driver === \"function\") {\n // Only a manager built by hand has no application. A factory that takes\n // one would otherwise fail on `undefined` with a TypeError that names\n // neither the queue nor what is missing.\n if (!application && (driver === \"database\" || driver.length > 0)) {\n throw new Error(\n `The queue driver needs the application it belongs to, and this ` +\n `QueueManager was built without one. Pass { application }.`,\n );\n }\n if (driver === \"database\") {\n return new DatabaseQueueDriver(application!.make(DatabaseManager));\n }\n return driver(application!);\n }\n if (typeof driver === \"string\") {\n throw new Error(\n `Unknown queue driver \"${driver}\". The queue slice's driver is ` +\n `\"memory\", \"database\", a QueueDriver, or a function returning one.`,\n );\n }\n return driver;\n}\n"
|
|
9
9
|
],
|
|
10
10
|
"mappings": ";6PAqGO,AAAM,LAA2C,LAC7C,AACQ,IACA,QAEA,WACA,YACT,WAER,WAAW,CACT,EAEA,EAAsC,CAAC,EACvC,CACA,IAAM,EAAQ,EAAQ,OAAS,YAC/B,GAAI,CAAC,2BAA2B,KAA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AAmB,EAAG,CACpC,GAAI,CAAC,EAAc,MAAO,GAC1B,GAAI,EAAc,EAAG,MAAO,GAC5B,OAAO,QAAQ,IAAI,WAAa,QAAa,CAAC,EAAkB,EAU3D,SAAS,CAAiB,CAAC,EAA0C,QAAQ,IAAK,CACvF,OAAQ,EAAI,kBAAoB,IAAI,KAAK,EAAE,YAAY,IAAM,MAO/D,IAAM,EAAe,OAAO,IAAI,mBAAmB,EAG5C,SAAS,CAAe,CAAC,EAAS,GAAM,CAC5C,WAA4C,GAAgB,EAGxD,SAAS,CAAa,EAAY,CACvC,OAAQ,WAA4C,KAAkB,GAOjE,SAAS,CAAU,CAAC,EAA4B,EAAiB,CACtE,IAAM,EAAQ,MAAM,QAAQ,CAAO,EAC/B,EAAQ,KAAK,IAAI,EAAS,EAAQ,MAAM,EAAI,GAC5C,EACJ,OAAO,KAAK,IAAI,EAAG,GAAS,CAAC,EAG/B,SAAS,CAAa,CACpB,EACA,EACa,CACb,GAAI,IAAW,SAAU,OAAO,IAAI,EACpC,GAAI,IAAW,YAAc,OAAO,IAAW,WAAY,CAIzD,GAAI,CAAC,IAAgB,IAAW,YAAc,EAAO,OAAS,GAC5D,MAAU,MACR,0HAEF,EAEF,GAAI,IAAW,WACb,OAAO,IAAI,EAAoB,EAAa,KAAK,CAAe,CAAC,EAEnE,OAAO,EAAO,CAAY,EAE5B,GAAI,OAAO,IAAW,SACpB,MAAU,MACR,yBAAyB,mGAE3B,EAEF,OAAO",
|
|
11
|
-
"debugId": "
|
|
11
|
+
"debugId": "E925071390E1B74564756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
class Q extends Error{constructor(z){super(`Could not infer a database dialect from "${z}". Expected a URL starting with postgres://, postgresql://, mysql://, mariadb://, `+"sqlite://, or file: \u2014 or a SQLite path such as ./dev.db or :memory:.");this.name="UnknownDatabaseUrlError"}}class j extends Error{constructor(z){super(z===void 0||z==="default"?"No database URL configured. Set the DATABASE_URL environment variable, or set `url` in app/config/database.ts.":`The "${z}" database connection has no \`url\`. Set one under \`connections.${z}\` in app/config/database.ts.`);this.name="MissingDatabaseUrlError"}}var b={"postgres:":"postgres","postgresql:":"postgres","mysql:":"mysql","mariadb:":"mariadb","sqlite:":"sqlite","file:":"sqlite"},L=[".db",".sqlite",".sqlite3"];function F(z){let B=z.trim();if(B==="")throw new Q(z);if(B===":memory:")return"sqlite";let G=B.indexOf(":");if(G!==-1){let J=B.slice(0,G+1).toLowerCase(),K=b[J];if(K)return K}if(D(B))return"sqlite";throw new Q(z)}function D(z){if(z.startsWith("./")||z.startsWith("../")||z.startsWith("/"))return!0;let B=z.toLowerCase();return L.some((G)=>B.endsWith(G))}function E(z){return z==="sqlite"}function f(z){return z==="mysql"||z==="mariadb"}import{existsSync as S,readFileSync as g,realpathSync as I,statSync as y}from"fs";import{isAbsolute as U,join as H,resolve as q}from"path";var w=H("prisma","schema.prisma");class R extends Error{constructor(z,B,G){super(`"${z}" now resolves to ${B}, which is where Prisma migrates it. gemi used to open ${G} instead, and that file holds data \u2014 so `+`opening the resolved one would quietly leave it behind. gemi will not choose. Move ${G} onto ${B} if it is the database you want, or point DATABASE_URL at an absolute path to say so explicitly.`);this.name="AmbiguousSqlitePathError"}}function O(z){let B=z.trim(),G="",J=B;for(let K of["file://","file:","sqlite://","sqlite:"])if(B.slice(0,K.length).toLowerCase()===K){G=B.slice(0,K.length),J=B.slice(K.length);break}if(J===":memory:"||J.startsWith(":memory:?"))return null;return{prefix:G,file:J}}function _(z,B,G=process.cwd()){if(B!=="sqlite")return{url:z};let J=O(z);if(!J||J.file==="")return{url:z};if(U(J.file))return{url:z};let K=J.file.indexOf("?"),Z=K===-1?J.file:J.file.slice(0,K),$=K===-1?"":J.file.slice(K),X=H(G,"prisma");if(!C(G,z))return{url:z};let W=q(G,Z),Y=q(X,Z);if(W===Y)return{url:z};return{url:`${J.prefix}${Y}${$}`,moved:{from:W,to:Y}}}function C(z,B){let G=H(z,w);if(!S(G))return!1;let J;try{J=g(G,"utf8")}catch{return!1}let Z=J.replace(/^\s*\/\/.*$/gm,"").match(/datasource\s+\w+\s*\{([\s\S]*?)\}/);if(!Z)return!1;let $=Z[1];if(!/provider\s*=\s*["']sqlite["']/.test($))return!1;let X=$.match(/url\s*=\s*env\(\s*["']([^"']+)["']\s*\)/);if(X){let Y=process.env[X[1]];return typeof Y==="string"&&Y.trim()===B.trim()}let W=$.match(/url\s*=\s*["']([^"']+)["']/);return W?W[1].trim()===B.trim():!1}function k(z){try{if(I(z.from)===I(z.to))return null}catch{}try{let B=y(z.from);return B.isFile()&&B.size>0?z.from:null}catch{return null}}var{SQL:A}=globalThis.Bun;var V="default";class P extends Error{constructor(z,B){super(`No database connection named "${z}". Configured: ${B.map((G)=>`"${G}"`).join(", ")}. Declare it under \`connections\` in app/config/database.ts.`);this.name="UnknownConnectionError"}}class x extends Error{constructor(z){super(`"${z}" is the name of the connection declared by the top-level \`url\` and \`options\`, so it cannot also appear under \`connections\`. Rename it, or move its settings up to the top level.`);this.name="ReservedConnectionNameError"}}class T extends Error{open;requested;constructor(z,B){super(`A transaction is open on the "${z}" connection, and this statement names "${B}". A transaction cannot span two connections: the statement would run outside it and stay committed when the transaction rolls back. Move this query outside the transaction, or run the whole unit on one connection.`);this.open=z;this.requested=B;this.name="CrossConnectionTransactionError"}}class M{name;config;sql;dialect;url;ready;constructor(z,B={}){this.name=z;this.config=B;let G=B.url;if(!G)throw new j(z);this.dialect=B.dialect??F(G);let J=_(G,this.dialect);if(J.moved){let K=k(J.moved);if(K)throw new R(G,J.moved.to,K)}this.url=J.url,this.sql=B.options?new A(this.url,B.options):new A(this.url),this.ready=this.configure()}async configure(){if(this.dialect!=="sqlite")return;await this.sql.unsafe("pragma foreign_keys = ON")}get query(){return this.sql}async close(){this.ready.catch(()=>{}),await this.sql.close()}}class N{config;static token="database";name=V;pools=new Map;ready;constructor(z={}){this.config=z;let{connections:B={},...G}=z;this.pools.set(V,new M(V,G));try{this.build(B,G.slowTransactionThreshold)}catch(J){for(let K of this.pools.values())K.ready.catch(()=>{}),K.close().catch(()=>{});throw J}this.ready=Promise.all([...this.pools.values()].map((J)=>J.ready)).then(()=>{return})}build(z,B){for(let[G,J]of Object.entries(z)){if(G===V)throw new x(G);this.pools.set(G,new M(G,{slowTransactionThreshold:B,...J}))}}connection(z=V){if(z===V)return this;let B=this.pools.get(z);if(!B)throw new P(z,this.connectionNames);return B}get connectionNames(){return[...this.pools.keys()]}get sql(){return this.default.sql}get dialect(){return this.default.dialect}get url(){return this.default.url}get query(){return this.sql}async close(){this.ready.catch(()=>{}),await Promise.all([...this.pools.values()].map((z)=>z.close()))}get default(){return this.pools.get(V)}}function l(z){return z}function o(){return{url:process.env.DATABASE_URL,dialect:void 0,options:void 0,slowTransactionThreshold:h,connections:void 0}}var h=2000;
|
|
3
|
+
export{Q as xf,j as yf,F as zf,E as Af,f as Bf,R as Cf,V as Df,P as Ef,x as Ff,T as Gf,M as Hf,N as If,l as Jf,o as Kf,h as Lf};
|
|
4
|
+
|
|
5
|
+
//# debugId=035EC4797A65984064756E2164756E21
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../database/dialect.ts", "../database/sqlitePath.ts", "../database/Connection.ts", "../database/DatabaseManager.ts", "../database/config.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// The SQL dialects Bun's `SQL` client can talk to. Bun infers the *connection*\n// from the URL protocol on its own, but it does not tell us which dialect it\n// picked — and gemi needs to know, because the SQL it generates differs per\n// dialect (`RETURNING` support, upsert syntax, autoincrement, boolean and\n// timestamp types). So we infer it a second time, here, for query generation.\nexport type Dialect = \"sqlite\" | \"postgres\" | \"mysql\" | \"mariadb\";\n\nexport class UnknownDatabaseUrlError extends Error {\n constructor(url: string) {\n super(\n `Could not infer a database dialect from \"${url}\". Expected a URL ` +\n `starting with postgres://, postgresql://, mysql://, mariadb://, ` +\n `sqlite://, or file: — or a SQLite path such as ./dev.db or :memory:.`,\n );\n this.name = \"UnknownDatabaseUrlError\";\n }\n}\n\nexport class MissingDatabaseUrlError extends Error {\n // The connection's name, when it is not the default one. A named connection\n // has no environment variable behind it and no top-level `url` to fall back\n // on, so the generic message would send whoever reads it to check\n // `DATABASE_URL`, which is set and is not what is missing.\n constructor(connection?: string) {\n super(\n connection === undefined || connection === \"default\"\n ? \"No database URL configured. Set the DATABASE_URL environment \" +\n \"variable, or set `url` in app/config/database.ts.\"\n : `The \"${connection}\" database connection has no \\`url\\`. Set one ` +\n `under \\`connections.${connection}\\` in app/config/database.ts.`,\n );\n this.name = \"MissingDatabaseUrlError\";\n }\n}\n\nconst PROTOCOLS: Record<string, Dialect> = {\n \"postgres:\": \"postgres\",\n \"postgresql:\": \"postgres\",\n \"mysql:\": \"mysql\",\n \"mariadb:\": \"mariadb\",\n \"sqlite:\": \"sqlite\",\n \"file:\": \"sqlite\",\n};\n\nconst SQLITE_FILE_EXTENSIONS = [\".db\", \".sqlite\", \".sqlite3\"];\n\n// Infer the dialect from a connection string. Accepts every form Bun's `SQL`\n// accepts, including the bare SQLite paths (`./dev.db`, `:memory:`) that have no\n// protocol at all.\n//\n// Note this deliberately does NOT default to postgres the way `new SQL(...)`\n// does. Guessing the dialect wrong means generating SQL that fails at runtime\n// against a database that connected fine, which is a far more confusing failure\n// than refusing to guess.\nexport function inferDialect(url: string): Dialect {\n const trimmed = url.trim();\n\n if (trimmed === \"\") {\n throw new UnknownDatabaseUrlError(url);\n }\n\n // `:memory:` is SQLite's in-memory database. It looks like a protocol to\n // `new URL()` but isn't one, so it has to be checked before parsing.\n if (trimmed === \":memory:\") {\n return \"sqlite\";\n }\n\n const separator = trimmed.indexOf(\":\");\n if (separator !== -1) {\n const protocol = trimmed.slice(0, separator + 1).toLowerCase();\n const dialect = PROTOCOLS[protocol];\n if (dialect) {\n return dialect;\n }\n }\n\n // No recognised protocol. Bun treats a bare path as a SQLite file, so we do\n // too — but only when it actually looks like one, rather than treating every\n // unrecognised string as SQLite.\n if (looksLikeSqlitePath(trimmed)) {\n return \"sqlite\";\n }\n\n throw new UnknownDatabaseUrlError(url);\n}\n\nfunction looksLikeSqlitePath(value: string): boolean {\n if (value.startsWith(\"./\") || value.startsWith(\"../\") || value.startsWith(\"/\")) {\n return true;\n }\n const lower = value.toLowerCase();\n return SQLITE_FILE_EXTENSIONS.some((extension) => lower.endsWith(extension));\n}\n\n// True when the dialect stores a SQLite database, i.e. a local file rather than\n// a networked server. Callers use this to decide whether `db:setup` should\n// create a file, and which DDL flavour to emit.\nexport function isSqlite(dialect: Dialect): boolean {\n return dialect === \"sqlite\";\n}\n\n// MariaDB is wire-compatible with MySQL and takes the same SQL in everything\n// gemi generates, so query builders collapse the two.\nexport function isMysqlFamily(dialect: Dialect): boolean {\n return dialect === \"mysql\" || dialect === \"mariadb\";\n}\n",
|
|
6
|
+
"import { existsSync, readFileSync, realpathSync, statSync } from \"node:fs\";\nimport { isAbsolute, join, resolve } from \"node:path\";\n\nimport type { Dialect } from \"./dialect\";\n\n/**\n * Where a relative SQLite `DATABASE_URL` actually points.\n *\n * ## The disagreement\n *\n * `DATABASE_URL=file:./dev.db` is the template's default and Prisma's own\n * convention. Prisma resolves it **relative to the directory holding the schema\n * file**, so `prisma migrate dev` writes `prisma/dev.db`. Bun's `SQL` client\n * resolves it relative to the process working directory, so gemi opened\n * `./dev.db` — a different file, which SQLite then *created*, empty. Every\n * query failed with `no such table`, and the 0-byte file left behind looked\n * like a database rather than the symptom.\n *\n * The two had to agree and did not, which is the same class of bug as the\n * `foreign_keys` pragma in `Connection.configure`: development ran under rules\n * the migrations did not share. This resolves the path the way Prisma does, so\n * one relative URL means one file.\n *\n * ## What is left alone\n *\n * Everything that is not ambiguous. `:memory:`, an absolute path, and a\n * networked dialect all pass through untouched, and so does a relative path in\n * an app with no `prisma/schema.prisma` — there is no schema directory to be\n * relative *to*, so the working directory is the only answer available and\n * stays the answer it always was.\n */\n\n/** Prisma's default schema location, relative to the project root. */\nconst SCHEMA_PATH = join(\"prisma\", \"schema.prisma\");\n\n/**\n * The url moved, and the file it used to name holds data.\n *\n * Thrown rather than warned, and rather than choosing. The app was reading the\n * working-directory file until now and that file has rows in it; the resolved one\n * is where Prisma migrates. Which of them matters is not knowable from here — the\n * resolved file may not even exist yet — and the failure mode of guessing is\n * silent: the app runs, against an empty database or against the wrong half of\n * its own history.\n */\nexport class AmbiguousSqlitePathError extends Error {\n constructor(url: string, resolved: string, stranded: string) {\n super(\n `\"${url}\" now resolves to ${resolved}, which is where Prisma migrates it. ` +\n `gemi used to open ${stranded} instead, and that file holds data — so ` +\n `opening the resolved one would quietly leave it behind. gemi will not ` +\n `choose. Move ${stranded} onto ${resolved} if it is the database you ` +\n `want, or point DATABASE_URL at an absolute path to say so explicitly.`,\n );\n this.name = \"AmbiguousSqlitePathError\";\n }\n}\n\nexport type SqliteResolution = {\n /** The URL to hand to the client, in the form it arrived in. */\n url: string;\n /** Set when the path was rewritten: where it used to point, and where it\n * points now. `undefined` when nothing changed. */\n moved?: { from: string; to: string };\n};\n\n/**\n * Splits a SQLite URL into the prefix to put back and the file path itself.\n *\n * `null` for a URL with no file path to resolve — an in-memory database, or a\n * form this does not recognise, both of which are handed on untouched.\n */\nfunction splitSqliteUrl(url: string): { prefix: string; file: string } | null {\n const trimmed = url.trim();\n\n // The prefix is sliced off first, and `:memory:` tested after — the other way\n // round, only the three exact spellings written out longhand were recognised,\n // and `sqlite::memory:` and `file::memory:?cache=shared` (both of which Bun\n // opens in memory) were resolved as if `:memory:` were a file name. That\n // produced a real file called `:memory:` inside `prisma/`, silently, with\n // nothing stranded for the guard below to notice.\n //\n // The original casing is kept rather than the matched constant, so a URL is\n // handed back as it arrived.\n let prefix = \"\";\n let file = trimmed;\n for (const candidate of [\"file://\", \"file:\", \"sqlite://\", \"sqlite:\"]) {\n if (trimmed.slice(0, candidate.length).toLowerCase() === candidate) {\n prefix = trimmed.slice(0, candidate.length);\n file = trimmed.slice(candidate.length);\n break;\n }\n }\n\n // In memory, however it was spelled and whatever query string follows. Not a\n // path, and `resolve` would happily turn it into one.\n if (file === \":memory:\" || file.startsWith(\":memory:?\")) {\n return null;\n }\n\n return { prefix, file };\n}\n\n/**\n * The file a SQLite URL names, resolved the way Prisma resolves it.\n *\n * `cwd` is a parameter rather than read here so the tests can point it at a\n * fixture directory instead of the process's own.\n */\nexport function resolveSqliteUrl(\n url: string,\n dialect: Dialect,\n cwd: string = process.cwd(),\n): SqliteResolution {\n if (dialect !== \"sqlite\") {\n return { url };\n }\n\n const split = splitSqliteUrl(url);\n if (!split || split.file === \"\") {\n return { url };\n }\n\n // An absolute path says exactly what it means; there is nothing to resolve\n // and nothing the two tools could disagree about.\n //\n // Unobservable, and kept anyway: `path.resolve` ignores its base for an\n // absolute segment, so the `from === to` check below reaches the same answer\n // and no test can tell the two apart. This states the intent where a reader\n // looks for it, and saves a `statSync` on every connection that has one.\n if (isAbsolute(split.file)) {\n return { url };\n }\n\n // Query parameters — `?mode=ro`, Prisma's `?connection_limit=` — belong to\n // the URL, not to the file name.\n const query = split.file.indexOf(\"?\");\n const file = query === -1 ? split.file : split.file.slice(0, query);\n const suffix = query === -1 ? \"\" : split.file.slice(query);\n\n const schemaDirectory = join(cwd, \"prisma\");\n if (!prismaMigratesThisUrl(cwd, url)) {\n // Not the database Prisma migrates — no schema at all, a datasource that is\n // not SQLite, or a connection whose url is simply a different one. Nothing\n // else has an opinion about where this points, so it is left as it arrived.\n return { url };\n }\n\n const from = resolve(cwd, file);\n const to = resolve(schemaDirectory, file);\n if (from === to) {\n return { url };\n }\n\n return { url: `${split.prefix}${to}${suffix}`, moved: { from, to } };\n}\n\n/**\n * Whether THIS url is the one Prisma migrates.\n *\n * Not \"does a Prisma schema exist\", and not \"is its datasource SQLite\" — both\n * are questions about the project, and the answer was being applied to every\n * connection. A project has one Prisma datasource and may open any number of\n * SQLite connections through `connections`; a secondary one is not something\n * Prisma has ever seen, so repointing it into `prisma/` either produced an empty\n * database or an `AmbiguousSqlitePathError` whose message — \"the file Prisma\n * migrates\" — was false about that file.\n *\n * So the datasource's own url is read and compared. `url = env(\"DATABASE_URL\")`\n * resolves through the environment, a quoted literal is taken as written, and a\n * connection whose url is neither is left exactly as it arrived.\n *\n * Read with a regex rather than Prisma's parser: this needs two fields out of\n * one block, and the dependency would be a poor trade. Line comments are\n * stripped first, so a commented-out datasource cannot answer for the live one.\n * Anything unreadable answers no, which lands on the old behaviour.\n */\nfunction prismaMigratesThisUrl(cwd: string, url: string): boolean {\n const schema = join(cwd, SCHEMA_PATH);\n if (!existsSync(schema)) return false;\n let source: string;\n try {\n source = readFileSync(schema, \"utf8\");\n } catch {\n return false;\n }\n // `//` to end of line. Prisma has no block comments, and a `//` inside the\n // quoted url would be part of a protocol this function does not act on.\n const live = source.replace(/^\\s*\\/\\/.*$/gm, \"\");\n const datasource = live.match(/datasource\\s+\\w+\\s*\\{([\\s\\S]*?)\\}/);\n if (!datasource) return false;\n const block = datasource[1]!;\n if (!/provider\\s*=\\s*[\"']sqlite[\"']/.test(block)) return false;\n\n const fromEnv = block.match(/url\\s*=\\s*env\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/);\n if (fromEnv) {\n const value = process.env[fromEnv[1]!];\n return typeof value === \"string\" && value.trim() === url.trim();\n }\n const literal = block.match(/url\\s*=\\s*[\"']([^\"']+)[\"']/);\n return literal ? literal[1]!.trim() === url.trim() : false;\n}\n\n/**\n * The database an app was opening before this resolution moved it, when that\n * file holds data.\n *\n * A 0-byte file is the artifact of the bug — SQLite creates an empty file for a\n * path that does not exist — so finding one is the expected case and says\n * nothing. A file with pages in it is the other thing entirely: two databases,\n * one URL, and no way to tell from here which one the app meant. Choosing\n * silently would be choosing somebody's data.\n */\nexport function strandedDatabase(moved: { from: string; to: string }): string | null {\n try {\n // The same file reached two ways is not two databases. `statSync` follows\n // symlinks, so an app that had already worked around this by symlinking the\n // old path onto the real database would otherwise be refused for finding\n // its own data where it put it.\n if (realpathSync(moved.from) === realpathSync(moved.to)) return null;\n } catch {\n // One of the two is not there, which is the ordinary case — fall through and\n // let the stat below decide.\n }\n try {\n const stats = statSync(moved.from);\n return stats.isFile() && stats.size > 0 ? moved.from : null;\n } catch {\n // Not there at all, which is the ordinary case for an app that has only\n // ever run migrations.\n return null;\n }\n}\n",
|
|
7
|
+
"import { SQL } from \"bun\";\nimport type { ConnectionConfig } from \"./config\";\nimport { MissingDatabaseUrlError, inferDialect, type Dialect } from \"./dialect\";\nimport { AmbiguousSqlitePathError, resolveSqliteUrl, strandedDatabase } from \"./sqlitePath\";\n\n/**\n * The name of the connection an application gets without asking for one: the\n * `url` / `options` pair at the top level of `app/config/database.ts`.\n *\n * A constant rather than the string spelled at each site, because it is\n * compared in five places across three layers — the manager resolving a name,\n * the ORM deciding whether a query names a different pool than the open\n * transaction, and the facade — and a typo in any one of them reads as \"that\n * connection is not configured\" rather than as a typo.\n */\nexport const DEFAULT_CONNECTION = \"default\";\n\n/**\n * What every layer above `database/` is allowed to know about a connection.\n *\n * `DatabaseManager` implements this itself and *is* the default connection —\n * see the note on `DatabaseManager.connection`. So this interface is the one\n * shape the ORM and the `DB` facade read, whether they are looking at the\n * default pool or at a named one, and neither has to branch on which it got.\n */\nexport interface DatabaseConnection {\n /** `\"default\"`, or the key this connection was declared under. */\n readonly name: string;\n readonly url: string;\n readonly dialect: Dialect;\n readonly sql: SQL;\n readonly ready: Promise<void>;\n readonly config: ConnectionConfig;\n}\n\n/** A connection named in the config that the manager has no pool for. */\nexport class UnknownConnectionError extends Error {\n constructor(name: string, known: readonly string[]) {\n super(\n `No database connection named \"${name}\". Configured: ` +\n `${known.map((one) => `\"${one}\"`).join(\", \")}. Declare it under ` +\n `\\`connections\\` in app/config/database.ts.`,\n );\n this.name = \"UnknownConnectionError\";\n }\n}\n\n/**\n * A `connections` entry that would shadow the top-level `url`.\n *\n * Refused rather than merged, because the two spellings would be a silent\n * either/or: whichever the manager happened to build last would win, and the\n * losing half of the config would go on describing a pool nothing uses.\n */\nexport class ReservedConnectionNameError extends Error {\n constructor(name: string) {\n super(\n `\"${name}\" is the name of the connection declared by the top-level ` +\n `\\`url\\` and \\`options\\`, so it cannot also appear under ` +\n `\\`connections\\`. Rename it, or move its settings up to the top level.`,\n );\n this.name = \"ReservedConnectionNameError\";\n }\n}\n\n/**\n * A statement that named one connection while a transaction was open on\n * another.\n *\n * **The whole reason named connections refuse rather than route.** A\n * transaction lives on one reserved connection of one pool; there is no\n * mechanism by which a second pool's statement could join it, and no rollback\n * that could take it back. So the alternatives to this error are both worse\n * than an error:\n *\n * - Run it on the other pool anyway, *outside* the transaction. The caller\n * wrote `Model.transaction`, the block rolls back, and that one statement\n * stays committed. Half the work landed and nothing said so.\n * - Run it on the open handle, ignoring the name. Then the statement went to\n * the wrong database, which the ORM cannot even detect afterwards — the\n * tables are usually the same shape.\n *\n * There is no third answer at this layer; two-phase commit is not what a second\n * pool for analytics is asking for. So the failure is made loud and early, at\n * the call that would have straddled the two, and the fix is always the same\n * shape: move that query outside the transaction, or do the whole unit on one\n * connection.\n */\nexport class CrossConnectionTransactionError extends Error {\n constructor(\n /** The connection the open transaction belongs to. */\n public readonly open: string,\n /** The connection the refused statement named. */\n public readonly requested: string,\n ) {\n super(\n `A transaction is open on the \"${open}\" connection, and this statement ` +\n `names \"${requested}\". A transaction cannot span two connections: ` +\n `the statement would run outside it and stay committed when the ` +\n `transaction rolls back. Move this query outside the transaction, or ` +\n `run the whole unit on one connection.`,\n );\n this.name = \"CrossConnectionTransactionError\";\n }\n}\n\n/**\n * One pool: a URL, its dialect, and Bun's client for it.\n *\n * Extracted from `DatabaseManager` when a second connection became\n * configurable (#327). The manager kept the lifecycle — which names exist, how\n * they are resolved, closing them all — and this kept everything that is true\n * of a connection *one at a time*, so the two do not have to be written twice.\n *\n * Safe to build eagerly, like the manager it came from: Bun's client connects\n * on the first query, not at construction. A named connection an application\n * declares and never queries therefore costs an object.\n */\nexport class Connection implements DatabaseConnection {\n public readonly sql: SQL;\n public readonly dialect: Dialect;\n public readonly url: string;\n\n /**\n * Resolves once the connection has been configured, or rejects if it could\n * not be. Only SQLite has anything to do; elsewhere it is already resolved.\n *\n * Exposed so a caller that needs the guarantee can wait for it. Nothing has\n * to: SQLite queues statements on one connection in the order they were\n * issued, so the pragma below is ahead of anything a caller sends after the\n * constructor returns. That ordering is asserted in `DatabaseManager.test.ts`\n * rather than assumed, because it is the load-bearing half.\n */\n public readonly ready: Promise<void>;\n\n constructor(\n public readonly name: string,\n public readonly config: ConnectionConfig = {},\n ) {\n const url = config.url;\n if (!url) {\n throw new MissingDatabaseUrlError(name);\n }\n\n // An explicit `dialect` wins, for URLs whose protocol we can't read (a\n // pooler on a custom scheme). Otherwise infer, which throws rather than\n // guessing — see the note in dialect.ts.\n this.dialect = config.dialect ?? inferDialect(url);\n\n // Before the client is built, because this decides which file the client\n // opens — and SQLite creates whatever it is pointed at, so getting it\n // wrong leaves a convincing empty database rather than an error. See\n // `sqlitePath.ts` for why gemi and Prisma disagreed about it.\n const resolved = resolveSqliteUrl(url, this.dialect);\n if (resolved.moved) {\n const stranded = strandedDatabase(resolved.moved);\n if (stranded) {\n throw new AmbiguousSqlitePathError(url, resolved.moved.to, stranded);\n }\n }\n\n this.url = resolved.url;\n this.sql = config.options\n ? new SQL(this.url, config.options as any)\n : new SQL(this.url);\n this.ready = this.configure();\n }\n\n /**\n * `pragma foreign_keys = ON`, which SQLite leaves **off** by default — and so\n * does Bun's driver, which reports `0` on a fresh connection.\n *\n * Without it SQLite enforces nothing at all. Not \"cascades do not fire\":\n * nothing. An insert naming a parent that does not exist is accepted, a\n * dangling reference survives the parent's deletion, and `ON DELETE RESTRICT`\n * does not restrict — while the migrations declare all three. Postgres\n * enforces them always, and Prisma turns the pragma on for every SQLite\n * connection it opens, so leaving it off meant development and production\n * disagreed about whether the schema's constraints were real.\n *\n * It is also why this is more than a dialect gap. The differential harness\n * compares gemi against Prisma on one database per dialect; with the pragma\n * off on one side, the two were being asked to agree while running under\n * different integrity rules, so an entire class of divergence was invisible\n * to the instrument rather than merely untested.\n *\n * **Per connection, not per database**, which is what makes this a live\n * assumption rather than a one-line fix: Bun serves SQLite from a single\n * connection today, so setting it once holds for every later statement. If\n * that ever becomes a pool, one statement's worth of enforcement would move\n * to whichever connection happened to serve it. `DatabaseManager.test.ts`\n * pins both halves — the value, and that it is the same across concurrent\n * queries — so the day it changes is a failing test rather than a silent\n * regression.\n *\n * That per-connection wording is now literal in a second sense: a named\n * SQLite connection is a *different* Bun client, so it needs the pragma of\n * its own. Running it from this constructor is what makes that automatic —\n * the alternative, doing it once for the default connection, was correct\n * exactly while there was only one.\n *\n * Issued outside any transaction. SQLite documents the pragma as a no-op\n * inside one, so a lazy \"set it on first use\" would be correct exactly until\n * the first use happened to be a transaction.\n */\n private async configure(): Promise<void> {\n if (this.dialect !== \"sqlite\") return;\n await this.sql.unsafe(\"pragma foreign_keys = ON\");\n }\n\n // Escape hatch matching Bun's own API, so `connection.query` reads like `sql`\n // does in Bun's docs: connection.query`select * from users where id = ${id}`\n get query(): SQL {\n return this.sql;\n }\n\n async close(): Promise<void> {\n // A close that races the constructor's `pragma` leaves that statement to\n // settle against a client that is going away, and it settles as a rejection\n // — `ERR_SQLITE_CONNECTION_CLOSED`, from a promise nobody is holding, which\n // arrives as an unhandled rejection naming neither the close nor the\n // pragma. The caller asked for this connection to go away, so that\n // rejection is expected rather than something to surface. Marked handled\n // here rather than suppressed globally, and only on the way out.\n this.ready.catch(() => {});\n await this.sql.close();\n }\n}\n",
|
|
8
|
+
"import type { SQL } from \"bun\";\nimport type { ConnectionConfig, DatabaseConfig } from \"./config\";\nimport {\n Connection,\n DEFAULT_CONNECTION,\n ReservedConnectionNameError,\n UnknownConnectionError,\n type DatabaseConnection,\n} from \"./Connection\";\nimport type { Dialect } from \"./dialect\";\n\n// Wraps Bun's `SQL` client. Bun ships one client that speaks SQLite, Postgres,\n// MySQL and MariaDB, so gemi does not need a driver per database — it needs to\n// know *which* one is in use, which is what `dialect` carries.\n//\n// Safe to build eagerly: Bun's client connects on the first query, not at\n// construction. (`RedisManager` used to be cited here as the parallel case. As\n// of #403 it builds its client in a memoizing getter instead — not because\n// eager construction was unsafe, but because naming Bun's `RedisClient` at\n// module scope is what made `gemi/services` unloadable off Bun. `Connection`\n// still imports `SQL` as a value for the same reason, which is the remaining\n// half of #396.) It is still bound as a lazy singleton,\n// so an app that never touches the database never resolves it and never has to\n// have DATABASE_URL set.\n//\n// Since #327 it holds *connections*, plural: the top-level `url` and `options`\n// build the one called `\"default\"`, and each key under `connections` builds\n// another. What it does not do is decide which one a query uses — that is the\n// ORM's ambient scope and the `DB` facade, because the choice is per query\n// rather than per application. See `connection` below.\nexport class DatabaseManager implements DatabaseConnection {\n static token = \"database\";\n\n /**\n * This object *is* the default connection, so it answers to the name.\n *\n * Not a formality: `connection(\"default\")` returns `this` rather than the\n * `Connection` in the map, which is what keeps every existing reader —\n * `DB.sql`, `db.dialect`, and the test harnesses that wrap the manager in a\n * Proxy to count statements — looking at the same object the ORM executes\n * through. A second object for the default pool would have quietly bypassed\n * all of them while every test still passed.\n */\n public readonly name = DEFAULT_CONNECTION;\n\n /**\n * Every pool this manager owns, keyed by name and including the default one.\n *\n * Private because the map is the manager's bookkeeping — `connection()` is\n * the way in, and it is the only path that knows the default is `this`.\n */\n private readonly pools = new Map<string, Connection>();\n\n /**\n * Resolves once **every** connection has been configured, or rejects if one\n * could not be. Only SQLite has anything to do; elsewhere it is already\n * resolved.\n *\n * All of them rather than the default alone, because the thing a caller waits\n * on this for — SQLite's `pragma foreign_keys` — is per client, so a second\n * SQLite connection has its own and a caller awaiting one manager-level\n * promise means all of them.\n */\n public readonly ready: Promise<void>;\n\n constructor(public config: DatabaseConfig = {}) {\n const { connections = {}, ...primary } = config;\n\n // The default first, so a `MissingDatabaseUrlError` from a missing\n // `DATABASE_URL` still comes out of construction the way it always has,\n // rather than after a named connection has already opened a client.\n this.pools.set(\n DEFAULT_CONNECTION,\n new Connection(DEFAULT_CONNECTION, primary),\n );\n\n // A connection that is built before the one whose config is wrong is still\n // a live client with an open handle, and on the throwing path nothing else\n // will ever hold it: the manager never becomes a value, so nobody can call\n // `close`. Left alone, the pragma this constructor issues for a SQLite\n // connection settles against a client being torn down and surfaces as an\n // unhandled rejection with no configuration error anywhere near it.\n try {\n this.build(connections, primary.slowTransactionThreshold);\n } catch (error) {\n for (const pool of this.pools.values()) {\n // The in-flight configuration first: it is what rejects when the client\n // under it goes away, and this is the only place that can say the\n // rejection was expected.\n pool.ready.catch(() => {});\n pool.close().catch(() => {});\n }\n throw error;\n }\n\n // Built once here rather than derived per read, so that a connection whose\n // configuration rejects produces one unhandled rejection at most instead of\n // a fresh one per access.\n this.ready = Promise.all(\n [...this.pools.values()].map((pool) => pool.ready),\n ).then(() => undefined);\n }\n\n private build(\n connections: Record<string, ConnectionConfig>,\n slowTransactionThreshold: number | false | undefined,\n ): void {\n for (const [name, connection] of Object.entries(connections)) {\n if (name === DEFAULT_CONNECTION)\n throw new ReservedConnectionNameError(name);\n\n this.pools.set(\n name,\n new Connection(name, {\n // The threshold is the one setting a named connection is likely to\n // want *unchanged*: it is a development diagnostic about holding a\n // pooled connection, and that concern does not stop applying because\n // the pool has a name. `url`, `options` and `dialect` are deliberately\n // not inherited — a connection that borrowed the default's URL by\n // omission would be a second pool onto the same database created by a\n // typo in a key.\n slowTransactionThreshold,\n ...connection,\n }),\n );\n }\n }\n\n /**\n * The connection called `name`, or the default one when called with nothing.\n *\n * Throws rather than falling back to the default for an unknown name, and\n * that is the important half. A fallback would make `Model.on(\"analitycs\")`\n * run on the hot path — the exact pool the caller was trying to stay off —\n * and the only symptom would be the incident it was meant to prevent,\n * arriving weeks later with nothing pointing back at the typo.\n */\n connection(name: string = DEFAULT_CONNECTION): DatabaseConnection {\n // `this`, not `pools.get(DEFAULT_CONNECTION)` — see `name` above.\n if (name === DEFAULT_CONNECTION) return this;\n\n const found = this.pools.get(name);\n if (!found) throw new UnknownConnectionError(name, this.connectionNames);\n return found;\n }\n\n /** Every configured name, default first. For error messages and diagnostics. */\n get connectionNames(): string[] {\n return [...this.pools.keys()];\n }\n\n /**\n * The default connection's client. Unchanged in meaning: an application that\n * never names a connection sees exactly what it saw before #327.\n */\n get sql(): SQL {\n return this.default.sql;\n }\n\n get dialect(): Dialect {\n return this.default.dialect;\n }\n\n get url(): string {\n return this.default.url;\n }\n\n // Escape hatch matching Bun's own API, so `db.query` reads like `sql` does in\n // Bun's docs: db.query`select * from users where id = ${id}`\n get query(): SQL {\n return this.sql;\n }\n\n /** Closes every connection, not only the default one. */\n async close(): Promise<void> {\n // The aggregate promise needs the same treatment each connection's own\n // `ready` gets in `Connection.close` — it is derived from them, so a\n // rejection there arrives here as a second, separately unhandled one.\n this.ready.catch(() => {});\n await Promise.all([...this.pools.values()].map((pool) => pool.close()));\n }\n\n private get default(): Connection {\n return this.pools.get(DEFAULT_CONNECTION)!;\n }\n}\n",
|
|
9
|
+
"import type { SQL } from \"bun\";\nimport type { Dialect } from \"./dialect\";\n\n// One connection: a URL, the dialect to compile for, and the pool behind it.\n//\n// Split out of `DatabaseConfig` when a second connection became configurable\n// (#327), so that a named connection is described by exactly the same fields\n// the default one is — rather than by a smaller, second-class shape that would\n// need widening the first time somebody's analytics pool needed a `dialect`\n// override or a threshold of its own.\nexport interface ConnectionConfig {\n // Connection string. Defaults to the `DATABASE_URL` environment variable.\n // The dialect is inferred from it — `postgres://`, `mysql://`, `mariadb://`,\n // `sqlite://`, `file:`, or a SQLite path like `./dev.db` or `:memory:`.\n url?: string;\n\n // Override the inferred dialect. Only needed when the URL doesn't carry a\n // recognisable protocol — a proxy or connection pooler fronting Postgres on a\n // custom scheme, say. Wrong values here produce SQL that fails at runtime\n // against a database that connected fine, so leave it unset unless inference\n // actually gets it wrong.\n dialect?: Dialect;\n\n // Options passed straight through to Bun's `SQL` client (pool size, timeouts,\n // TLS, ...). See https://bun.sh/docs/api/sql.\n options?: Record<string, unknown>;\n\n // How long a transaction may run, in milliseconds, before development warns\n // that it is still holding a pooled connection. `false` turns the warning off.\n //\n // A diagnostic, not a limit: nothing here cancels or shortens a transaction.\n // It only fires in development — the cost of a long transaction is paid by\n // unrelated queries blocking on connection acquisition, and that is a problem\n // worth catching while the callback is still in front of you.\n //\n // Raise it for a seed script or a data migration whose transactions are\n // legitimately long; `false` if the noise is not worth it at all. A value\n // that is not a positive finite number falls back to the 2s default rather\n // than disabling, so the warning cannot be lost to a typo — say `false` when\n // you mean off.\n //\n // Per connection, and this is the field most likely to differ between two of\n // them: a connection that exists *because* its queries are slow will warn on\n // every transaction it opens if it inherits the hot path's threshold, and a\n // warning that always fires is one nobody reads. A named connection that\n // does not set it inherits the top-level value.\n slowTransactionThreshold?: number | false;\n}\n\n// Config key: `database`.\n//\n// The top-level `url` / `options` / `dialect` describe the connection called\n// `\"default\"` — the one every query uses unless it says otherwise. `connections`\n// declares the others.\nexport interface DatabaseConfig extends ConnectionConfig {\n // Additional connections, keyed by the name `DB.connection(name)` and\n // `Model.on(name)` take.\n //\n // The case this exists for is two pools against **one** database with\n // opposite workloads — a hot path that must never block, and an analytics\n // path whose queries legitimately run for seconds:\n //\n // export default defineDatabaseConfig({\n // url: process.env.DATABASE_URL,\n // options: { max: 12 },\n //\n // connections: {\n // analytics: {\n // url: process.env.DATABASE_URL,\n // options: { max: 3, idleTimeout: 60, connectionTimeout: 45 },\n // slowTransactionThreshold: 60_000,\n // },\n // },\n // })\n //\n // A value that protects one of those is the wrong value for the other, which\n // is the entire reason they cannot be one pool with one setting. The same URL\n // twice is normal here and is not a mistake: what differs is the pool, not\n // the database.\n //\n // Two consequences worth knowing before declaring one, both of them\n // structural rather than incidental:\n //\n // - **A transaction cannot span two connections.** A statement that names one\n // while a transaction is open on another raises\n // `CrossConnectionTransactionError` rather than quietly running outside the\n // transaction.\n // - **Every connection is a real pool**, counted separately against whatever\n // connection cap the server or the pooler enforces. Two pools of 12 is 24\n // connections, not 12.\n connections?: Record<string, ConnectionConfig>;\n}\n\nexport function defineDatabaseConfig(config: DatabaseConfig): DatabaseConfig {\n return config;\n}\n\nexport function databaseConfigDefaults(): DatabaseConfig {\n return {\n url: process.env.DATABASE_URL,\n dialect: undefined,\n options: undefined,\n slowTransactionThreshold: SLOW_TRANSACTION_THRESHOLD,\n connections: undefined,\n };\n}\n\n// The default warning threshold, in milliseconds. Exported so the ORM can fall\n// back to the same number when a `DatabaseManager` was built without going\n// through `withDefaults` — a test constructing one directly, say — rather than\n// keeping a second copy of it that can drift.\nexport const SLOW_TRANSACTION_THRESHOLD = 2_000;\n\nexport type { SQL };\n"
|
|
10
|
+
],
|
|
11
|
+
"mappings": ";AAOO,MAAM,UAAgC,KAAM,CACjD,WAAW,CAAC,EAAa,CACvB,MACE,4CAA4C,sFAE1C,2EACJ,EACA,KAAK,KAAO,0BAEhB,CAEO,MAAM,UAAgC,KAAM,CAKjD,WAAW,CAAC,EAAqB,CAC/B,MACE,IAAe,QAAa,IAAe,UACvC,iHAEA,QAAQ,sEACiB,gCAC/B,EACA,KAAK,KAAO,0BAEhB,CAEA,IAAM,EAAqC,CACzC,YAAa,WACb,cAAe,WACf,SAAU,QACV,WAAY,UACZ,UAAW,SACX,QAAS,QACX,EAEM,EAAyB,CAAC,MAAO,UAAW,UAAU,EAUrD,SAAS,CAAY,CAAC,EAAsB,CACjD,IAAM,EAAU,EAAI,KAAK,EAEzB,GAAI,IAAY,GACd,MAAM,IAAI,EAAwB,CAAG,EAKvC,GAAI,IAAY,WACd,MAAO,SAGT,IAAM,EAAY,EAAQ,QAAQ,GAAG,EACrC,GAAI,IAAc,GAAI,CACpB,IAAM,EAAW,EAAQ,MAAM,EAAG,EAAY,CAAC,EAAE,YAAY,EACvD,EAAU,EAAU,GAC1B,GAAI,EACF,OAAO,EAOX,GAAI,EAAoB,CAAO,EAC7B,MAAO,SAGT,MAAM,IAAI,EAAwB,CAAG,EAGvC,SAAS,CAAmB,CAAC,EAAwB,CACnD,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,CAI3B,KAAK,MAAM,MAAM,IAAM,EAAE,EACzB,MAAM,QAAQ,IAAI,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,IAAI,CAAC,IAAS,EAAK,MAAM,CAAC,CAAC,KAG5D,QAAO,EAAe,CAChC,OAAO,KAAK,MAAM,IAAI,CAAkB,EAE5C,CC5FO,SAAS,CAAoB,CAAC,EAAwC,CAC3E,OAAO,EAGF,SAAS,CAAsB,EAAmB,CACvD,MAAO,CACL,IAAK,QAAQ,IAAI,aACjB,QAAS,OACT,QAAS,OACT,yBAA0B,EAC1B,YAAa,MACf,EAOK,IAAM,EAA6B",
|
|
12
|
+
"debugId": "035EC4797A65984064756E2164756E21",
|
|
13
|
+
"names": []
|
|
14
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_ as J}from"./chunk-
|
|
2
|
+
import{_ as J}from"./chunk-jkjt3e06.js";import{ug as I}from"./chunk-r6v21jn6.js";var Z=I((Q)=>{var K=J(),L=(b)=>{return{setHttpHandler(j){b.httpHandler=j},httpHandler(){return b.httpHandler},updateHttpClientConfig(j,w){b.httpHandler?.updateHttpClientConfig(j,w)},httpHandlerConfigs(){return b.httpHandler.httpHandlerConfigs()}}},M=(b)=>{return{httpHandler:b.httpHandler()}};class B{name;kind;values;constructor({name:b,kind:j=K.FieldPosition.HEADER,values:w=[]}){this.name=b,this.kind=j,this.values=w}add(b){this.values.push(b)}set(b){this.values=b}remove(b){this.values=this.values.filter((j)=>j!==b)}toString(){return this.values.map((b)=>b.includes(",")||b.includes(" ")?`"${b}"`:b).join(", ")}get(){return this.values}}class D{entries={};encoding;constructor({fields:b=[],encoding:j="utf-8"}){b.forEach(this.setField.bind(this)),this.encoding=j}setField(b){this.entries[b.name.toLowerCase()]=b}getField(b){return this.entries[b.toLowerCase()]}removeField(b){delete this.entries[b.toLowerCase()]}getByType(b){return Object.values(this.entries).filter((j)=>j.kind===b)}}class z{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(b){this.method=b.method||"GET",this.hostname=b.hostname||"localhost",this.port=b.port,this.query=b.query||{},this.headers=b.headers||{},this.body=b.body,this.protocol=b.protocol?b.protocol.slice(-1)!==":"?`${b.protocol}:`:b.protocol:"https:",this.path=b.path?b.path.charAt(0)!=="/"?`/${b.path}`:b.path:"/",this.username=b.username,this.password=b.password,this.fragment=b.fragment}static clone(b){let j=new z({...b,headers:{...b.headers}});if(j.query)j.query=O(j.query);return j}static isInstance(b){if(!b)return!1;let j=b;return"method"in j&&"protocol"in j&&"hostname"in j&&"path"in j&&typeof j.query==="object"&&typeof j.headers==="object"}clone(){return z.clone(this)}}function O(b){return Object.keys(b).reduce((j,w)=>{let A=b[w];return{...j,[w]:Array.isArray(A)?[...A]:A}},{})}class G{statusCode;reason;headers;body;constructor(b){this.statusCode=b.statusCode,this.reason=b.reason,this.headers=b.headers||{},this.body=b.body}static isInstance(b){if(!b)return!1;let j=b;return typeof j.statusCode==="number"&&typeof j.headers==="object"}}function P(b){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(b)}Q.Field=B;Q.Fields=D;Q.HttpRequest=z;Q.HttpResponse=G;Q.getHttpHandlerExtensionConfiguration=L;Q.isValidHostname=P;Q.resolveHttpHandlerRuntimeConfig=M});
|
|
3
3
|
export{Z as U};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=0E8CD8D37C24F9BB64756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"'use strict';\n\nvar types = require('@smithy/types');\n\nconst getHttpHandlerExtensionConfiguration = (runtimeConfig) => {\n return {\n setHttpHandler(handler) {\n runtimeConfig.httpHandler = handler;\n },\n httpHandler() {\n return runtimeConfig.httpHandler;\n },\n updateHttpClientConfig(key, value) {\n runtimeConfig.httpHandler?.updateHttpClientConfig(key, value);\n },\n httpHandlerConfigs() {\n return runtimeConfig.httpHandler.httpHandlerConfigs();\n },\n };\n};\nconst resolveHttpHandlerRuntimeConfig = (httpHandlerExtensionConfiguration) => {\n return {\n httpHandler: httpHandlerExtensionConfiguration.httpHandler(),\n };\n};\n\nclass Field {\n name;\n kind;\n values;\n constructor({ name, kind = types.FieldPosition.HEADER, values = [] }) {\n this.name = name;\n this.kind = kind;\n this.values = values;\n }\n add(value) {\n this.values.push(value);\n }\n set(values) {\n this.values = values;\n }\n remove(value) {\n this.values = this.values.filter((v) => v !== value);\n }\n toString() {\n return this.values.map((v) => (v.includes(\",\") || v.includes(\" \") ? `\"${v}\"` : v)).join(\", \");\n }\n get() {\n return this.values;\n }\n}\n\nclass Fields {\n entries = {};\n encoding;\n constructor({ fields = [], encoding = \"utf-8\" }) {\n fields.forEach(this.setField.bind(this));\n this.encoding = encoding;\n }\n setField(field) {\n this.entries[field.name.toLowerCase()] = field;\n }\n getField(name) {\n return this.entries[name.toLowerCase()];\n }\n removeField(name) {\n delete this.entries[name.toLowerCase()];\n }\n getByType(kind) {\n return Object.values(this.entries).filter((field) => field.kind === kind);\n }\n}\n\nclass HttpRequest {\n method;\n protocol;\n hostname;\n port;\n path;\n query;\n headers;\n username;\n password;\n fragment;\n body;\n constructor(options) {\n this.method = options.method || \"GET\";\n this.hostname = options.hostname || \"localhost\";\n this.port = options.port;\n this.query = options.query || {};\n this.headers = options.headers || {};\n this.body = options.body;\n this.protocol = options.protocol\n ? options.protocol.slice(-1) !== \":\"\n ? `${options.protocol}:`\n : options.protocol\n : \"https:\";\n this.path = options.path ? (options.path.charAt(0) !== \"/\" ? `/${options.path}` : options.path) : \"/\";\n this.username = options.username;\n this.password = options.password;\n this.fragment = options.fragment;\n }\n static clone(request) {\n const cloned = new HttpRequest({\n ...request,\n headers: { ...request.headers },\n });\n if (cloned.query) {\n cloned.query = cloneQuery(cloned.query);\n }\n return cloned;\n }\n static isInstance(request) {\n if (!request) {\n return false;\n }\n const req = request;\n return (\"method\" in req &&\n \"protocol\" in req &&\n \"hostname\" in req &&\n \"path\" in req &&\n typeof req[\"query\"] === \"object\" &&\n typeof req[\"headers\"] === \"object\");\n }\n clone() {\n return HttpRequest.clone(this);\n }\n}\nfunction cloneQuery(query) {\n return Object.keys(query).reduce((carry, paramName) => {\n const param = query[paramName];\n return {\n ...carry,\n [paramName]: Array.isArray(param) ? [...param] : param,\n };\n }, {});\n}\n\nclass HttpResponse {\n statusCode;\n reason;\n headers;\n body;\n constructor(options) {\n this.statusCode = options.statusCode;\n this.reason = options.reason;\n this.headers = options.headers || {};\n this.body = options.body;\n }\n static isInstance(response) {\n if (!response)\n return false;\n const resp = response;\n return typeof resp.statusCode === \"number\" && typeof resp.headers === \"object\";\n }\n}\n\nfunction isValidHostname(hostname) {\n const hostPattern = /^[a-z0-9][a-z0-9\\.\\-]*[a-z0-9]$/;\n return hostPattern.test(hostname);\n}\n\nexports.Field = Field;\nexports.Fields = Fields;\nexports.HttpRequest = HttpRequest;\nexports.HttpResponse = HttpResponse;\nexports.getHttpHandlerExtensionConfiguration = getHttpHandlerExtensionConfiguration;\nexports.isValidHostname = isValidHostname;\nexports.resolveHttpHandlerRuntimeConfig = resolveHttpHandlerRuntimeConfig;\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";qGAEA,FAAI,MAEE,EAAuC,CAAC,IAAkB,CAC5D,MAAO,CACH,cAAc,CAAC,EAAS,CACpB,EAAc,YAAc,GAEhC,WAAW,EAAG,CACV,OAAO,EAAc,aAEzB,sBAAsB,CAAC,EAAK,EAAO,CAC/B,EAAc,aAAa,uBAAuB,EAAK,CAAK,GAEhE,kBAAkB,EAAG,CACjB,OAAO,EAAc,YAAY,mBAAmB,EAE5D,GAEE,EAAkC,CAAC,IAAsC,CAC3E,MAAO,CACH,YAAa,EAAkC,YAAY,CAC/D,GAGJ,MAAM,CAAM,CACR,KACA,KACA,OACA,WAAW,EAAG,OAAM,OAAO,EAAM,cAAc,OAAQ,SAAS,CAAC,GAAK,CAClE,KAAK,KAAO,EACZ,KAAK,KAAO,EACZ,KAAK,OAAS,EAElB,GA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debugId": "
|
|
8
|
+
"debugId": "0E8CD8D37C24F9BB64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * Shallow-merges an app config slice over the framework defaults, ignoring keys\n * whose value is `undefined`.\n *\n * A plain `{ ...defaults, ...config }` lets an explicit `undefined` win — a\n * `defineMailConfig({ headers: undefined })`, or any optional property the app\n * spread in from another object, would erase the default and hand the service a\n * missing dependency. Omitting a key and setting it to `undefined` mean the\n * same thing for a config slice, so both fall back to the default here.\n */\nexport function withDefaults<T extends object>(\n defaults: Required<T>,\n config: Partial<T> | undefined,\n): Required<T>;\nexport function withDefaults<D extends object, C extends object>(\n defaults: D,\n config: C | undefined,\n): D & C;\nexport function withDefaults(\n defaults: Record<string, any>,\n config: Record<string, any> | undefined,\n) {\n const merged: Record<string, any> = { ...defaults };\n if (!config) {\n return merged;\n }\n for (const key of Object.keys(config)) {\n if (config[key] !== undefined) {\n merged[key] = config[key];\n }\n }\n return merged;\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAkBO,SAAS,CAAY,CAC1B,EACA,EACA,CACA,IAAM,EAA8B,IAAK,CAAS,EAClD,GAAI,CAAC,EACH,OAAO,EAET,QAAW,KAAO,OAAO,KAAK,CAAM,EAClC,GAAI,EAAO,KAAS,OAClB,EAAO,GAAO,EAAO,GAGzB,OAAO",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "8B724AD98B8A585964756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ug as a}from"./chunk-r6v21jn6.js";var i=a((f)=>{function u(t){let r={};if(t=t.replace(/^\?/,""),t)for(let n of t.split("&")){let[e,s=null]=n.split("=");if(e=decodeURIComponent(e),s)s=decodeURIComponent(s);if(!(e in r))r[e]=s;else if(Array.isArray(r[e]))r[e].push(s);else r[e]=[r[e],s]}return r}f.parseQueryString=u});var U=a((d)=>{var y=i(),c=(t)=>{if(typeof t==="string")return c(new URL(t));let{hostname:r,pathname:n,port:e,protocol:s,search:o}=t,p;if(o)p=y.parseQueryString(o);return{hostname:r,port:e?parseInt(e):void 0,protocol:s,path:n,query:p}};d.parseUrl=c});
|
|
3
3
|
export{U as Z};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=FD9E54BA0B3CBFA964756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"'use strict';\n\nvar querystringParser = require('@smithy/querystring-parser');\n\nconst parseUrl = (url) => {\n if (typeof url === \"string\") {\n return parseUrl(new URL(url));\n }\n const { hostname, pathname, port, protocol, search } = url;\n let query;\n if (search) {\n query = querystringParser.parseQueryString(search);\n }\n return {\n hostname,\n port: port ? parseInt(port) : undefined,\n protocol,\n path: pathname,\n query,\n };\n};\n\nexports.parseUrl = parseUrl;\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";uDAEA,SAAS,CAAgB,CAAC,EAAa,CACnC,IAAM,EAAQ,CAAC,EAEf,GADA,EAAc,EAAY,QAAQ,MAAO,EAAE,EACvC,EACA,QAAW,KAAQ,EAAY,MAAM,GAAG,EAAG,CACvC,IAAK,EAAK,EAAQ,MAAQ,EAAK,MAAM,GAAG,EAExC,GADA,EAAM,mBAAmB,CAAG,EACxB,EACA,EAAQ,mBAAmB,CAAK,EAEpC,GAAI,EAAE,KAAO,GACT,EAAM,GAAO,EAEZ,QAAI,MAAM,QAAQ,EAAM,EAAI,EAC7B,EAAM,GAAK,KAAK,CAAK,EAGrB,OAAM,GAAO,CAAC,EAAM,GAAM,CAAK,EAI3C,OAAO,EAGH,mBAAmB,kBCxB3B,IAAI,MAEE,EAAW,CAAC,IAAQ,CACtB,GAAI,OAAO,IAAQ,SACf,OAAO,EAAS,IAAI,IAAI,CAAG,CAAC,EAEhC,IAAQ,WAAU,WAAU,OAAM,WAAU,UAAW,EACnD,EACJ,GAAI,EACA,EAAQ,EAAkB,iBAAiB,CAAM,EAErD,MAAO,CACH,WACA,KAAM,EAAO,SAAS,CAAI,EAAI,OAC9B,WACA,KAAM,EACN,OACJ,GAGI,WAAW",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "FD9E54BA0B3CBFA964756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ug as y}from"./chunk-r6v21jn6.js";var v=y((x)=>{class s extends Error{name="ProviderError";tryNextLink;constructor(r,t=!0){let n,e=!0;if(typeof t==="boolean")n=void 0,e=t;else if(t!=null&&typeof t==="object")n=t.logger,e=t.tryNextLink??!0;super(r);this.tryNextLink=e,Object.setPrototypeOf(this,s.prototype),n?.debug?.(`@smithy/property-provider ${e?"->":"(!)"} ${r}`)}static from(r,t=!0){return Object.assign(new this(r.message,t),r)}}class f extends s{name="CredentialsProviderError";constructor(r,t=!0){super(r,t);Object.setPrototypeOf(this,f.prototype)}}class l extends s{name="TokenProviderError";constructor(r,t=!0){super(r,t);Object.setPrototypeOf(this,l.prototype)}}var p=(...r)=>async()=>{if(r.length===0)throw new s("No providers in chain");let t;for(let n of r)try{return await n()}catch(e){if(t=e,e?.tryNextLink)continue;throw e}throw t},d=(r)=>()=>Promise.resolve(r),h=(r,t,n)=>{let e,o,i,c=!1,a=async()=>{if(!o)o=r();try{e=await o,i=!0,c=!1}finally{o=void 0}return e};if(t===void 0)return async(u)=>{if(!i||u?.forceRefresh)e=await a();return e};return async(u)=>{if(!i||u?.forceRefresh)e=await a();if(c)return e;if(n&&!n(e))return c=!0,e;if(t(e))return await a(),e;return e}};x.CredentialsProviderError=f;x.ProviderError=s;x.TokenProviderError=l;x.chain=p;x.fromStatic=d;x.memoize=h});
|
|
3
3
|
export{v as $};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=A9AE0C765D01803164756E2164756E21
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"'use strict';\n\nclass ProviderError extends Error {\n name = \"ProviderError\";\n tryNextLink;\n constructor(message, options = true) {\n let logger;\n let tryNextLink = true;\n if (typeof options === \"boolean\") {\n logger = undefined;\n tryNextLink = options;\n }\n else if (options != null && typeof options === \"object\") {\n logger = options.logger;\n tryNextLink = options.tryNextLink ?? true;\n }\n super(message);\n this.tryNextLink = tryNextLink;\n Object.setPrototypeOf(this, ProviderError.prototype);\n logger?.debug?.(`@smithy/property-provider ${tryNextLink ? \"->\" : \"(!)\"} ${message}`);\n }\n static from(error, options = true) {\n return Object.assign(new this(error.message, options), error);\n }\n}\n\nclass CredentialsProviderError extends ProviderError {\n name = \"CredentialsProviderError\";\n constructor(message, options = true) {\n super(message, options);\n Object.setPrototypeOf(this, CredentialsProviderError.prototype);\n }\n}\n\nclass TokenProviderError extends ProviderError {\n name = \"TokenProviderError\";\n constructor(message, options = true) {\n super(message, options);\n Object.setPrototypeOf(this, TokenProviderError.prototype);\n }\n}\n\nconst chain = (...providers) => async () => {\n if (providers.length === 0) {\n throw new ProviderError(\"No providers in chain\");\n }\n let lastProviderError;\n for (const provider of providers) {\n try {\n const credentials = await provider();\n return credentials;\n }\n catch (err) {\n lastProviderError = err;\n if (err?.tryNextLink) {\n continue;\n }\n throw err;\n }\n }\n throw lastProviderError;\n};\n\nconst fromStatic = (staticValue) => () => Promise.resolve(staticValue);\n\nconst memoize = (provider, isExpired, requiresRefresh) => {\n let resolved;\n let pending;\n let hasResult;\n let isConstant = false;\n const coalesceProvider = async () => {\n if (!pending) {\n pending = provider();\n }\n try {\n resolved = await pending;\n hasResult = true;\n isConstant = false;\n }\n finally {\n pending = undefined;\n }\n return resolved;\n };\n if (isExpired === undefined) {\n return async (options) => {\n if (!hasResult || options?.forceRefresh) {\n resolved = await coalesceProvider();\n }\n return resolved;\n };\n }\n return async (options) => {\n if (!hasResult || options?.forceRefresh) {\n resolved = await coalesceProvider();\n }\n if (isConstant) {\n return resolved;\n }\n if (requiresRefresh && !requiresRefresh(resolved)) {\n isConstant = true;\n return resolved;\n }\n if (isExpired(resolved)) {\n await coalesceProvider();\n return resolved;\n }\n return resolved;\n };\n};\n\nexports.CredentialsProviderError = CredentialsProviderError;\nexports.ProviderError = ProviderError;\nexports.TokenProviderError = TokenProviderError;\nexports.chain = chain;\nexports.fromStatic = fromStatic;\nexports.memoize = memoize;\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";uDAEA,MAAM,UAAsB,KAAM,CAC9B,KAAO,gBACP,YACA,WAAW,CAAC,EAAS,EAAU,GAAM,CACjC,IAAI,EACA,EAAc,GAClB,GAAI,OAAO,IAAY,UACnB,EAAS,OACT,EAAc,EAEb,QAAI,GAAW,MAAQ,OAAO,IAAY,SAC3C,EAAS,EAAQ,OACjB,EAAc,EAAQ,aAAe,GAEzC,MAAM,CAAO,EACb,KAAK,YAAc,EACnB,OAAO,eAAe,KAAM,EAAc,SAAS,EACnD,GAAQ,QAAQ,6BAA6B,EAAc,KAAO,SAAS,GAAS,QAEjF,KAAI,CAAC,EAAO,EAAU,GAAM,CAC/B,OAAO,OAAO,OAAO,IAAI,KAAK,EAAM,QAAS,CAAO,EAAG,CAAK,EAEpE,CAEA,MAAM,UAAiC,CAAc,CACjD,KAAO,2BACP,WAAW,CAAC,EAAS,EAAU,GAAM,CACjC,MAAM,EAAS,CAAO,EACtB,OAAO,eAAe,KAAM,EAAyB,SAAS,EAEtE,CAEA,MAAM,UAA2B,CAAc,CAC3C,KAAO,qBACP,WAAW,CAAC,EAAS,EAAU,GAAM,CACjC,MAAM,EAAS,CAAO,EACtB,OAAO,eAAe,KAAM,EAAmB,SAAS,EAEhE,CAEA,IAAM,EAAQ,IAAI,IAAc,SAAY,CACxC,GAAI,EAAU,SAAW,EACrB,MAAM,IAAI,EAAc,uBAAuB,EAEnD,IAAI,EACJ,QAAW,KAAY,EACnB,GAAI,CAEA,OADoB,MAAM,EAAS,EAGvC,MAAO,EAAK,CAER,GADA,EAAoB,EAChB,GAAK,YACL,SAEJ,MAAM,EAGd,MAAM,GAGJ,EAAa,CAAC,IAAgB,IAAM,QAAQ,QAAQ,CAAW,EAE/D,EAAU,CAAC,EAAU,EAAW,IAAoB,CACtD,IAAI,EACA,EACA,EACA,EAAa,GACX,EAAmB,SAAY,CACjC,GAAI,CAAC,EACD,EAAU,EAAS,EAEvB,GAAI,CACA,EAAW,MAAM,EACjB,EAAY,GACZ,EAAa,UAEjB,CACI,EAAU,OAEd,OAAO,GAEX,GAAI,IAAc,OACd,MAAO,OAAO,IAAY,CACtB,GAAI,CAAC,GAAa,GAAS,aACvB,EAAW,MAAM,EAAiB,EAEtC,OAAO,GAGf,MAAO,OAAO,IAAY,CACtB,GAAI,CAAC,GAAa,GAAS,aACvB,EAAW,MAAM,EAAiB,EAEtC,GAAI,EACA,OAAO,EAEX,GAAI,GAAmB,CAAC,EAAgB,CAAQ,EAE5C,OADA,EAAa,GACN,EAEX,GAAI,EAAU,CAAQ,EAElB,OADA,MAAM,EAAiB,EAChB,EAEX,OAAO,IAIP,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EACR,aAAa,EACb,UAAU",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "A9AE0C765D01803164756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
"/**\n * The prefix every api route is served under. The browser adds it when it\n * fetches (`/api${path}`) and the server strips it before matching, so an api\n * router's own paths never carry it.\n */\nexport const API_PREFIX = \"/api\";\n\n/**\n * Whether a request pathname is an api request: `/api` itself or anything\n * under `/api/`. A bare `startsWith(\"/api\")` also claims `/apidocs`,\n * `/api-keys` and `/apiary`, so a view route there would never render — the\n * api dispatcher would answer its 404 JSON instead.\n */\nexport function isApiPath(pathname: string): boolean {\n return pathname === API_PREFIX || pathname.startsWith(`${API_PREFIX}/`);\n}\n\n/**\n * The api router path a request pathname addresses: `/api/users/1` is\n * `/users/1`, `/api/` is `/` and `/api` is `\"\"`. Only the leading prefix is\n * stripped — `replace(\"/api\", \"\")` would also strip an `/api` inside the path\n * of a request that did not start with one (`/files/api` becoming `/files`).\n * A pathname outside `/api` comes back unchanged, so the dispatcher can still\n * be handed a request by its route path directly.\n */\nexport function apiPath(pathname: string): string {\n return isApiPath(pathname) ? pathname.slice(API_PREFIX.length) : pathname;\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";AAaO,SAAS,CAAS,CAAC,EAA2B,CACnD,OAAO,IATiB,QASU,EAAS,WAAW,OAAgB,EAWjE,SAAS,CAAO,CAAC,EAA0B,CAChD,OAAO,EAAU,CAAQ,EAAI,EAAS,MAAM,CAAiB,EAAI",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "E8296F855FB2444264756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{H as A}from"./chunk-
|
|
2
|
+
import{H as A}from"./chunk-3mp9p38x.js";import{V as T}from"./chunk-e1fkxt82.js";import"./chunk-jkjt3e06.js";import{$ as y}from"./chunk-8jpvj3cj.js";import{tg as r}from"./chunk-r6v21jn6.js";var u=r(A(),1);var i=r(y(),1),E=r(A(),1);import{exec as d}from"child_process";import{promisify as I}from"util";var x=r(T(),1),_=(c,n,e)=>{if(n.Version!==1)throw Error(`Profile ${c} credential_process did not return Version 1.`);if(n.AccessKeyId===void 0||n.SecretAccessKey===void 0)throw Error(`Profile ${c} credential_process returned invalid credentials.`);if(n.Expiration){let w=new Date;if(new Date(n.Expiration)<w)throw Error(`Profile ${c} credential_process returned expired credentials.`)}let s=n.AccountId;if(!s&&e?.[c]?.aws_account_id)s=e[c].aws_account_id;let t={accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,...n.SessionToken&&{sessionToken:n.SessionToken},...n.Expiration&&{expiration:new Date(n.Expiration)},...n.CredentialScope&&{credentialScope:n.CredentialScope},...s&&{accountId:s}};return x.setCredentialFeature(t,"CREDENTIALS_PROCESS","w"),t};var K=async(c,n,e)=>{let s=n[c];if(n[c]){let t=s.credential_process;if(t!==void 0){let w=I(E.externalDataInterceptor?.getTokenRecord?.().exec??d);try{let{stdout:o}=await w(t),S;try{S=JSON.parse(o.trim())}catch{throw Error(`Profile ${c} credential_process returned invalid JSON.`)}return _(c,S,n)}catch(o){throw new i.CredentialsProviderError(o.message,{logger:e})}}else throw new i.CredentialsProviderError(`Profile ${c} did not contain credential_process.`,{logger:e})}else throw new i.CredentialsProviderError(`Profile ${c} could not be found in shared credentials file.`,{logger:e})};var R=(c={})=>async({callerClientConfig:n}={})=>{c.logger?.debug("@aws-sdk/credential-provider-process - fromProcess");let e=await u.parseKnownFiles(c);return K(u.getProfileName({profile:c.profile??n?.profile}),e,c.logger)};export{R as fromProcess};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=2BAF9EFA0264AEA464756E2164756E21
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
"import { setCredentialFeature } from \"@aws-sdk/core/client\";\nexport const getValidatedProcessCredentials = (profileName, data, profiles) => {\n if (data.Version !== 1) {\n throw Error(`Profile ${profileName} credential_process did not return Version 1.`);\n }\n if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {\n throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);\n }\n if (data.Expiration) {\n const currentTime = new Date();\n const expireTime = new Date(data.Expiration);\n if (expireTime < currentTime) {\n throw Error(`Profile ${profileName} credential_process returned expired credentials.`);\n }\n }\n let accountId = data.AccountId;\n if (!accountId && profiles?.[profileName]?.aws_account_id) {\n accountId = profiles[profileName].aws_account_id;\n }\n const credentials = {\n accessKeyId: data.AccessKeyId,\n secretAccessKey: data.SecretAccessKey,\n ...(data.SessionToken && { sessionToken: data.SessionToken }),\n ...(data.Expiration && { expiration: new Date(data.Expiration) }),\n ...(data.CredentialScope && { credentialScope: data.CredentialScope }),\n ...(accountId && { accountId }),\n };\n setCredentialFeature(credentials, \"CREDENTIALS_PROCESS\", \"w\");\n return credentials;\n};\n"
|
|
8
8
|
],
|
|
9
9
|
"mappings": ";qNAAA,SCAA,SACA,KACA,SAAS,sBACT,oBAAS,aCHT,eACa,EAAiC,CAAC,EAAa,EAAM,IAAa,CAC3E,GAAI,EAAK,UAAY,EACjB,MAAM,MAAM,WAAW,gDAA0D,EAErF,GAAI,EAAK,cAAgB,QAAa,EAAK,kBAAoB,OAC3D,MAAM,MAAM,WAAW,oDAA8D,EAEzF,GAAI,EAAK,WAAY,CACjB,IAAM,EAAc,IAAI,KAExB,GADmB,IAAI,KAAK,EAAK,UAAU,EAC1B,EACb,MAAM,MAAM,WAAW,oDAA8D,EAG7F,IAAI,EAAY,EAAK,UACrB,GAAI,CAAC,GAAa,IAAW,IAAc,eACvC,EAAY,EAAS,GAAa,eAEtC,IAAM,EAAc,CAChB,YAAa,EAAK,YAClB,gBAAiB,EAAK,mBAClB,EAAK,cAAgB,CAAE,aAAc,EAAK,YAAa,KACvD,EAAK,YAAc,CAAE,WAAY,IAAI,KAAK,EAAK,UAAU,CAAE,KAC3D,EAAK,iBAAmB,CAAE,gBAAiB,EAAK,eAAgB,KAChE,GAAa,CAAE,WAAU,CACjC,EAEA,OADA,uBAAqB,EAAa,sBAAuB,GAAG,EACrD,GDvBJ,IAAM,EAA4B,MAAO,EAAa,EAAU,IAAW,CAC9E,IAAM,EAAU,EAAS,GACzB,GAAI,EAAS,GAAc,CACvB,IAAM,EAAoB,EAAQ,mBAClC,GAAI,IAAsB,OAAW,CACjC,IAAM,EAAc,EAAU,2BAAyB,iBAAiB,EAAE,MAAQ,CAAI,EACtF,GAAI,CACA,IAAQ,UAAW,MAAM,EAAY,CAAiB,EAClD,EACJ,GAAI,CACA,EAAO,KAAK,MAAM,EAAO,KAAK,CAAC,EAEnC,KAAM,CACF,MAAM,MAAM,WAAW,6CAAuD,EAElF,OAAO,EAA+B,EAAa,EAAM,CAAQ,EAErE,MAAO,EAAO,CACV,MAAM,IAAI,2BAAyB,EAAM,QAAS,CAAE,QAAO,CAAC,GAIhE,WAAM,IAAI,2BAAyB,WAAW,wCAAmD,CAAE,QAAO,CAAC,EAI/G,WAAM,IAAI,2BAAyB,WAAW,mDAA8D,CACxG,QACJ,CAAC,GD/BF,IAAM,EAAc,CAAC,EAAO,CAAC,IAAM,OAAS,sBAAuB,CAAC,IAAM,CAC7E,EAAK,QAAQ,MAAM,oDAAoD,EACvE,IAAM,EAAW,MAAM,kBAAgB,CAAI,EAC3C,OAAO,EAA0B,iBAAe,CAC5C,QAAS,EAAK,SAAW,GAAoB,OACjD,CAAC,EAAG,EAAU,EAAK,MAAM",
|
|
10
|
-
"debugId": "
|
|
10
|
+
"debugId": "2BAF9EFA0264AEA464756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ug as t,xg as A}from"./chunk-r6v21jn6.js";var o=t((b)=>{var i=(r)=>typeof ArrayBuffer==="function"&&r instanceof ArrayBuffer||Object.prototype.toString.call(r)==="[object ArrayBuffer]";b.isArrayBuffer=i});var y=t((g)=>{var m=o(),f=A("buffer"),B=(r,e=0,u=r.byteLength-e)=>{if(!m.isArrayBuffer(r))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof r} (${r})`);return f.Buffer.from(r,e,u)},a=(r,e)=>{if(typeof r!=="string")throw TypeError(`The "input" argument must be of type string. Received type ${typeof r} (${r})`);return e?f.Buffer.from(r,e):f.Buffer.from(r)};g.fromArrayBuffer=B;g.fromString=a});var x=t((w)=>{var n=y(),s=(r)=>{let e=n.fromString(r,"utf8");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)},h=(r)=>{if(typeof r==="string")return s(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength/Uint8Array.BYTES_PER_ELEMENT);return new Uint8Array(r)},p=(r)=>{if(typeof r==="string")return r;if(typeof r!=="object"||typeof r.byteOffset!=="number"||typeof r.byteLength!=="number")throw Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.");return n.fromArrayBuffer(r.buffer,r.byteOffset,r.byteLength).toString("utf8")};w.fromUtf8=s;w.toUint8Array=h;w.toUtf8=p});
|
|
3
3
|
export{o as W,y as X,x as Y};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=2AF390A8497BB42764756E2164756E21
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
"'use strict';\n\nvar utilBufferFrom = require('@smithy/util-buffer-from');\n\nconst fromUtf8 = (input) => {\n const buf = utilBufferFrom.fromString(input, \"utf8\");\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);\n};\n\nconst toUint8Array = (data) => {\n if (typeof data === \"string\") {\n return fromUtf8(data);\n }\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);\n }\n return new Uint8Array(data);\n};\n\nconst toUtf8 = (input) => {\n if (typeof input === \"string\") {\n return input;\n }\n if (typeof input !== \"object\" || typeof input.byteOffset !== \"number\" || typeof input.byteLength !== \"number\") {\n throw new Error(\"@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.\");\n }\n return utilBufferFrom.fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString(\"utf8\");\n};\n\nexports.fromUtf8 = fromUtf8;\nexports.toUint8Array = toUint8Array;\nexports.toUtf8 = toUtf8;\n"
|
|
8
8
|
],
|
|
9
9
|
"mappings": ";+DAEA,IAAM,EAAgB,CAAC,IAAS,OAAO,cAAgB,YAAc,aAAe,aAChF,OAAO,UAAU,SAAS,KAAK,CAAG,IAAM,uBAEpC,gBAAgB,kBCHxB,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