@camstack/addon-provider-dreame 0.2.36 → 0.2.38

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
@@ -56421,6 +56421,40 @@ var BaseAddon = class {
56421
56421
  deviceSettingsSchema() {
56422
56422
  return null;
56423
56423
  }
56424
+ /**
56425
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
56426
+ * ARE the configuration of its integration.
56427
+ *
56428
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
56429
+ * operator should find on the addon's integration page (System →
56430
+ * Integrations → <name>) rather than only in the cluster-wide list of every
56431
+ * addon. Empty (the default) means the addon has no integration-level
56432
+ * settings and no such surface is offered — this is opt-in, because whether
56433
+ * an addon's configuration IS its integration's configuration depends on the
56434
+ * nature of the integration.
56435
+ *
56436
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
56437
+ * the ONE global schema, in the ONE addon store, written by the ONE
56438
+ * `updateGlobalSettings` path. There is deliberately no
56439
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
56440
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
56441
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
56442
+ *
56443
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
56444
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
56445
+ * removed with the reason recorded at
56446
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
56447
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
56448
+ * marker sprinkled across sections also has to borrow a field that already
56449
+ * means something else; borrowing `section.tab` put the literal word
56450
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
56451
+ * GROUP this visually" and cannot also mean "where this lives" (D269
56452
+ * supersedes D268). One declaration, in one place, next to the schema whose
56453
+ * ids it names.
56454
+ */
56455
+ integrationSettingSections() {
56456
+ return [];
56457
+ }
56424
56458
  async getGlobalSettings(overlay, cap, nodeId) {
56425
56459
  const schema = this.globalSettingsSchema(cap);
56426
56460
  if (!schema) return { sections: [] };
@@ -56431,6 +56465,55 @@ var BaseAddon = class {
56431
56465
  } : projected);
56432
56466
  }
56433
56467
  /**
56468
+ * The integration-level view of this addon's settings: exactly the sections
56469
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
56470
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
56471
+ *
56472
+ * Returns `null` when the addon declared nothing — an addon that opts out has
56473
+ * no integration settings surface at all, rather than an empty one that reads
56474
+ * as a failed load.
56475
+ *
56476
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
56477
+ * and not in whichever UI happens to render this:
56478
+ *
56479
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
56480
+ * shown here is the same field, with the same bare key, that the addon's
56481
+ * own page shows. There is no integration-specific writer — callers save
56482
+ * through `updateGlobalSettings` — so a second store key is unreachable,
56483
+ * not merely discouraged.
56484
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
56485
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
56486
+ * such a field silently picked would be a wrong answer for the operator
56487
+ * who opened the page (D266).
56488
+ * 3. **No silent typo.** A declared id that names no section throws. The
56489
+ * alternative — skip it — turns a rename into a surface that quietly
56490
+ * empties, which looks exactly like an addon with nothing to configure.
56491
+ */
56492
+ async getIntegrationSettings(nodeId) {
56493
+ const declared = this.integrationSettingSections();
56494
+ if (declared.length === 0) return null;
56495
+ const schema = this.globalSettingsSchema();
56496
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
56497
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
56498
+ const sections = [];
56499
+ for (const id of declared) {
56500
+ const section = byId.get(id);
56501
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
56502
+ const fields = dropPerNodeFields(section.fields);
56503
+ if (fields.length === 0) continue;
56504
+ sections.push({
56505
+ ...section,
56506
+ fields
56507
+ });
56508
+ }
56509
+ if (sections.length === 0) return null;
56510
+ const projected = await this.resolveGlobalStore(nodeId);
56511
+ return hydrateSchema({
56512
+ ...schema,
56513
+ sections
56514
+ }, projected);
56515
+ }
56516
+ /**
56434
56517
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
56435
56518
  * every `perNode: true` field carries THAT node's scoped value on its bare
56436
56519
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -56734,6 +56817,41 @@ var BaseAddon = class {
56734
56817
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
56735
56818
  * don't declare `perNode` and are excluded by the `in` narrowing.
56736
56819
  */
