@celerity-sdk/core 0.4.0 → 0.5.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 +281 -47
- package/dist/index.cjs +118 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -17
- package/dist/index.d.ts +21 -17
- package/dist/index.js +108 -44
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -431,7 +431,7 @@ declare function RequestContext(): ParameterDecorator;
|
|
|
431
431
|
declare function EventType(): ParameterDecorator;
|
|
432
432
|
|
|
433
433
|
type ConsumerMetadata = {
|
|
434
|
-
|
|
434
|
+
source?: string;
|
|
435
435
|
};
|
|
436
436
|
type ConsumerHandlerMetadata = {
|
|
437
437
|
route?: string;
|
|
@@ -443,13 +443,13 @@ type ConsumerHandlerMetadata = {
|
|
|
443
443
|
* The class becomes injectable and its `@MessageHandler()` methods are
|
|
444
444
|
* registered as consumer handler callbacks.
|
|
445
445
|
*
|
|
446
|
-
* @param
|
|
447
|
-
* which blueprint-defined consumer
|
|
446
|
+
* @param source - Optional blueprint resource name that tells the deploy engine
|
|
447
|
+
* which blueprint-defined consumer resource this handler should be wired to.
|
|
448
448
|
* Does not create infrastructure — the blueprint defines the actual source.
|
|
449
449
|
*
|
|
450
450
|
* @example
|
|
451
451
|
* ```ts
|
|
452
|
-
* @Consumer("
|
|
452
|
+
* @Consumer("ordersConsumer")
|
|
453
453
|
* class OrderConsumer {
|
|
454
454
|
* @MessageHandler()
|
|
455
455
|
* async process(@Messages(OrderSchema) messages: ValidatedConsumerMessage<Order>[]): Promise<EventResult> {
|
|
@@ -458,7 +458,7 @@ type ConsumerHandlerMetadata = {
|
|
|
458
458
|
* }
|
|
459
459
|
* ```
|
|
460
460
|
*/
|
|
461
|
-
declare function Consumer(
|
|
461
|
+
declare function Consumer(source?: string): ClassDecorator;
|
|
462
462
|
/**
|
|
463
463
|
* Marks a method inside a `@Consumer()` class as a message handler.
|
|
464
464
|
*
|
|
@@ -517,11 +517,11 @@ declare function Vendor(): ParameterDecorator;
|
|
|
517
517
|
declare function ConsumerTraceContext(): ParameterDecorator;
|
|
518
518
|
|
|
519
519
|
type ScheduleHandlerMetadata = {
|
|
520
|
-
|
|
520
|
+
source?: string;
|
|
521
521
|
schedule?: string;
|
|
522
522
|
};
|
|
523
523
|
type ScheduleHandlerOptions = {
|
|
524
|
-
|
|
524
|
+
source?: string;
|
|
525
525
|
schedule?: string;
|
|
526
526
|
};
|
|
527
527
|
/**
|
|
@@ -538,16 +538,16 @@ type ScheduleHandlerOptions = {
|
|
|
538
538
|
* @param arg - Optional string or options object. String parsing:
|
|
539
539
|
* - No args → fully blueprint-driven (no annotations)
|
|
540
540
|
* - String with `rate(` or `cron(` prefix → `schedule` expression annotation
|
|
541
|
-
* - String without prefix → `
|
|
542
|
-
* - Object → explicit `{
|
|
541
|
+
* - String without prefix → `source` blueprint resource name hint for deploy engine
|
|
542
|
+
* - Object → explicit `{ source?, schedule? }`
|
|
543
543
|
*
|
|
544
544
|
* @example
|
|
545
545
|
* ```ts
|
|
546
546
|
* @Controller()
|
|
547
547
|
* class MaintenanceTasks {
|
|
548
|
-
* @ScheduleHandler("
|
|
548
|
+
* @ScheduleHandler("dailyCleanup")
|
|
549
549
|
* async cleanup(@ScheduleInput() input: unknown): Promise<EventResult> {
|
|
550
|
-
* //
|
|
550
|
+
* // source hint — matches blueprint resource name, blueprint defines the actual schedule
|
|
551
551
|
* }
|
|
552
552
|
*
|
|
553
553
|
* @ScheduleHandler("rate(1 day)")
|
|
@@ -555,7 +555,7 @@ type ScheduleHandlerOptions = {
|
|
|
555
555
|
* // schedule expression annotation — blueprint can override
|
|
556
556
|
* }
|
|
557
557
|
*
|
|
558
|
-
* @ScheduleHandler({
|
|
558
|
+
* @ScheduleHandler({ source: "weeklyReport", schedule: "cron(0 9 ? * MON *)" })
|
|
559
559
|
* async report(): Promise<EventResult> {
|
|
560
560
|
* // explicit object with both fields
|
|
561
561
|
* }
|
|
@@ -563,7 +563,7 @@ type ScheduleHandlerOptions = {
|
|
|
563
563
|
* ```
|
|
564
564
|
*/
|
|
565
565
|
declare function ScheduleHandler(): MethodDecorator;
|
|
566
|
-
declare function ScheduleHandler(
|
|
566
|
+
declare function ScheduleHandler(sourceOrExpression: string): MethodDecorator;
|
|
567
567
|
declare function ScheduleHandler(options: ScheduleHandlerOptions): MethodDecorator;
|
|
568
568
|
|
|
569
569
|
/**
|
|
@@ -752,6 +752,8 @@ type ResolvedHandlerBase = {
|
|
|
752
752
|
id?: string;
|
|
753
753
|
handlerFn: (...args: unknown[]) => unknown;
|
|
754
754
|
handlerInstance?: object;
|
|
755
|
+
/** The class to lazily resolve via container on first invocation. */
|
|
756
|
+
controllerClass?: Type;
|
|
755
757
|
isFunctionHandler?: boolean;
|
|
756
758
|
injectTokens?: InjectionToken[];
|
|
757
759
|
layers: (CelerityLayer<BaseHandlerContext> | Type<CelerityLayer<BaseHandlerContext>>)[];
|
|
@@ -788,6 +790,8 @@ type ResolvedGuard = {
|
|
|
788
790
|
name: string;
|
|
789
791
|
handlerFn: (...args: unknown[]) => unknown;
|
|
790
792
|
handlerInstance?: object;
|
|
793
|
+
/** The guard class to lazily resolve via container on first invocation. */
|
|
794
|
+
guardClass?: Type;
|
|
791
795
|
paramMetadata: ParamMetadata[];
|
|
792
796
|
customMetadata: Record<string, unknown>;
|
|
793
797
|
injectTokens?: InjectionToken[];
|
|
@@ -1053,7 +1057,7 @@ type ConsumerHandlerFn = (event: ConsumerEventInput, ctx: ConsumerHandlerContext
|
|
|
1053
1057
|
declare function createConsumerHandler(config: ConsumerHandlerConfig, handler: ConsumerHandlerFn): FunctionHandlerDefinition;
|
|
1054
1058
|
|
|
1055
1059
|
type ScheduleHandlerConfig<T = unknown> = {
|
|
1056
|
-
|
|
1060
|
+
source?: string;
|
|
1057
1061
|
schedule?: string;
|
|
1058
1062
|
schema?: Schema<T>;
|
|
1059
1063
|
inject?: InjectionToken[];
|
|
@@ -1079,8 +1083,8 @@ type ScheduleHandlerFn = (event: ScheduleEventInput$1, ctx: ScheduleHandlerConte
|
|
|
1079
1083
|
* },
|
|
1080
1084
|
* );
|
|
1081
1085
|
*
|
|
1082
|
-
* // With
|
|
1083
|
-
* const weeklyReport = createScheduleHandler("
|
|
1086
|
+
* // With source hint for deploy engine auto-wiring
|
|
1087
|
+
* const weeklyReport = createScheduleHandler("weeklyReport", {
|
|
1084
1088
|
* inject: [ReportService],
|
|
1085
1089
|
* }, async (event, ctx, reportService: ReportService) => {
|
|
1086
1090
|
* await reportService.generate();
|
|
@@ -1097,7 +1101,7 @@ type ScheduleHandlerFn = (event: ScheduleEventInput$1, ctx: ScheduleHandlerConte
|
|
|
1097
1101
|
* ```
|
|
1098
1102
|
*/
|
|
1099
1103
|
declare function createScheduleHandler(config: ScheduleHandlerConfig, handler: ScheduleHandlerFn): FunctionHandlerDefinition;
|
|
1100
|
-
declare function createScheduleHandler(
|
|
1104
|
+
declare function createScheduleHandler(sourceOrExpression: string, config: ScheduleHandlerConfig, handler: ScheduleHandlerFn): FunctionHandlerDefinition;
|
|
1101
1105
|
|
|
1102
1106
|
type CustomHandlerConfig<TInput = unknown> = {
|
|
1103
1107
|
name?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -431,7 +431,7 @@ declare function RequestContext(): ParameterDecorator;
|
|
|
431
431
|
declare function EventType(): ParameterDecorator;
|
|
432
432
|
|
|
433
433
|
type ConsumerMetadata = {
|
|
434
|
-
|
|
434
|
+
source?: string;
|
|
435
435
|
};
|
|
436
436
|
type ConsumerHandlerMetadata = {
|
|
437
437
|
route?: string;
|
|
@@ -443,13 +443,13 @@ type ConsumerHandlerMetadata = {
|
|
|
443
443
|
* The class becomes injectable and its `@MessageHandler()` methods are
|
|
444
444
|
* registered as consumer handler callbacks.
|
|
445
445
|
*
|
|
446
|
-
* @param
|
|
447
|
-
* which blueprint-defined consumer
|
|
446
|
+
* @param source - Optional blueprint resource name that tells the deploy engine
|
|
447
|
+
* which blueprint-defined consumer resource this handler should be wired to.
|
|
448
448
|
* Does not create infrastructure — the blueprint defines the actual source.
|
|
449
449
|
*
|
|
450
450
|
* @example
|
|
451
451
|
* ```ts
|
|
452
|
-
* @Consumer("
|
|
452
|
+
* @Consumer("ordersConsumer")
|
|
453
453
|
* class OrderConsumer {
|
|
454
454
|
* @MessageHandler()
|
|
455
455
|
* async process(@Messages(OrderSchema) messages: ValidatedConsumerMessage<Order>[]): Promise<EventResult> {
|
|
@@ -458,7 +458,7 @@ type ConsumerHandlerMetadata = {
|
|
|
458
458
|
* }
|
|
459
459
|
* ```
|
|
460
460
|
*/
|
|
461
|
-
declare function Consumer(
|
|
461
|
+
declare function Consumer(source?: string): ClassDecorator;
|
|
462
462
|
/**
|
|
463
463
|
* Marks a method inside a `@Consumer()` class as a message handler.
|
|
464
464
|
*
|
|
@@ -517,11 +517,11 @@ declare function Vendor(): ParameterDecorator;
|
|
|
517
517
|
declare function ConsumerTraceContext(): ParameterDecorator;
|
|
518
518
|
|
|
519
519
|
type ScheduleHandlerMetadata = {
|
|
520
|
-
|
|
520
|
+
source?: string;
|
|
521
521
|
schedule?: string;
|
|
522
522
|
};
|
|
523
523
|
type ScheduleHandlerOptions = {
|
|
524
|
-
|
|
524
|
+
source?: string;
|
|
525
525
|
schedule?: string;
|
|
526
526
|
};
|
|
527
527
|
/**
|
|
@@ -538,16 +538,16 @@ type ScheduleHandlerOptions = {
|
|
|
538
538
|
* @param arg - Optional string or options object. String parsing:
|
|
539
539
|
* - No args → fully blueprint-driven (no annotations)
|
|
540
540
|
* - String with `rate(` or `cron(` prefix → `schedule` expression annotation
|
|
541
|
-
* - String without prefix → `
|
|
542
|
-
* - Object → explicit `{
|
|
541
|
+
* - String without prefix → `source` blueprint resource name hint for deploy engine
|
|
542
|
+
* - Object → explicit `{ source?, schedule? }`
|
|
543
543
|
*
|
|
544
544
|
* @example
|
|
545
545
|
* ```ts
|
|
546
546
|
* @Controller()
|
|
547
547
|
* class MaintenanceTasks {
|
|
548
|
-
* @ScheduleHandler("
|
|
548
|
+
* @ScheduleHandler("dailyCleanup")
|
|
549
549
|
* async cleanup(@ScheduleInput() input: unknown): Promise<EventResult> {
|
|
550
|
-
* //
|
|
550
|
+
* // source hint — matches blueprint resource name, blueprint defines the actual schedule
|
|
551
551
|
* }
|
|
552
552
|
*
|
|
553
553
|
* @ScheduleHandler("rate(1 day)")
|
|
@@ -555,7 +555,7 @@ type ScheduleHandlerOptions = {
|
|
|
555
555
|
* // schedule expression annotation — blueprint can override
|
|
556
556
|
* }
|
|
557
557
|
*
|
|
558
|
-
* @ScheduleHandler({
|
|
558
|
+
* @ScheduleHandler({ source: "weeklyReport", schedule: "cron(0 9 ? * MON *)" })
|
|
559
559
|
* async report(): Promise<EventResult> {
|
|
560
560
|
* // explicit object with both fields
|
|
561
561
|
* }
|
|
@@ -563,7 +563,7 @@ type ScheduleHandlerOptions = {
|
|
|
563
563
|
* ```
|
|
564
564
|
*/
|
|
565
565
|
declare function ScheduleHandler(): MethodDecorator;
|
|
566
|
-
declare function ScheduleHandler(
|
|
566
|
+
declare function ScheduleHandler(sourceOrExpression: string): MethodDecorator;
|
|
567
567
|
declare function ScheduleHandler(options: ScheduleHandlerOptions): MethodDecorator;
|
|
568
568
|
|
|
569
569
|
/**
|
|
@@ -752,6 +752,8 @@ type ResolvedHandlerBase = {
|
|
|
752
752
|
id?: string;
|
|
753
753
|
handlerFn: (...args: unknown[]) => unknown;
|
|
754
754
|
handlerInstance?: object;
|
|
755
|
+
/** The class to lazily resolve via container on first invocation. */
|
|
756
|
+
controllerClass?: Type;
|
|
755
757
|
isFunctionHandler?: boolean;
|
|
756
758
|
injectTokens?: InjectionToken[];
|
|
757
759
|
layers: (CelerityLayer<BaseHandlerContext> | Type<CelerityLayer<BaseHandlerContext>>)[];
|
|
@@ -788,6 +790,8 @@ type ResolvedGuard = {
|
|
|
788
790
|
name: string;
|
|
789
791
|
handlerFn: (...args: unknown[]) => unknown;
|
|
790
792
|
handlerInstance?: object;
|
|
793
|
+
/** The guard class to lazily resolve via container on first invocation. */
|
|
794
|
+
guardClass?: Type;
|
|
791
795
|
paramMetadata: ParamMetadata[];
|
|
792
796
|
customMetadata: Record<string, unknown>;
|
|
793
797
|
injectTokens?: InjectionToken[];
|
|
@@ -1053,7 +1057,7 @@ type ConsumerHandlerFn = (event: ConsumerEventInput, ctx: ConsumerHandlerContext
|
|
|
1053
1057
|
declare function createConsumerHandler(config: ConsumerHandlerConfig, handler: ConsumerHandlerFn): FunctionHandlerDefinition;
|
|
1054
1058
|
|
|
1055
1059
|
type ScheduleHandlerConfig<T = unknown> = {
|
|
1056
|
-
|
|
1060
|
+
source?: string;
|
|
1057
1061
|
schedule?: string;
|
|
1058
1062
|
schema?: Schema<T>;
|
|
1059
1063
|
inject?: InjectionToken[];
|
|
@@ -1079,8 +1083,8 @@ type ScheduleHandlerFn = (event: ScheduleEventInput$1, ctx: ScheduleHandlerConte
|
|
|
1079
1083
|
* },
|
|
1080
1084
|
* );
|
|
1081
1085
|
*
|
|
1082
|
-
* // With
|
|
1083
|
-
* const weeklyReport = createScheduleHandler("
|
|
1086
|
+
* // With source hint for deploy engine auto-wiring
|
|
1087
|
+
* const weeklyReport = createScheduleHandler("weeklyReport", {
|
|
1084
1088
|
* inject: [ReportService],
|
|
1085
1089
|
* }, async (event, ctx, reportService: ReportService) => {
|
|
1086
1090
|
* await reportService.generate();
|
|
@@ -1097,7 +1101,7 @@ type ScheduleHandlerFn = (event: ScheduleEventInput$1, ctx: ScheduleHandlerConte
|
|
|
1097
1101
|
* ```
|
|
1098
1102
|
*/
|
|
1099
1103
|
declare function createScheduleHandler(config: ScheduleHandlerConfig, handler: ScheduleHandlerFn): FunctionHandlerDefinition;
|
|
1100
|
-
declare function createScheduleHandler(
|
|
1104
|
+
declare function createScheduleHandler(sourceOrExpression: string, config: ScheduleHandlerConfig, handler: ScheduleHandlerFn): FunctionHandlerDefinition;
|
|
1101
1105
|
|
|
1102
1106
|
type CustomHandlerConfig<TInput = unknown> = {
|
|
1103
1107
|
name?: string;
|