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