56820
+ /**
56821
+ * The same fields with every `perNode: true` one removed, recursing into layout
56822
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
56823
+ * with no child is dropped rather than rendered empty.
56824
+ *
56825
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
56826
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
56827
+ */
56828
+ function dropPerNodeFields(fields) {
56829
+ const kept = [];
56830
+ for (const field of fields) {
56831
+ if (field.type === "group") {
56832
+ const inner = dropPerNodeFields(field.fields);
56833
+ if (inner.length > 0) kept.push({
56834
+ ...field,
56835
+ fields: inner
56836
+ });
56837
+ continue;
56838
+ }
56839
+ if (field.type === "sub-tabs") {
56840
+ const tabs = field.tabs.map((tab) => ({
56841
+ ...tab,
56842
+ fields: dropPerNodeFields(tab.fields)
56843
+ })).filter((tab) => tab.fields.length > 0);
56844
+ if (tabs.length > 0) kept.push({
56845
+ ...field,
56846
+ tabs
56847
+ });
56848
+ continue;
56849
+ }
56850
+ if ("perNode" in field && field.perNode === true) continue;
56851
+ kept.push(field);
56852
+ }
56853
+ return kept;
56854
+ }
56737
56855
  function collectPerNodeFieldKeys(fields) {
56738
56856
  const collected = [];
56739
56857
  for (const field of fields) {
@@ -59903,6 +60021,9 @@ method(object({
59903
60021
  kind: "mutation",
59904
60022
  auth: "admin"
59905
60023
  }), method(object({
60024
+ addonId: string(),
60025
+ nodeId: string().optional()
60026
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
59906
60027
  addonId: string(),
59907
60028
  deviceId: number(),
59908
60029
  nodeId: string().optional()
@@ -82038,6 +82159,12 @@ Object.freeze({
82038
82159
  addonId: null,
82039
82160
  access: "view"
82040
82161
  },
82162
+ "addonSettings.getIntegrationSettings": {
82163
+ capName: "addon-settings",
82164
+ capScope: "system",
82165
+ addonId: null,
82166
+ access: "view"
82167
+ },
82041
82168
  "addonSettings.updateDeviceSettings": {
82042
82169
  capName: "addon-settings",
82043
82170
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -56421,6 +56421,40 @@ var BaseAddon = class {
56421
56421
  deviceSettingsSchema() {
56422
56422
  return null;
56423
56423
  }
56424
+ /**
56425
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
56426
+ * ARE the configuration of its integration.
56427
+ *
56428
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
56429
+ * operator should find on the addon's integration page (System →
56430
+ * Integrations → <name>) rather than only in the cluster-wide list of every
56431
+ * addon. Empty (the default) means the addon has no integration-level
56432
+ * settings and no such surface is offered — this is opt-in, because whether
56433
+ * an addon's configuration IS its integration's configuration depends on the
56434
+ * nature of the integration.
56435
+ *
56436
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
56437
+ * the ONE global schema, in the ONE addon store, written by the ONE
56438
+ * `updateGlobalSettings` path. There is deliberately no
56439
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
56440
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
56441
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
56442
+ *
56443
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
56444
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
56445
+ * removed with the reason recorded at
56446
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
56447
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
56448
+ * marker sprinkled across sections also has to borrow a field that already
56449
+ * means something else; borrowing `section.tab` put the literal word
56450
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
56451
+ * GROUP this visually" and cannot also mean "where this lives" (D269
56452
+ * supersedes D268). One declaration, in one place, next to the schema whose
56453
+ * ids it names.
56454
+ */
56455
+ integrationSettingSections() {
56456
+ return [];
56457
+ }
56424
56458
  async getGlobalSettings(overlay, cap, nodeId) {
56425
56459
  const schema = this.globalSettingsSchema(cap);
56426
56460
  if (!schema) return { sections: [] };
@@ -56431,6 +56465,55 @@ var BaseAddon = class {
56431
56465
  } : projected);
56432
56466
  }
56433
56467
  /**
56468
+ * The integration-level view of this addon's settings: exactly the sections
56469
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
56470
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
56471
+ *
56472
+ * Returns `null` when the addon declared nothing — an addon that opts out has
56473
+ * no integration settings surface at all, rather than an empty one that reads
56474
+ * as a failed load.
56475
+ *
56476
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
56477
+ * and not in whichever UI happens to render this:
56478
+ *
56479
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
56480
+ * shown here is the same field, with the same bare key, that the addon's
56481
+ * own page shows. There is no integration-specific writer — callers save
56482
+ * through `updateGlobalSettings` — so a second store key is unreachable,
56483
+ * not merely discouraged.
56484
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
56485
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
56486
+ * such a field silently picked would be a wrong answer for the operator
56487
+ * who opened the page (D266).
56488
+ * 3. **No silent typo.** A declared id that names no section throws. The
56489
+ * alternative — skip it — turns a rename into a surface that quietly
56490
+ * empties, which looks exactly like an addon with nothing to configure.
56491
+ */
56492
+ async getIntegrationSettings(nodeId) {
56493
+ const declared = this.integrationSettingSections();
56494
+ if (declared.length === 0) return null;
56495
+ const schema = this.globalSettingsSchema();
56496
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
56497
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
56498
+ const sections = [];
56499
+ for (const id of declared) {
56500
+ const section = byId.get(id);
56501
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
56502
+ const fields = dropPerNodeFields(section.fields);
56503
+ if (fields.length === 0) continue;
56504
+ sections.push({
56505
+ ...section,
56506
+ fields
56507
+ });
56508
+ }
56509
+ if (sections.length === 0) return null;
56510
+ const projected = await this.resolveGlobalStore(nodeId);
56511
+ return hydrateSchema({
56512
+ ...schema,
56513
+ sections
56514
+ }, projected);
56515
+ }
56516
+ /**
56434
56517
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
56435
56518
  * every `perNode: true` field carries THAT node's scoped value on its bare
56436
56519
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -56734,6 +56817,41 @@ var BaseAddon = class {
56734
56817
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
56735
56818
  * don't declare `perNode` and are excluded by the `in` narrowing.
56736
56819
  */
56820
+ /**
56821
+ * The same fields with every `perNode: true` one removed, recursing into layout
56822
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
56823
+ * with no child is dropped rather than rendered empty.
56824
+ *
56825
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
56826
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
56827
+ */
56828
+ function dropPerNodeFields(fields) {
56829
+ const kept = [];
56830
+ for (const field of fields) {
56831
+ if (field.type === "group") {
56832
+ const inner = dropPerNodeFields(field.fields);
56833
+ if (inner.length > 0) kept.push({
56834
+ ...field,
56835
+ fields: inner
56836
+ });
56837
+ continue;
56838
+ }
56839
+ if (field.type === "sub-tabs") {
56840
+ const tabs = field.tabs.map((tab) => ({
56841
+ ...tab,
56842
+ fields: dropPerNodeFields(tab.fields)
56843
+ })).filter((tab) => tab.fields.length > 0);
56844
+ if (tabs.length > 0) kept.push({
56845
+ ...field,
56846
+ tabs
56847
+ });
56848
+ continue;
56849
+ }
56850
+ if ("perNode" in field && field.perNode === true) continue;
56851
+ kept.push(field);
56852
+ }
56853
+ return kept;
56854
+ }
56737
56855
  function collectPerNodeFieldKeys(fields) {
56738
56856
  const collected = [];
56739
56857
  for (const field of fields) {
@@ -59903,6 +60021,9 @@ method(object({
59903
60021
  kind: "mutation",
59904
60022
  auth: "admin"
59905
60023
  }), method(object({
60024
+ addonId: string(),
60025
+ nodeId: string().optional()
60026
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
59906
60027
  addonId: string(),
59907
60028
  deviceId: number(),
59908
60029
  nodeId: string().optional()
@@ -82038,6 +82159,12 @@ Object.freeze({
82038
82159
  addonId: null,
82039
82160
  access: "view"
82040
82161
  },
82162
+ "addonSettings.getIntegrationSettings": {
82163
+ capName: "addon-settings",
82164
+ capScope: "system",
82165
+ addonId: null,
82166
+ access: "view"
82167
+ },
82041
82168
  "addonSettings.updateDeviceSettings": {
82042
82169
  capName: "addon-settings",
82043
82170
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-dreame",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "description": "Dreame robot-vacuum / lawn-mower device-provider addon for CamStack — wraps the @apocaliss92/nodedreame Dreamehome cloud client",
5
5
  "keywords": [
6
6
  "camstack",