@camstack/addon-provider-tuya 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 +127 -0
- package/dist/addon.mjs +127 -0
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -6736,6 +6736,40 @@ var BaseAddon = class {
|
|
|
6736
6736
|
deviceSettingsSchema() {
|
|
6737
6737
|
return null;
|
|
6738
6738
|
}
|
|
6739
|
+
/**
|
|
6740
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
6741
|
+
* ARE the configuration of its integration.
|
|
6742
|
+
*
|
|
6743
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
6744
|
+
* operator should find on the addon's integration page (System →
|
|
6745
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
6746
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
6747
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
6748
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
6749
|
+
* nature of the integration.
|
|
6750
|
+
*
|
|
6751
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
6752
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
6753
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
6754
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
6755
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
6756
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
6757
|
+
*
|
|
6758
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
6759
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
6760
|
+
* removed with the reason recorded at
|
|
6761
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
6762
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
6763
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
6764
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
6765
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
6766
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
6767
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
6768
|
+
* ids it names.
|
|
6769
|
+
*/
|
|
6770
|
+
integrationSettingSections() {
|
|
6771
|
+
return [];
|
|
6772
|
+
}
|
|
6739
6773
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
6740
6774
|
const schema = this.globalSettingsSchema(cap);
|
|
6741
6775
|
if (!schema) return { sections: [] };
|
|
@@ -6746,6 +6780,55 @@ var BaseAddon = class {
|
|
|
6746
6780
|
} : projected);
|
|
6747
6781
|
}
|
|
6748
6782
|
/**
|
|
6783
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
6784
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
6785
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
6786
|
+
*
|
|
6787
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
6788
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
6789
|
+
* as a failed load.
|
|
6790
|
+
*
|
|
6791
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
6792
|
+
* and not in whichever UI happens to render this:
|
|
6793
|
+
*
|
|
6794
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
6795
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
6796
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
6797
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
6798
|
+
* not merely discouraged.
|
|
6799
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
6800
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
6801
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
6802
|
+
* who opened the page (D266).
|
|
6803
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
6804
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
6805
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
6806
|
+
*/
|
|
6807
|
+
async getIntegrationSettings(nodeId) {
|
|
6808
|
+
const declared = this.integrationSettingSections();
|
|
6809
|
+
if (declared.length === 0) return null;
|
|
6810
|
+
const schema = this.globalSettingsSchema();
|
|
6811
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
6812
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
6813
|
+
const sections = [];
|
|
6814
|
+
for (const id of declared) {
|
|
6815
|
+
const section = byId.get(id);
|
|
6816
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6817
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6818
|
+
if (fields.length === 0) continue;
|
|
6819
|
+
sections.push({
|
|
6820
|
+
...section,
|
|
6821
|
+
fields
|
|
6822
|
+
});
|
|
6823
|
+
}
|
|
6824
|
+
if (sections.length === 0) return null;
|
|
6825
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6826
|
+
return hydrateSchema({
|
|
6827
|
+
...schema,
|
|
6828
|
+
sections
|
|
6829
|
+
}, projected);
|
|
6830
|
+
}
|
|
6831
|
+
/**
|
|
6749
6832
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
6750
6833
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
6751
6834
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -7049,6 +7132,41 @@ var BaseAddon = class {
|
|
|
7049
7132
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
7050
7133
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
7051
7134
|
*/
|
|
7135
|
+
/**
|
|
7136
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
7137
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
7138
|
+
* with no child is dropped rather than rendered empty.
|
|
7139
|
+
*
|
|
7140
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
7141
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
7142
|
+
*/
|
|
7143
|
+
function dropPerNodeFields(fields) {
|
|
7144
|
+
const kept = [];
|
|
7145
|
+
for (const field of fields) {
|
|
7146
|
+
if (field.type === "group") {
|
|
7147
|
+
const inner = dropPerNodeFields(field.fields);
|
|
7148
|
+
if (inner.length > 0) kept.push({
|
|
7149
|
+
...field,
|
|
7150
|
+
fields: inner
|
|
7151
|
+
});
|
|
7152
|
+
continue;
|
|
7153
|
+
}
|
|
7154
|
+
if (field.type === "sub-tabs") {
|
|
7155
|
+
const tabs = field.tabs.map((tab) => ({
|
|
7156
|
+
...tab,
|
|
7157
|
+
fields: dropPerNodeFields(tab.fields)
|
|
7158
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
7159
|
+
if (tabs.length > 0) kept.push({
|
|
7160
|
+
...field,
|
|
7161
|
+
tabs
|
|
7162
|
+
});
|
|
7163
|
+
continue;
|
|
7164
|
+
}
|
|
7165
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
7166
|
+
kept.push(field);
|
|
7167
|
+
}
|
|
7168
|
+
return kept;
|
|
7169
|
+
}
|
|
7052
7170
|
function collectPerNodeFieldKeys(fields) {
|
|
7053
7171
|
const collected = [];
|
|
7054
7172
|
for (const field of fields) {
|
|
@@ -10218,6 +10336,9 @@ method(object({
|
|
|
10218
10336
|
kind: "mutation",
|
|
10219
10337
|
auth: "admin"
|
|
10220
10338
|
}), method(object({
|
|
10339
|
+
addonId: string(),
|
|
10340
|
+
nodeId: string().optional()
|
|
10341
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
10221
10342
|
addonId: string(),
|
|
10222
10343
|
deviceId: number(),
|
|
10223
10344
|
nodeId: string().optional()
|
|
@@ -32336,6 +32457,12 @@ Object.freeze({
|
|
|
32336
32457
|
addonId: null,
|
|
32337
32458
|
access: "view"
|
|
32338
32459
|
},
|
|
32460
|
+
"addonSettings.getIntegrationSettings": {
|
|
32461
|
+
capName: "addon-settings",
|
|
32462
|
+
capScope: "system",
|
|
32463
|
+
addonId: null,
|
|
32464
|
+
access: "view"
|
|
32465
|
+
},
|
|
32339
32466
|
"addonSettings.updateDeviceSettings": {
|
|
32340
32467
|
capName: "addon-settings",
|
|
32341
32468
|
capScope: "system",
|
package/dist/addon.mjs
CHANGED
|
@@ -6735,6 +6735,40 @@ var BaseAddon = class {
|
|
|
6735
6735
|
deviceSettingsSchema() {
|
|
6736
6736
|
return null;
|
|
6737
6737
|
}
|
|
6738
|
+
/**
|
|
6739
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
6740
|
+
* ARE the configuration of its integration.
|
|
6741
|
+
*
|
|
6742
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
6743
|
+
* operator should find on the addon's integration page (System →
|
|
6744
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
6745
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
6746
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
6747
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
6748
|
+
* nature of the integration.
|
|
6749
|
+
*
|
|
6750
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
6751
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
6752
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
6753
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
6754
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
6755
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
6756
|
+
*
|
|
6757
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
6758
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
6759
|
+
* removed with the reason recorded at
|
|
6760
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
6761
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
6762
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
6763
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
6764
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
6765
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
6766
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
6767
|
+
* ids it names.
|
|
6768
|
+
*/
|
|
6769
|
+
integrationSettingSections() {
|
|
6770
|
+
return [];
|
|
6771
|
+
}
|
|
6738
6772
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
6739
6773
|
const schema = this.globalSettingsSchema(cap);
|
|
6740
6774
|
if (!schema) return { sections: [] };
|
|
@@ -6745,6 +6779,55 @@ var BaseAddon = class {
|
|
|
6745
6779
|
} : projected);
|
|
6746
6780
|
}
|
|
6747
6781
|
/**
|
|
6782
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
6783
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
6784
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
6785
|
+
*
|
|
6786
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
6787
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
6788
|
+
* as a failed load.
|
|
6789
|
+
*
|
|
6790
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
6791
|
+
* and not in whichever UI happens to render this:
|
|
6792
|
+
*
|
|
6793
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
6794
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
6795
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
6796
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
6797
|
+
* not merely discouraged.
|
|
6798
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
6799
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
6800
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
6801
|
+
* who opened the page (D266).
|
|
6802
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
6803
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
6804
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
6805
|
+
*/
|
|
6806
|
+
async getIntegrationSettings(nodeId) {
|
|
6807
|
+
const declared = this.integrationSettingSections();
|
|
6808
|
+
if (declared.length === 0) return null;
|
|
6809
|
+
const schema = this.globalSettingsSchema();
|
|
6810
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
6811
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
6812
|
+
const sections = [];
|
|
6813
|
+
for (const id of declared) {
|
|
6814
|
+
const section = byId.get(id);
|
|
6815
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6816
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6817
|
+
if (fields.length === 0) continue;
|
|
6818
|
+
sections.push({
|
|
6819
|
+
...section,
|
|
6820
|
+
fields
|
|
6821
|
+
});
|
|
6822
|
+
}
|
|
6823
|
+
if (sections.length === 0) return null;
|
|
6824
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6825
|
+
return hydrateSchema({
|
|
6826
|
+
...schema,
|
|
6827
|
+
sections
|
|
6828
|
+
}, projected);
|
|
6829
|
+
}
|
|
6830
|
+
/**
|
|
6748
6831
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
6749
6832
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
6750
6833
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -7048,6 +7131,41 @@ var BaseAddon = class {
|
|
|
7048
7131
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
7049
7132
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
7050
7133
|
*/
|
|
7134
|
+
/**
|
|
7135
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
7136
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
7137
|
+
* with no child is dropped rather than rendered empty.
|
|
7138
|
+
*
|
|
7139
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
7140
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
7141
|
+
*/
|
|
7142
|
+
function dropPerNodeFields(fields) {
|
|
7143
|
+
const kept = [];
|
|
7144
|
+
for (const field of fields) {
|
|
7145
|
+
if (field.type === "group") {
|
|
7146
|
+
const inner = dropPerNodeFields(field.fields);
|
|
7147
|
+
if (inner.length > 0) kept.push({
|
|
7148
|
+
...field,
|
|
7149
|
+
fields: inner
|
|
7150
|
+
});
|
|
7151
|
+
continue;
|
|
7152
|
+
}
|
|
7153
|
+
if (field.type === "sub-tabs") {
|
|
7154
|
+
const tabs = field.tabs.map((tab) => ({
|
|
7155
|
+
...tab,
|
|
7156
|
+
fields: dropPerNodeFields(tab.fields)
|
|
7157
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
7158
|
+
if (tabs.length > 0) kept.push({
|
|
7159
|
+
...field,
|
|
7160
|
+
tabs
|
|
7161
|
+
});
|
|
7162
|
+
continue;
|
|
7163
|
+
}
|
|
7164
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
7165
|
+
kept.push(field);
|
|
7166
|
+
}
|
|
7167
|
+
return kept;
|
|
7168
|
+
}
|
|
7051
7169
|
function collectPerNodeFieldKeys(fields) {
|
|
7052
7170
|
const collected = [];
|
|
7053
7171
|
for (const field of fields) {
|
|
@@ -10217,6 +10335,9 @@ method(object({
|
|
|
10217
10335
|
kind: "mutation",
|
|
10218
10336
|
auth: "admin"
|
|
10219
10337
|
}), method(object({
|
|
10338
|
+
addonId: string(),
|
|
10339
|
+
nodeId: string().optional()
|
|
10340
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
10220
10341
|
addonId: string(),
|
|
10221
10342
|
deviceId: number(),
|
|
10222
10343
|
nodeId: string().optional()
|
|
@@ -32335,6 +32456,12 @@ Object.freeze({
|
|
|
32335
32456
|
addonId: null,
|
|
32336
32457
|
access: "view"
|
|
32337
32458
|
},
|
|
32459
|
+
"addonSettings.getIntegrationSettings": {
|
|
32460
|
+
capName: "addon-settings",
|
|
32461
|
+
capScope: "system",
|
|
32462
|
+
addonId: null,
|
|
32463
|
+
access: "view"
|
|
32464
|
+
},
|
|
32338
32465
|
"addonSettings.updateDeviceSettings": {
|
|
32339
32466
|
capName: "addon-settings",
|
|
32340
32467
|
capScope: "system",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-tuya",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|