@celerity-sdk/cli 0.3.0 → 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.js CHANGED
@@ -30,10 +30,12 @@ function buildScannedModule(rootModule) {
30
30
  const graph = buildModuleGraph(rootModule);
31
31
  const controllerClasses = [];
32
32
  const functionHandlers = [];
33
+ const guardClasses = [];
34
+ const functionGuards = [];
33
35
  const providers = [];
34
36
  const seenTokens = /* @__PURE__ */ new Set();
35
37
  for (const [moduleClass, node] of graph) {
36
- debug("scan: module %s \u2014 %d providers, %d controllers", moduleClass.name, node.providers.length, node.controllers.length);
38
+ debug("scan: module %s \u2014 %d providers, %d controllers, %d guards", moduleClass.name, node.providers.length, node.controllers.length, node.guards.length);
37
39
  for (const provider of node.providers) {
38
40
  const scanned = scanProvider(provider, seenTokens);
39
41
  if (scanned) providers.push(scanned);
@@ -49,11 +51,28 @@ function buildScannedModule(rootModule) {
49
51
  });
50
52
  }
51
53
  }
54
+ for (const guard of node.guards) {
55
+ if (typeof guard === "function") {
56
+ guardClasses.push(guard);
57
+ if (!seenTokens.has(guard)) {
58
+ seenTokens.add(guard);
59
+ providers.push({
60
+ token: guard,
61
+ providerType: "class",
62
+ dependencies: getClassDependencyTokens(guard)
63
+ });
64
+ }
65
+ } else {
66
+ functionGuards.push(guard);
67
+ }
68
+ }
52
69
  functionHandlers.push(...node.functionHandlers);
53
70
  }
54
71
  return {
55
72
  controllerClasses,
56
73
  functionHandlers,
74
+ guardClasses,
75
+ functionGuards,
57
76
  providers
58
77
  };
59
78
  }
@@ -97,7 +116,7 @@ __name(serializeToken, "serializeToken");
97
116
 
98
117
  // src/extract/serializer.ts
99
118
  import "reflect-metadata";
100
- import { CONTROLLER_METADATA, HTTP_METHOD_METADATA, ROUTE_PATH_METADATA, GUARD_PROTECTEDBY_METADATA, GUARD_CUSTOM_METADATA, PUBLIC_METADATA, CUSTOM_METADATA } from "@celerity-sdk/core";
119
+ import { CONTROLLER_METADATA, HTTP_METHOD_METADATA, ROUTE_PATH_METADATA, WEBSOCKET_CONTROLLER_METADATA, WEBSOCKET_EVENT_METADATA, CONSUMER_METADATA, CONSUMER_HANDLER_METADATA, SCHEDULE_HANDLER_METADATA, INVOKE_METADATA, GUARD_PROTECTEDBY_METADATA, GUARD_CUSTOM_METADATA, PUBLIC_METADATA, CUSTOM_METADATA, USE_RESOURCE_METADATA } from "@celerity-sdk/core";
101
120
 
102
121
  // src/extract/path-utils.ts
103
122
  import { joinHandlerPath } from "@celerity-sdk/common";
@@ -138,8 +157,9 @@ __name(deriveCodeLocation, "deriveCodeLocation");
138
157
  function serializeManifest(scanned, sourceFile, options) {
139
158
  const handlers = [];
140
159
  const functionHandlers = [];
160
+ const guardHandlers = [];
141
161
  for (const controllerClass of scanned.controllerClasses) {
142
- const entries = serializeClassHandler(controllerClass, sourceFile, options);
162
+ const entries = serializeClassHandlers(controllerClass, sourceFile, options);
143
163
  handlers.push(...entries);
144
164
  }
145
165
  for (const fnHandler of scanned.functionHandlers) {
@@ -148,40 +168,76 @@ function serializeManifest(scanned, sourceFile, options) {
148
168
  functionHandlers.push(entry);
149
169
  }
150
170
  }
171
+ for (const guardClass of scanned.guardClasses) {
172
+ const entry = serializeClassGuard(guardClass, sourceFile, options);
173
+ if (entry) {
174
+ guardHandlers.push(entry);
175
+ }
176
+ }
177
+ for (const fnGuard of scanned.functionGuards) {
178
+ const entry = serializeFunctionGuard(fnGuard, sourceFile, options);
179
+ if (entry) {
180
+ guardHandlers.push(entry);
181
+ }
182
+ }
151
183
  return {
152
184
  version: "1.0.0",
153
185
  handlers,
154
186
  functionHandlers,
187
+ guardHandlers,
155
188
  dependencyGraph: serializeDependencyGraph(scanned)
156
189
  };
157
190
  }
