@celerity-sdk/core 0.3.1 → 0.4.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/dist/index.cjs CHANGED
@@ -37,15 +37,24 @@ __export(index_exports, {
37
37
  BadGatewayException: () => BadGatewayException,
38
38
  BadRequestException: () => BadRequestException,
39
39
  Body: () => Body,
40
+ BucketEventType: () => import_types3.BucketEventType,
41
+ CONSUMER_HANDLER_METADATA: () => CONSUMER_HANDLER_METADATA,
42
+ CONSUMER_METADATA: () => CONSUMER_METADATA,
40
43
  CONTROLLER_METADATA: () => CONTROLLER_METADATA,
41
44
  CUSTOM_METADATA: () => CUSTOM_METADATA,
42
45
  CelerityApplication: () => CelerityApplication,
43
46
  CelerityFactory: () => CelerityFactory,
44
47
  ConflictException: () => ConflictException,
48
+ ConnectionId: () => ConnectionId,
49
+ Consumer: () => Consumer,
50
+ ConsumerTraceContext: () => ConsumerTraceContext,
45
51
  Container: () => Container,
46
52
  Controller: () => Controller,
47
53
  Cookies: () => Cookies,
54
+ DatastoreEventType: () => import_types3.DatastoreEventType,
48
55
  Delete: () => Delete,
56
+ EventInput: () => EventInput,
57
+ EventType: () => EventType,
49
58
  ForbiddenException: () => ForbiddenException,
50
59
  GUARD_CUSTOM_METADATA: () => GUARD_CUSTOM_METADATA,
51
60
  GUARD_PROTECTEDBY_METADATA: () => GUARD_PROTECTEDBY_METADATA,
@@ -59,21 +68,32 @@ __export(index_exports, {
59
68
  Head: () => Head,
60
69
  Headers: () => Headers,
61
70
  HttpException: () => HttpException,
62
- INJECT_METADATA: () => INJECT_METADATA,
71
+ INJECT_METADATA: () => import_common.INJECT_METADATA,
72
+ INVOKE_METADATA: () => INVOKE_METADATA,
63
73
  Inject: () => Inject,
64
74
  Injectable: () => Injectable,
65
75
  InternalServerErrorException: () => InternalServerErrorException,
76
+ Invoke: () => Invoke,
77
+ InvokeContext: () => InvokeContext,
66
78
  LAYER_METADATA: () => LAYER_METADATA,
67
79
  MODULE_METADATA: () => MODULE_METADATA,
80
+ MessageBody: () => MessageBody,
81
+ MessageHandler: () => MessageHandler,
82
+ MessageId: () => MessageId,
83
+ Messages: () => Messages,
68
84
  MethodNotAllowedException: () => MethodNotAllowedException,
69
85
  Module: () => Module,
70
86
  NotAcceptableException: () => NotAcceptableException,
71
87
  NotFoundException: () => NotFoundException,
72
88
  NotImplementedException: () => NotImplementedException,
89
+ OnConnect: () => OnConnect,
90
+ OnDisconnect: () => OnDisconnect,
91
+ OnMessage: () => OnMessage,
73
92
  Options: () => Options,
74
93
  PUBLIC_METADATA: () => PUBLIC_METADATA,
75
94
  Param: () => Param,
76
95
  Patch: () => Patch,
96
+ Payload: () => Payload,
77
97
  Post: () => Post,
78
98
  ProtectedBy: () => ProtectedBy,
79
99
  Public: () => Public,
@@ -82,24 +102,52 @@ __export(index_exports, {
82
102
  ROUTE_PATH_METADATA: () => ROUTE_PATH_METADATA,
83
103
  RUNTIME_APP: () => RUNTIME_APP,
84
104
  Req: () => Req,
105
+ RequestContext: () => RequestContext,
85
106
  RequestId: () => RequestId,
107
+ RuntimeWebSocketSender: () => RuntimeWebSocketSender,
108
+ SCHEDULE_HANDLER_METADATA: () => SCHEDULE_HANDLER_METADATA,
109
+ ScheduleEventInputParam: () => ScheduleEventInput,
110
+ ScheduleExpression: () => ScheduleExpression,
111
+ ScheduleHandler: () => ScheduleHandler,
112
+ ScheduleId: () => ScheduleId,
113
+ ScheduleInput: () => ScheduleInput,
86
114
  ServerlessApplication: () => ServerlessApplication,
87
115
  ServiceUnavailableException: () => ServiceUnavailableException,
88
116
  SetMetadata: () => SetMetadata,
117
+ SourceType: () => import_types3.SourceType,
89
118
  TestingApplication: () => TestingApplication,
119
+ Token: () => Token,
90
120
  TooManyRequestsException: () => TooManyRequestsException,
121
+ USE_RESOURCE_METADATA: () => import_common.USE_RESOURCE_METADATA,
91
122
  UnauthorizedException: () => UnauthorizedException,
92
123
  UnprocessableEntityException: () => UnprocessableEntityException,
93
124
  UseLayer: () => UseLayer,
94
125
  UseLayers: () => UseLayers,
126
+ UseResource: () => UseResource,
127
+ UseResources: () => UseResources,
128
+ Vendor: () => Vendor,
129
+ WEBSOCKET_CONTROLLER_METADATA: () => WEBSOCKET_CONTROLLER_METADATA,
130
+ WEBSOCKET_EVENT_METADATA: () => WEBSOCKET_EVENT_METADATA,
131
+ WebSocketController: () => WebSocketController,
132
+ WebSocketSender: () => import_types2.WebSocketSender,
95
133
  bootstrap: () => bootstrap,
96
134
  bootstrapForRuntime: () => bootstrapForRuntime,
97
135
  buildModuleGraph: () => buildModuleGraph,
136
+ createConsumerHandler: () => createConsumerHandler,
137
+ createCustomHandler: () => createCustomHandler,
98
138
  createDefaultSystemLayers: () => createDefaultSystemLayers,
139
+ createGuard: () => createGuard,
99
140
  createHttpHandler: () => createHttpHandler,
141
+ createScheduleHandler: () => createScheduleHandler,
142
+ createWebSocketHandler: () => createWebSocketHandler,
100
143
  discoverModule: () => discoverModule,
101
144
  disposeLayers: () => disposeLayers,
102
- executeHandlerPipeline: () => executeHandlerPipeline,
145
+ executeConsumerPipeline: () => executeConsumerPipeline,
146
+ executeCustomPipeline: () => executeCustomPipeline,
147
+ executeGuardPipeline: () => executeGuardPipeline,
148
+ executeHttpPipeline: () => executeHttpPipeline,
149
+ executeSchedulePipeline: () => executeSchedulePipeline,
150
+ executeWebSocketPipeline: () => executeWebSocketPipeline,
103
151
  flattenMultiValueRecord: () => flattenMultiValueRecord,
104
152
  getClassDependencyTokens: () => getClassDependencyTokens,
105
153
  getProviderDependencyTokens: () => getProviderDependencyTokens,
@@ -108,35 +156,56 @@ __export(index_exports, {
108
156
  httpPatch: () => httpPatch,
109
157
  httpPost: () => httpPost,
110
158
  httpPut: () => httpPut,
159
+ mapConsumerEventInput: () => mapConsumerEventInput,
111
160
  mapRuntimeRequest: () => mapRuntimeRequest,
161
+ mapScheduleEventInput: () => mapScheduleEventInput,
162
+ mapToNapiEventResult: () => mapToNapiEventResult,
112
163
  mapToRuntimeResponse: () => mapToRuntimeResponse,
164
+ mapWebSocketMessage: () => mapWebSocketMessage,
165
+ mockConsumerEvent: () => mockConsumerEvent,
113
166
  mockRequest: () => mockRequest,
167
+ mockScheduleEvent: () => mockScheduleEvent,
168
+ mockWebSocketMessage: () => mockWebSocketMessage,
114
169
  registerModuleGraph: () => registerModuleGraph,
115
170
  resolveHandlerByModuleRef: () => resolveHandlerByModuleRef,
171
+ routingKeyOf: () => routingKeyOf,
116
172
  runLayerPipeline: () => runLayerPipeline,
173
+ scanConsumerHandlers: () => scanConsumerHandlers,
174
+ scanCustomHandlers: () => scanCustomHandlers,
175
+ scanHttpGuards: () => scanHttpGuards,
176
+ scanHttpHandlers: () => scanHttpHandlers,
177
+ scanModule: () => scanModule,
178
+ scanScheduleHandlers: () => scanScheduleHandlers,
179
+ scanWebSocketHandlers: () => scanWebSocketHandlers,
117
180
  startRuntime: () => startRuntime,
118
181
  tokenToString: () => tokenToString,
119
182
  validate: () => validate
120
183
  });
121
184
  module.exports = __toCommonJS(index_exports);
122
- var import_reflect_metadata14 = require("reflect-metadata");
185
+ var import_reflect_metadata27 = require("reflect-metadata");
123
186
 
124
187
  // src/decorators/controller.ts
125
188
  var import_reflect_metadata = require("reflect-metadata");
126
189
 
127
190
  // src/metadata/constants.ts
128
- var CONTROLLER_METADATA = /* @__PURE__ */ Symbol("celerity:controller");
129
- var HTTP_METHOD_METADATA = /* @__PURE__ */ Symbol("celerity:http-method");
130
- var ROUTE_PATH_METADATA = /* @__PURE__ */ Symbol("celerity:route-path");
131
- var PARAM_METADATA = /* @__PURE__ */ Symbol("celerity:param");
132
- var GUARD_PROTECTEDBY_METADATA = /* @__PURE__ */ Symbol("celerity:guard:protectedBy");
133
- var GUARD_CUSTOM_METADATA = /* @__PURE__ */ Symbol("celerity:guard:custom");
134
- var LAYER_METADATA = /* @__PURE__ */ Symbol("celerity:layer");
135
- var MODULE_METADATA = /* @__PURE__ */ Symbol("celerity:module");
136
- var INJECTABLE_METADATA = /* @__PURE__ */ Symbol("celerity:injectable");
137
- var INJECT_METADATA = /* @__PURE__ */ Symbol("celerity:inject");
138
- var PUBLIC_METADATA = /* @__PURE__ */ Symbol("celerity:public");
139
- var CUSTOM_METADATA = /* @__PURE__ */ Symbol("celerity:custom-metadata");
191
+ var import_common = require("@celerity-sdk/common");
192
+ var CONTROLLER_METADATA = /* @__PURE__ */ Symbol.for("celerity:controller");
193
+ var HTTP_METHOD_METADATA = /* @__PURE__ */ Symbol.for("celerity:http-method");
194
+ var ROUTE_PATH_METADATA = /* @__PURE__ */ Symbol.for("celerity:route-path");
195
+ var PARAM_METADATA = /* @__PURE__ */ Symbol.for("celerity:param");
196
+ var GUARD_PROTECTEDBY_METADATA = /* @__PURE__ */ Symbol.for("celerity:guard:protectedBy");
197
+ var GUARD_CUSTOM_METADATA = /* @__PURE__ */ Symbol.for("celerity:guard:custom");
198
+ var LAYER_METADATA = /* @__PURE__ */ Symbol.for("celerity:layer");
199
+ var MODULE_METADATA = /* @__PURE__ */ Symbol.for("celerity:module");
200
+ var INJECTABLE_METADATA = /* @__PURE__ */ Symbol.for("celerity:injectable");
201
+ var PUBLIC_METADATA = /* @__PURE__ */ Symbol.for("celerity:public");
202
+ var CUSTOM_METADATA = /* @__PURE__ */ Symbol.for("celerity:custom-metadata");
203
+ var WEBSOCKET_CONTROLLER_METADATA = /* @__PURE__ */ Symbol.for("celerity:websocket-controller");
204
+ var WEBSOCKET_EVENT_METADATA = /* @__PURE__ */ Symbol.for("celerity:websocket-event");
205
+ var CONSUMER_METADATA = /* @__PURE__ */ Symbol.for("celerity:consumer");
206
+ var CONSUMER_HANDLER_METADATA = /* @__PURE__ */ Symbol.for("celerity:consumer-handler");
207
+ var SCHEDULE_HANDLER_METADATA = /* @__PURE__ */ Symbol.for("celerity:schedule-handler");
208
+ var INVOKE_METADATA = /* @__PURE__ */ Symbol.for("celerity:invoke");
140
209
 
141
210
  // src/decorators/controller.ts
142
211
  function Controller(prefix) {
@@ -231,6 +300,10 @@ function Auth() {
231
300
  return createParamDecorator("auth");
232
301
  }
233
302
  __name(Auth, "Auth");
303
+ function Token() {
304
+ return createParamDecorator("token");
305
+ }
306
+ __name(Token, "Token");
234
307
  function Req() {
235
308
  return createParamDecorator("request");
236
309
  }
@@ -270,6 +343,9 @@ var import_reflect_metadata4 = require("reflect-metadata");
270
343
  function Guard(name) {
271
344
  return (target) => {
272
345
  Reflect.defineMetadata(GUARD_CUSTOM_METADATA, name, target);
346
+ if (!Reflect.hasOwnMetadata(INJECTABLE_METADATA, target)) {
347
+ Reflect.defineMetadata(INJECTABLE_METADATA, true, target);
348
+ }
273
349
  };
274
350
  }
275
351
  __name(Guard, "Guard");
@@ -324,8 +400,33 @@ function UseLayers(layers) {
324
400
  }
325
401
  __name(UseLayers, "UseLayers");
326
402
 
327
- // src/decorators/metadata.ts
403
+ // src/decorators/resource.ts
328
404
  var import_reflect_metadata6 = require("reflect-metadata");
405
+ function UseResource(...resourceNames) {
406
+ return (target, propertyKey, _descriptor) => {
407
+ if (propertyKey) {
408
+ const existing = Reflect.getOwnMetadata(import_common.USE_RESOURCE_METADATA, target, propertyKey) ?? [];
409
+ Reflect.defineMetadata(import_common.USE_RESOURCE_METADATA, [
410
+ ...resourceNames,
411
+ ...existing
412
+ ], target, propertyKey);
413
+ } else {
414
+ const existing = Reflect.getOwnMetadata(import_common.USE_RESOURCE_METADATA, target) ?? [];
415
+ Reflect.defineMetadata(import_common.USE_RESOURCE_METADATA, [
416
+ ...resourceNames,
417
+ ...existing
418
+ ], target);
419
+ }
420
+ };
421
+ }
422
+ __name(UseResource, "UseResource");
423
+ function UseResources(resourceNames) {
424
+ return UseResource(...resourceNames);
425
+ }
426
+ __name(UseResources, "UseResources");
427
+
428
+ // src/decorators/metadata.ts
429
+ var import_reflect_metadata7 = require("reflect-metadata");
329
430
  function SetMetadata(key, value) {
330
431
  return (target, propertyKey, _descriptor) => {
331
432
  if (propertyKey) {
@@ -350,7 +451,7 @@ function Action(value) {
350
451
  __name(Action, "Action");
351
452
 
352
453
  // src/decorators/injectable.ts
353
- var import_reflect_metadata7 = require("reflect-metadata");
454
+ var import_reflect_metadata8 = require("reflect-metadata");
354
455
  function Injectable() {
355
456
  return (target) => {
356
457
  Reflect.defineMetadata(INJECTABLE_METADATA, true, target);
@@ -359,15 +460,15 @@ function Injectable() {
359
460
  __name(Injectable, "Injectable");
360
461
  function Inject(token) {
361
462
  return (target, _propertyKey, parameterIndex) => {
362
- const existing = Reflect.getOwnMetadata(INJECT_METADATA, target) ?? /* @__PURE__ */ new Map();
463
+ const existing = Reflect.getOwnMetadata(import_common.INJECT_METADATA, target) ?? /* @__PURE__ */ new Map();
363
464
  existing.set(parameterIndex, token);
364
- Reflect.defineMetadata(INJECT_METADATA, existing, target);
465
+ Reflect.defineMetadata(import_common.INJECT_METADATA, existing, target);
365
466
  };
366
467
  }
367
468
  __name(Inject, "Inject");
368
469
 
369
470
  // src/decorators/module.ts
370
- var import_reflect_metadata8 = require("reflect-metadata");
471
+ var import_reflect_metadata9 = require("reflect-metadata");
371
472
  function Module(metadata) {
372
473
  return (target) => {
373
474
  Reflect.defineMetadata(MODULE_METADATA, metadata, target);
@@ -375,6 +476,237 @@ function Module(metadata) {
375
476
  }
376
477
  __name(Module, "Module");
377
478
 
479
+ // src/decorators/websocket.ts
480
+ var import_reflect_metadata10 = require("reflect-metadata");
481
+ function WebSocketController() {
482
+ return (target) => {
483
+ Reflect.defineMetadata(WEBSOCKET_CONTROLLER_METADATA, true, target);
484
+ Reflect.defineMetadata(INJECTABLE_METADATA, true, target);
485
+ };
486
+ }
487
+ __name(WebSocketController, "WebSocketController");
488
+ function OnConnect() {
489
+ return (target, propertyKey, descriptor) => {
490
+ const meta = {
491
+ eventType: "connect",
492
+ route: "$connect"
493
+ };
494
+ Reflect.defineMetadata(WEBSOCKET_EVENT_METADATA, meta, target, propertyKey);
495
+ return descriptor;
496
+ };
497
+ }
498
+ __name(OnConnect, "OnConnect");
499
+ function OnMessage(route) {
500
+ return (target, propertyKey, descriptor) => {
501
+ const meta = {
502
+ eventType: "message",
503
+ route: route ?? "$default"
504
+ };
505
+ Reflect.defineMetadata(WEBSOCKET_EVENT_METADATA, meta, target, propertyKey);
506
+ return descriptor;
507
+ };
508
+ }
509
+ __name(OnMessage, "OnMessage");
510
+ function OnDisconnect() {
511
+ return (target, propertyKey, descriptor) => {
512
+ const meta = {
513
+ eventType: "disconnect",
514
+ route: "$disconnect"
515
+ };
516
+ Reflect.defineMetadata(WEBSOCKET_EVENT_METADATA, meta, target, propertyKey);
517
+ return descriptor;
518
+ };
519
+ }
520
+ __name(OnDisconnect, "OnDisconnect");
521
+
522
+ // src/decorators/websocket-params.ts
523
+ var import_reflect_metadata11 = require("reflect-metadata");
524
+ function createWsParamDecorator(type, schema) {
525
+ return (target, propertyKey, parameterIndex) => {
526
+ if (!propertyKey) return;
527
+ const existing = Reflect.getOwnMetadata(PARAM_METADATA, target, propertyKey) ?? [];
528
+ const meta = {
529
+ index: parameterIndex,
530
+ type
531
+ };
532
+ if (schema) meta.schema = schema;
533
+ existing.push(meta);
534
+ Reflect.defineMetadata(PARAM_METADATA, existing, target, propertyKey);
535
+ };
536
+ }
537
+ __name(createWsParamDecorator, "createWsParamDecorator");
538
+ function ConnectionId() {
539
+ return createWsParamDecorator("connectionId");
540
+ }
541
+ __name(ConnectionId, "ConnectionId");
542
+ function MessageBody(schema) {
543
+ return createWsParamDecorator("messageBody", schema);
544
+ }
545
+ __name(MessageBody, "MessageBody");
546
+ function MessageId() {
547
+ return createWsParamDecorator("messageId");
548
+ }
549
+ __name(MessageId, "MessageId");
550
+ function RequestContext() {
551
+ return createWsParamDecorator("requestContext");
552
+ }
553
+ __name(RequestContext, "RequestContext");
554
+ function EventType() {
555
+ return createWsParamDecorator("eventType");
556
+ }
557
+ __name(EventType, "EventType");
558
+
559
+ // src/decorators/consumer.ts
560
+ var import_reflect_metadata12 = require("reflect-metadata");
561
+ function Consumer(sourceId) {
562
+ return (target) => {
563
+ const meta = {};
564
+ if (sourceId !== void 0) meta.sourceId = sourceId;
565
+ Reflect.defineMetadata(CONSUMER_METADATA, meta, target);
566
+ Reflect.defineMetadata(INJECTABLE_METADATA, true, target);
567
+ };
568
+ }
569
+ __name(Consumer, "Consumer");
570
+ function MessageHandler(route) {
571
+ return (target, propertyKey) => {
572
+ const meta = {};
573
+ if (route !== void 0) meta.route = route;
574
+ Reflect.defineMetadata(CONSUMER_HANDLER_METADATA, meta, target, propertyKey);
575
+ };
576
+ }
577
+ __name(MessageHandler, "MessageHandler");
578
+
579
+ // src/decorators/consumer-params.ts
580
+ var import_reflect_metadata13 = require("reflect-metadata");
581
+ function createConsumerParamDecorator(type, schema) {
582
+ return (target, propertyKey, parameterIndex) => {
583
+ if (!propertyKey) return;
584
+ const existing = Reflect.getOwnMetadata(PARAM_METADATA, target, propertyKey) ?? [];
585
+ const meta = {
586
+ index: parameterIndex,
587
+ type
588
+ };
589
+ if (schema) meta.schema = schema;
590
+ existing.push(meta);
591
+ Reflect.defineMetadata(PARAM_METADATA, existing, target, propertyKey);
592
+ };
593
+ }
594
+ __name(createConsumerParamDecorator, "createConsumerParamDecorator");
595
+ function Messages(schema) {
596
+ return createConsumerParamDecorator("messages", schema);
597
+ }
598
+ __name(Messages, "Messages");
599
+ function EventInput() {
600
+ return createConsumerParamDecorator("consumerEvent");
601
+ }
602
+ __name(EventInput, "EventInput");
603
+ function Vendor() {
604
+ return createConsumerParamDecorator("consumerVendor");
605
+ }
606
+ __name(Vendor, "Vendor");
607
+ function ConsumerTraceContext() {
608
+ return createConsumerParamDecorator("consumerTraceContext");
609
+ }
610
+ __name(ConsumerTraceContext, "ConsumerTraceContext");
611
+
612
+ // src/decorators/schedule.ts
613
+ var import_reflect_metadata14 = require("reflect-metadata");
614
+ function isScheduleExpression(value) {
615
+ return value.startsWith("rate(") || value.startsWith("cron(");
616
+ }
617
+ __name(isScheduleExpression, "isScheduleExpression");
618
+ function parseScheduleArg(arg) {
619
+ if (typeof arg === "string") {
620
+ return isScheduleExpression(arg) ? {
621
+ schedule: arg
622
+ } : {
623
+ scheduleId: arg
624
+ };
625
+ }
626
+ const meta = {};
627
+ if (arg.scheduleId !== void 0) meta.scheduleId = arg.scheduleId;
628
+ if (arg.schedule !== void 0) meta.schedule = arg.schedule;
629
+ return meta;
630
+ }
631
+ __name(parseScheduleArg, "parseScheduleArg");
632
+ function ScheduleHandler(arg) {
633
+ return (target, propertyKey) => {
634
+ const meta = arg ? parseScheduleArg(arg) : {};
635
+ Reflect.defineMetadata(SCHEDULE_HANDLER_METADATA, meta, target, propertyKey);
636
+ };
637
+ }
638
+ __name(ScheduleHandler, "ScheduleHandler");
639
+
640
+ // src/decorators/schedule-params.ts
641
+ var import_reflect_metadata15 = require("reflect-metadata");
642
+ function createScheduleParamDecorator(type, schema) {
643
+ return (target, propertyKey, parameterIndex) => {
644
+ if (!propertyKey) return;
645
+ const existing = Reflect.getOwnMetadata(PARAM_METADATA, target, propertyKey) ?? [];
646
+ const meta = {
647
+ index: parameterIndex,
648
+ type
649
+ };
650
+ if (schema) meta.schema = schema;
651
+ existing.push(meta);
652
+ Reflect.defineMetadata(PARAM_METADATA, existing, target, propertyKey);
653
+ };
654
+ }
655
+ __name(createScheduleParamDecorator, "createScheduleParamDecorator");
656
+ function ScheduleInput(schema) {
657
+ return createScheduleParamDecorator("scheduleInput", schema);
658
+ }
659
+ __name(ScheduleInput, "ScheduleInput");
660
+ function ScheduleId() {
661
+ return createScheduleParamDecorator("scheduleId");
662
+ }
663
+ __name(ScheduleId, "ScheduleId");
664
+ function ScheduleExpression() {
665
+ return createScheduleParamDecorator("scheduleExpression");
666
+ }
667
+ __name(ScheduleExpression, "ScheduleExpression");
668
+ function ScheduleEventInput() {
669
+ return createScheduleParamDecorator("scheduleEvent");
670
+ }
671
+ __name(ScheduleEventInput, "ScheduleEventInput");
672
+
673
+ // src/decorators/invoke.ts
674
+ var import_reflect_metadata16 = require("reflect-metadata");
675
+ function Invoke(name) {
676
+ return (target, propertyKey) => {
677
+ const meta = {
678
+ name
679
+ };
680
+ Reflect.defineMetadata(INVOKE_METADATA, meta, target, propertyKey);
681
+ };
682
+ }
683
+ __name(Invoke, "Invoke");
684
+
685
+ // src/decorators/invoke-params.ts
686
+ var import_reflect_metadata17 = require("reflect-metadata");
687
+ function createInvokeParamDecorator(type, schema) {
688
+ return (target, propertyKey, parameterIndex) => {
689
+ if (!propertyKey) return;
690
+ const existing = Reflect.getOwnMetadata(PARAM_METADATA, target, propertyKey) ?? [];
691
+ const meta = {
692
+ index: parameterIndex,
693
+ type
694
+ };
695
+ if (schema) meta.schema = schema;
696
+ existing.push(meta);
697
+ Reflect.defineMetadata(PARAM_METADATA, existing, target, propertyKey);
698
+ };
699
+ }
700
+ __name(createInvokeParamDecorator, "createInvokeParamDecorator");
701
+ function Payload(schema) {
702
+ return createInvokeParamDecorator("payload", schema);
703
+ }
704
+ __name(Payload, "Payload");
705
+ function InvokeContext() {
706
+ return createInvokeParamDecorator("invokeContext");
707
+ }
708
+ __name(InvokeContext, "InvokeContext");
709
+
378
710
  // src/errors/http-exception.ts
379
711
  var HttpException = class extends Error {
380
712
  static {
@@ -524,15 +856,48 @@ var GatewayTimeoutException = class extends HttpException {
524
856
  };
525
857
 
526
858
  // src/layers/validate.ts
859
+ function inferMode(schemas) {
860
+ if (schemas.consumerMessage) return "consumer";
861
+ if (schemas.scheduleInput) return "schedule";
862
+ if (schemas.customPayload) return "custom";
863
+ if (schemas.wsMessageBody) return "websocket";
864
+ return "http";
865
+ }
866
+ __name(inferMode, "inferMode");
527
867
  var ValidationLayer = class ValidationLayer2 {
528
868
  static {
529
869
  __name(this, "ValidationLayer");
530
870
  }
531
871
  schemas;
872
+ mode;
532
873
  constructor(schemas) {
533
874
  this.schemas = schemas;
875
+ this.mode = inferMode(schemas);
876
+ }
877
+ supports(handlerType) {
878
+ return handlerType === this.mode;
534
879
  }
535
880
  async handle(context, next) {
881
+ switch (this.mode) {
882
+ case "http":
883
+ this.validateHttp(context);
884
+ break;
885
+ case "websocket":
886
+ this.validateWebSocket(context);
887
+ break;
888
+ case "consumer":
889
+ this.validateConsumer(context);
890
+ break;
891
+ case "schedule":
892
+ this.validateSchedule(context);
893
+ break;
894
+ case "custom":
895
+ this.validateCustom(context);
896
+ break;
897
+ }
898
+ return next();
899
+ }
900
+ validateHttp(context) {
536
901
  const { request } = context;
537
902
  if (this.schemas.body && request.textBody) {
538
903
  try {
@@ -563,7 +928,49 @@ var ValidationLayer = class ValidationLayer2 {
563
928
  throw new BadRequestException("Headers validation failed", formatError(error));
564
929
  }
565
930
  }
566
- return next();
931
+ }
932
+ validateWebSocket(context) {
933
+ const schema = this.schemas.wsMessageBody;
934
+ if (!schema) return;
935
+ const body = context.message.jsonBody;
936
+ if (body === void 0) return;
937
+ context.metadata.set("validatedMessageBody", schema.parse(body));
938
+ }
939
+ validateConsumer(context) {
940
+ const schema = this.schemas.consumerMessage;
941
+ if (!schema) return;
942
+ const validated = [];
943
+ const failures = [];
944
+ for (const msg of context.event.messages) {
945
+ try {
946
+ const parsed = JSON.parse(msg.body);
947
+ const result = schema.parse(parsed);
948
+ validated.push({
949
+ ...msg,
950
+ parsedBody: result
951
+ });
952
+ } catch (err) {
953
+ failures.push({
954
+ messageId: msg.messageId,
955
+ errorMessage: err instanceof Error ? err.message : String(err)
956
+ });
957
+ }
958
+ }
959
+ context.metadata.set("validatedMessages", validated);
960
+ if (failures.length > 0) {
961
+ context.metadata.set("validationFailures", failures);
962
+ }
963
+ }
964
+ validateSchedule(context) {
965
+ const schema = this.schemas.scheduleInput;
966
+ if (!schema) return;
967
+ context.metadata.set("validatedInput", schema.parse(context.event.input));
968
+ }
969
+ validateCustom(context) {
970
+ const schema = this.schemas.customPayload;
971
+ if (!schema) return;
972
+ const raw = context.metadata.get("rawPayload");
973
+ context.metadata.set("validatedPayload", schema.parse(raw));
567
974
  }
568
975
  };
569
976
  function formatError(error) {
@@ -584,9 +991,9 @@ __name(validate, "validate");
584
991
  // src/layers/pipeline.ts
585
992
  var import_debug = __toESM(require("debug"), 1);
586
993
  var debug = (0, import_debug.default)("celerity:core:layers");
587
- function runLayerPipeline(layers, context, handler) {
588
- const resolved = layers.map((layer) => typeof layer === "function" ? new layer() : layer);
589
- debug("runLayerPipeline: %d layers", resolved.length);
994
+ function runLayerPipeline(layers, context, handler, handlerType) {
995
+ const resolved = layers.map((layer) => typeof layer === "function" ? new layer() : layer).filter((layer) => !handlerType || !layer.supports || layer.supports(handlerType));
996
+ debug("runLayerPipeline: %d layers (handlerType=%s)", resolved.length, handlerType ?? "all");
590
997
  let index = -1;
591
998
  function dispatch(i) {
592
999
  if (i <= index) {
@@ -607,6 +1014,20 @@ __name(runLayerPipeline, "runLayerPipeline");
607
1014
 
608
1015
  // src/layers/system.ts
609
1016
  var import_config = require("@celerity-sdk/config");
1017
+ var RESOURCE_LAYER_MAP = {
1018
+ bucket: {
1019
+ pkg: "@celerity-sdk/bucket",
1020
+ className: "ObjectStorageLayer"
1021
+ },
1022
+ queue: {
1023
+ pkg: "@celerity-sdk/queue",
1024
+ className: "QueueLayer"
1025
+ },
1026
+ cache: {
1027
+ pkg: "@celerity-sdk/cache",
1028
+ className: "CacheLayer"
1029
+ }
1030
+ };
610
1031
  async function createDefaultSystemLayers() {
611
1032
  const layers = [];
612
1033
  try {
@@ -617,6 +1038,19 @@ async function createDefaultSystemLayers() {
617
1038
  } catch {
618
1039
  }
619
1040
  layers.push(new import_config.ConfigLayer());
1041
+ const links = (0, import_config.captureResourceLinks)();
1042
+ const resourceTypes = (0, import_config.getResourceTypes)(links);
1043
+ for (const type of resourceTypes) {
1044
+ const entry = RESOURCE_LAYER_MAP[type];
1045
+ if (!entry) continue;
1046
+ try {
1047
+ const pkg = entry.pkg;
1048
+ const mod = await import(pkg);
1049
+ const LayerClass = mod[entry.className];
1050
+ layers.push(new LayerClass());
1051
+ } catch {
1052
+ }
1053
+ }
620
1054
  return layers;
621
1055
  }
622
1056
  __name(createDefaultSystemLayers, "createDefaultSystemLayers");
@@ -659,11 +1093,11 @@ var HandlerMetadataStore = class {
659
1093
  };
660
1094
 
661
1095
  // src/di/container.ts
662
- var import_reflect_metadata10 = require("reflect-metadata");
1096
+ var import_reflect_metadata19 = require("reflect-metadata");
663
1097
  var import_debug2 = __toESM(require("debug"), 1);
664
1098
 
665
1099
  // src/di/dependency-tokens.ts
666
- var import_reflect_metadata9 = require("reflect-metadata");
1100
+ var import_reflect_metadata18 = require("reflect-metadata");
667
1101
  function isClassProvider(p) {
668
1102
  return "useClass" in p;
669
1103
  }
@@ -674,7 +1108,7 @@ function isFactoryProvider(p) {
674
1108
  __name(isFactoryProvider, "isFactoryProvider");
675
1109
  function getClassDependencyTokens(target) {
676
1110
  const paramTypes = Reflect.getMetadata("design:paramtypes", target) ?? [];
677
- const injectOverrides = Reflect.getMetadata(INJECT_METADATA, target) ?? /* @__PURE__ */ new Map();
1111
+ const injectOverrides = Reflect.getMetadata(import_common.INJECT_METADATA, target) ?? /* @__PURE__ */ new Map();
678
1112
  return paramTypes.map((paramType, index) => injectOverrides.get(index) ?? paramType);
679
1113
  }
680
1114
  __name(getClassDependencyTokens, "getClassDependencyTokens");
@@ -960,27 +1394,122 @@ var APP_CONFIG = /* @__PURE__ */ Symbol("celerity:app-config");
960
1394
  var RUNTIME_APP = /* @__PURE__ */ Symbol("celerity:runtime-app");
961
1395
 
962
1396
  // src/application/factory.ts
963
- var import_debug8 = __toESM(require("debug"), 1);
1397
+ var import_debug17 = __toESM(require("debug"), 1);
964
1398
 
965
1399
  // src/bootstrap/bootstrap.ts
966
- var import_reflect_metadata13 = require("reflect-metadata");
967
- var import_debug5 = __toESM(require("debug"), 1);
1400
+ var import_reflect_metadata26 = require("reflect-metadata");
1401
+ var import_debug10 = __toESM(require("debug"), 1);
968
1402
 
969
1403
  // src/handlers/registry.ts
970
- var import_reflect_metadata12 = require("reflect-metadata");
971
- var import_debug4 = __toESM(require("debug"), 1);
972
- var import_common = require("@celerity-sdk/common");
1404
+ var import_debug3 = __toESM(require("debug"), 1);
1405
+
1406
+ // src/handlers/routing.ts
1407
+ function routingKeyOf(handler) {
1408
+ switch (handler.type) {
1409
+ case "http":
1410
+ return `${handler.method} ${handler.path}`;
1411
+ case "websocket":
1412
+ return handler.route;
1413
+ case "consumer":
1414
+ return handler.handlerTag;
1415
+ case "schedule":
1416
+ return handler.handlerTag;
1417
+ case "custom":
1418
+ return handler.name;
1419
+ }
1420
+ }
1421
+ __name(routingKeyOf, "routingKeyOf");
1422
+
1423
+ // src/handlers/registry.ts
1424
+ var debug3 = (0, import_debug3.default)("celerity:core:registry");
1425
+ var HandlerRegistry = class {
1426
+ static {
1427
+ __name(this, "HandlerRegistry");
1428
+ }
1429
+ byType = /* @__PURE__ */ new Map();
1430
+ exactLookup = /* @__PURE__ */ new Map();
1431
+ byId = /* @__PURE__ */ new Map();
1432
+ guards = /* @__PURE__ */ new Map();
1433
+ register(handler) {
1434
+ const list = this.byType.get(handler.type) ?? [];
1435
+ list.push(handler);
1436
+ this.byType.set(handler.type, list);
1437
+ if (handler.type !== "http") {
1438
+ this.exactLookup.set(`${handler.type}::${routingKeyOf(handler)}`, handler);
1439
+ }
1440
+ if (handler.id) {
1441
+ this.byId.set(handler.id, handler);
1442
+ }
1443
+ }
1444
+ getHandler(type, routingKey) {
1445
+ if (type === "http") return this.findHttpHandler(routingKey);
1446
+ const found = this.exactLookup.get(`${type}::${routingKey}`);
1447
+ debug3("getHandler %s %s \u2192 %s", type, routingKey, found ? "matched" : "not found");
1448
+ return found;
1449
+ }
1450
+ getHandlerById(type, id) {
1451
+ const handler = this.byId.get(id);
1452
+ if (handler && handler.type === type) {
1453
+ return handler;
1454
+ }
1455
+ debug3("getHandlerById %s %s \u2192 not found", type, id);
1456
+ return void 0;
1457
+ }
1458
+ getHandlersByType(type) {
1459
+ return this.byType.get(type) ?? [];
1460
+ }
1461
+ getAllHandlers() {
1462
+ const result = [];
1463
+ for (const list of this.byType.values()) result.push(...list);
1464
+ return result;
1465
+ }
1466
+ registerGuard(guard) {
1467
+ debug3("registerGuard: %s", guard.name);
1468
+ this.guards.set(guard.name, guard);
1469
+ }
1470
+ getGuard(name) {
1471
+ const found = this.guards.get(name);
1472
+ debug3("getGuard %s \u2192 %s", name, found ? "matched" : "not found");
1473
+ return found;
1474
+ }
1475
+ getAllGuards() {
1476
+ return [
1477
+ ...this.guards.values()
1478
+ ];
1479
+ }
1480
+ /**
1481
+ * HTTP routing uses path-pattern matching: `"GET /items/{id}"` matches `"GET /items/42"`.
1482
+ * The routing key format is `"METHOD path"` (e.g., `"GET /items/{id}"`).
1483
+ */
1484
+ findHttpHandler(routingKey) {
1485
+ const spaceIdx = routingKey.indexOf(" ");
1486
+ if (spaceIdx < 0) return void 0;
1487
+ const method = routingKey.slice(0, spaceIdx);
1488
+ const path = routingKey.slice(spaceIdx + 1);
1489
+ const httpHandlers = this.byType.get("http") ?? [];
1490
+ const found = httpHandlers.find((h) => h.path !== void 0 && h.method !== void 0 && h.method === method && matchRoute(h.path, path));
1491
+ debug3("getHandler http %s \u2192 %s", routingKey, found ? "matched" : "not found");
1492
+ return found;
1493
+ }
1494
+ };
1495
+ function matchRoute(pattern, actual) {
1496
+ const patternParts = pattern.split("/").filter(Boolean);
1497
+ const actualParts = actual.split("/").filter(Boolean);
1498
+ if (patternParts.length !== actualParts.length) return false;
1499
+ return patternParts.every((part, i) => part.startsWith("{") || part === actualParts[i]);
1500
+ }
1501
+ __name(matchRoute, "matchRoute");
973
1502
 
974
1503
  // src/bootstrap/module-graph.ts
975
- var import_reflect_metadata11 = require("reflect-metadata");
976
- var import_debug3 = __toESM(require("debug"), 1);
977
- var debug3 = (0, import_debug3.default)("celerity:core:bootstrap");
1504
+ var import_reflect_metadata20 = require("reflect-metadata");
1505
+ var import_debug4 = __toESM(require("debug"), 1);
1506
+ var debug4 = (0, import_debug4.default)("celerity:core:bootstrap");
978
1507
  function buildModuleGraph(rootModule) {
979
1508
  const graph = /* @__PURE__ */ new Map();
980
1509
  const resolving = /* @__PURE__ */ new Set();
981
1510
  function walk(moduleClass, importChain) {
982
1511
  if (graph.has(moduleClass)) {
983
- debug3("walk %s \u2192 already visited", moduleClass.name);
1512
+ debug4("walk %s \u2192 already visited", moduleClass.name);
984
1513
  return;
985
1514
  }
986
1515
  if (resolving.has(moduleClass)) {
@@ -1001,6 +1530,7 @@ function buildModuleGraph(rootModule) {
1001
1530
  imports: [],
1002
1531
  controllers: [],
1003
1532
  functionHandlers: [],
1533
+ guards: [],
1004
1534
  providers: []
1005
1535
  });
1006
1536
  return;
@@ -1026,9 +1556,15 @@ function buildModuleGraph(rootModule) {
1026
1556
  for (const controller of controllers) {
1027
1557
  ownTokens.add(controller);
1028
1558
  }
1559
+ const guards = metadata.guards ?? [];
1560
+ for (const guard of guards) {
1561
+ if (typeof guard === "function") {
1562
+ ownTokens.add(guard);
1563
+ }
1564
+ }
1029
1565
  const exportTokens = new Set(metadata.exports ?? []);
1030
1566
  resolving.delete(moduleClass);
1031
- debug3("walk %s: %d providers, %d controllers, %d imports", moduleClass.name, providers.length, controllers.length, imports.length);
1567
+ debug4("walk %s: %d providers, %d controllers, %d guards, %d imports", moduleClass.name, providers.length, controllers.length, guards.length, imports.length);
1032
1568
  graph.set(moduleClass, {
1033
1569
  moduleClass,
1034
1570
  ownTokens,
@@ -1036,6 +1572,7 @@ function buildModuleGraph(rootModule) {
1036
1572
  imports,
1037
1573
  controllers,
1038
1574
  functionHandlers: metadata.functionHandlers ?? [],
1575
+ guards,
1039
1576
  providers
1040
1577
  });
1041
1578
  }
@@ -1059,6 +1596,11 @@ function registerModuleGraph(graph, container) {
1059
1596
  container.registerClass(controller);
1060
1597
  }
1061
1598
  }
1599
+ for (const guard of node.guards) {
1600
+ if (typeof guard === "function" && !container.has(guard)) {
1601
+ container.registerClass(guard);
1602
+ }
1603
+ }
1062
1604
  }
1063
1605
  }
1064
1606
  __name(registerModuleGraph, "registerModuleGraph");
@@ -1105,8 +1647,14 @@ function validateModuleGraph(graph, container) {
1105
1647
  const depTokens = getClassDependencyTokens(controller);
1106
1648
  checkDependencies(controller, depTokens, visibleTokens, node.moduleClass, graph, container, diagnostics);
1107
1649
  }
1650
+ for (const guard of node.guards) {
1651
+ if (typeof guard === "function") {
1652
+ const depTokens = getClassDependencyTokens(guard);
1653
+ checkDependencies(guard, depTokens, visibleTokens, node.moduleClass, graph, container, diagnostics);
1654
+ }
1655
+ }
1108
1656
  }
1109
- debug3("validateModuleGraph: %d modules, %d diagnostics", graph.size, diagnostics.length);
1657
+ debug4("validateModuleGraph: %d modules, %d diagnostics", graph.size, diagnostics.length);
1110
1658
  if (diagnostics.length > 0) {
1111
1659
  const details = diagnostics.map((d) => ` ${d.message}`).join("\n");
1112
1660
  throw new Error(`Module validation errors:
@@ -1160,139 +1708,173 @@ function findTokenOwner(token, graph) {
1160
1708
  }
1161
1709
  __name(findTokenOwner, "findTokenOwner");
1162
1710
 
1163
- // src/handlers/registry.ts
1164
- var debug4 = (0, import_debug4.default)("celerity:core:registry");
1165
- var HandlerRegistry = class {
1166
- static {
1167
- __name(this, "HandlerRegistry");
1168
- }
1169
- handlers = [];
1170
- getHandler(path, method) {
1171
- const found = this.handlers.find((h) => h.path !== void 0 && h.method !== void 0 && matchRoute(h.path, path) && h.method === method);
1172
- debug4("getHandler %s %s \u2192 %s", method, path, found ? "matched" : "not found");
1173
- return found;
1174
- }
1175
- getHandlerById(id) {
1176
- const found = this.handlers.find((h) => h.id !== void 0 && h.id === id);
1177
- debug4("getHandlerById %s \u2192 %s", id, found ? "matched" : "not found");
1178
- return found;
1179
- }
1180
- getAllHandlers() {
1181
- return [
1182
- ...this.handlers
1183
- ];
1184
- }
1185
- async populateFromGraph(graph, container) {
1186
- for (const [, node] of graph) {
1187
- for (const controllerClass of node.controllers) {
1188
- await this.registerClassHandler(controllerClass, container);
1189
- }
1190
- for (const fnHandler of node.functionHandlers) {
1191
- this.registerFunctionHandler(fnHandler);
1192
- }
1711
+ // src/handlers/scanners/http.ts
1712
+ var import_reflect_metadata21 = require("reflect-metadata");
1713
+ var import_debug5 = __toESM(require("debug"), 1);
1714
+ var import_common2 = require("@celerity-sdk/common");
1715
+ var debug5 = (0, import_debug5.default)("celerity:core:scanner:http");
1716
+ async function scanHttpHandlers(graph, container, registry) {
1717
+ for (const [, node] of graph) {
1718
+ for (const controllerClass of node.controllers) {
1719
+ await scanClassHandler(controllerClass, container, registry);
1720
+ }
1721
+ for (const fnHandler of node.functionHandlers) {
1722
+ scanFunctionHandler(fnHandler, registry);
1193
1723
  }
1194
1724
  }
1195
- async scanModule(moduleClass, container) {
1196
- const graph = buildModuleGraph(moduleClass);
1197
- registerModuleGraph(graph, container);
1198
- await this.populateFromGraph(graph, container);
1199
- }
1200
- async registerClassHandler(controllerClass, container) {
1201
- const controllerMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
1202
- if (!controllerMeta) return;
1203
- const instance = await container.resolve(controllerClass);
1204
- const prototype = Object.getPrototypeOf(instance);
1205
- const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
1206
- const classProtectedBy = Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, controllerClass) ?? [];
1207
- const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
1208
- const classCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {};
1209
- for (const methodName of methods) {
1210
- const method = Reflect.getOwnMetadata(HTTP_METHOD_METADATA, prototype, methodName);
1211
- if (!method) continue;
1212
- const routePath = Reflect.getOwnMetadata(ROUTE_PATH_METADATA, prototype, methodName) ?? "/";
1213
- const fullPath = (0, import_common.joinHandlerPath)(controllerMeta.prefix ?? "", routePath);
1214
- const methodProtectedBy = Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, prototype, methodName) ?? [];
1215
- const methodLayers = Reflect.getOwnMetadata(LAYER_METADATA, prototype, methodName) ?? [];
1216
- const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, methodName) ?? [];
1217
- const isPublic = Reflect.getOwnMetadata(PUBLIC_METADATA, prototype, methodName) === true;
1218
- const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
1219
- const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
1220
- if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1221
- const layers = [
1222
- ...classLayers,
1223
- ...methodLayers
1224
- ];
1225
- const validationSchemas = buildValidationSchemasFromParams(paramMetadata);
1226
- if (validationSchemas) {
1227
- layers.unshift(validate(validationSchemas));
1725
+ }
1726
+ __name(scanHttpHandlers, "scanHttpHandlers");
1727
+ async function scanHttpGuards(graph, container, registry) {
1728
+ for (const [, node] of graph) {
1729
+ for (const guard of node.guards) {
1730
+ if (typeof guard === "function") {
1731
+ await scanClassGuard(guard, container, registry);
1732
+ } else {
1733
+ scanFunctionGuard(guard, registry);
1228
1734
  }
1229
- debug4("registerClassHandler: %s %s (%s.%s)", method, fullPath, controllerClass.name, methodName);
1230
- this.handlers.push({
1231
- path: fullPath,
1232
- method,
1233
- protectedBy: [
1234
- ...classProtectedBy,
1235
- ...methodProtectedBy
1236
- ],
1237
- layers,
1238
- isPublic,
1239
- paramMetadata,
1240
- customMetadata: {
1241
- ...classCustomMetadata,
1242
- ...methodCustomMetadata
1243
- },
1244
- handlerFn: descriptor.value,
1245
- handlerInstance: instance
1246
- });
1247
1735
  }
1248
1736
  }
1249
- registerFunctionHandler(definition) {
1250
- if (definition.type !== "http") return;
1251
- const meta = definition.metadata;
1737
+ }
1738
+ __name(scanHttpGuards, "scanHttpGuards");
1739
+ async function scanModule(moduleClass, container, registry) {
1740
+ const graph = buildModuleGraph(moduleClass);
1741
+ registerModuleGraph(graph, container);
1742
+ await scanHttpHandlers(graph, container, registry);
1743
+ await scanHttpGuards(graph, container, registry);
1744
+ }
1745
+ __name(scanModule, "scanModule");
1746
+ async function scanClassHandler(controllerClass, container, registry) {
1747
+ const controllerMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
1748
+ if (!controllerMeta) return;
1749
+ const instance = await container.resolve(controllerClass);
1750
+ const prototype = Object.getPrototypeOf(instance);
1751
+ const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
1752
+ const classProtectedBy = Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, controllerClass) ?? [];
1753
+ const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
1754
+ const classCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {};
1755
+ for (const methodName of methods) {
1756
+ const method = Reflect.getOwnMetadata(HTTP_METHOD_METADATA, prototype, methodName);
1757
+ if (!method) continue;
1758
+ const routePath = Reflect.getOwnMetadata(ROUTE_PATH_METADATA, prototype, methodName) ?? "/";
1759
+ const fullPath = (0, import_common2.joinHandlerPath)(controllerMeta.prefix ?? "", routePath);
1760
+ const methodProtectedBy = Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, prototype, methodName) ?? [];
1761
+ const methodLayers = Reflect.getOwnMetadata(LAYER_METADATA, prototype, methodName) ?? [];
1762
+ const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, methodName) ?? [];
1763
+ const isPublic = Reflect.getOwnMetadata(PUBLIC_METADATA, prototype, methodName) === true;
1764
+ const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
1765
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
1766
+ if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1252
1767
  const layers = [
1253
- ...meta.layers ?? []
1768
+ ...classLayers,
1769
+ ...methodLayers
1254
1770
  ];
1255
- if (meta.schema) {
1256
- const schemas = {};
1257
- if (meta.schema.body) schemas.body = meta.schema.body;
1258
- if (meta.schema.query) schemas.query = meta.schema.query;
1259
- if (meta.schema.params) schemas.params = meta.schema.params;
1260
- if (meta.schema.headers) schemas.headers = meta.schema.headers;
1261
- if (Object.keys(schemas).length > 0) {
1262
- layers.unshift(validate(schemas));
1263
- }
1771
+ const validationSchemas = buildValidationSchemasFromParams(paramMetadata);
1772
+ if (validationSchemas) {
1773
+ layers.unshift(validate(validationSchemas));
1264
1774
  }
1265
- debug4("registerFunctionHandler: %s", definition.id ?? (meta.method && meta.path ? `${meta.method} ${meta.path}` : "(no route)"));
1266
- this.handlers.push({
1267
- id: definition.id,
1268
- path: meta.path,
1269
- method: meta.method,
1270
- protectedBy: [],
1775
+ debug5("scanClassHandler: %s %s (%s.%s)", method, fullPath, controllerClass.name, methodName);
1776
+ registry.register({
1777
+ type: "http",
1778
+ path: fullPath,
1779
+ method,
1780
+ protectedBy: [
1781
+ ...classProtectedBy,
1782
+ ...methodProtectedBy
1783
+ ],
1271
1784
  layers,
1272
- isPublic: false,
1273
- paramMetadata: [],
1274
- customMetadata: meta.customMetadata ?? {},
1275
- handlerFn: definition.handler,
1276
- isFunctionHandler: true,
1277
- injectTokens: meta.inject ?? []
1785
+ isPublic,
1786
+ paramMetadata,
1787
+ customMetadata: {
1788
+ ...classCustomMetadata,
1789
+ ...methodCustomMetadata
1790
+ },
1791
+ handlerFn: descriptor.value,
1792
+ handlerInstance: instance
1278
1793
  });
1279
1794
  }
1280
- };
1281
- function matchRoute(pattern, actual) {
1282
- const patternParts = pattern.split("/").filter(Boolean);
1283
- const actualParts = actual.split("/").filter(Boolean);
1284
- if (patternParts.length !== actualParts.length) return false;
1285
- return patternParts.every((part, i) => part.startsWith("{") || part === actualParts[i]);
1286
1795
  }
1287
- __name(matchRoute, "matchRoute");
1288
- var PARAM_TYPE_TO_SCHEMA_KEY = {
1289
- body: "body",
1290
- query: "query",
1291
- param: "params",
1292
- headers: "headers"
1293
- };
1294
- function buildValidationSchemasFromParams(paramMetadata) {
1295
- const wholeObjectSchemas = /* @__PURE__ */ new Map();
1796
+ __name(scanClassHandler, "scanClassHandler");
1797
+ function scanFunctionHandler(definition, registry) {
1798
+ if (definition.type !== "http") return;
1799
+ const meta = definition.metadata;
1800
+ const layers = [
1801
+ ...meta.layers ?? []
1802
+ ];
1803
+ if (meta.schema) {
1804
+ const schemas = {};
1805
+ if (meta.schema.body) schemas.body = meta.schema.body;
1806
+ if (meta.schema.query) schemas.query = meta.schema.query;
1807
+ if (meta.schema.params) schemas.params = meta.schema.params;
1808
+ if (meta.schema.headers) schemas.headers = meta.schema.headers;
1809
+ if (Object.keys(schemas).length > 0) {
1810
+ layers.unshift(validate(schemas));
1811
+ }
1812
+ }
1813
+ debug5("scanFunctionHandler: %s", definition.id ?? (meta.method && meta.path ? `${meta.method} ${meta.path}` : "(no route)"));
1814
+ registry.register({
1815
+ type: "http",
1816
+ id: definition.id,
1817
+ path: meta.path,
1818
+ method: meta.method,
1819
+ protectedBy: [],
1820
+ layers,
1821
+ isPublic: false,
1822
+ paramMetadata: [],
1823
+ customMetadata: meta.customMetadata ?? {},
1824
+ handlerFn: definition.handler,
1825
+ isFunctionHandler: true,
1826
+ injectTokens: meta.inject ?? []
1827
+ });
1828
+ }
1829
+ __name(scanFunctionHandler, "scanFunctionHandler");
1830
+ async function scanClassGuard(guardClass, container, registry) {
1831
+ const guardName = Reflect.getOwnMetadata(GUARD_CUSTOM_METADATA, guardClass);
1832
+ if (!guardName) return;
1833
+ const instance = await container.resolve(guardClass);
1834
+ const prototype = Object.getPrototypeOf(instance);
1835
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, "check");
1836
+ if (!descriptor?.value || typeof descriptor.value !== "function") {
1837
+ debug5("scanClassGuard: %s has no check() method, skipping", guardClass.name);
1838
+ return;
1839
+ }
1840
+ const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, "check") ?? [];
1841
+ const customMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, guardClass) ?? {};
1842
+ debug5("scanClassGuard: %s (name=%s)", guardClass.name, guardName);
1843
+ registry.registerGuard({
1844
+ name: guardName,
1845
+ handlerFn: descriptor.value,
1846
+ handlerInstance: instance,
1847
+ paramMetadata,
1848
+ customMetadata
1849
+ });
1850
+ }
1851
+ __name(scanClassGuard, "scanClassGuard");
1852
+ function scanFunctionGuard(definition, registry) {
1853
+ const name = definition.name;
1854
+ if (!name) {
1855
+ debug5("scanFunctionGuard: no name, skipping");
1856
+ return;
1857
+ }
1858
+ const meta = definition.metadata ?? {};
1859
+ debug5("scanFunctionGuard: %s", name);
1860
+ registry.registerGuard({
1861
+ name,
1862
+ handlerFn: definition.handler,
1863
+ customMetadata: meta.customMetadata ?? {},
1864
+ paramMetadata: [],
1865
+ isFunctionGuard: true,
1866
+ injectTokens: meta.inject ?? []
1867
+ });
1868
+ }
1869
+ __name(scanFunctionGuard, "scanFunctionGuard");
1870
+ var PARAM_TYPE_TO_SCHEMA_KEY = {
1871
+ body: "body",
1872
+ query: "query",
1873
+ param: "params",
1874
+ headers: "headers"
1875
+ };
1876
+ function buildValidationSchemasFromParams(paramMetadata) {
1877
+ const wholeObjectSchemas = /* @__PURE__ */ new Map();
1296
1878
  const perKeySchemas = /* @__PURE__ */ new Map();
1297
1879
  for (const meta of paramMetadata) {
1298
1880
  if (!meta.schema) continue;
@@ -1346,16 +1928,371 @@ function composeKeySchemas(keySchemas) {
1346
1928
  }
1347
1929
  __name(composeKeySchemas, "composeKeySchemas");
1348
1930
 
1931
+ // src/handlers/scanners/websocket.ts
1932
+ var import_reflect_metadata22 = require("reflect-metadata");
1933
+ var import_debug6 = __toESM(require("debug"), 1);
1934
+ var debug6 = (0, import_debug6.default)("celerity:core:scanner:websocket");
1935
+ async function scanWebSocketHandlers(graph, container, registry) {
1936
+ for (const [, node] of graph) {
1937
+ for (const controllerClass of node.controllers) {
1938
+ await scanClassHandler2(controllerClass, container, registry);
1939
+ }
1940
+ for (const fnHandler of node.functionHandlers) {
1941
+ scanFunctionHandler2(fnHandler, registry);
1942
+ }
1943
+ }
1944
+ }
1945
+ __name(scanWebSocketHandlers, "scanWebSocketHandlers");
1946
+ async function scanClassHandler2(controllerClass, container, registry) {
1947
+ const isWsController = Reflect.getOwnMetadata(WEBSOCKET_CONTROLLER_METADATA, controllerClass);
1948
+ if (!isWsController) return;
1949
+ const instance = await container.resolve(controllerClass);
1950
+ const prototype = Object.getPrototypeOf(instance);
1951
+ const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
1952
+ const classProtectedBy = Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, controllerClass) ?? [];
1953
+ const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
1954
+ const classCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {};
1955
+ const classIsPublic = Reflect.getOwnMetadata(PUBLIC_METADATA, controllerClass) === true;
1956
+ for (const methodName of methods) {
1957
+ const eventMeta = Reflect.getOwnMetadata(WEBSOCKET_EVENT_METADATA, prototype, methodName);
1958
+ if (!eventMeta) continue;
1959
+ const methodLayers = Reflect.getOwnMetadata(LAYER_METADATA, prototype, methodName) ?? [];
1960
+ const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, methodName) ?? [];
1961
+ const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
1962
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
1963
+ if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1964
+ debug6("scanClassHandler: %s %s (%s.%s)", eventMeta.eventType, eventMeta.route, controllerClass.name, methodName);
1965
+ const layers = [
1966
+ ...classLayers,
1967
+ ...methodLayers
1968
+ ];
1969
+ const msgBodyParam = paramMetadata.find((p) => p.type === "messageBody");
1970
+ if (msgBodyParam?.schema) {
1971
+ layers.unshift(validate({
1972
+ wsMessageBody: msgBodyParam.schema
1973
+ }));
1974
+ }
1975
+ registry.register({
1976
+ type: "websocket",
1977
+ route: eventMeta.route,
1978
+ protectedBy: classProtectedBy,
1979
+ layers,
1980
+ isPublic: classIsPublic,
1981
+ paramMetadata,
1982
+ customMetadata: {
1983
+ ...classCustomMetadata,
1984
+ ...methodCustomMetadata
1985
+ },
1986
+ handlerFn: descriptor.value,
1987
+ handlerInstance: instance
1988
+ });
1989
+ }
1990
+ }
1991
+ __name(scanClassHandler2, "scanClassHandler");
1992
+ function scanFunctionHandler2(definition, registry) {
1993
+ if (definition.type !== "websocket") return;
1994
+ const meta = definition.metadata;
1995
+ const layers = [
1996
+ ...meta.layers ?? []
1997
+ ];
1998
+ if (meta.schema) {
1999
+ layers.unshift(validate({
2000
+ wsMessageBody: meta.schema
2001
+ }));
2002
+ }
2003
+ debug6("scanFunctionHandler: %s", definition.id ?? meta.route ?? "(no route)");
2004
+ registry.register({
2005
+ type: "websocket",
2006
+ id: definition.id,
2007
+ route: meta.route ?? "$default",
2008
+ protectedBy: meta.protectedBy ?? [],
2009
+ layers,
2010
+ isPublic: false,
2011
+ paramMetadata: [],
2012
+ customMetadata: meta.customMetadata ?? {},
2013
+ handlerFn: definition.handler,
2014
+ isFunctionHandler: true,
2015
+ injectTokens: meta.inject ?? []
2016
+ });
2017
+ }
2018
+ __name(scanFunctionHandler2, "scanFunctionHandler");
2019
+
2020
+ // src/handlers/scanners/consumer.ts
2021
+ var import_reflect_metadata23 = require("reflect-metadata");
2022
+ var import_debug7 = __toESM(require("debug"), 1);
2023
+ var debug7 = (0, import_debug7.default)("celerity:core:scanner:consumer");
2024
+ async function scanConsumerHandlers(graph, container, registry) {
2025
+ for (const [, node] of graph) {
2026
+ for (const controllerClass of node.controllers) {
2027
+ await scanClassHandler3(controllerClass, container, registry);
2028
+ }
2029
+ for (const fnHandler of node.functionHandlers) {
2030
+ scanFunctionHandler3(fnHandler, registry);
2031
+ }
2032
+ }
2033
+ }
2034
+ __name(scanConsumerHandlers, "scanConsumerHandlers");
2035
+ async function scanClassHandler3(controllerClass, container, registry) {
2036
+ const consumerMeta = Reflect.getOwnMetadata(CONSUMER_METADATA, controllerClass);
2037
+ if (!consumerMeta) return;
2038
+ const instance = await container.resolve(controllerClass);
2039
+ const prototype = Object.getPrototypeOf(instance);
2040
+ const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
2041
+ const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
2042
+ const classCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {};
2043
+ for (const methodName of methods) {
2044
+ const handlerMeta = Reflect.getOwnMetadata(CONSUMER_HANDLER_METADATA, prototype, methodName);
2045
+ if (!handlerMeta) continue;
2046
+ const methodLayers = Reflect.getOwnMetadata(LAYER_METADATA, prototype, methodName) ?? [];
2047
+ const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, methodName) ?? [];
2048
+ const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
2049
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
2050
+ if (!descriptor?.value || typeof descriptor.value !== "function") continue;
2051
+ const handlerTag = handlerMeta.route ?? methodName;
2052
+ const layers = [
2053
+ ...classLayers,
2054
+ ...methodLayers
2055
+ ];
2056
+ const messageParam = paramMetadata.find((p) => p.type === "messages");
2057
+ if (messageParam?.schema) {
2058
+ layers.unshift(validate({
2059
+ consumerMessage: messageParam.schema
2060
+ }));
2061
+ }
2062
+ debug7("scanClassHandler: tag=%s (%s.%s)", handlerTag, controllerClass.name, methodName);
2063
+ registry.register({
2064
+ type: "consumer",
2065
+ handlerTag,
2066
+ layers,
2067
+ paramMetadata,
2068
+ customMetadata: {
2069
+ ...classCustomMetadata,
2070
+ ...methodCustomMetadata
2071
+ },
2072
+ handlerFn: descriptor.value,
2073
+ handlerInstance: instance
2074
+ });
2075
+ }
2076
+ }
2077
+ __name(scanClassHandler3, "scanClassHandler");
2078
+ function scanFunctionHandler3(definition, registry) {
2079
+ if (definition.type !== "consumer") return;
2080
+ const meta = definition.metadata;
2081
+ const handlerTag = meta.route ?? definition.id ?? "default";
2082
+ const layers = [
2083
+ ...meta.layers ?? []
2084
+ ];
2085
+ if (meta.messageSchema) {
2086
+ layers.unshift(validate({
2087
+ consumerMessage: meta.messageSchema
2088
+ }));
2089
+ }
2090
+ debug7("scanFunctionHandler: tag=%s", handlerTag);
2091
+ registry.register({
2092
+ type: "consumer",
2093
+ id: definition.id,
2094
+ handlerTag,
2095
+ layers,
2096
+ paramMetadata: [],
2097
+ customMetadata: meta.customMetadata ?? {},
2098
+ handlerFn: definition.handler,
2099
+ isFunctionHandler: true,
2100
+ injectTokens: meta.inject ?? []
2101
+ });
2102
+ }
2103
+ __name(scanFunctionHandler3, "scanFunctionHandler");
2104
+
2105
+ // src/handlers/scanners/schedule.ts
2106
+ var import_reflect_metadata24 = require("reflect-metadata");
2107
+ var import_debug8 = __toESM(require("debug"), 1);
2108
+ var debug8 = (0, import_debug8.default)("celerity:core:scanner:schedule");
2109
+ async function scanScheduleHandlers(graph, container, registry) {
2110
+ for (const [, node] of graph) {
2111
+ for (const controllerClass of node.controllers) {
2112
+ await scanClassHandler4(controllerClass, container, registry);
2113
+ }
2114
+ for (const fnHandler of node.functionHandlers) {
2115
+ scanFunctionHandler4(fnHandler, registry);
2116
+ }
2117
+ }
2118
+ }
2119
+ __name(scanScheduleHandlers, "scanScheduleHandlers");
2120
+ async function scanClassHandler4(controllerClass, container, registry) {
2121
+ const instance = await container.resolve(controllerClass);
2122
+ const prototype = Object.getPrototypeOf(instance);
2123
+ const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
2124
+ const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
2125
+ const classCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {};
2126
+ for (const methodName of methods) {
2127
+ const handlerMeta = Reflect.getOwnMetadata(SCHEDULE_HANDLER_METADATA, prototype, methodName);
2128
+ if (!handlerMeta) continue;
2129
+ const methodLayers = Reflect.getOwnMetadata(LAYER_METADATA, prototype, methodName) ?? [];
2130
+ const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, methodName) ?? [];
2131
+ const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
2132
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
2133
+ if (!descriptor?.value || typeof descriptor.value !== "function") continue;
2134
+ const handlerTag = handlerMeta.scheduleId ?? methodName;
2135
+ const layers = [
2136
+ ...classLayers,
2137
+ ...methodLayers
2138
+ ];
2139
+ const inputParam = paramMetadata.find((p) => p.type === "scheduleInput");
2140
+ if (inputParam?.schema) {
2141
+ layers.unshift(validate({
2142
+ scheduleInput: inputParam.schema
2143
+ }));
2144
+ }
2145
+ debug8("scanClassHandler: tag=%s (%s.%s)", handlerTag, controllerClass.name, methodName);
2146
+ registry.register({
2147
+ type: "schedule",
2148
+ handlerTag,
2149
+ layers,
2150
+ paramMetadata,
2151
+ customMetadata: {
2152
+ ...classCustomMetadata,
2153
+ ...methodCustomMetadata,
2154
+ ...handlerMeta.schedule ? {
2155
+ schedule: handlerMeta.schedule
2156
+ } : {},
2157
+ ...handlerMeta.scheduleId ? {
2158
+ scheduleId: handlerMeta.scheduleId
2159
+ } : {}
2160
+ },
2161
+ handlerFn: descriptor.value,
2162
+ handlerInstance: instance
2163
+ });
2164
+ }
2165
+ }
2166
+ __name(scanClassHandler4, "scanClassHandler");
2167
+ function scanFunctionHandler4(definition, registry) {
2168
+ if (definition.type !== "schedule") return;
2169
+ const meta = definition.metadata;
2170
+ const handlerTag = meta.scheduleId ?? definition.id ?? "default";
2171
+ const layers = [
2172
+ ...meta.layers ?? []
2173
+ ];
2174
+ if (meta.schema) {
2175
+ layers.unshift(validate({
2176
+ scheduleInput: meta.schema
2177
+ }));
2178
+ }
2179
+ const customMetadata = {
2180
+ ...meta.customMetadata ?? {}
2181
+ };
2182
+ if (meta.schedule) customMetadata.schedule = meta.schedule;
2183
+ if (meta.scheduleId) customMetadata.scheduleId = meta.scheduleId;
2184
+ debug8("scanFunctionHandler: tag=%s", handlerTag);
2185
+ registry.register({
2186
+ type: "schedule",
2187
+ id: definition.id,
2188
+ handlerTag,
2189
+ layers,
2190
+ paramMetadata: [],
2191
+ customMetadata,
2192
+ handlerFn: definition.handler,
2193
+ isFunctionHandler: true,
2194
+ injectTokens: meta.inject ?? []
2195
+ });
2196
+ }
2197
+ __name(scanFunctionHandler4, "scanFunctionHandler");
2198
+
2199
+ // src/handlers/scanners/custom.ts
2200
+ var import_reflect_metadata25 = require("reflect-metadata");
2201
+ var import_debug9 = __toESM(require("debug"), 1);
2202
+ var debug9 = (0, import_debug9.default)("celerity:core:scanner:custom");
2203
+ async function scanCustomHandlers(graph, container, registry) {
2204
+ for (const [, node] of graph) {
2205
+ for (const controllerClass of node.controllers) {
2206
+ await scanClassHandler5(controllerClass, container, registry);
2207
+ }
2208
+ for (const fnHandler of node.functionHandlers) {
2209
+ scanFunctionHandler5(fnHandler, registry);
2210
+ }
2211
+ }
2212
+ }
2213
+ __name(scanCustomHandlers, "scanCustomHandlers");
2214
+ async function scanClassHandler5(controllerClass, container, registry) {
2215
+ const instance = await container.resolve(controllerClass);
2216
+ const prototype = Object.getPrototypeOf(instance);
2217
+ const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
2218
+ const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
2219
+ const classCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {};
2220
+ for (const methodName of methods) {
2221
+ const invokeMeta = Reflect.getOwnMetadata(INVOKE_METADATA, prototype, methodName);
2222
+ if (!invokeMeta) continue;
2223
+ const methodLayers = Reflect.getOwnMetadata(LAYER_METADATA, prototype, methodName) ?? [];
2224
+ const paramMetadata = Reflect.getOwnMetadata(PARAM_METADATA, prototype, methodName) ?? [];
2225
+ const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
2226
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
2227
+ if (!descriptor?.value || typeof descriptor.value !== "function") continue;
2228
+ const layers = [
2229
+ ...classLayers,
2230
+ ...methodLayers
2231
+ ];
2232
+ const payloadParam = paramMetadata.find((p) => p.type === "payload");
2233
+ if (payloadParam?.schema) {
2234
+ layers.unshift(validate({
2235
+ customPayload: payloadParam.schema
2236
+ }));
2237
+ }
2238
+ debug9("scanClassHandler: name=%s (%s.%s)", invokeMeta.name, controllerClass.name, methodName);
2239
+ registry.register({
2240
+ type: "custom",
2241
+ name: invokeMeta.name,
2242
+ layers,
2243
+ paramMetadata,
2244
+ customMetadata: {
2245
+ ...classCustomMetadata,
2246
+ ...methodCustomMetadata
2247
+ },
2248
+ handlerFn: descriptor.value,
2249
+ handlerInstance: instance
2250
+ });
2251
+ }
2252
+ }
2253
+ __name(scanClassHandler5, "scanClassHandler");
2254
+ function scanFunctionHandler5(definition, registry) {
2255
+ if (definition.type !== "custom") return;
2256
+ const meta = definition.metadata;
2257
+ const name = meta.name ?? definition.id ?? "default";
2258
+ const layers = [
2259
+ ...meta.layers ?? []
2260
+ ];
2261
+ if (meta.schema) {
2262
+ layers.unshift(validate({
2263
+ customPayload: meta.schema
2264
+ }));
2265
+ }
2266
+ debug9("scanFunctionHandler: name=%s", name);
2267
+ registry.register({
2268
+ type: "custom",
2269
+ id: definition.id,
2270
+ name,
2271
+ layers,
2272
+ paramMetadata: [],
2273
+ customMetadata: meta.customMetadata ?? {},
2274
+ handlerFn: definition.handler,
2275
+ isFunctionHandler: true,
2276
+ injectTokens: meta.inject ?? []
2277
+ });
2278
+ }
2279
+ __name(scanFunctionHandler5, "scanFunctionHandler");
2280
+
1349
2281
  // src/bootstrap/bootstrap.ts
1350
- var debug5 = (0, import_debug5.default)("celerity:core:bootstrap");
2282
+ var debug10 = (0, import_debug10.default)("celerity:core:bootstrap");
1351
2283
  async function bootstrap(rootModule) {
1352
- debug5("bootstrap: starting from %s", rootModule.name);
2284
+ debug10("bootstrap: starting from %s", rootModule.name);
1353
2285
  const container = new Container();
1354
2286
  const registry = new HandlerRegistry();
1355
2287
  const graph = walkModuleGraph(rootModule, container);
1356
2288
  validateModuleGraph(graph, container);
1357
- await registry.populateFromGraph(graph, container);
1358
- debug5("bootstrap: complete \u2014 %d modules, %d handlers", graph.size, registry.getAllHandlers().length);
2289
+ await scanHttpHandlers(graph, container, registry);
2290
+ await scanHttpGuards(graph, container, registry);
2291
+ await scanWebSocketHandlers(graph, container, registry);
2292
+ await scanConsumerHandlers(graph, container, registry);
2293
+ await scanScheduleHandlers(graph, container, registry);
2294
+ await scanCustomHandlers(graph, container, registry);
2295
+ debug10("bootstrap: complete \u2014 %d modules, %d handlers", graph.size, registry.getAllHandlers().length);
1359
2296
  return {
1360
2297
  container,
1361
2298
  registry
@@ -1364,8 +2301,8 @@ async function bootstrap(rootModule) {
1364
2301
  __name(bootstrap, "bootstrap");
1365
2302
 
1366
2303
  // src/application/application.ts
1367
- var import_debug6 = __toESM(require("debug"), 1);
1368
- var debug6 = (0, import_debug6.default)("celerity:core:factory");
2304
+ var import_debug11 = __toESM(require("debug"), 1);
2305
+ var debug11 = (0, import_debug11.default)("celerity:core:factory");
1369
2306
  var CelerityApplication = class {
1370
2307
  static {
1371
2308
  __name(this, "CelerityApplication");
@@ -1389,7 +2326,7 @@ var CelerityApplication = class {
1389
2326
  }
1390
2327
  }
1391
2328
  async close() {
1392
- debug6("close: shutting down application");
2329
+ debug11("close: shutting down application");
1393
2330
  if (this.runtimeApp && typeof this.runtimeApp === "object") {
1394
2331
  const app = this.runtimeApp;
1395
2332
  await app.shutdown();
@@ -1415,6 +2352,13 @@ var CelerityApplication = class {
1415
2352
  };
1416
2353
 
1417
2354
  // src/application/serverless.ts
2355
+ var HANDLER_CREATORS = {
2356
+ http: /* @__PURE__ */ __name((adapter, registry, options) => adapter.createHttpHandler(registry, options), "http"),
2357
+ websocket: /* @__PURE__ */ __name((adapter, registry, options) => adapter.createWebSocketHandler(registry, options), "websocket"),
2358
+ consumer: /* @__PURE__ */ __name((adapter, registry, options) => adapter.createConsumerHandler(registry, options), "consumer"),
2359
+ schedule: /* @__PURE__ */ __name((adapter, registry, options) => adapter.createScheduleHandler(registry, options), "schedule"),
2360
+ custom: /* @__PURE__ */ __name((adapter, registry, options) => adapter.createCustomHandler(registry, options), "custom")
2361
+ };
1418
2362
  var ServerlessApplication = class {
1419
2363
  static {
1420
2364
  __name(this, "ServerlessApplication");
@@ -1432,12 +2376,16 @@ var ServerlessApplication = class {
1432
2376
  this.systemLayers = systemLayers;
1433
2377
  this.appLayers = appLayers;
1434
2378
  }
1435
- async start() {
1436
- this.handler = this.adapter.createHandler(this.registry, {
2379
+ createHandler(type) {
2380
+ const options = {
1437
2381
  container: this.container,
1438
2382
  systemLayers: this.systemLayers,
1439
2383
  appLayers: this.appLayers
1440
- });
2384
+ };
2385
+ return HANDLER_CREATORS[type](this.adapter, this.registry, options);
2386
+ }
2387
+ async start(type = "http") {
2388
+ this.handler = this.createHandler(type);
1441
2389
  return this.handler;
1442
2390
  }
1443
2391
  async close() {
@@ -1461,8 +2409,8 @@ var ServerlessApplication = class {
1461
2409
  }
1462
2410
  };
1463
2411
 
1464
- // src/handlers/pipeline.ts
1465
- var import_debug7 = __toESM(require("debug"), 1);
2412
+ // src/handlers/http-pipeline.ts
2413
+ var import_debug12 = __toESM(require("debug"), 1);
1466
2414
 
1467
2415
  // src/functions/context.ts
1468
2416
  function buildHttpRequest(request, metadata) {
@@ -1504,12 +2452,17 @@ function buildHttpContext(request, metadata, container, logger) {
1504
2452
  }
1505
2453
  __name(buildHttpContext, "buildHttpContext");
1506
2454
 
1507
- // src/handlers/pipeline.ts
1508
- var debug7 = (0, import_debug7.default)("celerity:core:pipeline");
1509
- async function executeHandlerPipeline(handler, request, options) {
2455
+ // src/handlers/http-pipeline.ts
2456
+ var debug12 = (0, import_debug12.default)("celerity:core:pipeline");
2457
+ async function executeHttpPipeline(handler, request, options) {
1510
2458
  const context = {
1511
2459
  request,
1512
- metadata: new HandlerMetadataStore(handler.customMetadata ?? {}),
2460
+ metadata: new HandlerMetadataStore({
2461
+ ...handler.customMetadata ?? {},
2462
+ ...options.handlerName ? {
2463
+ handlerName: options.handlerName
2464
+ } : {}
2465
+ }),
1513
2466
  container: options.container
1514
2467
  };
1515
2468
  const allLayers = [
@@ -1517,19 +2470,19 @@ async function executeHandlerPipeline(handler, request, options) {
1517
2470
  ...options.appLayers ?? [],
1518
2471
  ...handler.layers
1519
2472
  ];
1520
- debug7("%s %s \u2014 %d layers", request.method, request.path, allLayers.length);
2473
+ debug12("%s %s \u2014 %d layers", request.method, request.path, allLayers.length);
1521
2474
  try {
1522
2475
  const response = await runLayerPipeline(allLayers, context, async () => {
1523
- const handlerType = handler.isFunctionHandler ? "function" : "class";
1524
- debug7("invoking %s handler", handlerType);
2476
+ const style = handler.isFunctionHandler ? "function" : "class";
2477
+ debug12("invoking %s handler", style);
1525
2478
  const result = handler.isFunctionHandler ? await invokeFunctionHandler(handler, context) : await invokeClassHandler(handler, context);
1526
2479
  return normalizeResponse(result);
1527
- });
1528
- debug7("response %d", response.status);
2480
+ }, "http");
2481
+ debug12("response %d", response.status);
1529
2482
  return response;
1530
2483
  } catch (error) {
1531
2484
  if (error instanceof HttpException) {
1532
- debug7("HttpException %d: %s", error.statusCode, error.message);
2485
+ debug12("HttpException %d: %s", error.statusCode, error.message);
1533
2486
  return {
1534
2487
  status: error.statusCode,
1535
2488
  headers: {
@@ -1565,7 +2518,7 @@ async function executeHandlerPipeline(handler, request, options) {
1565
2518
  };
1566
2519
  }
1567
2520
  }
1568
- __name(executeHandlerPipeline, "executeHandlerPipeline");
2521
+ __name(executeHttpPipeline, "executeHttpPipeline");
1569
2522
  async function invokeClassHandler(handler, context) {
1570
2523
  const args = [];
1571
2524
  const sorted = [
@@ -1634,98 +2587,555 @@ function isHttpResponse(value) {
1634
2587
  }
1635
2588
  __name(isHttpResponse, "isHttpResponse");
1636
2589
 
1637
- // src/testing/test-app.ts
1638
- var TestingApplication = class {
1639
- static {
1640
- __name(this, "TestingApplication");
2590
+ // src/handlers/websocket-pipeline.ts
2591
+ var import_debug13 = __toESM(require("debug"), 1);
2592
+ var debug13 = (0, import_debug13.default)("celerity:core:ws-pipeline");
2593
+ async function executeWebSocketPipeline(handler, message, options) {
2594
+ const context = {
2595
+ message,
2596
+ metadata: new HandlerMetadataStore({
2597
+ ...handler.customMetadata ?? {},
2598
+ ...options.handlerName ? {
2599
+ handlerName: options.handlerName
2600
+ } : {}
2601
+ }),
2602
+ container: options.container
2603
+ };
2604
+ const allLayers = [
2605
+ ...options.systemLayers ?? [],
2606
+ ...options.appLayers ?? [],
2607
+ ...handler.layers
2608
+ ];
2609
+ debug13("%s %s \u2014 %d layers", message.eventType, message.connectionId, allLayers.length);
2610
+ try {
2611
+ await runLayerPipeline(allLayers, context, async () => {
2612
+ const style = handler.isFunctionHandler ? "function" : "class";
2613
+ debug13("invoking %s handler", style);
2614
+ if (handler.isFunctionHandler) {
2615
+ await invokeFunctionHandler2(handler, context);
2616
+ } else {
2617
+ await invokeClassHandler2(handler, context);
2618
+ }
2619
+ }, "websocket");
2620
+ } catch (error) {
2621
+ const errorMessage = error instanceof Error ? error.message : String(error);
2622
+ if (context.logger) {
2623
+ context.logger.error("Unhandled error in WebSocket handler pipeline", {
2624
+ error: errorMessage,
2625
+ connectionId: message.connectionId,
2626
+ eventType: message.eventType,
2627
+ ...error instanceof Error && error.stack ? {
2628
+ stack: error.stack
2629
+ } : {}
2630
+ });
2631
+ } else {
2632
+ console.error("Unhandled error in WebSocket handler pipeline:", error);
2633
+ }
1641
2634
  }
1642
- registry;
1643
- container;
1644
- systemLayers;
1645
- appLayers;
1646
- constructor(registry, container, systemLayers = [], appLayers = []) {
1647
- this.registry = registry;
1648
- this.container = container;
1649
- this.systemLayers = systemLayers;
1650
- this.appLayers = appLayers;
2635
+ }
2636
+ __name(executeWebSocketPipeline, "executeWebSocketPipeline");
2637
+ async function invokeClassHandler2(handler, context) {
2638
+ const args = [];
2639
+ const sorted = [
2640
+ ...handler.paramMetadata
2641
+ ].sort((a, b) => a.index - b.index);
2642
+ for (const meta of sorted) {
2643
+ args[meta.index] = extractWebSocketParam(meta, context);
1651
2644
  }
1652
- async inject(request) {
1653
- const handler = this.registry.getHandler(request.path, request.method);
1654
- if (!handler) {
1655
- throw new NotFoundException(`No handler found for ${request.method} ${request.path}`);
2645
+ await handler.handlerFn.apply(handler.handlerInstance, args);
2646
+ }
2647
+ __name(invokeClassHandler2, "invokeClassHandler");
2648
+ async function invokeFunctionHandler2(handler, context) {
2649
+ const validatedBody = context.metadata.get("validatedMessageBody");
2650
+ const message = validatedBody !== void 0 ? {
2651
+ ...context.message,
2652
+ jsonBody: validatedBody
2653
+ } : context.message;
2654
+ if (handler.injectTokens && handler.injectTokens.length > 0) {
2655
+ const deps = [];
2656
+ for (const token of handler.injectTokens) {
2657
+ deps.push(await context.container.resolve(token));
1656
2658
  }
1657
- return executeHandlerPipeline(handler, request, {
1658
- container: this.container,
1659
- systemLayers: this.systemLayers,
1660
- appLayers: this.appLayers
1661
- });
1662
- }
1663
- getContainer() {
1664
- return this.container;
2659
+ await handler.handlerFn(message, context, ...deps);
2660
+ } else {
2661
+ await handler.handlerFn(message, context);
1665
2662
  }
1666
- getRegistry() {
1667
- return this.registry;
2663
+ }
2664
+ __name(invokeFunctionHandler2, "invokeFunctionHandler");
2665
+ function extractWebSocketParam(meta, context) {
2666
+ const { message } = context;
2667
+ switch (meta.type) {
2668
+ case "connectionId":
2669
+ return message.connectionId;
2670
+ case "messageBody": {
2671
+ const validated = context.metadata.get("validatedMessageBody");
2672
+ if (validated !== void 0) return validated;
2673
+ return message.jsonBody;
2674
+ }
2675
+ case "messageId":
2676
+ return message.messageId;
2677
+ case "requestContext":
2678
+ return message.requestContext;
2679
+ case "eventType":
2680
+ return message.eventType;
2681
+ default:
2682
+ return void 0;
1668
2683
  }
1669
- };
1670
- function mockRequest(method, path, options = {}) {
1671
- return {
1672
- method,
1673
- path,
1674
- pathParams: options.pathParams ?? {},
1675
- query: options.query ?? {},
1676
- headers: options.headers ?? {},
1677
- cookies: options.cookies ?? {},
1678
- textBody: options.body !== void 0 ? JSON.stringify(options.body) : null,
1679
- binaryBody: null,
1680
- contentType: options.body !== void 0 ? "application/json" : null,
1681
- requestId: options.requestId ?? "test-request-id",
1682
- requestTime: (/* @__PURE__ */ new Date()).toISOString(),
1683
- auth: options.auth ?? null,
1684
- clientIp: options.clientIp ?? "127.0.0.1",
1685
- traceContext: null,
1686
- userAgent: "celerity-testing",
1687
- matchedRoute: null
1688
- };
1689
2684
  }
1690
- __name(mockRequest, "mockRequest");
2685
+ __name(extractWebSocketParam, "extractWebSocketParam");
1691
2686
 
1692
- // src/application/factory.ts
1693
- var debug8 = (0, import_debug8.default)("celerity:core:factory");
1694
- var CelerityFactory = class {
1695
- static {
1696
- __name(this, "CelerityFactory");
2687
+ // src/handlers/consumer-pipeline.ts
2688
+ var import_debug14 = __toESM(require("debug"), 1);
2689
+ var debug14 = (0, import_debug14.default)("celerity:core:consumer-pipeline");
2690
+ async function executeConsumerPipeline(handler, event, options) {
2691
+ const context = {
2692
+ event,
2693
+ metadata: new HandlerMetadataStore({
2694
+ ...handler.customMetadata ?? {},
2695
+ ...options.handlerName ? {
2696
+ handlerName: options.handlerName
2697
+ } : {}
2698
+ }),
2699
+ container: options.container
2700
+ };
2701
+ const allLayers = [
2702
+ ...options.systemLayers ?? [],
2703
+ ...options.appLayers ?? [],
2704
+ ...handler.layers
2705
+ ];
2706
+ debug14("tag=%s \u2014 %d messages, %d layers", event.handlerTag, event.messages.length, allLayers.length);
2707
+ let result = {
2708
+ success: true
2709
+ };
2710
+ try {
2711
+ await runLayerPipeline(allLayers, context, async () => {
2712
+ const style = handler.isFunctionHandler ? "function" : "class";
2713
+ debug14("invoking %s handler", style);
2714
+ const validatedMessages = context.metadata.get("validatedMessages");
2715
+ const validationFailures = context.metadata.get("validationFailures") ?? [];
2716
+ const rawMessages = validatedMessages ? void 0 : event.messages;
2717
+ if (handler.isFunctionHandler) {
2718
+ result = await invokeFunctionHandler3(handler, context, validatedMessages, rawMessages);
2719
+ } else {
2720
+ result = await invokeClassHandler3(handler, context, validatedMessages, rawMessages);
2721
+ }
2722
+ if (validationFailures.length > 0) {
2723
+ const existing = result.failures ?? [];
2724
+ result = {
2725
+ ...result,
2726
+ success: result.success && validationFailures.length === 0,
2727
+ failures: [
2728
+ ...validationFailures,
2729
+ ...existing
2730
+ ]
2731
+ };
2732
+ }
2733
+ }, "consumer");
2734
+ } catch (error) {
2735
+ const errorMessage = error instanceof Error ? error.message : String(error);
2736
+ if (context.logger) {
2737
+ context.logger.error("Unhandled error in consumer handler pipeline", {
2738
+ error: errorMessage,
2739
+ handlerTag: event.handlerTag,
2740
+ messageCount: event.messages.length,
2741
+ ...error instanceof Error && error.stack ? {
2742
+ stack: error.stack
2743
+ } : {}
2744
+ });
2745
+ } else {
2746
+ console.error("Unhandled error in consumer handler pipeline:", error);
2747
+ }
2748
+ return {
2749
+ success: false,
2750
+ errorMessage
2751
+ };
1697
2752
  }
1698
- static async create(rootModule, options) {
1699
- debug8("create: bootstrapping %s", rootModule.name);
1700
- const systemLayers = options?.systemLayers ?? await createDefaultSystemLayers();
1701
- const appLayers = options?.layers ?? [];
1702
- debug8("create: %d system layers, %d app layers", systemLayers.length, appLayers.length);
1703
- const { container, registry } = await bootstrap(rootModule);
1704
- if (options?.adapter) {
1705
- debug8("create: using adapter \u2192 ServerlessApplication");
1706
- return new ServerlessApplication(registry, container, options.adapter, systemLayers, appLayers);
2753
+ return result;
2754
+ }
2755
+ __name(executeConsumerPipeline, "executeConsumerPipeline");
2756
+ async function invokeClassHandler3(handler, context, validatedMessages, rawMessages) {
2757
+ const args = [];
2758
+ const sorted = [
2759
+ ...handler.paramMetadata
2760
+ ].sort((a, b) => a.index - b.index);
2761
+ for (const meta of sorted) {
2762
+ args[meta.index] = extractConsumerParam(meta, context, validatedMessages, rawMessages);
2763
+ }
2764
+ return await handler.handlerFn.apply(handler.handlerInstance, args);
2765
+ }
2766
+ __name(invokeClassHandler3, "invokeClassHandler");
2767
+ async function invokeFunctionHandler3(handler, context, validatedMessages, _rawMessages) {
2768
+ const deps = [];
2769
+ if (handler.injectTokens && handler.injectTokens.length > 0) {
2770
+ for (const token of handler.injectTokens) {
2771
+ deps.push(await context.container.resolve(token));
1707
2772
  }
1708
- debug8("create: \u2192 CelerityApplication");
1709
- return new CelerityApplication(registry, container, systemLayers, appLayers);
1710
2773
  }
1711
- static async createTestingApp(rootModule, options) {
1712
- debug8("createTestingApp: bootstrapping %s", rootModule.name);
1713
- const { container, registry } = await bootstrap(rootModule);
1714
- const systemLayers = options?.systemLayers ?? [];
1715
- const appLayers = options?.layers ?? [];
1716
- return new TestingApplication(registry, container, systemLayers, appLayers);
2774
+ const firstArg = validatedMessages ?? context.event;
2775
+ return await handler.handlerFn(firstArg, context, ...deps);
2776
+ }
2777
+ __name(invokeFunctionHandler3, "invokeFunctionHandler");
2778
+ function extractConsumerParam(meta, context, validatedMessages, rawMessages) {
2779
+ switch (meta.type) {
2780
+ case "messages":
2781
+ return validatedMessages ?? rawMessages ?? context.event.messages;
2782
+ case "consumerEvent":
2783
+ return context.event;
2784
+ case "consumerVendor":
2785
+ return context.event.vendor;
2786
+ case "consumerTraceContext":
2787
+ return context.event.traceContext ?? null;
2788
+ default:
2789
+ return void 0;
1717
2790
  }
1718
- };
2791
+ }
2792
+ __name(extractConsumerParam, "extractConsumerParam");
1719
2793
 
1720
- // src/functions/create-handler.ts
1721
- function createHttpHandler(config, handler) {
1722
- const metadata = {
1723
- schema: config.schema,
1724
- layers: config.layers ?? [],
1725
- inject: config.inject ?? [],
1726
- customMetadata: config.metadata ?? {}
2794
+ // src/handlers/schedule-pipeline.ts
2795
+ var import_debug15 = __toESM(require("debug"), 1);
2796
+ var debug15 = (0, import_debug15.default)("celerity:core:schedule-pipeline");
2797
+ async function executeSchedulePipeline(handler, event, options) {
2798
+ const context = {
2799
+ event,
2800
+ metadata: new HandlerMetadataStore({
2801
+ ...handler.customMetadata ?? {},
2802
+ ...options.handlerName ? {
2803
+ handlerName: options.handlerName
2804
+ } : {}
2805
+ }),
2806
+ container: options.container
1727
2807
  };
1728
- if (config.path !== void 0) metadata.path = config.path;
2808
+ const allLayers = [
2809
+ ...options.systemLayers ?? [],
2810
+ ...options.appLayers ?? [],
2811
+ ...handler.layers
2812
+ ];
2813
+ debug15("tag=%s \u2014 %d layers", event.handlerTag, allLayers.length);
2814
+ let result = {
2815
+ success: true
2816
+ };
2817
+ try {
2818
+ await runLayerPipeline(allLayers, context, async () => {
2819
+ const style = handler.isFunctionHandler ? "function" : "class";
2820
+ debug15("invoking %s handler", style);
2821
+ const validatedInput = context.metadata.get("validatedInput") ?? event.input;
2822
+ if (handler.isFunctionHandler) {
2823
+ result = await invokeFunctionHandler4(handler, context, validatedInput);
2824
+ } else {
2825
+ result = await invokeClassHandler4(handler, context, validatedInput);
2826
+ }
2827
+ }, "schedule");
2828
+ } catch (error) {
2829
+ const errorMessage = error instanceof Error ? error.message : String(error);
2830
+ if (context.logger) {
2831
+ context.logger.error("Unhandled error in schedule handler pipeline", {
2832
+ error: errorMessage,
2833
+ handlerTag: event.handlerTag,
2834
+ scheduleId: event.scheduleId,
2835
+ ...error instanceof Error && error.stack ? {
2836
+ stack: error.stack
2837
+ } : {}
2838
+ });
2839
+ } else {
2840
+ console.error("Unhandled error in schedule handler pipeline:", error);
2841
+ }
2842
+ return {
2843
+ success: false,
2844
+ errorMessage
2845
+ };
2846
+ }
2847
+ return result;
2848
+ }
2849
+ __name(executeSchedulePipeline, "executeSchedulePipeline");
2850
+ async function invokeClassHandler4(handler, context, validatedInput) {
2851
+ const args = [];
2852
+ const sorted = [
2853
+ ...handler.paramMetadata
2854
+ ].sort((a, b) => a.index - b.index);
2855
+ for (const meta of sorted) {
2856
+ args[meta.index] = extractScheduleParam(meta, context, validatedInput);
2857
+ }
2858
+ return await handler.handlerFn.apply(handler.handlerInstance, args);
2859
+ }
2860
+ __name(invokeClassHandler4, "invokeClassHandler");
2861
+ async function invokeFunctionHandler4(handler, context, _validatedInput) {
2862
+ const deps = [];
2863
+ if (handler.injectTokens && handler.injectTokens.length > 0) {
2864
+ for (const token of handler.injectTokens) {
2865
+ deps.push(await context.container.resolve(token));
2866
+ }
2867
+ }
2868
+ return await handler.handlerFn(context.event, context, ...deps);
2869
+ }
2870
+ __name(invokeFunctionHandler4, "invokeFunctionHandler");
2871
+ function extractScheduleParam(meta, context, validatedInput) {
2872
+ switch (meta.type) {
2873
+ case "scheduleInput":
2874
+ return validatedInput;
2875
+ case "scheduleId":
2876
+ return context.event.scheduleId;
2877
+ case "scheduleExpression":
2878
+ return context.event.schedule;
2879
+ case "scheduleEvent":
2880
+ return context.event;
2881
+ default:
2882
+ return void 0;
2883
+ }
2884
+ }
2885
+ __name(extractScheduleParam, "extractScheduleParam");
2886
+
2887
+ // src/handlers/custom-pipeline.ts
2888
+ var import_debug16 = __toESM(require("debug"), 1);
2889
+ var debug16 = (0, import_debug16.default)("celerity:core:custom-pipeline");
2890
+ async function executeCustomPipeline(handler, payload, options) {
2891
+ const context = {
2892
+ metadata: new HandlerMetadataStore({
2893
+ ...handler.customMetadata ?? {},
2894
+ ...options.handlerName ? {
2895
+ handlerName: options.handlerName
2896
+ } : {},
2897
+ rawPayload: payload
2898
+ }),
2899
+ container: options.container
2900
+ };
2901
+ const allLayers = [
2902
+ ...options.systemLayers ?? [],
2903
+ ...options.appLayers ?? [],
2904
+ ...handler.layers
2905
+ ];
2906
+ debug16("name=%s \u2014 %d layers", options.handlerName ?? "unknown", allLayers.length);
2907
+ let result;
2908
+ await runLayerPipeline(allLayers, context, async () => {
2909
+ const style = handler.isFunctionHandler ? "function" : "class";
2910
+ debug16("invoking %s handler", style);
2911
+ const validatedPayload = context.metadata.get("validatedPayload") ?? payload;
2912
+ if (handler.isFunctionHandler) {
2913
+ result = await invokeFunctionHandler5(handler, context, validatedPayload);
2914
+ } else {
2915
+ result = await invokeClassHandler5(handler, context, validatedPayload);
2916
+ }
2917
+ }, "custom");
2918
+ return result;
2919
+ }
2920
+ __name(executeCustomPipeline, "executeCustomPipeline");
2921
+ async function invokeClassHandler5(handler, context, validatedPayload) {
2922
+ const args = [];
2923
+ const sorted = [
2924
+ ...handler.paramMetadata
2925
+ ].sort((a, b) => a.index - b.index);
2926
+ for (const meta of sorted) {
2927
+ args[meta.index] = extractCustomParam(meta, context, validatedPayload);
2928
+ }
2929
+ return handler.handlerFn.apply(handler.handlerInstance, args);
2930
+ }
2931
+ __name(invokeClassHandler5, "invokeClassHandler");
2932
+ async function invokeFunctionHandler5(handler, context, validatedPayload) {
2933
+ const deps = [];
2934
+ if (handler.injectTokens && handler.injectTokens.length > 0) {
2935
+ for (const token of handler.injectTokens) {
2936
+ deps.push(await context.container.resolve(token));
2937
+ }
2938
+ }
2939
+ return handler.handlerFn(validatedPayload, context, ...deps);
2940
+ }
2941
+ __name(invokeFunctionHandler5, "invokeFunctionHandler");
2942
+ function extractCustomParam(meta, context, validatedPayload) {
2943
+ switch (meta.type) {
2944
+ case "payload":
2945
+ return validatedPayload;
2946
+ case "invokeContext":
2947
+ return context;
2948
+ default:
2949
+ return void 0;
2950
+ }
2951
+ }
2952
+ __name(extractCustomParam, "extractCustomParam");
2953
+
2954
+ // src/testing/test-app.ts
2955
+ var TestingApplication = class {
2956
+ static {
2957
+ __name(this, "TestingApplication");
2958
+ }
2959
+ registry;
2960
+ container;
2961
+ systemLayers;
2962
+ appLayers;
2963
+ constructor(registry, container, systemLayers = [], appLayers = []) {
2964
+ this.registry = registry;
2965
+ this.container = container;
2966
+ this.systemLayers = systemLayers;
2967
+ this.appLayers = appLayers;
2968
+ }
2969
+ async injectHttp(request) {
2970
+ const handler = this.registry.getHandler("http", `${request.method} ${request.path}`);
2971
+ if (!handler) {
2972
+ throw new NotFoundException(`No handler found for ${request.method} ${request.path}`);
2973
+ }
2974
+ return executeHttpPipeline(handler, request, {
2975
+ container: this.container,
2976
+ systemLayers: this.systemLayers,
2977
+ appLayers: this.appLayers
2978
+ });
2979
+ }
2980
+ async injectWebSocket(route, message) {
2981
+ const handler = this.registry.getHandler("websocket", route);
2982
+ if (!handler) {
2983
+ throw new NotFoundException(`No WebSocket handler found for route: ${route}`);
2984
+ }
2985
+ await executeWebSocketPipeline(handler, message, {
2986
+ container: this.container,
2987
+ systemLayers: this.systemLayers,
2988
+ appLayers: this.appLayers
2989
+ });
2990
+ }
2991
+ async injectConsumer(handlerTag, event) {
2992
+ const handler = this.registry.getHandler("consumer", handlerTag);
2993
+ if (!handler) {
2994
+ throw new NotFoundException(`No consumer handler found for tag: ${handlerTag}`);
2995
+ }
2996
+ return executeConsumerPipeline(handler, event, {
2997
+ container: this.container,
2998
+ systemLayers: this.systemLayers,
2999
+ appLayers: this.appLayers
3000
+ });
3001
+ }
3002
+ async injectSchedule(handlerTag, event) {
3003
+ const handler = this.registry.getHandler("schedule", handlerTag);
3004
+ if (!handler) {
3005
+ throw new NotFoundException(`No schedule handler found for tag: ${handlerTag}`);
3006
+ }
3007
+ return executeSchedulePipeline(handler, event, {
3008
+ container: this.container,
3009
+ systemLayers: this.systemLayers,
3010
+ appLayers: this.appLayers
3011
+ });
3012
+ }
3013
+ async injectCustom(name, payload) {
3014
+ const handler = this.registry.getHandler("custom", name);
3015
+ if (!handler) {
3016
+ throw new NotFoundException(`No custom handler found for name: ${name}`);
3017
+ }
3018
+ return executeCustomPipeline(handler, payload ?? null, {
3019
+ container: this.container,
3020
+ systemLayers: this.systemLayers,
3021
+ appLayers: this.appLayers
3022
+ });
3023
+ }
3024
+ getContainer() {
3025
+ return this.container;
3026
+ }
3027
+ getRegistry() {
3028
+ return this.registry;
3029
+ }
3030
+ };
3031
+ function mockRequest(method, path, options = {}) {
3032
+ return {
3033
+ method,
3034
+ path,
3035
+ pathParams: options.pathParams ?? {},
3036
+ query: options.query ?? {},
3037
+ headers: options.headers ?? {},
3038
+ cookies: options.cookies ?? {},
3039
+ textBody: options.body !== void 0 ? JSON.stringify(options.body) : null,
3040
+ binaryBody: null,
3041
+ contentType: options.body !== void 0 ? "application/json" : null,
3042
+ requestId: options.requestId ?? "test-request-id",
3043
+ requestTime: (/* @__PURE__ */ new Date()).toISOString(),
3044
+ auth: options.auth ?? null,
3045
+ clientIp: options.clientIp ?? "127.0.0.1",
3046
+ traceContext: null,
3047
+ userAgent: "celerity-testing",
3048
+ matchedRoute: null
3049
+ };
3050
+ }
3051
+ __name(mockRequest, "mockRequest");
3052
+ function mockWebSocketMessage(options = {}) {
3053
+ return {
3054
+ messageType: options.messageType ?? "json",
3055
+ eventType: options.eventType ?? "message",
3056
+ connectionId: options.connectionId ?? "test-conn-id",
3057
+ messageId: options.messageId ?? "test-msg-id",
3058
+ jsonBody: options.jsonBody ?? null,
3059
+ binaryBody: options.binaryBody,
3060
+ traceContext: options.traceContext ?? null
3061
+ };
3062
+ }
3063
+ __name(mockWebSocketMessage, "mockWebSocketMessage");
3064
+ function mockConsumerEvent(handlerTag, messages, options = {}) {
3065
+ const builtMessages = messages.map((msg, index) => ({
3066
+ messageId: msg.messageId ?? `msg-${index}`,
3067
+ body: msg.body,
3068
+ source: msg.source ?? "test",
3069
+ ...msg.sourceType !== void 0 && {
3070
+ sourceType: msg.sourceType
3071
+ },
3072
+ ...msg.sourceName !== void 0 && {
3073
+ sourceName: msg.sourceName
3074
+ },
3075
+ ...msg.eventType !== void 0 && {
3076
+ eventType: msg.eventType
3077
+ },
3078
+ messageAttributes: msg.messageAttributes ?? {},
3079
+ vendor: {}
3080
+ }));
3081
+ return {
3082
+ handlerTag,
3083
+ messages: builtMessages,
3084
+ vendor: options.vendor ?? {},
3085
+ traceContext: options.traceContext ?? null
3086
+ };
3087
+ }
3088
+ __name(mockConsumerEvent, "mockConsumerEvent");
3089
+ function mockScheduleEvent(handlerTag, options = {}) {
3090
+ return {
3091
+ handlerTag,
3092
+ scheduleId: options.scheduleId ?? handlerTag,
3093
+ messageId: options.messageId ?? "test-schedule-msg-id",
3094
+ schedule: options.schedule ?? "rate(1 day)",
3095
+ input: options.input,
3096
+ vendor: options.vendor ?? {},
3097
+ traceContext: options.traceContext ?? null
3098
+ };
3099
+ }
3100
+ __name(mockScheduleEvent, "mockScheduleEvent");
3101
+
3102
+ // src/application/factory.ts
3103
+ var debug17 = (0, import_debug17.default)("celerity:core:factory");
3104
+ var CelerityFactory = class {
3105
+ static {
3106
+ __name(this, "CelerityFactory");
3107
+ }
3108
+ static async create(rootModule, options) {
3109
+ debug17("create: bootstrapping %s", rootModule.name);
3110
+ const systemLayers = options?.systemLayers ?? await createDefaultSystemLayers();
3111
+ const appLayers = options?.layers ?? [];
3112
+ debug17("create: %d system layers, %d app layers", systemLayers.length, appLayers.length);
3113
+ const { container, registry } = await bootstrap(rootModule);
3114
+ if (options?.adapter) {
3115
+ debug17("create: using adapter \u2192 ServerlessApplication");
3116
+ return new ServerlessApplication(registry, container, options.adapter, systemLayers, appLayers);
3117
+ }
3118
+ debug17("create: \u2192 CelerityApplication");
3119
+ return new CelerityApplication(registry, container, systemLayers, appLayers);
3120
+ }
3121
+ static async createTestingApp(rootModule, options) {
3122
+ debug17("createTestingApp: bootstrapping %s", rootModule.name);
3123
+ const { container, registry } = await bootstrap(rootModule);
3124
+ const systemLayers = options?.systemLayers ?? [];
3125
+ const appLayers = options?.layers ?? [];
3126
+ return new TestingApplication(registry, container, systemLayers, appLayers);
3127
+ }
3128
+ };
3129
+
3130
+ // src/functions/create-handler.ts
3131
+ function createHttpHandler(config, handler) {
3132
+ const metadata = {
3133
+ schema: config.schema,
3134
+ layers: config.layers ?? [],
3135
+ inject: config.inject ?? [],
3136
+ customMetadata: config.metadata ?? {}
3137
+ };
3138
+ if (config.path !== void 0) metadata.path = config.path;
1729
3139
  if (config.method !== void 0) metadata.method = config.method;
1730
3140
  return {
1731
3141
  __celerity_handler: true,
@@ -1806,22 +3216,130 @@ function httpDelete(path, handlerOrOptions, maybeHandler) {
1806
3216
  }
1807
3217
  __name(httpDelete, "httpDelete");
1808
3218
 
3219
+ // src/functions/create-guard.ts
3220
+ function createGuard(config, handler) {
3221
+ return {
3222
+ __celerity_guard: true,
3223
+ name: config.name,
3224
+ handler,
3225
+ metadata: {
3226
+ inject: config.inject ?? [],
3227
+ customMetadata: config.metadata ?? {}
3228
+ }
3229
+ };
3230
+ }
3231
+ __name(createGuard, "createGuard");
3232
+
3233
+ // src/functions/create-websocket-handler.ts
3234
+ function createWebSocketHandler(config, handler) {
3235
+ const metadata = {
3236
+ layers: config.layers ?? [],
3237
+ inject: config.inject ?? [],
3238
+ customMetadata: config.metadata ?? {}
3239
+ };
3240
+ if (config.route !== void 0) metadata.route = config.route;
3241
+ if (config.protectedBy !== void 0) metadata.protectedBy = config.protectedBy;
3242
+ if (config.schema !== void 0) metadata.schema = config.schema;
3243
+ return {
3244
+ __celerity_handler: true,
3245
+ type: "websocket",
3246
+ metadata,
3247
+ handler
3248
+ };
3249
+ }
3250
+ __name(createWebSocketHandler, "createWebSocketHandler");
3251
+
3252
+ // src/functions/create-consumer-handler.ts
3253
+ function createConsumerHandler(config, handler) {
3254
+ const metadata = {
3255
+ layers: config.layers ?? [],
3256
+ inject: config.inject ?? [],
3257
+ customMetadata: config.metadata ?? {}
3258
+ };
3259
+ if (config.route !== void 0) metadata.route = config.route;
3260
+ if (config.messageSchema !== void 0) metadata.messageSchema = config.messageSchema;
3261
+ return {
3262
+ __celerity_handler: true,
3263
+ type: "consumer",
3264
+ metadata,
3265
+ handler
3266
+ };
3267
+ }
3268
+ __name(createConsumerHandler, "createConsumerHandler");
3269
+
3270
+ // src/functions/create-schedule-handler.ts
3271
+ function isScheduleExpression2(value) {
3272
+ return value.startsWith("rate(") || value.startsWith("cron(");
3273
+ }
3274
+ __name(isScheduleExpression2, "isScheduleExpression");
3275
+ function createScheduleHandler(configOrString, configOrHandler, maybeHandler) {
3276
+ let config;
3277
+ let handler;
3278
+ if (typeof configOrString === "string") {
3279
+ config = {
3280
+ ...configOrHandler
3281
+ };
3282
+ handler = maybeHandler;
3283
+ if (isScheduleExpression2(configOrString)) {
3284
+ config.schedule = configOrString;
3285
+ } else {
3286
+ config.scheduleId = configOrString;
3287
+ }
3288
+ } else {
3289
+ config = configOrString;
3290
+ handler = configOrHandler;
3291
+ }
3292
+ const metadata = {
3293
+ layers: config.layers ?? [],
3294
+ inject: config.inject ?? [],
3295
+ customMetadata: config.metadata ?? {}
3296
+ };
3297
+ if (config.scheduleId !== void 0) metadata.scheduleId = config.scheduleId;
3298
+ if (config.schedule !== void 0) metadata.schedule = config.schedule;
3299
+ if (config.schema !== void 0) metadata.schema = config.schema;
3300
+ return {
3301
+ __celerity_handler: true,
3302
+ type: "schedule",
3303
+ metadata,
3304
+ handler
3305
+ };
3306
+ }
3307
+ __name(createScheduleHandler, "createScheduleHandler");
3308
+
3309
+ // src/functions/create-custom-handler.ts
3310
+ function createCustomHandler(config, handler) {
3311
+ const metadata = {
3312
+ layers: config.layers ?? [],
3313
+ inject: config.inject ?? [],
3314
+ customMetadata: config.metadata ?? {}
3315
+ };
3316
+ if (config.name !== void 0) metadata.name = config.name;
3317
+ if (config.schema !== void 0) metadata.schema = config.schema;
3318
+ return {
3319
+ __celerity_handler: true,
3320
+ type: "custom",
3321
+ metadata,
3322
+ handler
3323
+ };
3324
+ }
3325
+ __name(createCustomHandler, "createCustomHandler");
3326
+
1809
3327
  // src/handlers/module-resolver.ts
1810
3328
  var import_node_path = require("path");
1811
- var import_debug9 = __toESM(require("debug"), 1);
1812
- var debug9 = (0, import_debug9.default)("celerity:core:module-resolver");
1813
- async function resolveHandlerByModuleRef(handlerId, registry, baseDir) {
3329
+ var import_debug18 = __toESM(require("debug"), 1);
3330
+ var debug18 = (0, import_debug18.default)("celerity:core:module-resolver");
3331
+ async function resolveHandlerByModuleRef(handlerId, handlerType, registry, baseDir) {
1814
3332
  const lastDot = handlerId.lastIndexOf(".");
1815
3333
  if (lastDot > 0) {
1816
3334
  const moduleName = handlerId.slice(0, lastDot);
1817
3335
  const exportName = handlerId.slice(lastDot + 1);
1818
- const result = await tryResolveExport(baseDir, moduleName, exportName, handlerId, registry);
3336
+ const result = await tryResolveExport(baseDir, moduleName, exportName, handlerId, handlerType, registry);
1819
3337
  if (result) return result;
1820
3338
  }
1821
- return tryResolveExport(baseDir, handlerId, "default", handlerId, registry);
3339
+ return tryResolveExport(baseDir, handlerId, "default", handlerId, handlerType, registry);
1822
3340
  }
1823
3341
  __name(resolveHandlerByModuleRef, "resolveHandlerByModuleRef");
1824
- async function tryResolveExport(baseDir, moduleName, exportName, handlerId, registry) {
3342
+ async function tryResolveExport(baseDir, moduleName, exportName, handlerId, handlerType, registry) {
1825
3343
  const handlerModulePath = (0, import_node_path.resolve)(baseDir, moduleName);
1826
3344
  let mod;
1827
3345
  try {
@@ -1836,66 +3354,235 @@ async function tryResolveExport(baseDir, moduleName, exportName, handlerId, regi
1836
3354
  const exported = mod[exportName];
1837
3355
  if (!exported) return null;
1838
3356
  const isFnDef = typeof exported === "object" && exported !== null && exported.__celerity_handler;
3357
+ if (isFnDef && exported.type !== handlerType) {
3358
+ return null;
3359
+ }
1839
3360
  const handlerFn = isFnDef ? exported.handler : exported;
1840
3361
  if (typeof handlerFn !== "function") return null;
1841
- const match = registry.getAllHandlers().find((h) => h.handlerFn === handlerFn);
3362
+ const handlers = registry.getHandlersByType(handlerType);
3363
+ const match = handlers.find((h) => h.handlerFn === handlerFn);
1842
3364
  if (match) {
1843
3365
  match.id = handlerId;
1844
- debug9("matched '%s' to registry handler", handlerId);
3366
+ debug18("matched '%s' to registry handler", handlerId);
1845
3367
  return match;
1846
3368
  }
1847
- debug9("'%s' not in registry, wrapping directly", handlerId);
1848
- return buildResolvedFromExport(handlerId, handlerFn, isFnDef ? exported : null);
3369
+ debug18("'%s' not in registry, wrapping directly", handlerId);
3370
+ return buildResolvedFromExport(handlerId, handlerType, handlerFn, isFnDef ? exported : null);
1849
3371
  }
1850
3372
  __name(tryResolveExport, "tryResolveExport");
1851
- function buildResolvedFromExport(handlerId, handlerFn, fnDef) {
1852
- if (fnDef) {
1853
- const meta = fnDef.metadata;
1854
- return {
1855
- id: handlerId,
1856
- protectedBy: [],
1857
- layers: [
1858
- ...meta.layers ?? []
1859
- ],
1860
- isPublic: false,
1861
- paramMetadata: [],
1862
- customMetadata: meta.customMetadata ?? {},
1863
- handlerFn,
1864
- isFunctionHandler: true,
1865
- injectTokens: meta.inject ?? []
1866
- };
1867
- }
1868
- return {
3373
+ function buildResolvedFromExport(handlerId, handlerType, handlerFn, fnDef) {
3374
+ const meta = fnDef ? fnDef.metadata : null;
3375
+ const base = {
1869
3376
  id: handlerId,
1870
- protectedBy: [],
1871
- layers: [],
1872
- isPublic: false,
3377
+ layers: [
3378
+ ...meta?.layers ?? []
3379
+ ],
1873
3380
  paramMetadata: [],
1874
- customMetadata: {},
3381
+ customMetadata: meta?.customMetadata ?? {},
1875
3382
  handlerFn,
1876
3383
  isFunctionHandler: true,
1877
- injectTokens: []
3384
+ injectTokens: meta?.inject ?? []
1878
3385
  };
3386
+ const guardFields = {
3387
+ protectedBy: [],
3388
+ isPublic: false
3389
+ };
3390
+ switch (handlerType) {
3391
+ case "http":
3392
+ return {
3393
+ ...base,
3394
+ ...guardFields,
3395
+ type: "http",
3396
+ ...meta?.path !== void 0 ? {
3397
+ path: meta.path
3398
+ } : {},
3399
+ ...meta?.method !== void 0 ? {
3400
+ method: meta.method
3401
+ } : {}
3402
+ };
3403
+ case "websocket":
3404
+ return {
3405
+ ...base,
3406
+ ...guardFields,
3407
+ type: "websocket",
3408
+ route: meta?.route ?? handlerId
3409
+ };
3410
+ case "consumer":
3411
+ return {
3412
+ ...base,
3413
+ type: "consumer",
3414
+ handlerTag: meta?.route ?? handlerId
3415
+ };
3416
+ case "schedule":
3417
+ return {
3418
+ ...base,
3419
+ type: "schedule",
3420
+ handlerTag: meta?.scheduleId ?? handlerId
3421
+ };
3422
+ case "custom":
3423
+ return {
3424
+ ...base,
3425
+ type: "custom",
3426
+ name: meta?.name ?? handlerId
3427
+ };
3428
+ }
1879
3429
  }
1880
3430
  __name(buildResolvedFromExport, "buildResolvedFromExport");
1881
3431
 
3432
+ // src/handlers/websocket-sender.ts
3433
+ var RuntimeWebSocketSender = class {
3434
+ static {
3435
+ __name(this, "RuntimeWebSocketSender");
3436
+ }
3437
+ registry;
3438
+ constructor(registry) {
3439
+ this.registry = registry;
3440
+ }
3441
+ async sendMessage(connectionId, data, options) {
3442
+ const messageId = options?.messageId ?? crypto.randomUUID();
3443
+ const messageType = options?.messageType === "binary" ? "binary" : "json";
3444
+ const payload = typeof data === "string" ? data : JSON.stringify(data);
3445
+ await this.registry.sendMessage(connectionId, messageId, messageType, payload);
3446
+ }
3447
+ };
3448
+
3449
+ // src/handlers/guard-pipeline.ts
3450
+ var import_debug19 = __toESM(require("debug"), 1);
3451
+ var debug19 = (0, import_debug19.default)("celerity:core:guard-pipeline");
3452
+ async function executeGuardPipeline(guard, input, options) {
3453
+ const metadata = new HandlerMetadataStore({
3454
+ ...guard.customMetadata ?? {},
3455
+ ...options.handlerMetadata ?? {}
3456
+ });
3457
+ const logger = await createGuardLogger(guard.name, input, options.container);
3458
+ try {
3459
+ const result = guard.isFunctionGuard ? await invokeFunctionGuard(guard, input, metadata, options, logger) : await invokeClassGuard(guard, input, metadata, options, logger);
3460
+ debug19("guard %s \u2014 allowed", guard.name);
3461
+ return {
3462
+ allowed: true,
3463
+ auth: result ?? {}
3464
+ };
3465
+ } catch (error) {
3466
+ if (error instanceof HttpException) {
3467
+ debug19("guard %s \u2014 rejected %d: %s", guard.name, error.statusCode, error.message);
3468
+ return {
3469
+ allowed: false,
3470
+ statusCode: error.statusCode,
3471
+ message: error.message,
3472
+ details: error.details
3473
+ };
3474
+ }
3475
+ const message = error instanceof Error ? error.message : String(error);
3476
+ debug19("guard %s \u2014 unexpected error: %s", guard.name, message);
3477
+ return {
3478
+ allowed: false,
3479
+ statusCode: 401,
3480
+ message: "Unauthorized"
3481
+ };
3482
+ }
3483
+ }
3484
+ __name(executeGuardPipeline, "executeGuardPipeline");
3485
+ async function createGuardLogger(guardName, input, container) {
3486
+ const attrs = {
3487
+ guard: guardName,
3488
+ requestId: input.requestId,
3489
+ method: input.method,
3490
+ path: input.path,
3491
+ clientIp: input.clientIp,
3492
+ ...input.handlerName ? {
3493
+ handlerName: input.handlerName
3494
+ } : {}
3495
+ };
3496
+ if (container.has("CelerityLogger")) {
3497
+ const root = await container.resolve("CelerityLogger");
3498
+ return root.child("guard", attrs);
3499
+ }
3500
+ const pkg = "@celerity-sdk/telemetry";
3501
+ const { createLogger, readTelemetryEnv } = await import(pkg);
3502
+ const rootLogger = await createLogger(readTelemetryEnv());
3503
+ return rootLogger.child("guard", attrs);
3504
+ }
3505
+ __name(createGuardLogger, "createGuardLogger");
3506
+ async function invokeClassGuard(guard, input, metadata, options, logger) {
3507
+ const guardContext = {
3508
+ token: input.token,
3509
+ auth: input.auth,
3510
+ request: {
3511
+ method: input.method,
3512
+ path: input.path,
3513
+ headers: input.headers,
3514
+ query: input.query,
3515
+ cookies: input.cookies,
3516
+ body: input.body,
3517
+ requestId: input.requestId,
3518
+ clientIp: input.clientIp
3519
+ },
3520
+ metadata,
3521
+ container: options.container,
3522
+ logger
3523
+ };
3524
+ const paramCount = guard.handlerFn.length;
3525
+ const args = new Array(paramCount);
3526
+ const decorated = new Set(guard.paramMetadata.map((m) => m.index));
3527
+ for (const meta of guard.paramMetadata) {
3528
+ if (meta.type === "token") {
3529
+ args[meta.index] = guardContext.token;
3530
+ } else if (meta.type === "auth") {
3531
+ args[meta.index] = guardContext.auth;
3532
+ }
3533
+ }
3534
+ for (let i = 0; i < paramCount; i++) {
3535
+ if (!decorated.has(i)) {
3536
+ args[i] = guardContext;
3537
+ }
3538
+ }
3539
+ return guard.handlerFn.apply(guard.handlerInstance, args);
3540
+ }
3541
+ __name(invokeClassGuard, "invokeClassGuard");
3542
+ async function invokeFunctionGuard(guard, input, metadata, options, logger) {
3543
+ const req = {
3544
+ token: input.token,
3545
+ headers: input.headers,
3546
+ query: input.query,
3547
+ cookies: input.cookies,
3548
+ body: input.body,
3549
+ requestId: input.requestId,
3550
+ clientIp: input.clientIp
3551
+ };
3552
+ const ctx = {
3553
+ metadata,
3554
+ container: options.container,
3555
+ auth: input.auth,
3556
+ logger
3557
+ };
3558
+ if (guard.injectTokens && guard.injectTokens.length > 0) {
3559
+ const deps = [];
3560
+ for (const token of guard.injectTokens) {
3561
+ deps.push(await options.container.resolve(token));
3562
+ }
3563
+ return guard.handlerFn(req, ctx, ...deps);
3564
+ }
3565
+ return guard.handlerFn(req, ctx);
3566
+ }
3567
+ __name(invokeFunctionGuard, "invokeFunctionGuard");
3568
+
1882
3569
  // src/bootstrap/discovery.ts
1883
3570
  var import_node_path2 = require("path");
1884
- var import_debug10 = __toESM(require("debug"), 1);
1885
- var debug10 = (0, import_debug10.default)("celerity:core:bootstrap");
3571
+ var import_debug20 = __toESM(require("debug"), 1);
3572
+ var debug20 = (0, import_debug20.default)("celerity:core:bootstrap");
1886
3573
  async function discoverModule(modulePath) {
1887
3574
  const resolved = modulePath ?? process.env.CELERITY_MODULE_PATH;
1888
3575
  if (!resolved) {
1889
3576
  throw new Error("Cannot discover module: set CELERITY_MODULE_PATH environment variable or pass modulePath");
1890
3577
  }
1891
3578
  const absolutePath = (0, import_node_path2.resolve)(resolved);
1892
- debug10("discoverModule: importing %s", absolutePath);
3579
+ debug20("discoverModule: importing %s", absolutePath);
1893
3580
  const imported = await import(absolutePath);
1894
3581
  const rootModule = imported.default ?? findModuleExport(imported);
1895
3582
  if (!rootModule || typeof rootModule !== "function") {
1896
3583
  throw new Error(`No module class found in "${resolved}"`);
1897
3584
  }
1898
- debug10("discoverModule: found %s", rootModule.name);
3585
+ debug20("discoverModule: found %s", rootModule.name);
1899
3586
  return rootModule;
1900
3587
  }
1901
3588
  __name(discoverModule, "discoverModule");
@@ -1949,61 +3636,350 @@ function mapToRuntimeResponse(response) {
1949
3636
  };
1950
3637
  }
1951
3638
  __name(mapToRuntimeResponse, "mapToRuntimeResponse");
3639
+ function mapWebSocketMessage(info) {
3640
+ const requestContext = info.requestContext ? {
3641
+ requestId: info.requestContext.requestId,
3642
+ requestTime: info.requestContext.requestTime,
3643
+ path: info.requestContext.path,
3644
+ protocolVersion: info.requestContext.protocolVersion,
3645
+ headers: flattenMultiValueRecord(info.requestContext.headers),
3646
+ userAgent: info.requestContext.userAgent,
3647
+ clientIp: info.requestContext.clientIp,
3648
+ query: flattenMultiValueRecord(info.requestContext.query),
3649
+ cookies: info.requestContext.cookies,
3650
+ auth: info.requestContext.auth,
3651
+ traceContext: info.requestContext.traceContext
3652
+ } : void 0;
3653
+ return {
3654
+ messageType: info.messageType,
3655
+ eventType: info.eventType,
3656
+ connectionId: info.connectionId,
3657
+ messageId: info.messageId,
3658
+ jsonBody: info.jsonBody,
3659
+ binaryBody: info.binaryBody,
3660
+ requestContext,
3661
+ traceContext: info.traceContext ?? null
3662
+ };
3663
+ }
3664
+ __name(mapWebSocketMessage, "mapWebSocketMessage");
3665
+ function mapConsumerEventInput(input) {
3666
+ return {
3667
+ handlerTag: input.handlerTag,
3668
+ messages: input.messages.map((msg) => {
3669
+ const m = msg;
3670
+ return {
3671
+ messageId: msg.messageId,
3672
+ body: msg.body,
3673
+ source: msg.source,
3674
+ ...m.sourceType !== void 0 && {
3675
+ sourceType: m.sourceType
3676
+ },
3677
+ ...m.sourceName !== void 0 && {
3678
+ sourceName: m.sourceName
3679
+ },
3680
+ ...m.eventType !== void 0 && {
3681
+ eventType: m.eventType
3682
+ },
3683
+ messageAttributes: msg.messageAttributes,
3684
+ vendor: msg.vendor
3685
+ };
3686
+ }),
3687
+ vendor: input.vendor,
3688
+ traceContext: input.traceContext ?? null
3689
+ };
3690
+ }
3691
+ __name(mapConsumerEventInput, "mapConsumerEventInput");
3692
+ function mapScheduleEventInput(input) {
3693
+ return {
3694
+ handlerTag: input.handlerTag,
3695
+ scheduleId: input.scheduleId,
3696
+ messageId: input.messageId,
3697
+ schedule: input.schedule,
3698
+ input: input.input,
3699
+ vendor: input.vendor,
3700
+ traceContext: input.traceContext ?? null
3701
+ };
3702
+ }
3703
+ __name(mapScheduleEventInput, "mapScheduleEventInput");
3704
+ function mapToNapiEventResult(result) {
3705
+ return {
3706
+ success: result.success,
3707
+ failures: result.failures?.map((f) => ({
3708
+ messageId: f.messageId,
3709
+ errorMessage: f.errorMessage
3710
+ })),
3711
+ errorMessage: result.errorMessage
3712
+ };
3713
+ }
3714
+ __name(mapToNapiEventResult, "mapToNapiEventResult");
1952
3715
 
1953
3716
  // src/bootstrap/runtime-entry.ts
1954
3717
  var import_node_path3 = require("path");
3718
+ var import_debug21 = __toESM(require("debug"), 1);
3719
+ var debug21 = (0, import_debug21.default)("celerity:core:runtime-entry");
1955
3720
  async function bootstrapForRuntime(modulePath, systemLayers) {
1956
3721
  const layers = systemLayers ?? await createDefaultSystemLayers();
1957
3722
  const resolvedModulePath = modulePath ?? process.env.CELERITY_MODULE_PATH;
1958
3723
  const moduleDir = resolvedModulePath ? (0, import_node_path3.dirname)((0, import_node_path3.resolve)(resolvedModulePath)) : process.cwd();
1959
3724
  const rootModule = await discoverModule(modulePath);
1960
3725
  const { container, registry } = await bootstrap(rootModule);
1961
- function buildCallback(handler) {
3726
+ function buildHttpCallback(handler, handlerName) {
1962
3727
  if (!handler) return null;
1963
3728
  return async (_err, request) => {
1964
3729
  const httpRequest = mapRuntimeRequest(request);
1965
- const httpResponse = await executeHandlerPipeline(handler, httpRequest, {
3730
+ const httpResponse = await executeHttpPipeline(handler, httpRequest, {
1966
3731
  container,
1967
- systemLayers: layers
3732
+ systemLayers: layers,
3733
+ handlerName
1968
3734
  });
1969
3735
  return mapToRuntimeResponse(httpResponse);
1970
3736
  };
1971
3737
  }
1972
- __name(buildCallback, "buildCallback");
3738
+ __name(buildHttpCallback, "buildHttpCallback");
3739
+ function buildWebSocketCallback(handler, handlerName) {
3740
+ if (!handler) return null;
3741
+ return async (_err, info) => {
3742
+ const message = mapWebSocketMessage(info);
3743
+ await executeWebSocketPipeline(handler, message, {
3744
+ container,
3745
+ systemLayers: layers,
3746
+ handlerName
3747
+ });
3748
+ };
3749
+ }
3750
+ __name(buildWebSocketCallback, "buildWebSocketCallback");
3751
+ function buildConsumerCallback(handler, handlerName) {
3752
+ if (!handler) return null;
3753
+ return async (_err, input) => {
3754
+ const event = mapConsumerEventInput(input);
3755
+ const result = await executeConsumerPipeline(handler, event, {
3756
+ container,
3757
+ systemLayers: layers,
3758
+ handlerName
3759
+ });
3760
+ return mapToNapiEventResult(result);
3761
+ };
3762
+ }
3763
+ __name(buildConsumerCallback, "buildConsumerCallback");
3764
+ function buildScheduleCallback(handler, handlerName) {
3765
+ if (!handler) return null;
3766
+ return async (_err, input) => {
3767
+ const event = mapScheduleEventInput(input);
3768
+ const result = await executeSchedulePipeline(handler, event, {
3769
+ container,
3770
+ systemLayers: layers,
3771
+ handlerName
3772
+ });
3773
+ return mapToNapiEventResult(result);
3774
+ };
3775
+ }
3776
+ __name(buildScheduleCallback, "buildScheduleCallback");
3777
+ function buildCustomCallback(handler, handlerName) {
3778
+ if (!handler) return null;
3779
+ return async (_err, payload) => {
3780
+ return executeCustomPipeline(handler, payload, {
3781
+ container,
3782
+ systemLayers: layers,
3783
+ handlerName
3784
+ });
3785
+ };
3786
+ }
3787
+ __name(buildCustomCallback, "buildCustomCallback");
1973
3788
  return {
1974
3789
  registry,
1975
3790
  container,
1976
- createRouteCallback(path, method) {
1977
- return buildCallback(registry.getHandler(path, method));
3791
+ createRouteCallback(method, path, handlerName) {
3792
+ return buildHttpCallback(registry.getHandler("http", `${method} ${path}`), handlerName);
1978
3793
  },
1979
- async createRouteCallbackById(handlerId, codeLocation) {
1980
- const fromRegistry = registry.getHandlerById(handlerId);
1981
- if (fromRegistry) return buildCallback(fromRegistry);
3794
+ async createRouteCallbackById(handlerId, codeLocation, handlerName) {
3795
+ const fromRegistry = registry.getHandlerById("http", handlerId);
3796
+ if (fromRegistry) return buildHttpCallback(fromRegistry, handlerName);
1982
3797
  const baseDir = codeLocation ? (0, import_node_path3.resolve)(codeLocation) : moduleDir;
1983
- const resolved = await resolveHandlerByModuleRef(handlerId, registry, baseDir);
1984
- return resolved ? buildCallback(resolved) : null;
3798
+ const resolved = await resolveHandlerByModuleRef(handlerId, "http", registry, baseDir);
3799
+ return resolved ? buildHttpCallback(resolved, handlerName) : null;
3800
+ },
3801
+ createGuardCallback(guardName) {
3802
+ const guard = registry.getGuard(guardName);
3803
+ if (!guard) return null;
3804
+ return async (input) => {
3805
+ debug21("guard %s \u2014 input method=%s path=%s", guardName, input.method, input.path);
3806
+ const handler = registry.getHandler("http", `${input.method} ${input.path}`);
3807
+ debug21("guard %s \u2014 handler %s, customMetadata=%o", guardName, handler ? "found" : "not found", handler?.customMetadata);
3808
+ return executeGuardPipeline(guard, input, {
3809
+ container,
3810
+ handlerMetadata: handler?.customMetadata
3811
+ });
3812
+ };
3813
+ },
3814
+ createWebSocketCallback(route, handlerName) {
3815
+ return buildWebSocketCallback(registry.getHandler("websocket", route), handlerName);
3816
+ },
3817
+ async createWebSocketCallbackById(handlerId, codeLocation, handlerName) {
3818
+ const fromRegistry = registry.getHandlerById("websocket", handlerId);
3819
+ if (fromRegistry) return buildWebSocketCallback(fromRegistry, handlerName);
3820
+ const baseDir = codeLocation ? (0, import_node_path3.resolve)(codeLocation) : moduleDir;
3821
+ const resolved = await resolveHandlerByModuleRef(handlerId, "websocket", registry, baseDir);
3822
+ return resolved ? buildWebSocketCallback(resolved, handlerName) : null;
3823
+ },
3824
+ createConsumerCallback(handlerTag, handlerName) {
3825
+ return buildConsumerCallback(registry.getHandler("consumer", handlerTag), handlerName);
3826
+ },
3827
+ async createConsumerCallbackById(handlerId, codeLocation, handlerName) {
3828
+ const fromRegistry = registry.getHandlerById("consumer", handlerId);
3829
+ if (fromRegistry) return buildConsumerCallback(fromRegistry, handlerName);
3830
+ const baseDir = codeLocation ? (0, import_node_path3.resolve)(codeLocation) : moduleDir;
3831
+ const resolved = await resolveHandlerByModuleRef(handlerId, "consumer", registry, baseDir);
3832
+ return resolved ? buildConsumerCallback(resolved, handlerName) : null;
3833
+ },
3834
+ createScheduleCallback(handlerTag, handlerName) {
3835
+ return buildScheduleCallback(registry.getHandler("schedule", handlerTag), handlerName);
3836
+ },
3837
+ async createScheduleCallbackById(handlerId, codeLocation, handlerName) {
3838
+ const fromRegistry = registry.getHandlerById("schedule", handlerId);
3839
+ if (fromRegistry) return buildScheduleCallback(fromRegistry, handlerName);
3840
+ const baseDir = codeLocation ? (0, import_node_path3.resolve)(codeLocation) : moduleDir;
3841
+ const resolved = await resolveHandlerByModuleRef(handlerId, "schedule", registry, baseDir);
3842
+ return resolved ? buildScheduleCallback(resolved, handlerName) : null;
3843
+ },
3844
+ createCustomCallback(handlerName) {
3845
+ return buildCustomCallback(registry.getHandler("custom", handlerName), handlerName);
3846
+ },
3847
+ async createCustomCallbackById(handlerId, codeLocation, handlerName) {
3848
+ const fromRegistry = registry.getHandlerById("custom", handlerId);
3849
+ if (fromRegistry) return buildCustomCallback(fromRegistry, handlerName);
3850
+ const baseDir = codeLocation ? (0, import_node_path3.resolve)(codeLocation) : moduleDir;
3851
+ const resolved = await resolveHandlerByModuleRef(handlerId, "custom", registry, baseDir);
3852
+ return resolved ? buildCustomCallback(resolved, handlerName) : null;
1985
3853
  }
1986
3854
  };
1987
3855
  }
1988
3856
  __name(bootstrapForRuntime, "bootstrapForRuntime");
1989
3857
 
1990
3858
  // src/bootstrap/runtime-orchestrator.ts
1991
- async function startRuntime(options) {
3859
+ var import_types = require("@celerity-sdk/types");
3860
+ async function loadRuntime() {
1992
3861
  const pkg = "@celerity-sdk/runtime";
1993
3862
  const runtimeModule = await import(pkg);
1994
3863
  const config = runtimeModule.runtimeConfigFromEnv();
1995
3864
  const app = new runtimeModule.CoreRuntimeApplication(config);
1996
3865
  const appConfig = app.setup();
1997
- const result = await bootstrapForRuntime();
1998
- for (const def of appConfig.api?.http?.handlers ?? []) {
1999
- const callback = result.createRouteCallback(def.path, def.method) ?? await result.createRouteCallbackById(def.handler, def.location);
3866
+ return {
3867
+ app,
3868
+ appConfig
3869
+ };
3870
+ }
3871
+ __name(loadRuntime, "loadRuntime");
3872
+ function mapGuardResult(result) {
3873
+ if (result.allowed) {
3874
+ return {
3875
+ status: "allowed",
3876
+ auth: result.auth
3877
+ };
3878
+ }
3879
+ const status = result.statusCode === 403 ? "forbidden" : "unauthorised";
3880
+ return {
3881
+ status,
3882
+ message: result.message
3883
+ };
3884
+ }
3885
+ __name(mapGuardResult, "mapGuardResult");
3886
+ async function registerHttpHandlers(app, handlers, result) {
3887
+ for (const def of handlers?.http?.handlers ?? []) {
3888
+ const callback = result.createRouteCallback(def.method, def.path, def.name) ?? await result.createRouteCallbackById(def.handler, def.location, def.name);
2000
3889
  if (callback) {
2001
3890
  app.registerHttpHandler(def.path, def.method, def.timeout, callback);
2002
3891
  }
2003
3892
  }
3893
+ }
3894
+ __name(registerHttpHandlers, "registerHttpHandlers");
3895
+ async function registerGuardHandlers(app, guards, result) {
3896
+ for (const guardDef of guards?.handlers ?? []) {
3897
+ const coreCallback = result.createGuardCallback(guardDef.name);
3898
+ if (coreCallback) {
3899
+ await app.registerGuardHandler(guardDef.name, async (_err, input) => {
3900
+ const coreResult = await coreCallback({
3901
+ token: input.token,
3902
+ method: input.request.method,
3903
+ path: input.request.path,
3904
+ headers: input.request.headers,
3905
+ query: input.request.query,
3906
+ cookies: input.request.cookies,
3907
+ body: input.request.body ?? null,
3908
+ requestId: input.request.requestId,
3909
+ clientIp: input.request.clientIp,
3910
+ auth: input.auth ?? {},
3911
+ handlerName: input.handlerName
3912
+ });
3913
+ return mapGuardResult(coreResult);
3914
+ });
3915
+ }
3916
+ }
3917
+ }
3918
+ __name(registerGuardHandlers, "registerGuardHandlers");
3919
+ async function registerWebSocketHandlers(app, websocket, result) {
3920
+ for (const def of websocket?.handlers ?? []) {
3921
+ const callback = result.createWebSocketCallback(def.route, def.name) ?? await result.createWebSocketCallbackById(def.handler, def.location, def.name);
3922
+ if (callback) {
3923
+ app.registerWebsocketHandler(def.route, callback);
3924
+ }
3925
+ }
3926
+ }
3927
+ __name(registerWebSocketHandlers, "registerWebSocketHandlers");
3928
+ async function registerConsumerHandlers(app, consumers, result) {
3929
+ for (const consumer of consumers?.consumers ?? []) {
3930
+ for (const def of consumer.handlers) {
3931
+ const tag = `source::${consumer.sourceId}::${def.name}`;
3932
+ const callback = result.createConsumerCallback(tag, def.name) ?? await result.createConsumerCallbackById(def.handler, def.location, def.name);
3933
+ if (callback) {
3934
+ app.registerConsumerHandler(tag, def.timeout, callback);
3935
+ }
3936
+ }
3937
+ }
3938
+ }
3939
+ __name(registerConsumerHandlers, "registerConsumerHandlers");
3940
+ async function registerScheduleHandlers(app, schedules, result) {
3941
+ for (const schedule of schedules?.schedules ?? []) {
3942
+ for (const def of schedule.handlers) {
3943
+ const tag = `source::${schedule.scheduleId}::${def.name}`;
3944
+ const callback = result.createScheduleCallback(tag, def.name) ?? await result.createScheduleCallbackById(def.handler, def.location, def.name);
3945
+ if (callback) {
3946
+ app.registerScheduleHandler(tag, def.timeout, callback);
3947
+ }
3948
+ }
3949
+ }
3950
+ }
3951
+ __name(registerScheduleHandlers, "registerScheduleHandlers");
3952
+ async function registerCustomHandlers(app, customHandlers, result) {
3953
+ for (const def of customHandlers?.handlers ?? []) {
3954
+ const callback = result.createCustomCallback(def.name) ?? await result.createCustomCallbackById(def.handler, def.location, def.name);
3955
+ if (callback) {
3956
+ app.registerCustomHandler(def.name, def.timeout, callback);
3957
+ }
3958
+ }
3959
+ }
3960
+ __name(registerCustomHandlers, "registerCustomHandlers");
3961
+ async function startRuntime(options) {
3962
+ const { app, appConfig } = await loadRuntime();
3963
+ const result = await bootstrapForRuntime();
3964
+ await registerHttpHandlers(app, appConfig.api, result);
3965
+ await registerGuardHandlers(app, appConfig.api?.guards, result);
3966
+ await registerWebSocketHandlers(app, appConfig.api?.websocket, result);
3967
+ await registerConsumerHandlers(app, appConfig.consumers, result);
3968
+ await registerScheduleHandlers(app, appConfig.schedules, result);
3969
+ await registerCustomHandlers(app, appConfig.customHandlers, result);
3970
+ if (appConfig.api?.websocket) {
3971
+ const sender = new RuntimeWebSocketSender(app.websocketRegistry());
3972
+ result.container.register(import_types.WebSocketSender, {
3973
+ useValue: sender
3974
+ });
3975
+ }
2004
3976
  await app.run(options?.block ?? true);
2005
3977
  }
2006
3978
  __name(startRuntime, "startRuntime");
3979
+
3980
+ // src/index.ts
3981
+ var import_types2 = require("@celerity-sdk/types");
3982
+ var import_types3 = require("@celerity-sdk/types");
2007
3983
  // Annotate the CommonJS export names for ESM import in node:
2008
3984
  0 && (module.exports = {
2009
3985
  APP_CONFIG,
@@ -2012,15 +3988,24 @@ __name(startRuntime, "startRuntime");
2012
3988
  BadGatewayException,
2013
3989
  BadRequestException,
2014
3990
  Body,
3991
+ BucketEventType,
3992
+ CONSUMER_HANDLER_METADATA,
3993
+ CONSUMER_METADATA,
2015
3994
  CONTROLLER_METADATA,
2016
3995
  CUSTOM_METADATA,
2017
3996
  CelerityApplication,
2018
3997
  CelerityFactory,
2019
3998
  ConflictException,
3999
+ ConnectionId,
4000
+ Consumer,
4001
+ ConsumerTraceContext,
2020
4002
  Container,
2021
4003
  Controller,
2022
4004
  Cookies,
4005
+ DatastoreEventType,
2023
4006
  Delete,
4007
+ EventInput,
4008
+ EventType,
2024
4009
  ForbiddenException,
2025
4010
  GUARD_CUSTOM_METADATA,
2026
4011
  GUARD_PROTECTEDBY_METADATA,
@@ -2035,20 +4020,31 @@ __name(startRuntime, "startRuntime");
2035
4020
  Headers,
2036
4021
  HttpException,
2037
4022
  INJECT_METADATA,
4023
+ INVOKE_METADATA,
2038
4024
  Inject,
2039
4025
  Injectable,
2040
4026
  InternalServerErrorException,
4027
+ Invoke,
4028
+ InvokeContext,
2041
4029
  LAYER_METADATA,
2042
4030
  MODULE_METADATA,
4031
+ MessageBody,
4032
+ MessageHandler,
4033
+ MessageId,
4034
+ Messages,
2043
4035
  MethodNotAllowedException,
2044
4036
  Module,
2045
4037
  NotAcceptableException,
2046
4038
  NotFoundException,
2047
4039
  NotImplementedException,
4040
+ OnConnect,
4041
+ OnDisconnect,
4042
+ OnMessage,
2048
4043
  Options,
2049
4044
  PUBLIC_METADATA,
2050
4045
  Param,
2051
4046
  Patch,
4047
+ Payload,
2052
4048
  Post,
2053
4049
  ProtectedBy,
2054
4050
  Public,
@@ -2057,24 +4053,52 @@ __name(startRuntime, "startRuntime");
2057
4053
  ROUTE_PATH_METADATA,
2058
4054
  RUNTIME_APP,
2059
4055
  Req,
4056
+ RequestContext,
2060
4057
  RequestId,
4058
+ RuntimeWebSocketSender,
4059
+ SCHEDULE_HANDLER_METADATA,
4060
+ ScheduleEventInputParam,
4061
+ ScheduleExpression,
4062
+ ScheduleHandler,
4063
+ ScheduleId,
4064
+ ScheduleInput,
2061
4065
  ServerlessApplication,
2062
4066
  ServiceUnavailableException,
2063
4067
  SetMetadata,
4068
+ SourceType,
2064
4069
  TestingApplication,
4070
+ Token,
2065
4071
  TooManyRequestsException,
4072
+ USE_RESOURCE_METADATA,
2066
4073
  UnauthorizedException,
2067
4074
  UnprocessableEntityException,
2068
4075
  UseLayer,
2069
4076
  UseLayers,
4077
+ UseResource,
4078
+ UseResources,
4079
+ Vendor,
4080
+ WEBSOCKET_CONTROLLER_METADATA,
4081
+ WEBSOCKET_EVENT_METADATA,
4082
+ WebSocketController,
4083
+ WebSocketSender,
2070
4084
  bootstrap,
2071
4085
  bootstrapForRuntime,
2072
4086
  buildModuleGraph,
4087
+ createConsumerHandler,
4088
+ createCustomHandler,
2073
4089
  createDefaultSystemLayers,
4090
+ createGuard,
2074
4091
  createHttpHandler,
4092
+ createScheduleHandler,
4093
+ createWebSocketHandler,
2075
4094
  discoverModule,
2076
4095
  disposeLayers,
2077
- executeHandlerPipeline,
4096
+ executeConsumerPipeline,
4097
+ executeCustomPipeline,
4098
+ executeGuardPipeline,
4099
+ executeHttpPipeline,
4100
+ executeSchedulePipeline,
4101
+ executeWebSocketPipeline,
2078
4102
  flattenMultiValueRecord,
2079
4103
  getClassDependencyTokens,
2080
4104
  getProviderDependencyTokens,
@@ -2083,12 +4107,27 @@ __name(startRuntime, "startRuntime");
2083
4107
  httpPatch,
2084
4108
  httpPost,
2085
4109
  httpPut,
4110
+ mapConsumerEventInput,
2086
4111
  mapRuntimeRequest,
4112
+ mapScheduleEventInput,
4113
+ mapToNapiEventResult,
2087
4114
  mapToRuntimeResponse,
4115
+ mapWebSocketMessage,
4116
+ mockConsumerEvent,
2088
4117
  mockRequest,
4118
+ mockScheduleEvent,
4119
+ mockWebSocketMessage,
2089
4120
  registerModuleGraph,
2090
4121
  resolveHandlerByModuleRef,
4122
+ routingKeyOf,
2091
4123
  runLayerPipeline,
4124
+ scanConsumerHandlers,
4125
+ scanCustomHandlers,
4126
+ scanHttpGuards,
4127
+ scanHttpHandlers,
4128
+ scanModule,
4129
+ scanScheduleHandlers,
4130
+ scanWebSocketHandlers,
2092
4131
  startRuntime,
2093
4132
  tokenToString,
2094
4133
  validate