@geekmidas/constructs 9.0.2 → 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-Bn99MceY.d.cts → AWSScheduledFunction-BvFvBsBN.d.cts} +8 -3
- package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-BvFvBsBN.d.cts.map} +1 -1
- package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-CVccZO-L.d.mts} +9 -4
- package/dist/{AWSScheduledFunction-Bn99MceY.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-DgfRslct.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-BVs9DvIj.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 -396
- 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-CLPSIl6S.d.mts.map +0 -1
- package/dist/Endpoint-DgfRslct.d.cts.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-BVs9DvIj.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
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger } from '@geekmidas/logger/console';
|
|
2
|
-
import type { Service } from '@geekmidas/services';
|
|
3
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { ConstructType } from '../../Construct';
|
|
6
|
-
import { Cron, type CronExpression, type RateExpression } from '../Cron';
|
|
7
|
-
import { CronBuilder } from '../CronBuilder';
|
|
8
|
-
|
|
9
|
-
// Mock service for testing
|
|
10
|
-
class MockService implements Service<'MockService', MockService> {
|
|
11
|
-
serviceName = 'MockService' as const;
|
|
12
|
-
|
|
13
|
-
async register() {
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getValue() {
|
|
18
|
-
return 'mock-value';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('Cron', () => {
|
|
23
|
-
describe('Cron class', () => {
|
|
24
|
-
it('should create a Cron instance with basic handler', () => {
|
|
25
|
-
const handler = vi.fn().mockResolvedValue({ success: true });
|
|
26
|
-
const cron = new Cron(handler);
|
|
27
|
-
|
|
28
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
29
|
-
expect(cron.type).toBe(ConstructType.Cron);
|
|
30
|
-
expect(cron.timeout).toBe(30000); // Default timeout
|
|
31
|
-
// The handler is stored in the protected fn property
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should create a Cron instance with timeout', () => {
|
|
35
|
-
const handler = vi.fn().mockResolvedValue({ data: 'test' });
|
|
36
|
-
const timeout = 60000;
|
|
37
|
-
const cron = new Cron(handler, timeout);
|
|
38
|
-
|
|
39
|
-
expect(cron.timeout).toBe(timeout);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should create a Cron instance with schedule expression', () => {
|
|
43
|
-
const handler = vi.fn();
|
|
44
|
-
const schedule: CronExpression = 'cron(0 12 * * MON)';
|
|
45
|
-
const cron = new Cron(handler, undefined, schedule);
|
|
46
|
-
|
|
47
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
48
|
-
expect(cron.type).toBe(ConstructType.Cron);
|
|
49
|
-
// Schedule is protected, so we can't directly test it, but it should be set
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should create a Cron instance with input schema', () => {
|
|
53
|
-
const inputSchema = z.object({
|
|
54
|
-
id: z.string(),
|
|
55
|
-
count: z.number(),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const handler = vi.fn().mockImplementation(async ({ input }) => {
|
|
59
|
-
return { processed: input.id };
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const cron = new Cron(handler, undefined, undefined, inputSchema);
|
|
63
|
-
|
|
64
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
65
|
-
expect(cron.input).toBe(inputSchema);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should create a Cron instance with output schema', () => {
|
|
69
|
-
const outputSchema = z.object({
|
|
70
|
-
result: z.string(),
|
|
71
|
-
timestamp: z.number(),
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const handler = vi.fn().mockResolvedValue({
|
|
75
|
-
result: 'success',
|
|
76
|
-
timestamp: Date.now(),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const cron = new Cron(
|
|
80
|
-
handler,
|
|
81
|
-
undefined,
|
|
82
|
-
undefined,
|
|
83
|
-
undefined,
|
|
84
|
-
outputSchema,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
88
|
-
expect(cron.outputSchema).toBe(outputSchema);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should create a Cron instance with services', () => {
|
|
92
|
-
const mockService = new MockService();
|
|
93
|
-
const services = [mockService];
|
|
94
|
-
|
|
95
|
-
const handler = vi.fn().mockImplementation(async ({ services }) => {
|
|
96
|
-
return { value: services.MockService.getValue() };
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const cron = new Cron(
|
|
100
|
-
handler,
|
|
101
|
-
undefined,
|
|
102
|
-
undefined,
|
|
103
|
-
undefined,
|
|
104
|
-
undefined,
|
|
105
|
-
services,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
109
|
-
expect(cron.services).toEqual(services);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('should create a Cron instance with custom logger', () => {
|
|
113
|
-
const customLogger = new ConsoleLogger();
|
|
114
|
-
|
|
115
|
-
const handler = vi.fn().mockImplementation(async ({ logger }) => {
|
|
116
|
-
logger.info('Cron executed');
|
|
117
|
-
return { logged: true };
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const cron = new Cron(
|
|
121
|
-
handler,
|
|
122
|
-
undefined,
|
|
123
|
-
undefined,
|
|
124
|
-
undefined,
|
|
125
|
-
undefined,
|
|
126
|
-
[],
|
|
127
|
-
customLogger,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
131
|
-
expect(cron.logger).toBe(customLogger);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should create a Cron with all parameters', () => {
|
|
135
|
-
const inputSchema = z.object({ name: z.string() });
|
|
136
|
-
const outputSchema = z.object({ greeting: z.string() });
|
|
137
|
-
const schedule: RateExpression = 'rate(5 minutes)';
|
|
138
|
-
const timeout = 60000;
|
|
139
|
-
const service = new MockService();
|
|
140
|
-
const logger = new ConsoleLogger();
|
|
141
|
-
|
|
142
|
-
const handler = vi
|
|
143
|
-
.fn()
|
|
144
|
-
.mockImplementation(async ({ input, services }) => {
|
|
145
|
-
return {
|
|
146
|
-
greeting: `Hello ${input.name} from ${services.MockService.getValue()}`,
|
|
147
|
-
};
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const cron = new Cron(
|
|
151
|
-
handler,
|
|
152
|
-
timeout,
|
|
153
|
-
schedule,
|
|
154
|
-
inputSchema,
|
|
155
|
-
outputSchema,
|
|
156
|
-
[service],
|
|
157
|
-
logger,
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
161
|
-
expect(cron.type).toBe(ConstructType.Cron);
|
|
162
|
-
expect(cron.timeout).toBe(timeout);
|
|
163
|
-
expect(cron.input).toBe(inputSchema);
|
|
164
|
-
expect(cron.outputSchema).toBe(outputSchema);
|
|
165
|
-
expect(cron.services).toEqual([service]);
|
|
166
|
-
expect(cron.logger).toBe(logger);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
describe('Cron.isCron', () => {
|
|
171
|
-
it('should return true for Cron instances', () => {
|
|
172
|
-
const cron = new Cron(vi.fn());
|
|
173
|
-
expect(Cron.isCron(cron)).toBe(true);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should return false for non-Cron objects', () => {
|
|
177
|
-
expect(Cron.isCron({})).toBe(false);
|
|
178
|
-
expect(Cron.isCron(null)).toBeFalsy();
|
|
179
|
-
expect(Cron.isCron(undefined)).toBeFalsy();
|
|
180
|
-
expect(Cron.isCron('string')).toBe(false);
|
|
181
|
-
expect(Cron.isCron(123)).toBe(false);
|
|
182
|
-
expect(Cron.isCron([])).toBe(false);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should return false for objects with similar structure', () => {
|
|
186
|
-
const fakeCron = {
|
|
187
|
-
__IS_FUNCTION__: true,
|
|
188
|
-
type: 'SomethingElse',
|
|
189
|
-
};
|
|
190
|
-
expect(Cron.isCron(fakeCron)).toBe(false);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('should return false for objects with __IS_FUNCTION__ but wrong type', () => {
|
|
194
|
-
const fakeFunction = {
|
|
195
|
-
__IS_FUNCTION__: true,
|
|
196
|
-
type: ConstructType.Function,
|
|
197
|
-
};
|
|
198
|
-
expect(Cron.isCron(fakeFunction)).toBe(false);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
describe('CronBuilder', () => {
|
|
203
|
-
it('should create a CronBuilder instance', () => {
|
|
204
|
-
const builder = new CronBuilder();
|
|
205
|
-
expect(builder).toBeInstanceOf(CronBuilder);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('should set schedule with schedule() method', () => {
|
|
209
|
-
const builder = new CronBuilder();
|
|
210
|
-
const schedule: CronExpression = 'cron(0 0 * * SUN)';
|
|
211
|
-
|
|
212
|
-
const result = builder.schedule(schedule);
|
|
213
|
-
expect(result).toBe(builder); // Should return self for chaining
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('should build Cron with handle() method', () => {
|
|
217
|
-
const builder = new CronBuilder();
|
|
218
|
-
const handler = vi.fn().mockResolvedValue({ done: true });
|
|
219
|
-
|
|
220
|
-
const cron = builder.handle(handler);
|
|
221
|
-
|
|
222
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
223
|
-
expect(cron.type).toBe(ConstructType.Cron);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('should build Cron with full builder chain', () => {
|
|
227
|
-
const inputSchema = z.object({ task: z.string() });
|
|
228
|
-
const outputSchema = z.object({ completed: z.boolean() });
|
|
229
|
-
const schedule: RateExpression = 'rate(1 hour)';
|
|
230
|
-
const service = new MockService();
|
|
231
|
-
const logger = new ConsoleLogger();
|
|
232
|
-
|
|
233
|
-
const handler = vi.fn().mockImplementation(async ({ input }) => {
|
|
234
|
-
return { completed: input.task === 'test' };
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
const cron = new CronBuilder()
|
|
238
|
-
.input(inputSchema)
|
|
239
|
-
.output(outputSchema)
|
|
240
|
-
.services([service])
|
|
241
|
-
.logger(logger)
|
|
242
|
-
.timeout(45000)
|
|
243
|
-
.schedule(schedule)
|
|
244
|
-
.handle(handler);
|
|
245
|
-
|
|
246
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
247
|
-
expect(cron.type).toBe(ConstructType.Cron);
|
|
248
|
-
expect(cron.timeout).toBe(45000);
|
|
249
|
-
expect(cron.input).toBe(inputSchema);
|
|
250
|
-
expect(cron.outputSchema).toBe(outputSchema);
|
|
251
|
-
expect(cron.services).toEqual([service]);
|
|
252
|
-
expect(cron.logger).toBe(logger);
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it('should support method chaining in any order', () => {
|
|
256
|
-
const builder = new CronBuilder();
|
|
257
|
-
const schedule: CronExpression = 'cron(30 2 * * TUE)';
|
|
258
|
-
|
|
259
|
-
const chained = builder
|
|
260
|
-
.timeout(30000)
|
|
261
|
-
.schedule(schedule)
|
|
262
|
-
.input(z.object({ data: z.string() }));
|
|
263
|
-
|
|
264
|
-
expect(chained).toBe(builder);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
describe('Schedule Expression Types', () => {
|
|
269
|
-
it('should accept valid rate expressions', () => {
|
|
270
|
-
const validRates: RateExpression[] = [
|
|
271
|
-
'rate(5 minutes)',
|
|
272
|
-
'rate(1 hour)',
|
|
273
|
-
'rate(7 days)',
|
|
274
|
-
'rate(30 seconds)',
|
|
275
|
-
'rate(2 weeks)',
|
|
276
|
-
];
|
|
277
|
-
|
|
278
|
-
validRates.forEach((rate) => {
|
|
279
|
-
const builder = new CronBuilder();
|
|
280
|
-
expect(() => builder.schedule(rate)).not.toThrow();
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('should accept valid cron expressions', () => {
|
|
285
|
-
const validCrons: CronExpression[] = [
|
|
286
|
-
'cron(0 12 * * MON)',
|
|
287
|
-
'cron(15 10 * * FRI)',
|
|
288
|
-
'cron(0 0 1 JAN SUN)',
|
|
289
|
-
'cron(*/5 * * * *)',
|
|
290
|
-
'cron(0 0-23/2 * * *)',
|
|
291
|
-
'cron(30 4 1,15 * *)',
|
|
292
|
-
'cron(0 12 * DEC MON)',
|
|
293
|
-
];
|
|
294
|
-
|
|
295
|
-
validCrons.forEach((cron) => {
|
|
296
|
-
const builder = new CronBuilder();
|
|
297
|
-
expect(() => builder.schedule(cron)).not.toThrow();
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('should work with complex cron patterns', () => {
|
|
302
|
-
const complexPatterns: CronExpression[] = [
|
|
303
|
-
'cron(*/15 * * * *)', // Every 15 minutes
|
|
304
|
-
'cron(0 */4 * * *)', // Every 4 hours
|
|
305
|
-
'cron(0 9-17 * * MON-FRI)', // Every hour 9-5 on weekdays
|
|
306
|
-
'cron(0 0 1-7 * SUN)', // First Sunday of month
|
|
307
|
-
'cron(*/30 8-18 * * *)', // Every 30 min during business hours
|
|
308
|
-
];
|
|
309
|
-
|
|
310
|
-
complexPatterns.forEach((pattern) => {
|
|
311
|
-
const builder = new CronBuilder();
|
|
312
|
-
expect(() => builder.schedule(pattern)).not.toThrow();
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it('should handle all month names', () => {
|
|
317
|
-
const months: CronExpression[] = [
|
|
318
|
-
'cron(0 0 1 JAN *)',
|
|
319
|
-
'cron(0 0 1 FEB *)',
|
|
320
|
-
'cron(0 0 1 MAR *)',
|
|
321
|
-
'cron(0 0 1 APR *)',
|
|
322
|
-
'cron(0 0 1 MAY *)',
|
|
323
|
-
'cron(0 0 1 JUN *)',
|
|
324
|
-
'cron(0 0 1 JUL *)',
|
|
325
|
-
'cron(0 0 1 AUG *)',
|
|
326
|
-
'cron(0 0 1 SEP *)',
|
|
327
|
-
'cron(0 0 1 OCT *)',
|
|
328
|
-
'cron(0 0 1 NOV *)',
|
|
329
|
-
'cron(0 0 1 DEC *)',
|
|
330
|
-
];
|
|
331
|
-
|
|
332
|
-
months.forEach((expression) => {
|
|
333
|
-
const builder = new CronBuilder();
|
|
334
|
-
expect(() => builder.schedule(expression)).not.toThrow();
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it('should handle all weekday names', () => {
|
|
339
|
-
const weekdays: CronExpression[] = [
|
|
340
|
-
'cron(0 0 * * SUN)',
|
|
341
|
-
'cron(0 0 * * MON)',
|
|
342
|
-
'cron(0 0 * * TUE)',
|
|
343
|
-
'cron(0 0 * * WED)',
|
|
344
|
-
'cron(0 0 * * THU)',
|
|
345
|
-
'cron(0 0 * * FRI)',
|
|
346
|
-
'cron(0 0 * * SAT)',
|
|
347
|
-
];
|
|
348
|
-
|
|
349
|
-
weekdays.forEach((expression) => {
|
|
350
|
-
const builder = new CronBuilder();
|
|
351
|
-
expect(() => builder.schedule(expression)).not.toThrow();
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
describe('Cron configuration', () => {
|
|
357
|
-
it('should store handler with error handling capability', () => {
|
|
358
|
-
const error = new Error('Cron execution failed');
|
|
359
|
-
const handler = vi.fn().mockRejectedValue(error);
|
|
360
|
-
|
|
361
|
-
const cron = new Cron(handler);
|
|
362
|
-
|
|
363
|
-
expect(cron).toBeInstanceOf(Cron);
|
|
364
|
-
// Handler is stored but not directly accessible (protected)
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('should store input schema for validation', () => {
|
|
368
|
-
const inputSchema = z.object({
|
|
369
|
-
id: z.string().uuid(),
|
|
370
|
-
amount: z.number().positive(),
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
const handler = vi.fn();
|
|
374
|
-
const cron = new Cron(handler, undefined, undefined, inputSchema);
|
|
375
|
-
|
|
376
|
-
expect(cron.input).toBe(inputSchema);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it('should store output schema for validation', () => {
|
|
380
|
-
const outputSchema = z.object({
|
|
381
|
-
status: z.enum(['success', 'failure']),
|
|
382
|
-
count: z.number().int(),
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
const handler = vi.fn().mockResolvedValue({
|
|
386
|
-
status: 'invalid',
|
|
387
|
-
count: 3.14,
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
const cron = new Cron(
|
|
391
|
-
handler,
|
|
392
|
-
undefined,
|
|
393
|
-
undefined,
|
|
394
|
-
undefined,
|
|
395
|
-
outputSchema,
|
|
396
|
-
);
|
|
397
|
-
|
|
398
|
-
expect(cron.outputSchema).toBe(outputSchema);
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('should work with multiple services', () => {
|
|
402
|
-
class ServiceA implements Service<'ServiceA', ServiceA> {
|
|
403
|
-
serviceName = 'ServiceA' as const;
|
|
404
|
-
async register() {
|
|
405
|
-
return this;
|
|
406
|
-
}
|
|
407
|
-
getA() {
|
|
408
|
-
return 'A';
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
class ServiceB implements Service<'ServiceB', ServiceB> {
|
|
413
|
-
serviceName = 'ServiceB' as const;
|
|
414
|
-
async register() {
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
|
-
getB() {
|
|
418
|
-
return 'B';
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const services = [new ServiceA(), new ServiceB()];
|
|
423
|
-
|
|
424
|
-
const handler = vi.fn().mockImplementation(async ({ services }) => {
|
|
425
|
-
return {
|
|
426
|
-
a: services.ServiceA.getA(),
|
|
427
|
-
b: services.ServiceB.getB(),
|
|
428
|
-
};
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
const cron = new Cron(
|
|
432
|
-
handler,
|
|
433
|
-
undefined,
|
|
434
|
-
undefined,
|
|
435
|
-
undefined,
|
|
436
|
-
undefined,
|
|
437
|
-
services,
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
expect(cron.services).toEqual(services);
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
it('should maintain separate instances with different configurations', () => {
|
|
444
|
-
const handler1 = vi.fn().mockResolvedValue({ cron: 1 });
|
|
445
|
-
const handler2 = vi.fn().mockResolvedValue({ cron: 2 });
|
|
446
|
-
|
|
447
|
-
const cron1 = new CronBuilder()
|
|
448
|
-
.timeout(1000)
|
|
449
|
-
.schedule('rate(5 minutes)')
|
|
450
|
-
.handle(handler1);
|
|
451
|
-
|
|
452
|
-
const cron2 = new CronBuilder()
|
|
453
|
-
.timeout(2000)
|
|
454
|
-
.schedule('cron(0 0 * * *)')
|
|
455
|
-
.handle(handler2);
|
|
456
|
-
|
|
457
|
-
expect(cron1).toBeInstanceOf(Cron);
|
|
458
|
-
expect(cron2).toBeInstanceOf(Cron);
|
|
459
|
-
expect(cron1.timeout).toBe(1000);
|
|
460
|
-
expect(cron2.timeout).toBe(2000);
|
|
461
|
-
expect(cron1).not.toBe(cron2);
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
});
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger } from '@geekmidas/logger/console';
|
|
2
|
-
import type { Service } from '@geekmidas/services';
|
|
3
|
-
import { describe, expect, it } from 'vitest';
|
|
4
|
-
import { CronBuilder } from '../CronBuilder';
|
|
5
|
-
|
|
6
|
-
const ServiceA = {
|
|
7
|
-
serviceName: 'a' as const,
|
|
8
|
-
async register() {
|
|
9
|
-
return { test: () => 'a' };
|
|
10
|
-
},
|
|
11
|
-
} satisfies Service<'a', any>;
|
|
12
|
-
|
|
13
|
-
const ServiceB = {
|
|
14
|
-
serviceName: 'b' as const,
|
|
15
|
-
async register() {
|
|
16
|
-
return { test: () => 'b' };
|
|
17
|
-
},
|
|
18
|
-
} satisfies Service<'b', any>;
|
|
19
|
-
|
|
20
|
-
describe('CronBuilder - State Isolation', () => {
|
|
21
|
-
describe('singleton instance state reset', () => {
|
|
22
|
-
it('should reset services after handle() is called', () => {
|
|
23
|
-
const c = new CronBuilder();
|
|
24
|
-
|
|
25
|
-
// First cron with ServiceA and ServiceB
|
|
26
|
-
const cron1 = c
|
|
27
|
-
.schedule('rate(5 minutes)')
|
|
28
|
-
.services([ServiceA, ServiceB])
|
|
29
|
-
.handle(async () => ({}));
|
|
30
|
-
|
|
31
|
-
// Second cron should not have any services from first
|
|
32
|
-
const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
|
|
33
|
-
|
|
34
|
-
expect(cron1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
|
|
35
|
-
expect(cron2.services.map((s) => s.serviceName)).toEqual([]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should reset logger after handle() is called', () => {
|
|
39
|
-
const c = new CronBuilder();
|
|
40
|
-
const customLogger = new ConsoleLogger({ app: 'custom' });
|
|
41
|
-
|
|
42
|
-
// First cron with custom logger
|
|
43
|
-
const cron1 = c
|
|
44
|
-
.schedule('rate(5 minutes)')
|
|
45
|
-
.logger(customLogger)
|
|
46
|
-
.handle(async () => ({}));
|
|
47
|
-
|
|
48
|
-
// Second cron should have default logger (not the custom one)
|
|
49
|
-
const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
|
|
50
|
-
|
|
51
|
-
expect(cron1.logger).toBe(customLogger);
|
|
52
|
-
expect(cron2.logger).not.toBe(customLogger);
|
|
53
|
-
expect(cron2.logger).toBeInstanceOf(ConsoleLogger);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should reset schedule after handle() is called', () => {
|
|
57
|
-
const c = new CronBuilder();
|
|
58
|
-
|
|
59
|
-
// First cron with schedule
|
|
60
|
-
const cron1 = c.schedule('rate(5 minutes)').handle(async () => ({}));
|
|
61
|
-
|
|
62
|
-
// Second cron should not have schedule from first
|
|
63
|
-
const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
|
|
64
|
-
|
|
65
|
-
expect(cron1.schedule).toBe('rate(5 minutes)');
|
|
66
|
-
expect(cron2.schedule).toBe('rate(10 minutes)');
|
|
67
|
-
|
|
68
|
-
// Check internal state is reset
|
|
69
|
-
expect((c as any)._schedule).toBeUndefined();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should reset events after handle() is called', () => {
|
|
73
|
-
const c = new CronBuilder();
|
|
74
|
-
|
|
75
|
-
// Create first cron (events array should be empty initially)
|
|
76
|
-
const _cron1 = c.schedule('rate(5 minutes)').handle(async () => ({}));
|
|
77
|
-
|
|
78
|
-
// Verify state was reset
|
|
79
|
-
expect((c as any)._events).toEqual([]);
|
|
80
|
-
expect((c as any)._services).toEqual([]);
|
|
81
|
-
expect((c as any)._schedule).toBeUndefined();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should reset input/output schemas after handle() is called', () => {
|
|
85
|
-
const c = new CronBuilder();
|
|
86
|
-
const inputSchema: any = { '~standard': { validate: () => ({}) } };
|
|
87
|
-
const outputSchema: any = { '~standard': { validate: () => ({}) } };
|
|
88
|
-
|
|
89
|
-
// First cron with schemas
|
|
90
|
-
const cron1 = c
|
|
91
|
-
.schedule('rate(5 minutes)')
|
|
92
|
-
.input(inputSchema)
|
|
93
|
-
.output(outputSchema)
|
|
94
|
-
.handle(async () => ({}));
|
|
95
|
-
|
|
96
|
-
// Second cron should not have schemas
|
|
97
|
-
const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
|
|
98
|
-
|
|
99
|
-
expect(cron1.input).toBe(inputSchema);
|
|
100
|
-
expect(cron1.outputSchema).toBe(outputSchema);
|
|
101
|
-
expect(cron2.input).toBeUndefined();
|
|
102
|
-
expect(cron2.outputSchema).toBeUndefined();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should reset timeout after handle() is called', () => {
|
|
106
|
-
const c = new CronBuilder();
|
|
107
|
-
|
|
108
|
-
// First cron with custom timeout
|
|
109
|
-
const cron1 = c
|
|
110
|
-
.schedule('rate(5 minutes)')
|
|
111
|
-
.timeout(5000)
|
|
112
|
-
.handle(async () => ({}));
|
|
113
|
-
|
|
114
|
-
// Second cron should have default timeout (30000)
|
|
115
|
-
const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
|
|
116
|
-
|
|
117
|
-
expect(cron1.timeout).toBe(5000);
|
|
118
|
-
expect(cron2.timeout).toBe(30000); // Default timeout
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('method chaining before handle()', () => {
|
|
123
|
-
it('should accumulate services when chaining', () => {
|
|
124
|
-
const c = new CronBuilder();
|
|
125
|
-
|
|
126
|
-
const cron = c
|
|
127
|
-
.schedule('rate(5 minutes)')
|
|
128
|
-
.services([ServiceA])
|
|
129
|
-
.services([ServiceB])
|
|
130
|
-
.handle(async () => ({}));
|
|
131
|
-
|
|
132
|
-
expect(cron.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('should not share references between different builder chains', () => {
|
|
136
|
-
const c = new CronBuilder();
|
|
137
|
-
|
|
138
|
-
// Start two separate chains
|
|
139
|
-
const builder1 = c.schedule('rate(5 minutes)').services([ServiceA]);
|
|
140
|
-
const builder2 = c.schedule('rate(10 minutes)').services([ServiceB]);
|
|
141
|
-
|
|
142
|
-
// They should be the same instance (singleton)
|
|
143
|
-
expect(builder1).toBe(builder2);
|
|
144
|
-
expect(builder1).toBe(c);
|
|
145
|
-
|
|
146
|
-
// But after handle, state is reset
|
|
147
|
-
const cron1 = builder1.handle(async () => ({}));
|
|
148
|
-
|
|
149
|
-
// Now builder2 should have reset state
|
|
150
|
-
expect((builder2 as any)._services).toEqual([]);
|
|
151
|
-
|
|
152
|
-
// Add services again
|
|
153
|
-
const cron2 = builder2
|
|
154
|
-
.schedule('rate(15 minutes)')
|
|
155
|
-
.services([ServiceB])
|
|
156
|
-
.handle(async () => ({}));
|
|
157
|
-
|
|
158
|
-
expect(cron1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
|
|
159
|
-
expect(cron2.services.map((s) => s.serviceName)).toEqual(['b']);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('sequential cron creation', () => {
|
|
164
|
-
it('should create independent crons sequentially', () => {
|
|
165
|
-
const c = new CronBuilder();
|
|
166
|
-
|
|
167
|
-
const cron1 = c
|
|
168
|
-
.schedule('rate(5 minutes)')
|
|
169
|
-
.services([ServiceA, ServiceB])
|
|
170
|
-
.handle(async () => ({ result: 1 }));
|
|
171
|
-
|
|
172
|
-
const cron2 = c
|
|
173
|
-
.schedule('rate(10 minutes)')
|
|
174
|
-
.services([ServiceA])
|
|
175
|
-
.handle(async () => ({ result: 2 }));
|
|
176
|
-
|
|
177
|
-
const cron3 = c
|
|
178
|
-
.schedule('rate(15 minutes)')
|
|
179
|
-
.handle(async () => ({ result: 3 }));
|
|
180
|
-
|
|
181
|
-
expect(cron1.services.map((s) => s.serviceName)).toEqual(['a', 'b']);
|
|
182
|
-
expect(cron1.schedule).toBe('rate(5 minutes)');
|
|
183
|
-
|
|
184
|
-
expect(cron2.services.map((s) => s.serviceName)).toEqual(['a']);
|
|
185
|
-
expect(cron2.schedule).toBe('rate(10 minutes)');
|
|
186
|
-
|
|
187
|
-
expect(cron3.services.map((s) => s.serviceName)).toEqual([]);
|
|
188
|
-
expect(cron3.schedule).toBe('rate(15 minutes)');
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
describe('publisher isolation', () => {
|
|
193
|
-
it('should reset publisher after handle() is called', () => {
|
|
194
|
-
const c = new CronBuilder();
|
|
195
|
-
const mockPublisher: any = {
|
|
196
|
-
serviceName: 'publisher',
|
|
197
|
-
async register() {
|
|
198
|
-
return { publish: () => {} };
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const cron1 = c
|
|
203
|
-
.schedule('rate(5 minutes)')
|
|
204
|
-
.publisher(mockPublisher)
|
|
205
|
-
.handle(async () => ({}));
|
|
206
|
-
|
|
207
|
-
const cron2 = c.schedule('rate(10 minutes)').handle(async () => ({}));
|
|
208
|
-
|
|
209
|
-
expect((cron1 as any).publisherService).toBe(mockPublisher);
|
|
210
|
-
expect((cron2 as any).publisherService).toBeUndefined();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe('cron expression types', () => {
|
|
215
|
-
it('should handle different schedule expression formats', () => {
|
|
216
|
-
const c = new CronBuilder();
|
|
217
|
-
|
|
218
|
-
const cron1 = c.schedule('rate(5 minutes)').handle(async () => ({}));
|
|
219
|
-
const cron2 = c.schedule('cron(0 12 * * ? *)').handle(async () => ({}));
|
|
220
|
-
const cron3 = c.schedule('rate(1 hour)').handle(async () => ({}));
|
|
221
|
-
|
|
222
|
-
expect(cron1.schedule).toBe('rate(5 minutes)');
|
|
223
|
-
expect(cron2.schedule).toBe('cron(0 12 * * ? *)');
|
|
224
|
-
expect(cron3.schedule).toBe('rate(1 hour)');
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
});
|
package/src/crons/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { AWSScheduledFunction } from './AWSScheduledFunction';
|
|
2
|
-
export {
|
|
3
|
-
Cron,
|
|
4
|
-
type CronExpression,
|
|
5
|
-
type RateExpression,
|
|
6
|
-
type ScheduleExpression,
|
|
7
|
-
} from './Cron';
|
|
8
|
-
export { CronBuilder } from './CronBuilder';
|
|
9
|
-
|
|
10
|
-
import { CronBuilder } from './CronBuilder';
|
|
11
|
-
|
|
12
|
-
export const c = new CronBuilder();
|