@camstack/addon-provider-amcrest 0.2.37 → 0.2.39
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/addon.js +127 -0
- package/dist/addon.mjs +127 -0
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5921,6 +5921,40 @@ var BaseAddon = class {
|
|
|
5921
5921
|
deviceSettingsSchema() {
|
|
5922
5922
|
return null;
|
|
5923
5923
|
}
|
|
5924
|
+
/**
|
|
5925
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
5926
|
+
* ARE the configuration of its integration.
|
|
5927
|
+
*
|
|
5928
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
5929
|
+
* operator should find on the addon's integration page (System →
|
|
5930
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
5931
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
5932
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
5933
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
5934
|
+
* nature of the integration.
|
|
5935
|
+
*
|
|
5936
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
5937
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
5938
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
5939
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
5940
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
5941
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
5942
|
+
*
|
|
5943
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
5944
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
5945
|
+
* removed with the reason recorded at
|
|
5946
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
5947
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
5948
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
5949
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
5950
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
5951
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
5952
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
5953
|
+
* ids it names.
|
|
5954
|
+
*/
|
|
5955
|
+
integrationSettingSections() {
|
|
5956
|
+
return [];
|
|
5957
|
+
}
|
|
5924
5958
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5925
5959
|
const schema = this.globalSettingsSchema(cap);
|
|
5926
5960
|
if (!schema) return { sections: [] };
|
|
@@ -5931,6 +5965,55 @@ var BaseAddon = class {
|
|
|
5931
5965
|
} : projected);
|
|
5932
5966
|
}
|
|
5933
5967
|
/**
|
|
5968
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
5969
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
5970
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
5971
|
+
*
|
|
5972
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
5973
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
5974
|
+
* as a failed load.
|
|
5975
|
+
*
|
|
5976
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
5977
|
+
* and not in whichever UI happens to render this:
|
|
5978
|
+
*
|
|
5979
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
5980
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
5981
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
5982
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
5983
|
+
* not merely discouraged.
|
|
5984
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
5985
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
5986
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
5987
|
+
* who opened the page (D266).
|
|
5988
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
5989
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
5990
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
5991
|
+
*/
|
|
5992
|
+
async getIntegrationSettings(nodeId) {
|
|
5993
|
+
const declared = this.integrationSettingSections();
|
|
5994
|
+
if (declared.length === 0) return null;
|
|
5995
|
+
const schema = this.globalSettingsSchema();
|
|
5996
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
5997
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
5998
|
+
const sections = [];
|
|
5999
|
+
for (const id of declared) {
|
|
6000
|
+
const section = byId.get(id);
|
|
6001
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6002
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6003
|
+
if (fields.length === 0) continue;
|
|
6004
|
+
sections.push({
|
|
6005
|
+
...section,
|
|
6006
|
+
fields
|
|
6007
|
+
});
|
|
6008
|
+
}
|
|
6009
|
+
if (sections.length === 0) return null;
|
|
6010
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6011
|
+
return hydrateSchema({
|
|
6012
|
+
...schema,
|
|
6013
|
+
sections
|
|
6014
|
+
}, projected);
|
|
6015
|
+
}
|
|
6016
|
+
/**
|
|
5934
6017
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5935
6018
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5936
6019
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -6234,6 +6317,41 @@ var BaseAddon = class {
|
|
|
6234
6317
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6235
6318
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6236
6319
|
*/
|
|
6320
|
+
/**
|
|
6321
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
6322
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
6323
|
+
* with no child is dropped rather than rendered empty.
|
|
6324
|
+
*
|
|
6325
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
6326
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
6327
|
+
*/
|
|
6328
|
+
function dropPerNodeFields(fields) {
|
|
6329
|
+
const kept = [];
|
|
6330
|
+
for (const field of fields) {
|
|
6331
|
+
if (field.type === "group") {
|
|
6332
|
+
const inner = dropPerNodeFields(field.fields);
|
|
6333
|
+
if (inner.length > 0) kept.push({
|
|
6334
|
+
...field,
|
|
6335
|
+
fields: inner
|
|
6336
|
+
});
|
|
6337
|
+
continue;
|
|
6338
|
+
}
|
|
6339
|
+
if (field.type === "sub-tabs") {
|
|
6340
|
+
const tabs = field.tabs.map((tab) => ({
|
|
6341
|
+
...tab,
|
|
6342
|
+
fields: dropPerNodeFields(tab.fields)
|
|
6343
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
6344
|
+
if (tabs.length > 0) kept.push({
|
|
6345
|
+
...field,
|
|
6346
|
+
tabs
|
|
6347
|
+
});
|
|
6348
|
+
continue;
|
|
6349
|
+
}
|
|
6350
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
6351
|
+
kept.push(field);
|
|
6352
|
+
}
|
|
6353
|
+
return kept;
|
|
6354
|
+
}
|
|
6237
6355
|
function collectPerNodeFieldKeys(fields) {
|
|
6238
6356
|
const collected = [];
|
|
6239
6357
|
for (const field of fields) {
|
|
@@ -9391,6 +9509,9 @@ method(object({
|
|
|
9391
9509
|
kind: "mutation",
|
|
9392
9510
|
auth: "admin"
|
|
9393
9511
|
}), method(object({
|
|
9512
|
+
addonId: string(),
|
|
9513
|
+
nodeId: string().optional()
|
|
9514
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
9394
9515
|
addonId: string(),
|
|
9395
9516
|
deviceId: number(),
|
|
9396
9517
|
nodeId: string().optional()
|
|
@@ -32080,6 +32201,12 @@ Object.freeze({
|
|
|
32080
32201
|
addonId: null,
|
|
32081
32202
|
access: "view"
|
|
32082
32203
|
},
|
|
32204
|
+
"addonSettings.getIntegrationSettings": {
|
|
32205
|
+
capName: "addon-settings",
|
|
32206
|
+
capScope: "system",
|
|
32207
|
+
addonId: null,
|
|
32208
|
+
access: "view"
|
|
32209
|
+
},
|
|
32083
32210
|
"addonSettings.updateDeviceSettings": {
|
|
32084
32211
|
capName: "addon-settings",
|
|
32085
32212
|
capScope: "system",
|
package/dist/addon.mjs
CHANGED
|
@@ -5922,6 +5922,40 @@ var BaseAddon = class {
|
|
|
5922
5922
|
deviceSettingsSchema() {
|
|
5923
5923
|
return null;
|
|
5924
5924
|
}
|
|
5925
|
+
/**
|
|
5926
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
5927
|
+
* ARE the configuration of its integration.
|
|
5928
|
+
*
|
|
5929
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
5930
|
+
* operator should find on the addon's integration page (System →
|
|
5931
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
5932
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
5933
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
5934
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
5935
|
+
* nature of the integration.
|
|
5936
|
+
*
|
|
5937
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
5938
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
5939
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
5940
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
5941
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
5942
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
5943
|
+
*
|
|
5944
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
5945
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
5946
|
+
* removed with the reason recorded at
|
|
5947
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
5948
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
5949
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
5950
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
5951
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
5952
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
5953
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
5954
|
+
* ids it names.
|
|
5955
|
+
*/
|
|
5956
|
+
integrationSettingSections() {
|
|
5957
|
+
return [];
|
|
5958
|
+
}
|
|
5925
5959
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5926
5960
|
const schema = this.globalSettingsSchema(cap);
|
|
5927
5961
|
if (!schema) return { sections: [] };
|
|
@@ -5932,6 +5966,55 @@ var BaseAddon = class {
|
|
|
5932
5966
|
} : projected);
|
|
5933
5967
|
}
|
|
5934
5968
|
/**
|
|
5969
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
5970
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
5971
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
5972
|
+
*
|
|
5973
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
5974
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
5975
|
+
* as a failed load.
|
|
5976
|
+
*
|
|
5977
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
5978
|
+
* and not in whichever UI happens to render this:
|
|
5979
|
+
*
|
|
5980
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
5981
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
5982
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
5983
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
5984
|
+
* not merely discouraged.
|
|
5985
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
5986
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
5987
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
5988
|
+
* who opened the page (D266).
|
|
5989
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
5990
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
5991
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
5992
|
+
*/
|
|
5993
|
+
async getIntegrationSettings(nodeId) {
|
|
5994
|
+
const declared = this.integrationSettingSections();
|
|
5995
|
+
if (declared.length === 0) return null;
|
|
5996
|
+
const schema = this.globalSettingsSchema();
|
|
5997
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
5998
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
5999
|
+
const sections = [];
|
|
6000
|
+
for (const id of declared) {
|
|
6001
|
+
const section = byId.get(id);
|
|
6002
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6003
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6004
|
+
if (fields.length === 0) continue;
|
|
6005
|
+
sections.push({
|
|
6006
|
+
...section,
|
|
6007
|
+
fields
|
|
6008
|
+
});
|
|
6009
|
+
}
|
|
6010
|
+
if (sections.length === 0) return null;
|
|
6011
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6012
|
+
return hydrateSchema({
|
|
6013
|
+
...schema,
|
|
6014
|
+
sections
|
|
6015
|
+
}, projected);
|
|
6016
|
+
}
|
|
6017
|
+
/**
|
|
5935
6018
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5936
6019
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5937
6020
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -6235,6 +6318,41 @@ var BaseAddon = class {
|
|
|
6235
6318
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6236
6319
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6237
6320
|
*/
|
|
6321
|
+
/**
|
|
6322
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
6323
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
6324
|
+
* with no child is dropped rather than rendered empty.
|
|
6325
|
+
*
|
|
6326
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
6327
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
6328
|
+
*/
|
|
6329
|
+
function dropPerNodeFields(fields) {
|
|
6330
|
+
const kept = [];
|
|
6331
|
+
for (const field of fields) {
|
|
6332
|
+
if (field.type === "group") {
|
|
6333
|
+
const inner = dropPerNodeFields(field.fields);
|
|
6334
|
+
if (inner.length > 0) kept.push({
|
|
6335
|
+
...field,
|
|
6336
|
+
fields: inner
|
|
6337
|
+
});
|
|
6338
|
+
continue;
|
|
6339
|
+
}
|
|
6340
|
+
if (field.type === "sub-tabs") {
|
|
6341
|
+
const tabs = field.tabs.map((tab) => ({
|
|
6342
|
+
...tab,
|
|
6343
|
+
fields: dropPerNodeFields(tab.fields)
|
|
6344
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
6345
|
+
if (tabs.length > 0) kept.push({
|
|
6346
|
+
...field,
|
|
6347
|
+
tabs
|
|
6348
|
+
});
|
|
6349
|
+
continue;
|
|
6350
|
+
}
|
|
6351
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
6352
|
+
kept.push(field);
|
|
6353
|
+
}
|
|
6354
|
+
return kept;
|
|
6355
|
+
}
|
|
6238
6356
|
function collectPerNodeFieldKeys(fields) {
|
|
6239
6357
|
const collected = [];
|
|
6240
6358
|
for (const field of fields) {
|
|
@@ -9392,6 +9510,9 @@ method(object({
|
|
|
9392
9510
|
kind: "mutation",
|
|
9393
9511
|
auth: "admin"
|
|
9394
9512
|
}), method(object({
|
|
9513
|
+
addonId: string(),
|
|
9514
|
+
nodeId: string().optional()
|
|
9515
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
9395
9516
|
addonId: string(),
|
|
9396
9517
|
deviceId: number(),
|
|
9397
9518
|
nodeId: string().optional()
|
|
@@ -32081,6 +32202,12 @@ Object.freeze({
|
|
|
32081
32202
|
addonId: null,
|
|
32082
32203
|
access: "view"
|
|
32083
32204
|
},
|
|
32205
|
+
"addonSettings.getIntegrationSettings": {
|
|
32206
|
+
capName: "addon-settings",
|
|
32207
|
+
capScope: "system",
|
|
32208
|
+
addonId: null,
|
|
32209
|
+
access: "view"
|
|
32210
|
+
},
|
|
32084
32211
|
"addonSettings.updateDeviceSettings": {
|
|
32085
32212
|
capName: "addon-settings",
|
|
32086
32213
|
capScope: "system",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-amcrest",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.39",
|
|
4
4
|
"description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|