@celerity-sdk/core 0.5.0 → 0.6.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.d.cts CHANGED
@@ -1220,6 +1220,7 @@ type ModuleNode = {
1220
1220
  providers: (Type | (Provider & {
1221
1221
  provide: InjectionToken;
1222
1222
  }))[];
1223
+ layers: (CelerityLayer | Type<CelerityLayer>)[];
1223
1224
  };
1224
1225
  type ModuleGraph = Map<Type, ModuleNode>;
1225
1226
  /**
package/dist/index.d.ts CHANGED
@@ -1220,6 +1220,7 @@ type ModuleNode = {
1220
1220
  providers: (Type | (Provider & {
1221
1221
  provide: InjectionToken;
1222
1222
  }))[];
1223
+ layers: (CelerityLayer | Type<CelerityLayer>)[];
1223
1224
  };
1224
1225
  type ModuleGraph = Map<Type, ModuleNode>;
1225
1226
  /**
package/dist/index.js CHANGED
@@ -1364,7 +1364,8 @@ function buildModuleGraph(rootModule) {
1364
1364
  controllers: [],
1365
1365
  functionHandlers: [],
1366
1366
  guards: [],
1367
- providers: []
1367
+ providers: [],
1368
+ layers: []
1368
1369
  });
1369
1370
  return;
1370
1371
  }
@@ -1406,7 +1407,8 @@ function buildModuleGraph(rootModule) {
1406
1407
  controllers,
1407
1408
  functionHandlers: metadata.functionHandlers ?? [],
1408
1409
  guards,
1409
- providers
1410
+ providers,
1411
+ layers: metadata.layers ?? []
1410
1412
  });
1411
1413
  }
1412
1414
  __name(walk, "walk");
@@ -1550,10 +1552,10 @@ var debug5 = createDebug5("celerity:core:scanner:http");
1550
1552
  async function scanHttpHandlers(graph, container, registry) {
1551
1553
  for (const [, node] of graph) {
1552
1554
  for (const controllerClass of node.controllers) {
1553
- await scanClassHandler(controllerClass, container, registry);
1555
+ await scanClassHandler(controllerClass, container, registry, node.layers);
1554
1556
  }
1555
1557
  for (const fnHandler of node.functionHandlers) {
1556
- scanFunctionHandler(fnHandler, registry);
1558
+ scanFunctionHandler(fnHandler, registry, node.layers);
1557
1559
  }
1558
1560
  }
1559
1561
  }
@@ -1577,7 +1579,7 @@ async function scanModule(moduleClass, container, registry) {
1577
1579
  await scanHttpGuards(graph, container, registry);
1578
1580
  }
1579
1581
  __name(scanModule, "scanModule");
1580
- async function scanClassHandler(controllerClass, container, registry) {
1582
+ async function scanClassHandler(controllerClass, container, registry, moduleLayers) {
1581
1583
  const controllerMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
1582
1584
  if (!controllerMeta) return;
1583
1585
  const prototype = controllerClass.prototype;
@@ -1598,6 +1600,7 @@ async function scanClassHandler(controllerClass, container, registry) {
1598
1600
  const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
1599
1601
  if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1600
1602
  const layers = [
1603
+ ...moduleLayers,
1601
1604
  ...classLayers,
1602
1605
  ...methodLayers
1603
1606
  ];
@@ -1627,10 +1630,11 @@ async function scanClassHandler(controllerClass, container, registry) {
1627
1630
  }
1628
1631
  }
1629
1632
  __name(scanClassHandler, "scanClassHandler");
1630
- function scanFunctionHandler(definition, registry) {
1633
+ function scanFunctionHandler(definition, registry, moduleLayers) {
1631
1634
  if (definition.type !== "http") return;
1632
1635
  const meta = definition.metadata;
1633
1636
  const layers = [
1637
+ ...moduleLayers,
1634
1638
  ...meta.layers ?? []
1635
1639
  ];
1636
1640
  if (meta.schema) {
@@ -1767,15 +1771,15 @@ var debug6 = createDebug6("celerity:core:scanner:websocket");
1767
1771
  async function scanWebSocketHandlers(graph, container, registry) {
1768
1772
  for (const [, node] of graph) {
1769
1773
  for (const controllerClass of node.controllers) {
1770
- await scanClassHandler2(controllerClass, container, registry);
1774
+ await scanClassHandler2(controllerClass, container, registry, node.layers);
1771
1775
  }
1772
1776
  for (const fnHandler of node.functionHandlers) {
1773
- scanFunctionHandler2(fnHandler, registry);
1777
+ scanFunctionHandler2(fnHandler, registry, node.layers);
1774
1778
  }
1775
1779
  }
1776
1780
  }
1777
1781
  __name(scanWebSocketHandlers, "scanWebSocketHandlers");
1778
- async function scanClassHandler2(controllerClass, container, registry) {
1782
+ async function scanClassHandler2(controllerClass, container, registry, moduleLayers) {
1779
1783
  const isWsController = Reflect.getOwnMetadata(WEBSOCKET_CONTROLLER_METADATA, controllerClass);
1780
1784
  if (!isWsController) return;
1781
1785
  const prototype = controllerClass.prototype;
@@ -1794,6 +1798,7 @@ async function scanClassHandler2(controllerClass, container, registry) {
1794
1798
  if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1795
1799
  debug6("scanClassHandler: %s %s (%s.%s)", eventMeta.eventType, eventMeta.route, controllerClass.name, methodName);
1796
1800
  const layers = [
1801
+ ...moduleLayers,
1797
1802
  ...classLayers,
1798
1803
  ...methodLayers
1799
1804
  ];
@@ -1820,10 +1825,11 @@ async function scanClassHandler2(controllerClass, container, registry) {
1820
1825
  }
1821
1826
  }
1822
1827
  __name(scanClassHandler2, "scanClassHandler");
1823
- function scanFunctionHandler2(definition, registry) {
1828
+ function scanFunctionHandler2(definition, registry, moduleLayers) {
1824
1829
  if (definition.type !== "websocket") return;
1825
1830
  const meta = definition.metadata;
1826
1831
  const layers = [
1832
+ ...moduleLayers,
1827
1833
  ...meta.layers ?? []
1828
1834
  ];
1829
1835
  if (meta.schema) {
@@ -1855,15 +1861,15 @@ var debug7 = createDebug7("celerity:core:scanner:consumer");
1855
1861
  async function scanConsumerHandlers(graph, container, registry) {
1856
1862
  for (const [, node] of graph) {
1857
1863
  for (const controllerClass of node.controllers) {
1858
- await scanClassHandler3(controllerClass, container, registry);
1864
+ await scanClassHandler3(controllerClass, container, registry, node.layers);
1859
1865
  }
1860
1866
  for (const fnHandler of node.functionHandlers) {
1861
- scanFunctionHandler3(fnHandler, registry);
1867
+ scanFunctionHandler3(fnHandler, registry, node.layers);
1862
1868
  }
1863
1869
  }
1864
1870
  }
1865
1871
  __name(scanConsumerHandlers, "scanConsumerHandlers");
1866
- async function scanClassHandler3(controllerClass, container, registry) {
1872
+ async function scanClassHandler3(controllerClass, container, registry, moduleLayers) {
1867
1873
  const consumerMeta = Reflect.getOwnMetadata(CONSUMER_METADATA, controllerClass);
1868
1874
  if (!consumerMeta) return;
1869
1875
  const prototype = controllerClass.prototype;
@@ -1880,6 +1886,7 @@ async function scanClassHandler3(controllerClass, container, registry) {
1880
1886
  if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1881
1887
  const handlerTag = consumerMeta.source ? `${consumerMeta.source}::${methodName}` : methodName;
1882
1888
  const layers = [
1889
+ ...moduleLayers,
1883
1890
  ...classLayers,
1884
1891
  ...methodLayers
1885
1892
  ];
@@ -1905,11 +1912,12 @@ async function scanClassHandler3(controllerClass, container, registry) {
1905
1912
  }
1906
1913
  }
1907
1914
  __name(scanClassHandler3, "scanClassHandler");
1908
- function scanFunctionHandler3(definition, registry) {
1915
+ function scanFunctionHandler3(definition, registry, moduleLayers) {
1909
1916
  if (definition.type !== "consumer") return;
1910
1917
  const meta = definition.metadata;
1911
1918
  const handlerTag = definition.id ?? "default";
1912
1919
  const layers = [
1920
+ ...moduleLayers,
1913
1921
  ...meta.layers ?? []
1914
1922
  ];
1915
1923
  if (meta.messageSchema) {
@@ -1939,15 +1947,15 @@ var debug8 = createDebug8("celerity:core:scanner:schedule");
1939
1947
  async function scanScheduleHandlers(graph, container, registry) {
1940
1948
  for (const [, node] of graph) {
1941
1949
  for (const controllerClass of node.controllers) {
1942
- await scanClassHandler4(controllerClass, container, registry);
1950
+ await scanClassHandler4(controllerClass, container, registry, node.layers);
1943
1951
  }
1944
1952
  for (const fnHandler of node.functionHandlers) {
1945
- scanFunctionHandler4(fnHandler, registry);
1953
+ scanFunctionHandler4(fnHandler, registry, node.layers);
1946
1954
  }
1947
1955
  }
1948
1956
  }
1949
1957
  __name(scanScheduleHandlers, "scanScheduleHandlers");
1950
- async function scanClassHandler4(controllerClass, container, registry) {
1958
+ async function scanClassHandler4(controllerClass, container, registry, moduleLayers) {
1951
1959
  const prototype = controllerClass.prototype;
1952
1960
  const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
1953
1961
  const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
@@ -1962,6 +1970,7 @@ async function scanClassHandler4(controllerClass, container, registry) {
1962
1970
  if (!descriptor?.value || typeof descriptor.value !== "function") continue;
1963
1971
  const handlerTag = handlerMeta.source ? `${handlerMeta.source}::${methodName}` : methodName;
1964
1972
  const layers = [
1973
+ ...moduleLayers,
1965
1974
  ...classLayers,
1966
1975
  ...methodLayers
1967
1976
  ];
@@ -1993,11 +2002,12 @@ async function scanClassHandler4(controllerClass, container, registry) {
1993
2002
  }
1994
2003
  }
1995
2004
  __name(scanClassHandler4, "scanClassHandler");
1996
- function scanFunctionHandler4(definition, registry) {
2005
+ function scanFunctionHandler4(definition, registry, moduleLayers) {
1997
2006
  if (definition.type !== "schedule") return;
1998
2007
  const meta = definition.metadata;
1999
2008
  const handlerTag = meta.source ?? definition.id ?? "default";
2000
2009
  const layers = [
2010
+ ...moduleLayers,
2001
2011
  ...meta.layers ?? []
2002
2012
  ];
2003
2013
  if (meta.schema) {
@@ -2032,15 +2042,15 @@ var debug9 = createDebug9("celerity:core:scanner:custom");
2032
2042
  async function scanCustomHandlers(graph, container, registry) {
2033
2043
  for (const [, node] of graph) {
2034
2044
  for (const controllerClass of node.controllers) {
2035
- await scanClassHandler5(controllerClass, container, registry);
2045
+ await scanClassHandler5(controllerClass, container, registry, node.layers);
2036
2046
  }
2037
2047
  for (const fnHandler of node.functionHandlers) {
2038
- scanFunctionHandler5(fnHandler, registry);
2048
+ scanFunctionHandler5(fnHandler, registry, node.layers);
2039
2049
  }
2040
2050
  }
2041
2051
  }
2042
2052
  __name(scanCustomHandlers, "scanCustomHandlers");
2043
- async function scanClassHandler5(controllerClass, container, registry) {
2053
+ async function scanClassHandler5(controllerClass, container, registry, moduleLayers) {
2044
2054
  const prototype = controllerClass.prototype;
2045
2055
  const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
2046
2056
  const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
@@ -2054,6 +2064,7 @@ async function scanClassHandler5(controllerClass, container, registry) {
2054
2064
  const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
2055
2065
  if (!descriptor?.value || typeof descriptor.value !== "function") continue;
2056
2066
  const layers = [
2067
+ ...moduleLayers,
2057
2068
  ...classLayers,
2058
2069
  ...methodLayers
2059
2070
  ];
@@ -2079,11 +2090,12 @@ async function scanClassHandler5(controllerClass, container, registry) {
2079
2090
  }
2080
2091
  }
2081
2092
  __name(scanClassHandler5, "scanClassHandler");
2082
- function scanFunctionHandler5(definition, registry) {
2093
+ function scanFunctionHandler5(definition, registry, moduleLayers) {
2083
2094
  if (definition.type !== "custom") return;
2084
2095
  const meta = definition.metadata;
2085
2096
  const name = meta.name ?? definition.id ?? "default";
2086
2097
  const layers = [
2098
+ ...moduleLayers,
2087
2099
  ...meta.layers ?? []
2088
2100
  ];
2089
2101
  if (meta.schema) {