@camstack/addon-post-analysis 1.2.135 → 1.2.137

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.
@@ -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) {
@@ -9669,6 +9787,9 @@ method(object({
9669
9787
  kind: "mutation",
9670
9788
  auth: "admin"
9671
9789
  }), method(object({
9790
+ addonId: string(),
9791
+ nodeId: string().optional()
9792
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9672
9793
  addonId: string(),
9673
9794
  deviceId: number(),
9674
9795
  nodeId: string().optional()
@@ -33016,6 +33137,12 @@ Object.freeze({
33016
33137
  addonId: null,
33017
33138
  access: "view"
33018
33139
  },
33140
+ "addonSettings.getIntegrationSettings": {
33141
+ capName: "addon-settings",
33142
+ capScope: "system",
33143
+ addonId: null,
33144
+ access: "view"
33145
+ },
33019
33146
  "addonSettings.updateDeviceSettings": {
33020
33147
  capName: "addon-settings",
33021
33148
  capScope: "system",
@@ -5915,6 +5915,40 @@ var BaseAddon = class {
5915
5915
  deviceSettingsSchema() {
5916
5916
  return null;
5917
5917
  }
5918
+ /**
5919
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5920
+ * ARE the configuration of its integration.
5921
+ *
5922
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5923
+ * operator should find on the addon's integration page (System →
5924
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5925
+ * addon. Empty (the default) means the addon has no integration-level
5926
+ * settings and no such surface is offered — this is opt-in, because whether
5927
+ * an addon's configuration IS its integration's configuration depends on the
5928
+ * nature of the integration.
5929
+ *
5930
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5931
+ * the ONE global schema, in the ONE addon store, written by the ONE
5932
+ * `updateGlobalSettings` path. There is deliberately no
5933
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5934
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5935
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5936
+ *
5937
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5938
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5939
+ * removed with the reason recorded at
5940
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5941
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5942
+ * marker sprinkled across sections also has to borrow a field that already
5943
+ * means something else; borrowing `section.tab` put the literal word
5944
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5945
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5946
+ * supersedes D268). One declaration, in one place, next to the schema whose
5947
+ * ids it names.
5948
+ */
5949
+ integrationSettingSections() {
5950
+ return [];
5951
+ }
5918
5952
  async getGlobalSettings(overlay, cap, nodeId) {
5919
5953
  const schema = this.globalSettingsSchema(cap);
5920
5954
  if (!schema) return { sections: [] };
@@ -5925,6 +5959,55 @@ var BaseAddon = class {
5925
5959
  } : projected);
5926
5960
  }
5927
5961
  /**
5962
+ * The integration-level view of this addon's settings: exactly the sections
5963
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5964
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5965
+ *
5966
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5967
+ * no integration settings surface at all, rather than an empty one that reads
5968
+ * as a failed load.
5969
+ *
5970
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5971
+ * and not in whichever UI happens to render this:
5972
+ *
5973
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5974
+ * shown here is the same field, with the same bare key, that the addon's
5975
+ * own page shows. There is no integration-specific writer — callers save
5976
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5977
+ * not merely discouraged.
5978
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5979
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5980
+ * such a field silently picked would be a wrong answer for the operator
5981
+ * who opened the page (D266).
5982
+ * 3. **No silent typo.** A declared id that names no section throws. The
5983
+ * alternative — skip it — turns a rename into a surface that quietly
5984
+ * empties, which looks exactly like an addon with nothing to configure.
5985
+ */
5986
+ async getIntegrationSettings(nodeId) {
5987
+ const declared = this.integrationSettingSections();
5988
+ if (declared.length === 0) return null;
5989
+ const schema = this.globalSettingsSchema();
5990
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5991
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5992
+ const sections = [];
5993
+ for (const id of declared) {
5994
+ const section = byId.get(id);
5995
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
5996
+ const fields = dropPerNodeFields(section.fields);
5997
+ if (fields.length === 0) continue;
5998
+ sections.push({
5999
+ ...section,
6000
+ fields
6001
+ });
6002
+ }
6003
+ if (sections.length === 0) return null;
6004
+ const projected = await this.resolveGlobalStore(nodeId);
6005
+ return hydrateSchema({
6006
+ ...schema,
6007
+ sections
6008
+ }, projected);
6009
+ }
6010
+ /**
5928
6011
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5929
6012
  * every `perNode: true` field carries THAT node's scoped value on its bare
5930
6013
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6228,6 +6311,41 @@ var BaseAddon = class {
6228
6311
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6229
6312
  * don't declare `perNode` and are excluded by the `in` narrowing.
6230
6313
  */
6314
+ /**
6315
+ * The same fields with every `perNode: true` one removed, recursing into layout
6316
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6317
+ * with no child is dropped rather than rendered empty.
6318
+ *
6319
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6320
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6321
+ */
6322
+ function dropPerNodeFields(fields) {
6323
+ const kept = [];
6324
+ for (const field of fields) {
6325
+ if (field.type === "group") {
6326
+ const inner = dropPerNodeFields(field.fields);
6327
+ if (inner.length > 0) kept.push({
6328
+ ...field,
6329
+ fields: inner
6330
+ });
6331
+ continue;
6332
+ }
6333
+ if (field.type === "sub-tabs") {
6334
+ const tabs = field.tabs.map((tab) => ({
6335
+ ...tab,
6336
+ fields: dropPerNodeFields(tab.fields)
6337
+ })).filter((tab) => tab.fields.length > 0);
6338
+ if (tabs.length > 0) kept.push({
6339
+ ...field,
6340
+ tabs
6341
+ });
6342
+ continue;
6343
+ }
6344
+ if ("perNode" in field && field.perNode === true) continue;
6345
+ kept.push(field);
6346
+ }
6347
+ return kept;
6348
+ }
6231
6349
  function collectPerNodeFieldKeys(fields) {
6232
6350
  const collected = [];
6233
6351
  for (const field of fields) {
@@ -9638,6 +9756,9 @@ method(object({
9638
9756
  kind: "mutation",
9639
9757
  auth: "admin"
9640
9758
  }), method(object({
9759
+ addonId: string(),
9760
+ nodeId: string().optional()
9761
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9641
9762
  addonId: string(),
9642
9763
  deviceId: number(),
9643
9764
  nodeId: string().optional()
@@ -32985,6 +33106,12 @@ Object.freeze({
32985
33106
  addonId: null,
32986
33107
  access: "view"
32987
33108
  },
33109
+ "addonSettings.getIntegrationSettings": {
33110
+ capName: "addon-settings",
33111
+ capScope: "system",
33112
+ addonId: null,
33113
+ access: "view"
33114
+ },
32988
33115
  "addonSettings.updateDeviceSettings": {
32989
33116
  capName: "addon-settings",
32990
33117
  capScope: "system",