@geekmidas/constructs 7.0.1 → 10.0.0-alpha.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/README.md +71 -44
- package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-BvFvBsBN.d.cts} +10 -5
- package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-BvFvBsBN.d.cts.map} +1 -1
- package/dist/{AWSScheduledFunction-CTIa90EH.d.cts → AWSScheduledFunction-CVccZO-L.d.mts} +10 -5
- package/dist/{AWSScheduledFunction-CTIa90EH.d.cts.map → AWSScheduledFunction-CVccZO-L.d.mts.map} +1 -1
- package/dist/{AWSScheduledFunction-CufMMhGB.mjs → AWSScheduledFunction-Db1lttJH.mjs} +3 -3
- package/dist/{AWSScheduledFunction-CufMMhGB.mjs.map → AWSScheduledFunction-Db1lttJH.mjs.map} +1 -1
- package/dist/{AWSScheduledFunction-DbkDr8CA.cjs → AWSScheduledFunction-qu4ieRZR.cjs} +9 -9
- package/dist/{AWSScheduledFunction-DbkDr8CA.cjs.map → AWSScheduledFunction-qu4ieRZR.cjs.map} +1 -1
- package/dist/{Construct-_1wX7p_Y.d.cts → Construct-B-xc0SE9.d.mts} +27 -5
- package/dist/Construct-B-xc0SE9.d.mts.map +1 -0
- package/dist/{Construct-r0U2zBwW.mjs → Construct-HmWM6YYu.mjs} +4 -3
- package/dist/Construct-HmWM6YYu.mjs.map +1 -0
- package/dist/{Construct-DCMuYOox.d.mts → Construct-WhCXIOPV.d.cts} +29 -7
- package/dist/Construct-WhCXIOPV.d.cts.map +1 -0
- package/dist/{Construct-vXMZJgRp.cjs → Construct-roId57cU.cjs} +7 -43
- package/dist/Construct-roId57cU.cjs.map +1 -0
- package/dist/{lazyAccessors-DmTG8sQH.cjs → Endpoint-BBkV6l0k.cjs} +869 -1079
- package/dist/Endpoint-BBkV6l0k.cjs.map +1 -0
- package/dist/{lazyAccessors-DfqZR6C4.mjs → Endpoint-BGwpNEX4.mjs} +840 -1003
- package/dist/Endpoint-BGwpNEX4.mjs.map +1 -0
- package/dist/{Endpoint-CAzNbDEt.d.cts → Endpoint-BnxZqIX-.d.cts} +53 -4
- package/dist/Endpoint-BnxZqIX-.d.cts.map +1 -0
- package/dist/{Endpoint-CLPSIl6S.d.mts → Endpoint-ROcXU-eH.d.mts} +55 -6
- package/dist/Endpoint-ROcXU-eH.d.mts.map +1 -0
- package/dist/EndpointFactory-DYoGLaIT.cjs +850 -0
- package/dist/EndpointFactory-DYoGLaIT.cjs.map +1 -0
- package/dist/EndpointFactory-Di0X9AWp.mjs +808 -0
- package/dist/EndpointFactory-Di0X9AWp.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-DJDT3PMx.mjs → HonoEndpointAdaptor-DFKIIG2o.mjs} +5 -4
- package/dist/HonoEndpointAdaptor-DFKIIG2o.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-CkJENANP.cjs → HonoEndpointAdaptor-wMsCyMgt.cjs} +24 -23
- package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +1 -0
- package/dist/{Queue-DaxjwmOQ.d.cts → Queue-D6WeziRD.d.cts} +43 -4
- package/dist/Queue-D6WeziRD.d.cts.map +1 -0
- package/dist/{Queue-HBDf0fqz.d.mts → Queue-DpUeqdC8.d.mts} +43 -4
- package/dist/Queue-DpUeqdC8.d.mts.map +1 -0
- package/dist/{Subscriber-B69ngPwl.d.cts → Subscriber-4rBJgDKI.d.mts} +9 -4
- package/dist/{Subscriber-B69ngPwl.d.cts.map → Subscriber-4rBJgDKI.d.mts.map} +1 -1
- package/dist/{Subscriber-D8Xm-86W.d.mts → Subscriber-DVQowdyj.d.cts} +11 -6
- package/dist/Subscriber-DVQowdyj.d.cts.map +1 -0
- package/dist/{Topic-C5ZMfveW.d.cts → Topic-Ohx9dvWr.d.cts} +33 -2
- package/dist/Topic-Ohx9dvWr.d.cts.map +1 -0
- package/dist/{Topic-DT10AqHk.d.mts → Topic-cmy2jOUy.d.mts} +33 -2
- package/dist/Topic-cmy2jOUy.d.mts.map +1 -0
- package/dist/adaptors/aws.cjs +39 -26
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +24 -16
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +25 -17
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +26 -14
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +9 -6
- package/dist/adaptors/hono.d.cts +7 -6
- package/dist/adaptors/hono.d.cts.map +1 -1
- package/dist/adaptors/hono.d.mts +8 -7
- package/dist/adaptors/hono.d.mts.map +1 -1
- package/dist/adaptors/hono.mjs +9 -6
- package/dist/adaptors/testing.cjs +18 -14
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +7 -6
- package/dist/adaptors/testing.d.cts.map +1 -1
- package/dist/adaptors/testing.d.mts +11 -10
- package/dist/adaptors/testing.d.mts.map +1 -1
- package/dist/adaptors/testing.mjs +10 -7
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth.cjs +165 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +108 -0
- package/dist/auth.d.cts.map +1 -0
- package/dist/auth.d.mts +108 -0
- package/dist/auth.d.mts.map +1 -0
- package/dist/auth.mjs +164 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/cache-0ANvRQnD.mjs +51 -0
- package/dist/cache-0ANvRQnD.mjs.map +1 -0
- package/dist/cache-3WSvAulx.cjs +57 -0
- package/dist/cache-3WSvAulx.cjs.map +1 -0
- package/dist/cache-CdQ7OLpR.d.cts +47 -0
- package/dist/cache-CdQ7OLpR.d.cts.map +1 -0
- package/dist/cache-DYoJFcfd.d.mts +47 -0
- package/dist/cache-DYoJFcfd.d.mts.map +1 -0
- package/dist/cache.cjs +3 -0
- package/dist/cache.d.cts +3 -0
- package/dist/cache.d.mts +3 -0
- package/dist/cache.mjs +3 -0
- package/dist/chunk-DWy1uDak.cjs +39 -0
- package/dist/clone-DblgEZZa.mjs +39 -0
- package/dist/clone-DblgEZZa.mjs.map +1 -0
- package/dist/clone-Dy0cR2SZ.cjs +45 -0
- package/dist/clone-Dy0cR2SZ.cjs.map +1 -0
- package/dist/construct-interface-BfjcOD_E.cjs +117 -0
- package/dist/construct-interface-BfjcOD_E.cjs.map +1 -0
- package/dist/construct-interface-BqwRNYA2.d.mts +131 -0
- package/dist/construct-interface-BqwRNYA2.d.mts.map +1 -0
- package/dist/construct-interface-D2nNkHUN.d.cts +131 -0
- package/dist/construct-interface-D2nNkHUN.d.cts.map +1 -0
- package/dist/construct-interface-Z4CpS8tK.mjs +81 -0
- package/dist/construct-interface-Z4CpS8tK.mjs.map +1 -0
- package/dist/construct-interface.cjs +8 -0
- package/dist/construct-interface.d.cts +2 -0
- package/dist/construct-interface.d.mts +2 -0
- package/dist/construct-interface.mjs +3 -0
- package/dist/credential.cjs +96 -0
- package/dist/credential.cjs.map +1 -0
- package/dist/credential.d.cts +61 -0
- package/dist/credential.d.cts.map +1 -0
- package/dist/credential.d.mts +61 -0
- package/dist/credential.d.mts.map +1 -0
- package/dist/credential.mjs +94 -0
- package/dist/credential.mjs.map +1 -0
- package/dist/crons/index.cjs +39 -37
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +21 -8
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +29 -13
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +37 -36
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.cjs +181 -0
- package/dist/database/kysely.cjs.map +1 -0
- package/dist/database/kysely.d.cts +152 -0
- package/dist/database/kysely.d.cts.map +1 -0
- package/dist/database/kysely.d.mts +152 -0
- package/dist/database/kysely.d.mts.map +1 -0
- package/dist/database/kysely.mjs +180 -0
- package/dist/database/kysely.mjs.map +1 -0
- package/dist/email.cjs +59 -0
- package/dist/email.cjs.map +1 -0
- package/dist/email.d.cts +50 -0
- package/dist/email.d.cts.map +1 -0
- package/dist/email.d.mts +50 -0
- package/dist/email.d.mts.map +1 -0
- package/dist/email.mjs +58 -0
- package/dist/email.mjs.map +1 -0
- package/dist/endpoints/index.cjs +21 -747
- package/dist/endpoints/index.d.cts +7 -343
- package/dist/endpoints/index.d.mts +7 -342
- package/dist/endpoints/index.mjs +11 -738
- package/dist/file-server.cjs +154 -0
- package/dist/file-server.cjs.map +1 -0
- package/dist/file-server.d.cts +156 -0
- package/dist/file-server.d.cts.map +1 -0
- package/dist/file-server.d.mts +156 -0
- package/dist/file-server.d.mts.map +1 -0
- package/dist/file-server.mjs +152 -0
- package/dist/file-server.mjs.map +1 -0
- package/dist/functions/index.cjs +4 -2
- package/dist/functions/index.d.cts +3 -2
- package/dist/functions/index.d.mts +3 -2
- package/dist/functions/index.mjs +4 -2
- package/dist/{functions-B-qt91O7.mjs → functions-CvT_q7Y4.mjs} +55 -51
- package/dist/functions-CvT_q7Y4.mjs.map +1 -0
- package/dist/{functions-C8i1kCMM.cjs → functions-DukjG8ov.cjs} +62 -57
- package/dist/functions-DukjG8ov.cjs.map +1 -0
- package/dist/index-7OcOWe75.d.cts +419 -0
- package/dist/index-7OcOWe75.d.cts.map +1 -0
- package/dist/index-Bt-F7u8L.d.mts +419 -0
- package/dist/index-Bt-F7u8L.d.mts.map +1 -0
- package/dist/{index-DP6fqv0I.d.mts → index-CPeqtKgq.d.mts} +48 -19
- package/dist/index-CPeqtKgq.d.mts.map +1 -0
- package/dist/{index-BGeTScmi.d.cts → index-Dadljnh_.d.cts} +36 -9
- package/dist/index-Dadljnh_.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/lazyAccessors-DM6HcXQk.mjs +175 -0
- package/dist/lazyAccessors-DM6HcXQk.mjs.map +1 -0
- package/dist/lazyAccessors-DrJj8NpA.cjs +223 -0
- package/dist/lazyAccessors-DrJj8NpA.cjs.map +1 -0
- package/dist/object-storage.cjs +48 -0
- package/dist/object-storage.cjs.map +1 -0
- package/dist/object-storage.d.cts +36 -0
- package/dist/object-storage.d.cts.map +1 -0
- package/dist/object-storage.d.mts +36 -0
- package/dist/object-storage.d.mts.map +1 -0
- package/dist/object-storage.mjs +47 -0
- package/dist/object-storage.mjs.map +1 -0
- package/dist/{processAudits-CKjjivyz.cjs → processAudits-Bc8rz6Ev.cjs} +3 -3
- package/dist/{processAudits-CKjjivyz.cjs.map → processAudits-Bc8rz6Ev.cjs.map} +1 -1
- package/dist/{processAudits-ySnizdMG.mjs → processAudits-D89tICM4.mjs} +1 -1
- package/dist/{processAudits-ySnizdMG.mjs.map → processAudits-D89tICM4.mjs.map} +1 -1
- package/dist/{publisher-BrFOF847.mjs → publisher-CGEo8UKD.mjs} +1 -1
- package/dist/{publisher-BrFOF847.mjs.map → publisher-CGEo8UKD.mjs.map} +1 -1
- package/dist/{publisher-lFQleddL.cjs → publisher-CqGsXB2X.cjs} +1 -1
- package/dist/{publisher-lFQleddL.cjs.map → publisher-CqGsXB2X.cjs.map} +1 -1
- package/dist/queue/index.cjs +92 -30
- package/dist/queue/index.cjs.map +1 -1
- package/dist/queue/index.d.cts +19 -4
- package/dist/queue/index.d.cts.map +1 -1
- package/dist/queue/index.d.mts +22 -6
- package/dist/queue/index.d.mts.map +1 -1
- package/dist/queue/index.mjs +90 -29
- package/dist/queue/index.mjs.map +1 -1
- package/dist/rest-api.cjs +187 -0
- package/dist/rest-api.cjs.map +1 -0
- package/dist/rest-api.d.cts +221 -0
- package/dist/rest-api.d.cts.map +1 -0
- package/dist/rest-api.d.mts +221 -0
- package/dist/rest-api.d.mts.map +1 -0
- package/dist/rest-api.mjs +186 -0
- package/dist/rest-api.mjs.map +1 -0
- package/dist/site.cjs +48 -0
- package/dist/site.cjs.map +1 -0
- package/dist/site.d.cts +101 -0
- package/dist/site.d.cts.map +1 -0
- package/dist/site.d.mts +101 -0
- package/dist/site.d.mts.map +1 -0
- package/dist/site.mjs +47 -0
- package/dist/site.mjs.map +1 -0
- package/dist/subscribers/index.cjs +35 -27
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +20 -5
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +23 -7
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +34 -27
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/surfaceEnv-BFXEms2f.cjs +39 -0
- package/dist/surfaceEnv-BFXEms2f.cjs.map +1 -0
- package/dist/surfaceEnv-C3Ktahea.mjs +27 -0
- package/dist/surfaceEnv-C3Ktahea.mjs.map +1 -0
- package/dist/{telemetry-3vdxGn4q.d.mts → telemetry-C3L0iS28.d.cts} +2 -2
- package/dist/{telemetry-3vdxGn4q.d.mts.map → telemetry-C3L0iS28.d.cts.map} +1 -1
- package/dist/{telemetry-Dqx-D3F7.d.cts → telemetry-D7bVFLGi.d.mts} +2 -2
- package/dist/{telemetry-Dqx-D3F7.d.cts.map → telemetry-D7bVFLGi.d.mts.map} +1 -1
- package/dist/topic/index.cjs +56 -13
- package/dist/topic/index.cjs.map +1 -1
- package/dist/topic/index.d.cts +2 -2
- package/dist/topic/index.d.cts.map +1 -1
- package/dist/topic/index.d.mts +2 -2
- package/dist/topic/index.d.mts.map +1 -1
- package/dist/topic/index.mjs +54 -12
- package/dist/topic/index.mjs.map +1 -1
- package/dist/{types-BDNGr7pv.d.mts → types-BlAkSuGI.d.cts} +1 -1
- package/dist/{types-BDNGr7pv.d.mts.map → types-BlAkSuGI.d.cts.map} +1 -1
- package/dist/{types-BdAaYDvd.d.cts → types-aKksMEWL.d.mts} +1 -1
- package/dist/{types-BdAaYDvd.d.cts.map → types-aKksMEWL.d.mts.map} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +155 -23
- package/CHANGELOG.md +0 -366
- package/dist/Construct-DCMuYOox.d.mts.map +0 -1
- package/dist/Construct-_1wX7p_Y.d.cts.map +0 -1
- package/dist/Construct-r0U2zBwW.mjs.map +0 -1
- package/dist/Construct-vXMZJgRp.cjs.map +0 -1
- package/dist/Endpoint-CAzNbDEt.d.cts.map +0 -1
- package/dist/Endpoint-CLPSIl6S.d.mts.map +0 -1
- package/dist/HonoEndpointAdaptor-CkJENANP.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-DJDT3PMx.mjs.map +0 -1
- package/dist/Queue-DaxjwmOQ.d.cts.map +0 -1
- package/dist/Queue-HBDf0fqz.d.mts.map +0 -1
- package/dist/Subscriber-D8Xm-86W.d.mts.map +0 -1
- package/dist/Topic-C5ZMfveW.d.cts.map +0 -1
- package/dist/Topic-DT10AqHk.d.mts.map +0 -1
- package/dist/endpoints/index.cjs.map +0 -1
- package/dist/endpoints/index.d.cts.map +0 -1
- package/dist/endpoints/index.d.mts.map +0 -1
- package/dist/endpoints/index.mjs.map +0 -1
- package/dist/functions-B-qt91O7.mjs.map +0 -1
- package/dist/functions-C8i1kCMM.cjs.map +0 -1
- package/dist/index-BGeTScmi.d.cts.map +0 -1
- package/dist/index-DP6fqv0I.d.mts.map +0 -1
- package/dist/lazyAccessors-DfqZR6C4.mjs.map +0 -1
- package/dist/lazyAccessors-DmTG8sQH.cjs.map +0 -1
- package/src/Construct.ts +0 -204
- package/src/__benchmarks__/build-time-optimization.bench.ts +0 -274
- package/src/__benchmarks__/endpoint.bench.ts +0 -494
- package/src/__benchmarks__/fixtures.ts +0 -241
- package/src/__benchmarks__/hono-adaptor.bench.ts +0 -533
- package/src/__benchmarks__/hono-server.bench.ts +0 -249
- package/src/__benchmarks__/response-builder.bench.ts +0 -428
- package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +0 -319
- package/src/__benchmarks__/strategies/strategy-c-middleware.ts +0 -530
- package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +0 -567
- package/src/__tests__/Construct.environment.spec.ts +0 -704
- package/src/__tests__/publisher.setting.spec.ts +0 -508
- package/src/__tests__/publisher.spec.ts +0 -452
- package/src/adaptors/aws.ts +0 -6
- package/src/adaptors/hono.ts +0 -1
- package/src/adaptors/testing.ts +0 -11
- package/src/crons/AWSScheduledFunction.ts +0 -73
- package/src/crons/Cron.ts +0 -149
- package/src/crons/CronBuilder.ts +0 -271
- package/src/crons/__tests__/AWSScheduledFunction.spec.ts +0 -152
- package/src/crons/__tests__/Cron.spec.ts +0 -464
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +0 -227
- package/src/crons/index.ts +0 -12
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +0 -677
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +0 -105
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +0 -97
- package/src/endpoints/Authorizer.ts +0 -152
- package/src/endpoints/Endpoint.ts +0 -1287
- package/src/endpoints/EndpointBuilder.ts +0 -758
- package/src/endpoints/EndpointFactory.ts +0 -1148
- package/src/endpoints/HonoEndpointAdaptor.ts +0 -677
- package/src/endpoints/MswEndpointAdaptor.ts +0 -226
- package/src/endpoints/TestEndpointAdaptor.ts +0 -422
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +0 -499
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +0 -560
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +0 -1304
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +0 -626
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +0 -732
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +0 -296
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +0 -951
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +0 -111
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +0 -307
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +0 -629
- package/src/endpoints/__tests__/Authorizer.spec.ts +0 -286
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +0 -207
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +0 -187
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +0 -175
- package/src/endpoints/__tests__/Endpoint.spec.ts +0 -857
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +0 -448
- package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +0 -47
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +0 -523
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +0 -492
- package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +0 -509
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +0 -190
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +0 -479
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +0 -155
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +0 -703
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +0 -632
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +0 -577
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +0 -1067
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +0 -317
- package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +0 -289
- package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +0 -128
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +0 -1207
- package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +0 -211
- package/src/endpoints/__tests__/ResponseBuilder.spec.ts +0 -235
- package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +0 -602
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +0 -1044
- package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +0 -54
- package/src/endpoints/__tests__/endpoint-types.test.ts +0 -88
- package/src/endpoints/__tests__/helpers.spec.ts +0 -37
- package/src/endpoints/__tests__/lazyAccessors.spec.ts +0 -330
- package/src/endpoints/__tests__/processAudits.spec.ts +0 -631
- package/src/endpoints/audit.ts +0 -87
- package/src/endpoints/helpers.ts +0 -98
- package/src/endpoints/index.ts +0 -42
- package/src/endpoints/lazyAccessors.ts +0 -241
- package/src/endpoints/parseHonoQuery.ts +0 -16
- package/src/endpoints/parseQueryParams.ts +0 -32
- package/src/endpoints/processAudits.ts +0 -371
- package/src/endpoints/rls.ts +0 -67
- package/src/functions/AWSLambdaFunction.ts +0 -348
- package/src/functions/BaseFunctionBuilder.ts +0 -201
- package/src/functions/Function.ts +0 -238
- package/src/functions/FunctionBuilder.ts +0 -391
- package/src/functions/FunctionExecutionWrapper.ts +0 -216
- package/src/functions/TestFunctionAdaptor.ts +0 -217
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +0 -513
- package/src/functions/__tests__/Function.audits.spec.ts +0 -393
- package/src/functions/__tests__/Function.spec.ts +0 -477
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +0 -207
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +0 -480
- package/src/functions/index.ts +0 -12
- package/src/index.ts +0 -23
- package/src/publisher.ts +0 -93
- package/src/queue/AWSLambdaQueueAdaptor.ts +0 -162
- package/src/queue/Queue.ts +0 -128
- package/src/queue/QueueBuilder.ts +0 -115
- package/src/queue/TestQueueAdaptor.ts +0 -63
- package/src/queue/__tests__/QueueBuilder.spec.ts +0 -137
- package/src/queue/index.ts +0 -12
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +0 -342
- package/src/subscribers/Subscriber.ts +0 -117
- package/src/subscribers/SubscriberBuilder.ts +0 -186
- package/src/subscribers/TestSubscriberAdaptor.ts +0 -133
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +0 -1018
- package/src/subscribers/__tests__/Subscriber.spec.ts +0 -430
- package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +0 -652
- package/src/subscribers/index.ts +0 -6
- package/src/telemetry.ts +0 -103
- package/src/topic/Topic.ts +0 -103
- package/src/topic/TopicBuilder.ts +0 -51
- package/src/topic/__tests__/TopicBuilder.spec.ts +0 -82
- package/src/topic/index.ts +0 -11
- package/src/types.ts +0 -13
- package/test.ts +0 -91
- package/tsconfig.json +0 -9
- package/tsdown.config.ts +0 -34
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone-DblgEZZa.mjs","names":["instance: T","delta: Record<string, unknown>"],"sources":["../src/clone.ts"],"sourcesContent":["/**\n * Cloning a builder, without enumerating its fields.\n *\n * The builders were mutable singletons that reset themselves by listing every\n * field at the end of `.handle()`. Two things followed from that, and both were\n * real:\n *\n * A configured base could not be reused. `const fn = f.logger(log)` handed back\n * `f` itself, and the first `.handle()` reset `_logger` to the default — so the\n * second handler built from that base silently logged somewhere else. Every\n * field in the reset block behaved the same way, which made\n * `f.logger(l).timeout(60_000)` a base that worked exactly once.\n *\n * And a field left out of the reset list leaked into the next handler instead.\n * `_constructs` was left out, so a function was granted a bucket a *previous*\n * function had declared — an over-grant in the field a deploy reads to size an\n * IAM policy.\n *\n * Both are the same defect: a hand-maintained list of fields that has to be\n * edited every time a field is added, and is silent when it isn't. So this\n * copies whatever the instance actually has, and the list stops existing. The\n * prototype is carried over, so `instanceof` and every method still resolve,\n * and the constructor is deliberately not re-run — this copies state rather\n * than initialising it.\n *\n * Fields must be replaced rather than mutated in place: a clone and its parent\n * share whatever array a field points at, so `_events.push(…)` would be seen by\n * both. Every builder assigns a fresh array instead, which is what makes\n * sharing the reference safe.\n */\nexport function cloneWith<T extends object>(\n\tinstance: T,\n\tdelta: Record<string, unknown>,\n): T {\n\tconst next = Object.create(Object.getPrototypeOf(instance)) as T;\n\n\treturn Object.assign(next, instance, delta);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACfA,UACAC,OACI;CACJ,MAAM,OAAO,OAAO,OAAO,OAAO,eAAe,SAAS,CAAC;AAE3D,QAAO,OAAO,OAAO,MAAM,UAAU,MAAM;AAC3C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/clone.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cloning a builder, without enumerating its fields.
|
|
5
|
+
*
|
|
6
|
+
* The builders were mutable singletons that reset themselves by listing every
|
|
7
|
+
* field at the end of `.handle()`. Two things followed from that, and both were
|
|
8
|
+
* real:
|
|
9
|
+
*
|
|
10
|
+
* A configured base could not be reused. `const fn = f.logger(log)` handed back
|
|
11
|
+
* `f` itself, and the first `.handle()` reset `_logger` to the default — so the
|
|
12
|
+
* second handler built from that base silently logged somewhere else. Every
|
|
13
|
+
* field in the reset block behaved the same way, which made
|
|
14
|
+
* `f.logger(l).timeout(60_000)` a base that worked exactly once.
|
|
15
|
+
*
|
|
16
|
+
* And a field left out of the reset list leaked into the next handler instead.
|
|
17
|
+
* `_constructs` was left out, so a function was granted a bucket a *previous*
|
|
18
|
+
* function had declared — an over-grant in the field a deploy reads to size an
|
|
19
|
+
* IAM policy.
|
|
20
|
+
*
|
|
21
|
+
* Both are the same defect: a hand-maintained list of fields that has to be
|
|
22
|
+
* edited every time a field is added, and is silent when it isn't. So this
|
|
23
|
+
* copies whatever the instance actually has, and the list stops existing. The
|
|
24
|
+
* prototype is carried over, so `instanceof` and every method still resolve,
|
|
25
|
+
* and the constructor is deliberately not re-run — this copies state rather
|
|
26
|
+
* than initialising it.
|
|
27
|
+
*
|
|
28
|
+
* Fields must be replaced rather than mutated in place: a clone and its parent
|
|
29
|
+
* share whatever array a field points at, so `_events.push(…)` would be seen by
|
|
30
|
+
* both. Every builder assigns a fresh array instead, which is what makes
|
|
31
|
+
* sharing the reference safe.
|
|
32
|
+
*/
|
|
33
|
+
function cloneWith(instance, delta) {
|
|
34
|
+
const next = Object.create(Object.getPrototypeOf(instance));
|
|
35
|
+
return Object.assign(next, instance, delta);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
Object.defineProperty(exports, 'cloneWith', {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return cloneWith;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=clone-Dy0cR2SZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone-Dy0cR2SZ.cjs","names":["instance: T","delta: Record<string, unknown>"],"sources":["../src/clone.ts"],"sourcesContent":["/**\n * Cloning a builder, without enumerating its fields.\n *\n * The builders were mutable singletons that reset themselves by listing every\n * field at the end of `.handle()`. Two things followed from that, and both were\n * real:\n *\n * A configured base could not be reused. `const fn = f.logger(log)` handed back\n * `f` itself, and the first `.handle()` reset `_logger` to the default — so the\n * second handler built from that base silently logged somewhere else. Every\n * field in the reset block behaved the same way, which made\n * `f.logger(l).timeout(60_000)` a base that worked exactly once.\n *\n * And a field left out of the reset list leaked into the next handler instead.\n * `_constructs` was left out, so a function was granted a bucket a *previous*\n * function had declared — an over-grant in the field a deploy reads to size an\n * IAM policy.\n *\n * Both are the same defect: a hand-maintained list of fields that has to be\n * edited every time a field is added, and is silent when it isn't. So this\n * copies whatever the instance actually has, and the list stops existing. The\n * prototype is carried over, so `instanceof` and every method still resolve,\n * and the constructor is deliberately not re-run — this copies state rather\n * than initialising it.\n *\n * Fields must be replaced rather than mutated in place: a clone and its parent\n * share whatever array a field points at, so `_events.push(…)` would be seen by\n * both. Every builder assigns a fresh array instead, which is what makes\n * sharing the reference safe.\n */\nexport function cloneWith<T extends object>(\n\tinstance: T,\n\tdelta: Record<string, unknown>,\n): T {\n\tconst next = Object.create(Object.getPrototypeOf(instance)) as T;\n\n\treturn Object.assign(next, instance, delta);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,UACfA,UACAC,OACI;CACJ,MAAM,OAAO,OAAO,OAAO,OAAO,eAAe,SAAS,CAAC;AAE3D,QAAO,OAAO,OAAO,MAAM,UAAU,MAAM;AAC3C"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/construct-interface.ts
|
|
3
|
+
/**
|
|
4
|
+
* The edge that points at a construct.
|
|
5
|
+
*
|
|
6
|
+
* A construct's *canonical* node is the one carrying its own id — the others are
|
|
7
|
+
* things it owns rather than things it is, like the signing secret beside an
|
|
8
|
+
* auth server — so the kind an edge records is read off that node instead of
|
|
9
|
+
* being written down beside it. Hand-written kinds are the same fact stated
|
|
10
|
+
* twice, and the copy is what goes stale when a construct changes what it
|
|
11
|
+
* declares.
|
|
12
|
+
*
|
|
13
|
+
* @throws {NotAConstruct} when the value declares nothing under its own id.
|
|
14
|
+
*/
|
|
15
|
+
function edgeTo(construct) {
|
|
16
|
+
const canonical = construct.declare().find((declaration) => declaration.id === construct.id);
|
|
17
|
+
if (!canonical) throw new NotAConstruct(construct);
|
|
18
|
+
return {
|
|
19
|
+
target: construct.id,
|
|
20
|
+
kind: canonical.kind
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The services of a list of constructs, at runtime.
|
|
25
|
+
*
|
|
26
|
+
* @throws {NotAConstruct} when handed something else. The type already refuses
|
|
27
|
+
* it, but a JavaScript caller gets no such warning, and a `Service` slipping
|
|
28
|
+
* through would fail later as an undefined key in the handler.
|
|
29
|
+
*/
|
|
30
|
+
function servicesOf(constructs) {
|
|
31
|
+
return constructs.map((construct) => {
|
|
32
|
+
if (!isConsumable(construct)) throw new NotAConstruct(construct);
|
|
33
|
+
return construct.service;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The other half of `servicesOf`: the same edge, as the manifest records it.
|
|
38
|
+
*
|
|
39
|
+
* `.dependsOn()` used to keep only the services, which is what a handler runs
|
|
40
|
+
* with — and an id cannot be recovered from a service name reliably, so the
|
|
41
|
+
* edges were gone by the time the build could read them. Both halves are taken
|
|
42
|
+
* from one call now, and `existing` is folded in so repeated `.dependsOn()`
|
|
43
|
+
* calls accumulate the way `.services()` already does.
|
|
44
|
+
*/
|
|
45
|
+
function idsOf(constructs, existing = []) {
|
|
46
|
+
return [...new Set([...existing, ...constructs.map(({ id }) => id)])];
|
|
47
|
+
}
|
|
48
|
+
/** Something that is not a construct was passed to `.dependsOn()`. */
|
|
49
|
+
var NotAConstruct = class extends Error {
|
|
50
|
+
constructor(value) {
|
|
51
|
+
const name = typeof value === "object" && value !== null && "serviceName" in value ? `the service '${String(value.serviceName)}'` : `a ${typeof value}`;
|
|
52
|
+
super(`.dependsOn() takes constructs, and was given ${name}. Pass it to .services([…]) instead, or lift it with Construct.fromService().`);
|
|
53
|
+
this.value = value;
|
|
54
|
+
this.name = "NotAConstruct";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Whether a value is a construct rather than a bare `Service`.
|
|
59
|
+
*
|
|
60
|
+
* Structural rather than `instanceof`: a construct from a second copy of
|
|
61
|
+
* `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
|
|
62
|
+
* still a construct, and `instanceof` is exactly the check that says otherwise.
|
|
63
|
+
*/
|
|
64
|
+
function isConsumable(value) {
|
|
65
|
+
if (typeof value !== "object" || value === null) return false;
|
|
66
|
+
const candidate = value;
|
|
67
|
+
return typeof candidate.id === "string" && typeof candidate.declare === "function" && typeof candidate.service?.serviceName === "string";
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The service behind either face.
|
|
71
|
+
*
|
|
72
|
+
* `.database()` and the publisher slots take a construct now; they took a
|
|
73
|
+
* `Service` before and still do, because a hand-written one is exactly what
|
|
74
|
+
* `Construct.fromService` exists to lift and not everything has been lifted.
|
|
75
|
+
*/
|
|
76
|
+
function serviceOf(source) {
|
|
77
|
+
return isConsumable(source) ? source.service : source;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
Object.defineProperty(exports, 'NotAConstruct', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return NotAConstruct;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, 'edgeTo', {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return edgeTo;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, 'idsOf', {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return idsOf;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(exports, 'isConsumable', {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
get: function () {
|
|
102
|
+
return isConsumable;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, 'serviceOf', {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () {
|
|
108
|
+
return serviceOf;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(exports, 'servicesOf', {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function () {
|
|
114
|
+
return servicesOf;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=construct-interface-BfjcOD_E.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-interface-BfjcOD_E.cjs","names":["construct: Declarable","constructs: T","constructs: readonly Consumable[]","existing: readonly string[]","value: unknown","source: Consumable<TName, TClient> | Service<TName, TClient>"],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * caches by service *object*, and `Topic.publisher` returns a fresh literal\n\t * on every access, so that cache never hits for topics or queues today.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead, or lift it with ` +\n\t\t\t\t`Construct.fromService().`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the publisher slots take a construct now; they took a\n * `Service` before and still do, because a hand-written one is exactly what\n * `Construct.fromService` exists to lift and not everything has been lifted.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n"],"mappings":";;;;;;;;;;;;;;AAgFA,SAAgB,OAAOA,WAAmC;CACzD,MAAM,YAAY,UAChB,SAAS,CACT,KAAK,CAAC,gBAAgB,YAAY,OAAO,UAAU,GAAG;AAExD,MAAK,UAAW,OAAM,IAAI,cAAc;AAExC,QAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAM;AACrD;;;;;;;;AA6CD,SAAgB,WACfC,YACgB;AAChB,QAAO,WAAW,IAAI,CAAC,cAAc;AACpC,OAAK,aAAa,UAAU,CAAE,OAAM,IAAI,cAAc;AAEtD,SAAO,UAAU;CACjB,EAAC;AACF;;;;;;;;;;AAWD,SAAgB,MACfC,YACAC,WAA8B,CAAE,GACrB;AACX,QAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,AAAC,EAAE;AACrE;;AAGD,IAAa,gBAAb,cAAmC,MAAM;CACxC,YAAqBC,OAAgB;EACpC,MAAM,cACE,UAAU,YAAY,UAAU,QAAQ,iBAAiB,SAC5D,eAAe,OAAQ,MAAmC,YAAY,CAAC,MACvE,WAAW,MAAM;AAEtB,SACE,+CAA+C,KAAK,+EAGrD;EAVmB;AAWpB,OAAK,OAAO;CACZ;AACD;;;;;;;;AASD,SAAgB,aAAaA,OAAqC;AACjE,YAAW,UAAU,YAAY,UAAU,KAAM,QAAO;CAExD,MAAM,YAAY;AAElB,eACQ,UAAU,OAAO,mBACjB,UAAU,YAAY,qBACrB,UAAU,SAAiC,gBAAgB;AAEpE;;;;;;;;AASD,SAAgB,UACfC,QAC0B;AAG1B,QAAO,aAAa,OAAO,GACvB,OAAO,UACP;AACJ"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Declaration, Dependency } from "@geekmidas/manifest";
|
|
2
|
+
import { Service } from "@geekmidas/services";
|
|
3
|
+
|
|
4
|
+
//#region src/construct-interface.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
|
|
8
|
+
* literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript
|
|
9
|
+
* intrinsic, so no custom transform needs a runtime twin.
|
|
10
|
+
* @typeParam TClient - what consuming this construct hands you. `never` means it
|
|
11
|
+
* owns no address and cannot be consumed: a `Cron` is fired by a schedule and a
|
|
12
|
+
* `Subscriber` is reached through its topic, so `.dependsOn()` on either is a
|
|
13
|
+
* compile error rather than a stub that throws.
|
|
14
|
+
*/
|
|
15
|
+
interface Construct<TName extends string = string, TClient = never> {
|
|
16
|
+
/** Canonical, PascalCase, unique within the manifest. */
|
|
17
|
+
readonly id: TName;
|
|
18
|
+
/**
|
|
19
|
+
* The build-time face: what this construct contributes to the manifest.
|
|
20
|
+
*
|
|
21
|
+
* Returns an array because some constructs contribute more than one node — a
|
|
22
|
+
* queue declares the queue and its worker, a database declares its migrator
|
|
23
|
+
* and seeder. Most return one.
|
|
24
|
+
*/
|
|
25
|
+
declare(): Declaration[];
|
|
26
|
+
/**
|
|
27
|
+
* The consumable face — the address this construct owns, as a client.
|
|
28
|
+
*
|
|
29
|
+
* A field assigned once rather than a getter. `Construct.getEnvironment`
|
|
30
|
+
* caches by service *object*, and `Topic.publisher` returns a fresh literal
|
|
31
|
+
* on every access, so that cache never hits for topics or queues today.
|
|
32
|
+
*/
|
|
33
|
+
readonly service: [TClient] extends [never] ? never : Service<Uncapitalize<TName>, TClient>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The build-time face alone — an id and what it contributes to the manifest.
|
|
37
|
+
*
|
|
38
|
+
* Weaker than {@link Consumable} on purpose. An edge is not always an
|
|
39
|
+
* injection: a site depending on an API needs that API's *address at build
|
|
40
|
+
* time* and has no service record to put a client into, so requiring one would
|
|
41
|
+
* make the weakest kind of edge impossible to express with the strongest
|
|
42
|
+
* interface. Discovery asks this same question and nothing more.
|
|
43
|
+
*/
|
|
44
|
+
interface Declarable<TName extends string = string> {
|
|
45
|
+
readonly id: TName;
|
|
46
|
+
declare(): Declaration[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The edge that points at a construct.
|
|
50
|
+
*
|
|
51
|
+
* A construct's *canonical* node is the one carrying its own id — the others are
|
|
52
|
+
* things it owns rather than things it is, like the signing secret beside an
|
|
53
|
+
* auth server — so the kind an edge records is read off that node instead of
|
|
54
|
+
* being written down beside it. Hand-written kinds are the same fact stated
|
|
55
|
+
* twice, and the copy is what goes stale when a construct changes what it
|
|
56
|
+
* declares.
|
|
57
|
+
*
|
|
58
|
+
* @throws {NotAConstruct} when the value declares nothing under its own id.
|
|
59
|
+
*/
|
|
60
|
+
declare function edgeTo(construct: Declarable): Dependency;
|
|
61
|
+
/** What consuming a construct hands you. */
|
|
62
|
+
type Infer<C> = C extends Construct<string, infer TClient> ? TClient : never;
|
|
63
|
+
/** A construct's canonical id. */
|
|
64
|
+
type NameOf<C> = C extends Construct<infer TName, unknown> ? TName : never;
|
|
65
|
+
/**
|
|
66
|
+
* What `.dependsOn([…])` accepts: a construct that owns a client.
|
|
67
|
+
*
|
|
68
|
+
* Structural, and deliberately narrower than {@link Construct} — it is the
|
|
69
|
+
* face a *consumer* needs, so the builders can accept a database, a bucket, a
|
|
70
|
+
* mail sender, a queue, or a topic without importing any of them. A plain
|
|
71
|
+
* `Service` is not one of these, which is the point: constructs-only confines
|
|
72
|
+
* env sniffing to `.services()` and the explicit lift, so retiring that method
|
|
73
|
+
* retires implicit inference with it.
|
|
74
|
+
*/
|
|
75
|
+
interface Consumable<TName extends string = string, TClient = unknown> {
|
|
76
|
+
readonly id: TName;
|
|
77
|
+
readonly service: Service<Uncapitalize<TName>, TClient>;
|
|
78
|
+
declare(): Declaration[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The services a list of constructs dissolves into.
|
|
82
|
+
*
|
|
83
|
+
* A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,
|
|
84
|
+
* Service<'uploads', StorageClient>]` and the handler's service record gains
|
|
85
|
+
* both keys — the same machinery `.services()` already uses, which is why
|
|
86
|
+
* `dependsOn` needs no type plumbing of its own.
|
|
87
|
+
*/
|
|
88
|
+
type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service'] };
|
|
89
|
+
/**
|
|
90
|
+
* The services of a list of constructs, at runtime.
|
|
91
|
+
*
|
|
92
|
+
* @throws {NotAConstruct} when handed something else. The type already refuses
|
|
93
|
+
* it, but a JavaScript caller gets no such warning, and a `Service` slipping
|
|
94
|
+
* through would fail later as an undefined key in the handler.
|
|
95
|
+
*/
|
|
96
|
+
declare function servicesOf<const T extends readonly Consumable[]>(constructs: T): ServicesOf<T>;
|
|
97
|
+
/**
|
|
98
|
+
* The other half of `servicesOf`: the same edge, as the manifest records it.
|
|
99
|
+
*
|
|
100
|
+
* `.dependsOn()` used to keep only the services, which is what a handler runs
|
|
101
|
+
* with — and an id cannot be recovered from a service name reliably, so the
|
|
102
|
+
* edges were gone by the time the build could read them. Both halves are taken
|
|
103
|
+
* from one call now, and `existing` is folded in so repeated `.dependsOn()`
|
|
104
|
+
* calls accumulate the way `.services()` already does.
|
|
105
|
+
*/
|
|
106
|
+
declare function idsOf(constructs: readonly Consumable[], existing?: readonly string[]): string[];
|
|
107
|
+
/** Something that is not a construct was passed to `.dependsOn()`. */
|
|
108
|
+
declare class NotAConstruct extends Error {
|
|
109
|
+
readonly value: unknown;
|
|
110
|
+
constructor(value: unknown);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether a value is a construct rather than a bare `Service`.
|
|
114
|
+
*
|
|
115
|
+
* Structural rather than `instanceof`: a construct from a second copy of
|
|
116
|
+
* `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
|
|
117
|
+
* still a construct, and `instanceof` is exactly the check that says otherwise.
|
|
118
|
+
*/
|
|
119
|
+
declare function isConsumable(value: unknown): value is Consumable;
|
|
120
|
+
/**
|
|
121
|
+
* The service behind either face.
|
|
122
|
+
*
|
|
123
|
+
* `.database()` and the publisher slots take a construct now; they took a
|
|
124
|
+
* `Service` before and still do, because a hand-written one is exactly what
|
|
125
|
+
* `Construct.fromService` exists to lift and not everything has been lifted.
|
|
126
|
+
*/
|
|
127
|
+
declare function serviceOf<TName extends string, TClient>(source: Consumable<TName, TClient> | Service<TName, TClient>): Service<TName, TClient>;
|
|
128
|
+
//# sourceMappingURL=construct-interface.d.ts.map
|
|
129
|
+
//#endregion
|
|
130
|
+
export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
|
|
131
|
+
//# sourceMappingURL=construct-interface-BqwRNYA2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-interface-BqwRNYA2.d.mts","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":[],"mappings":";;;;;AAiEuB;AAevB;;;;AAAyD;AAWzD;;;AACW,UA/DM,SA+DN,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,UAAA,KAAA,CAAA,CAAA;EAAS;EAAiC,SAAA,EAAA,EA7DvC,KA6DuC;EAGzC;;;;;AACsC;AAYlD;EAA2B,OAAA,EAAA,EApEf,WAoEe,EAAA;EAAA;;;;;;AAGJ;EAWX,SAAA,OAAU,EAAA,CAzEF,OAyEE,CAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAA,GAvElB,OAuEkB,CAvEV,YAuEU,CAvEG,KAuEH,CAAA,EAvEW,OAuEX,CAAA;;;;;;AACF;AAUpB;;;;AAEc,UAxEG,UAwEH,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,CAAA;EAAC,SAAZ,EAAA,EAvEW,KAuEX;EAAU,OAAA,EAAA,EAtED,WAsEC,EAAA;AAiBb;AAQA;AAuBA;AAmBA;;;;;;;;;;AAEG,iBA5Ha,MAAA,CA4Hb,SAAA,EA5H+B,UA4H/B,CAAA,EA5H4C,UA4H5C;AAAO;KAjHE,WACX,UAAU,mCAAmC;;KAGlC,YACX,UAAU,kCAAkC;;;;;;;;;;;UAY5B;eACH;oBACK,QAAQ,aAAa,QAAQ;aACpC;;;;;;;;;;KAWA,8BAA8B,8BAC7B,IAAI,EAAE;;;;;;;;iBAUH,oCAAoC,0BACvC,IACV,WAAW;;;;;;;;;;iBAiBE,KAAA,sBACM;;cAOT,aAAA,SAAsB,KAAK;;;;;;;;;;;iBAuBxB,YAAA,2BAAuC;;;;;;;;iBAmBvC,iDACP,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Service } from "@geekmidas/services";
|
|
2
|
+
import { Declaration, Dependency } from "@geekmidas/manifest";
|
|
3
|
+
|
|
4
|
+
//#region src/construct-interface.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typeParam TName - the construct's canonical id, PascalCase. Keeping it a
|
|
8
|
+
* literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript
|
|
9
|
+
* intrinsic, so no custom transform needs a runtime twin.
|
|
10
|
+
* @typeParam TClient - what consuming this construct hands you. `never` means it
|
|
11
|
+
* owns no address and cannot be consumed: a `Cron` is fired by a schedule and a
|
|
12
|
+
* `Subscriber` is reached through its topic, so `.dependsOn()` on either is a
|
|
13
|
+
* compile error rather than a stub that throws.
|
|
14
|
+
*/
|
|
15
|
+
interface Construct<TName extends string = string, TClient = never> {
|
|
16
|
+
/** Canonical, PascalCase, unique within the manifest. */
|
|
17
|
+
readonly id: TName;
|
|
18
|
+
/**
|
|
19
|
+
* The build-time face: what this construct contributes to the manifest.
|
|
20
|
+
*
|
|
21
|
+
* Returns an array because some constructs contribute more than one node — a
|
|
22
|
+
* queue declares the queue and its worker, a database declares its migrator
|
|
23
|
+
* and seeder. Most return one.
|
|
24
|
+
*/
|
|
25
|
+
declare(): Declaration[];
|
|
26
|
+
/**
|
|
27
|
+
* The consumable face — the address this construct owns, as a client.
|
|
28
|
+
*
|
|
29
|
+
* A field assigned once rather than a getter. `Construct.getEnvironment`
|
|
30
|
+
* caches by service *object*, and `Topic.publisher` returns a fresh literal
|
|
31
|
+
* on every access, so that cache never hits for topics or queues today.
|
|
32
|
+
*/
|
|
33
|
+
readonly service: [TClient] extends [never] ? never : Service<Uncapitalize<TName>, TClient>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The build-time face alone — an id and what it contributes to the manifest.
|
|
37
|
+
*
|
|
38
|
+
* Weaker than {@link Consumable} on purpose. An edge is not always an
|
|
39
|
+
* injection: a site depending on an API needs that API's *address at build
|
|
40
|
+
* time* and has no service record to put a client into, so requiring one would
|
|
41
|
+
* make the weakest kind of edge impossible to express with the strongest
|
|
42
|
+
* interface. Discovery asks this same question and nothing more.
|
|
43
|
+
*/
|
|
44
|
+
interface Declarable<TName extends string = string> {
|
|
45
|
+
readonly id: TName;
|
|
46
|
+
declare(): Declaration[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The edge that points at a construct.
|
|
50
|
+
*
|
|
51
|
+
* A construct's *canonical* node is the one carrying its own id — the others are
|
|
52
|
+
* things it owns rather than things it is, like the signing secret beside an
|
|
53
|
+
* auth server — so the kind an edge records is read off that node instead of
|
|
54
|
+
* being written down beside it. Hand-written kinds are the same fact stated
|
|
55
|
+
* twice, and the copy is what goes stale when a construct changes what it
|
|
56
|
+
* declares.
|
|
57
|
+
*
|
|
58
|
+
* @throws {NotAConstruct} when the value declares nothing under its own id.
|
|
59
|
+
*/
|
|
60
|
+
declare function edgeTo(construct: Declarable): Dependency;
|
|
61
|
+
/** What consuming a construct hands you. */
|
|
62
|
+
type Infer<C> = C extends Construct<string, infer TClient> ? TClient : never;
|
|
63
|
+
/** A construct's canonical id. */
|
|
64
|
+
type NameOf<C> = C extends Construct<infer TName, unknown> ? TName : never;
|
|
65
|
+
/**
|
|
66
|
+
* What `.dependsOn([…])` accepts: a construct that owns a client.
|
|
67
|
+
*
|
|
68
|
+
* Structural, and deliberately narrower than {@link Construct} — it is the
|
|
69
|
+
* face a *consumer* needs, so the builders can accept a database, a bucket, a
|
|
70
|
+
* mail sender, a queue, or a topic without importing any of them. A plain
|
|
71
|
+
* `Service` is not one of these, which is the point: constructs-only confines
|
|
72
|
+
* env sniffing to `.services()` and the explicit lift, so retiring that method
|
|
73
|
+
* retires implicit inference with it.
|
|
74
|
+
*/
|
|
75
|
+
interface Consumable<TName extends string = string, TClient = unknown> {
|
|
76
|
+
readonly id: TName;
|
|
77
|
+
readonly service: Service<Uncapitalize<TName>, TClient>;
|
|
78
|
+
declare(): Declaration[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The services a list of constructs dissolves into.
|
|
82
|
+
*
|
|
83
|
+
* A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,
|
|
84
|
+
* Service<'uploads', StorageClient>]` and the handler's service record gains
|
|
85
|
+
* both keys — the same machinery `.services()` already uses, which is why
|
|
86
|
+
* `dependsOn` needs no type plumbing of its own.
|
|
87
|
+
*/
|
|
88
|
+
type ServicesOf<T extends readonly Consumable[]> = { [K in keyof T]: T[K]['service'] };
|
|
89
|
+
/**
|
|
90
|
+
* The services of a list of constructs, at runtime.
|
|
91
|
+
*
|
|
92
|
+
* @throws {NotAConstruct} when handed something else. The type already refuses
|
|
93
|
+
* it, but a JavaScript caller gets no such warning, and a `Service` slipping
|
|
94
|
+
* through would fail later as an undefined key in the handler.
|
|
95
|
+
*/
|
|
96
|
+
declare function servicesOf<const T extends readonly Consumable[]>(constructs: T): ServicesOf<T>;
|
|
97
|
+
/**
|
|
98
|
+
* The other half of `servicesOf`: the same edge, as the manifest records it.
|
|
99
|
+
*
|
|
100
|
+
* `.dependsOn()` used to keep only the services, which is what a handler runs
|
|
101
|
+
* with — and an id cannot be recovered from a service name reliably, so the
|
|
102
|
+
* edges were gone by the time the build could read them. Both halves are taken
|
|
103
|
+
* from one call now, and `existing` is folded in so repeated `.dependsOn()`
|
|
104
|
+
* calls accumulate the way `.services()` already does.
|
|
105
|
+
*/
|
|
106
|
+
declare function idsOf(constructs: readonly Consumable[], existing?: readonly string[]): string[];
|
|
107
|
+
/** Something that is not a construct was passed to `.dependsOn()`. */
|
|
108
|
+
declare class NotAConstruct extends Error {
|
|
109
|
+
readonly value: unknown;
|
|
110
|
+
constructor(value: unknown);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether a value is a construct rather than a bare `Service`.
|
|
114
|
+
*
|
|
115
|
+
* Structural rather than `instanceof`: a construct from a second copy of
|
|
116
|
+
* `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
|
|
117
|
+
* still a construct, and `instanceof` is exactly the check that says otherwise.
|
|
118
|
+
*/
|
|
119
|
+
declare function isConsumable(value: unknown): value is Consumable;
|
|
120
|
+
/**
|
|
121
|
+
* The service behind either face.
|
|
122
|
+
*
|
|
123
|
+
* `.database()` and the publisher slots take a construct now; they took a
|
|
124
|
+
* `Service` before and still do, because a hand-written one is exactly what
|
|
125
|
+
* `Construct.fromService` exists to lift and not everything has been lifted.
|
|
126
|
+
*/
|
|
127
|
+
declare function serviceOf<TName extends string, TClient>(source: Consumable<TName, TClient> | Service<TName, TClient>): Service<TName, TClient>;
|
|
128
|
+
//# sourceMappingURL=construct-interface.d.ts.map
|
|
129
|
+
//#endregion
|
|
130
|
+
export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
|
|
131
|
+
//# sourceMappingURL=construct-interface-D2nNkHUN.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-interface-D2nNkHUN.d.cts","names":[],"sources":["../src/construct-interface.ts"],"sourcesContent":[],"mappings":";;;;;AAiEuB;AAevB;;;;AAAyD;AAWzD;;;AACW,UA/DM,SA+DN,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,UAAA,KAAA,CAAA,CAAA;EAAS;EAAiC,SAAA,EAAA,EA7DvC,KA6DuC;EAGzC;;;;;AACsC;AAYlD;EAA2B,OAAA,EAAA,EApEf,WAoEe,EAAA;EAAA;;;;;;AAGJ;EAWX,SAAA,OAAU,EAAA,CAzEF,OAyEE,CAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAA,GAvElB,OAuEkB,CAvEV,YAuEU,CAvEG,KAuEH,CAAA,EAvEW,OAuEX,CAAA;;;;;;AACF;AAUpB;;;;AAEc,UAxEG,UAwEH,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,CAAA;EAAC,SAAZ,EAAA,EAvEW,KAuEX;EAAU,OAAA,EAAA,EAtED,WAsEC,EAAA;AAiBb;AAQA;AAuBA;AAmBA;;;;;;;;;;AAEG,iBA5Ha,MAAA,CA4Hb,SAAA,EA5H+B,UA4H/B,CAAA,EA5H4C,UA4H5C;AAAO;KAjHE,WACX,UAAU,mCAAmC;;KAGlC,YACX,UAAU,kCAAkC;;;;;;;;;;;UAY5B;eACH;oBACK,QAAQ,aAAa,QAAQ;aACpC;;;;;;;;;;KAWA,8BAA8B,8BAC7B,IAAI,EAAE;;;;;;;;iBAUH,oCAAoC,0BACvC,IACV,WAAW;;;;;;;;;;iBAiBE,KAAA,sBACM;;cAOT,aAAA,SAAsB,KAAK;;;;;;;;;;;iBAuBxB,YAAA,2BAAuC;;;;;;;;iBAmBvC,iDACP,WAAW,OAAO,WAAW,QAAQ,OAAO,WAClD,QAAQ,OAAO"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//#region src/construct-interface.ts
|
|
2
|
+
/**
|
|
3
|
+
* The edge that points at a construct.
|
|
4
|
+
*
|
|
5
|
+
* A construct's *canonical* node is the one carrying its own id — the others are
|
|
6
|
+
* things it owns rather than things it is, like the signing secret beside an
|
|
7
|
+
* auth server — so the kind an edge records is read off that node instead of
|
|
8
|
+
* being written down beside it. Hand-written kinds are the same fact stated
|
|
9
|
+
* twice, and the copy is what goes stale when a construct changes what it
|
|
10
|
+
* declares.
|
|
11
|
+
*
|
|
12
|
+
* @throws {NotAConstruct} when the value declares nothing under its own id.
|
|
13
|
+
*/
|
|
14
|
+
function edgeTo(construct) {
|
|
15
|
+
const canonical = construct.declare().find((declaration) => declaration.id === construct.id);
|
|
16
|
+
if (!canonical) throw new NotAConstruct(construct);
|
|
17
|
+
return {
|
|
18
|
+
target: construct.id,
|
|
19
|
+
kind: canonical.kind
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The services of a list of constructs, at runtime.
|
|
24
|
+
*
|
|
25
|
+
* @throws {NotAConstruct} when handed something else. The type already refuses
|
|
26
|
+
* it, but a JavaScript caller gets no such warning, and a `Service` slipping
|
|
27
|
+
* through would fail later as an undefined key in the handler.
|
|
28
|
+
*/
|
|
29
|
+
function servicesOf(constructs) {
|
|
30
|
+
return constructs.map((construct) => {
|
|
31
|
+
if (!isConsumable(construct)) throw new NotAConstruct(construct);
|
|
32
|
+
return construct.service;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The other half of `servicesOf`: the same edge, as the manifest records it.
|
|
37
|
+
*
|
|
38
|
+
* `.dependsOn()` used to keep only the services, which is what a handler runs
|
|
39
|
+
* with — and an id cannot be recovered from a service name reliably, so the
|
|
40
|
+
* edges were gone by the time the build could read them. Both halves are taken
|
|
41
|
+
* from one call now, and `existing` is folded in so repeated `.dependsOn()`
|
|
42
|
+
* calls accumulate the way `.services()` already does.
|
|
43
|
+
*/
|
|
44
|
+
function idsOf(constructs, existing = []) {
|
|
45
|
+
return [...new Set([...existing, ...constructs.map(({ id }) => id)])];
|
|
46
|
+
}
|
|
47
|
+
/** Something that is not a construct was passed to `.dependsOn()`. */
|
|
48
|
+
var NotAConstruct = class extends Error {
|
|
49
|
+
constructor(value) {
|
|
50
|
+
const name = typeof value === "object" && value !== null && "serviceName" in value ? `the service '${String(value.serviceName)}'` : `a ${typeof value}`;
|
|
51
|
+
super(`.dependsOn() takes constructs, and was given ${name}. Pass it to .services([…]) instead, or lift it with Construct.fromService().`);
|
|
52
|
+
this.value = value;
|
|
53
|
+
this.name = "NotAConstruct";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Whether a value is a construct rather than a bare `Service`.
|
|
58
|
+
*
|
|
59
|
+
* Structural rather than `instanceof`: a construct from a second copy of
|
|
60
|
+
* `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is
|
|
61
|
+
* still a construct, and `instanceof` is exactly the check that says otherwise.
|
|
62
|
+
*/
|
|
63
|
+
function isConsumable(value) {
|
|
64
|
+
if (typeof value !== "object" || value === null) return false;
|
|
65
|
+
const candidate = value;
|
|
66
|
+
return typeof candidate.id === "string" && typeof candidate.declare === "function" && typeof candidate.service?.serviceName === "string";
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The service behind either face.
|
|
70
|
+
*
|
|
71
|
+
* `.database()` and the publisher slots take a construct now; they took a
|
|
72
|
+
* `Service` before and still do, because a hand-written one is exactly what
|
|
73
|
+
* `Construct.fromService` exists to lift and not everything has been lifted.
|
|
74
|
+
*/
|
|
75
|
+
function serviceOf(source) {
|
|
76
|
+
return isConsumable(source) ? source.service : source;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
export { NotAConstruct, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
|
|
81
|
+
//# sourceMappingURL=construct-interface-Z4CpS8tK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-interface-Z4CpS8tK.mjs","names":["construct: Declarable","constructs: T","constructs: readonly Consumable[]","existing: readonly string[]","value: unknown","source: Consumable<TName, TClient> | Service<TName, TClient>"],"sources":["../src/construct-interface.ts"],"sourcesContent":["/**\n * The construct contract.\n *\n * A construct is three things at once — an infrastructure requirement at build\n * time, a runtime capability, and something other code can consume — which is\n * what forces exactly these three members.\n *\n * An **interface**, not a base class: `Endpoint`, `Cron`, `Queue`, and `Topic`\n * can satisfy it without inheritance surgery, a lifted `Service` can satisfy it\n * as a plain object, and `.dependsOn()` gets its enforcement structurally — a\n * `Service` (`{ serviceName, register }`) simply does not match\n * `{ id, declare, service }`, with no `instanceof` anywhere.\n *\n * Lives in its own module while the existing abstract `Construct` class is\n * still in use; it takes that name once the class is gone.\n */\n\nimport type { Declaration, Dependency } from '@geekmidas/manifest';\nimport type { Service } from '@geekmidas/services';\n\n/**\n * @typeParam TName - the construct's canonical id, PascalCase. Keeping it a\n * literal is what lets the service key be `Uncapitalize<TName>` — a TypeScript\n * intrinsic, so no custom transform needs a runtime twin.\n * @typeParam TClient - what consuming this construct hands you. `never` means it\n * owns no address and cannot be consumed: a `Cron` is fired by a schedule and a\n * `Subscriber` is reached through its topic, so `.dependsOn()` on either is a\n * compile error rather than a stub that throws.\n */\nexport interface Construct<TName extends string = string, TClient = never> {\n\t/** Canonical, PascalCase, unique within the manifest. */\n\treadonly id: TName;\n\n\t/**\n\t * The build-time face: what this construct contributes to the manifest.\n\t *\n\t * Returns an array because some constructs contribute more than one node — a\n\t * queue declares the queue and its worker, a database declares its migrator\n\t * and seeder. Most return one.\n\t */\n\tdeclare(): Declaration[];\n\n\t/**\n\t * The consumable face — the address this construct owns, as a client.\n\t *\n\t * A field assigned once rather than a getter. `Construct.getEnvironment`\n\t * caches by service *object*, and `Topic.publisher` returns a fresh literal\n\t * on every access, so that cache never hits for topics or queues today.\n\t */\n\treadonly service: [TClient] extends [never]\n\t\t? never\n\t\t: Service<Uncapitalize<TName>, TClient>;\n}\n\n/**\n * The build-time face alone — an id and what it contributes to the manifest.\n *\n * Weaker than {@link Consumable} on purpose. An edge is not always an\n * injection: a site depending on an API needs that API's *address at build\n * time* and has no service record to put a client into, so requiring one would\n * make the weakest kind of edge impossible to express with the strongest\n * interface. Discovery asks this same question and nothing more.\n */\nexport interface Declarable<TName extends string = string> {\n\treadonly id: TName;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The edge that points at a construct.\n *\n * A construct's *canonical* node is the one carrying its own id — the others are\n * things it owns rather than things it is, like the signing secret beside an\n * auth server — so the kind an edge records is read off that node instead of\n * being written down beside it. Hand-written kinds are the same fact stated\n * twice, and the copy is what goes stale when a construct changes what it\n * declares.\n *\n * @throws {NotAConstruct} when the value declares nothing under its own id.\n */\nexport function edgeTo(construct: Declarable): Dependency {\n\tconst canonical = construct\n\t\t.declare()\n\t\t.find((declaration) => declaration.id === construct.id);\n\n\tif (!canonical) throw new NotAConstruct(construct);\n\n\treturn { target: construct.id, kind: canonical.kind };\n}\n\n/** What consuming a construct hands you. */\nexport type Infer<C> =\n\tC extends Construct<string, infer TClient> ? TClient : never;\n\n/** A construct's canonical id. */\nexport type NameOf<C> =\n\tC extends Construct<infer TName, unknown> ? TName : never;\n\n/**\n * What `.dependsOn([…])` accepts: a construct that owns a client.\n *\n * Structural, and deliberately narrower than {@link Construct} — it is the\n * face a *consumer* needs, so the builders can accept a database, a bucket, a\n * mail sender, a queue, or a topic without importing any of them. A plain\n * `Service` is not one of these, which is the point: constructs-only confines\n * env sniffing to `.services()` and the explicit lift, so retiring that method\n * retires implicit inference with it.\n */\nexport interface Consumable<TName extends string = string, TClient = unknown> {\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, TClient>;\n\tdeclare(): Declaration[];\n}\n\n/**\n * The services a list of constructs dissolves into.\n *\n * A mapped tuple, so `[db, uploads]` types as `[Service<'orders', Kysely<DB>>,\n * Service<'uploads', StorageClient>]` and the handler's service record gains\n * both keys — the same machinery `.services()` already uses, which is why\n * `dependsOn` needs no type plumbing of its own.\n */\nexport type ServicesOf<T extends readonly Consumable[]> = {\n\t[K in keyof T]: T[K]['service'];\n};\n\n/**\n * The services of a list of constructs, at runtime.\n *\n * @throws {NotAConstruct} when handed something else. The type already refuses\n * it, but a JavaScript caller gets no such warning, and a `Service` slipping\n * through would fail later as an undefined key in the handler.\n */\nexport function servicesOf<const T extends readonly Consumable[]>(\n\tconstructs: T,\n): ServicesOf<T> {\n\treturn constructs.map((construct) => {\n\t\tif (!isConsumable(construct)) throw new NotAConstruct(construct);\n\n\t\treturn construct.service;\n\t}) as ServicesOf<T>;\n}\n\n/**\n * The other half of `servicesOf`: the same edge, as the manifest records it.\n *\n * `.dependsOn()` used to keep only the services, which is what a handler runs\n * with — and an id cannot be recovered from a service name reliably, so the\n * edges were gone by the time the build could read them. Both halves are taken\n * from one call now, and `existing` is folded in so repeated `.dependsOn()`\n * calls accumulate the way `.services()` already does.\n */\nexport function idsOf(\n\tconstructs: readonly Consumable[],\n\texisting: readonly string[] = [],\n): string[] {\n\treturn [...new Set([...existing, ...constructs.map(({ id }) => id)])];\n}\n\n/** Something that is not a construct was passed to `.dependsOn()`. */\nexport class NotAConstruct extends Error {\n\tconstructor(readonly value: unknown) {\n\t\tconst name =\n\t\t\ttypeof value === 'object' && value !== null && 'serviceName' in value\n\t\t\t\t? `the service '${String((value as { serviceName: unknown }).serviceName)}'`\n\t\t\t\t: `a ${typeof value}`;\n\n\t\tsuper(\n\t\t\t`.dependsOn() takes constructs, and was given ${name}. ` +\n\t\t\t\t`Pass it to .services([…]) instead, or lift it with ` +\n\t\t\t\t`Construct.fromService().`,\n\t\t);\n\t\tthis.name = 'NotAConstruct';\n\t}\n}\n\n/**\n * Whether a value is a construct rather than a bare `Service`.\n *\n * Structural rather than `instanceof`: a construct from a second copy of\n * `@geekmidas/constructs` — a linked workspace, two versions in a lockfile — is\n * still a construct, and `instanceof` is exactly the check that says otherwise.\n */\nexport function isConsumable(value: unknown): value is Consumable {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\tconst candidate = value as Partial<Consumable>;\n\n\treturn (\n\t\ttypeof candidate.id === 'string' &&\n\t\ttypeof candidate.declare === 'function' &&\n\t\ttypeof (candidate.service as Service | undefined)?.serviceName === 'string'\n\t);\n}\n\n/**\n * The service behind either face.\n *\n * `.database()` and the publisher slots take a construct now; they took a\n * `Service` before and still do, because a hand-written one is exactly what\n * `Construct.fromService` exists to lift and not everything has been lifted.\n */\nexport function serviceOf<TName extends string, TClient>(\n\tsource: Consumable<TName, TClient> | Service<TName, TClient>,\n): Service<TName, TClient> {\n\t// A construct's service key is `Uncapitalize<TName>` and the slot is typed\n\t// by `TName`; the two describe the same key, and only the cast says so.\n\treturn isConsumable(source)\n\t\t? (source.service as unknown as Service<TName, TClient>)\n\t\t: (source as Service<TName, TClient>);\n}\n"],"mappings":";;;;;;;;;;;;;AAgFA,SAAgB,OAAOA,WAAmC;CACzD,MAAM,YAAY,UAChB,SAAS,CACT,KAAK,CAAC,gBAAgB,YAAY,OAAO,UAAU,GAAG;AAExD,MAAK,UAAW,OAAM,IAAI,cAAc;AAExC,QAAO;EAAE,QAAQ,UAAU;EAAI,MAAM,UAAU;CAAM;AACrD;;;;;;;;AA6CD,SAAgB,WACfC,YACgB;AAChB,QAAO,WAAW,IAAI,CAAC,cAAc;AACpC,OAAK,aAAa,UAAU,CAAE,OAAM,IAAI,cAAc;AAEtD,SAAO,UAAU;CACjB,EAAC;AACF;;;;;;;;;;AAWD,SAAgB,MACfC,YACAC,WAA8B,CAAE,GACrB;AACX,QAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,WAAW,IAAI,CAAC,EAAE,IAAI,KAAK,GAAG,AAAC,EAAE;AACrE;;AAGD,IAAa,gBAAb,cAAmC,MAAM;CACxC,YAAqBC,OAAgB;EACpC,MAAM,cACE,UAAU,YAAY,UAAU,QAAQ,iBAAiB,SAC5D,eAAe,OAAQ,MAAmC,YAAY,CAAC,MACvE,WAAW,MAAM;AAEtB,SACE,+CAA+C,KAAK,+EAGrD;EAVmB;AAWpB,OAAK,OAAO;CACZ;AACD;;;;;;;;AASD,SAAgB,aAAaA,OAAqC;AACjE,YAAW,UAAU,YAAY,UAAU,KAAM,QAAO;CAExD,MAAM,YAAY;AAElB,eACQ,UAAU,OAAO,mBACjB,UAAU,YAAY,qBACrB,UAAU,SAAiC,gBAAgB;AAEpE;;;;;;;;AASD,SAAgB,UACfC,QAC0B;AAG1B,QAAO,aAAa,OAAO,GACvB,OAAO,UACP;AACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_construct_interface = require('./construct-interface-BfjcOD_E.cjs');
|
|
2
|
+
|
|
3
|
+
exports.NotAConstruct = require_construct_interface.NotAConstruct;
|
|
4
|
+
exports.edgeTo = require_construct_interface.edgeTo;
|
|
5
|
+
exports.idsOf = require_construct_interface.idsOf;
|
|
6
|
+
exports.isConsumable = require_construct_interface.isConsumable;
|
|
7
|
+
exports.serviceOf = require_construct_interface.serviceOf;
|
|
8
|
+
exports.servicesOf = require_construct_interface.servicesOf;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf } from "./construct-interface-D2nNkHUN.cjs";
|
|
2
|
+
export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf } from "./construct-interface-BqwRNYA2.mjs";
|
|
2
|
+
export { Construct, Consumable, Declarable, Infer, NameOf, NotAConstruct, ServicesOf, edgeTo, idsOf, isConsumable, serviceOf, servicesOf };
|