@geekmidas/constructs 10.0.0-alpha.12 → 10.0.0-alpha.120
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/README.md +222 -158
- package/dist/Construct-B7AXn0xH.d.mts +230 -0
- package/dist/Construct-B7AXn0xH.d.mts.map +1 -0
- package/dist/Construct-CFW0zjdD.d.cts +230 -0
- package/dist/Construct-CFW0zjdD.d.cts.map +1 -0
- package/dist/{Construct-BD5neF7w.mjs → Construct-CKUA-CTA.mjs} +35 -35
- package/dist/Construct-CKUA-CTA.mjs.map +1 -0
- package/dist/{Construct-CyS3RpTL.cjs → Construct-DEOVauyA.cjs} +55 -49
- package/dist/Construct-DEOVauyA.cjs.map +1 -0
- package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-bdGRSROY.d.cts} +15 -9
- package/dist/Cron-bdGRSROY.d.cts.map +1 -0
- package/dist/{Cron-dh4rUgib.d.mts → Cron-i4Uetezh.d.mts} +15 -9
- package/dist/Cron-i4Uetezh.d.mts.map +1 -0
- package/dist/CronBuilder-9H4BnD6W.d.mts +47 -0
- package/dist/CronBuilder-9H4BnD6W.d.mts.map +1 -0
- package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BXTG10u5.cjs} +47 -31
- package/dist/CronBuilder-BXTG10u5.cjs.map +1 -0
- package/dist/CronBuilder-B_24LZpn.d.cts +47 -0
- package/dist/CronBuilder-B_24LZpn.d.cts.map +1 -0
- package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-D3sF9tS_.mjs} +37 -21
- package/dist/CronBuilder-D3sF9tS_.mjs.map +1 -0
- package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-CeFkSwh5.d.mts} +129 -99
- package/dist/Endpoint-CeFkSwh5.d.mts.map +1 -0
- package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-DgrpG15P.d.cts} +127 -97
- package/dist/Endpoint-DgrpG15P.d.cts.map +1 -0
- package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-gPXhHKhJ.mjs} +208 -100
- package/dist/Endpoint-gPXhHKhJ.mjs.map +1 -0
- package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-yhR2T2Wt.cjs} +248 -122
- package/dist/Endpoint-yhR2T2Wt.cjs.map +1 -0
- package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-CSrAyazj.cjs} +361 -112
- package/dist/EndpointFactory-CSrAyazj.cjs.map +1 -0
- package/dist/{index-lAO9egTb.d.mts → EndpointFactory-Cc863XJS.d.cts} +190 -136
- package/dist/EndpointFactory-Cc863XJS.d.cts.map +1 -0
- package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-Dbw9ugkX.d.mts} +189 -135
- package/dist/EndpointFactory-Dbw9ugkX.d.mts.map +1 -0
- package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-c2ZugGig.mjs} +283 -76
- package/dist/EndpointFactory-c2ZugGig.mjs.map +1 -0
- package/dist/Function-B0uZhZnU.d.cts +76 -0
- package/dist/Function-B0uZhZnU.d.cts.map +1 -0
- package/dist/Function-B_9R7Zy1.d.mts +76 -0
- package/dist/Function-B_9R7Zy1.d.mts.map +1 -0
- package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-CN1jjUBJ.cjs} +115 -71
- package/dist/HonoEndpointAdaptor-CN1jjUBJ.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-euH1oSdY.mjs} +105 -64
- package/dist/HonoEndpointAdaptor-euH1oSdY.mjs.map +1 -0
- package/dist/{Queue-D7ZuwBhy.d.cts → Queue-B-dDXyjF.d.mts} +48 -48
- package/dist/Queue-B-dDXyjF.d.mts.map +1 -0
- package/dist/Queue-BhuofM3k.cjs +109 -0
- package/dist/Queue-BhuofM3k.cjs.map +1 -0
- package/dist/{Queue-gVGfi2Yk.d.mts → Queue-JbIjVtTf.d.cts} +49 -49
- package/dist/Queue-JbIjVtTf.d.cts.map +1 -0
- package/dist/Queue-cmhqEBOB.mjs +104 -0
- package/dist/Queue-cmhqEBOB.mjs.map +1 -0
- package/dist/QueueBuilder-48W-q8In.d.mts +75 -0
- package/dist/QueueBuilder-48W-q8In.d.mts.map +1 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs +118 -0
- package/dist/QueueBuilder-DXu1qxT1.mjs.map +1 -0
- package/dist/QueueBuilder-DdU2klPu.cjs +135 -0
- package/dist/QueueBuilder-DdU2klPu.cjs.map +1 -0
- package/dist/QueueBuilder-MfpkJ3R9.d.cts +75 -0
- package/dist/QueueBuilder-MfpkJ3R9.d.cts.map +1 -0
- package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CEt7kHkc.d.cts} +29 -20
- package/dist/Subscriber-CEt7kHkc.d.cts.map +1 -0
- package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-dsxc5LKa.d.mts} +29 -20
- package/dist/Subscriber-dsxc5LKa.d.mts.map +1 -0
- package/dist/SubscriberBuilder-BRa_nrmH.d.cts +67 -0
- package/dist/SubscriberBuilder-BRa_nrmH.d.cts.map +1 -0
- package/dist/SubscriberBuilder-D9bkrYzH.d.mts +67 -0
- package/dist/SubscriberBuilder-D9bkrYzH.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DRXfxWn_.mjs} +50 -24
- package/dist/SubscriberBuilder-DRXfxWn_.mjs.map +1 -0
- package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-M2EAgQhC.cjs} +61 -36
- package/dist/SubscriberBuilder-M2EAgQhC.cjs.map +1 -0
- package/dist/Topic-D2R0r24C.mjs +99 -0
- package/dist/Topic-D2R0r24C.mjs.map +1 -0
- package/dist/Topic-DwS3QO0m.cjs +104 -0
- package/dist/Topic-DwS3QO0m.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +200 -246
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +58 -62
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +59 -63
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +171 -219
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +3 -10
- package/dist/adaptors/hono.d.cts +7 -16
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +9 -18
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +2 -10
- package/dist/adaptors/testing.cjs +765 -99
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +351 -54
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +351 -54
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +726 -78
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth-BMCJN30Y.d.cts +268 -0
- package/dist/auth-BMCJN30Y.d.cts.map +1 -0
- package/dist/auth-D_0788uW.d.mts +268 -0
- package/dist/auth-D_0788uW.d.mts.map +1 -0
- package/dist/auth.cjs +301 -33
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -108
- package/dist/auth.d.mts +2 -108
- package/dist/auth.mjs +289 -27
- package/dist/auth.mjs.map +1 -1
- package/dist/{cache-BrRz3fEB.d.mts → cache-5QZzh5Er.d.mts} +3 -6
- package/dist/cache-5QZzh5Er.d.mts.map +1 -0
- package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
- package/dist/cache-DnGDGly3.d.cts.map +1 -0
- package/dist/cache.cjs +68 -2
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.cts +1 -2
- package/dist/cache.d.mts +1 -2
- package/dist/cache.mjs +67 -2
- package/dist/cache.mjs.map +1 -0
- package/dist/cipher-C1lEFX63.mjs +225 -0
- package/dist/cipher-C1lEFX63.mjs.map +1 -0
- package/dist/cipher-CVxfwLjk.cjs +332 -0
- package/dist/cipher-CVxfwLjk.cjs.map +1 -0
- package/dist/cipher-DSDxPRIp.d.cts +106 -0
- package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
- package/dist/cipher-DSDxPRIp.d.mts +106 -0
- package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
- package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
- package/dist/clone-EKNovYHu.mjs.map +1 -0
- package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
- package/dist/clone-UGJpvQnL.cjs.map +1 -0
- package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
- package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
- package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-ZvYQbivO.d.mts} +42 -11
- package/dist/construct-interface-ZvYQbivO.d.mts.map +1 -0
- package/dist/construct-interface.cjs +113 -7
- package/dist/construct-interface.cjs.map +1 -0
- package/dist/construct-interface.d.cts +2 -2
- package/dist/construct-interface.d.mts +2 -2
- package/dist/construct-interface.mjs +106 -2
- package/dist/construct-interface.mjs.map +1 -0
- package/dist/credential-DYymbp_7.cjs +257 -0
- package/dist/credential-DYymbp_7.cjs.map +1 -0
- package/dist/credential-DfSAOOdY.mjs +222 -0
- package/dist/credential-DfSAOOdY.mjs.map +1 -0
- package/dist/credential.cjs +8 -96
- package/dist/credential.d.cts +2 -61
- package/dist/credential.d.mts +2 -61
- package/dist/credential.mjs +2 -94
- package/dist/crons/index.cjs +129 -7
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +45 -11
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +45 -11
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +127 -8
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +4 -181
- package/dist/database/kysely.d.cts +2 -152
- package/dist/database/kysely.d.mts +2 -152
- package/dist/database/kysely.mjs +2 -180
- package/dist/email.cjs +25 -12
- package/dist/email.cjs.map +1 -1
- package/dist/email.d.cts +3 -7
- package/dist/email.d.cts.map +1 -1
- package/dist/email.d.mts +4 -8
- package/dist/email.d.mts.map +1 -1
- package/dist/email.mjs +16 -3
- package/dist/email.mjs.map +1 -1
- package/dist/encryption/kms.cjs +95 -0
- package/dist/encryption/kms.cjs.map +1 -0
- package/dist/encryption/kms.d.cts +7 -0
- package/dist/encryption/kms.d.cts.map +1 -0
- package/dist/encryption/kms.d.mts +7 -0
- package/dist/encryption/kms.d.mts.map +1 -0
- package/dist/encryption/kms.mjs +93 -0
- package/dist/encryption/kms.mjs.map +1 -0
- package/dist/encryption.cjs +116 -0
- package/dist/encryption.cjs.map +1 -0
- package/dist/encryption.d.cts +37 -0
- package/dist/encryption.d.cts.map +1 -0
- package/dist/encryption.d.mts +37 -0
- package/dist/encryption.d.mts.map +1 -0
- package/dist/encryption.mjs +101 -0
- package/dist/encryption.mjs.map +1 -0
- package/dist/endpoints/index.cjs +27 -16
- package/dist/endpoints/index.d.cts +105 -7
- package/dist/endpoints/index.d.cts.map +1 -0
- package/dist/endpoints/index.d.mts +105 -7
- package/dist/endpoints/index.d.mts.map +1 -0
- package/dist/endpoints/index.mjs +6 -10
- package/dist/expire-C586zznE.d.cts +38 -0
- package/dist/expire-C586zznE.d.cts.map +1 -0
- package/dist/expire-C586zznE.d.mts +38 -0
- package/dist/expire-C586zznE.d.mts.map +1 -0
- package/dist/expire-CieftS01.cjs +67 -0
- package/dist/expire-CieftS01.cjs.map +1 -0
- package/dist/expire-CpzUAfr9.mjs +50 -0
- package/dist/expire-CpzUAfr9.mjs.map +1 -0
- package/dist/external-api.cjs +106 -0
- package/dist/external-api.cjs.map +1 -0
- package/dist/external-api.d.cts +2 -0
- package/dist/external-api.d.mts +2 -0
- package/dist/external-api.mjs +103 -0
- package/dist/external-api.mjs.map +1 -0
- package/dist/fake-B7rvi4Qp.d.cts +201 -0
- package/dist/fake-B7rvi4Qp.d.cts.map +1 -0
- package/dist/fake-JXbkdao8.d.mts +201 -0
- package/dist/fake-JXbkdao8.d.mts.map +1 -0
- package/dist/file-server.cjs +66 -11
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +25 -10
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +25 -10
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +58 -4
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +3 -6
- package/dist/functions/index.d.cts +3 -4
- package/dist/functions/index.d.mts +3 -4
- package/dist/functions/index.mjs +2 -6
- package/dist/{functions-14lpEFL4.mjs → functions-CTI-hDem.mjs} +376 -238
- package/dist/{functions-14lpEFL4.mjs.map → functions-CTI-hDem.mjs.map} +1 -1
- package/dist/{functions-i_la-N5r.cjs → functions-D7O5SGVc.cjs} +414 -264
- package/dist/functions-D7O5SGVc.cjs.map +1 -0
- package/dist/index-Cd2w-DRL.d.cts +115 -0
- package/dist/index-Cd2w-DRL.d.cts.map +1 -0
- package/dist/index-DdRjYhiJ.d.cts +119 -0
- package/dist/index-DdRjYhiJ.d.cts.map +1 -0
- package/dist/index-DdRjYhiJ.d.mts +119 -0
- package/dist/index-DdRjYhiJ.d.mts.map +1 -0
- package/dist/index-aBIcAiH5.d.mts +115 -0
- package/dist/index-aBIcAiH5.d.mts.map +1 -0
- package/dist/index.cjs +6 -3
- package/dist/index.d.cts +27 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +27 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/kysely-BHYV-WC-.d.cts +216 -0
- package/dist/kysely-BHYV-WC-.d.cts.map +1 -0
- package/dist/kysely-CAW3QSqp.d.mts +216 -0
- package/dist/kysely-CAW3QSqp.d.mts.map +1 -0
- package/dist/kysely-Cs4uPO8k.mjs +371 -0
- package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
- package/dist/kysely-CukArHJ0.cjs +384 -0
- package/dist/kysely-CukArHJ0.cjs.map +1 -0
- package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
- package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
- package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
- package/dist/mobile-app.cjs +74 -0
- package/dist/mobile-app.cjs.map +1 -0
- package/dist/mobile-app.d.cts +73 -0
- package/dist/mobile-app.d.cts.map +1 -0
- package/dist/mobile-app.d.mts +73 -0
- package/dist/mobile-app.d.mts.map +1 -0
- package/dist/mobile-app.mjs +73 -0
- package/dist/mobile-app.mjs.map +1 -0
- package/dist/object-storage.cjs +26 -11
- package/dist/object-storage.cjs.map +1 -1
- package/dist/object-storage.d.cts +12 -7
- package/dist/object-storage.d.cts.map +1 -1
- package/dist/object-storage.d.mts +12 -7
- package/dist/object-storage.d.mts.map +1 -1
- package/dist/object-storage.mjs +18 -5
- package/dist/object-storage.mjs.map +1 -1
- package/dist/queue/index.cjs +6 -189
- package/dist/queue/index.d.cts +3 -60
- package/dist/queue/index.d.mts +3 -60
- package/dist/queue/index.mjs +3 -186
- package/dist/random-password.cjs +86 -0
- package/dist/random-password.cjs.map +1 -0
- package/dist/random-password.d.cts +30 -0
- package/dist/random-password.d.cts.map +1 -0
- package/dist/random-password.d.mts +30 -0
- package/dist/random-password.d.mts.map +1 -0
- package/dist/random-password.mjs +84 -0
- package/dist/random-password.mjs.map +1 -0
- package/dist/{lazyAccessors-BoJN3SMd.mjs → readRequestBody-BTIl3k-D.mjs} +117 -60
- package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
- package/dist/readRequestBody-Dej_L3c4.cjs +342 -0
- package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
- package/dist/requestLogger-BZcXwdBs.cjs +207 -0
- package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
- package/dist/requestLogger-pA4gi3E1.mjs +178 -0
- package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
- package/dist/rest-api.cjs +90 -59
- package/dist/rest-api.cjs.map +1 -1
- package/dist/rest-api.d.cts +70 -42
- package/dist/rest-api.d.cts.map +1 -1
- package/dist/rest-api.d.mts +70 -42
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +82 -51
- package/dist/rest-api.mjs.map +1 -1
- package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
- package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
- package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
- package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
- package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
- package/dist/shutdown-BMJmAhSt.cjs +38 -0
- package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
- package/dist/shutdown-C7xa8x9S.mjs +27 -0
- package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
- package/dist/site.cjs +33 -7
- package/dist/site.cjs.map +1 -1
- package/dist/site.d.cts +17 -7
- package/dist/site.d.cts.map +1 -1
- package/dist/site.d.mts +17 -7
- package/dist/site.d.mts.map +1 -1
- package/dist/site.mjs +29 -3
- package/dist/site.mjs.map +1 -1
- package/dist/stages-BSCF19o2.d.cts +56 -0
- package/dist/stages-BSCF19o2.d.cts.map +1 -0
- package/dist/stages-BSCF19o2.d.mts +56 -0
- package/dist/stages-BSCF19o2.d.mts.map +1 -0
- package/dist/subscribers/index.cjs +118 -6
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +51 -6
- package/dist/subscribers/index.d.cts.map +1 -0
- package/dist/subscribers/index.d.mts +51 -6
- package/dist/subscribers/index.d.mts.map +1 -0
- package/dist/subscribers/index.mjs +115 -5
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/surfaceEnv-CNimK76p.cjs +56 -0
- package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
- package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
- package/dist/telemetry-B48RLjyk.d.cts +40 -0
- package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
- package/dist/telemetry-BEoBn6GO.d.mts +40 -0
- package/dist/telemetry-BEoBn6GO.d.mts.map +1 -0
- package/dist/telemetry.cjs +56 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +55 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/topic/index.cjs +3 -137
- package/dist/topic/index.d.cts +2 -4
- package/dist/topic/index.d.mts +2 -4
- package/dist/topic/index.mjs +2 -134
- package/dist/tracing-Bbj1uoFJ.mjs +127 -0
- package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
- package/dist/tracing-C0ooU0V2.cjs +150 -0
- package/dist/tracing-C0ooU0V2.cjs.map +1 -0
- package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
- package/dist/types-DMuSQeLL.d.cts.map +1 -0
- package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
- package/dist/types-DMuSQeLL.d.mts.map +1 -0
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -0
- package/dist/worker.cjs +59 -34
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +70 -45
- package/dist/worker.d.cts.map +1 -1
- package/dist/worker.d.mts +71 -45
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +54 -29
- package/dist/worker.mjs.map +1 -1
- package/package.json +115 -41
- package/dist/Construct-BD5neF7w.mjs.map +0 -1
- package/dist/Construct-C0ijr2qp.d.cts +0 -117
- package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
- package/dist/Construct-Ct8nalEi.d.mts +0 -117
- package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
- package/dist/Construct-CyS3RpTL.cjs.map +0 -1
- package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
- package/dist/Cron-dh4rUgib.d.mts.map +0 -1
- package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
- package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
- package/dist/CronBuilder-CGgY2080.d.mts +0 -44
- package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
- package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
- package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
- package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
- package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
- package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
- package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
- package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
- package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
- package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
- package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
- package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
- package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
- package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
- package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
- package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
- package/dist/Topic-19QeHBIR.d.cts +0 -91
- package/dist/Topic-19QeHBIR.d.cts.map +0 -1
- package/dist/Topic-DuFeqkBh.d.mts +0 -91
- package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
- package/dist/auth.d.cts.map +0 -1
- package/dist/auth.d.mts.map +0 -1
- package/dist/cache-0ANvRQnD.mjs +0 -51
- package/dist/cache-0ANvRQnD.mjs.map +0 -1
- package/dist/cache-3WSvAulx.cjs +0 -57
- package/dist/cache-3WSvAulx.cjs.map +0 -1
- package/dist/cache-BrRz3fEB.d.mts.map +0 -1
- package/dist/cache-BtZY_tHe.d.cts.map +0 -1
- package/dist/clone-DblgEZZa.mjs.map +0 -1
- package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
- package/dist/construct-interface-BfjcOD_E.cjs +0 -117
- package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
- package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
- package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
- package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
- package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
- package/dist/credential.cjs.map +0 -1
- package/dist/credential.d.cts.map +0 -1
- package/dist/credential.d.mts.map +0 -1
- package/dist/credential.mjs.map +0 -1
- package/dist/database/kysely.cjs.map +0 -1
- package/dist/database/kysely.d.cts.map +0 -1
- package/dist/database/kysely.d.mts.map +0 -1
- package/dist/database/kysely.mjs.map +0 -1
- package/dist/functions-i_la-N5r.cjs.map +0 -1
- package/dist/index-Bd5FqCoe.d.cts.map +0 -1
- package/dist/index-BknhM6Ux.d.mts +0 -31
- package/dist/index-BknhM6Ux.d.mts.map +0 -1
- package/dist/index-CBSfrowv.d.cts +0 -31
- package/dist/index-CBSfrowv.d.cts.map +0 -1
- package/dist/index-D24Xm79M.d.cts +0 -171
- package/dist/index-D24Xm79M.d.cts.map +0 -1
- package/dist/index-_ajboYxK.d.mts +0 -171
- package/dist/index-_ajboYxK.d.mts.map +0 -1
- package/dist/index-lAO9egTb.d.mts.map +0 -1
- package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
- package/dist/lazyAccessors-e3j2oE2m.cjs +0 -274
- package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
- package/dist/processAudits-CGqttuXm.cjs +0 -92
- package/dist/processAudits-CGqttuXm.cjs.map +0 -1
- package/dist/processAudits-Dmts9H_b.mjs +0 -80
- package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts.map +0 -1
- package/dist/queue/index.d.mts.map +0 -1
- package/dist/queue/index.mjs.map +0 -1
- package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
- package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
- package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
- package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
- package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
- package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.mjs.map +0 -1
- package/dist/types-BlAkSuGI.d.cts.map +0 -1
- package/dist/types-aKksMEWL.d.mts.map +0 -1
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-y5ARvAq5.cjs");
|
|
2
|
+
const require_shutdown = require("./shutdown-BMJmAhSt.cjs");
|
|
3
|
+
const require_cache = require("./cache.cjs");
|
|
4
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
5
|
+
let _geekmidas_services = require("@geekmidas/services");
|
|
6
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
7
|
+
let kysely = require("kysely");
|
|
8
|
+
let pg = require("pg");
|
|
9
|
+
pg = require_rolldown_runtime.__toESM(pg, 1);
|
|
10
|
+
/** Every pool opened and not yet closed, so a shutdown can end them all. */
|
|
11
|
+
const open = /* @__PURE__ */ new Set();
|
|
12
|
+
require_shutdown.onShutdown(() => closeDatabasePools());
|
|
13
|
+
/**
|
|
14
|
+
* A pool for one URL, with its schema actually on the search path.
|
|
15
|
+
*
|
|
16
|
+
* `?search_path=` is not a libpq parameter — a URL carrying it connects
|
|
17
|
+
* happily and then resolves every unqualified name against `public`, which is
|
|
18
|
+
* how a schema tenant silently writes its tables into the database it was
|
|
19
|
+
* separated from. Postgres takes it as a startup option instead, so the URL
|
|
20
|
+
* keeps the readable form the target derives and this turns it into the thing
|
|
21
|
+
* the server understands.
|
|
22
|
+
*/
|
|
23
|
+
function openPool(url, options = {}) {
|
|
24
|
+
const parsed = new URL(url);
|
|
25
|
+
const searchPath = parsed.searchParams.get("search_path");
|
|
26
|
+
parsed.searchParams.delete("search_path");
|
|
27
|
+
const pool = new pg.default.Pool({
|
|
28
|
+
connectionString: parsed.toString(),
|
|
29
|
+
...searchPath ? { options: `-c search_path=${searchPath}` } : {},
|
|
30
|
+
fallback_application_name: applicationName()
|
|
31
|
+
});
|
|
32
|
+
pool.on("error", (error) => {
|
|
33
|
+
const logger = (0, _geekmidas_services.currentRequestContext)()?.logger;
|
|
34
|
+
if (logger) logger.warn({ err: error }, "Idle database connection lost");
|
|
35
|
+
else console.warn("Idle database connection lost:", error.message);
|
|
36
|
+
});
|
|
37
|
+
const target = connectionAttributes(parsed);
|
|
38
|
+
pool.on("connect", (client) => {
|
|
39
|
+
if (options.queryTags !== false) tagQueries(client);
|
|
40
|
+
traceQueries(client, target);
|
|
41
|
+
});
|
|
42
|
+
open.add(pool);
|
|
43
|
+
const end = pool.end.bind(pool);
|
|
44
|
+
pool.end = (async () => {
|
|
45
|
+
open.delete(pool);
|
|
46
|
+
await end();
|
|
47
|
+
});
|
|
48
|
+
return pool;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* End every pool opened, waiting for checked-out connections to come back.
|
|
52
|
+
* For a server's shutdown, after it has stopped taking requests.
|
|
53
|
+
*/
|
|
54
|
+
async function closeDatabasePools() {
|
|
55
|
+
await Promise.all([...open].map((pool) => pool.end()));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Who this process is, as Postgres will show it: the Lambda function, else the
|
|
59
|
+
* app — `GKM_APP_NAME` where an entry sets it, `gkm dev`'s app tag otherwise.
|
|
60
|
+
* Postgres keeps 63 bytes of it.
|
|
61
|
+
*/
|
|
62
|
+
function applicationName(env = process.env) {
|
|
63
|
+
return env.AWS_LAMBDA_FUNCTION_NAME || env.GKM_APP_NAME || env.GKM_DEV_APP?.split("#").pop() || void 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The comment that says what ran a query: the request's operation and id, and
|
|
67
|
+
* the active span as a W3C `traceparent` — the query's own span when it runs
|
|
68
|
+
* through a traced client, since the span wraps the tagging. '' with neither.
|
|
69
|
+
*
|
|
70
|
+
* The keys are in sqlcommenter's sorted order. Values keep only characters
|
|
71
|
+
* that cannot end a comment or a quoted value — `*` and `'` among those
|
|
72
|
+
* dropped — so a route cannot inject SQL through it.
|
|
73
|
+
*/
|
|
74
|
+
function queryTag() {
|
|
75
|
+
const request = (0, _geekmidas_services.currentRequestContext)();
|
|
76
|
+
const span = _opentelemetry_api.trace.getActiveSpan()?.spanContext();
|
|
77
|
+
const tags = [
|
|
78
|
+
["operation", request?.operation],
|
|
79
|
+
["request_id", request?.requestId],
|
|
80
|
+
["traceparent", span && (0, _opentelemetry_api.isSpanContextValid)(span) ? traceparent(span) : ""]
|
|
81
|
+
].filter((tag) => Boolean(tag[1]));
|
|
82
|
+
if (tags.length === 0) return "";
|
|
83
|
+
const clean = (value) => value.replace(/[^\w ./:{}@-]/g, "");
|
|
84
|
+
return ` /*${tags.map(([key, value]) => `${key}='${clean(value)}'`).join(",")}*/`;
|
|
85
|
+
}
|
|
86
|
+
/** A span as W3C trace context's `traceparent`, version 00. */
|
|
87
|
+
function traceparent(span) {
|
|
88
|
+
const flags = (span.traceFlags & 255).toString(16).padStart(2, "0");
|
|
89
|
+
return `00-${span.traceId}-${span.spanId}-${flags}`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Append {@link queryTag} to everything `client` runs: a SQL string — what
|
|
93
|
+
* Kysely sends — or a query object such as a cursor's.
|
|
94
|
+
*/
|
|
95
|
+
function tagQueries(client) {
|
|
96
|
+
const query = client.query.bind(client);
|
|
97
|
+
client.query = ((first, ...rest) => {
|
|
98
|
+
const tag = queryTag();
|
|
99
|
+
if (tag && typeof first === "string") return query(first + tag, ...rest);
|
|
100
|
+
if (tag && first && typeof first === "object" && typeof first.text === "string") {
|
|
101
|
+
const config = first;
|
|
102
|
+
config.text += tag;
|
|
103
|
+
}
|
|
104
|
+
return query(first, ...rest);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** What every span of one pool says about where it connects. */
|
|
108
|
+
function connectionAttributes(url) {
|
|
109
|
+
const name = decodeURIComponent(url.pathname.slice(1));
|
|
110
|
+
return {
|
|
111
|
+
"db.system": "postgresql",
|
|
112
|
+
...name && { "db.name": name },
|
|
113
|
+
"server.address": url.hostname,
|
|
114
|
+
"server.port": Number(url.port || 5432)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const TRACER = "@geekmidas/constructs";
|
|
118
|
+
/** `select`, `insert`, … — the first keyword, or `with`'s main statement. */
|
|
119
|
+
const OPERATION = /^\s*(?:\/\*.*?\*\/\s*)?(\w+)/s;
|
|
120
|
+
/** The table a statement is about, when it names one where it usually does. */
|
|
121
|
+
const TABLE = /\b(?:from|into|update|join)\s+((?:"[^"]+"|[\w$]+)(?:\.(?:"[^"]+"|[\w$]+))?)/i;
|
|
122
|
+
/**
|
|
123
|
+
* What a statement does and to which table, parsed cheaply from its first
|
|
124
|
+
* characters: `select "orders"`, `insert "public"."users"`. A statement the
|
|
125
|
+
* patterns cannot read leaves `table` unset.
|
|
126
|
+
*/
|
|
127
|
+
function describeStatement(text) {
|
|
128
|
+
const head = text.length > 512 ? text.slice(0, 512) : text;
|
|
129
|
+
const operation = OPERATION.exec(head)?.[1]?.toLowerCase();
|
|
130
|
+
const table = TABLE.exec(head)?.[1]?.replace(/"/g, "");
|
|
131
|
+
return {
|
|
132
|
+
...operation && { operation },
|
|
133
|
+
...table && { table }
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A span around everything `client` runs — `<operation> <table>`, or
|
|
138
|
+
* `db.query` when the statement does not say.
|
|
139
|
+
*
|
|
140
|
+
* The statement text goes on the span only for a parameterized query — values
|
|
141
|
+
* passed separately, as Kysely always does — and truncated. Parameter values
|
|
142
|
+
* never do. A bare string with no values could hold anything a caller
|
|
143
|
+
* concatenated into it, so it gets no text at all.
|
|
144
|
+
*/
|
|
145
|
+
function traceQueries(client, connection) {
|
|
146
|
+
const query = client.query.bind(client);
|
|
147
|
+
client.query = ((first, ...rest) => {
|
|
148
|
+
const config = first && typeof first === "object" ? first : void 0;
|
|
149
|
+
const text = typeof first === "string" ? first : typeof config?.text === "string" ? config.text : void 0;
|
|
150
|
+
const values = typeof first === "string" ? rest[0] : config?.values;
|
|
151
|
+
const { operation, table } = text ? describeStatement(text) : {};
|
|
152
|
+
const span = _opentelemetry_api.trace.getTracer(TRACER).startSpan(operation && table ? `${operation} ${table}` : "db.query", {
|
|
153
|
+
kind: _opentelemetry_api.SpanKind.CLIENT,
|
|
154
|
+
attributes: {
|
|
155
|
+
...connection,
|
|
156
|
+
...operation && { "db.operation": operation },
|
|
157
|
+
...table && { "db.sql.table": table },
|
|
158
|
+
...text && Array.isArray(values) && { "db.statement": text.length > 2048 ? text.slice(0, 2048) : text }
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const end = (error) => {
|
|
162
|
+
if (error) {
|
|
163
|
+
if (error instanceof Error) span.recordException(error);
|
|
164
|
+
span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
|
|
165
|
+
}
|
|
166
|
+
span.end();
|
|
167
|
+
};
|
|
168
|
+
const last = rest[rest.length - 1];
|
|
169
|
+
if (typeof last === "function") {
|
|
170
|
+
const args = [...rest];
|
|
171
|
+
args[args.length - 1] = (error, ...result) => {
|
|
172
|
+
end(error);
|
|
173
|
+
return last(error, ...result);
|
|
174
|
+
};
|
|
175
|
+
return _opentelemetry_api.context.with(_opentelemetry_api.trace.setSpan(_opentelemetry_api.context.active(), span), () => query(first, ...args));
|
|
176
|
+
}
|
|
177
|
+
let result;
|
|
178
|
+
try {
|
|
179
|
+
result = _opentelemetry_api.context.with(_opentelemetry_api.trace.setSpan(_opentelemetry_api.context.active(), span), () => query(first, ...rest));
|
|
180
|
+
} catch (error) {
|
|
181
|
+
end(error);
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
if (result && typeof result.then === "function") result.then(() => end(), (error) => end(error));
|
|
185
|
+
else if (result && typeof result.once === "function") {
|
|
186
|
+
const emitter = result;
|
|
187
|
+
emitter.once("end", () => end());
|
|
188
|
+
emitter.once("error", (error) => end(error));
|
|
189
|
+
} else end();
|
|
190
|
+
return result;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/database/kysely.ts
|
|
195
|
+
/**
|
|
196
|
+
* `KyselyDatabase` — a declared Postgres database, typed by its schema.
|
|
197
|
+
*
|
|
198
|
+
* It declares a logical database, a schema, and the roles that reach it, and
|
|
199
|
+
* hands back a Kysely client built from the one URL the adapter supplied. It
|
|
200
|
+
* names no cloud: `--target=aws` fills that URL from RDS, local dev from the
|
|
201
|
+
* Postgres container.
|
|
202
|
+
*
|
|
203
|
+
* Transactions and RLS context are the execution wrapper's job — it opens the
|
|
204
|
+
* transaction and puts it in `ctx.db`. This construct does not resolve
|
|
205
|
+
* connections per request.
|
|
206
|
+
*/
|
|
207
|
+
/** The schema a database uses when it does not say otherwise. */
|
|
208
|
+
const DEFAULT_SCHEMA = "app";
|
|
209
|
+
/**
|
|
210
|
+
* @typeParam DB - the database's schema.
|
|
211
|
+
* @typeParam TName - the canonical id. TypeScript has no partial
|
|
212
|
+
* type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
|
|
213
|
+
* this at its default and the service key widens to `string`. `db` still types
|
|
214
|
+
* through `.database()`, which infers from the service.
|
|
215
|
+
*/
|
|
216
|
+
var KyselyDatabase = class KyselyDatabase {
|
|
217
|
+
options;
|
|
218
|
+
id;
|
|
219
|
+
service;
|
|
220
|
+
/**
|
|
221
|
+
* Declared once and read by both `declare()` and `connect()`, so the key the
|
|
222
|
+
* build publishes and the key the client reads cannot drift.
|
|
223
|
+
*/
|
|
224
|
+
config;
|
|
225
|
+
schemaName;
|
|
226
|
+
roles;
|
|
227
|
+
runtime;
|
|
228
|
+
derivedFrom;
|
|
229
|
+
constructor(id, options = {}, derivedFrom) {
|
|
230
|
+
this.options = options;
|
|
231
|
+
const canonical = (0, _geekmidas_manifest.canonicalId)(id);
|
|
232
|
+
this.id = canonical;
|
|
233
|
+
this.config = {
|
|
234
|
+
url: (0, _geekmidas_manifest.provideKey)(canonical, "url"),
|
|
235
|
+
ownerUrl: (0, _geekmidas_manifest.provideKey)(canonical, "ownerUrl")
|
|
236
|
+
};
|
|
237
|
+
this.schemaName = options.schema ?? DEFAULT_SCHEMA;
|
|
238
|
+
this.roles = options.roles ?? true;
|
|
239
|
+
this.runtime = options.image ? { image: options.image } : { version: options.version ?? _geekmidas_manifest.DEFAULT_POSTGRES_VERSION };
|
|
240
|
+
this.derivedFrom = derivedFrom;
|
|
241
|
+
this.service = {
|
|
242
|
+
serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
|
|
243
|
+
register: (registerOptions) => this.connect(registerOptions)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
declare() {
|
|
247
|
+
if (this.derivedFrom) {
|
|
248
|
+
const { kind, of, schema } = this.derivedFrom;
|
|
249
|
+
return [kind === "database-schema" ? {
|
|
250
|
+
kind,
|
|
251
|
+
id: this.id,
|
|
252
|
+
of,
|
|
253
|
+
schema: schema ?? this.schemaName,
|
|
254
|
+
provides: [this.config.url]
|
|
255
|
+
} : {
|
|
256
|
+
kind,
|
|
257
|
+
id: this.id,
|
|
258
|
+
of,
|
|
259
|
+
provides: [this.config.url]
|
|
260
|
+
}];
|
|
261
|
+
}
|
|
262
|
+
return [{
|
|
263
|
+
kind: "database",
|
|
264
|
+
id: this.id,
|
|
265
|
+
engine: "postgres",
|
|
266
|
+
schema: this.schemaName,
|
|
267
|
+
...this.runtime,
|
|
268
|
+
...this.options.extensions?.length ? { extensions: [...new Set(this.options.extensions)] } : {},
|
|
269
|
+
provides: [this.config.url],
|
|
270
|
+
...this.roles ? {} : { roles: false }
|
|
271
|
+
}];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* A read-only endpoint on this database.
|
|
275
|
+
*
|
|
276
|
+
* Read-only is enforced by the reader role's grants rather than by which
|
|
277
|
+
* endpoint it resolves to, so falling back to the writer where no replica
|
|
278
|
+
* exists is safe rather than a silently writable connection behind a name
|
|
279
|
+
* that says reader. There is no `writer()`: the database *is* the writer, so
|
|
280
|
+
* a replica can never be reached by accident.
|
|
281
|
+
*
|
|
282
|
+
* The return type is narrower than this class on purpose — see
|
|
283
|
+
* {@link ReadOnlyDatabase}.
|
|
284
|
+
*/
|
|
285
|
+
reader() {
|
|
286
|
+
return new KyselyDatabase(`${this.id}Reader`, this.options, {
|
|
287
|
+
kind: "database-reader",
|
|
288
|
+
of: this.id
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A cache that lives in this database.
|
|
293
|
+
*
|
|
294
|
+
* The same strengthening `schema()` is over a second database: `new
|
|
295
|
+
* Cache('Sessions')` says the app caches and leaves where to the deployment,
|
|
296
|
+
* while this says it caches *here* — which is a fact about the application
|
|
297
|
+
* and so belongs in its code.
|
|
298
|
+
*
|
|
299
|
+
* What it buys beyond being explicit: the table's schema and the role that
|
|
300
|
+
* reaches it come from this database rather than from a second convention,
|
|
301
|
+
* and the backend no longer has to guess which database "the database" meant
|
|
302
|
+
* when an app declares two.
|
|
303
|
+
*
|
|
304
|
+
* A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
|
|
305
|
+
* is a key/value store, not a query builder, and typing it as the parent
|
|
306
|
+
* would be a convenience that lies.
|
|
307
|
+
*/
|
|
308
|
+
cache(id = `${this.id}Cache`, options = {}) {
|
|
309
|
+
return new require_cache.Cache(id, {
|
|
310
|
+
of: this.id,
|
|
311
|
+
...options.table ? { table: options.table } : {}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* A second schema in this database, with its own role(s) and its own URL —
|
|
316
|
+
* so this database's role holds no grant on those tables at all.
|
|
317
|
+
*
|
|
318
|
+
* Typed separately because a tenant has its own tables: the point is that
|
|
319
|
+
* `auth.selectFrom('sessions')` type-checks and
|
|
320
|
+
* `orders.selectFrom('sessions')` does not.
|
|
321
|
+
*/
|
|
322
|
+
schema(id, options = {}) {
|
|
323
|
+
return new KyselyDatabase(id, options, {
|
|
324
|
+
kind: "database-schema",
|
|
325
|
+
of: this.id,
|
|
326
|
+
schema: options.schema ?? id.toLowerCase()
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* A connection as the *owner* role — the one that may create, alter and drop.
|
|
331
|
+
*
|
|
332
|
+
* A `Service` rather than part of the construct, and deliberately so: a
|
|
333
|
+
* construct is what `.dependsOn()` accepts, and nothing should be able to
|
|
334
|
+
* depend on this. A migrator asks for it by name; a handler cannot ask at
|
|
335
|
+
* all, which is the security property the role split exists for.
|
|
336
|
+
*
|
|
337
|
+
* Falls back to the runtime URL where no owner URL was published — the
|
|
338
|
+
* `roles: false` downgrade, where there is only one credential and it is the
|
|
339
|
+
* cluster master's.
|
|
340
|
+
*/
|
|
341
|
+
get owner() {
|
|
342
|
+
return {
|
|
343
|
+
serviceName: `${(0, _geekmidas_manifest.serviceKey)(this.id)}Owner`,
|
|
344
|
+
register: (options) => this.connect(options, { owner: true })
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* What this database's clients are built with besides a dialect — the
|
|
349
|
+
* plugins and logging it was declared with.
|
|
350
|
+
*
|
|
351
|
+
* Public so that whatever opens a connection to it outside \`connect()\` —
|
|
352
|
+
* a test's transaction — builds the same client. A test that dropped the
|
|
353
|
+
* plugins would write \`createdAt\` where production writes \`created_at\`.
|
|
354
|
+
*/
|
|
355
|
+
get clientConfig() {
|
|
356
|
+
const { schema: _schema, roles: _roles, version: _version, image: _image, extensions: _extensions, queryTags: _queryTags, ...kysely$1 } = this.options;
|
|
357
|
+
return kysely$1;
|
|
358
|
+
}
|
|
359
|
+
async connect(options, as = {}) {
|
|
360
|
+
const { url, ownerUrl } = options.envParser.create((get) => ({
|
|
361
|
+
url: get(this.config.url).string(),
|
|
362
|
+
ownerUrl: get(this.config.ownerUrl).string().optional()
|
|
363
|
+
})).parse();
|
|
364
|
+
return new kysely.Kysely({
|
|
365
|
+
...this.clientConfig,
|
|
366
|
+
dialect: new kysely.PostgresDialect({ pool: openPool(as.owner ? ownerUrl ?? url : url, { queryTags: this.options.queryTags }) })
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
//#endregion
|
|
371
|
+
Object.defineProperty(exports, "KyselyDatabase", {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function() {
|
|
374
|
+
return KyselyDatabase;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
Object.defineProperty(exports, "closeDatabasePools", {
|
|
378
|
+
enumerable: true,
|
|
379
|
+
get: function() {
|
|
380
|
+
return closeDatabasePools;
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
//# sourceMappingURL=kysely-CukArHJ0.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kysely-CukArHJ0.cjs","names":["onShutdown","currentRequestContext","trace","isSpanContextValid","SpanKind","SpanStatusCode","context","canonicalId","provideKey","DEFAULT_POSTGRES_VERSION","serviceKey","Cache","kysely","Kysely","PostgresDialect"],"sources":["../src/database/pool.ts","../src/database/kysely.ts"],"sourcesContent":["/**\n * The `pg` pools a database construct opens, and what every one of them gets:\n *\n * - **A name.** `application_name` is what `pg_stat_activity` shows beside a\n * connection. Without one, a database at `max_connections` cannot say who\n * holds them. It is a *fallback*, so `PGAPPNAME` or `?application_name=` in\n * the URL still win.\n * - **Tagged queries.** Inside a request, each query ends in a comment naming\n * what ran it — `/*operation='POST /orders',request_id='…'*\\/` — in the\n * sqlcommenter form, and inside a trace the query's own span as\n * `traceparent='00-<trace>-<span>-<flags>'`. It shows in\n * `pg_stat_activity.query`, in the server's slow-query and `auto_explain`\n * logs, and costs no round trip; `pg_stat_statements` ignores comments, so\n * its grouping is unchanged.\n * - **A listener for idle-client errors.** When the server ends an idle\n * connection (`idle_session_timeout`, a failover, an admin), the pool emits\n * `'error'`. With no listener that is an uncaught exception that kills the\n * process — for a client the pool has already discarded.\n * - **A span per query.** Through the global OpenTelemetry tracer, so a no-op\n * without a provider. `pg` is bundled into a production entry, where no\n * instrumentation can hook its module load — so the client is wrapped here,\n * as the tags are. See {@link traceQueries}.\n * - **A way to close.** {@link closeDatabasePools} ends every pool opened, so a\n * server shutting down releases its connections instead of holding them\n * until the process dies.\n */\n\nimport { currentRequestContext } from '@geekmidas/services';\nimport {\n\ttype Attributes,\n\tcontext,\n\tisSpanContextValid,\n\tSpanKind,\n\tSpanStatusCode,\n\ttrace,\n} from '@opentelemetry/api';\nimport pg from 'pg';\nimport { onShutdown } from '../shutdown';\n\nexport interface DatabasePoolOptions {\n\t/** Tag queries with what ran them and the trace they ran in. Default true. */\n\tqueryTags?: boolean;\n}\n\n/** The longest statement text a query span carries. */\nexport const MAX_STATEMENT_LENGTH = 2048;\n\n/** Every pool opened and not yet closed, so a shutdown can end them all. */\nconst open = new Set<pg.Pool>();\nonShutdown(() => closeDatabasePools());\n\n/**\n * A pool for one URL, with its schema actually on the search path.\n *\n * `?search_path=` is not a libpq parameter — a URL carrying it connects\n * happily and then resolves every unqualified name against `public`, which is\n * how a schema tenant silently writes its tables into the database it was\n * separated from. Postgres takes it as a startup option instead, so the URL\n * keeps the readable form the target derives and this turns it into the thing\n * the server understands.\n */\nexport function openPool(\n\turl: string,\n\toptions: DatabasePoolOptions = {},\n): pg.Pool {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tparsed.searchParams.delete('search_path');\n\n\tconst pool = new pg.Pool({\n\t\tconnectionString: parsed.toString(),\n\t\t...(searchPath ? { options: `-c search_path=${searchPath}` } : {}),\n\t\tfallback_application_name: applicationName(),\n\t});\n\n\tpool.on('error', (error) => {\n\t\tconst logger = currentRequestContext()?.logger;\n\t\tif (logger) logger.warn({ err: error }, 'Idle database connection lost');\n\t\telse console.warn('Idle database connection lost:', error.message);\n\t});\n\tconst target = connectionAttributes(parsed);\n\tpool.on('connect', (client) => {\n\t\t// Tags first, so the span wraps them: it records the statement as the\n\t\t// application wrote it rather than with the comment on the end, and it\n\t\t// is the active span when the tag is written — so the `traceparent` a\n\t\t// query carries names the query's own span.\n\t\tif (options.queryTags !== false) tagQueries(client);\n\t\ttraceQueries(client, target);\n\t});\n\n\topen.add(pool);\n\tconst end = pool.end.bind(pool);\n\tpool.end = (async () => {\n\t\topen.delete(pool);\n\t\tawait end();\n\t}) as typeof pool.end;\n\n\treturn pool;\n}\n\n/**\n * End every pool opened, waiting for checked-out connections to come back.\n * For a server's shutdown, after it has stopped taking requests.\n */\nexport async function closeDatabasePools(): Promise<void> {\n\tawait Promise.all([...open].map((pool) => pool.end()));\n}\n\n/**\n * Who this process is, as Postgres will show it: the Lambda function, else the\n * app — `GKM_APP_NAME` where an entry sets it, `gkm dev`'s app tag otherwise.\n * Postgres keeps 63 bytes of it.\n */\nexport function applicationName(\n\tenv: NodeJS.ProcessEnv = process.env,\n): string | undefined {\n\treturn (\n\t\tenv.AWS_LAMBDA_FUNCTION_NAME ||\n\t\tenv.GKM_APP_NAME ||\n\t\tenv.GKM_DEV_APP?.split('#').pop() ||\n\t\tundefined\n\t);\n}\n\n/**\n * The comment that says what ran a query: the request's operation and id, and\n * the active span as a W3C `traceparent` — the query's own span when it runs\n * through a traced client, since the span wraps the tagging. '' with neither.\n *\n * The keys are in sqlcommenter's sorted order. Values keep only characters\n * that cannot end a comment or a quoted value — `*` and `'` among those\n * dropped — so a route cannot inject SQL through it.\n */\nexport function queryTag(): string {\n\tconst request = currentRequestContext();\n\tconst span = trace.getActiveSpan()?.spanContext();\n\n\tconst tags = [\n\t\t['operation', request?.operation],\n\t\t['request_id', request?.requestId],\n\t\t['traceparent', span && isSpanContextValid(span) ? traceparent(span) : ''],\n\t].filter((tag): tag is [string, string] => Boolean(tag[1]));\n\tif (tags.length === 0) return '';\n\n\tconst clean = (value: string) => value.replace(/[^\\w ./:{}@-]/g, '');\n\treturn ` /*${tags.map(([key, value]) => `${key}='${clean(value)}'`).join(',')}*/`;\n}\n\n/** A span as W3C trace context's `traceparent`, version 00. */\nfunction traceparent(span: {\n\ttraceId: string;\n\tspanId: string;\n\ttraceFlags: number;\n}): string {\n\tconst flags = (span.traceFlags & 0xff).toString(16).padStart(2, '0');\n\treturn `00-${span.traceId}-${span.spanId}-${flags}`;\n}\n\n/**\n * Append {@link queryTag} to everything `client` runs: a SQL string — what\n * Kysely sends — or a query object such as a cursor's.\n */\nfunction tagQueries(client: pg.PoolClient): void {\n\tconst query = client.query.bind(client) as (...args: unknown[]) => unknown;\n\tclient.query = ((first: unknown, ...rest: unknown[]) => {\n\t\tconst tag = queryTag();\n\t\tif (tag && typeof first === 'string') return query(first + tag, ...rest);\n\t\tif (\n\t\t\ttag &&\n\t\t\tfirst &&\n\t\t\ttypeof first === 'object' &&\n\t\t\ttypeof (first as { text?: unknown }).text === 'string'\n\t\t) {\n\t\t\tconst config = first as { text: string };\n\t\t\tconfig.text += tag;\n\t\t}\n\t\treturn query(first, ...rest);\n\t}) as typeof client.query;\n}\n\n/** What every span of one pool says about where it connects. */\nfunction connectionAttributes(url: URL): Attributes {\n\tconst name = decodeURIComponent(url.pathname.slice(1));\n\treturn {\n\t\t'db.system': 'postgresql',\n\t\t...(name && { 'db.name': name }),\n\t\t'server.address': url.hostname,\n\t\t'server.port': Number(url.port || 5432),\n\t};\n}\n\nconst TRACER = '@geekmidas/constructs';\n\n/** `select`, `insert`, … — the first keyword, or `with`'s main statement. */\nconst OPERATION = /^\\s*(?:\\/\\*.*?\\*\\/\\s*)?(\\w+)/s;\n/** The table a statement is about, when it names one where it usually does. */\nconst TABLE =\n\t/\\b(?:from|into|update|join)\\s+((?:\"[^\"]+\"|[\\w$]+)(?:\\.(?:\"[^\"]+\"|[\\w$]+))?)/i;\n\n/**\n * What a statement does and to which table, parsed cheaply from its first\n * characters: `select \"orders\"`, `insert \"public\".\"users\"`. A statement the\n * patterns cannot read leaves `table` unset.\n */\nexport function describeStatement(text: string): {\n\toperation?: string;\n\ttable?: string;\n} {\n\tconst head = text.length > 512 ? text.slice(0, 512) : text;\n\tconst operation = OPERATION.exec(head)?.[1]?.toLowerCase();\n\tconst table = TABLE.exec(head)?.[1]?.replace(/\"/g, '');\n\treturn {\n\t\t...(operation && { operation }),\n\t\t...(table && { table }),\n\t};\n}\n\n/**\n * A span around everything `client` runs — `<operation> <table>`, or\n * `db.query` when the statement does not say.\n *\n * The statement text goes on the span only for a parameterized query — values\n * passed separately, as Kysely always does — and truncated. Parameter values\n * never do. A bare string with no values could hold anything a caller\n * concatenated into it, so it gets no text at all.\n */\nfunction traceQueries(client: pg.PoolClient, connection: Attributes): void {\n\tconst query = client.query.bind(client) as (...args: unknown[]) => unknown;\n\tclient.query = ((first: unknown, ...rest: unknown[]) => {\n\t\tconst config =\n\t\t\tfirst && typeof first === 'object'\n\t\t\t\t? (first as { text?: unknown; values?: unknown })\n\t\t\t\t: undefined;\n\t\tconst text =\n\t\t\ttypeof first === 'string'\n\t\t\t\t? first\n\t\t\t\t: typeof config?.text === 'string'\n\t\t\t\t\t? config.text\n\t\t\t\t\t: undefined;\n\t\tconst values = typeof first === 'string' ? rest[0] : config?.values;\n\t\tconst { operation, table } = text ? describeStatement(text) : {};\n\n\t\tconst span = trace\n\t\t\t.getTracer(TRACER)\n\t\t\t.startSpan(operation && table ? `${operation} ${table}` : 'db.query', {\n\t\t\t\tkind: SpanKind.CLIENT,\n\t\t\t\tattributes: {\n\t\t\t\t\t...connection,\n\t\t\t\t\t...(operation && { 'db.operation': operation }),\n\t\t\t\t\t...(table && { 'db.sql.table': table }),\n\t\t\t\t\t...(text &&\n\t\t\t\t\t\tArray.isArray(values) && {\n\t\t\t\t\t\t\t'db.statement':\n\t\t\t\t\t\t\t\ttext.length > MAX_STATEMENT_LENGTH\n\t\t\t\t\t\t\t\t\t? text.slice(0, MAX_STATEMENT_LENGTH)\n\t\t\t\t\t\t\t\t\t: text,\n\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t});\n\t\tconst end = (error?: unknown) => {\n\t\t\tif (error) {\n\t\t\t\tif (error instanceof Error) span.recordException(error);\n\t\t\t\tspan.setStatus({ code: SpanStatusCode.ERROR });\n\t\t\t}\n\t\t\tspan.end();\n\t\t};\n\n\t\t// A callback, as `pg`'s own callback form takes it.\n\t\tconst last = rest[rest.length - 1];\n\t\tif (typeof last === 'function') {\n\t\t\tconst args = [...rest];\n\t\t\targs[args.length - 1] = (error: unknown, ...result: unknown[]) => {\n\t\t\t\tend(error);\n\t\t\t\treturn (last as (...a: unknown[]) => unknown)(error, ...result);\n\t\t\t};\n\t\t\treturn context.with(trace.setSpan(context.active(), span), () =>\n\t\t\t\tquery(first, ...args),\n\t\t\t);\n\t\t}\n\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = context.with(trace.setSpan(context.active(), span), () =>\n\t\t\t\tquery(first, ...rest),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tend(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (result && typeof (result as Promise<unknown>).then === 'function') {\n\t\t\t(result as Promise<unknown>).then(\n\t\t\t\t() => end(),\n\t\t\t\t(error) => end(error),\n\t\t\t);\n\t\t} else if (\n\t\t\tresult &&\n\t\t\ttypeof (result as { once?: unknown }).once === 'function'\n\t\t) {\n\t\t\t// A submittable — a cursor or a stream — ends when it says so.\n\t\t\tconst emitter = result as {\n\t\t\t\tonce(event: string, fn: (e?: unknown) => void): void;\n\t\t\t};\n\t\t\temitter.once('end', () => end());\n\t\t\temitter.once('error', (error) => end(error));\n\t\t} else {\n\t\t\tend();\n\t\t}\n\t\treturn result;\n\t}) as typeof client.query;\n}\n","/**\n * `KyselyDatabase` — a declared Postgres database, typed by its schema.\n *\n * It declares a logical database, a schema, and the roles that reach it, and\n * hands back a Kysely client built from the one URL the adapter supplied. It\n * names no cloud: `--target=aws` fills that URL from RDS, local dev from the\n * Postgres container.\n *\n * Transactions and RLS context are the execution wrapper's job — it opens the\n * transaction and puts it in `ctx.db`. This construct does not resolve\n * connections per request.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDEFAULT_POSTGRES_VERSION,\n\ttype Declaration,\n\ttype PostgresVersion,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport { Cache } from '../cache';\nimport type { Construct } from '../construct-interface';\nimport { openPool } from './pool';\n\n/** The schema a database uses when it does not say otherwise. */\nconst DEFAULT_SCHEMA = 'app';\n\n/**\n * Everything Kysely takes, plus what this construct declares.\n *\n * `dialect` is omitted because the construct owns it — it is built from the one\n * URL the adapter supplied, which is the whole point of the construct. The rest\n * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes\n * straight through, so anything Kysely adds later arrives without being\n * tracked here.\n */\ninterface KyselyDatabaseBaseOptions extends Omit<KyselyConfig, 'dialect'> {\n\t/**\n\t * The schema, pinned on both roles' `search_path`.\n\t *\n\t * Defaults to `app` — the role the schema plays, rather than a restatement\n\t * of the database's own name, which reads correctly beside `auth` and\n\t * `pgboss` and keeps the application off `public`.\n\t */\n\tschema?: string;\n\t/**\n\t * Provision the owner/runtime role split. Defaults to on.\n\t *\n\t * Off falls back to the cluster's master credential in both URLs, giving up\n\t * the DDL/DML split and putting credentials that can drop a table into the\n\t * function's environment. A deliberate downgrade, not a default.\n\t */\n\troles?: boolean;\n\t/**\n\t * Extensions to create in this database, as the cluster master, before the\n\t * first migration — for the ones the owner role a migration runs as may not\n\t * create (PostGIS is not a trusted extension). They are created in\n\t * `public`, which joins this database's roles' `search_path`, so their\n\t * types resolve unqualified.\n\t *\n\t * Only attempted: the image has to ship them.\n\t */\n\textensions?: readonly string[];\n\t/**\n\t * End each query run inside a request with a comment naming what ran it —\n\t * `/*operation='POST /orders',request_id='…'*\\/` — so `pg_stat_activity`\n\t * and the server's logs can tie a query to its endpoint — and, inside a\n\t * trace, with the query span's `traceparent='00-…'` (sqlcommenter), so\n\t * they can tie it to the trace too. Defaults to on.\n\t */\n\tqueryTags?: boolean;\n}\n\n/**\n * Which Postgres the database runs: a major on the stock image, or an image\n * the project names. One or the other, never both — an image's tag already\n * says its major, and a second statement of it is one that can disagree.\n */\nexport type PostgresRuntime =\n\t| {\n\t\t\t/**\n\t\t\t * The Postgres major version to provision, on the stock image.\n\t\t\t *\n\t\t\t * Declared here so one statement reaches every target. It was\n\t\t\t * previously set in two unrelated places — a container tag locally,\n\t\t\t * nothing at all on AWS (so Aurora chose) — which is how local came to\n\t\t\t * run 18 while deployed ran 17.7 with nothing recording the difference.\n\t\t\t *\n\t\t\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t\t\t */\n\t\t\tversion?: PostgresVersion;\n\t\t\timage?: never;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The container image to run, wherever a target runs one (local,\n\t\t\t * Dokploy), in place of `postgres:<version>`.\n\t\t\t *\n\t\t\t * Yours to choose and used as written: its tag is the major, and it\n\t\t\t * should ship every extension in `extensions`. AWS runs RDS, ignores\n\t\t\t * it, and provisions {@link DEFAULT_POSTGRES_VERSION}.\n\t\t\t *\n\t\t\t * ```ts\n\t\t\t * new KyselyDatabase<GeoDB>('Geo', {\n\t\t\t * image: 'postgis/postgis:18-3.6-alpine',\n\t\t\t * extensions: ['postgis'],\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\timage: string;\n\t\t\tversion?: never;\n\t };\n\n/**\n * Everything Kysely takes, plus what this construct declares — including\n * which Postgres it runs, as a version or an image.\n */\nexport type KyselyDatabaseOptions = KyselyDatabaseBaseOptions & PostgresRuntime;\n\n/** What makes a construct derived rather than a database in its own right. */\ninterface DerivedFrom {\n\tkind: 'database-reader' | 'database-schema';\n\tof: string;\n\tschema?: string;\n}\n\n/**\n * @typeParam DB - the database's schema.\n * @typeParam TName - the canonical id. TypeScript has no partial\n * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves\n * this at its default and the service key widens to `string`. `db` still types\n * through `.database()`, which infers from the service.\n */\nexport class KyselyDatabase<DB = unknown, TName extends string = string>\n\timplements Construct<TName, Kysely<DB>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Kysely<DB>>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift.\n\t */\n\tprivate readonly config: { url: string; ownerUrl: string };\n\tprivate readonly schemaName: string;\n\tprivate readonly roles: boolean;\n\tprivate readonly runtime: { version: PostgresVersion } | { image: string };\n\tprivate readonly derivedFrom?: DerivedFrom;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: KyselyDatabaseOptions = {},\n\t\tderivedFrom?: DerivedFrom,\n\t) {\n\t\t// Canonicalises, so `orders` and `Orders` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.config = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\townerUrl: provideKey(canonical, 'ownerUrl'),\n\t\t};\n\t\tthis.schemaName = options.schema ?? DEFAULT_SCHEMA;\n\t\tthis.roles = options.roles ?? true;\n\t\tthis.runtime = options.image\n\t\t\t? { image: options.image }\n\t\t\t: { version: options.version ?? DEFAULT_POSTGRES_VERSION };\n\t\tthis.derivedFrom = derivedFrom;\n\n\t\t// A field, not a getter: service discovery caches by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\t// Forwards the whole options object — cherry-picking `envParser` strips\n\t\t\t// `context` and with it the request-scoped logger.\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tif (this.derivedFrom) {\n\t\t\tconst { kind, of, schema } = this.derivedFrom;\n\n\t\t\treturn [\n\t\t\t\tkind === 'database-schema'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\tschema: schema ?? this.schemaName,\n\t\t\t\t\t\t\t// The runtime key alone — see the note below on the parent.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\t// A reader has no owner URL of its own — nothing migrates\n\t\t\t\t\t\t\t// through a read-only endpoint — so this is the one key.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'database',\n\t\t\t\tid: this.id,\n\t\t\t\tengine: 'postgres',\n\t\t\t\tschema: this.schemaName,\n\t\t\t\t// A version, or the image whose tag is one — never both.\n\t\t\t\t...this.runtime,\n\t\t\t\t...(this.options.extensions?.length\n\t\t\t\t\t? { extensions: [...new Set(this.options.extensions)] }\n\t\t\t\t\t: {}),\n\t\t\t\t// One key, the runtime role's. `config` also holds the owner key and\n\t\t\t\t// it is deliberately absent here: a key in `provides` is a key an\n\t\t\t\t// edge can name, and nothing should be able to depend on DDL rights.\n\t\t\t\tprovides: [this.config.url],\n\t\t\t\t...(this.roles ? {} : { roles: false }),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * A read-only endpoint on this database.\n\t *\n\t * Read-only is enforced by the reader role's grants rather than by which\n\t * endpoint it resolves to, so falling back to the writer where no replica\n\t * exists is safe rather than a silently writable connection behind a name\n\t * that says reader. There is no `writer()`: the database *is* the writer, so\n\t * a replica can never be reached by accident.\n\t *\n\t * The return type is narrower than this class on purpose — see\n\t * {@link ReadOnlyDatabase}.\n\t */\n\treader(): ReadOnlyDatabase<DB, `${TName}Reader`> {\n\t\treturn new KyselyDatabase<DB, `${TName}Reader`>(\n\t\t\t`${this.id}Reader` as ConstructName<`${TName}Reader`>,\n\t\t\tthis.options,\n\t\t\t{ kind: 'database-reader', of: this.id },\n\t\t);\n\t}\n\n\t/**\n\t * A cache that lives in this database.\n\t *\n\t * The same strengthening `schema()` is over a second database: `new\n\t * Cache('Sessions')` says the app caches and leaves where to the deployment,\n\t * while this says it caches *here* — which is a fact about the application\n\t * and so belongs in its code.\n\t *\n\t * What it buys beyond being explicit: the table's schema and the role that\n\t * reaches it come from this database rather than from a second convention,\n\t * and the backend no longer has to guess which database \"the database\" meant\n\t * when an app declares two.\n\t *\n\t * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client\n\t * is a key/value store, not a query builder, and typing it as the parent\n\t * would be a convenience that lies.\n\t */\n\tcache<TCache extends string = `${TName}Cache`>(\n\t\tid: ConstructName<TCache> = `${this.id}Cache` as ConstructName<TCache>,\n\t\toptions: { table?: string } = {},\n\t): Cache<TCache> {\n\t\treturn new Cache<TCache>(id, {\n\t\t\tof: this.id,\n\t\t\t...(options.table ? { table: options.table } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * A second schema in this database, with its own role(s) and its own URL —\n\t * so this database's role holds no grant on those tables at all.\n\t *\n\t * Typed separately because a tenant has its own tables: the point is that\n\t * `auth.selectFrom('sessions')` type-checks and\n\t * `orders.selectFrom('sessions')` does not.\n\t */\n\tschema<TenantDB, TTenant extends string>(\n\t\tid: ConstructName<TTenant>,\n\t\toptions: KyselyDatabaseOptions = {},\n\t): KyselyDatabase<TenantDB, TTenant> {\n\t\treturn new KyselyDatabase<TenantDB, TTenant>(id, options, {\n\t\t\tkind: 'database-schema',\n\t\t\tof: this.id,\n\t\t\tschema: options.schema ?? (id as string).toLowerCase(),\n\t\t});\n\t}\n\n\t/**\n\t * A connection as the *owner* role — the one that may create, alter and drop.\n\t *\n\t * A `Service` rather than part of the construct, and deliberately so: a\n\t * construct is what `.dependsOn()` accepts, and nothing should be able to\n\t * depend on this. A migrator asks for it by name; a handler cannot ask at\n\t * all, which is the security property the role split exists for.\n\t *\n\t * Falls back to the runtime URL where no owner URL was published — the\n\t * `roles: false` downgrade, where there is only one credential and it is the\n\t * cluster master's.\n\t */\n\tget owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>> {\n\t\treturn {\n\t\t\tserviceName:\n\t\t\t\t`${serviceKey(this.id)}Owner` as `${Uncapitalize<TName>}Owner`,\n\t\t\tregister: (options) => this.connect(options, { owner: true }),\n\t\t};\n\t}\n\n\t/**\n\t * What this database's clients are built with besides a dialect — the\n\t * plugins and logging it was declared with.\n\t *\n\t * Public so that whatever opens a connection to it outside \\`connect()\\` —\n\t * a test's transaction — builds the same client. A test that dropped the\n\t * plugins would write \\`createdAt\\` where production writes \\`created_at\\`.\n\t */\n\tget clientConfig(): Omit<KyselyConfig, 'dialect'> {\n\t\t// Split what the manifest declared from what Kysely takes, so neither\n\t\t// leaks into the other: \\`schema\\`, \\`roles\\`, \\`version\\`, \\`image\\`\n\t\t// and \\`extensions\\` describe infrastructure and mean nothing to a\n\t\t// client.\n\t\tconst {\n\t\t\tschema: _schema,\n\t\t\troles: _roles,\n\t\t\tversion: _version,\n\t\t\timage: _image,\n\t\t\textensions: _extensions,\n\t\t\tqueryTags: _queryTags,\n\t\t\t...kysely\n\t\t} = this.options;\n\t\treturn kysely;\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<Kysely<DB>> {\n\t\tconst { url, ownerUrl } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.config.url).string(),\n\t\t\t\townerUrl: get(this.config.ownerUrl).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\treturn new Kysely<DB>({\n\t\t\t...this.clientConfig,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: openPool(as.owner ? (ownerUrl ?? url) : url, {\n\t\t\t\t\tqueryTags: this.options.queryTags,\n\t\t\t\t}),\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/**\n * A database you may read through, and derive nothing from.\n *\n * A reader is terminal in the graph, and this is that fact in the type system.\n * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`\n * parent, and there is no reader of a reader — so `orders.reader().cache(…)`\n * has always been illegal, but it type-checked and failed later at\n * `assertDerivations`. That is a long way round to learn that a read-only\n * endpoint cannot own a table something writes to.\n *\n * Omitting the three deriving methods rather than making them throw keeps the\n * failure where it costs least: the editor, on the line that wrote it.\n *\n * The result is deliberately not assignable back to `KyselyDatabase` — a\n * reader is not one, and anything that genuinely needs the writer should say\n * so.\n */\nexport type ReadOnlyDatabase<DB, TName extends string> = Omit<\n\tKyselyDatabase<DB, TName>,\n\t'reader' | 'cache' | 'schema'\n>;\nexport { closeDatabasePools } from './pool';\n"],"mappings":";;;;;;;;;;AAgDA,MAAM,uBAAO,IAAI,IAAa;AAC9BA,iBAAAA,iBAAiB,mBAAmB,CAAC;;;;;;;;;;;AAYrC,SAAgB,SACf,KACA,UAA+B,CAAC,GACtB;CACV,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,aAAa,IAAI,aAAa;CACxD,OAAO,aAAa,OAAO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K;GACT,QAAQ,QAAQ,UAAW,GAAc,YAAY;EACtD,CAAC;CACF;;;;;;;;;;;;;CAcA,IAAI,QAA4D;EAC/D,OAAO;GACN,aACC,IAAA,GAAGD,oBAAAA,WAAAA,CAAW,KAAK,EAAE,EAAE;GACxB,WAAW,YAAY,KAAK,QAAQ,SAAS,EAAE,OAAO,KAAK,CAAC;EAC7D;CACD;;;;;;;;;CAUA,IAAI,eAA8C;EAKjD,MAAM,EACL,QAAQ,SACR,OAAO,QACP,SAAS,UACT,OAAO,QACP,YAAY,aACZ,WAAW,YACX,GAAGE,aACA,KAAK;EACT,OAAOA;CACR;CAEA,MAAc,QACb,SACA,KAA0B,CAAC,GACL;EACtB,MAAM,EAAE,KAAK,aAAa,QAAQ,UAChC,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,OAAO,GAAG,CAAC,CAAC,OAAO;GACjC,UAAU,IAAI,KAAK,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;EACvD,EAAE,CAAC,CACF,MAAM;EAER,OAAO,IAAIC,OAAAA,OAAW;GACrB,GAAG,KAAK;GACR,SAAS,IAAIC,OAAAA,gBAAgB,EAC5B,MAAM,SAAS,GAAG,QAAS,YAAY,MAAO,KAAK,EAClD,WAAW,KAAK,QAAQ,UACzB,CAAC,EACF,CAAC;EACF,CAAC;CACF;AACD"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Context } from "aws-lambda";
|
|
2
|
-
|
|
3
|
-
//#region src/telemetry.d.ts
|
|
4
|
-
|
|
2
|
+
//#region src/endpoints/lambdaTelemetry.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Context object returned by onRequestStart, passed to subsequent hooks
|
|
7
5
|
*/
|
|
@@ -89,7 +87,6 @@ interface Telemetry {
|
|
|
89
87
|
*/
|
|
90
88
|
onRequestError(ctx: TelemetryContext, error: Error): void;
|
|
91
89
|
}
|
|
92
|
-
//# sourceMappingURL=telemetry.d.ts.map
|
|
93
90
|
//#endregion
|
|
94
|
-
export {
|
|
95
|
-
//# sourceMappingURL=
|
|
91
|
+
export { TelemetryResponse as i, TelemetryContext as n, TelemetryRequest as r, Telemetry as t };
|
|
92
|
+
//# sourceMappingURL=lambdaTelemetry-8vnmVZQ5.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambdaTelemetry-8vnmVZQ5.d.cts","names":["LambdaContext"],"sources":["../src/endpoints/lambdaTelemetry.ts"],"mappings":";;;;;UAWiB;;;;GAIf;;;;;UAMe;;;;EAIhB;;;;EAKA,SAASA;;;;;UAMO;;;;EAIhB;;;;EAKA;;;;EAKA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BM;;;;;;;EAOhB,eAAe,SAAS,mBAAmB;;;;;;;EAQ3C,aAAa,KAAK,kBAAkB,UAAU;;;;;;;EAQ9C,eAAe,KAAK,kBAAkB,OAAO"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Context } from "aws-lambda";
|
|
2
|
-
|
|
3
|
-
//#region src/telemetry.d.ts
|
|
4
|
-
|
|
2
|
+
//#region src/endpoints/lambdaTelemetry.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Context object returned by onRequestStart, passed to subsequent hooks
|
|
7
5
|
*/
|
|
@@ -89,7 +87,6 @@ interface Telemetry {
|
|
|
89
87
|
*/
|
|
90
88
|
onRequestError(ctx: TelemetryContext, error: Error): void;
|
|
91
89
|
}
|
|
92
|
-
//# sourceMappingURL=telemetry.d.ts.map
|
|
93
90
|
//#endregion
|
|
94
|
-
export {
|
|
95
|
-
//# sourceMappingURL=
|
|
91
|
+
export { TelemetryResponse as i, TelemetryContext as n, TelemetryRequest as r, Telemetry as t };
|
|
92
|
+
//# sourceMappingURL=lambdaTelemetry-8vnmVZQ5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lambdaTelemetry-8vnmVZQ5.d.mts","names":["LambdaContext"],"sources":["../src/endpoints/lambdaTelemetry.ts"],"mappings":";;;;;UAWiB;;;;GAIf;;;;;UAMe;;;;EAIhB;;;;EAKA,SAASA;;;;;UAMO;;;;EAIhB;;;;EAKA;;;;EAKA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BM;;;;;;;EAOhB,eAAe,SAAS,mBAAmB;;;;;;;EAQ3C,aAAa,KAAK,kBAAkB,UAAU;;;;;;;EAQ9C,eAAe,KAAK,kBAAkB,OAAO"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_construct_interface = require("./construct-interface.cjs");
|
|
3
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
4
|
+
//#region src/mobile-app.ts
|
|
5
|
+
/**
|
|
6
|
+
* `MobileApp` — an Expo app, declared like a site.
|
|
7
|
+
*
|
|
8
|
+
* Its edges are the point, as a site's are. One `.dependsOn([api, auth])` is
|
|
9
|
+
* the fact behind everything a mobile app otherwise has written down by hand:
|
|
10
|
+
*
|
|
11
|
+
* - its `EXPO_PUBLIC_API_URL` and `EXPO_PUBLIC_AUTH_URL`, which locally are
|
|
12
|
+
* the servers' own ports — reachable once the app swaps `localhost` for the
|
|
13
|
+
* address Metro is served from, which is what makes a phone on the LAN work;
|
|
14
|
+
* - with an `Email` among them, Mailpit's inbox on a local stage
|
|
15
|
+
* (`EXPO_PUBLIC_<ID>_INBOX_URL`), so a sign-in link can be opened from the
|
|
16
|
+
* app — unset deployed, where there is no inbox;
|
|
17
|
+
* - its URL scheme (`shop`), the same on every stage;
|
|
18
|
+
* - the scheme in the auth server's and the API's trusted origins — and, on a
|
|
19
|
+
* local stage, the `exp://` origins Expo Go sends from;
|
|
20
|
+
* - Better Auth's Expo plugin on the auth server, and sign-in links an app asks
|
|
21
|
+
* for built on an address the phone can open.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* export const app = new MobileApp('App', { path: 'apps/app' })
|
|
25
|
+
* .dependsOn([api, auth]);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Like a site it has no `.service`: it is built by its own toolchain, and
|
|
29
|
+
* consumes addresses rather than connections. Nothing deploys it — EAS and the
|
|
30
|
+
* stores do — so the targets derive *for* it and never run it.
|
|
31
|
+
*/
|
|
32
|
+
var MobileApp = class MobileApp {
|
|
33
|
+
config;
|
|
34
|
+
dependencies;
|
|
35
|
+
id;
|
|
36
|
+
/** The key its scheme arrives under — what its `app.config.ts` reads. */
|
|
37
|
+
keys;
|
|
38
|
+
constructor(id, config, dependencies = []) {
|
|
39
|
+
this.config = config;
|
|
40
|
+
this.dependencies = dependencies;
|
|
41
|
+
this.id = (0, _geekmidas_manifest.canonicalId)(id);
|
|
42
|
+
this.keys = { scheme: (0, _geekmidas_manifest.provideKey)(this.id, "scheme") };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* What this app calls — the surfaces it is built with the URLs of, and the
|
|
46
|
+
* ones that come to trust its scheme.
|
|
47
|
+
*
|
|
48
|
+
* Immutable, like every other builder: it returns a new app rather than
|
|
49
|
+
* changing this one.
|
|
50
|
+
*/
|
|
51
|
+
dependsOn(constructs) {
|
|
52
|
+
return new MobileApp(this.id, this.config, [...this.dependencies, ...constructs.map(require_construct_interface.edgeTo)]);
|
|
53
|
+
}
|
|
54
|
+
declare() {
|
|
55
|
+
return [{
|
|
56
|
+
kind: "mobile-app",
|
|
57
|
+
id: this.id,
|
|
58
|
+
variant: this.config.variant ?? "expo",
|
|
59
|
+
app: {
|
|
60
|
+
path: this.config.path,
|
|
61
|
+
...this.config.port ? { port: this.config.port } : {},
|
|
62
|
+
...this.config.config ? { config: this.config.config } : {}
|
|
63
|
+
},
|
|
64
|
+
...this.config.scheme ? { scheme: this.config.scheme } : {},
|
|
65
|
+
...this.config.stages ? { stages: this.config.stages } : {},
|
|
66
|
+
dependencies: this.dependencies,
|
|
67
|
+
provides: [this.keys.scheme]
|
|
68
|
+
}];
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.MobileApp = MobileApp;
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=mobile-app.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mobile-app.cjs","names":["canonicalId","provideKey","edgeTo"],"sources":["../src/mobile-app.ts"],"sourcesContent":["/**\n * `MobileApp` — an Expo app, declared like a site.\n *\n * Its edges are the point, as a site's are. One `.dependsOn([api, auth])` is\n * the fact behind everything a mobile app otherwise has written down by hand:\n *\n * - its `EXPO_PUBLIC_API_URL` and `EXPO_PUBLIC_AUTH_URL`, which locally are\n * the servers' own ports — reachable once the app swaps `localhost` for the\n * address Metro is served from, which is what makes a phone on the LAN work;\n * - with an `Email` among them, Mailpit's inbox on a local stage\n * (`EXPO_PUBLIC_<ID>_INBOX_URL`), so a sign-in link can be opened from the\n * app — unset deployed, where there is no inbox;\n * - its URL scheme (`shop`), the same on every stage;\n * - the scheme in the auth server's and the API's trusted origins — and, on a\n * local stage, the `exp://` origins Expo Go sends from;\n * - Better Auth's Expo plugin on the auth server, and sign-in links an app asks\n * for built on an address the phone can open.\n *\n * ```ts\n * export const app = new MobileApp('App', { path: 'apps/app' })\n * .dependsOn([api, auth]);\n * ```\n *\n * Like a site it has no `.service`: it is built by its own toolchain, and\n * consumes addresses rather than connections. Nothing deploys it — EAS and the\n * stores do — so the targets derive *for* it and never run it.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n\ttype MobileAppDeclaration,\n\ttype MobileAppStage,\n\tprovideKey,\n} from '@geekmidas/manifest';\nimport { type Declarable, edgeTo } from './construct-interface';\n\nexport interface MobileAppConfig {\n\t/**\n\t * Where its source lives, relative to the workspace root — `'apps/app'`.\n\t * Required, the same field a site and a surface take.\n\t */\n\tpath: string;\n\t/**\n\t * The port Metro serves it on locally.\n\t *\n\t * Normally omitted: ports are assigned in a stable order, as a site's are,\n\t * and `gkm exec` hands it to Expo as `RCT_METRO_PORT`.\n\t */\n\tport?: number;\n\t/**\n\t * Modules to import when sniffing which env vars the app reads — its\n\t * values are inlined at build time, as a site's are.\n\t */\n\tconfig?: { client?: string; server?: string };\n\t/**\n\t * Which toolchain builds it — the same field a site names its framework\n\t * by. Expo is the one that ships, and the default.\n\t */\n\tvariant?: MobileAppDeclaration['variant'];\n\t/**\n\t * Its URL scheme.\n\t *\n\t * Normally omitted: it is the project's name — `shop` — on every stage.\n\t * Give one only when the app is known by another name.\n\t */\n\tscheme?: string;\n\t/**\n\t * How a deployed stage ships it, where that differs from the defaults: the\n\t * protected stage reads EAS's `production` environment and submits to\n\t * Play's `production` track, every other deployed stage `preview` and\n\t * `internal`, and every Android release is a `draft` until someone\n\t * releases it in Play Console.\n\t *\n\t * ```ts\n\t * stages: { beta: { environment: 'preview', android: { track: 'alpha' } } }\n\t * ```\n\t */\n\tstages?: Readonly<Record<string, MobileAppStage>>;\n}\n\nexport class MobileApp<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\t/** The key its scheme arrives under — what its `app.config.ts` reads. */\n\treadonly keys: { scheme: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: MobileAppConfig,\n\t\t/** Internal: how `.dependsOn()` carries edges into the copy it returns. */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tthis.id = canonicalId(id as string) as TName;\n\t\tthis.keys = { scheme: provideKey(this.id, 'scheme') };\n\t}\n\n\t/**\n\t * What this app calls — the surfaces it is built with the URLs of, and the\n\t * ones that come to trust its scheme.\n\t *\n\t * Immutable, like every other builder: it returns a new app rather than\n\t * changing this one.\n\t */\n\tdependsOn(constructs: readonly Declarable[]): MobileApp<TName> {\n\t\treturn new MobileApp<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(edgeTo),\n\t\t]);\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'mobile-app',\n\t\t\t\tid: this.id,\n\t\t\t\tvariant: this.config.variant ?? 'expo',\n\t\t\t\tapp: {\n\t\t\t\t\tpath: this.config.path,\n\t\t\t\t\t...(this.config.port ? { port: this.config.port } : {}),\n\t\t\t\t\t...(this.config.config ? { config: this.config.config } : {}),\n\t\t\t\t},\n\t\t\t\t...(this.config.scheme ? { scheme: this.config.scheme } : {}),\n\t\t\t\t...(this.config.stages ? { stages: this.config.stages } : {}),\n\t\t\t\tdependencies: this.dependencies,\n\t\t\t\tprovides: [this.keys.scheme],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,IAAa,YAAb,MAAa,UAEb;CAOmB;CAEA;CARlB;;CAEA;CAEA,YACC,IACA,QAEA,eAAuD,CAAC,GACvD;EAHgB,KAAA,SAAA;EAEA,KAAA,eAAA;EAEjB,KAAK,MAAA,GAAKA,oBAAAA,YAAAA,CAAY,EAAY;EAClC,KAAK,OAAO,EAAE,SAAA,GAAQC,oBAAAA,WAAAA,CAAW,KAAK,IAAI,QAAQ,EAAE;CACrD;;;;;;;;CASA,UAAU,YAAqD;EAC9D,OAAO,IAAI,UAAiB,KAAK,IAA4B,KAAK,QAAQ,CACzE,GAAG,KAAK,cACR,GAAG,WAAW,IAAIC,4BAAAA,MAAM,CACzB,CAAC;CACF;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,SAAS,KAAK,OAAO,WAAW;GAChC,KAAK;IACJ,MAAM,KAAK,OAAO;IAClB,GAAI,KAAK,OAAO,OAAO,EAAE,MAAM,KAAK,OAAO,KAAK,IAAI,CAAC;IACrD,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC5D;GACA,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC3D,GAAI,KAAK,OAAO,SAAS,EAAE,QAAQ,KAAK,OAAO,OAAO,IAAI,CAAC;GAC3D,cAAc,KAAK;GACnB,UAAU,CAAC,KAAK,KAAK,MAAM;EAC5B,CACD;CACD;AACD"}
|