@celerity-sdk/core 0.5.0 → 0.7.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 +43 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -24
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1327,8 +1327,15 @@ var HandlerRegistry = class {
|
|
|
1327
1327
|
function matchRoute(pattern, actual) {
|
|
1328
1328
|
const patternParts = pattern.split("/").filter(Boolean);
|
|
1329
1329
|
const actualParts = actual.split("/").filter(Boolean);
|
|
1330
|
-
|
|
1331
|
-
|
|
1330
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
1331
|
+
const part = patternParts[i];
|
|
1332
|
+
if (part.startsWith("{") && part.endsWith("+}")) {
|
|
1333
|
+
return actualParts.length >= patternParts.length;
|
|
1334
|
+
}
|
|
1335
|
+
if (part.startsWith("{")) continue;
|
|
1336
|
+
if (part !== actualParts[i]) return false;
|
|
1337
|
+
}
|
|
1338
|
+
return patternParts.length === actualParts.length;
|
|
1332
1339
|
}
|
|
1333
1340
|
__name(matchRoute, "matchRoute");
|
|
1334
1341
|
|
|
@@ -1364,7 +1371,8 @@ function buildModuleGraph(rootModule) {
|
|
|
1364
1371
|
controllers: [],
|
|
1365
1372
|
functionHandlers: [],
|
|
1366
1373
|
guards: [],
|
|
1367
|
-
providers: []
|
|
1374
|
+
providers: [],
|
|
1375
|
+
layers: []
|
|
1368
1376
|
});
|
|
1369
1377
|
return;
|
|
1370
1378
|
}
|
|
@@ -1406,7 +1414,8 @@ function buildModuleGraph(rootModule) {
|
|
|
1406
1414
|
controllers,
|
|
1407
1415
|
functionHandlers: metadata.functionHandlers ?? [],
|
|
1408
1416
|
guards,
|
|
1409
|
-
providers
|
|
1417
|
+
providers,
|
|
1418
|
+
layers: metadata.layers ?? []
|
|
1410
1419
|
});
|
|
1411
1420
|
}
|
|
1412
1421
|
__name(walk, "walk");
|
|
@@ -1550,10 +1559,10 @@ var debug5 = createDebug5("celerity:core:scanner:http");
|
|
|
1550
1559
|
async function scanHttpHandlers(graph, container, registry) {
|
|
1551
1560
|
for (const [, node] of graph) {
|
|
1552
1561
|
for (const controllerClass of node.controllers) {
|
|
1553
|
-
await scanClassHandler(controllerClass, container, registry);
|
|
1562
|
+
await scanClassHandler(controllerClass, container, registry, node.layers);
|
|
1554
1563
|
}
|
|
1555
1564
|
for (const fnHandler of node.functionHandlers) {
|
|
1556
|
-
scanFunctionHandler(fnHandler, registry);
|
|
1565
|
+
scanFunctionHandler(fnHandler, registry, node.layers);
|
|
1557
1566
|
}
|
|
1558
1567
|
}
|
|
1559
1568
|
}
|
|
@@ -1577,7 +1586,7 @@ async function scanModule(moduleClass, container, registry) {
|
|
|
1577
1586
|
await scanHttpGuards(graph, container, registry);
|
|
1578
1587
|
}
|
|
1579
1588
|
__name(scanModule, "scanModule");
|
|
1580
|
-
async function scanClassHandler(controllerClass, container, registry) {
|
|
1589
|
+
async function scanClassHandler(controllerClass, container, registry, moduleLayers) {
|
|
1581
1590
|
const controllerMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
|
|
1582
1591
|
if (!controllerMeta) return;
|
|
1583
1592
|
const prototype = controllerClass.prototype;
|
|
@@ -1598,6 +1607,7 @@ async function scanClassHandler(controllerClass, container, registry) {
|
|
|
1598
1607
|
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
|
|
1599
1608
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
1600
1609
|
const layers = [
|
|
1610
|
+
...moduleLayers,
|
|
1601
1611
|
...classLayers,
|
|
1602
1612
|
...methodLayers
|
|
1603
1613
|
];
|
|
@@ -1627,10 +1637,11 @@ async function scanClassHandler(controllerClass, container, registry) {
|
|
|
1627
1637
|
}
|
|
1628
1638
|
}
|
|
1629
1639
|
__name(scanClassHandler, "scanClassHandler");
|
|
1630
|
-
function scanFunctionHandler(definition, registry) {
|
|
1640
|
+
function scanFunctionHandler(definition, registry, moduleLayers) {
|
|
1631
1641
|
if (definition.type !== "http") return;
|
|
1632
1642
|
const meta = definition.metadata;
|
|
1633
1643
|
const layers = [
|
|
1644
|
+
...moduleLayers,
|
|
1634
1645
|
...meta.layers ?? []
|
|
1635
1646
|
];
|
|
1636
1647
|
if (meta.schema) {
|
|
@@ -1767,15 +1778,15 @@ var debug6 = createDebug6("celerity:core:scanner:websocket");
|
|
|
1767
1778
|
async function scanWebSocketHandlers(graph, container, registry) {
|
|
1768
1779
|
for (const [, node] of graph) {
|
|
1769
1780
|
for (const controllerClass of node.controllers) {
|
|
1770
|
-
await scanClassHandler2(controllerClass, container, registry);
|
|
1781
|
+
await scanClassHandler2(controllerClass, container, registry, node.layers);
|
|
1771
1782
|
}
|
|
1772
1783
|
for (const fnHandler of node.functionHandlers) {
|
|
1773
|
-
scanFunctionHandler2(fnHandler, registry);
|
|
1784
|
+
scanFunctionHandler2(fnHandler, registry, node.layers);
|
|
1774
1785
|
}
|
|
1775
1786
|
}
|
|
1776
1787
|
}
|
|
1777
1788
|
__name(scanWebSocketHandlers, "scanWebSocketHandlers");
|
|
1778
|
-
async function scanClassHandler2(controllerClass, container, registry) {
|
|
1789
|
+
async function scanClassHandler2(controllerClass, container, registry, moduleLayers) {
|
|
1779
1790
|
const isWsController = Reflect.getOwnMetadata(WEBSOCKET_CONTROLLER_METADATA, controllerClass);
|
|
1780
1791
|
if (!isWsController) return;
|
|
1781
1792
|
const prototype = controllerClass.prototype;
|
|
@@ -1794,6 +1805,7 @@ async function scanClassHandler2(controllerClass, container, registry) {
|
|
|
1794
1805
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
1795
1806
|
debug6("scanClassHandler: %s %s (%s.%s)", eventMeta.eventType, eventMeta.route, controllerClass.name, methodName);
|
|
1796
1807
|
const layers = [
|
|
1808
|
+
...moduleLayers,
|
|
1797
1809
|
...classLayers,
|
|
1798
1810
|
...methodLayers
|
|
1799
1811
|
];
|
|
@@ -1820,10 +1832,11 @@ async function scanClassHandler2(controllerClass, container, registry) {
|
|
|
1820
1832
|
}
|
|
1821
1833
|
}
|
|
1822
1834
|
__name(scanClassHandler2, "scanClassHandler");
|
|
1823
|
-
function scanFunctionHandler2(definition, registry) {
|
|
1835
|
+
function scanFunctionHandler2(definition, registry, moduleLayers) {
|
|
1824
1836
|
if (definition.type !== "websocket") return;
|
|
1825
1837
|
const meta = definition.metadata;
|
|
1826
1838
|
const layers = [
|
|
1839
|
+
...moduleLayers,
|
|
1827
1840
|
...meta.layers ?? []
|
|
1828
1841
|
];
|
|
1829
1842
|
if (meta.schema) {
|
|
@@ -1855,15 +1868,15 @@ var debug7 = createDebug7("celerity:core:scanner:consumer");
|
|
|
1855
1868
|
async function scanConsumerHandlers(graph, container, registry) {
|
|
1856
1869
|
for (const [, node] of graph) {
|
|
1857
1870
|
for (const controllerClass of node.controllers) {
|
|
1858
|
-
await scanClassHandler3(controllerClass, container, registry);
|
|
1871
|
+
await scanClassHandler3(controllerClass, container, registry, node.layers);
|
|
1859
1872
|
}
|
|
1860
1873
|
for (const fnHandler of node.functionHandlers) {
|
|
1861
|
-
scanFunctionHandler3(fnHandler, registry);
|
|
1874
|
+
scanFunctionHandler3(fnHandler, registry, node.layers);
|
|
1862
1875
|
}
|
|
1863
1876
|
}
|
|
1864
1877
|
}
|
|
1865
1878
|
__name(scanConsumerHandlers, "scanConsumerHandlers");
|
|
1866
|
-
async function scanClassHandler3(controllerClass, container, registry) {
|
|
1879
|
+
async function scanClassHandler3(controllerClass, container, registry, moduleLayers) {
|
|
1867
1880
|
const consumerMeta = Reflect.getOwnMetadata(CONSUMER_METADATA, controllerClass);
|
|
1868
1881
|
if (!consumerMeta) return;
|
|
1869
1882
|
const prototype = controllerClass.prototype;
|
|
@@ -1880,6 +1893,7 @@ async function scanClassHandler3(controllerClass, container, registry) {
|
|
|
1880
1893
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
1881
1894
|
const handlerTag = consumerMeta.source ? `${consumerMeta.source}::${methodName}` : methodName;
|
|
1882
1895
|
const layers = [
|
|
1896
|
+
...moduleLayers,
|
|
1883
1897
|
...classLayers,
|
|
1884
1898
|
...methodLayers
|
|
1885
1899
|
];
|
|
@@ -1905,11 +1919,12 @@ async function scanClassHandler3(controllerClass, container, registry) {
|
|
|
1905
1919
|
}
|
|
1906
1920
|
}
|
|
1907
1921
|
__name(scanClassHandler3, "scanClassHandler");
|
|
1908
|
-
function scanFunctionHandler3(definition, registry) {
|
|
1922
|
+
function scanFunctionHandler3(definition, registry, moduleLayers) {
|
|
1909
1923
|
if (definition.type !== "consumer") return;
|
|
1910
1924
|
const meta = definition.metadata;
|
|
1911
1925
|
const handlerTag = definition.id ?? "default";
|
|
1912
1926
|
const layers = [
|
|
1927
|
+
...moduleLayers,
|
|
1913
1928
|
...meta.layers ?? []
|
|
1914
1929
|
];
|
|
1915
1930
|
if (meta.messageSchema) {
|
|
@@ -1939,15 +1954,15 @@ var debug8 = createDebug8("celerity:core:scanner:schedule");
|
|
|
1939
1954
|
async function scanScheduleHandlers(graph, container, registry) {
|
|
1940
1955
|
for (const [, node] of graph) {
|
|
1941
1956
|
for (const controllerClass of node.controllers) {
|
|
1942
|
-
await scanClassHandler4(controllerClass, container, registry);
|
|
1957
|
+
await scanClassHandler4(controllerClass, container, registry, node.layers);
|
|
1943
1958
|
}
|
|
1944
1959
|
for (const fnHandler of node.functionHandlers) {
|
|
1945
|
-
scanFunctionHandler4(fnHandler, registry);
|
|
1960
|
+
scanFunctionHandler4(fnHandler, registry, node.layers);
|
|
1946
1961
|
}
|
|
1947
1962
|
}
|
|
1948
1963
|
}
|
|
1949
1964
|
__name(scanScheduleHandlers, "scanScheduleHandlers");
|
|
1950
|
-
async function scanClassHandler4(controllerClass, container, registry) {
|
|
1965
|
+
async function scanClassHandler4(controllerClass, container, registry, moduleLayers) {
|
|
1951
1966
|
const prototype = controllerClass.prototype;
|
|
1952
1967
|
const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
|
|
1953
1968
|
const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
|
|
@@ -1962,6 +1977,7 @@ async function scanClassHandler4(controllerClass, container, registry) {
|
|
|
1962
1977
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
1963
1978
|
const handlerTag = handlerMeta.source ? `${handlerMeta.source}::${methodName}` : methodName;
|
|
1964
1979
|
const layers = [
|
|
1980
|
+
...moduleLayers,
|
|
1965
1981
|
...classLayers,
|
|
1966
1982
|
...methodLayers
|
|
1967
1983
|
];
|
|
@@ -1993,11 +2009,12 @@ async function scanClassHandler4(controllerClass, container, registry) {
|
|
|
1993
2009
|
}
|
|
1994
2010
|
}
|
|
1995
2011
|
__name(scanClassHandler4, "scanClassHandler");
|
|
1996
|
-
function scanFunctionHandler4(definition, registry) {
|
|
2012
|
+
function scanFunctionHandler4(definition, registry, moduleLayers) {
|
|
1997
2013
|
if (definition.type !== "schedule") return;
|
|
1998
2014
|
const meta = definition.metadata;
|
|
1999
2015
|
const handlerTag = meta.source ?? definition.id ?? "default";
|
|
2000
2016
|
const layers = [
|
|
2017
|
+
...moduleLayers,
|
|
2001
2018
|
...meta.layers ?? []
|
|
2002
2019
|
];
|
|
2003
2020
|
if (meta.schema) {
|
|
@@ -2032,15 +2049,15 @@ var debug9 = createDebug9("celerity:core:scanner:custom");
|
|
|
2032
2049
|
async function scanCustomHandlers(graph, container, registry) {
|
|
2033
2050
|
for (const [, node] of graph) {
|
|
2034
2051
|
for (const controllerClass of node.controllers) {
|
|
2035
|
-
await scanClassHandler5(controllerClass, container, registry);
|
|
2052
|
+
await scanClassHandler5(controllerClass, container, registry, node.layers);
|
|
2036
2053
|
}
|
|
2037
2054
|
for (const fnHandler of node.functionHandlers) {
|
|
2038
|
-
scanFunctionHandler5(fnHandler, registry);
|
|
2055
|
+
scanFunctionHandler5(fnHandler, registry, node.layers);
|
|
2039
2056
|
}
|
|
2040
2057
|
}
|
|
2041
2058
|
}
|
|
2042
2059
|
__name(scanCustomHandlers, "scanCustomHandlers");
|
|
2043
|
-
async function scanClassHandler5(controllerClass, container, registry) {
|
|
2060
|
+
async function scanClassHandler5(controllerClass, container, registry, moduleLayers) {
|
|
2044
2061
|
const prototype = controllerClass.prototype;
|
|
2045
2062
|
const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
|
|
2046
2063
|
const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
|
|
@@ -2054,6 +2071,7 @@ async function scanClassHandler5(controllerClass, container, registry) {
|
|
|
2054
2071
|
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
|
|
2055
2072
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
2056
2073
|
const layers = [
|
|
2074
|
+
...moduleLayers,
|
|
2057
2075
|
...classLayers,
|
|
2058
2076
|
...methodLayers
|
|
2059
2077
|
];
|
|
@@ -2079,11 +2097,12 @@ async function scanClassHandler5(controllerClass, container, registry) {
|
|
|
2079
2097
|
}
|
|
2080
2098
|
}
|
|
2081
2099
|
__name(scanClassHandler5, "scanClassHandler");
|
|
2082
|
-
function scanFunctionHandler5(definition, registry) {
|
|
2100
|
+
function scanFunctionHandler5(definition, registry, moduleLayers) {
|
|
2083
2101
|
if (definition.type !== "custom") return;
|
|
2084
2102
|
const meta = definition.metadata;
|
|
2085
2103
|
const name = meta.name ?? definition.id ?? "default";
|
|
2086
2104
|
const layers = [
|
|
2105
|
+
...moduleLayers,
|
|
2087
2106
|
...meta.layers ?? []
|
|
2088
2107
|
];
|
|
2089
2108
|
if (meta.schema) {
|