158
191
  __name(serializeManifest, "serializeManifest");
159
- function extractClassMeta(controllerClass) {
160
- const controllerMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
161
- if (!controllerMeta) return null;
192
+ function extractControllerMeta(controllerClass) {
193
+ const httpMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
194
+ if (httpMeta) {
195
+ return {
196
+ controllerType: "http",
197
+ prefix: httpMeta.prefix ?? "",
198
+ ...extractSharedClassMeta(controllerClass)
199
+ };
200
+ }
201
+ const isWebSocket = Reflect.getOwnMetadata(WEBSOCKET_CONTROLLER_METADATA, controllerClass);
202
+ if (isWebSocket) {
203
+ return {
204
+ controllerType: "websocket",
205
+ prefix: "",
206
+ ...extractSharedClassMeta(controllerClass)
207
+ };
208
+ }
209
+ const consumerMeta = Reflect.getOwnMetadata(CONSUMER_METADATA, controllerClass);
210
+ if (consumerMeta) {
211
+ return {
212
+ controllerType: "consumer",
213
+ prefix: "",
214
+ sourceId: consumerMeta.sourceId,
215
+ ...extractSharedClassMeta(controllerClass)
216
+ };
217
+ }
218
+ return null;
219
+ }
220
+ __name(extractControllerMeta, "extractControllerMeta");
221
+ function extractSharedClassMeta(controllerClass) {
162
222
  return {
163
- prefix: controllerMeta.prefix ?? "",
164
223
  protectedBy: Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, controllerClass) ?? [],
165
224
  customGuardName: Reflect.getOwnMetadata(GUARD_CUSTOM_METADATA, controllerClass),
166
- customMetadata: Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {}
225
+ customMetadata: Reflect.getOwnMetadata(CUSTOM_METADATA, controllerClass) ?? {},
226
+ resourceRefs: Reflect.getOwnMetadata(USE_RESOURCE_METADATA, controllerClass) ?? []
167
227
  };
168
228
  }
