@geekmidas/constructs 10.0.0-alpha.0 → 10.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Construct-HmWM6YYu.mjs → Construct-BD5neF7w.mjs} +15 -2
- package/dist/Construct-BD5neF7w.mjs.map +1 -0
- package/dist/{Construct-WhCXIOPV.d.cts → Construct-C0ijr2qp.d.cts} +14 -1
- package/dist/Construct-C0ijr2qp.d.cts.map +1 -0
- package/dist/{Construct-B-xc0SE9.d.mts → Construct-Ct8nalEi.d.mts} +14 -1
- package/dist/Construct-Ct8nalEi.d.mts.map +1 -0
- package/dist/{Construct-roId57cU.cjs → Construct-CyS3RpTL.cjs} +14 -1
- package/dist/Construct-CyS3RpTL.cjs.map +1 -0
- package/dist/Cron-ByxdOfpE.d.mts +31 -0
- package/dist/Cron-ByxdOfpE.d.mts.map +1 -0
- package/dist/Cron-Wqh464aO.d.cts +31 -0
- package/dist/Cron-Wqh464aO.d.cts.map +1 -0
- package/dist/CronBuilder-BL0AP6fs.d.mts +44 -0
- package/dist/CronBuilder-BL0AP6fs.d.mts.map +1 -0
- package/dist/CronBuilder-BmABazzH.mjs +84 -0
- package/dist/CronBuilder-BmABazzH.mjs.map +1 -0
- package/dist/CronBuilder-BqpEzMPQ.d.cts +44 -0
- package/dist/CronBuilder-BqpEzMPQ.d.cts.map +1 -0
- package/dist/CronBuilder-CkXPJiGO.cjs +96 -0
- package/dist/CronBuilder-CkXPJiGO.cjs.map +1 -0
- package/dist/{Endpoint-ROcXU-eH.d.mts → Endpoint-2Wg7T7Cq.d.mts} +2 -2
- package/dist/{Endpoint-ROcXU-eH.d.mts.map → Endpoint-2Wg7T7Cq.d.mts.map} +1 -1
- package/dist/{Endpoint-BBkV6l0k.cjs → Endpoint-BiaaMEn_.cjs} +3 -3
- package/dist/{Endpoint-BBkV6l0k.cjs.map → Endpoint-BiaaMEn_.cjs.map} +1 -1
- package/dist/{Endpoint-BnxZqIX-.d.cts → Endpoint-CH9Fn1AD.d.cts} +2 -2
- package/dist/{Endpoint-BnxZqIX-.d.cts.map → Endpoint-CH9Fn1AD.d.cts.map} +1 -1
- package/dist/{Endpoint-BGwpNEX4.mjs → Endpoint-VIOpSo0S.mjs} +3 -3
- package/dist/{Endpoint-BGwpNEX4.mjs.map → Endpoint-VIOpSo0S.mjs.map} +1 -1
- package/dist/{EndpointFactory-DYoGLaIT.cjs → EndpointFactory-ChxLZllA.cjs} +7 -5
- package/dist/EndpointFactory-ChxLZllA.cjs.map +1 -0
- package/dist/{EndpointFactory-Di0X9AWp.mjs → EndpointFactory-DTTCkGEL.mjs} +7 -5
- package/dist/EndpointFactory-DTTCkGEL.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-wMsCyMgt.cjs → HonoEndpointAdaptor-D233Jvpk.cjs} +5 -6
- package/dist/{HonoEndpointAdaptor-wMsCyMgt.cjs.map → HonoEndpointAdaptor-D233Jvpk.cjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-DFKIIG2o.mjs → HonoEndpointAdaptor-NKQQQbBY.mjs} +4 -5
- package/dist/{HonoEndpointAdaptor-DFKIIG2o.mjs.map → HonoEndpointAdaptor-NKQQQbBY.mjs.map} +1 -1
- package/dist/{Queue-D6WeziRD.d.cts → Queue-D7ZuwBhy.d.cts} +2 -2
- package/dist/{Queue-D6WeziRD.d.cts.map → Queue-D7ZuwBhy.d.cts.map} +1 -1
- package/dist/{Queue-DpUeqdC8.d.mts → Queue-gVGfi2Yk.d.mts} +2 -2
- package/dist/{Queue-DpUeqdC8.d.mts.map → Queue-gVGfi2Yk.d.mts.map} +1 -1
- package/dist/{Subscriber-4rBJgDKI.d.mts → Subscriber-2mEi0ImH.d.cts} +3 -3
- package/dist/{Subscriber-4rBJgDKI.d.mts.map → Subscriber-2mEi0ImH.d.cts.map} +1 -1
- package/dist/{Subscriber-DVQowdyj.d.cts → Subscriber-xTJ9ayPN.d.mts} +3 -3
- package/dist/{Subscriber-DVQowdyj.d.cts.map → Subscriber-xTJ9ayPN.d.mts.map} +1 -1
- package/dist/SubscriberBuilder-4OPehf2R.cjs +120 -0
- package/dist/SubscriberBuilder-4OPehf2R.cjs.map +1 -0
- package/dist/SubscriberBuilder-BjkbeT9l.mjs +108 -0
- package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +1 -0
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts +62 -0
- package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +1 -0
- package/dist/SubscriberBuilder-waNhzjSM.d.cts +62 -0
- package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +1 -0
- package/dist/{Topic-Ohx9dvWr.d.cts → Topic-19QeHBIR.d.cts} +2 -2
- package/dist/{Topic-Ohx9dvWr.d.cts.map → Topic-19QeHBIR.d.cts.map} +1 -1
- package/dist/{Topic-cmy2jOUy.d.mts → Topic-DuFeqkBh.d.mts} +2 -2
- package/dist/{Topic-cmy2jOUy.d.mts.map → Topic-DuFeqkBh.d.mts.map} +1 -1
- package/dist/adaptors/aws.cjs +243 -10
- package/dist/adaptors/aws.cjs.map +1 -1
- package/dist/adaptors/aws.d.cts +99 -10
- package/dist/adaptors/aws.d.cts.map +1 -1
- package/dist/adaptors/aws.d.mts +99 -10
- package/dist/adaptors/aws.d.mts.map +1 -1
- package/dist/adaptors/aws.mjs +240 -7
- package/dist/adaptors/aws.mjs.map +1 -1
- package/dist/adaptors/hono.cjs +6 -7
- package/dist/adaptors/hono.d.cts +6 -6
- package/dist/adaptors/hono.d.mts +6 -6
- package/dist/adaptors/hono.mjs +6 -7
- package/dist/adaptors/testing.cjs +9 -10
- package/dist/adaptors/testing.cjs.map +1 -1
- package/dist/adaptors/testing.d.cts +6 -6
- package/dist/adaptors/testing.d.mts +6 -6
- package/dist/adaptors/testing.mjs +6 -7
- package/dist/adaptors/testing.mjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.mts +1 -1
- package/dist/{cache-CdQ7OLpR.d.cts → cache-BrRz3fEB.d.mts} +3 -3
- package/dist/{cache-CdQ7OLpR.d.cts.map → cache-BrRz3fEB.d.mts.map} +1 -1
- package/dist/{cache-DYoJFcfd.d.mts → cache-BtZY_tHe.d.cts} +3 -3
- package/dist/{cache-DYoJFcfd.d.mts.map → cache-BtZY_tHe.d.cts.map} +1 -1
- package/dist/cache.d.cts +2 -2
- package/dist/cache.d.mts +2 -2
- package/dist/{construct-interface-BqwRNYA2.d.mts → construct-interface-D9d4Gm4p.d.cts} +2 -2
- package/dist/{construct-interface-BqwRNYA2.d.mts.map → construct-interface-D9d4Gm4p.d.cts.map} +1 -1
- package/dist/{construct-interface-D2nNkHUN.d.cts → construct-interface-g5GM5pwR.d.mts} +2 -2
- package/dist/{construct-interface-D2nNkHUN.d.cts.map → construct-interface-g5GM5pwR.d.mts.map} +1 -1
- package/dist/construct-interface.d.cts +1 -1
- package/dist/construct-interface.d.mts +1 -1
- package/dist/credential.d.cts +1 -1
- package/dist/credential.d.mts +1 -1
- package/dist/crons/index.cjs +8 -87
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +10 -46
- package/dist/crons/index.d.cts.map +1 -1
- package/dist/crons/index.d.mts +10 -46
- package/dist/crons/index.d.mts.map +1 -1
- package/dist/crons/index.mjs +6 -83
- package/dist/crons/index.mjs.map +1 -1
- package/dist/database/kysely.d.cts +2 -2
- package/dist/database/kysely.d.mts +2 -2
- package/dist/email.d.cts +1 -1
- package/dist/email.d.mts +1 -1
- package/dist/endpoints/index.cjs +6 -7
- package/dist/endpoints/index.d.cts +5 -5
- package/dist/endpoints/index.d.mts +5 -5
- package/dist/endpoints/index.mjs +5 -6
- package/dist/file-server.d.cts +1 -1
- package/dist/file-server.d.mts +1 -1
- package/dist/functions/index.cjs +2 -2
- package/dist/functions/index.d.cts +3 -3
- package/dist/functions/index.d.mts +3 -3
- package/dist/functions/index.mjs +2 -2
- package/dist/{functions-DukjG8ov.cjs → functions-Bd3TPxid.cjs} +10 -2
- package/dist/{functions-DukjG8ov.cjs.map → functions-Bd3TPxid.cjs.map} +1 -1
- package/dist/{functions-CvT_q7Y4.mjs → functions-Cxbo-pEd.mjs} +10 -2
- package/dist/{functions-CvT_q7Y4.mjs.map → functions-Cxbo-pEd.mjs.map} +1 -1
- package/dist/{index-Bt-F7u8L.d.mts → index-BxHDdy6a.d.mts} +5 -5
- package/dist/{index-7OcOWe75.d.cts.map → index-BxHDdy6a.d.mts.map} +1 -1
- package/dist/{index-Dadljnh_.d.cts → index-CubPzHd9.d.mts} +16 -9
- package/dist/index-CubPzHd9.d.mts.map +1 -0
- package/dist/{index-CPeqtKgq.d.mts → index-JSf9xNIJ.d.cts} +22 -14
- package/dist/index-JSf9xNIJ.d.cts.map +1 -0
- package/dist/{index-7OcOWe75.d.cts → index-V2nksZIJ.d.cts} +5 -5
- package/dist/{index-Bt-F7u8L.d.mts.map → index-V2nksZIJ.d.cts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{lazyAccessors-DM6HcXQk.mjs → lazyAccessors-BoJN3SMd.mjs} +41 -2
- package/dist/lazyAccessors-BoJN3SMd.mjs.map +1 -0
- package/dist/{lazyAccessors-DrJj8NpA.cjs → lazyAccessors-e3j2oE2m.cjs} +52 -1
- package/dist/lazyAccessors-e3j2oE2m.cjs.map +1 -0
- package/dist/object-storage.d.cts +1 -1
- package/dist/object-storage.d.mts +1 -1
- package/dist/{processAudits-Bc8rz6Ev.cjs → processAudits-CGqttuXm.cjs} +1 -1
- package/dist/{processAudits-Bc8rz6Ev.cjs.map → processAudits-CGqttuXm.cjs.map} +1 -1
- package/dist/{processAudits-D89tICM4.mjs → processAudits-Dmts9H_b.mjs} +1 -1
- package/dist/{processAudits-D89tICM4.mjs.map → processAudits-Dmts9H_b.mjs.map} +1 -1
- package/dist/queue/index.cjs +1 -1
- package/dist/queue/index.d.cts +5 -5
- package/dist/queue/index.d.mts +5 -5
- package/dist/queue/index.mjs +1 -1
- package/dist/rest-api.cjs +4 -4
- package/dist/rest-api.d.cts +5 -5
- package/dist/rest-api.d.mts +11 -11
- package/dist/rest-api.d.mts.map +1 -1
- package/dist/rest-api.mjs +4 -4
- package/dist/site.d.cts +1 -1
- package/dist/site.d.mts +1 -1
- package/dist/subscribers/index.cjs +7 -103
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +7 -56
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +7 -56
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +4 -99
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/topic/index.cjs +1 -1
- package/dist/topic/index.d.cts +2 -2
- package/dist/topic/index.d.mts +2 -2
- package/dist/topic/index.mjs +1 -1
- package/dist/worker.cjs +91 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +95 -0
- package/dist/worker.d.cts.map +1 -0
- package/dist/worker.d.mts +95 -0
- package/dist/worker.d.mts.map +1 -0
- package/dist/worker.mjs +90 -0
- package/dist/worker.mjs.map +1 -0
- package/package.json +44 -52
- package/dist/AWSScheduledFunction-BvFvBsBN.d.cts +0 -122
- package/dist/AWSScheduledFunction-BvFvBsBN.d.cts.map +0 -1
- package/dist/AWSScheduledFunction-CVccZO-L.d.mts +0 -122
- package/dist/AWSScheduledFunction-CVccZO-L.d.mts.map +0 -1
- package/dist/AWSScheduledFunction-Db1lttJH.mjs +0 -243
- package/dist/AWSScheduledFunction-Db1lttJH.mjs.map +0 -1
- package/dist/AWSScheduledFunction-qu4ieRZR.cjs +0 -255
- package/dist/AWSScheduledFunction-qu4ieRZR.cjs.map +0 -1
- package/dist/Construct-B-xc0SE9.d.mts.map +0 -1
- package/dist/Construct-HmWM6YYu.mjs.map +0 -1
- package/dist/Construct-WhCXIOPV.d.cts.map +0 -1
- package/dist/Construct-roId57cU.cjs.map +0 -1
- package/dist/EndpointFactory-DYoGLaIT.cjs.map +0 -1
- package/dist/EndpointFactory-Di0X9AWp.mjs.map +0 -1
- package/dist/index-CPeqtKgq.d.mts.map +0 -1
- package/dist/index-Dadljnh_.d.cts.map +0 -1
- package/dist/lazyAccessors-DM6HcXQk.mjs.map +0 -1
- package/dist/lazyAccessors-DrJj8NpA.cjs.map +0 -1
- package/dist/publisher-CGEo8UKD.mjs +0 -41
- package/dist/publisher-CGEo8UKD.mjs.map +0 -1
- package/dist/publisher-CqGsXB2X.cjs +0 -53
- package/dist/publisher-CqGsXB2X.cjs.map +0 -1
|
@@ -1,61 +1,12 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import
|
|
3
|
-
import { Subscriber
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import * as
|
|
7
|
-
import { Logger } from "@geekmidas/logger";
|
|
8
|
-
import { Service } from "@geekmidas/services";
|
|
9
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
1
|
+
import "../Construct-C0ijr2qp.cjs";
|
|
2
|
+
import "../construct-interface-D9d4Gm4p.cjs";
|
|
3
|
+
import { Subscriber } from "../Subscriber-2mEi0ImH.cjs";
|
|
4
|
+
import "../Topic-19QeHBIR.cjs";
|
|
5
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-waNhzjSM.cjs";
|
|
6
|
+
import * as _geekmidas_logger24 from "@geekmidas/logger";
|
|
10
7
|
|
|
11
|
-
//#region src/subscribers/SubscriberBuilder.d.ts
|
|
12
|
-
declare class SubscriberBuilder<TServices extends Service[] = [], TLogger extends Logger = Logger, OutSchema extends StandardSchemaV1 | undefined = undefined, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string, TSubscribedEvents extends any[] = []> {
|
|
13
|
-
private _subscribedEvents;
|
|
14
|
-
private _timeout?;
|
|
15
|
-
private outputSchema?;
|
|
16
|
-
private _services;
|
|
17
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
18
|
-
_constructs: string[];
|
|
19
|
-
private _logger;
|
|
20
|
-
private _publisher?;
|
|
21
|
-
private _topicName?;
|
|
22
|
-
constructor();
|
|
23
|
-
/**
|
|
24
|
-
* Bind this subscriber to a {@link Topic} — the preferred way to type and wire
|
|
25
|
-
* a fan-out consumer. It supplies the subscribable event types (and their
|
|
26
|
-
* payloads) from the topic's contract and records the binding for the manifest,
|
|
27
|
-
* so infra wires the SNS subscription.
|
|
28
|
-
*
|
|
29
|
-
* Prefer this over typing via a hand-written publisher service: a consumer does
|
|
30
|
-
* not publish, so binding a topic does *not* require the topic's publisher
|
|
31
|
-
* connection string (least privilege). Use `.publisher(...)` only when the
|
|
32
|
-
* subscriber actually publishes follow-up events.
|
|
33
|
-
*/
|
|
34
|
-
topic<TName extends string, TEvents extends TopicEvents>(topic: Topic<TName, TEvents>): SubscriberBuilder<TServices, TLogger, OutSchema, EventPublisher<TopicMessage<TEvents>>, TEventPublisherServiceName, TSubscribedEvents>;
|
|
35
|
-
timeout(timeout: number): this;
|
|
36
|
-
output<T extends StandardSchemaV1>(schema: T): SubscriberBuilder<TServices, TLogger, T, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
37
|
-
/**
|
|
38
|
-
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
39
|
-
* topic.
|
|
40
|
-
*
|
|
41
|
-
* It records the edge and dissolves each construct's client into the
|
|
42
|
-
* handler's service record under the construct's own id, so
|
|
43
|
-
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
44
|
-
*
|
|
45
|
-
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
46
|
-
* env sniffing confined to `.services()` and the explicit lift.
|
|
47
|
-
*/
|
|
48
|
-
dependsOn<const T extends readonly Consumable[]>(constructs: T): SubscriberBuilder<[...TServices, ...ServicesOf<T>], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
49
|
-
services<T extends Service[]>(services: T): SubscriberBuilder<[...TServices, ...T], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
50
|
-
logger<T extends Logger>(logger: T): SubscriberBuilder<TServices, T, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
51
|
-
publisher<T extends EventPublisher<any>, TName extends string>(publisher: Service<TName, T>): SubscriberBuilder<TServices, TLogger, OutSchema, T, TName, TSubscribedEvents>;
|
|
52
|
-
subscribe<TEvent extends (TEventPublisher extends EventPublisher<any> ? ExtractPublisherMessage<TEventPublisher>['type'] | ExtractPublisherMessage<TEventPublisher>['type'][] : never)>(event: TEvent): SubscriberBuilder<TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TEvent extends any[] ? [...TSubscribedEvents, ...TEvent] : [...TSubscribedEvents, TEvent]>;
|
|
53
|
-
handle(fn: SubscriberHandler<TEventPublisher, TSubscribedEvents, TServices, TLogger, OutSchema>): Subscriber<TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=SubscriberBuilder.d.ts.map
|
|
56
|
-
//#endregion
|
|
57
8
|
//#region src/subscribers/index.d.ts
|
|
58
|
-
declare const s: SubscriberBuilder<[],
|
|
9
|
+
declare const s: SubscriberBuilder<[], _geekmidas_logger24.Logger, undefined, undefined, string, []>;
|
|
59
10
|
//# sourceMappingURL=index.d.ts.map
|
|
60
11
|
|
|
61
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAKa,GAAC,sBAA0B,mBAAA,CAA1B,MAAA"}
|
|
@@ -1,61 +1,12 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import
|
|
3
|
-
import { Subscriber
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import * as _geekmidas_logger16 from "@geekmidas/logger";
|
|
8
|
-
import { Logger } from "@geekmidas/logger";
|
|
9
|
-
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
1
|
+
import "../Construct-Ct8nalEi.mjs";
|
|
2
|
+
import "../construct-interface-g5GM5pwR.mjs";
|
|
3
|
+
import { Subscriber } from "../Subscriber-xTJ9ayPN.mjs";
|
|
4
|
+
import "../Topic-DuFeqkBh.mjs";
|
|
5
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-Dptmo-1A.mjs";
|
|
6
|
+
import * as _geekmidas_logger25 from "@geekmidas/logger";
|
|
10
7
|
|
|
11
|
-
//#region src/subscribers/SubscriberBuilder.d.ts
|
|
12
|
-
declare class SubscriberBuilder<TServices extends Service[] = [], TLogger extends Logger = Logger, OutSchema extends StandardSchemaV1 | undefined = undefined, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string, TSubscribedEvents extends any[] = []> {
|
|
13
|
-
private _subscribedEvents;
|
|
14
|
-
private _timeout?;
|
|
15
|
-
private outputSchema?;
|
|
16
|
-
private _services;
|
|
17
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
18
|
-
_constructs: string[];
|
|
19
|
-
private _logger;
|
|
20
|
-
private _publisher?;
|
|
21
|
-
private _topicName?;
|
|
22
|
-
constructor();
|
|
23
|
-
/**
|
|
24
|
-
* Bind this subscriber to a {@link Topic} — the preferred way to type and wire
|
|
25
|
-
* a fan-out consumer. It supplies the subscribable event types (and their
|
|
26
|
-
* payloads) from the topic's contract and records the binding for the manifest,
|
|
27
|
-
* so infra wires the SNS subscription.
|
|
28
|
-
*
|
|
29
|
-
* Prefer this over typing via a hand-written publisher service: a consumer does
|
|
30
|
-
* not publish, so binding a topic does *not* require the topic's publisher
|
|
31
|
-
* connection string (least privilege). Use `.publisher(...)` only when the
|
|
32
|
-
* subscriber actually publishes follow-up events.
|
|
33
|
-
*/
|
|
34
|
-
topic<TName extends string, TEvents extends TopicEvents>(topic: Topic<TName, TEvents>): SubscriberBuilder<TServices, TLogger, OutSchema, EventPublisher<TopicMessage<TEvents>>, TEventPublisherServiceName, TSubscribedEvents>;
|
|
35
|
-
timeout(timeout: number): this;
|
|
36
|
-
output<T extends StandardSchemaV1>(schema: T): SubscriberBuilder<TServices, TLogger, T, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
37
|
-
/**
|
|
38
|
-
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
39
|
-
* topic.
|
|
40
|
-
*
|
|
41
|
-
* It records the edge and dissolves each construct's client into the
|
|
42
|
-
* handler's service record under the construct's own id, so
|
|
43
|
-
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
44
|
-
*
|
|
45
|
-
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
46
|
-
* env sniffing confined to `.services()` and the explicit lift.
|
|
47
|
-
*/
|
|
48
|
-
dependsOn<const T extends readonly Consumable[]>(constructs: T): SubscriberBuilder<[...TServices, ...ServicesOf<T>], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
49
|
-
services<T extends Service[]>(services: T): SubscriberBuilder<[...TServices, ...T], TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
50
|
-
logger<T extends Logger>(logger: T): SubscriberBuilder<TServices, T, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
51
|
-
publisher<T extends EventPublisher<any>, TName extends string>(publisher: Service<TName, T>): SubscriberBuilder<TServices, TLogger, OutSchema, T, TName, TSubscribedEvents>;
|
|
52
|
-
subscribe<TEvent extends (TEventPublisher extends EventPublisher<any> ? ExtractPublisherMessage<TEventPublisher>['type'] | ExtractPublisherMessage<TEventPublisher>['type'][] : never)>(event: TEvent): SubscriberBuilder<TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TEvent extends any[] ? [...TSubscribedEvents, ...TEvent] : [...TSubscribedEvents, TEvent]>;
|
|
53
|
-
handle(fn: SubscriberHandler<TEventPublisher, TSubscribedEvents, TServices, TLogger, OutSchema>): Subscriber<TServices, TLogger, OutSchema, TEventPublisher, TEventPublisherServiceName, TSubscribedEvents>;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=SubscriberBuilder.d.ts.map
|
|
56
|
-
//#endregion
|
|
57
8
|
//#region src/subscribers/index.d.ts
|
|
58
|
-
declare const s: SubscriberBuilder<[],
|
|
9
|
+
declare const s: SubscriberBuilder<[], _geekmidas_logger25.Logger, undefined, undefined, string, []>;
|
|
59
10
|
//# sourceMappingURL=index.d.ts.map
|
|
60
11
|
|
|
61
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/subscribers/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAKa,GAAC,sBAA0B,mBAAA,CAA1B,MAAA"}
|
|
@@ -1,103 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import "../Construct-BD5neF7w.mjs";
|
|
2
|
+
import "../construct-interface-Z4CpS8tK.mjs";
|
|
3
|
+
import "../clone-DblgEZZa.mjs";
|
|
4
|
+
import { Subscriber, SubscriberBuilder } from "../SubscriberBuilder-BjkbeT9l.mjs";
|
|
5
5
|
|
|
6
|
-
//#region src/subscribers/Subscriber.ts
|
|
7
|
-
var Subscriber = class extends Construct {
|
|
8
|
-
__IS_SUBSCRIBER__ = true;
|
|
9
|
-
static isSubscriber(obj) {
|
|
10
|
-
return Boolean(obj && obj.__IS_SUBSCRIBER__ === true && obj.type === ConstructType.Subscriber);
|
|
11
|
-
}
|
|
12
|
-
constructor(handler, timeout = 3e4, _subscribedEvents, outputSchema, services = [], logger = DEFAULT_LOGGER, publisherService, topicName, constructs = []) {
|
|
13
|
-
super(ConstructType.Subscriber, logger, services, [], publisherService, outputSchema, timeout, void 0, void 0, constructs);
|
|
14
|
-
this.handler = handler;
|
|
15
|
-
this.timeout = timeout;
|
|
16
|
-
this._subscribedEvents = _subscribedEvents;
|
|
17
|
-
this.outputSchema = outputSchema;
|
|
18
|
-
this.services = services;
|
|
19
|
-
this.logger = logger;
|
|
20
|
-
this.publisherService = publisherService;
|
|
21
|
-
this.topicName = topicName;
|
|
22
|
-
}
|
|
23
|
-
get subscribedEvents() {
|
|
24
|
-
return this._subscribedEvents;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/subscribers/SubscriberBuilder.ts
|
|
30
|
-
var SubscriberBuilder = class {
|
|
31
|
-
_subscribedEvents = [];
|
|
32
|
-
_timeout;
|
|
33
|
-
outputSchema;
|
|
34
|
-
_services = [];
|
|
35
|
-
/** The construct ids `.dependsOn()` named — what the manifest records. */
|
|
36
|
-
_constructs = [];
|
|
37
|
-
_logger = DEFAULT_LOGGER;
|
|
38
|
-
_publisher;
|
|
39
|
-
_topicName;
|
|
40
|
-
constructor() {
|
|
41
|
-
this._timeout = 3e4;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Bind this subscriber to a {@link Topic} — the preferred way to type and wire
|
|
45
|
-
* a fan-out consumer. It supplies the subscribable event types (and their
|
|
46
|
-
* payloads) from the topic's contract and records the binding for the manifest,
|
|
47
|
-
* so infra wires the SNS subscription.
|
|
48
|
-
*
|
|
49
|
-
* Prefer this over typing via a hand-written publisher service: a consumer does
|
|
50
|
-
* not publish, so binding a topic does *not* require the topic's publisher
|
|
51
|
-
* connection string (least privilege). Use `.publisher(...)` only when the
|
|
52
|
-
* subscriber actually publishes follow-up events.
|
|
53
|
-
*/
|
|
54
|
-
topic(topic) {
|
|
55
|
-
return cloneWith(this, { _topicName: topic.name });
|
|
56
|
-
}
|
|
57
|
-
timeout(timeout) {
|
|
58
|
-
return cloneWith(this, { _timeout: timeout });
|
|
59
|
-
}
|
|
60
|
-
output(schema) {
|
|
61
|
-
return cloneWith(this, { outputSchema: schema });
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Depend on constructs — a database, a bucket, a mail sender, a queue, a
|
|
65
|
-
* topic.
|
|
66
|
-
*
|
|
67
|
-
* It records the edge and dissolves each construct's client into the
|
|
68
|
-
* handler's service record under the construct's own id, so
|
|
69
|
-
* `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
|
|
70
|
-
*
|
|
71
|
-
* Constructs only. A `Service` does not match the shape, which is what keeps
|
|
72
|
-
* env sniffing confined to `.services()` and the explicit lift.
|
|
73
|
-
*/
|
|
74
|
-
dependsOn(constructs) {
|
|
75
|
-
const services = servicesOf(constructs);
|
|
76
|
-
return cloneWith(this, {
|
|
77
|
-
_services: [...this._services, ...services],
|
|
78
|
-
_constructs: idsOf(constructs, this._constructs)
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
services(services) {
|
|
82
|
-
return cloneWith(this, { _services: [...this._services, ...services] });
|
|
83
|
-
}
|
|
84
|
-
logger(logger) {
|
|
85
|
-
return cloneWith(this, { _logger: logger });
|
|
86
|
-
}
|
|
87
|
-
publisher(publisher) {
|
|
88
|
-
return cloneWith(this, { _publisher: publisher });
|
|
89
|
-
}
|
|
90
|
-
subscribe(event) {
|
|
91
|
-
const eventsToAdd = Array.isArray(event) ? event : [event];
|
|
92
|
-
return cloneWith(this, { _subscribedEvents: [...this._subscribedEvents, ...eventsToAdd] });
|
|
93
|
-
}
|
|
94
|
-
handle(fn) {
|
|
95
|
-
const subscriber = new Subscriber(fn, this._timeout, this._subscribedEvents, this.outputSchema, this._services, this._logger, this._publisher, this._topicName, this._constructs);
|
|
96
|
-
return subscriber;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
6
|
//#region src/subscribers/index.ts
|
|
102
7
|
const s = new SubscriberBuilder();
|
|
103
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["obj: any","handler: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>","timeout: number","_subscribedEvents?: TSubscribedEvents","outputSchema?: OutSchema","services: TServices","logger: TLogger","publisherService?: Service<\n\t\t\tTEventPublisherServiceName,\n\t\t\tTEventPublisher\n\t\t>","topicName?: string","constructs: string[]","topic: Topic<TName, TEvents>","timeout: number","schema: T","constructs: T","services: T","logger: T","publisher: Service<TName, T>","event: TEvent","fn: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>"],"sources":["../../src/subscribers/Subscriber.ts","../../src/subscribers/SubscriberBuilder.ts","../../src/subscribers/index.ts"],"sourcesContent":["import type {\n\tEventPublisher,\n\tExtractPublisherMessage,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n// Helper type to extract payload types for subscribed events\ntype ExtractEventPayloads<\n\tTPublisher extends EventPublisher<any> | undefined,\n\tTEventTypes extends any[],\n> = TPublisher extends EventPublisher<any>\n\t? Extract<ExtractPublisherMessage<TPublisher>, { type: TEventTypes[number] }>\n\t: never;\n\nexport class Subscriber<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTSubscribedEvents extends\n\t\tExtractPublisherMessage<TEventPublisher>['type'][] = ExtractPublisherMessage<TEventPublisher>['type'][],\n> extends Construct<\n\tTLogger,\n\tTEventPublisherServiceName,\n\tTEventPublisher,\n\tOutSchema,\n\tTServices\n> {\n\t__IS_SUBSCRIBER__ = true;\n\n\tstatic isSubscriber(\n\t\tobj: any,\n\t): obj is Subscriber<any, any, any, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\tobj.__IS_SUBSCRIBER__ === true &&\n\t\t\t\tobj.type === ConstructType.Subscriber,\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic readonly handler: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tprotected _subscribedEvents?: TSubscribedEvents,\n\t\tpublic override readonly outputSchema?: OutSchema,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\tpublic override readonly publisherService?: Service<\n\t\t\tTEventPublisherServiceName,\n\t\t\tTEventPublisher\n\t\t>,\n\t\t/**\n\t\t * The name of the {@link Topic} this subscriber binds to (via\n\t\t * `s.topic(topic)`), recorded for the manifest so infra wires the SNS\n\t\t * subscription. Undefined when the subscriber's events are typed from a\n\t\t * (hand-written) publisher instead.\n\t\t */\n\t\tpublic readonly topicName?: string,\n\t\t/**\n\t\t * The construct ids `.dependsOn()` named — last, so no existing positional\n\t\t * argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Subscriber,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tpublisherService,\n\t\t\toutputSchema,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\t}\n\n\tget subscribedEvents(): TSubscribedEvents | undefined {\n\t\treturn this._subscribedEvents;\n\t}\n}\n\n// Handler type for subscribers that receives an array of events\nexport type SubscriberHandler<\n\tTEventPublisher extends EventPublisher<any> | undefined,\n\tTSubscribedEvents extends ExtractPublisherMessage<TEventPublisher>['type'][],\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n> = (\n\tctx: SubscriberContext<\n\t\tTEventPublisher,\n\t\tTSubscribedEvents,\n\t\tTServices,\n\t\tTLogger\n\t>,\n) => OutSchema extends StandardSchemaV1\n\t? InferStandardSchema<OutSchema> | Promise<InferStandardSchema<OutSchema>>\n\t: any | Promise<any>;\n\n// Context type for subscriber handlers\nexport type SubscriberContext<\n\tTEventPublisher extends EventPublisher<any> | undefined,\n\tTSubscribedEvents extends ExtractPublisherMessage<TEventPublisher>['type'][],\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tevents: ExtractEventPayloads<TEventPublisher, TSubscribedEvents>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n","import type {\n\tEventPublisher,\n\tExtractPublisherMessage,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport type { Topic, TopicEvents, TopicMessage } from '../topic/Topic';\nimport { Subscriber, type SubscriberHandler } from './Subscriber';\n\nexport class SubscriberBuilder<\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTEventPublisher extends EventPublisher<any> | undefined = undefined,\n\tTEventPublisherServiceName extends string = string,\n\tTSubscribedEvents extends any[] = [],\n> {\n\tprivate _subscribedEvents: TSubscribedEvents = [] as any;\n\tprivate _timeout?: number;\n\tprivate outputSchema?: OutSchema;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER;\n\tprivate _publisher?: Service<TEventPublisherServiceName, TEventPublisher>;\n\tprivate _topicName?: string;\n\n\tconstructor() {\n\t\tthis._timeout = 30000; // Default timeout\n\t}\n\n\t/**\n\t * Bind this subscriber to a {@link Topic} — the preferred way to type and wire\n\t * a fan-out consumer. It supplies the subscribable event types (and their\n\t * payloads) from the topic's contract and records the binding for the manifest,\n\t * so infra wires the SNS subscription.\n\t *\n\t * Prefer this over typing via a hand-written publisher service: a consumer does\n\t * not publish, so binding a topic does *not* require the topic's publisher\n\t * connection string (least privilege). Use `.publisher(...)` only when the\n\t * subscriber actually publishes follow-up events.\n\t */\n\ttopic<TName extends string, TEvents extends TopicEvents>(\n\t\ttopic: Topic<TName, TEvents>,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tEventPublisher<TopicMessage<TEvents>>,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_topicName: topic.name,\n\t\t}) as unknown as SubscriberBuilder<\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tEventPublisher<TopicMessage<TEvents>>,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\toutput<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tT,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\toutputSchema: schema as unknown as OutSchema,\n\t\t}) as any;\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): SubscriberBuilder<\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as SubscriberBuilder<\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tOutSchema,\n\t\t\tTEventPublisher,\n\t\t\tTEventPublisherServiceName,\n\t\t\tTSubscribedEvents\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): SubscriberBuilder<\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as any,\n\t\t}) as any;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tT,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, { _logger: logger as unknown as TLogger }) as any;\n\t}\n\n\tpublisher<T extends EventPublisher<any>, TName extends string>(\n\t\tpublisher: Service<TName, T>,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tT,\n\t\tTName,\n\t\tTSubscribedEvents\n\t> {\n\t\treturn cloneWith(this, { _publisher: publisher as any }) as any;\n\t}\n\n\tsubscribe<\n\t\tTEvent extends TEventPublisher extends EventPublisher<any>\n\t\t\t?\n\t\t\t\t\t| ExtractPublisherMessage<TEventPublisher>['type']\n\t\t\t\t\t| ExtractPublisherMessage<TEventPublisher>['type'][]\n\t\t\t: never,\n\t>(\n\t\tevent: TEvent,\n\t): SubscriberBuilder<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTEvent extends any[]\n\t\t\t? [...TSubscribedEvents, ...TEvent]\n\t\t\t: [...TSubscribedEvents, TEvent]\n\t> {\n\t\tconst eventsToAdd = Array.isArray(event) ? event : [event];\n\t\treturn cloneWith(this, {\n\t\t\t_subscribedEvents: [...this._subscribedEvents, ...eventsToAdd] as any,\n\t\t}) as any;\n\t}\n\n\thandle(\n\t\tfn: SubscriberHandler<\n\t\t\tTEventPublisher,\n\t\t\tTSubscribedEvents,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tOutSchema\n\t\t>,\n\t): Subscriber<\n\t\tTServices,\n\t\tTLogger,\n\t\tOutSchema,\n\t\tTEventPublisher,\n\t\tTEventPublisherServiceName,\n\t\tTSubscribedEvents\n\t> {\n\t\tconst subscriber = new Subscriber(\n\t\t\tfn,\n\t\t\tthis._timeout,\n\t\t\tthis._subscribedEvents,\n\t\t\tthis.outputSchema,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._publisher,\n\t\t\tthis._topicName,\n\t\t\tthis._constructs,\n\t\t);\n\n\t\t// No reset: `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base stays usable for the next subscriber.\n\t\treturn subscriber;\n\t}\n}\n","import { SubscriberBuilder } from './SubscriberBuilder';\n\nexport { Subscriber } from './Subscriber';\nexport { SubscriberBuilder };\n\nexport const s = new SubscriberBuilder();\n"],"mappings":";;;;;;AAmBA,IAAa,aAAb,cAQU,UAMR;CACD,oBAAoB;CAEpB,OAAO,aACNA,KACkD;AAClD,SAAO,QACN,OACC,IAAI,sBAAsB,QAC1B,IAAI,SAAS,cAAc,WAC5B;CACD;CAED,YACiBC,SAOSC,UAAkB,KACjCC,mBACeC,cACAC,WAAsB,CAAE,GACxBC,SAAkB,gBAClBC,kBAUTC,WAKhBC,aAAuB,CAAE,GACxB;AACD,QACC,cAAc,YACd,QACA,UACA,CAAE,GACF,kBACA,cACA,yBAGA,WACA;EAxCe;EAOS;EACf;EACe;EACA;EACA;EACA;EAUT;CAmBhB;CAED,IAAI,mBAAkD;AACrD,SAAO,KAAK;CACZ;AACD;;;;AC3ED,IAAa,oBAAb,MAOE;CACD,AAAQ,oBAAuC,CAAE;CACjD,AAAQ;CACR,AAAQ;CACR,AAAQ,YAAuB,CAAE;;CAEjC,AAAO,cAAwB,CAAE;CACjC,AAAQ,UAAmB;CAC3B,AAAQ;CACR,AAAQ;CAER,cAAc;AACb,OAAK,WAAW;CAChB;;;;;;;;;;;;CAaD,MACCC,OAQC;AACD,SAAO,UAAU,MAAM,EACtB,YAAY,MAAM,KAClB,EAAC;CAQF;CAED,QAAQC,SAAuB;AAC9B,SAAO,UAAU,MAAM,EAAE,UAAU,QAAS,EAAC;CAC7C;CAED,OACCC,QAQC;AACD,SAAO,UAAU,MAAM,EACtB,cAAc,OACd,EAAC;CACF;;;;;;;;;;;;CAaD,UACCC,YAQC;EAQD,MAAM,WAAW,WAAW,WAAW;AAEvC,SAAO,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS;GAC3C,aAAa,MAAM,YAAY,KAAK,YAAY;EAChD,EAAC;CAQF;CAED,SACCC,UAQC;AACD,SAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,EAC3C,EAAC;CACF;CAED,OACCC,QAQC;AACD,SAAO,UAAU,MAAM,EAAE,SAAS,OAA8B,EAAC;CACjE;CAED,UACCC,WAQC;AACD,SAAO,UAAU,MAAM,EAAE,YAAY,UAAkB,EAAC;CACxD;CAED,UAOCC,OAUC;EACD,MAAM,cAAc,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,KAAM;AAC1D,SAAO,UAAU,MAAM,EACtB,mBAAmB,CAAC,GAAG,KAAK,mBAAmB,GAAG,WAAY,EAC9D,EAAC;CACF;CAED,OACCC,IAcC;EACD,MAAM,aAAa,IAAI,WACtB,IACA,KAAK,UACL,KAAK,mBACL,KAAK,cACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,YACL,KAAK;AAKN,SAAO;CACP;AACD;;;;ACnOD,MAAa,IAAI,IAAI"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":["import { SubscriberBuilder } from './SubscriberBuilder';\n\nexport { Subscriber } from './Subscriber';\nexport { SubscriberBuilder };\n\nexport const s = new SubscriberBuilder();\n"],"mappings":";;;;;;AAKA,MAAa,IAAI,IAAI"}
|
package/dist/topic/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('../chunk-DWy1uDak.cjs');
|
|
2
|
-
const require_Construct = require('../Construct-
|
|
2
|
+
const require_Construct = require('../Construct-CyS3RpTL.cjs');
|
|
3
3
|
const require_clone = require('../clone-Dy0cR2SZ.cjs');
|
|
4
4
|
const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
|
|
5
5
|
const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
|
package/dist/topic/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Topic, TopicEvents, TopicMessage } from "../Topic-
|
|
1
|
+
import "../Construct-C0ijr2qp.cjs";
|
|
2
|
+
import { Topic, TopicEvents, TopicMessage } from "../Topic-19QeHBIR.cjs";
|
|
3
3
|
import { Logger } from "@geekmidas/logger";
|
|
4
4
|
|
|
5
5
|
//#region src/topic/TopicBuilder.d.ts
|
package/dist/topic/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Topic, TopicEvents, TopicMessage } from "../Topic-
|
|
1
|
+
import "../Construct-Ct8nalEi.mjs";
|
|
2
|
+
import { Topic, TopicEvents, TopicMessage } from "../Topic-DuFeqkBh.mjs";
|
|
3
3
|
import { Logger } from "@geekmidas/logger";
|
|
4
4
|
|
|
5
5
|
//#region src/topic/TopicBuilder.d.ts
|
package/dist/topic/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "../Construct-
|
|
1
|
+
import { Construct, ConstructType } from "../Construct-BD5neF7w.mjs";
|
|
2
2
|
import { cloneWith } from "../clone-DblgEZZa.mjs";
|
|
3
3
|
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
4
4
|
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
package/dist/worker.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
+
const require_construct_interface = require('./construct-interface-BfjcOD_E.cjs');
|
|
3
|
+
require('./Construct-CyS3RpTL.cjs');
|
|
4
|
+
const require_functions = require('./functions-Bd3TPxid.cjs');
|
|
5
|
+
require('./clone-Dy0cR2SZ.cjs');
|
|
6
|
+
const require_surfaceEnv = require('./surfaceEnv-BFXEms2f.cjs');
|
|
7
|
+
const require_CronBuilder = require('./CronBuilder-CkXPJiGO.cjs');
|
|
8
|
+
const require_SubscriberBuilder = require('./SubscriberBuilder-4OPehf2R.cjs');
|
|
9
|
+
const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
|
|
10
|
+
const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
|
|
11
|
+
|
|
12
|
+
//#region src/worker.ts
|
|
13
|
+
var Worker = class Worker {
|
|
14
|
+
id;
|
|
15
|
+
/** Always defined — the worker's own, or the console logger. */
|
|
16
|
+
logger;
|
|
17
|
+
/** Always defined, and normally the default. */
|
|
18
|
+
envParser;
|
|
19
|
+
constructor(id, config = {}, dependencies = []) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.dependencies = dependencies;
|
|
22
|
+
const canonical = (0, __geekmidas_manifest.canonicalId)(id);
|
|
23
|
+
this.id = canonical;
|
|
24
|
+
this.logger = config.logger ?? __geekmidas_logger_console.DEFAULT_LOGGER;
|
|
25
|
+
this.envParser = require_surfaceEnv.envParserFor(config.envParser ? {
|
|
26
|
+
id: canonical,
|
|
27
|
+
envParser: config.envParser
|
|
28
|
+
} : void 0);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This worker's cron factory, carrying its logger.
|
|
32
|
+
*
|
|
33
|
+
* `export const c = crons.logger(logger)` written once and hung off the
|
|
34
|
+
* thing that runs it, so a cron file opens with the schedule rather than
|
|
35
|
+
* with an import of a logger it has to know the path to.
|
|
36
|
+
*/
|
|
37
|
+
get crons() {
|
|
38
|
+
return this.own(new require_CronBuilder.CronBuilder().logger(this.logger));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This worker's subscriber factory, carrying its logger.
|
|
42
|
+
*
|
|
43
|
+
* Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
|
|
44
|
+
* from the publisher's message union, so there is nothing to spell twice.
|
|
45
|
+
*/
|
|
46
|
+
get subscribers() {
|
|
47
|
+
return this.own(new require_SubscriberBuilder.SubscriberBuilder().logger(this.logger));
|
|
48
|
+
}
|
|
49
|
+
/** This worker's function factory, carrying its logger. */
|
|
50
|
+
get functions() {
|
|
51
|
+
return this.own(new require_functions.FunctionBuilder().logger(this.logger));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sugar for the common case, the way `api.get()` is for `api.endpoints`.
|
|
55
|
+
*
|
|
56
|
+
* @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
|
|
57
|
+
*/
|
|
58
|
+
cron(schedule) {
|
|
59
|
+
return this.crons.schedule(schedule);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resources and surfaces this worker calls.
|
|
63
|
+
*
|
|
64
|
+
* Not `.dependsOn()`: this records the edge that derives the worker's
|
|
65
|
+
* environment and its access, the same distinction `RestApi.calls()` draws.
|
|
66
|
+
*/
|
|
67
|
+
calls(constructs) {
|
|
68
|
+
return new Worker(this.id, this.config, [...this.dependencies, ...constructs.map(require_construct_interface.edgeTo)]);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Stamps this worker's id onto a builder, so everything built from it says
|
|
72
|
+
* which process runs it.
|
|
73
|
+
*/
|
|
74
|
+
own(builder) {
|
|
75
|
+
builder._owner = this.id;
|
|
76
|
+
return builder;
|
|
77
|
+
}
|
|
78
|
+
declare() {
|
|
79
|
+
return [{
|
|
80
|
+
kind: "worker",
|
|
81
|
+
id: this.id,
|
|
82
|
+
...this.config.app ? { app: this.config.app } : {},
|
|
83
|
+
...this.dependencies.length ? { dependencies: this.dependencies } : {},
|
|
84
|
+
provides: []
|
|
85
|
+
}];
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.Worker = Worker;
|
|
91
|
+
//# sourceMappingURL=worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.cjs","names":["id: ConstructName<TName>","config: WorkerConfig","dependencies: readonly Dependency[]","DEFAULT_LOGGER","CronBuilder","SubscriberBuilder","FunctionBuilder","schedule: ScheduleExpression","constructs: readonly Declarable[]","edgeTo","builder: T"],"sources":["../src/worker.ts"],"sourcesContent":["/**\n * A process with no port.\n *\n * `RestApi` is the process that answers HTTP. This is the one that does not —\n * the thing that runs a schedule, drains a queue, consumes a topic. Until it\n * existed, those had nowhere to say they belonged: a cron declared a schedule\n * and nothing else, and which container ran it was decided by the directory the\n * file sat in. A glob owned it.\n *\n * The cost of that shows up in the scaffolds. `gkm init --template worker` —\n * a project that is background jobs and nothing else — declared\n * `new RestApi('Api', { defaultAuthorizer: 'none', logger })`: an HTTP surface\n * with no HTTP on it, written because it was the only construct that made an\n * app exist and the only way to get a logger into the generated runtime.\n *\n * It takes no authorizer, and that is the tell that these are two constructs\n * rather than one with a flag: a `RestApi` needs one because an HTTP surface\n * can ship open by omission, and nothing reaches a worker from outside.\n *\n * @example\n * ```ts\n * // constructs/worker.ts\n * import { Worker } from '@geekmidas/constructs/worker';\n * import { logger } from './logger.js';\n *\n * export const worker = new Worker('Worker', { logger }).calls([database]);\n *\n * // crons/cleanup.ts\n * import { worker } from '@acme/constructs/worker.js';\n *\n * export const cleanup = worker\n * .cron('rate(1 day)')\n * .handle(async ({ logger }) => { … });\n * ```\n */\n\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\ttype AppSpec,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\ttype Dependency,\n} from '@geekmidas/manifest';\nimport { type Declarable, edgeTo } from './construct-interface';\nimport type { ScheduleExpression } from './crons/Cron';\nimport { CronBuilder } from './crons/CronBuilder';\nimport { envParserFor } from './endpoints/surfaceEnv';\nimport { FunctionBuilder } from './functions/FunctionBuilder';\nimport { SubscriberBuilder } from './subscribers/SubscriberBuilder';\n\nexport interface WorkerConfig {\n\t/**\n\t * Where its source lives and how it is run.\n\t *\n\t * Normally omitted, like every other app's: `Worker` means `apps/worker`\n\t * where that directory exists and the project root otherwise. Write one only\n\t * for a layout that genuinely differs.\n\t */\n\tapp?: AppSpec;\n\t/**\n\t * The logger everything built from this worker runs with.\n\t *\n\t * The actual logger, not a path to one — the same reason `RestApi` takes\n\t * one. Every cron and subscriber in a scaffolded project used to open with\n\t * `import { logger } from '…/constructs/logger.js'`, which is the line this\n\t * removes.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * The environment parser everything built from this worker runs with.\n\t *\n\t * Defaults to `process.env` merged with the credentials `gkm dev` injected,\n\t * which is what an application's own `config/env.ts` always was.\n\t */\n\tenvParser?: EnvironmentParser<{}>;\n}\n\nexport class Worker<TName extends string = string>\n\timplements Declarable<TName>\n{\n\treadonly id: TName;\n\n\t/** Always defined — the worker's own, or the console logger. */\n\treadonly logger: Logger;\n\n\t/** Always defined, and normally the default. */\n\treadonly envParser: EnvironmentParser<{}>;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: WorkerConfig = {},\n\t\t/** Internal: how `.calls()` carries edges into the copy it returns. */\n\t\tprivate readonly dependencies: readonly Dependency[] = [],\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.logger = config.logger ?? DEFAULT_LOGGER;\n\t\tthis.envParser = envParserFor(\n\t\t\tconfig.envParser\n\t\t\t\t? { id: canonical, envParser: config.envParser }\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\t/**\n\t * This worker's cron factory, carrying its logger.\n\t *\n\t * `export const c = crons.logger(logger)` written once and hung off the\n\t * thing that runs it, so a cron file opens with the schedule rather than\n\t * with an import of a logger it has to know the path to.\n\t */\n\tget crons() {\n\t\treturn this.own(new CronBuilder().logger(this.logger));\n\t}\n\n\t/**\n\t * This worker's subscriber factory, carrying its logger.\n\t *\n\t * Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed\n\t * from the publisher's message union, so there is nothing to spell twice.\n\t */\n\tget subscribers() {\n\t\treturn this.own(new SubscriberBuilder().logger(this.logger));\n\t}\n\n\t/** This worker's function factory, carrying its logger. */\n\tget functions() {\n\t\treturn this.own(new FunctionBuilder().logger(this.logger));\n\t}\n\n\t/**\n\t * Sugar for the common case, the way `api.get()` is for `api.endpoints`.\n\t *\n\t * @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`\n\t */\n\tcron(schedule: ScheduleExpression) {\n\t\treturn this.crons.schedule(schedule);\n\t}\n\n\t/**\n\t * Resources and surfaces this worker calls.\n\t *\n\t * Not `.dependsOn()`: this records the edge that derives the worker's\n\t * environment and its access, the same distinction `RestApi.calls()` draws.\n\t */\n\tcalls(constructs: readonly Declarable[]): Worker<TName> {\n\t\treturn new Worker<TName>(this.id as ConstructName<TName>, this.config, [\n\t\t\t...this.dependencies,\n\t\t\t...constructs.map(edgeTo),\n\t\t]);\n\t}\n\n\t/**\n\t * Stamps this worker's id onto a builder, so everything built from it says\n\t * which process runs it.\n\t */\n\tprivate own<T extends { _owner?: string }>(builder: T): T {\n\t\tbuilder._owner = this.id;\n\n\t\treturn builder;\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'worker',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.config.app ? { app: this.config.app } : {}),\n\t\t\t\t...(this.dependencies.length\n\t\t\t\t\t? { dependencies: this.dependencies }\n\t\t\t\t\t: {}),\n\t\t\t\t// Nothing calls a worker, so it publishes no address.\n\t\t\t\tprovides: [],\n\t\t\t},\n\t\t];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAgFA,IAAa,SAAb,MAAa,OAEb;CACC,AAAS;;CAGT,AAAS;;CAGT,AAAS;CAET,YACCA,IACiBC,SAAuB,CAAE,GAEzBC,eAAsC,CAAE,GACxD;EAHgB;EAEA;EAEjB,MAAM,YAAY,sCAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,SAAS,OAAO,UAAUC;AAC/B,OAAK,YAAY,gCAChB,OAAO,YACJ;GAAE,IAAI;GAAW,WAAW,OAAO;EAAW,WAEjD;CACD;;;;;;;;CASD,IAAI,QAAQ;AACX,SAAO,KAAK,IAAI,IAAIC,kCAAc,OAAO,KAAK,OAAO,CAAC;CACtD;;;;;;;CAQD,IAAI,cAAc;AACjB,SAAO,KAAK,IAAI,IAAIC,8CAAoB,OAAO,KAAK,OAAO,CAAC;CAC5D;;CAGD,IAAI,YAAY;AACf,SAAO,KAAK,IAAI,IAAIC,oCAAkB,OAAO,KAAK,OAAO,CAAC;CAC1D;;;;;;CAOD,KAAKC,UAA8B;AAClC,SAAO,KAAK,MAAM,SAAS,SAAS;CACpC;;;;;;;CAQD,MAAMC,YAAkD;AACvD,SAAO,IAAI,OAAc,KAAK,IAA4B,KAAK,QAAQ,CACtE,GAAG,KAAK,cACR,GAAG,WAAW,IAAIC,mCAAO,AACzB;CACD;;;;;CAMD,AAAQ,IAAmCC,SAAe;AACzD,UAAQ,SAAS,KAAK;AAEtB,SAAO;CACP;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,OAAO,MAAM,EAAE,KAAK,KAAK,OAAO,IAAK,IAAG,CAAE;GACnD,GAAI,KAAK,aAAa,SACnB,EAAE,cAAc,KAAK,aAAc,IACnC,CAAE;GAEL,UAAU,CAAE;EACZ,CACD;CACD;AACD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import "./Construct-C0ijr2qp.cjs";
|
|
2
|
+
import { FunctionBuilder } from "./index-JSf9xNIJ.cjs";
|
|
3
|
+
import { Declarable } from "./construct-interface-D9d4Gm4p.cjs";
|
|
4
|
+
import { ScheduleExpression } from "./Cron-Wqh464aO.cjs";
|
|
5
|
+
import "./Subscriber-2mEi0ImH.cjs";
|
|
6
|
+
import { CronBuilder } from "./CronBuilder-BqpEzMPQ.cjs";
|
|
7
|
+
import "./Topic-19QeHBIR.cjs";
|
|
8
|
+
import { SubscriberBuilder } from "./SubscriberBuilder-waNhzjSM.cjs";
|
|
9
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
10
|
+
import { Logger } from "@geekmidas/logger";
|
|
11
|
+
import * as _geekmidas_schema12 from "@geekmidas/schema";
|
|
12
|
+
import * as _geekmidas_services13 from "@geekmidas/services";
|
|
13
|
+
import * as _geekmidas_audit15 from "@geekmidas/audit";
|
|
14
|
+
import { AppSpec, ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
|
|
15
|
+
|
|
16
|
+
//#region src/worker.d.ts
|
|
17
|
+
|
|
18
|
+
interface WorkerConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Where its source lives and how it is run.
|
|
21
|
+
*
|
|
22
|
+
* Normally omitted, like every other app's: `Worker` means `apps/worker`
|
|
23
|
+
* where that directory exists and the project root otherwise. Write one only
|
|
24
|
+
* for a layout that genuinely differs.
|
|
25
|
+
*/
|
|
26
|
+
app?: AppSpec;
|
|
27
|
+
/**
|
|
28
|
+
* The logger everything built from this worker runs with.
|
|
29
|
+
*
|
|
30
|
+
* The actual logger, not a path to one — the same reason `RestApi` takes
|
|
31
|
+
* one. Every cron and subscriber in a scaffolded project used to open with
|
|
32
|
+
* `import { logger } from '…/constructs/logger.js'`, which is the line this
|
|
33
|
+
* removes.
|
|
34
|
+
*/
|
|
35
|
+
logger?: Logger;
|
|
36
|
+
/**
|
|
37
|
+
* The environment parser everything built from this worker runs with.
|
|
38
|
+
*
|
|
39
|
+
* Defaults to `process.env` merged with the credentials `gkm dev` injected,
|
|
40
|
+
* which is what an application's own `config/env.ts` always was.
|
|
41
|
+
*/
|
|
42
|
+
envParser?: EnvironmentParser<{}>;
|
|
43
|
+
}
|
|
44
|
+
declare class Worker<TName extends string = string> implements Declarable<TName> {
|
|
45
|
+
private readonly config;
|
|
46
|
+
/** Internal: how `.calls()` carries edges into the copy it returns. */
|
|
47
|
+
private readonly dependencies;
|
|
48
|
+
readonly id: TName;
|
|
49
|
+
/** Always defined — the worker's own, or the console logger. */
|
|
50
|
+
readonly logger: Logger;
|
|
51
|
+
/** Always defined, and normally the default. */
|
|
52
|
+
readonly envParser: EnvironmentParser<{}>;
|
|
53
|
+
constructor(id: ConstructName<TName>, config?: WorkerConfig, /** Internal: how `.calls()` carries edges into the copy it returns. */
|
|
54
|
+
dependencies?: readonly Dependency[]);
|
|
55
|
+
/**
|
|
56
|
+
* This worker's cron factory, carrying its logger.
|
|
57
|
+
*
|
|
58
|
+
* `export const c = crons.logger(logger)` written once and hung off the
|
|
59
|
+
* thing that runs it, so a cron file opens with the schedule rather than
|
|
60
|
+
* with an import of a logger it has to know the path to.
|
|
61
|
+
*/
|
|
62
|
+
get crons(): CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
|
|
63
|
+
/**
|
|
64
|
+
* This worker's subscriber factory, carrying its logger.
|
|
65
|
+
*
|
|
66
|
+
* Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
|
|
67
|
+
* from the publisher's message union, so there is nothing to spell twice.
|
|
68
|
+
*/
|
|
69
|
+
get subscribers(): SubscriberBuilder<[], Logger, undefined, undefined, string, []>;
|
|
70
|
+
/** This worker's function factory, carrying its logger. */
|
|
71
|
+
get functions(): FunctionBuilder<_geekmidas_schema12.ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit15.AuditableAction<string, unknown>>;
|
|
72
|
+
/**
|
|
73
|
+
* Sugar for the common case, the way `api.get()` is for `api.endpoints`.
|
|
74
|
+
*
|
|
75
|
+
* @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
|
|
76
|
+
*/
|
|
77
|
+
cron(schedule: ScheduleExpression): CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Resources and surfaces this worker calls.
|
|
80
|
+
*
|
|
81
|
+
* Not `.dependsOn()`: this records the edge that derives the worker's
|
|
82
|
+
* environment and its access, the same distinction `RestApi.calls()` draws.
|
|
83
|
+
*/
|
|
84
|
+
calls(constructs: readonly Declarable[]): Worker<TName>;
|
|
85
|
+
/**
|
|
86
|
+
* Stamps this worker's id onto a builder, so everything built from it says
|
|
87
|
+
* which process runs it.
|
|
88
|
+
*/
|
|
89
|
+
private own;
|
|
90
|
+
declare(): Declaration[];
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
93
|
+
//#endregion
|
|
94
|
+
export { Worker, WorkerConfig };
|
|
95
|
+
//# sourceMappingURL=worker.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.cts","names":[],"sources":["../src/worker.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;AA2IkC,UAtFjB,YAAA,CAsFiB;EAAA;;;;;;;EA2BX,GArFX,CAAA,EApBL,OAoBK;EAAU;;;;;;;;WAXZ;;;;;;;cAOG;;cAGA,iDACD,WAAW;;;;eAET;;mBAGI;;sBAGG;kBAGf,cAAc,iBACO;0BAEe;;;;;;;;eAoBhC,YApB0C,mBAAA,CAoB1C,wBAAA,EAAA,qBAAA,CAAA,4BAAA;;;;;;;qBAUM,sBAAA;;mBAKF,gBALE,mBAAA,CAKF,wBAAA,iBAAA,iEAAA,kBAAA,CAAA;;;;;;iBASE,qBAAkB,YAAA,mBAAA,CAAA,wBAAA,EAAA,qBAAA,CAAA,4BAAA;;;;;;;6BAUN,eAAe,OAAO;;;;;;aAiBtC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import "./Construct-Ct8nalEi.mjs";
|
|
2
|
+
import { FunctionBuilder } from "./index-CubPzHd9.mjs";
|
|
3
|
+
import { Declarable } from "./construct-interface-g5GM5pwR.mjs";
|
|
4
|
+
import { ScheduleExpression } from "./Cron-ByxdOfpE.mjs";
|
|
5
|
+
import "./Subscriber-xTJ9ayPN.mjs";
|
|
6
|
+
import { CronBuilder } from "./CronBuilder-BL0AP6fs.mjs";
|
|
7
|
+
import "./Topic-DuFeqkBh.mjs";
|
|
8
|
+
import { SubscriberBuilder } from "./SubscriberBuilder-Dptmo-1A.mjs";
|
|
9
|
+
import { AppSpec, ConstructName, Declaration, Dependency } from "@geekmidas/manifest";
|
|
10
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
11
|
+
import * as _geekmidas_services13 from "@geekmidas/services";
|
|
12
|
+
import * as _geekmidas_audit15 from "@geekmidas/audit";
|
|
13
|
+
import { Logger } from "@geekmidas/logger";
|
|
14
|
+
import * as _geekmidas_schema12 from "@geekmidas/schema";
|
|
15
|
+
|
|
16
|
+
//#region src/worker.d.ts
|
|
17
|
+
|
|
18
|
+
interface WorkerConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Where its source lives and how it is run.
|
|
21
|
+
*
|
|
22
|
+
* Normally omitted, like every other app's: `Worker` means `apps/worker`
|
|
23
|
+
* where that directory exists and the project root otherwise. Write one only
|
|
24
|
+
* for a layout that genuinely differs.
|
|
25
|
+
*/
|
|
26
|
+
app?: AppSpec;
|
|
27
|
+
/**
|
|
28
|
+
* The logger everything built from this worker runs with.
|
|
29
|
+
*
|
|
30
|
+
* The actual logger, not a path to one — the same reason `RestApi` takes
|
|
31
|
+
* one. Every cron and subscriber in a scaffolded project used to open with
|
|
32
|
+
* `import { logger } from '…/constructs/logger.js'`, which is the line this
|
|
33
|
+
* removes.
|
|
34
|
+
*/
|
|
35
|
+
logger?: Logger;
|
|
36
|
+
/**
|
|
37
|
+
* The environment parser everything built from this worker runs with.
|
|
38
|
+
*
|
|
39
|
+
* Defaults to `process.env` merged with the credentials `gkm dev` injected,
|
|
40
|
+
* which is what an application's own `config/env.ts` always was.
|
|
41
|
+
*/
|
|
42
|
+
envParser?: EnvironmentParser<{}>;
|
|
43
|
+
}
|
|
44
|
+
declare class Worker<TName extends string = string> implements Declarable<TName> {
|
|
45
|
+
private readonly config;
|
|
46
|
+
/** Internal: how `.calls()` carries edges into the copy it returns. */
|
|
47
|
+
private readonly dependencies;
|
|
48
|
+
readonly id: TName;
|
|
49
|
+
/** Always defined — the worker's own, or the console logger. */
|
|
50
|
+
readonly logger: Logger;
|
|
51
|
+
/** Always defined, and normally the default. */
|
|
52
|
+
readonly envParser: EnvironmentParser<{}>;
|
|
53
|
+
constructor(id: ConstructName<TName>, config?: WorkerConfig, /** Internal: how `.calls()` carries edges into the copy it returns. */
|
|
54
|
+
dependencies?: readonly Dependency[]);
|
|
55
|
+
/**
|
|
56
|
+
* This worker's cron factory, carrying its logger.
|
|
57
|
+
*
|
|
58
|
+
* `export const c = crons.logger(logger)` written once and hung off the
|
|
59
|
+
* thing that runs it, so a cron file opens with the schedule rather than
|
|
60
|
+
* with an import of a logger it has to know the path to.
|
|
61
|
+
*/
|
|
62
|
+
get crons(): CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
|
|
63
|
+
/**
|
|
64
|
+
* This worker's subscriber factory, carrying its logger.
|
|
65
|
+
*
|
|
66
|
+
* Chain `.publisher(…)` before `.subscribe([…])`: the event names are typed
|
|
67
|
+
* from the publisher's message union, so there is nothing to spell twice.
|
|
68
|
+
*/
|
|
69
|
+
get subscribers(): SubscriberBuilder<[], Logger, undefined, undefined, string, []>;
|
|
70
|
+
/** This worker's function factory, carrying its logger. */
|
|
71
|
+
get functions(): FunctionBuilder<_geekmidas_schema12.ComposableStandardSchema, undefined, [], Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit15.AuditableAction<string, unknown>>;
|
|
72
|
+
/**
|
|
73
|
+
* Sugar for the common case, the way `api.get()` is for `api.endpoints`.
|
|
74
|
+
*
|
|
75
|
+
* @example `worker.cron('rate(1 day)').handle(async ({ logger }) => { … })`
|
|
76
|
+
*/
|
|
77
|
+
cron(schedule: ScheduleExpression): CronBuilder<_geekmidas_schema12.ComposableStandardSchema, _geekmidas_services13.Service<string, unknown>[], Logger, undefined, undefined, string, undefined, string>;
|
|
78
|
+
/**
|
|
79
|
+
* Resources and surfaces this worker calls.
|
|
80
|
+
*
|
|
81
|
+
* Not `.dependsOn()`: this records the edge that derives the worker's
|
|
82
|
+
* environment and its access, the same distinction `RestApi.calls()` draws.
|
|
83
|
+
*/
|
|
84
|
+
calls(constructs: readonly Declarable[]): Worker<TName>;
|
|
85
|
+
/**
|
|
86
|
+
* Stamps this worker's id onto a builder, so everything built from it says
|
|
87
|
+
* which process runs it.
|
|
88
|
+
*/
|
|
89
|
+
private own;
|
|
90
|
+
declare(): Declaration[];
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
93
|
+
//#endregion
|
|
94
|
+
export { Worker, WorkerConfig };
|
|
95
|
+
//# sourceMappingURL=worker.d.mts.map
|