@camstack/addon-provider-rademacher 0.2.35 → 0.2.37

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
@@ -6901,6 +6901,40 @@ var BaseAddon = class {
6901
6901
  deviceSettingsSchema() {
6902
6902
  return null;
6903
6903
  }
6904
+ /**
6905
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
6906
+ * ARE the configuration of its integration.
6907
+ *
6908
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
6909
+ * operator should find on the addon's integration page (System →
6910
+ * Integrations → <name>) rather than only in the cluster-wide list of every
6911
+ * addon. Empty (the default) means the addon has no integration-level
6912
+ * settings and no such surface is offered — this is opt-in, because whether
6913
+ * an addon's configuration IS its integration's configuration depends on the
6914
+ * nature of the integration.
6915
+ *
6916
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
6917
+ * the ONE global schema, in the ONE addon store, written by the ONE
6918
+ * `updateGlobalSettings` path. There is deliberately no
6919
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
6920
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
6921
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
6922
+ *
6923
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
6924
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
6925
+ * removed with the reason recorded at
6926
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
6927
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
6928
+ * marker sprinkled across sections also has to borrow a field that already
6929
+ * means something else; borrowing `section.tab` put the literal word
6930
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
6931
+ * GROUP this visually" and cannot also mean "where this lives" (D269
6932
+ * supersedes D268). One declaration, in one place, next to the schema whose
6933
+ * ids it names.
6934
+ */
6935
+ integrationSettingSections() {
6936
+ return [];
6937
+ }
6904
6938
  async getGlobalSettings(overlay, cap, nodeId) {
6905
6939
  const schema = this.globalSettingsSchema(cap);
6906
6940
  if (!schema) return { sections: [] };
@@ -6911,6 +6945,55 @@ var BaseAddon = class {
6911
6945
  } : projected);
6912
6946
  }
6913
6947
  /**
6948
+ * The integration-level view of this addon's settings: exactly the sections
6949
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6950
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6951
+ *
6952
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6953
+ * no integration settings surface at all, rather than an empty one that reads
6954
+ * as a failed load.
6955
+ *
6956
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6957
+ * and not in whichever UI happens to render this:
6958
+ *
6959
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6960
+ * shown here is the same field, with the same bare key, that the addon's
6961
+ * own page shows. There is no integration-specific writer — callers save
6962
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6963
+ * not merely discouraged.
6964
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6965
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6966
+ * such a field silently picked would be a wrong answer for the operator
6967
+ * who opened the page (D266).
6968
+ * 3. **No silent typo.** A declared id that names no section throws. The
6969
+ * alternative — skip it — turns a rename into a surface that quietly
6970
+ * empties, which looks exactly like an addon with nothing to configure.
6971
+ */
6972
+ async getIntegrationSettings(nodeId) {
6973
+ const declared = this.integrationSettingSections();
6974
+ if (declared.length === 0) return null;
6975
+ const schema = this.globalSettingsSchema();
6976
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6977
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6978
+ const sections = [];
6979
+ for (const id of declared) {
6980
+ const section = byId.get(id);
6981
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6982
+ const fields = dropPerNodeFields(section.fields);
6983
+ if (fields.length === 0) continue;
6984
+ sections.push({
6985
+ ...section,
6986
+ fields
6987
+ });
6988
+ }
6989
+ if (sections.length === 0) return null;
6990
+ const projected = await this.resolveGlobalStore(nodeId);
6991
+ return hydrateSchema({
6992
+ ...schema,
6993
+ sections
6994
+ }, projected);
6995
+ }
6996
+ /**
6914
6997
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
6915
6998
  * every `perNode: true` field carries THAT node's scoped value on its bare
6916
6999
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -7214,6 +7297,41 @@ var BaseAddon = class {
7214
7297
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
7215
7298
  * don't declare `perNode` and are excluded by the `in` narrowing.
7216
7299
  */
