@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.cjs
CHANGED
|
@@ -1507,8 +1507,15 @@ var HandlerRegistry = class {
|
|
|
1507
1507
|
function matchRoute(pattern, actual) {
|
|
1508
1508
|
const patternParts = pattern.split("/").filter(Boolean);
|
|
1509
1509
|
const actualParts = actual.split("/").filter(Boolean);
|
|
1510
|
-
|
|
1511
|
-
|
|
1510
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
1511
|
+
const part = patternParts[i];
|
|
1512
|
+
if (part.startsWith("{") && part.endsWith("+}")) {
|
|
1513
|
+
return actualParts.length >= patternParts.length;
|
|
1514
|
+
}
|
|
1515
|
+
if (part.startsWith("{")) continue;
|
|
1516
|
+
if (part !== actualParts[i]) return false;
|
|
1517
|
+
}
|
|
1518
|
+
return patternParts.length === actualParts.length;
|
|
1512
1519
|
}
|
|
1513
1520
|
__name(matchRoute, "matchRoute");
|
|
1514
1521
|
|
|
@@ -1544,7 +1551,8 @@ function buildModuleGraph(rootModule) {
|
|
|
1544
1551
|
controllers: [],
|
|
1545
1552
|
functionHandlers: [],
|
|
1546
1553
|
guards: [],
|
|
1547
|
-
providers: []
|
|
1554
|
+
providers: [],
|
|
1555
|
+
layers: []
|
|
1548
1556
|
});
|
|
1549
1557
|
return;
|
|
1550
1558
|
}
|
|
@@ -1586,7 +1594,8 @@ function buildModuleGraph(rootModule) {
|
|
|
1586
1594
|
controllers,
|
|
1587
1595
|
functionHandlers: metadata.functionHandlers ?? [],
|
|
1588
1596
|
guards,
|
|
1589
|
-
providers
|
|
1597
|
+
providers,
|
|
1598
|
+
layers: metadata.layers ?? []
|
|
1590
1599
|
});
|
|
1591
1600
|
}
|
|
1592
1601
|
__name(walk, "walk");
|
|
@@ -1730,10 +1739,10 @@ var debug5 = (0, import_debug5.default)("celerity:core:scanner:http");
|
|
|
1730
1739
|
async function scanHttpHandlers(graph, container, registry) {
|
|
1731
1740
|
for (const [, node] of graph) {
|
|
1732
1741
|
for (const controllerClass of node.controllers) {
|
|
1733
|
-
await scanClassHandler(controllerClass, container, registry);
|
|
1742
|
+
await scanClassHandler(controllerClass, container, registry, node.layers);
|
|
1734
1743
|
}
|
|
1735
1744
|
for (const fnHandler of node.functionHandlers) {
|
|
1736
|
-
scanFunctionHandler(fnHandler, registry);
|
|
1745
|
+
scanFunctionHandler(fnHandler, registry, node.layers);
|
|
1737
1746
|
}
|
|
1738
1747
|
}
|
|
1739
1748
|
}
|
|
@@ -1757,7 +1766,7 @@ async function scanModule(moduleClass, container, registry) {
|
|
|
1757
1766
|
await scanHttpGuards(graph, container, registry);
|
|
1758
1767
|
}
|
|
1759
1768
|
__name(scanModule, "scanModule");
|
|
1760
|
-
async function scanClassHandler(controllerClass, container, registry) {
|
|
1769
|
+
async function scanClassHandler(controllerClass, container, registry, moduleLayers) {
|
|
1761
1770
|
const controllerMeta = Reflect.getOwnMetadata(CONTROLLER_METADATA, controllerClass);
|
|
1762
1771
|
if (!controllerMeta) return;
|
|
1763
1772
|
const prototype = controllerClass.prototype;
|
|
@@ -1778,6 +1787,7 @@ async function scanClassHandler(controllerClass, container, registry) {
|
|
|
1778
1787
|
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
|
|
1779
1788
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
1780
1789
|
const layers = [
|
|
1790
|
+
...moduleLayers,
|
|
1781
1791
|
...classLayers,
|
|
1782
1792
|
...methodLayers
|
|
1783
1793
|
];
|
|
@@ -1807,10 +1817,11 @@ async function scanClassHandler(controllerClass, container, registry) {
|
|
|
1807
1817
|
}
|
|
1808
1818
|
}
|
|
1809
1819
|
__name(scanClassHandler, "scanClassHandler");
|
|
1810
|
-
function scanFunctionHandler(definition, registry) {
|
|
1820
|
+
function scanFunctionHandler(definition, registry, moduleLayers) {
|
|
1811
1821
|
if (definition.type !== "http") return;
|
|
1812
1822
|
const meta = definition.metadata;
|
|
1813
1823
|
const layers = [
|
|
1824
|
+
...moduleLayers,
|
|
1814
1825
|
...meta.layers ?? []
|
|
1815
1826
|
];
|
|
1816
1827
|
if (meta.schema) {
|
|
@@ -1947,15 +1958,15 @@ var debug6 = (0, import_debug6.default)("celerity:core:scanner:websocket");
|
|
|
1947
1958
|
async function scanWebSocketHandlers(graph, container, registry) {
|
|
1948
1959
|
for (const [, node] of graph) {
|
|
1949
1960
|
for (const controllerClass of node.controllers) {
|
|
1950
|
-
await scanClassHandler2(controllerClass, container, registry);
|
|
1961
|
+
await scanClassHandler2(controllerClass, container, registry, node.layers);
|
|
1951
1962
|
}
|
|
1952
1963
|
for (const fnHandler of node.functionHandlers) {
|
|
1953
|
-
scanFunctionHandler2(fnHandler, registry);
|
|
1964
|
+
scanFunctionHandler2(fnHandler, registry, node.layers);
|
|
1954
1965
|
}
|
|
1955
1966
|
}
|
|
1956
1967
|
}
|
|
1957
1968
|
__name(scanWebSocketHandlers, "scanWebSocketHandlers");
|
|
1958
|
-
async function scanClassHandler2(controllerClass, container, registry) {
|
|
1969
|
+
async function scanClassHandler2(controllerClass, container, registry, moduleLayers) {
|
|
1959
1970
|
const isWsController = Reflect.getOwnMetadata(WEBSOCKET_CONTROLLER_METADATA, controllerClass);
|
|
1960
1971
|
if (!isWsController) return;
|
|
1961
1972
|
const prototype = controllerClass.prototype;
|
|
@@ -1974,6 +1985,7 @@ async function scanClassHandler2(controllerClass, container, registry) {
|
|
|
1974
1985
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
1975
1986
|
debug6("scanClassHandler: %s %s (%s.%s)", eventMeta.eventType, eventMeta.route, controllerClass.name, methodName);
|
|
1976
1987
|
const layers = [
|
|
1988
|
+
...moduleLayers,
|
|
1977
1989
|
...classLayers,
|
|
1978
1990
|
...methodLayers
|
|
1979
1991
|
];
|
|
@@ -2000,10 +2012,11 @@ async function scanClassHandler2(controllerClass, container, registry) {
|
|
|
2000
2012
|
}
|
|
2001
2013
|
}
|
|
2002
2014
|
__name(scanClassHandler2, "scanClassHandler");
|
|
2003
|
-
function scanFunctionHandler2(definition, registry) {
|
|
2015
|
+
function scanFunctionHandler2(definition, registry, moduleLayers) {
|
|
2004
2016
|
if (definition.type !== "websocket") return;
|
|
2005
2017
|
const meta = definition.metadata;
|
|
2006
2018
|
const layers = [
|
|
2019
|
+
...moduleLayers,
|
|
2007
2020
|
...meta.layers ?? []
|
|
2008
2021
|
];
|
|
2009
2022
|
if (meta.schema) {
|
|
@@ -2035,15 +2048,15 @@ var debug7 = (0, import_debug7.default)("celerity:core:scanner:consumer");
|
|
|
2035
2048
|
async function scanConsumerHandlers(graph, container, registry) {
|
|
2036
2049
|
for (const [, node] of graph) {
|
|
2037
2050
|
for (const controllerClass of node.controllers) {
|
|
2038
|
-
await scanClassHandler3(controllerClass, container, registry);
|
|
2051
|
+
await scanClassHandler3(controllerClass, container, registry, node.layers);
|
|
2039
2052
|
}
|
|
2040
2053
|
for (const fnHandler of node.functionHandlers) {
|
|
2041
|
-
scanFunctionHandler3(fnHandler, registry);
|
|
2054
|
+
scanFunctionHandler3(fnHandler, registry, node.layers);
|
|
2042
2055
|
}
|
|
2043
2056
|
}
|
|
2044
2057
|
}
|
|
2045
2058
|
__name(scanConsumerHandlers, "scanConsumerHandlers");
|
|
2046
|
-
async function scanClassHandler3(controllerClass, container, registry) {
|
|
2059
|
+
async function scanClassHandler3(controllerClass, container, registry, moduleLayers) {
|
|
2047
2060
|
const consumerMeta = Reflect.getOwnMetadata(CONSUMER_METADATA, controllerClass);
|
|
2048
2061
|
if (!consumerMeta) return;
|
|
2049
2062
|
const prototype = controllerClass.prototype;
|
|
@@ -2060,6 +2073,7 @@ async function scanClassHandler3(controllerClass, container, registry) {
|
|
|
2060
2073
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
2061
2074
|
const handlerTag = consumerMeta.source ? `${consumerMeta.source}::${methodName}` : methodName;
|
|
2062
2075
|
const layers = [
|
|
2076
|
+
...moduleLayers,
|
|
2063
2077
|
...classLayers,
|
|
2064
2078
|
...methodLayers
|
|
2065
2079
|
];
|
|
@@ -2085,11 +2099,12 @@ async function scanClassHandler3(controllerClass, container, registry) {
|
|
|
2085
2099
|
}
|
|
2086
2100
|
}
|
|
2087
2101
|
__name(scanClassHandler3, "scanClassHandler");
|
|
2088
|
-
function scanFunctionHandler3(definition, registry) {
|
|
2102
|
+
function scanFunctionHandler3(definition, registry, moduleLayers) {
|
|
2089
2103
|
if (definition.type !== "consumer") return;
|
|
2090
2104
|
const meta = definition.metadata;
|
|
2091
2105
|
const handlerTag = definition.id ?? "default";
|
|
2092
2106
|
const layers = [
|
|
2107
|
+
...moduleLayers,
|
|
2093
2108
|
...meta.layers ?? []
|
|
2094
2109
|
];
|
|
2095
2110
|
if (meta.messageSchema) {
|
|
@@ -2119,15 +2134,15 @@ var debug8 = (0, import_debug8.default)("celerity:core:scanner:schedule");
|
|
|
2119
2134
|
async function scanScheduleHandlers(graph, container, registry) {
|
|
2120
2135
|
for (const [, node] of graph) {
|
|
2121
2136
|
for (const controllerClass of node.controllers) {
|
|
2122
|
-
await scanClassHandler4(controllerClass, container, registry);
|
|
2137
|
+
await scanClassHandler4(controllerClass, container, registry, node.layers);
|
|
2123
2138
|
}
|
|
2124
2139
|
for (const fnHandler of node.functionHandlers) {
|
|
2125
|
-
scanFunctionHandler4(fnHandler, registry);
|
|
2140
|
+
scanFunctionHandler4(fnHandler, registry, node.layers);
|
|
2126
2141
|
}
|
|
2127
2142
|
}
|
|
2128
2143
|
}
|
|
2129
2144
|
__name(scanScheduleHandlers, "scanScheduleHandlers");
|
|
2130
|
-
async function scanClassHandler4(controllerClass, container, registry) {
|
|
2145
|
+
async function scanClassHandler4(controllerClass, container, registry, moduleLayers) {
|
|
2131
2146
|
const prototype = controllerClass.prototype;
|
|
2132
2147
|
const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
|
|
2133
2148
|
const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
|
|
@@ -2142,6 +2157,7 @@ async function scanClassHandler4(controllerClass, container, registry) {
|
|
|
2142
2157
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
2143
2158
|
const handlerTag = handlerMeta.source ? `${handlerMeta.source}::${methodName}` : methodName;
|
|
2144
2159
|
const layers = [
|
|
2160
|
+
...moduleLayers,
|
|
2145
2161
|
...classLayers,
|
|
2146
2162
|
...methodLayers
|
|
2147
2163
|
];
|
|
@@ -2173,11 +2189,12 @@ async function scanClassHandler4(controllerClass, container, registry) {
|
|
|
2173
2189
|
}
|
|
2174
2190
|
}
|
|
2175
2191
|
__name(scanClassHandler4, "scanClassHandler");
|
|
2176
|
-
function scanFunctionHandler4(definition, registry) {
|
|
2192
|
+
function scanFunctionHandler4(definition, registry, moduleLayers) {
|
|
2177
2193
|
if (definition.type !== "schedule") return;
|
|
2178
2194
|
const meta = definition.metadata;
|
|
2179
2195
|
const handlerTag = meta.source ?? definition.id ?? "default";
|
|
2180
2196
|
const layers = [
|
|
2197
|
+
...moduleLayers,
|
|
2181
2198
|
...meta.layers ?? []
|
|
2182
2199
|
];
|
|
2183
2200
|
if (meta.schema) {
|
|
@@ -2212,15 +2229,15 @@ var debug9 = (0, import_debug9.default)("celerity:core:scanner:custom");
|
|
|
2212
2229
|
async function scanCustomHandlers(graph, container, registry) {
|
|
2213
2230
|
for (const [, node] of graph) {
|
|
2214
2231
|
for (const controllerClass of node.controllers) {
|
|
2215
|
-
await scanClassHandler5(controllerClass, container, registry);
|
|
2232
|
+
await scanClassHandler5(controllerClass, container, registry, node.layers);
|
|
2216
2233
|
}
|
|
2217
2234
|
for (const fnHandler of node.functionHandlers) {
|
|
2218
|
-
scanFunctionHandler5(fnHandler, registry);
|
|
2235
|
+
scanFunctionHandler5(fnHandler, registry, node.layers);
|
|
2219
2236
|
}
|
|
2220
2237
|
}
|
|
2221
2238
|
}
|
|
2222
2239
|
__name(scanCustomHandlers, "scanCustomHandlers");
|
|
2223
|
-
async function scanClassHandler5(controllerClass, container, registry) {
|
|
2240
|
+
async function scanClassHandler5(controllerClass, container, registry, moduleLayers) {
|
|
2224
2241
|
const prototype = controllerClass.prototype;
|
|
2225
2242
|
const methods = Object.getOwnPropertyNames(prototype).filter((name) => name !== "constructor");
|
|
2226
2243
|
const classLayers = Reflect.getOwnMetadata(LAYER_METADATA, controllerClass) ?? [];
|
|
@@ -2234,6 +2251,7 @@ async function scanClassHandler5(controllerClass, container, registry) {
|
|
|
2234
2251
|
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
|
|
2235
2252
|
if (!descriptor?.value || typeof descriptor.value !== "function") continue;
|
|
2236
2253
|
const layers = [
|
|
2254
|
+
...moduleLayers,
|
|
2237
2255
|
...classLayers,
|
|
2238
2256
|
...methodLayers
|
|
2239
2257
|
];
|
|
@@ -2259,11 +2277,12 @@ async function scanClassHandler5(controllerClass, container, registry) {
|
|
|
2259
2277
|
}
|
|
2260
2278
|
}
|
|
2261
2279
|
__name(scanClassHandler5, "scanClassHandler");
|
|
2262
|
-
function scanFunctionHandler5(definition, registry) {
|
|
2280
|
+
function scanFunctionHandler5(definition, registry, moduleLayers) {
|
|
2263
2281
|
if (definition.type !== "custom") return;
|
|
2264
2282
|
const meta = definition.metadata;
|
|
2265
2283
|
const name = meta.name ?? definition.id ?? "default";
|
|
2266
2284
|
const layers = [
|
|
2285
|
+
...moduleLayers,
|
|
2267
2286
|
...meta.layers ?? []
|
|
2268
2287
|
];
|
|
2269
2288
|
if (meta.schema) {
|