169
- __name(extractClassMeta, "extractClassMeta");
170
- function buildMethodAnnotations(classMeta, prototype, methodName, httpMethod, fullPath) {
171
- const annotations = {};
172
- annotations["celerity.handler.http"] = true;
173
- annotations["celerity.handler.http.method"] = httpMethod;
174
- annotations["celerity.handler.http.path"] = fullPath;
229
+ __name(extractSharedClassMeta, "extractSharedClassMeta");
230
+ function appendSharedAnnotations(annotations, meta, prototype, methodName) {
175
231
  const methodProtectedBy = Reflect.getOwnMetadata(GUARD_PROTECTEDBY_METADATA, prototype, methodName) ?? [];
176
232
  const allProtectedBy = [
177
- ...classMeta.protectedBy,
233
+ ...meta.protectedBy,
178
234
  ...methodProtectedBy
179
235
  ];
180
236
  if (allProtectedBy.length > 0) {
181
237
  annotations["celerity.handler.guard.protectedBy"] = allProtectedBy;
182
238
  }
183
- if (classMeta.customGuardName) {
184
- annotations["celerity.handler.guard.custom"] = classMeta.customGuardName;
239
+ if (meta.customGuardName) {
240
+ annotations["celerity.handler.guard.custom"] = meta.customGuardName;
185
241
  }
186
242
  const isPublic = Reflect.getOwnMetadata(PUBLIC_METADATA, prototype, methodName) === true;
187
243
  if (isPublic) {
@@ -189,57 +245,206 @@ function buildMethodAnnotations(classMeta, prototype, methodName, httpMethod, fu
189
245
  }
190
246
  const methodCustomMetadata = Reflect.getOwnMetadata(CUSTOM_METADATA, prototype, methodName) ?? {};
191
247
  const customMetadata = {
192
- ...classMeta.customMetadata,
248
+ ...meta.customMetadata,
193
249
  ...methodCustomMetadata
194
250
  };
195
251
  for (const [key, value] of Object.entries(customMetadata)) {
196
252
  if (value === void 0) continue;
197
253
  annotations[`celerity.handler.metadata.${key}`] = serializeAnnotationValue(value);
198
254
  }
255
+ const methodResourceRefs = Reflect.getOwnMetadata(USE_RESOURCE_METADATA, prototype, methodName) ?? [];
256
+ const allResourceRefs = [
257
+ .../* @__PURE__ */ new Set([
258
+ ...meta.resourceRefs,
259
+ ...methodResourceRefs
260
+ ])
261
+ ];
262
+ if (allResourceRefs.length > 0) {
263
+ annotations["celerity.handler.resource.ref"] = allResourceRefs;
264
+ }
265
+ }
266
+ __name(appendSharedAnnotations, "appendSharedAnnotations");
267
+ function buildHttpAnnotations(meta, prototype, methodName, httpMethod, fullPath) {
268
+ const annotations = {};
269
+ annotations["celerity.handler.http"] = true;
270
+ annotations["celerity.handler.http.method"] = httpMethod;
271
+ annotations["celerity.handler.http.path"] = fullPath;
272
+ appendSharedAnnotations(annotations, meta, prototype, methodName);
273
+ return annotations;
274
+ }
275
+ __name(buildHttpAnnotations, "buildHttpAnnotations");
276
+ function buildWebSocketAnnotations(meta, prototype, methodName, wsEvent) {
277
+ const annotations = {};
278
+ annotations["celerity.handler.websocket"] = true;
279
+ annotations["celerity.handler.websocket.route"] = wsEvent.route;
280
+ annotations["celerity.handler.websocket.eventType"] = wsEvent.eventType;
281
+ appendSharedAnnotations(annotations, meta, prototype, methodName);
282
+ return annotations;
283
+ }
284
+ __name(buildWebSocketAnnotations, "buildWebSocketAnnotations");
285
+ function buildConsumerAnnotations(meta, prototype, methodName, consumerHandler) {
286
+ const annotations = {};
287
+ annotations["celerity.handler.consumer"] = true;
288
+ if (meta.sourceId) {
289
+ annotations["celerity.handler.consumer.sourceId"] = meta.sourceId;
290
+ }
291
+ if (consumerHandler.route) {
292
+ annotations["celerity.handler.consumer.route"] = consumerHandler.route;
293
+ }
294
+ appendSharedAnnotations(annotations, meta, prototype, methodName);
295
+ return annotations;
296
+ }
297
+ __name(buildConsumerAnnotations, "buildConsumerAnnotations");
298
+ function buildScheduleAnnotations(meta, prototype, methodName, scheduleMeta) {
299
+ const annotations = {};
300
+ annotations["celerity.handler.schedule"] = true;
301
+ if (scheduleMeta.scheduleId) {
302
+ annotations["celerity.handler.schedule.scheduleId"] = scheduleMeta.scheduleId;
303
+ }
304
+ if (scheduleMeta.schedule) {
305
+ annotations["celerity.handler.schedule.expression"] = scheduleMeta.schedule;
306
+ }
307
+ appendSharedAnnotations(annotations, meta, prototype, methodName);
308
+ return annotations;
309
+ }
310
+ __name(buildScheduleAnnotations, "buildScheduleAnnotations");
311
+ function buildCustomAnnotations(meta, prototype, methodName, invokeMeta) {
312
+ const annotations = {};
313
+ annotations["celerity.handler.custom"] = true;
314
+ annotations["celerity.handler.custom.name"] = invokeMeta.name;
315
+ appendSharedAnnotations(annotations, meta, prototype, methodName);
199
316
  return annotations;
200
317
  }
201
- __name(buildMethodAnnotations, "buildMethodAnnotations");
202
- function serializeClassHandler(controllerClass, sourceFile, options) {
203
- const classMeta = extractClassMeta(controllerClass);
204
- if (!classMeta) return [];
318
+ __name(buildCustomAnnotations, "buildCustomAnnotations");
319
+ function serializeClassHandlers(controllerClass, sourceFile, options) {
320
+ const meta = extractControllerMeta(controllerClass);
321
+ if (!meta) return [];
205
322
  const className = controllerClass.name;
206
323
  const prototype = controllerClass.prototype;
207
324
  const methods = Object.getOwnPropertyNames(prototype).filter((n) => n !== "constructor");
208
325
  const entries = [];
209
326
  for (const methodName of methods) {
210
- const httpMethod = Reflect.getOwnMetadata(HTTP_METHOD_METADATA, prototype, methodName);
211
- if (!httpMethod) continue;
212
- const routePath = Reflect.getOwnMetadata(ROUTE_PATH_METADATA, prototype, methodName) ?? "/";
213
- const fullPath = joinHandlerPath(classMeta.prefix, routePath);
214
- const annotations = buildMethodAnnotations(classMeta, prototype, methodName, httpMethod, fullPath);
215
- entries.push({
216
- resourceName: deriveClassResourceName(className, methodName),
217
- className,
218
- methodName,
219
- sourceFile,
220
- handlerType: "http",
221
- annotations,
222
- spec: {
223
- handlerName: deriveClassHandlerName(className, methodName),
224
- codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
225
- handler: deriveClassHandlerFunction(sourceFile, className, methodName)
226
- }
227
- });
327
+ const typeEntry = serializeControllerTypeMethod(meta, className, prototype, methodName, sourceFile, options);
328
+ if (typeEntry) entries.push(typeEntry);
329
+ const scheduleMeta = Reflect.getOwnMetadata(SCHEDULE_HANDLER_METADATA, prototype, methodName);
330
+ if (scheduleMeta) {
331
+ entries.push({
332
+ resourceName: deriveClassResourceName(className, methodName),
333
+ className,
334
+ methodName,
335
+ sourceFile,
336
+ handlerType: "schedule",
337
+ annotations: buildScheduleAnnotations(meta, prototype, methodName, scheduleMeta),
338
+ spec: {
339
+ handlerName: deriveClassHandlerName(className, methodName),
340
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
341
+ handler: deriveClassHandlerFunction(sourceFile, className, methodName)
342
+ }
343
+ });
344
+ }
345
+ const invokeMeta = Reflect.getOwnMetadata(INVOKE_METADATA, prototype, methodName);
346
+ if (invokeMeta) {
347
+ entries.push({
348
+ resourceName: deriveClassResourceName(className, methodName),
349
+ className,
350
+ methodName,
351
+ sourceFile,
352
+ handlerType: "custom",
353
+ annotations: buildCustomAnnotations(meta, prototype, methodName, invokeMeta),
354
+ spec: {
355
+ handlerName: deriveClassHandlerName(className, methodName),
356
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
357
+ handler: deriveClassHandlerFunction(sourceFile, className, methodName)
358
+ }
359
+ });
360
+ }
228
361
  }
229
362
  return entries;
230
363
  }
231
- __name(serializeClassHandler, "serializeClassHandler");
364
+ __name(serializeClassHandlers, "serializeClassHandlers");
365
+ function serializeControllerTypeMethod(meta, className, prototype, methodName, sourceFile, options) {
366
+ switch (meta.controllerType) {
367
+ case "http":
368
+ return serializeHttpMethod(meta, className, prototype, methodName, sourceFile, options);
369
+ case "websocket":
370
+ return serializeWebSocketMethod(meta, className, prototype, methodName, sourceFile, options);
371
+ case "consumer":
372
+ return serializeConsumerMethod(meta, className, prototype, methodName, sourceFile, options);
373
+ default:
374
+ return null;
375
+ }
376
+ }
377
+ __name(serializeControllerTypeMethod, "serializeControllerTypeMethod");
378
+ function serializeHttpMethod(meta, className, prototype, methodName, sourceFile, options) {
379
+ const httpMethod = Reflect.getOwnMetadata(HTTP_METHOD_METADATA, prototype, methodName);
380
+ if (!httpMethod) return null;
381
+ const routePath = Reflect.getOwnMetadata(ROUTE_PATH_METADATA, prototype, methodName) ?? "/";
382
+ const fullPath = joinHandlerPath(meta.prefix, routePath);
383
+ return {
384
+ resourceName: deriveClassResourceName(className, methodName),
385
+ className,
386
+ methodName,
387
+ sourceFile,
388
+ handlerType: "http",
389
+ annotations: buildHttpAnnotations(meta, prototype, methodName, httpMethod, fullPath),
390
+ spec: {
391
+ handlerName: deriveClassHandlerName(className, methodName),
392
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
393
+ handler: deriveClassHandlerFunction(sourceFile, className, methodName)
394
+ }
395
+ };
396
+ }
397
+ __name(serializeHttpMethod, "serializeHttpMethod");
398
+ function serializeWebSocketMethod(meta, className, prototype, methodName, sourceFile, options) {
399
+ const wsEvent = Reflect.getOwnMetadata(WEBSOCKET_EVENT_METADATA, prototype, methodName);
400
+ if (!wsEvent) return null;
401
+ return {
402
+ resourceName: deriveClassResourceName(className, methodName),
403
+ className,
404
+ methodName,
405
+ sourceFile,
406
+ handlerType: "websocket",
407
+ annotations: buildWebSocketAnnotations(meta, prototype, methodName, wsEvent),
408
+ spec: {
409
+ handlerName: deriveClassHandlerName(className, methodName),
410
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
411
+ handler: deriveClassHandlerFunction(sourceFile, className, methodName)
412
+ }
413
+ };
414
+ }
415
+ __name(serializeWebSocketMethod, "serializeWebSocketMethod");
416
+ function serializeConsumerMethod(meta, className, prototype, methodName, sourceFile, options) {
417
+ const consumerHandler = Reflect.getOwnMetadata(CONSUMER_HANDLER_METADATA, prototype, methodName);
418
+ if (!consumerHandler) return null;
419
+ return {
420
+ resourceName: deriveClassResourceName(className, methodName),
421
+ className,
422
+ methodName,
423
+ sourceFile,
424
+ handlerType: "consumer",
425
+ annotations: buildConsumerAnnotations(meta, prototype, methodName, consumerHandler),
426
+ spec: {
427
+ handlerName: deriveClassHandlerName(className, methodName),
428
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
429
+ handler: deriveClassHandlerFunction(sourceFile, className, methodName)
430
+ }
431
+ };
432
+ }
433
+ __name(serializeConsumerMethod, "serializeConsumerMethod");
232
434
  function serializeFunctionHandler(definition, sourceFile, options) {
435
+ const supported = [
436
+ "http",
437
+ "websocket",
438
+ "consumer",
439
+ "schedule",
440
+ "custom"
441
+ ];
442
+ if (!supported.includes(definition.type)) return null;
233
443
  const exportName = definition.metadata.handlerName ?? "handler";
234
444
  const customMetadata = definition.metadata.customMetadata ?? {};
445
+ const handlerType = definition.type;
235
446
  const annotations = {};
236
- const path = definition.metadata.path;
237
- const method = definition.metadata.method;
238
- if (path !== void 0 && method !== void 0) {
239
- annotations["celerity.handler.http"] = true;
240
- annotations["celerity.handler.http.method"] = method;
241
- annotations["celerity.handler.http.path"] = path;
242
- }
447
+ buildFunctionTypeAnnotations(annotations, definition);
243
448
  for (const [key, value] of Object.entries(customMetadata)) {
244
449
  if (value === void 0) continue;
245
450
  annotations[`celerity.handler.metadata.${key}`] = serializeAnnotationValue(value);
@@ -248,6 +453,7 @@ function serializeFunctionHandler(definition, sourceFile, options) {
248
453
  resourceName: deriveFunctionResourceName(exportName),
249
454
  exportName,
250
455
  sourceFile,
456
+ handlerType,
251
457
  ...Object.keys(annotations).length > 0 ? {
252
458
  annotations
253
459
  } : {},
@@ -259,6 +465,122 @@ function serializeFunctionHandler(definition, sourceFile, options) {
259
465
  };
260
466
  }
261
467
  __name(serializeFunctionHandler, "serializeFunctionHandler");
468
+ function buildFunctionTypeAnnotations(annotations, definition) {
469
+ const meta = definition.metadata;
470
+ switch (definition.type) {
471
+ case "http": {
472
+ const path = meta.path;
473
+ const method = meta.method;
474
+ if (path !== void 0 && method !== void 0) {
475
+ annotations["celerity.handler.http"] = true;
476
+ annotations["celerity.handler.http.method"] = method;
477
+ annotations["celerity.handler.http.path"] = path;
478
+ }
479
+ break;
480
+ }
481
+ case "websocket": {
482
+ annotations["celerity.handler.websocket"] = true;
483
+ const route = meta.route;
484
+ if (route) {
485
+ annotations["celerity.handler.websocket.route"] = route;
486
+ }
487
+ break;
488
+ }
489
+ case "consumer": {
490
+ annotations["celerity.handler.consumer"] = true;
491
+ const route = meta.route;
492
+ if (route) {
493
+ annotations["celerity.handler.consumer.route"] = route;
494
+ }
495
+ break;
496
+ }
497
+ case "schedule": {
498
+ annotations["celerity.handler.schedule"] = true;
499
+ const scheduleId = meta.scheduleId;
500
+ if (scheduleId) {
501
+ annotations["celerity.handler.schedule.scheduleId"] = scheduleId;
502
+ }
503
+ const schedule = meta.schedule;
504
+ if (schedule) {
505
+ annotations["celerity.handler.schedule.expression"] = schedule;
506
+ }
507
+ break;
508
+ }
509
+ case "custom": {
510
+ annotations["celerity.handler.custom"] = true;
511
+ const name = meta.name;
512
+ if (name) {
513
+ annotations["celerity.handler.custom.name"] = name;
514
+ }
515
+ break;
516
+ }
517
+ }
518
+ }
519
+ __name(buildFunctionTypeAnnotations, "buildFunctionTypeAnnotations");
520
+ function extractGuardMeta(guardClass) {
521
+ const guardName = Reflect.getOwnMetadata(GUARD_CUSTOM_METADATA, guardClass);
522
+ if (!guardName) return null;
523
+ return {
524
+ guardName,
525
+ customMetadata: Reflect.getOwnMetadata(CUSTOM_METADATA, guardClass) ?? {}
526
+ };
527
+ }
528
+ __name(extractGuardMeta, "extractGuardMeta");
529
+ function serializeClassGuard(guardClass, sourceFile, options) {
530
+ const meta = extractGuardMeta(guardClass);
531
+ if (!meta) return null;
532
+ const className = guardClass.name;
533
+ const methodName = "check";
534
+ const annotations = {
535
+ "celerity.handler.guard.custom": meta.guardName
536
+ };
537
+ for (const [key, value] of Object.entries(meta.customMetadata)) {
538
+ if (value === void 0) continue;
539
+ annotations[`celerity.handler.metadata.${key}`] = serializeAnnotationValue(value);
540
+ }
541
+ return {
542
+ resourceName: deriveClassResourceName(className, methodName),
543
+ guardName: meta.guardName,
544
+ sourceFile,
545
+ guardType: "class",
546
+ className,
547
+ annotations,
548
+ spec: {
549
+ handlerName: deriveClassHandlerName(className, methodName),
550
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
551
+ handler: deriveClassHandlerFunction(sourceFile, className, methodName)
552
+ }
553
+ };
554
+ }
555
+ __name(serializeClassGuard, "serializeClassGuard");
556
+ function serializeFunctionGuard(definition, sourceFile, options) {
557
+ const guardName = definition.name;
558
+ if (!guardName) return null;
559
+ const meta = definition.metadata ?? {};
560
+ const customMetadata = meta.customMetadata ?? {};
561
+ const annotations = {
562
+ "celerity.handler.guard.custom": guardName
563
+ };
564
+ for (const [key, value] of Object.entries(customMetadata)) {
565
+ if (value === void 0) continue;
566
+ annotations[`celerity.handler.metadata.${key}`] = serializeAnnotationValue(value);
567
+ }
568
+ const exportName = guardName;
569
+ return {
570
+ resourceName: deriveFunctionResourceName(exportName),
571
+ guardName,
572
+ sourceFile,
573
+ guardType: "function",
574
+ exportName,
575
+ annotations,
576
+ spec: {
577
+ handlerName: exportName,
578
+ codeLocation: deriveCodeLocation(sourceFile, options.projectRoot),
579
+ handler: deriveFunctionHandlerFunction(sourceFile, exportName)
580
+ }
581
+ };
582
+ }
583
+ __name(serializeFunctionGuard, "serializeFunctionGuard");
262
584
  function serializeAnnotationValue(value) {
263
585
  if (typeof value === "boolean") return value;
264
586
  if (typeof value === "string") return value;