@camstack/server 1.1.40 → 1.1.42
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/api/trpc/cap-router-runtime.js +2 -3
- package/dist/api/trpc/generated-cap-routers.js +9 -0
- package/dist/api/trpc/scope-access.js +2 -2
- package/dist/api/trpc/trpc.middleware.js +2 -2
- package/dist/core/addon/addon-package.service.js +33 -6
- package/dist/core/addon/addon-registry.service.js +3 -3
- package/dist/core/moleculer/moleculer.service.js +1 -1
- package/dist/main.js +9 -6
- package/package.json +1 -1
|
@@ -25,7 +25,6 @@ exports.createCapRouterPrimitives = createCapRouterPrimitives;
|
|
|
25
25
|
exports.createCapRouterServices = createCapRouterServices;
|
|
26
26
|
exports.buildRuntimeCapRouters = buildRuntimeCapRouters;
|
|
27
27
|
const system_1 = require("@camstack/system");
|
|
28
|
-
const types_1 = require("@camstack/types");
|
|
29
28
|
const server_1 = require("@trpc/server");
|
|
30
29
|
const cap_mount_helpers_js_1 = require("./cap-mount-helpers.js");
|
|
31
30
|
const trpc_middleware_js_1 = require("./trpc.middleware.js");
|
|
@@ -38,7 +37,7 @@ const trpc_middleware_js_1 = require("./trpc.middleware.js");
|
|
|
38
37
|
exports.COLLECTION_ARRAY_METHODS = computeArrayMethods();
|
|
39
38
|
function computeArrayMethods() {
|
|
40
39
|
const out = new Map();
|
|
41
|
-
for (const def of
|
|
40
|
+
for (const def of system_1.ALL_CAPABILITY_DEFINITIONS) {
|
|
42
41
|
if (def.mode !== 'collection')
|
|
43
42
|
continue;
|
|
44
43
|
const names = [];
|
|
@@ -46,7 +45,7 @@ function computeArrayMethods() {
|
|
|
46
45
|
const m = schema;
|
|
47
46
|
if (m.kind === 'subscription')
|
|
48
47
|
continue;
|
|
49
|
-
if ((0,
|
|
48
|
+
if ((0, system_1.isArrayOutputSchema)(m.output))
|
|
50
49
|
names.push(name);
|
|
51
50
|
}
|
|
52
51
|
if (names.length > 0)
|
|
@@ -5006,6 +5006,15 @@ function createCapRouter_pipelineExecutor(getProvider, createRemoteProxy) {
|
|
|
5006
5006
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
5007
5007
|
return p.setVideoPipelineSteps(methodInput);
|
|
5008
5008
|
}),
|
|
5009
|
+
resetToDefault: trpc_middleware_js_1.adminProcedure
|
|
5010
|
+
.input(types_76.pipelineExecutorCapability.methods.resetToDefault.input.loose())
|
|
5011
|
+
.output(types_76.pipelineExecutorCapability.methods.resetToDefault.output)
|
|
5012
|
+
.mutation(async ({ input, ctx }) => {
|
|
5013
|
+
const { nodeId, ...methodInput } = input;
|
|
5014
|
+
const p = resolveProvider('pipeline-executor', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
5015
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
5016
|
+
return p.resetToDefault(methodInput);
|
|
5017
|
+
}),
|
|
5009
5018
|
getSchema: trpc_middleware_js_1.protectedProcedure
|
|
5010
5019
|
.input(zod_1.z.object({ nodeId: zod_1.z.string().optional() }).optional())
|
|
5011
5020
|
.output(types_76.pipelineExecutorCapability.methods.getSchema.output)
|
|
@@ -24,7 +24,7 @@ exports.checkScopeAccess = checkScopeAccess;
|
|
|
24
24
|
* method's required `access` flavour.
|
|
25
25
|
* 4. No matching scope → FORBIDDEN with a human-readable reason.
|
|
26
26
|
*/
|
|
27
|
-
const
|
|
27
|
+
const system_1 = require("@camstack/system");
|
|
28
28
|
/**
|
|
29
29
|
* Pull `deviceId` off a tRPC request input. Device-scope cap methods
|
|
30
30
|
* uniformly take `{deviceId: number, ...}` per the DeviceProxy contract,
|
|
@@ -51,7 +51,7 @@ function effectiveDeviceIds(deviceId, getAncestors) {
|
|
|
51
51
|
return [...out];
|
|
52
52
|
}
|
|
53
53
|
function checkScopeAccess(scopes, path, input, getDeviceAncestors) {
|
|
54
|
-
const meta =
|
|
54
|
+
const meta = system_1.METHOD_ACCESS_MAP[path];
|
|
55
55
|
if (!meta) {
|
|
56
56
|
return { ok: false, reason: `Unknown method '${path}' — codegen drift` };
|
|
57
57
|
}
|
|
@@ -8,7 +8,7 @@ exports.iterableSubscription = iterableSubscription;
|
|
|
8
8
|
exports.iterableInterval = iterableInterval;
|
|
9
9
|
const server_1 = require("@trpc/server");
|
|
10
10
|
const superjson_1 = __importDefault(require("superjson"));
|
|
11
|
-
const
|
|
11
|
+
const system_1 = require("@camstack/system");
|
|
12
12
|
const scope_access_js_1 = require("./scope-access.js");
|
|
13
13
|
const cap_route_error_formatter_js_1 = require("./cap-route-error-formatter.js");
|
|
14
14
|
const t = server_1.initTRPC.context().create({
|
|
@@ -102,7 +102,7 @@ exports.protectedProcedure = t.procedure.use(async ({ ctx, next, path, getRawInp
|
|
|
102
102
|
// Hand-written core route — no cap entry. Authentication has already
|
|
103
103
|
// passed; defer further gating to any explicit `adminProcedure`
|
|
104
104
|
// chained on top of this one.
|
|
105
|
-
if (!(path in
|
|
105
|
+
if (!(path in system_1.METHOD_ACCESS_MAP)) {
|
|
106
106
|
return next({ ctx: { ...ctx, user: ctx.user } });
|
|
107
107
|
}
|
|
108
108
|
// Device-scope caps may be gated by a `device:N` scope. Resolve the
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.AddonPackageService = exports.SYSTEM_PACKAGE = void 0;
|
|
36
|
+
exports.AddonPackageService = exports.FRAMEWORK_PACKAGES = exports.SYSTEM_PACKAGE = void 0;
|
|
37
37
|
exports.isFrameworkPackage = isFrameworkPackage;
|
|
38
38
|
exports.extractTgzStripped = extractTgzStripped;
|
|
39
39
|
exports.sweepStaleFrameworkBackups = sweepStaleFrameworkBackups;
|
|
@@ -49,14 +49,41 @@ const types_1 = require("@camstack/types");
|
|
|
49
49
|
const system_1 = require("@camstack/system");
|
|
50
50
|
const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
51
51
|
/**
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
54
|
-
* shm-ring is a private native dep). There is no multi-entry allowlist.
|
|
52
|
+
* The primary host-provided framework package (kernel + core). Kept as a named
|
|
53
|
+
* export because `lifecycle-job-runner` + several tests reference it directly.
|
|
55
54
|
*/
|
|
56
55
|
exports.SYSTEM_PACKAGE = '@camstack/system';
|
|
57
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Host-provided framework packages that a `camstack deploy` mirrors into the
|
|
58
|
+
* running hub's live closure via `syncFrameworkDist` (hub-main node_modules +
|
|
59
|
+
* addon-runner overlay) instead of the normal addon-install path, then bounces
|
|
60
|
+
* the server — delivering the new code with NO image rebuild.
|
|
61
|
+
*
|
|
62
|
+
* `@camstack/types` is included so a CAPABILITY change ships live via
|
|
63
|
+
* `camstack deploy packages/types`: the hub-main reads `ALL_CAPABILITY_DEFINITIONS`
|
|
64
|
+
* + `METHOD_ACCESS_MAP` and the runtime cap-router builder reads the cap defs
|
|
65
|
+
* from this single closure copy, so mirroring types' `dist/` refreshes the
|
|
66
|
+
* ENTIRE cap surface (new caps, new methods, AND the per-method auth map)
|
|
67
|
+
* without an image. `@camstack/sdk` rides along as a pure-JS lockstep companion.
|
|
68
|
+
* `@camstack/shm-ring` is deliberately EXCLUDED: it ships a native `.node`
|
|
69
|
+
* prebuild the dist-only mirror cannot rebuild — it must go through the
|
|
70
|
+
* native-aware install path, not this JS-dist swap.
|
|
71
|
+
*
|
|
72
|
+
* Membership is by package NAME, independent of the `camstack.system` manifest
|
|
73
|
+
* flag (`@camstack/types` declares `system: false` yet is a framework package
|
|
74
|
+
* here) — that flag drives Admin-UI grouping; this gate drives live-sync routing.
|
|
75
|
+
*/
|
|
76
|
+
exports.FRAMEWORK_PACKAGES = [
|
|
77
|
+
exports.SYSTEM_PACKAGE,
|
|
78
|
+
'@camstack/types',
|
|
79
|
+
'@camstack/sdk',
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* Returns true for a host-provided framework package whose `dist/` is mirrored
|
|
83
|
+
* into the live closure by `syncFrameworkDist` (not installed as a normal addon).
|
|
84
|
+
*/
|
|
58
85
|
function isFrameworkPackage(packageName) {
|
|
59
|
-
return
|
|
86
|
+
return exports.FRAMEWORK_PACKAGES.includes(packageName);
|
|
60
87
|
}
|
|
61
88
|
// ---------------------------------------------------------------------------
|
|
62
89
|
// Typed JSON helpers
|
|
@@ -50,8 +50,8 @@ const fs = __importStar(require("node:fs"));
|
|
|
50
50
|
const node_url_1 = require("node:url");
|
|
51
51
|
const addon_settings_provider_js_1 = require("./addon-settings-provider.js");
|
|
52
52
|
const addon_call_gateway_js_1 = require("./addon-call-gateway.js");
|
|
53
|
+
const system_5 = require("@camstack/system");
|
|
53
54
|
const types_2 = require("@camstack/types");
|
|
54
|
-
const types_3 = require("@camstack/types");
|
|
55
55
|
/**
|
|
56
56
|
* Type predicate: true when an `ISettingsBackend` also satisfies the
|
|
57
57
|
* sync `ISettingsStore` contract (system/addon/device key-value ops)
|
|
@@ -355,7 +355,7 @@ class AddonRegistryService {
|
|
|
355
355
|
// Register the addon-settings singleton provider — replaces the
|
|
356
356
|
// former `$addonHost` Moleculer service. The provider resolves
|
|
357
357
|
// addonId → local addon instance (hub) or remote Moleculer call.
|
|
358
|
-
this.capabilityRegistry.declareCapability(
|
|
358
|
+
this.capabilityRegistry.declareCapability(system_5.addonSettingsCapability);
|
|
359
359
|
// The SINGLE router for addon-level calls (routes / custom / settings).
|
|
360
360
|
// It classifies in-process | hub-local-child (UDS) | remote-agent
|
|
361
361
|
// (Moleculer) in ONE place — `resolveNode` reports only the BASE node
|
|
@@ -2592,7 +2592,7 @@ class AddonRegistryService {
|
|
|
2592
2592
|
let chain = this.disposerChains.get(addonId);
|
|
2593
2593
|
if (chain == null) {
|
|
2594
2594
|
const log = this.loggingService.createLogger().withTags({ addonId });
|
|
2595
|
-
chain = new
|
|
2595
|
+
chain = new types_2.DisposerChain({
|
|
2596
2596
|
onError: (err, index) => {
|
|
2597
2597
|
log.error(`Disposer #${index} threw during teardown`, {
|
|
2598
2598
|
meta: { error: (0, types_1.errMsg)(err) },
|
|
@@ -717,7 +717,7 @@ class MoleculerService {
|
|
|
717
717
|
},
|
|
718
718
|
});
|
|
719
719
|
const proxy = { id: addonId, nodeId };
|
|
720
|
-
for (const methodName of Object.keys((0,
|
|
720
|
+
for (const methodName of Object.keys((0, system_1.expandCapMethods)(capDef))) {
|
|
721
721
|
proxy[methodName] = (methodParams) => callFn(methodName, methodParams);
|
|
722
722
|
}
|
|
723
723
|
registry.registerProvider(capName, registryKey, proxy);
|
package/dist/main.js
CHANGED
|
@@ -57,7 +57,10 @@ const auth_service_1 = require("./core/auth/auth.service");
|
|
|
57
57
|
// `npx tsx scripts/generate-capability-router-types.ts`. The previous
|
|
58
58
|
// hand-curated list silently dropped caps (zones, zone-rules,
|
|
59
59
|
// zone-analytics, audio-metrics — see git for the regression).
|
|
60
|
-
|
|
60
|
+
// Sourced from `@camstack/system` (not `@camstack/types`) so the hub's
|
|
61
|
+
// capability surface refreshes on `camstack deploy packages/system` with no new
|
|
62
|
+
// server image. `@camstack/types` is never deployed to the hub.
|
|
63
|
+
const system_1 = require("@camstack/system");
|
|
61
64
|
const stream_probe_service_1 = require("./core/streaming/stream-probe.service");
|
|
62
65
|
const feature_service_1 = require("./core/feature/feature.service");
|
|
63
66
|
const agent_registry_service_1 = require("./core/agent/agent-registry.service");
|
|
@@ -79,7 +82,7 @@ const auth_whoami_1 = require("./api/auth-whoami");
|
|
|
79
82
|
const session_cookie_js_1 = require("./auth/session-cookie.js");
|
|
80
83
|
const health_routes_1 = require("./api/health/health.routes");
|
|
81
84
|
const oauth2_routes_js_1 = require("./api/oauth2/oauth2-routes.js");
|
|
82
|
-
const
|
|
85
|
+
const system_2 = require("@camstack/system");
|
|
83
86
|
const boot_config_1 = require("./boot/boot-config");
|
|
84
87
|
const manual_boot_1 = require("./manual-boot");
|
|
85
88
|
const post_boot_service_1 = require("./boot/post-boot.service");
|
|
@@ -238,8 +241,8 @@ async function bootstrap() {
|
|
|
238
241
|
// If registration fails, start in degraded mode: serve a health warning endpoint.
|
|
239
242
|
// Instantiate new core services
|
|
240
243
|
const loggingService = app.get(logging_service_1.LoggingService);
|
|
241
|
-
const addonRouteRegistry = new
|
|
242
|
-
const dataPlaneRegistry = new
|
|
244
|
+
const addonRouteRegistry = new system_2.AddonRouteRegistry();
|
|
245
|
+
const dataPlaneRegistry = new system_2.DataPlaneRegistry();
|
|
243
246
|
// Use Fastify-managed notification/toast wrappers (globally provided by NotificationModule)
|
|
244
247
|
const { NotificationServiceWrapper } = await Promise.resolve().then(() => __importStar(require('./core/notification/notification-wrapper.service')));
|
|
245
248
|
const { ToastServiceWrapper } = await Promise.resolve().then(() => __importStar(require('./core/notification/toast-wrapper.service')));
|
|
@@ -260,7 +263,7 @@ async function bootstrap() {
|
|
|
260
263
|
// from forked workers / agents) find their definition during
|
|
261
264
|
// onModuleInit. The list comes from the codegen — see the import
|
|
262
265
|
// comment above for the rationale.
|
|
263
|
-
for (const capDef of
|
|
266
|
+
for (const capDef of system_1.ALL_CAPABILITY_DEFINITIONS) {
|
|
264
267
|
capabilityRegistry.declareCapability(capDef);
|
|
265
268
|
}
|
|
266
269
|
// Hub-internal `sso-bridge` provider — gives auth-provider addons
|
|
@@ -730,7 +733,7 @@ async function bootstrap() {
|
|
|
730
733
|
const upstreamPath = `/${subPath}${queryString}`;
|
|
731
734
|
// Take over the socket — `proxyToUpstream` drives the raw response.
|
|
732
735
|
reply.hijack();
|
|
733
|
-
(0,
|
|
736
|
+
(0, system_2.proxyToUpstream)({
|
|
734
737
|
baseUrl: dpMatch.endpoint.baseUrl,
|
|
735
738
|
secret: dpMatch.endpoint.secret,
|
|
736
739
|
upstreamPath,
|