gemi 0.116.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/app/index.js +2 -2
- package/dist/app/index.js.map +1 -1
- package/dist/auth/AuthServiceProvider.d.ts.map +1 -1
- package/dist/auth/config.d.ts +27 -0
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/auth/connections/ConnectionManager.d.ts +133 -0
- package/dist/auth/connections/ConnectionManager.d.ts.map +1 -0
- package/dist/auth/connections/ConnectionStore.d.ts +146 -0
- package/dist/auth/connections/ConnectionStore.d.ts.map +1 -0
- package/dist/auth/connections/ConnectionsController.d.ts +23 -0
- package/dist/auth/connections/ConnectionsController.d.ts.map +1 -0
- package/dist/auth/connections/OAuthConnectionProvider.d.ts +105 -0
- package/dist/auth/connections/OAuthConnectionProvider.d.ts.map +1 -0
- package/dist/auth/connections/errors.d.ts +32 -0
- package/dist/auth/connections/errors.d.ts.map +1 -0
- package/dist/auth/oauth/oauthState.d.ts +15 -2
- package/dist/auth/oauth/oauthState.d.ts.map +1 -1
- package/dist/auth/routes.d.ts +13 -0
- package/dist/auth/routes.d.ts.map +1 -1
- package/dist/bin/orm/emit.d.ts.map +1 -1
- package/dist/bin/orm-generator.js +51 -4
- package/dist/bin/orm-generator.js.map +4 -4
- package/dist/bun/plugin.js +2 -2
- package/dist/bun/plugin.js.map +1 -1
- package/dist/bun/preload.js +2 -2
- package/dist/bun/preload.js.map +1 -1
- package/dist/{chunk-2tzm58j3.js → chunk-01ehxca0.js} +2 -2
- package/dist/{chunk-2tzm58j3.js.map → chunk-01ehxca0.js.map} +1 -1
- package/dist/chunk-0gtyects.js +10 -0
- package/dist/{chunk-yf1njzd5.js.map → chunk-0gtyects.js.map} +6 -5
- package/dist/{chunk-15c2vgaf.js → chunk-1m3hvy3q.js} +2 -2
- package/dist/{chunk-15c2vgaf.js.map → chunk-1m3hvy3q.js.map} +1 -1
- package/dist/{chunk-6cx8ncd4.js → chunk-1z1rj2zq.js} +3 -3
- package/dist/{chunk-6cx8ncd4.js.map → chunk-1z1rj2zq.js.map} +1 -1
- package/dist/{chunk-5stgtwqw.js → chunk-2bja99cq.js} +2 -2
- package/dist/{chunk-5stgtwqw.js.map → chunk-2bja99cq.js.map} +1 -1
- package/dist/{chunk-n672d4g8.js → chunk-30xxc6r7.js} +2 -2
- package/dist/{chunk-n672d4g8.js.map → chunk-30xxc6r7.js.map} +1 -1
- package/dist/{chunk-qjhw8nje.js → chunk-33s2xqv1.js} +1 -1
- package/dist/{chunk-4088szy9.js → chunk-39kyz4k6.js} +3 -3
- package/dist/{chunk-4088szy9.js.map → chunk-39kyz4k6.js.map} +1 -1
- package/dist/chunk-3nf95j9e.js +5 -0
- package/dist/{chunk-1q9kd20m.js.map → chunk-3nf95j9e.js.map} +1 -1
- package/dist/chunk-3zxfd7pn.js +14 -0
- package/dist/{chunk-pn8v6fj2.js.map → chunk-3zxfd7pn.js.map} +11 -6
- package/dist/{chunk-pyk3gzvc.js → chunk-453rmkpm.js} +2 -2
- package/dist/{chunk-pyk3gzvc.js.map → chunk-453rmkpm.js.map} +1 -1
- package/dist/chunk-47h12eme.js +57 -0
- package/dist/{chunk-ms9k0rx6.js.map → chunk-47h12eme.js.map} +15 -11
- package/dist/chunk-490sbcma.js +5 -0
- package/dist/chunk-490sbcma.js.map +12 -0
- package/dist/{chunk-kqxdsv22.js → chunk-4c1kdd8p.js} +2 -2
- package/dist/{chunk-kqxdsv22.js.map → chunk-4c1kdd8p.js.map} +1 -1
- package/dist/{chunk-jdhdrr2k.js → chunk-5cgq9c43.js} +2 -2
- package/dist/{chunk-jdhdrr2k.js.map → chunk-5cgq9c43.js.map} +1 -1
- package/dist/{chunk-9n1hx3mq.js → chunk-5dbpgyrx.js} +3 -3
- package/dist/{chunk-9n1hx3mq.js.map → chunk-5dbpgyrx.js.map} +1 -1
- package/dist/{chunk-eqse2m6n.js → chunk-5ses4tcz.js} +2 -2
- package/dist/{chunk-eqse2m6n.js.map → chunk-5ses4tcz.js.map} +1 -1
- package/dist/{chunk-2z1981d0.js → chunk-675kzd7z.js} +2 -2
- package/dist/{chunk-2z1981d0.js.map → chunk-675kzd7z.js.map} +1 -1
- package/dist/{chunk-p1aqq0ga.js → chunk-6ggmk2eg.js} +3 -3
- package/dist/{chunk-p1aqq0ga.js.map → chunk-6ggmk2eg.js.map} +1 -1
- package/dist/{chunk-mazznq15.js → chunk-76p0rf4d.js} +3 -3
- package/dist/{chunk-mazznq15.js.map → chunk-76p0rf4d.js.map} +1 -1
- package/dist/{chunk-41da9628.js → chunk-8t6dwwz6.js} +1 -1
- package/dist/{chunk-zyt2w03d.js → chunk-8wcpxm41.js} +2 -2
- package/dist/{chunk-zyt2w03d.js.map → chunk-8wcpxm41.js.map} +1 -1
- package/dist/chunk-9pkj7sk6.js +50 -0
- package/dist/chunk-9pkj7sk6.js.map +10 -0
- package/dist/{chunk-jmpw6bqz.js → chunk-a1qt8aky.js} +2 -2
- package/dist/{chunk-jmpw6bqz.js.map → chunk-a1qt8aky.js.map} +1 -1
- package/dist/{chunk-frerzsxq.js → chunk-a22h5cby.js} +2 -2
- package/dist/{chunk-frerzsxq.js.map → chunk-a22h5cby.js.map} +1 -1
- package/dist/{chunk-e573yxpq.js → chunk-aedkrck1.js} +3 -3
- package/dist/{chunk-e573yxpq.js.map → chunk-aedkrck1.js.map} +1 -1
- package/dist/{chunk-vxm6yevm.js → chunk-aqpaw4jq.js} +2 -2
- package/dist/{chunk-vxm6yevm.js.map → chunk-aqpaw4jq.js.map} +1 -1
- package/dist/{chunk-aeh67ynz.js → chunk-bgwtdbfw.js} +3 -3
- package/dist/{chunk-aeh67ynz.js.map → chunk-bgwtdbfw.js.map} +1 -1
- package/dist/{chunk-tw5kwbx4.js → chunk-bz8xssrc.js} +2 -2
- package/dist/{chunk-tw5kwbx4.js.map → chunk-bz8xssrc.js.map} +1 -1
- package/dist/{chunk-tzm3c7n6.js → chunk-cte6ysqd.js} +4 -4
- package/dist/{chunk-tzm3c7n6.js.map → chunk-cte6ysqd.js.map} +1 -1
- package/dist/{chunk-qsrcdzan.js → chunk-cvfg88cx.js} +3 -3
- package/dist/{chunk-qsrcdzan.js.map → chunk-cvfg88cx.js.map} +1 -1
- package/dist/{chunk-1vzks22y.js → chunk-d806cy7p.js} +2 -2
- package/dist/{chunk-1vzks22y.js.map → chunk-d806cy7p.js.map} +1 -1
- package/dist/{chunk-6chz1ktz.js → chunk-de4t48j9.js} +3 -3
- package/dist/{chunk-6chz1ktz.js.map → chunk-de4t48j9.js.map} +1 -1
- package/dist/{chunk-mqfzdfnz.js → chunk-dwpn6fze.js} +2 -2
- package/dist/{chunk-mqfzdfnz.js.map → chunk-dwpn6fze.js.map} +1 -1
- package/dist/{chunk-vbdty91k.js → chunk-ebret82e.js} +3 -3
- package/dist/{chunk-vbdty91k.js.map → chunk-ebret82e.js.map} +1 -1
- package/dist/chunk-eke2frrm.js +9 -0
- package/dist/{chunk-hytt9qyj.js.map → chunk-eke2frrm.js.map} +3 -4
- package/dist/{chunk-yer1r3t3.js → chunk-epvpmakp.js} +2 -2
- package/dist/{chunk-yer1r3t3.js.map → chunk-epvpmakp.js.map} +1 -1
- package/dist/{chunk-fxgxf16k.js → chunk-fsj5k511.js} +2 -2
- package/dist/{chunk-fxgxf16k.js.map → chunk-fsj5k511.js.map} +1 -1
- package/dist/{chunk-t4yh4nf9.js → chunk-g5ppst76.js} +3 -3
- package/dist/{chunk-t4yh4nf9.js.map → chunk-g5ppst76.js.map} +1 -1
- package/dist/{chunk-aazmrxj9.js → chunk-g9hhdcax.js} +2 -2
- package/dist/{chunk-aazmrxj9.js.map → chunk-g9hhdcax.js.map} +1 -1
- package/dist/{chunk-cbqazg9k.js → chunk-gqfqnv3f.js} +2 -2
- package/dist/{chunk-cbqazg9k.js.map → chunk-gqfqnv3f.js.map} +1 -1
- package/dist/chunk-hkf2k2eq.js +5 -0
- package/dist/{chunk-whtzggn6.js.map → chunk-hkf2k2eq.js.map} +3 -4
- package/dist/{chunk-vw8849ys.js → chunk-hm9cjxy2.js} +2 -2
- package/dist/{chunk-m54s6jpr.js.map → chunk-hm9cjxy2.js.map} +1 -1
- package/dist/{chunk-kejwjerj.js → chunk-hr1r3g0d.js} +2 -2
- package/dist/{chunk-kejwjerj.js.map → chunk-hr1r3g0d.js.map} +1 -1
- package/dist/{chunk-3hrj5rwm.js → chunk-hzepfrzy.js} +2 -2
- package/dist/{chunk-3hrj5rwm.js.map → chunk-hzepfrzy.js.map} +1 -1
- package/dist/{chunk-785b41h1.js → chunk-j5858bz7.js} +3 -3
- package/dist/{chunk-785b41h1.js.map → chunk-j5858bz7.js.map} +1 -1
- package/dist/{chunk-d9mar37g.js → chunk-jf6qqzat.js} +2 -2
- package/dist/{chunk-d9mar37g.js.map → chunk-jf6qqzat.js.map} +1 -1
- package/dist/{chunk-1hr4xht1.js → chunk-jg79n382.js} +2 -2
- package/dist/{chunk-1hr4xht1.js.map → chunk-jg79n382.js.map} +1 -1
- package/dist/chunk-k31qfe7a.js +71 -0
- package/dist/chunk-k31qfe7a.js.map +13 -0
- package/dist/{chunk-4mfrgd5m.js → chunk-kk77x2v4.js} +2 -2
- package/dist/{chunk-4mfrgd5m.js.map → chunk-kk77x2v4.js.map} +1 -1
- package/dist/{chunk-1myhm0g3.js → chunk-kkte8nze.js} +3 -3
- package/dist/{chunk-1myhm0g3.js.map → chunk-kkte8nze.js.map} +1 -1
- package/dist/{chunk-hdps9n52.js → chunk-m4kmetpb.js} +3 -3
- package/dist/{chunk-hdps9n52.js.map → chunk-m4kmetpb.js.map} +1 -1
- package/dist/{chunk-gts5p6mw.js → chunk-n4sdm0jn.js} +4 -4
- package/dist/{chunk-gts5p6mw.js.map → chunk-n4sdm0jn.js.map} +1 -1
- package/dist/chunk-nang3847.js +416 -0
- package/dist/chunk-nang3847.js.map +24 -0
- package/dist/{chunk-agyfv3f8.js → chunk-nrezmscd.js} +1 -1
- package/dist/{chunk-xt9tv99x.js → chunk-p83erprx.js} +2 -2
- package/dist/{chunk-xt9tv99x.js.map → chunk-p83erprx.js.map} +1 -1
- package/dist/{chunk-sr942vb1.js → chunk-pkr5dsbk.js} +2 -2
- package/dist/{chunk-sr942vb1.js.map → chunk-pkr5dsbk.js.map} +1 -1
- package/dist/{chunk-yhrye9cm.js → chunk-pqc16rrx.js} +2 -2
- package/dist/{chunk-yhrye9cm.js.map → chunk-pqc16rrx.js.map} +1 -1
- package/dist/{chunk-m54s6jpr.js → chunk-pvz90a49.js} +2 -2
- package/dist/{chunk-vw8849ys.js.map → chunk-pvz90a49.js.map} +1 -1
- package/dist/{chunk-fre6f4nk.js → chunk-q290tgza.js} +2 -2
- package/dist/{chunk-fre6f4nk.js.map → chunk-q290tgza.js.map} +1 -1
- package/dist/{chunk-8rv62v14.js → chunk-qf4bmee9.js} +2 -2
- package/dist/{chunk-8rv62v14.js.map → chunk-qf4bmee9.js.map} +1 -1
- package/dist/chunk-qkxnvpaj.js +5 -0
- package/dist/chunk-qkxnvpaj.js.map +10 -0
- package/dist/chunk-r1favzz4.js +19 -0
- package/dist/{chunk-ktr3k768.js.map → chunk-r1favzz4.js.map} +5 -4
- package/dist/{chunk-303mprnv.js → chunk-r3v2cnrj.js} +2 -2
- package/dist/{chunk-303mprnv.js.map → chunk-r3v2cnrj.js.map} +1 -1
- package/dist/{chunk-x7cpth2f.js → chunk-razjfecn.js} +1 -1
- package/dist/{chunk-t04f3akb.js → chunk-scc0j5k9.js} +2 -2
- package/dist/{chunk-t04f3akb.js.map → chunk-scc0j5k9.js.map} +1 -1
- package/dist/{chunk-56jky6vf.js → chunk-sce5jes2.js} +2 -2
- package/dist/{chunk-56jky6vf.js.map → chunk-sce5jes2.js.map} +1 -1
- package/dist/chunk-sd02ktf2.js +24 -0
- package/dist/{chunk-79xg42e7.js.map → chunk-sd02ktf2.js.map} +2 -2
- package/dist/{chunk-mschc94q.js → chunk-sn04cyw0.js} +2 -2
- package/dist/{chunk-mschc94q.js.map → chunk-sn04cyw0.js.map} +1 -1
- package/dist/{chunk-bra1a1fq.js → chunk-tfdmvxza.js} +2 -2
- package/dist/{chunk-bra1a1fq.js.map → chunk-tfdmvxza.js.map} +1 -1
- package/dist/{chunk-z10cas5r.js → chunk-thz75w6e.js} +2 -2
- package/dist/{chunk-z10cas5r.js.map → chunk-thz75w6e.js.map} +1 -1
- package/dist/{chunk-v1tfdgy1.js → chunk-tzdenj0n.js} +3 -3
- package/dist/{chunk-v1tfdgy1.js.map → chunk-tzdenj0n.js.map} +1 -1
- package/dist/{chunk-98m15b9x.js → chunk-x6v2zex2.js} +2 -2
- package/dist/{chunk-98m15b9x.js.map → chunk-x6v2zex2.js.map} +1 -1
- package/dist/{chunk-d2gfcf85.js → chunk-xfw8zyvn.js} +2 -2
- package/dist/{chunk-d2gfcf85.js.map → chunk-xfw8zyvn.js.map} +1 -1
- package/dist/{chunk-wyw6p3fg.js → chunk-xtzn0qfh.js} +3 -3
- package/dist/{chunk-wyw6p3fg.js.map → chunk-xtzn0qfh.js.map} +1 -1
- package/dist/{chunk-tn2bryy2.js → chunk-xx3zvc3g.js} +2 -2
- package/dist/{chunk-tn2bryy2.js.map → chunk-xx3zvc3g.js.map} +1 -1
- package/dist/{chunk-er3wf6ng.js → chunk-xzn2nmny.js} +2 -2
- package/dist/{chunk-er3wf6ng.js.map → chunk-xzn2nmny.js.map} +1 -1
- package/dist/{chunk-p91b8zcn.js → chunk-xzyy896s.js} +2 -2
- package/dist/{chunk-p91b8zcn.js.map → chunk-xzyy896s.js.map} +1 -1
- package/dist/chunk-y09r0wsw.js +5 -0
- package/dist/chunk-y09r0wsw.js.map +12 -0
- package/dist/{chunk-6d8rvr1v.js → chunk-ygf0z7kk.js} +2 -2
- package/dist/{chunk-6d8rvr1v.js.map → chunk-ygf0z7kk.js.map} +1 -1
- package/dist/chunk-z759yah5.js +5 -0
- package/dist/chunk-z759yah5.js.map +12 -0
- package/dist/client/Head.d.ts.map +1 -1
- package/dist/client/fonts.d.ts +69 -0
- package/dist/client/fonts.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +75 -1
- package/dist/client/index.js.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/console/builtins.d.ts +13 -0
- package/dist/console/builtins.d.ts.map +1 -0
- package/dist/console/run.js +13 -11
- package/dist/console/run.js.map +6 -5
- package/dist/console/runner.d.ts.map +1 -1
- package/dist/console/usage.d.ts +2 -0
- package/dist/console/usage.d.ts.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Connections.d.ts +36 -0
- package/dist/facades/Connections.d.ts.map +1 -0
- package/dist/facades/Crypt.d.ts +26 -0
- package/dist/facades/Crypt.d.ts.map +1 -0
- package/dist/facades/Meta.d.ts +7 -1
- package/dist/facades/Meta.d.ts.map +1 -1
- package/dist/facades/Storage.d.ts +29 -0
- package/dist/facades/Storage.d.ts.map +1 -1
- package/dist/facades/index.d.ts +2 -0
- package/dist/facades/index.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/HttpRequest.d.ts +1 -0
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/Metadata.d.ts +5 -0
- package/dist/http/Metadata.d.ts.map +1 -1
- package/dist/http/index.d.ts +3 -1
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/http/requestContext.d.ts +1 -0
- package/dist/http/requestContext.d.ts.map +1 -1
- package/dist/http/safeFetch/errors.d.ts +10 -0
- package/dist/http/safeFetch/errors.d.ts.map +1 -1
- package/dist/http/safeFetch/index.d.ts +1 -1
- package/dist/http/safeFetch/index.d.ts.map +1 -1
- package/dist/http/sitemap/Robots.d.ts +95 -0
- package/dist/http/sitemap/Robots.d.ts.map +1 -0
- package/dist/http/sitemap/Sitemap.d.ts +145 -0
- package/dist/http/sitemap/Sitemap.d.ts.map +1 -0
- package/dist/http/sitemap/fetchText.d.ts +16 -0
- package/dist/http/sitemap/fetchText.d.ts.map +1 -0
- package/dist/http/sitemap/index.d.ts +3 -0
- package/dist/http/sitemap/index.d.ts.map +1 -0
- package/dist/http/sitemap/xml.d.ts +21 -0
- package/dist/http/sitemap/xml.d.ts.map +1 -0
- package/dist/i18n/Translator.d.ts.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +2 -2
- package/dist/i18n/resolveLocale.d.ts +18 -0
- package/dist/i18n/resolveLocale.d.ts.map +1 -1
- package/dist/kernel/index.js +3 -3
- package/dist/kernel/index.js.map +3 -3
- package/dist/kernel/providers.d.ts +2 -2
- package/dist/kernel/providers.d.ts.map +1 -1
- package/dist/orm/Model.d.ts.map +1 -1
- package/dist/orm/encryption-rotate.d.ts +44 -0
- package/dist/orm/encryption-rotate.d.ts.map +1 -0
- package/dist/orm/encryption.d.ts +54 -0
- package/dist/orm/encryption.d.ts.map +1 -0
- package/dist/orm/index.d.ts +2 -0
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +3 -3
- package/dist/orm/index.js.map +4 -4
- package/dist/orm/schema.d.ts +25 -1
- package/dist/orm/schema.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/discovery.d.ts +8 -0
- package/dist/services/discovery.d.ts.map +1 -1
- package/dist/services/encryption/Encrypter.d.ts +86 -0
- package/dist/services/encryption/Encrypter.d.ts.map +1 -0
- package/dist/services/encryption/EncryptionServiceProvider.d.ts +13 -0
- package/dist/services/encryption/EncryptionServiceProvider.d.ts.map +1 -0
- package/dist/services/encryption/config.d.ts +36 -0
- package/dist/services/encryption/config.d.ts.map +1 -0
- package/dist/services/file-storage/drivers/FileStorageDriver.d.ts +12 -1
- package/dist/services/file-storage/drivers/FileStorageDriver.d.ts.map +1 -1
- package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +8 -1
- package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
- package/dist/services/file-storage/drivers/types.d.ts +17 -0
- package/dist/services/file-storage/drivers/types.d.ts.map +1 -1
- package/dist/services/file-storage/putFromUrl.d.ts +56 -0
- package/dist/services/file-storage/putFromUrl.d.ts.map +1 -0
- package/dist/services/file-storage/sniffContentType.d.ts +33 -0
- package/dist/services/file-storage/sniffContentType.d.ts.map +1 -0
- package/dist/services/index.d.ts +26 -5
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +10 -10
- package/dist/services/index.js.map +4 -3
- package/dist/services/queue/DatabaseQueueDriver.d.ts +117 -7
- package/dist/services/queue/DatabaseQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/Job.d.ts +75 -0
- package/dist/services/queue/Job.d.ts.map +1 -1
- package/dist/services/queue/MemoryQueueDriver.d.ts +32 -2
- package/dist/services/queue/MemoryQueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueDriver.d.ts +83 -1
- package/dist/services/queue/QueueDriver.d.ts.map +1 -1
- package/dist/services/queue/QueueManager.d.ts +80 -7
- package/dist/services/queue/QueueManager.d.ts.map +1 -1
- package/dist/services/queue/QueueServiceProvider.d.ts.map +1 -1
- package/dist/services/queue/backoff.d.ts +6 -0
- package/dist/services/queue/backoff.d.ts.map +1 -0
- package/dist/services/queue/batch.d.ts +112 -0
- package/dist/services/queue/batch.d.ts.map +1 -0
- package/dist/services/queue/config.d.ts +9 -0
- package/dist/services/queue/config.d.ts.map +1 -1
- package/dist/services/queue/queueDriverContract.d.ts +5 -0
- package/dist/services/queue/queueDriverContract.d.ts.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts +89 -0
- package/dist/services/queue/workflow/DatabaseWorkflowStore.d.ts.map +1 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts +43 -0
- package/dist/services/queue/workflow/MemoryWorkflowStore.d.ts.map +1 -0
- package/dist/services/queue/workflow/Step.d.ts +202 -0
- package/dist/services/queue/workflow/Step.d.ts.map +1 -0
- package/dist/services/queue/workflow/Workflow.d.ts +124 -0
- package/dist/services/queue/workflow/Workflow.d.ts.map +1 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts +60 -0
- package/dist/services/queue/workflow/WorkflowRuntime.d.ts.map +1 -0
- package/dist/services/queue/workflow/WorkflowStore.d.ts +184 -0
- package/dist/services/queue/workflow/WorkflowStore.d.ts.map +1 -0
- package/dist/services/queue/workflow/duration.d.ts +8 -0
- package/dist/services/queue/workflow/duration.d.ts.map +1 -0
- package/dist/services/queue/workflow/workflowContract.d.ts +30 -0
- package/dist/services/queue/workflow/workflowContract.d.ts.map +1 -0
- package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
- package/dist/stats/route-table.js +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/dist/vitest/index.js +2 -2
- package/dist/vitest/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-1q9kd20m.js +0 -5
- package/dist/chunk-49nyyjfe.js +0 -5
- package/dist/chunk-49nyyjfe.js.map +0 -11
- package/dist/chunk-79xg42e7.js +0 -24
- package/dist/chunk-7vb4eey2.js +0 -217
- package/dist/chunk-7vb4eey2.js.map +0 -16
- package/dist/chunk-hytt9qyj.js +0 -54
- package/dist/chunk-jmg2zsaf.js +0 -5
- package/dist/chunk-jmg2zsaf.js.map +0 -12
- package/dist/chunk-ktr3k768.js +0 -19
- package/dist/chunk-ms9k0rx6.js +0 -46
- package/dist/chunk-pn8v6fj2.js +0 -14
- package/dist/chunk-whtzggn6.js +0 -5
- package/dist/chunk-yf1njzd5.js +0 -10
- /package/dist/{chunk-qjhw8nje.js.map → chunk-33s2xqv1.js.map} +0 -0
- /package/dist/{chunk-41da9628.js.map → chunk-8t6dwwz6.js.map} +0 -0
- /package/dist/{chunk-agyfv3f8.js.map → chunk-nrezmscd.js.map} +0 -0
- /package/dist/{chunk-x7cpth2f.js.map → chunk-razjfecn.js.map} +0 -0
package/dist/chunk-79xg42e7.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{S as D,T as KJ,U as OJ}from"./chunk-6d8rvr1v.js";import{na as B,ra as L,sa as UJ}from"./chunk-frerzsxq.js";import{Ca as e}from"./chunk-4mfrgd5m.js";import"./chunk-5stgtwqw.js";import{Nc as a,qe as QJ,re as A}from"./chunk-ms9k0rx6.js";import"./chunk-whtzggn6.js";import"./chunk-hytt9qyj.js";import{cg as o,dg as n,gg as i}from"./chunk-pn8v6fj2.js";import{Tg as WJ}from"./chunk-15c2vgaf.js";import"./chunk-49nyyjfe.js";import"./chunk-tn2bryy2.js";import"./chunk-cbqazg9k.js";import"./chunk-1myhm0g3.js";import"./chunk-kejwjerj.js";import"./chunk-aazmrxj9.js";import"./chunk-jmg2zsaf.js";import"./chunk-t4yh4nf9.js";import"./chunk-1vzks22y.js";import"./chunk-zyt2w03d.js";import{ni as YJ}from"./chunk-1hr4xht1.js";import{oi as N}from"./chunk-d9mar37g.js";import"./chunk-vw8849ys.js";import{join as w,resolve as VJ,sep as zJ}from"path";import{Duplex as qJ}from"stream";import{constants as P,createBrotliCompress as TJ,createGzip as RJ}from"zlib";var bJ=["br","gzip"],kJ=1024,SJ=5,wJ=19,vJ=6;function EJ(J){if(J===void 0)return 1;if(!/^\d+(\.\d{0,3})?$/.test(J.trim()))return 1;let $=Number(J.trim());return Number.isFinite($)?Math.min($,1):1}function yJ(J){if(J===null||J===void 0)return null;let $=new Map;for(let Z of J.split(",")){let[X,...Q]=Z.split(";"),W=X.trim().toLowerCase();if(W==="")continue;let j=1;for(let Y of Q){let K=Y.indexOf("=");if(K===-1)continue;if(Y.slice(0,K).trim().toLowerCase()==="q"){j=EJ(Y.slice(K+1));break}}$.set(W,j)}return $}function b(J,$=bJ){let Z=yJ(J);if(!Z)return null;let X=Z.get("*"),Q=null,W=0;for(let j of $){let Y=Z.get(j)??X??0;if(Y>W)Q=j,W=Y}return Q}function gJ(J,$){if(!J)return!1;return J.split(",").some((Z)=>Z.trim().toLowerCase().split("=")[0].trim()===$)}function fJ(J,$){if(J==="HEAD")return!1;if($.status<200||$.status===204||$.status===206||$.status===304)return!1;if($.headers.has("Content-Range"))return!1;let Z=$.headers.get("Content-Type");if(!Z||!/^\s*text\/html\s*(;|$)/i.test(Z))return!1;if(!$.body)return!1;let X=$.headers.get("Content-Encoding");if(X&&X.trim().toLowerCase()!=="identity")return!1;if(gJ($.headers.get("Cache-Control"),"no-transform"))return!1;let Q=$.headers.get("Content-Length");if(Q!==null&&Number(Q)<kJ)return!1;return!0}function mJ(J){let $=J==="br"?TJ({params:{[P.BROTLI_PARAM_QUALITY]:SJ,[P.BROTLI_PARAM_LGWIN]:wJ},flush:P.BROTLI_OPERATION_FLUSH}):RJ({level:vJ,flush:P.Z_SYNC_FLUSH});return qJ.toWeb($)}function uJ(J){let $=J.get("Vary");if(!$){J.set("Vary","Accept-Encoding");return}let Z=$.split(",").map((X)=>X.trim().toLowerCase());if(Z.includes("*")||Z.includes("accept-encoding"))return;J.append("Vary","Accept-Encoding")}function c(J,$){if(!fJ(J.method,$))return $;let Z=new Headers($.headers);uJ(Z);let X=b(J.headers.get("Accept-Encoding"));if(!X)return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z});let Q;try{Q=mJ(X)}catch{return new Response($.body,{status:$.status,statusText:$.statusText,headers:Z})}return Z.set("Content-Encoding",X),Z.delete("Content-Length"),new Response($.body.pipeThrough(Q),{status:$.status,statusText:$.statusText,headers:Z})}import{readdir as nJ,stat as t}from"fs/promises";import{join as iJ}from"path";import{mkdir as U2,readFile as hJ,stat as K2,writeFile as O2}from"fs/promises";import{dirname as z2,join as cJ}from"path";import{promisify as p}from"util";import{brotliCompress as pJ,constants as C2,gzip as dJ}from"zlib";var lJ=".vite/static-assets.json";var d={br:".br",gzip:".gz"},oJ=["br","gzip"],I2=p(pJ),F2=p(dJ);async function l(J){let $;try{$=await hJ(cJ(J,lJ),"utf8")}catch{return null}let Z;try{Z=JSON.parse($)?.files}catch{return null}if(!Z||typeof Z!=="object")return null;let X={files:{}};for(let[Q,W]of Object.entries(Z)){if(!Array.isArray(W))continue;X.files[Q]=oJ.filter((j)=>W.includes(j))}return X}function k(J){let $=J.toString(),Z=new Bun.CryptoHasher("sha1");return Z.update($),Z.digest("hex")}async function r(J){let $=new Set;async function Z(X,Q){let W;try{W=await nJ(X,{withFileTypes:!0})}catch{return}for(let j of W){if(j.name.startsWith("."))continue;if(Q&&j.name==="assets")continue;let Y=iJ(X,j.name),K=j.isDirectory(),V=j.isFile();if(j.isSymbolicLink())try{let I=await t(Y);K=I.isDirectory(),V=I.isFile()}catch{continue}if(V)$.add(Y);else if(K&&!j.isSymbolicLink())await Z(Y,!1)}}return await Z(J,!0),$}var aJ="public, max-age=31536000, must-revalidate",tJ="public, max-age=31536000, immutable";async function rJ(J,$,Z){if(Z.length===0||J.headers.has("Range"))return null;let X=b(J.headers.get("Accept-Encoding"),Z);if(!X)return null;let Q=$+d[X];try{let W=await t(Q);return W.isFile()?{encoding:X,path:Q,size:W.size}:null}catch{return null}}async function s(J,$,Z={}){let X=Bun.file($),Q=Z.encodings??[],W={"Content-Type":X.type||"application/octet-stream","Cache-Control":Z.immutable?tJ:aJ,"Accept-Ranges":"bytes"};if(Q.length>0)W.Vary="Accept-Encoding";let j=await rJ(J,$,Q);if(j){let V=Bun.file(j.path);return new Response(V.stream(),{headers:{...W,"Content-Encoding":j.encoding,"Content-Length":String(j.size),ETag:`${k(V.lastModified)}-${j.encoding}`}})}let Y=X.size;W.ETag=k(X.lastModified);let K=o(J.headers.get("Range"));if(K){let V=n(K,Y);if(!V)return a(Y);return new Response(X.slice(V.start,V.end+1).stream(),{status:206,headers:{...W,"Content-Range":i(V.start,V.end,Y),"Content-Length":String(V.length)}})}return new Response(X.stream(),{headers:{...W,"Content-Length":String(Y)}})}import{stat as Z2}from"fs/promises";var _="app/client.tsx";function JJ(J,$=B){let Z=J[_]?.file;if(!Z)return;return{module:L(Z,$),preload:M(J,_,$)}}function M(J,$,Z=B){let X=[],Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y?.file)return;X.push(L(Y.file,Z));for(let K of Y.imports??[])W(K)};return W($),X}function $J(J,$){let Z=[],X=new Set,Q=new Set,W=(j)=>{if(Q.has(j))return;Q.add(j);let Y=J[j];if(!Y)return;for(let K of Y.imports??[])W(K);for(let K of Y.css??[])if(!X.has(K))X.add(K),Z.push(K)};return W($),Z}function ZJ(J,$=B){let Z=new Map;return(X)=>{if(!Z.has(X)){let Q=`${X}${e}`,W=J[Q]?.file;Z.set(X,W?{src:L(W,$),preload:M(J,Q,$)}:void 0)}return Z.get(X)}}function XJ(J,$=30000){let Z=JSON.stringify("gemi:chunk-reload"),X=JSON.stringify(`Failed to fetch dynamically imported module: ${J}`);return`var r=!1;try{var s=window.sessionStorage,m=JSON.parse(s.getItem(${Z})||"null");var d=m?Date.now()-m.at:NaN;if(navigator.onLine!==!1&&!(d>=0&&d<${$})){s.setItem(${Z},JSON.stringify({url:window.location.href,at:Date.now()}));r=!0}}catch(e){}if(r)window.location.reload();else throw new Error(${X});export {}`}var sJ=new RegExp(`^${QJ}/.+\\.m?js$`);function eJ(J){return sJ.test(J)}function HJ(J){if(eJ(J))return new Response(XJ(J),{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store"}});if(A(J))return new Response("Not found",{status:404});return}var J2=`<!DOCTYPE html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Internal Server Error</title>
|
|
8
|
-
<style>
|
|
9
|
-
body { font-family: system-ui, sans-serif; margin: 0; min-height: 100vh; display: grid; place-items: center; }
|
|
10
|
-
main { text-align: center; padding: 16px; }
|
|
11
|
-
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
|
|
12
|
-
p { margin: 0; opacity: 0.7; }
|
|
13
|
-
</style>
|
|
14
|
-
</head>
|
|
15
|
-
<body>
|
|
16
|
-
<main>
|
|
17
|
-
<h1>Something went wrong</h1>
|
|
18
|
-
<p>Please try again later.</p>
|
|
19
|
-
</main>
|
|
20
|
-
</body>
|
|
21
|
-
</html>`;function S(J,$,Z){if(!Z)console.error(J);else try{Z(J instanceof Error?J:Error(String(J),{cause:J}))}catch(X){console.error(J),console.error(X)}if(N($))return new Response(JSON.stringify({error:WJ("server_error","Internal Server Error",500)}),{status:500,headers:{"Content-Type":"application/json"}});return new Response(J2,{status:500,headers:{"Content-Type":"text/html; charset=utf-8"}})}var $2={kind:"none"};function jJ(J){let $=(J??"").trim().toLowerCase();if($===""||$==="false"||$==="off"||$==="0")return $2;if($==="true")return{kind:"all"};if(/^[1-9]\d*$/.test($))return{kind:"hops",hops:Number($)};throw Error(`GEMI_TRUST_PROXY must be "false", "true" or the number of proxies in front of the app (e.g. 1). Got ${JSON.stringify(J)}.`)}function GJ(J,$,Z){if(Z.kind==="all"){if(!J.get("x-forwarded-for")&&$)J.set("x-forwarded-for",$);return}J.delete("x-real-ip");let X=$;if(Z.kind==="hops"){let Q=(J.get("x-forwarded-for")??"").split(",").map((j)=>j.trim()).filter(Boolean),W=Q.length-Z.hops;X=W>=0?Q[W]:Q[0]??$}if(X)J.set("x-forwarded-for",X);else J.delete("x-forwarded-for")}var q=YJ(),X2=w(q,"app"),x=w(q,"dist"),C=w(x,"client");function Q2(J){let $;try{$=decodeURIComponent(J)}catch{return null}let Z=VJ(C,"."+$.replace("/assets/assets","/assets"));return Z.startsWith(C+zJ)?Z:null}async function H2(J){try{return(await Z2(J)).isFile()}catch{return!1}}async function Z3(J,$){let Z=await import(`${x}/client/.vite/manifest.json`),X=await import(`${x}/server/.vite/manifest.json`),Q=await UJ(`${x}/client`);process.env.ROOT_DIR=q,process.env.APP_DIR=X2,process.env.DIST_DIR=x;let W={},j={},Y={},K={},V={},I=(H,G)=>`"${H}": () => import("${G}")`,v=[];for(let H of["404",...J.getFlatComponentTree.call(J)]){let G=X[`app/views/${H}.tsx`];if(!G?.file){console.log(`Server file not found for ${H}`),console.log(G);let z=Object.keys(X),F=`app/views/${H}.tsx`;console.log(`${F} not found in server manifest`),console.log(z)}let U=await import(`${process.env.DIST_DIR}/server/${G?.file}`);W[H]=U.default,j[H]=U.OpenGraph,Y[H]=U;let O=Z[`app/views/${H}.tsx`];if(O?.css&&O?.css.length>0)K[H]=O?.css;if(O)v.push(I(H,L(O?.file,Q))),V[H]=M(Z,`app/views/${H}.tsx`,Q)}let xJ=`{${v.join(",")}}`,E=JJ(Z,Q);if(!E)console.error(`Client manifest has no "${_}" entry \u2014 dist/client is incomplete, so documents will render but never hydrate.`);let LJ=Z["app/client.tsx"]?.css??[],y=(await Promise.all(LJ.map((H)=>Bun.file(`${x}/client/${H}`).text()))).join(`
|
|
22
|
-
`),CJ=ZJ(Z,Q),g=new Map,IJ=(H)=>{let G=g.get(H);if(!G)G=Bun.file(`${x}/client/${H}`).text(),g.set(H,G);return G},FJ=async(H,G)=>{let U=new Set;for(let z of G?[G,...H]:H)for(let F of $J(Z,`app/views/${z}.tsx`))U.add(F);let O=await Promise.all([...U].map(async(z)=>({id:z,content:await IJ(z)})));return D(G?O:[{content:y},...O])},PJ=await r(C),f=new Map;for(let[H,G]of Object.entries((await l(C))?.files??{})){let U=VJ(C,H);if(U.startsWith(C+zJ))f.set(U,{immutable:!0,encodings:G})}async function _J(H){let{pathname:G}=new URL(H.url);if(N(G))return await T(H,G);let U=Q2(G);if(A(G)||G.startsWith("/.well-known")||U!==null&&PJ.has(U)){if(!U||!await H2(U))return HJ(G)??await T(H,G);try{return await s(H,U,f.get(U))}catch(z){return J.onException?.(z),new Response("Not found",{status:404})}}return await T(H,G)}async function T(H,G){let U=J.fetch.bind(J);try{let O=await U(H);if(O instanceof Response)return O;else{let z=[];return z.push({content:y}),await O({getStyles:async(R,u)=>{if(!R)return D([]);if(u?.static)return FJ(R,u.layout);for(let AJ of R){let NJ=Z[`app/views/${AJ}.tsx`];for(let h of NJ?.css??[]){let DJ=Bun.file(`${process.env.DIST_DIR}/client/${h}`);z.push({id:h,content:await DJ.text()})}}return D(z)},clientEntry:E,modulePreloadManifest:V,loaders:xJ,viewImportMap:W,viewModules:Y,ogMap:j,cssManifest:K,assetBase:Q,resolveIsland:CJ})}}catch(O){return S(O,G,J.onException)}}let BJ=(process.env.GEMI_COMPRESSION??"auto").toLowerCase()!=="off",MJ=jJ(process.env.GEMI_TRUST_PROXY),m=Bun.serve({maxRequestBodySize:10737418240,fetch:async(H,G)=>{GJ(H.headers,G.requestIP(H)?.address??null,MJ);let U=await $(H,(O)=>J.withGlobalMiddleware(O,_J,(z)=>S(z,new URL(O.url).pathname,J.onException)));return BJ?c(H,U):U},idleTimeout:OJ(),port:process.env.PORT||5173});return KJ({port:m.port,rootDir:q}),m}export{Z3 as httpProd};
|
|
23
|
-
|
|
24
|
-
//# debugId=436C7117592AA70664756E2164756E21
|
package/dist/chunk-7vb4eey2.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Xg as J,Zg as h}from"./chunk-tn2bryy2.js";import{_g as g}from"./chunk-cbqazg9k.js";import{ah as D,bh as L,ch as Q,eh as _,gh as T,ph as N}from"./chunk-1myhm0g3.js";import{Eh as C}from"./chunk-kejwjerj.js";import{_h as v,bi as p}from"./chunk-t4yh4nf9.js";import{ei as f}from"./chunk-zyt2w03d.js";class W{entries=new Map;counters=new Map;async acquire(z,G,H){let V=Date.now(),Y=this.entries.get(z);if(Y&&(Y.expiresAt>V||Y.fences>0))return null;let Z=(Y?.token??0)+1;return this.entries.set(z,{owner:G,token:Z,expiresAt:V+Math.max(0,H),fences:0}),Z}async extend(z,G,H,V){let Y=this.current(z,G,H);if(!Y)return!1;return Y.expiresAt=Date.now()+Math.max(0,V),!0}async release(z,G,H){let V=this.current(z,G,H);if(!V)return!1;return V.owner="",V.expiresAt=0,!0}async holder(z){let G=this.entries.get(z);if(!G||G.expiresAt<=Date.now())return null;return{owner:G.owner,token:G.token}}async held(z,G,H){return this.current(z,G,H)!==void 0}async advance(z,G){if((this.counters.get(z)??-1/0)>=G)return!1;return this.counters.set(z,G),!0}async fence(z,G,H,V){let Y=this.current(z,G,H);if(!Y)throw new J(z,H);Y.fences++;try{return await V()}finally{Y.fences--}}windows=new Map;async hit(z,G,H){let V=Date.now(),Y=this.windows.get(z);if(!Y||Y.endsAt<=V)Y={count:0,endsAt:V+Math.max(1,H)},this.windows.set(z,Y);if(Y.count>=G)return{allowed:!1,resetInMs:Y.endsAt-V};return Y.count++,{allowed:!0,resetInMs:Y.endsAt-V}}async refund(z){let G=this.windows.get(z);if(G&&G.endsAt>Date.now()&&G.count>0)G.count--}current(z,G,H){let V=this.entries.get(z);if(!V||V.owner!==G||V.expiresAt<=Date.now())return;if(H!==void 0&&V.token!==H)return;return V}}class F{table;sql;dialect;connection;busyTimeout;configured;constructor(z,G={}){let H=G.table??"gemi_locks";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(H))throw Error(`The lock table name "${H}" is not a plain identifier. Use letters, digits and underscores.`);this.table=H,this.sql=z.sql,this.dialect=z.dialect,this.connection=z.name,this.busyTimeout=G.busyTimeout??1000}async createTable(){await this.configure();for(let z of j(this.dialect,this.table))await this.sql.unsafe(z)}async acquire(z,G,H){await this.configure();let V=this.sql,Y=this.now(V);if(await this.seed(V,z),this.mysql){let $=await V`
|
|
3
|
-
UPDATE ${this.name(V)}
|
|
4
|
-
SET owner = ${G}, token = token + 1, expires_at = ${Y} + ${this.ms(V,H)},
|
|
5
|
-
updated_at = ${Y}
|
|
6
|
-
WHERE name = ${z} AND expires_at <= ${Y}
|
|
7
|
-
`;if(A($)===0)return null;let[B]=await V`
|
|
8
|
-
SELECT token FROM ${this.name(V)} WHERE name = ${z} AND owner = ${G}
|
|
9
|
-
`;return B?Number(B.token):null}let Z=await V`
|
|
10
|
-
UPDATE ${this.name(V)}
|
|
11
|
-
SET owner = ${G}, token = token + 1, expires_at = ${Y} + ${this.ms(V,H)},
|
|
12
|
-
updated_at = ${Y}
|
|
13
|
-
WHERE name = ${z} AND expires_at <= ${Y}
|
|
14
|
-
RETURNING token
|
|
15
|
-
`;return Z[0]?Number(Z[0].token):null}async extend(z,G,H,V){await this.configure();let Y=this.sql,Z=this.now(Y),$=await Y`
|
|
16
|
-
UPDATE ${this.name(Y)}
|
|
17
|
-
SET expires_at = ${Z} + ${this.ms(Y,V)}, updated_at = ${Z}
|
|
18
|
-
WHERE name = ${z} AND owner = ${G} AND token = ${H} AND expires_at > ${Z}
|
|
19
|
-
`;if(A($)>0)return!0;return this.mysql?this.held(z,G,H):!1}async release(z,G,H){await this.configure();let V=this.sql,Y=this.now(V),Z=H===void 0?V`1 = 1`:V`token = ${H}`,$=await V`
|
|
20
|
-
UPDATE ${this.name(V)}
|
|
21
|
-
SET owner = '', expires_at = 0, updated_at = ${Y}
|
|
22
|
-
WHERE name = ${z} AND owner = ${G} AND ${Z} AND expires_at > ${Y}
|
|
23
|
-
`;return A($)>0}async holder(z){await this.configure();let G=this.sql,[H]=await G`
|
|
24
|
-
SELECT owner, token FROM ${this.name(G)}
|
|
25
|
-
WHERE name = ${z} AND expires_at > ${this.now(G)}
|
|
26
|
-
`;return H?{owner:String(H.owner),token:Number(H.token)}:null}async held(z,G,H){await this.configure();let V=this.sql;return(await V`
|
|
27
|
-
SELECT 1 AS held FROM ${this.name(V)}
|
|
28
|
-
WHERE name = ${z} AND owner = ${G} AND token = ${H} AND expires_at > ${this.now(V)}
|
|
29
|
-
`).length>0}async advance(z,G){await this.configure();let H=this.sql;await this.seed(H,z);let V=await H`
|
|
30
|
-
UPDATE ${this.name(H)}
|
|
31
|
-
SET token = ${this.int(H,G)}, updated_at = ${this.now(H)}
|
|
32
|
-
WHERE name = ${z} AND token < ${this.int(H,G)}
|
|
33
|
-
`;return A(V)>0}async fence(z,G,H,V){await this.configure();let Y=async($)=>{let B=this.now($),X;if(this.dialect==="sqlite"){let K=await $`
|
|
34
|
-
UPDATE ${this.name($)} SET updated_at = ${B}
|
|
35
|
-
WHERE name = ${z} AND owner = ${G} AND token = ${H} AND expires_at > ${B}
|
|
36
|
-
`;X=A(K)>0}else X=(await $`
|
|
37
|
-
SELECT 1 AS held FROM ${this.name($)}
|
|
38
|
-
WHERE name = ${z} AND owner = ${G} AND token = ${H} AND expires_at > ${B}
|
|
39
|
-
FOR UPDATE
|
|
40
|
-
`).length>0;if(!X)throw new J(z,H);return V()},Z=this.connection;if(Z===void 0)return await this.sql.begin(($)=>Y($));return N(this.sql,($)=>Q(Z,()=>Y($)),{connection:Z})}async hit(z,G,H){await this.configure();let V=this.sql,Y=this.now(V);await this.seed(V,z);let Z=this.ms(V,Math.max(1,H)),$=await V`
|
|
41
|
-
UPDATE ${this.name(V)}
|
|
42
|
-
SET token = CASE WHEN expires_at <= ${Y} THEN 1 ELSE token + 1 END,
|
|
43
|
-
expires_at = CASE WHEN expires_at <= ${Y} THEN ${Y} + ${Z} ELSE expires_at END,
|
|
44
|
-
updated_at = ${Y}
|
|
45
|
-
WHERE name = ${z} AND (expires_at <= ${Y} OR token < ${this.int(V,G)})
|
|
46
|
-
`,B=A($)>0,[X]=await V`
|
|
47
|
-
SELECT expires_at - ${Y} AS reset FROM ${this.name(V)} WHERE name = ${z}
|
|
48
|
-
`;return{allowed:B,resetInMs:Math.max(0,Number(X?.reset??0))}}async refund(z){await this.configure();let G=this.sql,H=this.now(G);await G`
|
|
49
|
-
UPDATE ${this.name(G)} SET token = token - 1, updated_at = ${H}
|
|
50
|
-
WHERE name = ${z} AND token > 0 AND expires_at > ${H}
|
|
51
|
-
`}async prune(z){await this.configure();let G=this.sql,H=this.now(G),V=await G`
|
|
52
|
-
DELETE FROM ${this.name(G)}
|
|
53
|
-
WHERE expires_at <= ${H} AND updated_at <= ${H} - ${this.ms(G,z)}
|
|
54
|
-
`;return A(V)}async seed(z,G){let H=this.now(z);if(this.mysql){await z`
|
|
55
|
-
INSERT IGNORE INTO ${this.name(z)} (name, owner, token, expires_at, updated_at)
|
|
56
|
-
VALUES (${G}, '', 0, 0, ${H})
|
|
57
|
-
`;return}await z`
|
|
58
|
-
INSERT INTO ${this.name(z)} (name, owner, token, expires_at, updated_at)
|
|
59
|
-
VALUES (${G}, '', 0, 0, ${H})
|
|
60
|
-
ON CONFLICT (name) DO NOTHING
|
|
61
|
-
`}get mysql(){return this.dialect==="mysql"||this.dialect==="mariadb"}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}name(z){return z.unsafe(this.mysql?`\`${this.table}\``:`"${this.table}"`)}now(z){switch(this.dialect){case"postgres":return z`floor(extract(epoch from statement_timestamp()) * 1000)::bigint`;case"mysql":case"mariadb":return z`(TIMESTAMPDIFF(MICROSECOND, '1970-01-01 00:00:00', UTC_TIMESTAMP(6)) DIV 1000)`;case"sqlite":return z`CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER)`}}ms(z,G){return this.int(z,Math.max(0,Math.round(G)))}int(z,G){let H=Math.round(G);return this.mysql?z`CAST(${H} AS SIGNED)`:z`CAST(${H} AS BIGINT)`}}function A(z){let G=z;return Math.max(Number(G.count??0),Number(G.affectedRows??0))}function j(z,G){if(z==="mysql"||z==="mariadb")return[`CREATE TABLE IF NOT EXISTS \`${G}\` (
|
|
62
|
-
\`name\` VARCHAR(191) NOT NULL,
|
|
63
|
-
\`owner\` VARCHAR(191) NOT NULL,
|
|
64
|
-
\`token\` BIGINT NOT NULL DEFAULT 0,
|
|
65
|
-
\`expires_at\` BIGINT NOT NULL,
|
|
66
|
-
\`updated_at\` BIGINT NOT NULL,
|
|
67
|
-
|
|
68
|
-
PRIMARY KEY (\`name\`)
|
|
69
|
-
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci`];let H=z==="sqlite"?'"name" TEXT NOT NULL PRIMARY KEY,':'"name" TEXT NOT NULL,',V=z==="sqlite"?"":`,
|
|
70
|
-
|
|
71
|
-
CONSTRAINT "${G}_pkey" PRIMARY KEY ("name")`;return[`CREATE TABLE IF NOT EXISTS "${G}" (
|
|
72
|
-
${H}
|
|
73
|
-
"owner" TEXT NOT NULL,
|
|
74
|
-
"token" BIGINT NOT NULL DEFAULT 0,
|
|
75
|
-
"expires_at" BIGINT NOT NULL,
|
|
76
|
-
"updated_at" BIGINT NOT NULL${V}
|
|
77
|
-
)`]}class I{table;sql;dialect;connection;busyTimeout;configured;constructor(z,G={}){let H=G.table??"gemi_jobs";if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(H))throw Error(`The queue table name "${H}" is not a plain identifier. Use letters, digits and underscores.`);let V=G.busyTimeout??1000;if(!Number.isInteger(V)||V<0)throw Error(`The queue's busyTimeout must be a whole number of milliseconds, 0 or more; got ${V}.`);this.table=H,this.sql=z.sql,this.dialect=z.dialect,this.connection=z.name,this.busyTimeout=V}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 q(this.dialect,this.table))await this.sql.unsafe(z)}enqueue(z){let G=this.transaction(),H=this.insert(G??this.sql,z);if(G)T(H);return H}async insert(z,{name:G,args:H,delayMs:V=0,id:Y=Bun.randomUUIDv7()}){await this.configure();let Z=this.now(z);return await z`
|
|
78
|
-
INSERT INTO ${this.name(z)}
|
|
79
|
-
(id, name, payload, status, attempts, available_at, created_at, updated_at)
|
|
80
|
-
VALUES
|
|
81
|
-
(${Y}, ${G}, ${H}, 'pending', 0, ${Z} + ${this.ms(z,V)}, ${Z}, ${Z})
|
|
82
|
-
`,Y}lockStore(){return new F({sql:this.sql,dialect:this.dialect,name:this.connection},{busyTimeout:this.busyTimeout})}joinsTransaction(){return this.transaction()!==void 0}transaction(){if(this.dialect==="sqlite"||this.connection===void 0)return;let z=D();if(z===void 0||L()!==this.connection)return;return z}async claim(z,G){let H=Math.max(0,Math.floor(z));if(H===0)return[];return await this.configure(),(this.dialect==="mysql"||this.dialect==="mariadb"?await this.claimLocking(H,G):await this.claimUpdating(H,G)).map((Y)=>({order:Number(Y.available_at),job:{id:String(Y.id),name:String(Y.name),args:String(Y.payload),attempt:Number(Y.attempts),createdAt:Number(Y.created_at)}})).sort((Y,Z)=>Y.order-Z.order||(Y.job.id<Z.job.id?-1:1)).map(({job:Y})=>Y)}async complete(z){await this.configure();let G=this.sql;await G`
|
|
83
|
-
DELETE FROM ${this.name(G)}
|
|
84
|
-
WHERE id = ${z.id} AND status = 'claimed' AND attempts = ${z.attempt}
|
|
85
|
-
`}async fail(z,G){await this.configure();let H=this.sql,V=this.now(H);if(G.retryInMs===null){await H`
|
|
86
|
-
UPDATE ${this.name(H)}
|
|
87
|
-
SET status = 'dead', lease_expires_at = NULL, last_error = ${G.error},
|
|
88
|
-
updated_at = ${V}
|
|
89
|
-
WHERE id = ${z.id} AND status = 'claimed' AND attempts = ${z.attempt}
|
|
90
|
-
`;return}await H`
|
|
91
|
-
UPDATE ${this.name(H)}
|
|
92
|
-
SET status = 'pending', available_at = ${V} + ${this.ms(H,G.retryInMs)},
|
|
93
|
-
lease_expires_at = NULL, last_error = ${G.error}, updated_at = ${V}
|
|
94
|
-
WHERE id = ${z.id} AND status = 'claimed' AND attempts = ${z.attempt}
|
|
95
|
-
`}async release(z,G){let H=this.sql,V=this.now(H);await H`
|
|
96
|
-
UPDATE ${this.name(H)}
|
|
97
|
-
SET status = 'pending', attempts = attempts - 1,
|
|
98
|
-
available_at = ${V} + ${this.ms(H,G.retryInMs)},
|
|
99
|
-
lease_expires_at = NULL, updated_at = ${V}
|
|
100
|
-
WHERE id = ${z.id} AND status = 'claimed' AND attempts = ${z.attempt}
|
|
101
|
-
`}async heartbeat(z,G){await this.configure();let H=this.sql;await Promise.all(z.map((V)=>{let Y=this.now(H);return H`
|
|
102
|
-
UPDATE ${this.name(H)}
|
|
103
|
-
SET lease_expires_at = ${Y} + ${this.ms(H,G.visibilityTimeoutMs)},
|
|
104
|
-
updated_at = ${Y}
|
|
105
|
-
WHERE id = ${V.id} AND status = 'claimed' AND attempts = ${V.attempt}
|
|
106
|
-
`}))}async retryDead(z){await this.configure();let G=this.sql,H=this.now(G),V=await G`
|
|
107
|
-
UPDATE ${this.name(G)}
|
|
108
|
-
SET status = 'pending', attempts = 0, available_at = ${H}, lease_expires_at = NULL,
|
|
109
|
-
updated_at = ${H}
|
|
110
|
-
WHERE id = ${z} AND status = 'dead'
|
|
111
|
-
`;return S(V)>0}async prune(z){await this.configure();let G=this.sql,H=await G`
|
|
112
|
-
DELETE FROM ${this.name(G)}
|
|
113
|
-
WHERE status = 'dead' AND updated_at <= ${this.now(G)} - ${this.ms(G,z)}
|
|
114
|
-
`;return S(H)}async claimUpdating(z,G){let H=this.sql,V=this.now(H),Y=this.ms(H,G.visibilityTimeoutMs),Z=this.name(H);if(this.dialect==="postgres")return await H`
|
|
115
|
-
WITH next AS (
|
|
116
|
-
SELECT id FROM ${Z}
|
|
117
|
-
WHERE ${this.claimable(H,G)}
|
|
118
|
-
ORDER BY available_at, id
|
|
119
|
-
LIMIT ${z}
|
|
120
|
-
FOR UPDATE SKIP LOCKED
|
|
121
|
-
)
|
|
122
|
-
UPDATE ${Z} AS job
|
|
123
|
-
SET status = 'claimed', attempts = job.attempts + 1, claimed_at = ${V},
|
|
124
|
-
lease_expires_at = ${V} + ${Y}, updated_at = ${V}
|
|
125
|
-
FROM next
|
|
126
|
-
WHERE job.id = next.id
|
|
127
|
-
RETURNING job.id, job.name, job.payload, job.attempts, job.available_at, job.created_at
|
|
128
|
-
`;return await H`
|
|
129
|
-
UPDATE ${Z}
|
|
130
|
-
SET status = 'claimed', attempts = attempts + 1, claimed_at = ${V},
|
|
131
|
-
lease_expires_at = ${V} + ${Y}, updated_at = ${V}
|
|
132
|
-
WHERE id IN (
|
|
133
|
-
SELECT id FROM ${Z}
|
|
134
|
-
WHERE ${this.claimable(H,G)}
|
|
135
|
-
ORDER BY available_at, id
|
|
136
|
-
LIMIT ${z}
|
|
137
|
-
)
|
|
138
|
-
RETURNING id, name, payload, attempts, available_at, created_at
|
|
139
|
-
`}async claimLocking(z,G){let H=await this.sql.reserve(),[V]=await H`
|
|
140
|
-
SELECT @@transaction_isolation AS level
|
|
141
|
-
`;await H`SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED`;try{return await this.claimLockingOn(H,z,G)}finally{let Y=V?.level?.replaceAll("-"," ");if(Y&&/^[A-Z ]+$/.test(Y))await H.unsafe(`SET SESSION TRANSACTION ISOLATION LEVEL ${Y}`);H.release()}}async claimLockingOn(z,G,H){return await z.begin(async(V)=>{let Y=this.name(V),Z=V.unsafe("id, name, payload, attempts, available_at, created_at"),$=await V`
|
|
142
|
-
SELECT ${Z} FROM ${Y}
|
|
143
|
-
WHERE status = 'pending' AND available_at <= ${this.now(V)}
|
|
144
|
-
AND ${this.runnable(V,H,"available_at")}
|
|
145
|
-
ORDER BY available_at, id
|
|
146
|
-
LIMIT ${G}
|
|
147
|
-
FOR UPDATE SKIP LOCKED
|
|
148
|
-
`;if($.length<G){let B=await V`
|
|
149
|
-
SELECT ${Z} FROM ${Y}
|
|
150
|
-
WHERE status = 'claimed' AND lease_expires_at <= ${this.now(V)}
|
|
151
|
-
AND ${this.runnable(V,H,"lease_expires_at")}
|
|
152
|
-
ORDER BY lease_expires_at, id
|
|
153
|
-
LIMIT ${G-$.length}
|
|
154
|
-
FOR UPDATE SKIP LOCKED
|
|
155
|
-
`;$.push(...B)}for(let B of $){let X=this.now(V);await V`
|
|
156
|
-
UPDATE ${Y}
|
|
157
|
-
SET status = 'claimed', attempts = attempts + 1, claimed_at = ${X},
|
|
158
|
-
lease_expires_at = ${X} + ${this.ms(V,H.visibilityTimeoutMs)},
|
|
159
|
-
updated_at = ${X}
|
|
160
|
-
WHERE id = ${B.id}
|
|
161
|
-
`}return $.map((B)=>({...B,attempts:Number(B.attempts)+1}))})}claimable(z,G){let H=this.now(z);return z`(
|
|
162
|
-
(status = 'pending' AND available_at <= ${H}
|
|
163
|
-
AND ${this.runnable(z,G,"available_at")})
|
|
164
|
-
OR (status = 'claimed' AND lease_expires_at <= ${H}
|
|
165
|
-
AND ${this.runnable(z,G,"lease_expires_at")})
|
|
166
|
-
)`}runnable(z,G,H){let V=G.registered;if(!V)return z`1 = 1`;let Y=V.names.length?z`name IN (${V.names.map(($)=>z`${$}`).reduce(($,B)=>z`${$}, ${B}`)})`:z`1 = 0`;if(!Number.isFinite(V.graceMs))return Y;let Z=z.unsafe(H);return z`(${Y} OR ${Z} <= ${this.now(z)} - ${this.ms(z,V.graceMs)})`}name(z){let G=this.dialect==="mysql"||this.dialect==="mariadb";return z.unsafe(G?`\`${this.table}\``:`"${this.table}"`)}now(z){switch(this.dialect){case"postgres":return z`floor(extract(epoch from statement_timestamp()) * 1000)::bigint`;case"mysql":case"mariadb":return z`(TIMESTAMPDIFF(MICROSECOND, '1970-01-01 00:00:00', UTC_TIMESTAMP(6)) DIV 1000)`;case"sqlite":return z`CAST((julianday('now') - 2440587.5) * 86400000 AS INTEGER)`}}ms(z,G){let H=Math.max(0,Math.round(G));return this.dialect==="mysql"||this.dialect==="mariadb"?z`CAST(${H} AS SIGNED)`:z`CAST(${H} AS BIGINT)`}}function S(z){let G=z;return Math.max(Number(G.count??0),Number(G.affectedRows??0))}function q(z,G){if(z==="mysql"||z==="mariadb")return[`CREATE TABLE IF NOT EXISTS \`${G}\` (
|
|
167
|
-
\`id\` VARCHAR(191) NOT NULL,
|
|
168
|
-
\`name\` VARCHAR(191) NOT NULL,
|
|
169
|
-
\`payload\` LONGTEXT NOT NULL,
|
|
170
|
-
\`status\` VARCHAR(191) NOT NULL,
|
|
171
|
-
\`attempts\` INTEGER NOT NULL DEFAULT 0,
|
|
172
|
-
\`available_at\` BIGINT NOT NULL,
|
|
173
|
-
\`claimed_at\` BIGINT NULL,
|
|
174
|
-
\`lease_expires_at\` BIGINT NULL,
|
|
175
|
-
\`last_error\` LONGTEXT NULL,
|
|
176
|
-
\`created_at\` BIGINT NOT NULL,
|
|
177
|
-
\`updated_at\` BIGINT NOT NULL,
|
|
178
|
-
|
|
179
|
-
INDEX \`${G}_status_available_at_idx\`(\`status\`, \`available_at\`),
|
|
180
|
-
INDEX \`${G}_status_lease_expires_at_idx\`(\`status\`, \`lease_expires_at\`),
|
|
181
|
-
PRIMARY KEY (\`id\`)
|
|
182
|
-
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci`];let H=z==="sqlite"?'"id" TEXT NOT NULL PRIMARY KEY,':'"id" TEXT NOT NULL,',V=z==="sqlite"?"":`,
|
|
183
|
-
|
|
184
|
-
CONSTRAINT "${G}_pkey" PRIMARY KEY ("id")`;return[`CREATE TABLE IF NOT EXISTS "${G}" (
|
|
185
|
-
${H}
|
|
186
|
-
"name" TEXT NOT NULL,
|
|
187
|
-
"payload" TEXT NOT NULL,
|
|
188
|
-
"status" TEXT NOT NULL,
|
|
189
|
-
"attempts" INTEGER NOT NULL DEFAULT 0,
|
|
190
|
-
"available_at" BIGINT NOT NULL,
|
|
191
|
-
"claimed_at" BIGINT,
|
|
192
|
-
"lease_expires_at" BIGINT,
|
|
193
|
-
"last_error" TEXT,
|
|
194
|
-
"created_at" BIGINT NOT NULL,
|
|
195
|
-
"updated_at" BIGINT NOT NULL${V}
|
|
196
|
-
)`,`CREATE INDEX IF NOT EXISTS "${G}_status_available_at_idx" ON "${G}"("status", "available_at")`,`CREATE INDEX IF NOT EXISTS "${G}_status_lease_expires_at_idx" ON "${G}"("status", "lease_expires_at")`]}import{AsyncResource as u}from"async_hooks";import{isMainThread as w}from"worker_threads";function Zz(z){return z}function M(){return{jobs:[],jobsDir:"app/jobs",concurrency:1,driver:"memory",visibilityTimeout:300000,pollInterval:1000,unknownJobGrace:3600000,locks:"auto"}}class U{entries=new Map;listeners=new Set;timer;timerAt=1/0;seq=0;get waiting(){let z=0;for(let G of this.entries.values())if(!G.leased)z++;return z}get leased(){return this.entries.size-this.waiting}async enqueue({name:z,args:G,delayMs:H=0,id:V=crypto.randomUUID()}){let Y=Date.now();return this.entries.set(V,{job:{id:V,name:z,args:G,attempt:0,createdAt:Y},until:Y+Math.max(0,H),leased:!1,seq:this.seq++}),this.changed(),V}async claim(z,G){let H=Date.now(),V=[...this.entries.values()].filter((Y)=>Y.until<=H).sort((Y,Z)=>Y.until-Z.until||Y.seq-Z.seq).slice(0,Math.max(0,z));for(let Y of V)Y.job={...Y.job,attempt:Y.job.attempt+1},Y.leased=!0,Y.until=H+G.visibilityTimeoutMs;if(V.length>0)this.schedule();return V.map((Y)=>({...Y.job}))}async complete(z){if(!this.current(z))return;this.entries.delete(z.id),this.schedule()}async fail(z,G){let H=this.current(z);if(!H)return;if(G.retryInMs===null){this.entries.delete(z.id),this.schedule();return}H.leased=!1,H.until=Date.now()+Math.max(0,G.retryInMs),H.seq=this.seq++,this.changed()}async release(z,G){let H=this.current(z);if(!H)return;H.job={...H.job,attempt:H.job.attempt-1},H.leased=!1,H.until=Date.now()+Math.max(0,G.retryInMs),H.seq=this.seq++,this.changed()}async heartbeat(z,G){let H=Date.now()+G.visibilityTimeoutMs;for(let V of z){let Y=this.current(V);if(Y)Y.until=H}this.schedule()}subscribe(z){return this.listeners.add(z),()=>void this.listeners.delete(z)}current(z){let G=this.entries.get(z.id);if(!G||!G.leased||G.job.attempt!==z.attempt)return;return G}changed(){this.schedule();let z=Date.now();for(let G of this.entries.values())if(G.until<=z){this.wake();return}}wake(){for(let z of[...this.listeners])z()}schedule(){let z=Date.now(),G=1/0;for(let H of this.entries.values())if(H.until>z&&H.until<G)G=H.until;if(G===this.timerAt)return;if(clearTimeout(this.timer),this.timer=void 0,this.timerAt=G,G===1/0)return;this.timer=setTimeout(()=>{this.timer=void 0,this.timerAt=1/0,this.changed()},G-z),this.timer.unref?.()}}function b(){let z=process.env.APP_DIR,G=process.env.ROOT_DIR,H=Bun.env.NODE_ENV==="production"?`${G}/dist/server/bootstrap.mjs`:`${z}/bootstrap.ts`,V=new File([`
|
|
197
|
-
import { app } from "${H}"
|
|
198
|
-
self.onmessage = async (event) => {
|
|
199
|
-
const clone = app.clone()
|
|
200
|
-
let result = null;
|
|
201
|
-
let error = null;
|
|
202
|
-
try {
|
|
203
|
-
result = await clone.dispatchJob(event.data.jobName, event.data.args)
|
|
204
|
-
} catch (err) {
|
|
205
|
-
error = err
|
|
206
|
-
}
|
|
207
|
-
clone.destroy()
|
|
208
|
-
if(error) {
|
|
209
|
-
self.postMessage({error});
|
|
210
|
-
} else {
|
|
211
|
-
self.postMessage({result});
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
`],"worker.ts"),Y=URL.createObjectURL(V);return new Worker(Y)}async function d(z,G){let H=b();return H.postMessage({jobName:z,args:G}),await new Promise((V,Y)=>{H.onmessage=(Z)=>{let $=Z.data;if("error"in $)Y($.error);else V($.result)}})}var m=new u("gemi.queue"),c=60000;class E{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;lockManager;constructor(z={},G={}){this.config=g(M(),z),this.application=G.application,this.driver=t(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,H={}){let V=this.uniqueKey(z,G);if(V)return this.pushUnique(z,G,V,H);let Y=this.driver.joinsTransaction?.()===!0;if(!Y){let Z=Bun.randomUUIDv7();if(_(()=>this.record(z,G,{id:Z,reportFailure:!0,committed:!0}).then(()=>{},()=>{})))return Promise.resolve(Z)}return this.record(z,G,{reportFailure:H.reportFailure,joins:Y})}get locks(){return this.lockManager??=new h(this.resolveLockStore()),this.lockManager}resolveLockStore(){let z=this.config.locks;if(z==="auto"){let G=this.driver.lockStore?.();if(G)return G;if(this.durable)console.warn('[gemi] The queue driver keeps no locks, so unique jobs, withoutOverlapping and onOneServer only hold within this process. Set the queue slice\'s `locks` to "database" or a LockStore.');return new W}if(z==="memory")return new W;if(z==="database"||typeof z==="function"){if(!this.application&&(z==="database"||z.length>0))throw Error("The queue's locks need the application they belong to, and this QueueManager was built without one. Pass { application }.");if(z==="database")return new F(this.application.make(C));return z(this.application)}if(typeof z==="string")throw Error(`Unknown queue locks "${z}". The queue slice's locks is "auto", "memory", "database", a LockStore, or a function returning one.`);return z}uniqueKey(z,G){if(z.prototype.uniqueId===R.prototype.uniqueId)return;let H=new z,V=H.uniqueId(...JSON.parse(G));if(V===void 0||V===null||V==="")return;return{key:x(z.name,V),ttl:Math.max(1,H.uniqueFor)}}pushUnique(z,G,H,V){let Y=Bun.randomUUIDv7();if(_(()=>this.recordUnique(z,G,H,Y,{report:!0,committed:!0}).then(()=>{},()=>{})))return Promise.resolve(Y);return this.recordUnique(z,G,H,Y,{report:V.reportFailure!==!1,committed:!1})}recordUnique(z,G,H,V,Y){let Z=this.locks.store,$=(async()=>{for(let B=0;B<5;B++){if(await Z.acquire(H.key,V,H.ttl)!==null)try{return await this.record(z,G,{id:V,reportFailure:!1})}catch(K){throw await Z.release(H.key,V).catch(()=>{}),K}let X=await Z.holder(H.key);if(X)return X.owner}throw Error(`The unique key "${H.key}" kept changing hands, so ${z.name} was not queued.`)})();return $.catch((B)=>{if(!Y.report)return;console.error(`[gemi] The queue could not record the unique job ${z.name}`+(Y.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)}),$}async releaseUnique(z,G,H){if(z.uniqueId===R.prototype.uniqueId)return;try{let V=z.uniqueId(...G);if(V===void 0||V===null||V==="")return;await this.locks.store.release(x(H.name,V),H.id)}catch(V){console.error(`[gemi] Could not free the unique key of ${H.name} (${H.id}); it frees itself after uniqueFor.`,V)}}record(z,G,H){let V=this.driver.enqueue({name:z.name,args:G,...H.id===void 0?{}:{id:H.id}});this.startIfIdle();let Y=()=>!this.driver.subscribe&&this.state==="running"&&this.wake(),Z=H.joins===!0&&_(Y);return V.then(()=>Z||Y(),($)=>{if(H.reportFailure===!1)return;console.error(`[gemi] The queue driver could not record ${z.name}`+(H.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."),$)}),V}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()&&!l())globalThis.__gemiDevQueue=this;if(this.unsubscribe=this.driver.subscribe?.(()=>this.wake()),this.looping)return this.wake();m.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,H=new Promise((Y)=>{if(z!==1/0)G=setTimeout(Y,z)}),V=(async()=>{await this.claiming?.catch(()=>{}),await Promise.allSettled([...this.inFlight.values()].map((Y)=>Y.done))})();return await Promise.race([V,H]),clearTimeout(G),{unfinished:[...this.inFlight.values()].map((Y)=>({...Y.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&&f()?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 H=[];try{H=await G,this.claimFailures=0}catch(V){this.claimFailures++,console.error(`The queue could not claim jobs from its driver; it will try again in ${this.retryDelay()}ms.`,V)}finally{this.claiming=void 0}for(let V of H)this.execute(V);if(H.length===z)continue;if(this.woken&&this.inFlight.size<this.config.concurrency)continue}await this.sleep()}}sleep(){return new Promise((z)=>{let G,H=this.claimFailures>0?this.retryDelay():this.driver.subscribe?void 0:this.config.pollInterval;if(H!==void 0)G=setTimeout(()=>this.wake(),H),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,c)}wake(){this.woken=!0;let z=this.resume;this.resume=void 0,z?.()}get durable(){return!(this.driver instanceof U)}mayClaimHere(){return!this.application||s()}lease(){return{visibilityTimeoutMs:this.config.visibilityTimeout}}execute(z){let G=`${z.id}:${z.attempt}`,H=()=>this.run(z),V=(this.application?v.run(this.application,H):H()).catch((Y)=>{console.error(`The queue could not record the outcome of ${z.name}.`,Y)}).finally(()=>{this.inFlight.delete(G),this.wake()});this.inFlight.set(G,{job:z,done:V}),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((H)=>H.job);z.heartbeat(G,this.lease()).catch((H)=>{console.error("The queue could not extend its job leases.",H)})},Math.max(1,Math.floor(this.config.visibilityTimeout/3))),this.heartbeatTimer.unref?.()}async run(z){let G=this.jobs[z.name];if(!G){let K=Date.now()-z.createdAt;if(this.durable&&K<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 H;try{H=new G}catch(K){console.error(`Dropped a queued ${z.name}: it could not be constructed.`,K),await this.driver.fail(z,{error:`The job could not be constructed: ${String(K)}`,retryInMs:null});return}let V;try{V=JSON.parse(z.args)}catch(K){console.error(`Dropped a queued ${z.name}: its arguments are not JSON.`,K),await this.driver.fail(z,{error:`The arguments are not JSON: ${String(K)}`,retryInMs:null});return}if(z.attempt>Math.max(1,H.maxAttempts)){let K=Error(`${z.name} was claimed for attempt ${z.attempt} of ${H.maxAttempts}: an earlier attempt never finished, most likely because the process running it exited. Dead-lettered without running it again.`);P(`${z.name}.onDeadletter`,()=>H.onDeadletter(K,...V)),await this.driver.fail(z,{error:K.message,retryInMs:null}),await this.releaseUnique(H,V,z);return}let Y=await this.admit(H,V,z);if(!Y)return;let Z,$;try{$=await(H.worker?d(z.name,z.args):H.run(...V))}catch(K){Z=K}finally{await Y.done()}let B=H.$outcome;if(Z===void 0&&B?.kind==="release"){await this.driver.release(z,{retryInMs:Math.max(0,B.delayMs)});return}if(Z===void 0&&B?.kind==="fail")Z=B.error;let X=B?.kind==="fail"?B.retry:!0;if(Z===void 0)try{H.onSuccess($,...V)}catch(K){Z=K}if(Z!==void 0){let K=String(Z?.stack??Z);if(P(`${z.name}.onFail`,()=>H.onFail(Z,...V)),!X||z.attempt>=H.maxAttempts)P(`${z.name}.onDeadletter`,()=>H.onDeadletter(Z,...V)),await this.driver.fail(z,{error:K,retryInMs:null}),await this.releaseUnique(H,V,z);else await this.driver.fail(z,{error:K,retryInMs:r(H.backoff,z.attempt)});return}await this.driver.complete(z),await this.releaseUnique(H,V,z)}async admit(z,G,H){let V=z.concurrency(...G),Y=[z.throttle(...G)??[]].flat();if(!V&&Y.length===0)return{done:async()=>{}};let Z=this.locks,$;if(V&&V.limit>0){let X=this.config.visibilityTimeout;for(let K=0;K<V.limit&&!$;K++)$=await Z.acquire(`gemi:concurrency:${V.key}:${K}`,{ttl:X,renew:!0})??void 0;if(!$){await this.driver.release(H,{retryInMs:Math.round(this.config.pollInterval*(1+Math.random()))});return}}let B=[];for(let X of Y){let K=`gemi:throttle:${X.key}`,O=await Z.store.hit(K,X.limit,X.window);if(!O.allowed){await Promise.all(B.map((k)=>Z.store.refund(k))),await $?.release(),await this.driver.release(H,{retryInMs:Math.max(1,O.resetInMs)});return}B.push(K)}return{done:async()=>{await $?.release().catch((X)=>{console.error(`[gemi] Could not free a concurrency slot of ${H.name}.`,X)})}}}}function x(z,G){return`gemi:job:${z}:${String(G)}`}function P(z,G){try{G()}catch(H){console.error(`${z} threw; the job's claim was ended anyway.`,H)}}function l(){return Bun.env.NODE_ENV==="production"}function s(){if(!w)return!1;if(a())return!0;return process.env.ROOT_DIR!==void 0&&!i()}function i(z=process.env){return(z.GEMI_QUEUE_CLAIM??"").trim().toLowerCase()==="off"}var y=Symbol.for("gemi.queue.worker");function Qz(z=!0){globalThis[y]=z}function a(){return globalThis[y]===!0}function r(z,G){let H=Array.isArray(z)?z[Math.min(G,z.length)-1]:z;return Math.max(0,H??0)}function t(z,G){if(z==="memory")return new U;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 I(G.make(C));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}class R{static name="unset";worker=!1;maxAttempts=3;backoff=0;uniqueId(...z){return}uniqueFor=3600000;throttle(...z){return}concurrency(...z){return}release(z=0){this.$outcome={kind:"release",delayMs:z}}fail(z,G={}){this.$outcome={kind:"fail",error:z instanceof Error?z:Error(String(z)),retry:G.retry??!0}}$outcome;run(...z){}onFail(z,...G){}onSuccess(z,...G){}onDeadletter(z,...G){}static dispatch(...z){if(this.name==="unset")throw Error("Cannot dispatch a job with no name");return p(E).push(this,JSON.stringify(z))}}
|
|
215
|
-
export{W as xc,F as yc,I as zc,R as Ac,Zz as Bc,M as Cc,U as Dc,E as Ec,s as Fc,i as Gc,Qz as Hc,a as Ic};
|
|
216
|
-
|
|
217
|
-
//# debugId=22064B8F734D075464756E2164756E21
|