7300
+ /**
7301
+ * The same fields with every `perNode: true` one removed, recursing into layout
7302
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
7303
+ * with no child is dropped rather than rendered empty.
7304
+ *
7305
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
7306
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
7307
+ */
7308
+ function dropPerNodeFields(fields) {
7309
+ const kept = [];
7310
+ for (const field of fields) {
7311
+ if (field.type === "group") {
7312
+ const inner = dropPerNodeFields(field.fields);
7313
+ if (inner.length > 0) kept.push({
7314
+ ...field,
7315
+ fields: inner
7316
+ });
7317
+ continue;
7318
+ }
7319
+ if (field.type === "sub-tabs") {
7320
+ const tabs = field.tabs.map((tab) => ({
7321
+ ...tab,
7322
+ fields: dropPerNodeFields(tab.fields)
7323
+ })).filter((tab) => tab.fields.length > 0);
7324
+ if (tabs.length > 0) kept.push({
7325
+ ...field,
7326
+ tabs
7327
+ });
7328
+ continue;
7329
+ }
7330
+ if ("perNode" in field && field.perNode === true) continue;
7331
+ kept.push(field);
7332
+ }
7333
+ return kept;
7334
+ }
7217
7335
  function collectPerNodeFieldKeys(fields) {
7218
7336
  const collected = [];
7219
7337
  for (const field of fields) {
@@ -10383,6 +10501,9 @@ method(object({
10383
10501
  kind: "mutation",
10384
10502
  auth: "admin"
10385
10503
  }), method(object({
10504
+ addonId: string(),
10505
+ nodeId: string().optional()
10506
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
10386
10507
  addonId: string(),
10387
10508
  deviceId: number(),
10388
10509
  nodeId: string().optional()
@@ -32476,6 +32597,12 @@ Object.freeze({
32476
32597
  addonId: null,
32477
32598
  access: "view"
32478
32599
  },
32600
+ "addonSettings.getIntegrationSettings": {
32601
+ capName: "addon-settings",
32602
+ capScope: "system",
32603
+ addonId: null,
32604
+ access: "view"
32605
+ },
32479
32606
  "addonSettings.updateDeviceSettings": {
32480
32607
  capName: "addon-settings",
32481
32608
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -6900,6 +6900,40 @@ var BaseAddon = class {
6900
6900
  deviceSettingsSchema() {
6901
6901
  return null;
6902
6902
  }
6903
+ /**
6904
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
6905
+ * ARE the configuration of its integration.
6906
+ *
6907
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
6908
+ * operator should find on the addon's integration page (System →
6909
+ * Integrations → <name>) rather than only in the cluster-wide list of every
6910
+ * addon. Empty (the default) means the addon has no integration-level
6911
+ * settings and no such surface is offered — this is opt-in, because whether
6912
+ * an addon's configuration IS its integration's configuration depends on the
6913
+ * nature of the integration.
6914
+ *
6915
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
6916
+ * the ONE global schema, in the ONE addon store, written by the ONE
6917
+ * `updateGlobalSettings` path. There is deliberately no
6918
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
6919
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
6920
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
6921
+ *
6922
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
6923
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
6924
+ * removed with the reason recorded at
6925
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
6926
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
6927
+ * marker sprinkled across sections also has to borrow a field that already
6928
+ * means something else; borrowing `section.tab` put the literal word
6929
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
6930
+ * GROUP this visually" and cannot also mean "where this lives" (D269
6931
+ * supersedes D268). One declaration, in one place, next to the schema whose
6932
+ * ids it names.
6933
+ */
6934
+ integrationSettingSections() {
6935
+ return [];
6936
+ }
6903
6937
  async getGlobalSettings(overlay, cap, nodeId) {
6904
6938
  const schema = this.globalSettingsSchema(cap);
6905
6939
  if (!schema) return { sections: [] };
@@ -6910,6 +6944,55 @@ var BaseAddon = class {
6910
6944
  } : projected);
6911
6945
  }
6912
6946
  /**
6947
+ * The integration-level view of this addon's settings: exactly the sections
6948
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6949
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6950
+ *
6951
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6952
+ * no integration settings surface at all, rather than an empty one that reads
6953
+ * as a failed load.
6954
+ *
6955
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6956
+ * and not in whichever UI happens to render this:
6957
+ *
6958
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6959
+ * shown here is the same field, with the same bare key, that the addon's
6960
+ * own page shows. There is no integration-specific writer — callers save
6961
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6962
+ * not merely discouraged.
6963
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6964
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6965
+ * such a field silently picked would be a wrong answer for the operator
6966
+ * who opened the page (D266).
6967
+ * 3. **No silent typo.** A declared id that names no section throws. The
6968
+ * alternative — skip it — turns a rename into a surface that quietly
6969
+ * empties, which looks exactly like an addon with nothing to configure.
6970
+ */
6971
+ async getIntegrationSettings(nodeId) {
6972
+ const declared = this.integrationSettingSections();
6973
+ if (declared.length === 0) return null;
6974
+ const schema = this.globalSettingsSchema();
6975
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6976
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6977
+ const sections = [];
6978
+ for (const id of declared) {
6979
+ const section = byId.get(id);
6980
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6981
+ const fields = dropPerNodeFields(section.fields);
6982
+ if (fields.length === 0) continue;
6983
+ sections.push({
6984
+ ...section,
6985
+ fields
6986
+ });
6987
+ }
6988
+ if (sections.length === 0) return null;
6989
+ const projected = await this.resolveGlobalStore(nodeId);
6990
+ return hydrateSchema({
6991
+ ...schema,
6992
+ sections
6993
+ }, projected);
6994
+ }
6995
+ /**
6913
6996
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
6914
6997
  * every `perNode: true` field carries THAT node's scoped value on its bare
6915
6998
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -7213,6 +7296,41 @@ var BaseAddon = class {
7213
7296
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
7214
7297
  * don't declare `perNode` and are excluded by the `in` narrowing.
7215
7298
  */
7299
+ /**
7300
+ * The same fields with every `perNode: true` one removed, recursing into layout
7301
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
7302
+ * with no child is dropped rather than rendered empty.
7303
+ *
7304
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
7305
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
7306
+ */
7307
+ function dropPerNodeFields(fields) {
7308
+ const kept = [];
7309
+ for (const field of fields) {
7310
+ if (field.type === "group") {
7311
+ const inner = dropPerNodeFields(field.fields);
7312
+ if (inner.length > 0) kept.push({
7313
+ ...field,
7314
+ fields: inner
7315
+ });
7316
+ continue;
7317
+ }
7318
+ if (field.type === "sub-tabs") {
7319
+ const tabs = field.tabs.map((tab) => ({
7320
+ ...tab,
7321
+ fields: dropPerNodeFields(tab.fields)
7322
+ })).filter((tab) => tab.fields.length > 0);
7323
+ if (tabs.length > 0) kept.push({
7324
+ ...field,
7325
+ tabs
7326
+ });
7327
+ continue;
7328
+ }
7329
+ if ("perNode" in field && field.perNode === true) continue;
7330
+ kept.push(field);
7331
+ }
7332
+ return kept;
7333
+ }
7216
7334
  function collectPerNodeFieldKeys(fields) {
7217
7335
  const collected = [];
7218
7336
  for (const field of fields) {
@@ -10382,6 +10500,9 @@ method(object({
10382
10500
  kind: "mutation",
10383
10501
  auth: "admin"
10384
10502
  }), method(object({
10503
+ addonId: string(),
10504
+ nodeId: string().optional()
10505
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
10385
10506
  addonId: string(),
10386
10507
  deviceId: number(),
10387
10508
  nodeId: string().optional()
@@ -32475,6 +32596,12 @@ Object.freeze({
32475
32596
  addonId: null,
32476
32597
  access: "view"
32477
32598
  },
32599
+ "addonSettings.getIntegrationSettings": {
32600
+ capName: "addon-settings",
32601
+ capScope: "system",
32602
+ addonId: null,
32603
+ access: "view"
32604
+ },
32478
32605
  "addonSettings.updateDeviceSettings": {
32479
32606
  capName: "addon-settings",
32480
32607
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rademacher",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "description": "Rademacher HomePilot device-provider addon for CamStack — wraps the @apocaliss92/noderademacher local-hub client (roller shutters over the cover cap)",
5
5
  "keywords": [
6
6
  "camstack",