@camstack/server 1.1.16 → 1.1.18
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.
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* was with the old static `mountAllCaps()` spread.
|
|
21
21
|
*/
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.COLLECTION_ARRAY_METHODS = void 0;
|
|
23
24
|
exports.createCapRouterPrimitives = createCapRouterPrimitives;
|
|
24
25
|
exports.createCapRouterServices = createCapRouterServices;
|
|
25
26
|
exports.buildRuntimeCapRouters = buildRuntimeCapRouters;
|
|
@@ -34,7 +35,7 @@ const trpc_middleware_js_1 = require("./trpc.middleware.js");
|
|
|
34
35
|
* `generate-cap-mounts.ts` `isArrayOutputSchema` so the runtime collection
|
|
35
36
|
* resolver fans the SAME methods the codegen used to.
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
+
exports.COLLECTION_ARRAY_METHODS = computeArrayMethods();
|
|
38
39
|
function computeArrayMethods() {
|
|
39
40
|
const out = new Map();
|
|
40
41
|
for (const def of types_1.ALL_CAPABILITY_DEFINITIONS) {
|
|
@@ -103,7 +104,7 @@ function resolveCollectionProvider(reg, capName, addonId) {
|
|
|
103
104
|
const first = providers[0];
|
|
104
105
|
if (first === undefined)
|
|
105
106
|
return null;
|
|
106
|
-
const arrayMethods = COLLECTION_ARRAY_METHODS.get(capName);
|
|
107
|
+
const arrayMethods = exports.COLLECTION_ARRAY_METHODS.get(capName);
|
|
107
108
|
if (!arrayMethods || arrayMethods.length === 0)
|
|
108
109
|
return first;
|
|
109
110
|
const aggregate = { ...first };
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MoleculerService = void 0;
|
|
4
4
|
exports.buildChildUdsManifest = buildChildUdsManifest;
|
|
5
5
|
const system_1 = require("@camstack/system");
|
|
6
|
+
const cap_router_runtime_js_1 = require("../../api/trpc/cap-router-runtime.js");
|
|
6
7
|
const cap_call_fn_js_1 = require("./cap-call-fn.js");
|
|
7
8
|
const cap_route_authority_js_1 = require("./cap-route-authority.js");
|
|
8
9
|
const types_1 = require("@camstack/types");
|
|
@@ -233,6 +234,27 @@ class MoleculerService {
|
|
|
233
234
|
// handler retries the hub-local route then throws a precise error rather
|
|
234
235
|
// than the unroutable broker fallback (`switch.switch.getStatus`).
|
|
235
236
|
isDeviceNativeCap: (capName) => this.capabilityService.getRegistry()?.getDefinition(capName)?.deviceNative === true,
|
|
237
|
+
// Empty-collection fast-path: a `collection` cap's array-output method
|
|
238
|
+
// with ZERO providers registered cluster-wide IS the empty aggregate —
|
|
239
|
+
// return [] instead of routing (resolver miss → broker fallback → ~30s
|
|
240
|
+
// Moleculer discovery deadline for a service that never appears; this
|
|
241
|
+
// stalled every WebRTC cold start via the provider-less `turn-provider`).
|
|
242
|
+
// Conservative: only fires for a declared collection array-method with
|
|
243
|
+
// no hub-local collection entries AND no cluster manifest entry.
|
|
244
|
+
resolveEmptyCollection: (capName, method) => {
|
|
245
|
+
const reg = this.capabilityService.getRegistry();
|
|
246
|
+
if (!reg)
|
|
247
|
+
return null;
|
|
248
|
+
if (reg.getDefinition(capName)?.mode !== 'collection')
|
|
249
|
+
return null;
|
|
250
|
+
if (!cap_router_runtime_js_1.COLLECTION_ARRAY_METHODS.get(capName)?.includes(method))
|
|
251
|
+
return null;
|
|
252
|
+
if (reg.getCollectionEntries(capName).length > 0)
|
|
253
|
+
return null;
|
|
254
|
+
if (this.nodeRegistry.listEntries().some((e) => e.capName === capName))
|
|
255
|
+
return null;
|
|
256
|
+
return [];
|
|
257
|
+
},
|
|
236
258
|
logger: {
|
|
237
259
|
warn: (msg, meta) => logger.warn(msg, meta !== null && meta !== undefined
|
|
238
260
|
? { meta: meta }
|