@camstack/addon-notifiers 1.2.41 → 1.2.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/addon.js CHANGED
@@ -5946,6 +5946,40 @@ var BaseAddon = class {
5946
5946
  deviceSettingsSchema() {
5947
5947
  return null;
5948
5948
  }
5949
+ /**
5950
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5951
+ * ARE the configuration of its integration.
5952
+ *
5953
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5954
+ * operator should find on the addon's integration page (System →
5955
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5956
+ * addon. Empty (the default) means the addon has no integration-level
5957
+ * settings and no such surface is offered — this is opt-in, because whether
5958
+ * an addon's configuration IS its integration's configuration depends on the
5959
+ * nature of the integration.
5960
+ *
5961
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5962
+ * the ONE global schema, in the ONE addon store, written by the ONE
5963
+ * `updateGlobalSettings` path. There is deliberately no
5964
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5965
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5966
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5967
+ *
5968
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5969
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5970
+ * removed with the reason recorded at
5971
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5972
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5973
+ * marker sprinkled across sections also has to borrow a field that already
5974
+ * means something else; borrowing `section.tab` put the literal word
5975
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5976
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5977
+ * supersedes D268). One declaration, in one place, next to the schema whose
5978
+ * ids it names.
5979
+ */
5980
+ integrationSettingSections() {
5981
+ return [];
5982
+ }
5949
5983
  async getGlobalSettings(overlay, cap, nodeId) {
5950
5984
  const schema = this.globalSettingsSchema(cap);
5951
5985
  if (!schema) return { sections: [] };
@@ -5956,6 +5990,55 @@ var BaseAddon = class {
5956
5990
  } : projected);
5957
5991
  }
5958
5992
  /**
5993
+ * The integration-level view of this addon's settings: exactly the sections
5994
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5995
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5996
+ *
5997
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5998
+ * no integration settings surface at all, rather than an empty one that reads
5999
+ * as a failed load.
6000
+ *
6001
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6002
+ * and not in whichever UI happens to render this:
6003
+ *
6004
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6005
+ * shown here is the same field, with the same bare key, that the addon's
6006
+ * own page shows. There is no integration-specific writer — callers save
6007
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6008
+ * not merely discouraged.
6009
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6010
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6011
+ * such a field silently picked would be a wrong answer for the operator
6012
+ * who opened the page (D266).
6013
+ * 3. **No silent typo.** A declared id that names no section throws. The
6014
+ * alternative — skip it — turns a rename into a surface that quietly
6015
+ * empties, which looks exactly like an addon with nothing to configure.
6016
+ */
6017
+ async getIntegrationSettings(nodeId) {
6018
+ const declared = this.integrationSettingSections();
6019
+ if (declared.length === 0) return null;
6020
+ const schema = this.globalSettingsSchema();
6021
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6022
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6023
+ const sections = [];
6024
+ for (const id of declared) {
6025
+ const section = byId.get(id);
6026
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6027
+ const fields = dropPerNodeFields(section.fields);
6028
+ if (fields.length === 0) continue;
6029
+ sections.push({
6030
+ ...section,
6031
+ fields
6032
+ });
6033
+ }
6034
+ if (sections.length === 0) return null;
6035
+ const projected = await this.resolveGlobalStore(nodeId);
6036
+ return hydrateSchema({
6037
+ ...schema,
6038
+ sections
6039
+ }, projected);
6040
+ }
6041
+ /**
5959
6042
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5960
6043
  * every `perNode: true` field carries THAT node's scoped value on its bare
5961
6044
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6259,6 +6342,41 @@ var BaseAddon = class {
6259
6342
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6260
6343
  * don't declare `perNode` and are excluded by the `in` narrowing.
6261
6344
  */
