@camstack/addon-provider-unraid 0.2.152 → 0.2.153
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/CHANGELOG.md +8 -0
- package/dist/addon.js +172 -42
- package/dist/addon.mjs +172 -42
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.153] - 2026-11-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Declares the minimum CamStack server it needs; the Addons page shows a held update as requires server >= X
|
|
15
|
+
- Integration reconcile no longer removes devices when the integration list or settings read fails or is empty; devices are removed only on an explicit Deleted/Disabled event
|
|
16
|
+
|
|
10
17
|
## [0.2.152] - 2026-11-01
|
|
11
18
|
|
|
12
19
|
### Changed
|
|
13
20
|
|
|
14
21
|
- Unraid is now added as an integration: the server host and API key are the integration's settings, and the server appears as a Gateway next to its instance device instead of a Hub.
|
|
22
|
+
- Declares the minimum CamStack server it needs; the Addons page shows a held update as requires server >= X
|
|
15
23
|
|
|
16
24
|
## [0.2.151] - 2026-10-28
|
|
17
25
|
|
package/dist/addon.js
CHANGED
|
@@ -5831,7 +5831,7 @@ var ZodIssueCode = {
|
|
|
5831
5831
|
var ZodFirstPartyTypeKind;
|
|
5832
5832
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5833
5833
|
//#endregion
|
|
5834
|
-
//#region ../types/dist/sleep-
|
|
5834
|
+
//#region ../types/dist/sleep-CSYuxssh.mjs
|
|
5835
5835
|
/**
|
|
5836
5836
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5837
5837
|
* window to float samples (D455).
|
|
@@ -9114,7 +9114,7 @@ var ProfileRtspEntrySchema = object({
|
|
|
9114
9114
|
/**
|
|
9115
9115
|
* The model weight formats a catalog entry can ship. Schema-free on purpose:
|
|
9116
9116
|
* `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
|
|
9117
|
-
* (the model downloader in `@camstack/system`) needs only the list and must
|
|
9117
|
+
* (the model downloader in `@camstack/server/system`) needs only the list and must
|
|
9118
9118
|
* reach it through `@camstack/types/addon` without building the cap schema
|
|
9119
9119
|
* graph (D28).
|
|
9120
9120
|
*/
|
|
@@ -12489,6 +12489,71 @@ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
|
|
|
12489
12489
|
var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
|
|
12490
12490
|
new Set(EVENT_OWNER_TYPES);
|
|
12491
12491
|
/**
|
|
12492
|
+
* What a published package needs from the rest of the install (D989).
|
|
12493
|
+
*
|
|
12494
|
+
* One published framework package (`@camstack/server`) carries the kernel, the
|
|
12495
|
+
* builtins and the capability contracts, so "which addon runs on which
|
|
12496
|
+
* framework" is a question of version, and the answer is DECLARED by the
|
|
12497
|
+
* package that knows it:
|
|
12498
|
+
*
|
|
12499
|
+
* - an addon says the oldest server it runs on (`requires.server: ">=X"`);
|
|
12500
|
+
* - the server says the oldest addon it works with
|
|
12501
|
+
* (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
|
|
12502
|
+
* around it (`requires.wrapper: { desktop, image }`);
|
|
12503
|
+
* - a wrapper (the desktop app, the container starter) says which server
|
|
12504
|
+
* range it can host, and reports its own kind and version.
|
|
12505
|
+
*
|
|
12506
|
+
* The publish workflow STAMPS these after the version bump
|
|
12507
|
+
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
12508
|
+
*
|
|
12509
|
+
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
12510
|
+
* version counts as below the minimum, and an unreadable running version is
|
|
12511
|
+
* named in the result (a failed read is never a pass).
|
|
12512
|
+
*/
|
|
12513
|
+
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
12514
|
+
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
12515
|
+
object({
|
|
12516
|
+
/** The oldest `@camstack/server` this package runs on. */
|
|
12517
|
+
server: MinVersionSchema.optional(),
|
|
12518
|
+
/** The oldest installed version of each named addon package. */
|
|
12519
|
+
addons: record(string(), MinVersionSchema).optional(),
|
|
12520
|
+
/** The oldest shell around the server, per shell kind. */
|
|
12521
|
+
wrapper: object({
|
|
12522
|
+
desktop: MinVersionSchema.optional(),
|
|
12523
|
+
image: MinVersionSchema.optional()
|
|
12524
|
+
}).optional()
|
|
12525
|
+
});
|
|
12526
|
+
/** One unmet requirement; each names the versions on both sides. */
|
|
12527
|
+
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
12528
|
+
object({
|
|
12529
|
+
kind: literal("server-too-old"),
|
|
12530
|
+
required: string(),
|
|
12531
|
+
/** `null` — the running server version could not be read. */
|
|
12532
|
+
running: string().nullable()
|
|
12533
|
+
}),
|
|
12534
|
+
object({
|
|
12535
|
+
kind: literal("addon-too-old"),
|
|
12536
|
+
packageName: string(),
|
|
12537
|
+
required: string(),
|
|
12538
|
+
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
12539
|
+
running: string().nullable()
|
|
12540
|
+
}),
|
|
12541
|
+
object({
|
|
12542
|
+
kind: literal("wrapper-too-old"),
|
|
12543
|
+
wrapper: _enum(["desktop", "image"]),
|
|
12544
|
+
required: string(),
|
|
12545
|
+
/** `null` — the wrapper reported no version. */
|
|
12546
|
+
running: string().nullable()
|
|
12547
|
+
})
|
|
12548
|
+
]);
|
|
12549
|
+
var RequiredAddonUpdateSchema = object({
|
|
12550
|
+
packageName: string(),
|
|
12551
|
+
/** The minimum the target server declares. */
|
|
12552
|
+
required: string(),
|
|
12553
|
+
/** What this node has; `null` when the addon is not installed. */
|
|
12554
|
+
installed: string().nullable()
|
|
12555
|
+
});
|
|
12556
|
+
/**
|
|
12492
12557
|
* Which integration instance a settings form is for. An addon that serves several instances
|
|
12493
12558
|
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
12494
12559
|
* needs its connection, the default integration needs the addon's own sections.
|
|
@@ -42904,7 +42969,7 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
|
|
|
42904
42969
|
* rebuilds without manual reload.
|
|
42905
42970
|
*
|
|
42906
42971
|
* The hub-local builtin `addon-pages-aggregator` (see
|
|
42907
|
-
* `@camstack/system/builtins/addon-pages-aggregator`) registers the
|
|
42972
|
+
* `@camstack/server/system/builtins/addon-pages-aggregator`) registers the
|
|
42908
42973
|
* provider. Splitting the public aggregator from the raw collection
|
|
42909
42974
|
* keeps both ends in codegen — there's no hand-written
|
|
42910
42975
|
* `addon-pages.router.ts` wrapper anymore.
|
|
@@ -43204,7 +43269,7 @@ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
|
|
|
43204
43269
|
* manual reload — same scheme used by `addon-pages`.
|
|
43205
43270
|
*
|
|
43206
43271
|
* The hub-local builtin `addon-widgets-aggregator` (see
|
|
43207
|
-
* `@camstack/system/builtins/addon-widgets-aggregator`) registers the
|
|
43272
|
+
* `@camstack/server/system/builtins/addon-widgets-aggregator`) registers the
|
|
43208
43273
|
* provider. Splitting the public aggregator from the raw collection
|
|
43209
43274
|
* keeps both ends in codegen — there's no hand-written wrapper.
|
|
43210
43275
|
*/
|
|
@@ -61404,7 +61469,18 @@ var ServerUpdateActionResultSchema = object({
|
|
|
61404
61469
|
* store (D877), present when the pre-flight refused the update
|
|
61405
61470
|
* (`reason: 'addon-would-refuse'`). Optional for version skew.
|
|
61406
61471
|
*/
|
|
61407
|
-
blockers: array(UpdateBlockerSchema).optional()
|
|
61472
|
+
blockers: array(UpdateBlockerSchema).optional(),
|
|
61473
|
+
/**
|
|
61474
|
+
* The minimums the target server declares and this node does not meet
|
|
61475
|
+
* (D989), present when the update was refused with
|
|
61476
|
+
* `reason: 'requirements-unmet'`. Each names the versions on both sides.
|
|
61477
|
+
*/
|
|
61478
|
+
unmet: array(UnmetRequirementSchema).optional(),
|
|
61479
|
+
/**
|
|
61480
|
+
* The addons this node has below the minimum the staged server declares —
|
|
61481
|
+
* the ones to update WITH the server. Present on an accepted update.
|
|
61482
|
+
*/
|
|
61483
|
+
requiredAddonUpdates: array(RequiredAddonUpdateSchema).optional()
|
|
61408
61484
|
});
|
|
61409
61485
|
var LaunchOverridesSchema = object({
|
|
61410
61486
|
/** The persisted heap ceiling in MB, or `null` when none is set. */
|
|
@@ -63948,7 +64024,9 @@ var PackageUpdateSchema = object({
|
|
|
63948
64024
|
latestVersion: string(),
|
|
63949
64025
|
category: _enum(["addon", "core"]),
|
|
63950
64026
|
requiresRestart: boolean(),
|
|
63951
|
-
isSystem: boolean()
|
|
64027
|
+
isSystem: boolean(),
|
|
64028
|
+
/** Held: what the newer version needs and this node does not meet (D989). */
|
|
64029
|
+
blockedBy: array(UnmetRequirementSchema).readonly().optional()
|
|
63952
64030
|
});
|
|
63953
64031
|
var PackageVersionInfoSchema = object({
|
|
63954
64032
|
version: string(),
|
|
@@ -69248,7 +69326,7 @@ var lawnMowerControlCapability = {
|
|
|
69248
69326
|
* clients — they reverse-connect to the hub. Exposing their interfaces
|
|
69249
69327
|
* via the same surface would leak internal topology with no upside.
|
|
69250
69328
|
*
|
|
69251
|
-
* Implementation in `@camstack/system/builtins/local-network/`.
|
|
69329
|
+
* Implementation in `@camstack/server/system/builtins/local-network/`.
|
|
69252
69330
|
*/
|
|
69253
69331
|
/** Coarse classification derived from the interface name + IP range. */
|
|
69254
69332
|
var InterfaceKindEnum = _enum([
|
|
@@ -71136,7 +71214,7 @@ onStatusChanged: { data: object({
|
|
|
71136
71214
|
* jitter, and observed/peak bandwidth per device + per client.
|
|
71137
71215
|
*
|
|
71138
71216
|
* Implementation lives in the server's `NetworkQualityService` (thin
|
|
71139
|
-
* wrapper over the shared `NetworkQualityTracker` from `@camstack/system`).
|
|
71217
|
+
* wrapper over the shared `NetworkQualityTracker` from `@camstack/server/system`).
|
|
71140
71218
|
* The provider is registered from `trpc.router.ts` against the existing
|
|
71141
71219
|
* service instance — no addon owns this state.
|
|
71142
71220
|
*
|
|
@@ -73287,7 +73365,7 @@ var ptzAutotrackCapability = {
|
|
|
73287
73365
|
* - **Native**: the camera's own firmware autotrack, registered per device by
|
|
73288
73366
|
* the driver when the probe says it exists (Reolink: yes; Hikvision:
|
|
73289
73367
|
* model-dependent).
|
|
73290
|
-
* - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
|
|
73368
|
+
* - **Wrapper**: the emulated implementation (`@camstack/server/system`'s `autotrack` builtin),
|
|
73291
73369
|
* which follows a subject with `ptz.move` pulses driven by the detection
|
|
73292
73370
|
* pipeline. `defaultActive: false` — the operator binds it per camera in
|
|
73293
73371
|
* the bindings UI.
|
|
@@ -95999,6 +96077,60 @@ function buildUnraidDeviceAdopter(input) {
|
|
|
95999
96077
|
};
|
|
96000
96078
|
}
|
|
96001
96079
|
//#endregion
|
|
96080
|
+
//#region src/unraid-reconciler.ts
|
|
96081
|
+
/**
|
|
96082
|
+
* Keeps one live client per enabled integration. Devices are removed ONLY on an explicit
|
|
96083
|
+
* lifecycle event naming the integration (D49): a list that failed, an empty list or an
|
|
96084
|
+
* unreadable connection changes nothing about devices and is logged, never read as "gone".
|
|
96085
|
+
*/
|
|
96086
|
+
var UnraidReconciler = class {
|
|
96087
|
+
#deps;
|
|
96088
|
+
constructor(deps) {
|
|
96089
|
+
this.#deps = deps;
|
|
96090
|
+
}
|
|
96091
|
+
/** Upsert a client per usable enabled integration; drop the CLIENT (never devices) of one the list answered is gone. */
|
|
96092
|
+
async reconcile() {
|
|
96093
|
+
const { logger, clients } = this.#deps;
|
|
96094
|
+
let all;
|
|
96095
|
+
try {
|
|
96096
|
+
all = await this.#deps.listIntegrations();
|
|
96097
|
+
} catch (err) {
|
|
96098
|
+
logger.warn("Unraid integration reconcile skipped — the integration list did not answer", { meta: { error: errMsg(err) } });
|
|
96099
|
+
return;
|
|
96100
|
+
}
|
|
96101
|
+
const enabled = all.filter((i) => i.addonId === this.#deps.addonId && i.enabled);
|
|
96102
|
+
for (const integration of enabled) try {
|
|
96103
|
+
if (!await this.#deps.applySettings(integration)) logger.warn("Unraid integration has no usable connection — left as it is", { meta: { integrationId: integration.id } });
|
|
96104
|
+
} catch (err) {
|
|
96105
|
+
logger.warn("Unraid reconcile failed for integration — left as it is", { meta: {
|
|
96106
|
+
integrationId: integration.id,
|
|
96107
|
+
error: errMsg(err)
|
|
96108
|
+
} });
|
|
96109
|
+
}
|
|
96110
|
+
const enabledIds = new Set(enabled.map((i) => i.id));
|
|
96111
|
+
for (const id of clients.list()) if (!enabledIds.has(id)) await clients.remove(id);
|
|
96112
|
+
}
|
|
96113
|
+
/** An explicit lifecycle event: only `deleted` / `disabled` of a named integration remove devices. */
|
|
96114
|
+
async onLifecycle(kind, integrationId) {
|
|
96115
|
+
await this.reconcile();
|
|
96116
|
+
if (kind === "enabled" || integrationId === null) return;
|
|
96117
|
+
try {
|
|
96118
|
+
const removed = await this.#deps.removeDevices(integrationId);
|
|
96119
|
+
this.#deps.logger.info("Unraid integration devices removed", { meta: {
|
|
96120
|
+
integrationId,
|
|
96121
|
+
kind,
|
|
96122
|
+
removed
|
|
96123
|
+
} });
|
|
96124
|
+
} catch (err) {
|
|
96125
|
+
this.#deps.logger.warn("Unraid integration device removal failed", { meta: {
|
|
96126
|
+
integrationId,
|
|
96127
|
+
kind,
|
|
96128
|
+
error: errMsg(err)
|
|
96129
|
+
} });
|
|
96130
|
+
}
|
|
96131
|
+
}
|
|
96132
|
+
};
|
|
96133
|
+
//#endregion
|
|
96002
96134
|
//#region src/unraid-integration-device-cascade.ts
|
|
96003
96135
|
/**
|
|
96004
96136
|
* Remove every top-level device (Gateway and instance Container) of an integration that
|
|
@@ -96075,6 +96207,7 @@ var UnraidProviderAddon = class extends BaseDeviceProvider {
|
|
|
96075
96207
|
[DeviceType.Button]: UnraidEntityDevice,
|
|
96076
96208
|
[DeviceType.EventEmitter]: UnraidEntityDevice
|
|
96077
96209
|
};
|
|
96210
|
+
integrationReconciler = null;
|
|
96078
96211
|
clients = null;
|
|
96079
96212
|
constructor() {
|
|
96080
96213
|
super({});
|
|
@@ -96100,6 +96233,7 @@ var UnraidProviderAddon = class extends BaseDeviceProvider {
|
|
|
96100
96233
|
this.ctx.logger.warn("Unraid shutdown error", { meta: { error: errMsg(err) } });
|
|
96101
96234
|
}
|
|
96102
96235
|
this.clients = null;
|
|
96236
|
+
this.integrationReconciler = null;
|
|
96103
96237
|
unraidInstances.clear();
|
|
96104
96238
|
await super.onShutdown();
|
|
96105
96239
|
}
|
|
@@ -96116,51 +96250,47 @@ var UnraidProviderAddon = class extends BaseDeviceProvider {
|
|
|
96116
96250
|
return unraidStableId(integrationId, nativeId);
|
|
96117
96251
|
}
|
|
96118
96252
|
/**
|
|
96119
|
-
*
|
|
96120
|
-
*
|
|
96121
|
-
* runs at boot and on every integration lifecycle event.
|
|
96253
|
+
* Upsert one client per enabled integration and drop the client of one the list ANSWERED is
|
|
96254
|
+
* gone. Never removes a device (D49): that follows only an explicit lifecycle event.
|
|
96255
|
+
* Idempotent; runs at boot and on every integration lifecycle event.
|
|
96122
96256
|
*/
|
|
96123
|
-
|
|
96124
|
-
|
|
96125
|
-
|
|
96126
|
-
|
|
96127
|
-
|
|
96128
|
-
|
|
96257
|
+
reconciler() {
|
|
96258
|
+
this.integrationReconciler ??= new UnraidReconciler({
|
|
96259
|
+
addonId: this.ctx.id,
|
|
96260
|
+
logger: this.ctx.logger,
|
|
96261
|
+
clients: this.requireClients(),
|
|
96262
|
+
listIntegrations: () => this.ctx.api.integrations.list.query(),
|
|
96263
|
+
applySettings: async (integration) => {
|
|
96264
|
+
const reg = this.requireClients();
|
|
96129
96265
|
const read = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
|
|
96130
|
-
if (read === null)
|
|
96131
|
-
this.ctx.logger.warn("Unraid integration has no server host — skipping", { meta: { integrationId: integration.id } });
|
|
96132
|
-
continue;
|
|
96133
|
-
}
|
|
96266
|
+
if (read === null) return false;
|
|
96134
96267
|
await reg.upsert(integration.id, integration.name, read.connection, read.apiKeyLocked);
|
|
96135
|
-
|
|
96136
|
-
}
|
|
96137
|
-
|
|
96138
|
-
|
|
96139
|
-
|
|
96140
|
-
|
|
96141
|
-
|
|
96142
|
-
|
|
96143
|
-
await reg.retain(surviving);
|
|
96144
|
-
for (const integrationId of vanished) await this.cascadeRemoveDevicesForIntegration(integrationId);
|
|
96145
|
-
} catch (err) {
|
|
96146
|
-
this.ctx.logger.warn("Unraid integration reconcile failed", { meta: { error: errMsg(err) } });
|
|
96147
|
-
}
|
|
96268
|
+
return true;
|
|
96269
|
+
},
|
|
96270
|
+
removeDevices: (integrationId) => this.cascadeRemoveDevicesForIntegration(integrationId)
|
|
96271
|
+
});
|
|
96272
|
+
return this.integrationReconciler;
|
|
96273
|
+
}
|
|
96274
|
+
async reconcileIntegrations() {
|
|
96275
|
+
await this.reconciler().reconcile();
|
|
96148
96276
|
}
|
|
96277
|
+
/** Lifecycle events: only an explicit Deleted/Disabled naming an integration removes devices. */
|
|
96149
96278
|
subscribeIntegrationLifecycle() {
|
|
96150
|
-
const
|
|
96279
|
+
const on = (kind) => (event) => {
|
|
96151
96280
|
const addonId = event.data["addonId"];
|
|
96152
96281
|
if (typeof addonId === "string" && addonId !== this.ctx.id) return;
|
|
96153
|
-
|
|
96282
|
+
const integrationId = event.data["integrationId"];
|
|
96283
|
+
this.reconciler().onLifecycle(kind, typeof integrationId === "string" ? integrationId : null);
|
|
96154
96284
|
};
|
|
96155
|
-
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled },
|
|
96156
|
-
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled },
|
|
96157
|
-
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted },
|
|
96285
|
+
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled }, on("enabled"));
|
|
96286
|
+
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled }, on("disabled"));
|
|
96287
|
+
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, on("deleted"));
|
|
96158
96288
|
}
|
|
96159
96289
|
async cascadeRemoveDevicesForIntegration(integrationId) {
|
|
96160
96290
|
const reg = this.ctx.kernel.deviceRegistry;
|
|
96161
96291
|
const devices = this.ctx.kernel.devices;
|
|
96162
|
-
if (!reg || !devices) return;
|
|
96163
|
-
await cascadeRemoveDevicesForIntegration({
|
|
96292
|
+
if (!reg || !devices) return 0;
|
|
96293
|
+
return await cascadeRemoveDevicesForIntegration({
|
|
96164
96294
|
reg,
|
|
96165
96295
|
devices,
|
|
96166
96296
|
addonId: this.addonId,
|
package/dist/addon.mjs
CHANGED
|
@@ -5830,7 +5830,7 @@ var ZodIssueCode = {
|
|
|
5830
5830
|
var ZodFirstPartyTypeKind;
|
|
5831
5831
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5832
5832
|
//#endregion
|
|
5833
|
-
//#region ../types/dist/sleep-
|
|
5833
|
+
//#region ../types/dist/sleep-CSYuxssh.mjs
|
|
5834
5834
|
/**
|
|
5835
5835
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5836
5836
|
* window to float samples (D455).
|
|
@@ -9113,7 +9113,7 @@ var ProfileRtspEntrySchema = object({
|
|
|
9113
9113
|
/**
|
|
9114
9114
|
* The model weight formats a catalog entry can ship. Schema-free on purpose:
|
|
9115
9115
|
* `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
|
|
9116
|
-
* (the model downloader in `@camstack/system`) needs only the list and must
|
|
9116
|
+
* (the model downloader in `@camstack/server/system`) needs only the list and must
|
|
9117
9117
|
* reach it through `@camstack/types/addon` without building the cap schema
|
|
9118
9118
|
* graph (D28).
|
|
9119
9119
|
*/
|
|
@@ -12488,6 +12488,71 @@ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
|
|
|
12488
12488
|
var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
|
|
12489
12489
|
new Set(EVENT_OWNER_TYPES);
|
|
12490
12490
|
/**
|
|
12491
|
+
* What a published package needs from the rest of the install (D989).
|
|
12492
|
+
*
|
|
12493
|
+
* One published framework package (`@camstack/server`) carries the kernel, the
|
|
12494
|
+
* builtins and the capability contracts, so "which addon runs on which
|
|
12495
|
+
* framework" is a question of version, and the answer is DECLARED by the
|
|
12496
|
+
* package that knows it:
|
|
12497
|
+
*
|
|
12498
|
+
* - an addon says the oldest server it runs on (`requires.server: ">=X"`);
|
|
12499
|
+
* - the server says the oldest addon it works with
|
|
12500
|
+
* (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
|
|
12501
|
+
* around it (`requires.wrapper: { desktop, image }`);
|
|
12502
|
+
* - a wrapper (the desktop app, the container starter) says which server
|
|
12503
|
+
* range it can host, and reports its own kind and version.
|
|
12504
|
+
*
|
|
12505
|
+
* The publish workflow STAMPS these after the version bump
|
|
12506
|
+
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
12507
|
+
*
|
|
12508
|
+
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
12509
|
+
* version counts as below the minimum, and an unreadable running version is
|
|
12510
|
+
* named in the result (a failed read is never a pass).
|
|
12511
|
+
*/
|
|
12512
|
+
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
12513
|
+
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
12514
|
+
object({
|
|
12515
|
+
/** The oldest `@camstack/server` this package runs on. */
|
|
12516
|
+
server: MinVersionSchema.optional(),
|
|
12517
|
+
/** The oldest installed version of each named addon package. */
|
|
12518
|
+
addons: record(string(), MinVersionSchema).optional(),
|
|
12519
|
+
/** The oldest shell around the server, per shell kind. */
|
|
12520
|
+
wrapper: object({
|
|
12521
|
+
desktop: MinVersionSchema.optional(),
|
|
12522
|
+
image: MinVersionSchema.optional()
|
|
12523
|
+
}).optional()
|
|
12524
|
+
});
|
|
12525
|
+
/** One unmet requirement; each names the versions on both sides. */
|
|
12526
|
+
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
12527
|
+
object({
|
|
12528
|
+
kind: literal("server-too-old"),
|
|
12529
|
+
required: string(),
|
|
12530
|
+
/** `null` — the running server version could not be read. */
|
|
12531
|
+
running: string().nullable()
|
|
12532
|
+
}),
|
|
12533
|
+
object({
|
|
12534
|
+
kind: literal("addon-too-old"),
|
|
12535
|
+
packageName: string(),
|
|
12536
|
+
required: string(),
|
|
12537
|
+
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
12538
|
+
running: string().nullable()
|
|
12539
|
+
}),
|
|
12540
|
+
object({
|
|
12541
|
+
kind: literal("wrapper-too-old"),
|
|
12542
|
+
wrapper: _enum(["desktop", "image"]),
|
|
12543
|
+
required: string(),
|
|
12544
|
+
/** `null` — the wrapper reported no version. */
|
|
12545
|
+
running: string().nullable()
|
|
12546
|
+
})
|
|
12547
|
+
]);
|
|
12548
|
+
var RequiredAddonUpdateSchema = object({
|
|
12549
|
+
packageName: string(),
|
|
12550
|
+
/** The minimum the target server declares. */
|
|
12551
|
+
required: string(),
|
|
12552
|
+
/** What this node has; `null` when the addon is not installed. */
|
|
12553
|
+
installed: string().nullable()
|
|
12554
|
+
});
|
|
12555
|
+
/**
|
|
12491
12556
|
* Which integration instance a settings form is for. An addon that serves several instances
|
|
12492
12557
|
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
12493
12558
|
* needs its connection, the default integration needs the addon's own sections.
|
|
@@ -42903,7 +42968,7 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
|
|
|
42903
42968
|
* rebuilds without manual reload.
|
|
42904
42969
|
*
|
|
42905
42970
|
* The hub-local builtin `addon-pages-aggregator` (see
|
|
42906
|
-
* `@camstack/system/builtins/addon-pages-aggregator`) registers the
|
|
42971
|
+
* `@camstack/server/system/builtins/addon-pages-aggregator`) registers the
|
|
42907
42972
|
* provider. Splitting the public aggregator from the raw collection
|
|
42908
42973
|
* keeps both ends in codegen — there's no hand-written
|
|
42909
42974
|
* `addon-pages.router.ts` wrapper anymore.
|
|
@@ -43203,7 +43268,7 @@ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
|
|
|
43203
43268
|
* manual reload — same scheme used by `addon-pages`.
|
|
43204
43269
|
*
|
|
43205
43270
|
* The hub-local builtin `addon-widgets-aggregator` (see
|
|
43206
|
-
* `@camstack/system/builtins/addon-widgets-aggregator`) registers the
|
|
43271
|
+
* `@camstack/server/system/builtins/addon-widgets-aggregator`) registers the
|
|
43207
43272
|
* provider. Splitting the public aggregator from the raw collection
|
|
43208
43273
|
* keeps both ends in codegen — there's no hand-written wrapper.
|
|
43209
43274
|
*/
|
|
@@ -61403,7 +61468,18 @@ var ServerUpdateActionResultSchema = object({
|
|
|
61403
61468
|
* store (D877), present when the pre-flight refused the update
|
|
61404
61469
|
* (`reason: 'addon-would-refuse'`). Optional for version skew.
|
|
61405
61470
|
*/
|
|
61406
|
-
blockers: array(UpdateBlockerSchema).optional()
|
|
61471
|
+
blockers: array(UpdateBlockerSchema).optional(),
|
|
61472
|
+
/**
|
|
61473
|
+
* The minimums the target server declares and this node does not meet
|
|
61474
|
+
* (D989), present when the update was refused with
|
|
61475
|
+
* `reason: 'requirements-unmet'`. Each names the versions on both sides.
|
|
61476
|
+
*/
|
|
61477
|
+
unmet: array(UnmetRequirementSchema).optional(),
|
|
61478
|
+
/**
|
|
61479
|
+
* The addons this node has below the minimum the staged server declares —
|
|
61480
|
+
* the ones to update WITH the server. Present on an accepted update.
|
|
61481
|
+
*/
|
|
61482
|
+
requiredAddonUpdates: array(RequiredAddonUpdateSchema).optional()
|
|
61407
61483
|
});
|
|
61408
61484
|
var LaunchOverridesSchema = object({
|
|
61409
61485
|
/** The persisted heap ceiling in MB, or `null` when none is set. */
|
|
@@ -63947,7 +64023,9 @@ var PackageUpdateSchema = object({
|
|
|
63947
64023
|
latestVersion: string(),
|
|
63948
64024
|
category: _enum(["addon", "core"]),
|
|
63949
64025
|
requiresRestart: boolean(),
|
|
63950
|
-
isSystem: boolean()
|
|
64026
|
+
isSystem: boolean(),
|
|
64027
|
+
/** Held: what the newer version needs and this node does not meet (D989). */
|
|
64028
|
+
blockedBy: array(UnmetRequirementSchema).readonly().optional()
|
|
63951
64029
|
});
|
|
63952
64030
|
var PackageVersionInfoSchema = object({
|
|
63953
64031
|
version: string(),
|
|
@@ -69247,7 +69325,7 @@ var lawnMowerControlCapability = {
|
|
|
69247
69325
|
* clients — they reverse-connect to the hub. Exposing their interfaces
|
|
69248
69326
|
* via the same surface would leak internal topology with no upside.
|
|
69249
69327
|
*
|
|
69250
|
-
* Implementation in `@camstack/system/builtins/local-network/`.
|
|
69328
|
+
* Implementation in `@camstack/server/system/builtins/local-network/`.
|
|
69251
69329
|
*/
|
|
69252
69330
|
/** Coarse classification derived from the interface name + IP range. */
|
|
69253
69331
|
var InterfaceKindEnum = _enum([
|
|
@@ -71135,7 +71213,7 @@ onStatusChanged: { data: object({
|
|
|
71135
71213
|
* jitter, and observed/peak bandwidth per device + per client.
|
|
71136
71214
|
*
|
|
71137
71215
|
* Implementation lives in the server's `NetworkQualityService` (thin
|
|
71138
|
-
* wrapper over the shared `NetworkQualityTracker` from `@camstack/system`).
|
|
71216
|
+
* wrapper over the shared `NetworkQualityTracker` from `@camstack/server/system`).
|
|
71139
71217
|
* The provider is registered from `trpc.router.ts` against the existing
|
|
71140
71218
|
* service instance — no addon owns this state.
|
|
71141
71219
|
*
|
|
@@ -73286,7 +73364,7 @@ var ptzAutotrackCapability = {
|
|
|
73286
73364
|
* - **Native**: the camera's own firmware autotrack, registered per device by
|
|
73287
73365
|
* the driver when the probe says it exists (Reolink: yes; Hikvision:
|
|
73288
73366
|
* model-dependent).
|
|
73289
|
-
* - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
|
|
73367
|
+
* - **Wrapper**: the emulated implementation (`@camstack/server/system`'s `autotrack` builtin),
|
|
73290
73368
|
* which follows a subject with `ptz.move` pulses driven by the detection
|
|
73291
73369
|
* pipeline. `defaultActive: false` — the operator binds it per camera in
|
|
73292
73370
|
* the bindings UI.
|
|
@@ -95998,6 +96076,60 @@ function buildUnraidDeviceAdopter(input) {
|
|
|
95998
96076
|
};
|
|
95999
96077
|
}
|
|
96000
96078
|
//#endregion
|
|
96079
|
+
//#region src/unraid-reconciler.ts
|
|
96080
|
+
/**
|
|
96081
|
+
* Keeps one live client per enabled integration. Devices are removed ONLY on an explicit
|
|
96082
|
+
* lifecycle event naming the integration (D49): a list that failed, an empty list or an
|
|
96083
|
+
* unreadable connection changes nothing about devices and is logged, never read as "gone".
|
|
96084
|
+
*/
|
|
96085
|
+
var UnraidReconciler = class {
|
|
96086
|
+
#deps;
|
|
96087
|
+
constructor(deps) {
|
|
96088
|
+
this.#deps = deps;
|
|
96089
|
+
}
|
|
96090
|
+
/** Upsert a client per usable enabled integration; drop the CLIENT (never devices) of one the list answered is gone. */
|
|
96091
|
+
async reconcile() {
|
|
96092
|
+
const { logger, clients } = this.#deps;
|
|
96093
|
+
let all;
|
|
96094
|
+
try {
|
|
96095
|
+
all = await this.#deps.listIntegrations();
|
|
96096
|
+
} catch (err) {
|
|
96097
|
+
logger.warn("Unraid integration reconcile skipped — the integration list did not answer", { meta: { error: errMsg(err) } });
|
|
96098
|
+
return;
|
|
96099
|
+
}
|
|
96100
|
+
const enabled = all.filter((i) => i.addonId === this.#deps.addonId && i.enabled);
|
|
96101
|
+
for (const integration of enabled) try {
|
|
96102
|
+
if (!await this.#deps.applySettings(integration)) logger.warn("Unraid integration has no usable connection — left as it is", { meta: { integrationId: integration.id } });
|
|
96103
|
+
} catch (err) {
|
|
96104
|
+
logger.warn("Unraid reconcile failed for integration — left as it is", { meta: {
|
|
96105
|
+
integrationId: integration.id,
|
|
96106
|
+
error: errMsg(err)
|
|
96107
|
+
} });
|
|
96108
|
+
}
|
|
96109
|
+
const enabledIds = new Set(enabled.map((i) => i.id));
|
|
96110
|
+
for (const id of clients.list()) if (!enabledIds.has(id)) await clients.remove(id);
|
|
96111
|
+
}
|
|
96112
|
+
/** An explicit lifecycle event: only `deleted` / `disabled` of a named integration remove devices. */
|
|
96113
|
+
async onLifecycle(kind, integrationId) {
|
|
96114
|
+
await this.reconcile();
|
|
96115
|
+
if (kind === "enabled" || integrationId === null) return;
|
|
96116
|
+
try {
|
|
96117
|
+
const removed = await this.#deps.removeDevices(integrationId);
|
|
96118
|
+
this.#deps.logger.info("Unraid integration devices removed", { meta: {
|
|
96119
|
+
integrationId,
|
|
96120
|
+
kind,
|
|
96121
|
+
removed
|
|
96122
|
+
} });
|
|
96123
|
+
} catch (err) {
|
|
96124
|
+
this.#deps.logger.warn("Unraid integration device removal failed", { meta: {
|
|
96125
|
+
integrationId,
|
|
96126
|
+
kind,
|
|
96127
|
+
error: errMsg(err)
|
|
96128
|
+
} });
|
|
96129
|
+
}
|
|
96130
|
+
}
|
|
96131
|
+
};
|
|
96132
|
+
//#endregion
|
|
96001
96133
|
//#region src/unraid-integration-device-cascade.ts
|
|
96002
96134
|
/**
|
|
96003
96135
|
* Remove every top-level device (Gateway and instance Container) of an integration that
|
|
@@ -96074,6 +96206,7 @@ var UnraidProviderAddon = class extends BaseDeviceProvider {
|
|
|
96074
96206
|
[DeviceType.Button]: UnraidEntityDevice,
|
|
96075
96207
|
[DeviceType.EventEmitter]: UnraidEntityDevice
|
|
96076
96208
|
};
|
|
96209
|
+
integrationReconciler = null;
|
|
96077
96210
|
clients = null;
|
|
96078
96211
|
constructor() {
|
|
96079
96212
|
super({});
|
|
@@ -96099,6 +96232,7 @@ var UnraidProviderAddon = class extends BaseDeviceProvider {
|
|
|
96099
96232
|
this.ctx.logger.warn("Unraid shutdown error", { meta: { error: errMsg(err) } });
|
|
96100
96233
|
}
|
|
96101
96234
|
this.clients = null;
|
|
96235
|
+
this.integrationReconciler = null;
|
|
96102
96236
|
unraidInstances.clear();
|
|
96103
96237
|
await super.onShutdown();
|
|
96104
96238
|
}
|
|
@@ -96115,51 +96249,47 @@ var UnraidProviderAddon = class extends BaseDeviceProvider {
|
|
|
96115
96249
|
return unraidStableId(integrationId, nativeId);
|
|
96116
96250
|
}
|
|
96117
96251
|
/**
|
|
96118
|
-
*
|
|
96119
|
-
*
|
|
96120
|
-
* runs at boot and on every integration lifecycle event.
|
|
96252
|
+
* Upsert one client per enabled integration and drop the client of one the list ANSWERED is
|
|
96253
|
+
* gone. Never removes a device (D49): that follows only an explicit lifecycle event.
|
|
96254
|
+
* Idempotent; runs at boot and on every integration lifecycle event.
|
|
96121
96255
|
*/
|
|
96122
|
-
|
|
96123
|
-
|
|
96124
|
-
|
|
96125
|
-
|
|
96126
|
-
|
|
96127
|
-
|
|
96256
|
+
reconciler() {
|
|
96257
|
+
this.integrationReconciler ??= new UnraidReconciler({
|
|
96258
|
+
addonId: this.ctx.id,
|
|
96259
|
+
logger: this.ctx.logger,
|
|
96260
|
+
clients: this.requireClients(),
|
|
96261
|
+
listIntegrations: () => this.ctx.api.integrations.list.query(),
|
|
96262
|
+
applySettings: async (integration) => {
|
|
96263
|
+
const reg = this.requireClients();
|
|
96128
96264
|
const read = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
|
|
96129
|
-
if (read === null)
|
|
96130
|
-
this.ctx.logger.warn("Unraid integration has no server host — skipping", { meta: { integrationId: integration.id } });
|
|
96131
|
-
continue;
|
|
96132
|
-
}
|
|
96265
|
+
if (read === null) return false;
|
|
96133
96266
|
await reg.upsert(integration.id, integration.name, read.connection, read.apiKeyLocked);
|
|
96134
|
-
|
|
96135
|
-
}
|
|
96136
|
-
|
|
96137
|
-
|
|
96138
|
-
|
|
96139
|
-
|
|
96140
|
-
|
|
96141
|
-
|
|
96142
|
-
await reg.retain(surviving);
|
|
96143
|
-
for (const integrationId of vanished) await this.cascadeRemoveDevicesForIntegration(integrationId);
|
|
96144
|
-
} catch (err) {
|
|
96145
|
-
this.ctx.logger.warn("Unraid integration reconcile failed", { meta: { error: errMsg(err) } });
|
|
96146
|
-
}
|
|
96267
|
+
return true;
|
|
96268
|
+
},
|
|
96269
|
+
removeDevices: (integrationId) => this.cascadeRemoveDevicesForIntegration(integrationId)
|
|
96270
|
+
});
|
|
96271
|
+
return this.integrationReconciler;
|
|
96272
|
+
}
|
|
96273
|
+
async reconcileIntegrations() {
|
|
96274
|
+
await this.reconciler().reconcile();
|
|
96147
96275
|
}
|
|
96276
|
+
/** Lifecycle events: only an explicit Deleted/Disabled naming an integration removes devices. */
|
|
96148
96277
|
subscribeIntegrationLifecycle() {
|
|
96149
|
-
const
|
|
96278
|
+
const on = (kind) => (event) => {
|
|
96150
96279
|
const addonId = event.data["addonId"];
|
|
96151
96280
|
if (typeof addonId === "string" && addonId !== this.ctx.id) return;
|
|
96152
|
-
|
|
96281
|
+
const integrationId = event.data["integrationId"];
|
|
96282
|
+
this.reconciler().onLifecycle(kind, typeof integrationId === "string" ? integrationId : null);
|
|
96153
96283
|
};
|
|
96154
|
-
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled },
|
|
96155
|
-
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled },
|
|
96156
|
-
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted },
|
|
96284
|
+
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled }, on("enabled"));
|
|
96285
|
+
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled }, on("disabled"));
|
|
96286
|
+
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, on("deleted"));
|
|
96157
96287
|
}
|
|
96158
96288
|
async cascadeRemoveDevicesForIntegration(integrationId) {
|
|
96159
96289
|
const reg = this.ctx.kernel.deviceRegistry;
|
|
96160
96290
|
const devices = this.ctx.kernel.devices;
|
|
96161
|
-
if (!reg || !devices) return;
|
|
96162
|
-
await cascadeRemoveDevicesForIntegration({
|
|
96291
|
+
if (!reg || !devices) return 0;
|
|
96292
|
+
return await cascadeRemoveDevicesForIntegration({
|
|
96163
96293
|
reg,
|
|
96164
96294
|
devices,
|
|
96165
96295
|
addonId: this.addonId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-unraid",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.153",
|
|
4
4
|
"description": "Unraid device-provider addon for CamStack — one Container per Unraid instance fanning out array, disk, docker and notification entities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|
|
@@ -57,7 +57,10 @@
|
|
|
57
57
|
}
|
|
58
58
|
]
|
|
59
59
|
}
|
|
60
|
-
]
|
|
60
|
+
],
|
|
61
|
+
"requires": {
|
|
62
|
+
"server": ">=1.2.719"
|
|
63
|
+
}
|
|
61
64
|
},
|
|
62
65
|
"files": [
|
|
63
66
|
"dist",
|