@camstack/addon-provider-hikvision 1.2.44 → 1.2.45

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