6345
+ /**
6346
+ * The same fields with every `perNode: true` one removed, recursing into layout
6347
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6348
+ * with no child is dropped rather than rendered empty.
6349
+ *
6350
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6351
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6352
+ */
6353
+ function dropPerNodeFields(fields) {
6354
+ const kept = [];
6355
+ for (const field of fields) {
6356
+ if (field.type === "group") {
6357
+ const inner = dropPerNodeFields(field.fields);
6358
+ if (inner.length > 0) kept.push({
6359
+ ...field,
6360
+ fields: inner
6361
+ });
6362
+ continue;
6363
+ }
6364
+ if (field.type === "sub-tabs") {
6365
+ const tabs = field.tabs.map((tab) => ({
6366
+ ...tab,
6367
+ fields: dropPerNodeFields(tab.fields)
6368
+ })).filter((tab) => tab.fields.length > 0);
6369
+ if (tabs.length > 0) kept.push({
6370
+ ...field,
6371
+ tabs
6372
+ });
6373
+ continue;
6374
+ }
6375
+ if ("perNode" in field && field.perNode === true) continue;
6376
+ kept.push(field);
6377
+ }
6378
+ return kept;
6379
+ }
6262
6380
  function collectPerNodeFieldKeys(fields) {
6263
6381
  const collected = [];
6264
6382
  for (const field of fields) {
@@ -9550,6 +9668,9 @@ method(object({
9550
9668
  kind: "mutation",
9551
9669
  auth: "admin"
9552
9670
  }), method(object({
9671
+ addonId: string(),
9672
+ nodeId: string().optional()
9673
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9553
9674
  addonId: string(),
9554
9675
  deviceId: number(),
9555
9676
  nodeId: string().optional()
@@ -27980,6 +28101,12 @@ Object.freeze({
27980
28101
  addonId: null,
27981
28102
  access: "view"
27982
28103
  },
28104
+ "addonSettings.getIntegrationSettings": {
28105
+ capName: "addon-settings",
28106
+ capScope: "system",
28107
+ addonId: null,
28108
+ access: "view"
28109
+ },
27983
28110
  "addonSettings.updateDeviceSettings": {
27984
28111
  capName: "addon-settings",
27985
28112
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5919,6 +5919,40 @@ var BaseAddon = class {
5919
5919
  deviceSettingsSchema() {
5920
5920
  return null;
5921
5921
  }
5922
+ /**
5923
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5924
+ * ARE the configuration of its integration.
5925
+ *
5926
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5927
+ * operator should find on the addon's integration page (System →
5928
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5929
+ * addon. Empty (the default) means the addon has no integration-level
5930
+ * settings and no such surface is offered — this is opt-in, because whether
5931
+ * an addon's configuration IS its integration's configuration depends on the
5932
+ * nature of the integration.
5933
+ *
5934
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5935
+ * the ONE global schema, in the ONE addon store, written by the ONE
5936
+ * `updateGlobalSettings` path. There is deliberately no
5937
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5938
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5939
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5940
+ *
5941
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5942
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5943
+ * removed with the reason recorded at
5944
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5945
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5946
+ * marker sprinkled across sections also has to borrow a field that already
5947
+ * means something else; borrowing `section.tab` put the literal word
5948
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5949
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5950
+ * supersedes D268). One declaration, in one place, next to the schema whose
5951
+ * ids it names.
5952
+ */
5953
+ integrationSettingSections() {
5954
+ return [];
5955
+ }
5922
5956
  async getGlobalSettings(overlay, cap, nodeId) {
5923
5957
  const schema = this.globalSettingsSchema(cap);
5924
5958
  if (!schema) return { sections: [] };
@@ -5929,6 +5963,55 @@ var BaseAddon = class {
5929
5963
  } : projected);
5930
5964
  }
5931
5965
  /**
5966
+ * The integration-level view of this addon's settings: exactly the sections
5967
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5968
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5969
+ *
5970
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5971
+ * no integration settings surface at all, rather than an empty one that reads
5972
+ * as a failed load.
5973
+ *
5974
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5975
+ * and not in whichever UI happens to render this:
5976
+ *
5977
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5978
+ * shown here is the same field, with the same bare key, that the addon's
5979
+ * own page shows. There is no integration-specific writer — callers save
5980
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5981
+ * not merely discouraged.
5982
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5983
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5984
+ * such a field silently picked would be a wrong answer for the operator
5985
+ * who opened the page (D266).
5986
+ * 3. **No silent typo.** A declared id that names no section throws. The
5987
+ * alternative — skip it — turns a rename into a surface that quietly
5988
+ * empties, which looks exactly like an addon with nothing to configure.
5989
+ */
5990
+ async getIntegrationSettings(nodeId) {
5991
+ const declared = this.integrationSettingSections();
5992
+ if (declared.length === 0) return null;
5993
+ const schema = this.globalSettingsSchema();
5994
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5995
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5996
+ const sections = [];
5997
+ for (const id of declared) {
5998
+ const section = byId.get(id);
5999
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6000
+ const fields = dropPerNodeFields(section.fields);
6001
+ if (fields.length === 0) continue;
6002
+ sections.push({
6003
+ ...section,
6004
+ fields
6005
+ });
6006
+ }
6007
+ if (sections.length === 0) return null;
6008
+ const projected = await this.resolveGlobalStore(nodeId);
6009
+ return hydrateSchema({
6010
+ ...schema,
6011
+ sections
6012
+ }, projected);
6013
+ }
6014
+ /**
5932
6015
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5933
6016
  * every `perNode: true` field carries THAT node's scoped value on its bare
5934
6017
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6232,6 +6315,41 @@ var BaseAddon = class {
6232
6315
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6233
6316
  * don't declare `perNode` and are excluded by the `in` narrowing.
6234
6317
  */
6318
+ /**
6319
+ * The same fields with every `perNode: true` one removed, recursing into layout
6320
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6321
+ * with no child is dropped rather than rendered empty.
6322
+ *
6323
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6324
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6325
+ */
6326
+ function dropPerNodeFields(fields) {
6327
+ const kept = [];
6328
+ for (const field of fields) {
6329
+ if (field.type === "group") {
6330
+ const inner = dropPerNodeFields(field.fields);
6331
+ if (inner.length > 0) kept.push({
6332
+ ...field,
6333
+ fields: inner
6334
+ });
6335
+ continue;
6336
+ }
6337
+ if (field.type === "sub-tabs") {
6338
+ const tabs = field.tabs.map((tab) => ({
6339
+ ...tab,
6340
+ fields: dropPerNodeFields(tab.fields)
6341
+ })).filter((tab) => tab.fields.length > 0);
6342
+ if (tabs.length > 0) kept.push({
6343
+ ...field,
6344
+ tabs
6345
+ });
6346
+ continue;
6347
+ }
6348
+ if ("perNode" in field && field.perNode === true) continue;
6349
+ kept.push(field);
6350
+ }
6351
+ return kept;
6352
+ }
6235
6353
  function collectPerNodeFieldKeys(fields) {
6236
6354
  const collected = [];
6237
6355
  for (const field of fields) {
@@ -9523,6 +9641,9 @@ method(object({
9523
9641
  kind: "mutation",
9524
9642
  auth: "admin"
9525
9643
  }), method(object({
9644
+ addonId: string(),
9645
+ nodeId: string().optional()
9646
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9526
9647
  addonId: string(),
9527
9648
  deviceId: number(),
9528
9649
  nodeId: string().optional()
@@ -27953,6 +28074,12 @@ Object.freeze({
27953
28074
  addonId: null,
27954
28075
  access: "view"
27955
28076
  },
28077
+ "addonSettings.getIntegrationSettings": {
28078
+ capName: "addon-settings",
28079
+ capScope: "system",
28080
+ addonId: null,
28081
+ access: "view"
28082
+ },
27956
28083
  "addonSettings.updateDeviceSettings": {
27957
28084
  capName: "addon-settings",
27958
28085
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-notifiers",
3
- "version": "1.2.41",
3
+ "version": "1.2.42",
4
4
  "description": "System notifiers addon for CamStack — a `notification-output` collection provider hosting per-kind notifier adapters (ntfy, pushover, gotify, telegram, discord, webhook, zentik).",
5
5
  "keywords": [
6
6
  "camstack",