@camstack/addon-import-alexa 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 +127 -0
- package/dist/addon.mjs +127 -0
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5955,6 +5955,40 @@ var BaseAddon = class {
|
|
|
5955
5955
|
deviceSettingsSchema() {
|
|
5956
5956
|
return null;
|
|
5957
5957
|
}
|
|
5958
|
+
/**
|
|
5959
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
5960
|
+
* ARE the configuration of its integration.
|
|
5961
|
+
*
|
|
5962
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
5963
|
+
* operator should find on the addon's integration page (System →
|
|
5964
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
5965
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
5966
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
5967
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
5968
|
+
* nature of the integration.
|
|
5969
|
+
*
|
|
5970
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
5971
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
5972
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
5973
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
5974
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
5975
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
5976
|
+
*
|
|
5977
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
5978
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
5979
|
+
* removed with the reason recorded at
|
|
5980
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
5981
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
5982
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
5983
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
5984
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
5985
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
5986
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
5987
|
+
* ids it names.
|
|
5988
|
+
*/
|
|
5989
|
+
integrationSettingSections() {
|
|
5990
|
+
return [];
|
|
5991
|
+
}
|
|
5958
5992
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5959
5993
|
const schema = this.globalSettingsSchema(cap);
|
|
5960
5994
|
if (!schema) return { sections: [] };
|
|
@@ -5965,6 +5999,55 @@ var BaseAddon = class {
|
|
|
5965
5999
|
} : projected);
|
|
5966
6000
|
}
|
|
5967
6001
|
/**
|
|
6002
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
6003
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
6004
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
6005
|
+
*
|
|
6006
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
6007
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
6008
|
+
* as a failed load.
|
|
6009
|
+
*
|
|
6010
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
6011
|
+
* and not in whichever UI happens to render this:
|
|
6012
|
+
*
|
|
6013
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
6014
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
6015
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
6016
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
6017
|
+
* not merely discouraged.
|
|
6018
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
6019
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
6020
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
6021
|
+
* who opened the page (D266).
|
|
6022
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
6023
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
6024
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
6025
|
+
*/
|
|
6026
|
+
async getIntegrationSettings(nodeId) {
|
|
6027
|
+
const declared = this.integrationSettingSections();
|
|
6028
|
+
if (declared.length === 0) return null;
|
|
6029
|
+
const schema = this.globalSettingsSchema();
|
|
6030
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
6031
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
6032
|
+
const sections = [];
|
|
6033
|
+
for (const id of declared) {
|
|
6034
|
+
const section = byId.get(id);
|
|
6035
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6036
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6037
|
+
if (fields.length === 0) continue;
|
|
6038
|
+
sections.push({
|
|
6039
|
+
...section,
|
|
6040
|
+
fields
|
|
6041
|
+
});
|
|
6042
|
+
}
|
|
6043
|
+
if (sections.length === 0) return null;
|
|
6044
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6045
|
+
return hydrateSchema({
|
|
6046
|
+
...schema,
|
|
6047
|
+
sections
|
|
6048
|
+
}, projected);
|
|
6049
|
+
}
|
|
6050
|
+
/**
|
|
5968
6051
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5969
6052
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5970
6053
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -6268,6 +6351,41 @@ var BaseAddon = class {
|
|
|
6268
6351
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6269
6352
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6270
6353
|
*/
|
|
6354
|
+
/**
|
|
6355
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
6356
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
6357
|
+
* with no child is dropped rather than rendered empty.
|
|
6358
|
+
*
|
|
6359
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
6360
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
6361
|
+
*/
|
|
6362
|
+
function dropPerNodeFields(fields) {
|
|
6363
|
+
const kept = [];
|
|
6364
|
+
for (const field of fields) {
|
|
6365
|
+
if (field.type === "group") {
|
|
6366
|
+
const inner = dropPerNodeFields(field.fields);
|
|
6367
|
+
if (inner.length > 0) kept.push({
|
|
6368
|
+
...field,
|
|
6369
|
+
fields: inner
|
|
6370
|
+
});
|
|
6371
|
+
continue;
|
|
6372
|
+
}
|
|
6373
|
+
if (field.type === "sub-tabs") {
|
|
6374
|
+
const tabs = field.tabs.map((tab) => ({
|
|
6375
|
+
...tab,
|
|
6376
|
+
fields: dropPerNodeFields(tab.fields)
|
|
6377
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
6378
|
+
if (tabs.length > 0) kept.push({
|
|
6379
|
+
...field,
|
|
6380
|
+
tabs
|
|
6381
|
+
});
|
|
6382
|
+
continue;
|
|
6383
|
+
}
|
|
6384
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
6385
|
+
kept.push(field);
|
|
6386
|
+
}
|
|
6387
|
+
return kept;
|
|
6388
|
+
}
|
|
6271
6389
|
function collectPerNodeFieldKeys(fields) {
|
|
6272
6390
|
const collected = [];
|
|
6273
6391
|
for (const field of fields) {
|
|
@@ -9575,6 +9693,9 @@ method(object({
|
|
|
9575
9693
|
kind: "mutation",
|
|
9576
9694
|
auth: "admin"
|
|
9577
9695
|
}), method(object({
|
|
9696
|
+
addonId: string(),
|
|
9697
|
+
nodeId: string().optional()
|
|
9698
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
9578
9699
|
addonId: string(),
|
|
9579
9700
|
deviceId: number(),
|
|
9580
9701
|
nodeId: string().optional()
|
|
@@ -31751,6 +31872,12 @@ Object.freeze({
|
|
|
31751
31872
|
addonId: null,
|
|
31752
31873
|
access: "view"
|
|
31753
31874
|
},
|
|
31875
|
+
"addonSettings.getIntegrationSettings": {
|
|
31876
|
+
capName: "addon-settings",
|
|
31877
|
+
capScope: "system",
|
|
31878
|
+
addonId: null,
|
|
31879
|
+
access: "view"
|
|
31880
|
+
},
|
|
31754
31881
|
"addonSettings.updateDeviceSettings": {
|
|
31755
31882
|
capName: "addon-settings",
|
|
31756
31883
|
capScope: "system",
|
package/dist/addon.mjs
CHANGED
|
@@ -5955,6 +5955,40 @@ var BaseAddon = class {
|
|
|
5955
5955
|
deviceSettingsSchema() {
|
|
5956
5956
|
return null;
|
|
5957
5957
|
}
|
|
5958
|
+
/**
|
|
5959
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
5960
|
+
* ARE the configuration of its integration.
|
|
5961
|
+
*
|
|
5962
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
5963
|
+
* operator should find on the addon's integration page (System →
|
|
5964
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
5965
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
5966
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
5967
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
5968
|
+
* nature of the integration.
|
|
5969
|
+
*
|
|
5970
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
5971
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
5972
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
5973
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
5974
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
5975
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
5976
|
+
*
|
|
5977
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
5978
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
5979
|
+
* removed with the reason recorded at
|
|
5980
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
5981
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
5982
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
5983
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
5984
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
5985
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
5986
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
5987
|
+
* ids it names.
|
|
5988
|
+
*/
|
|
5989
|
+
integrationSettingSections() {
|
|
5990
|
+
return [];
|
|
5991
|
+
}
|
|
5958
5992
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5959
5993
|
const schema = this.globalSettingsSchema(cap);
|
|
5960
5994
|
if (!schema) return { sections: [] };
|
|
@@ -5965,6 +5999,55 @@ var BaseAddon = class {
|
|
|
5965
5999
|
} : projected);
|
|
5966
6000
|
}
|
|
5967
6001
|
/**
|
|
6002
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
6003
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
6004
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
6005
|
+
*
|
|
6006
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
6007
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
6008
|
+
* as a failed load.
|
|
6009
|
+
*
|
|
6010
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
6011
|
+
* and not in whichever UI happens to render this:
|
|
6012
|
+
*
|
|
6013
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
6014
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
6015
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
6016
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
6017
|
+
* not merely discouraged.
|
|
6018
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
6019
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
6020
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
6021
|
+
* who opened the page (D266).
|
|
6022
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
6023
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
6024
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
6025
|
+
*/
|
|
6026
|
+
async getIntegrationSettings(nodeId) {
|
|
6027
|
+
const declared = this.integrationSettingSections();
|
|
6028
|
+
if (declared.length === 0) return null;
|
|
6029
|
+
const schema = this.globalSettingsSchema();
|
|
6030
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
6031
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
6032
|
+
const sections = [];
|
|
6033
|
+
for (const id of declared) {
|
|
6034
|
+
const section = byId.get(id);
|
|
6035
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6036
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6037
|
+
if (fields.length === 0) continue;
|
|
6038
|
+
sections.push({
|
|
6039
|
+
...section,
|
|
6040
|
+
fields
|
|
6041
|
+
});
|
|
6042
|
+
}
|
|
6043
|
+
if (sections.length === 0) return null;
|
|
6044
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6045
|
+
return hydrateSchema({
|
|
6046
|
+
...schema,
|
|
6047
|
+
sections
|
|
6048
|
+
}, projected);
|
|
6049
|
+
}
|
|
6050
|
+
/**
|
|
5968
6051
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5969
6052
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5970
6053
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -6268,6 +6351,41 @@ var BaseAddon = class {
|
|
|
6268
6351
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6269
6352
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6270
6353
|
*/
|
|
6354
|
+
/**
|
|
6355
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
6356
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
6357
|
+
* with no child is dropped rather than rendered empty.
|
|
6358
|
+
*
|
|
6359
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
6360
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
6361
|
+
*/
|
|
6362
|
+
function dropPerNodeFields(fields) {
|
|
6363
|
+
const kept = [];
|
|
6364
|
+
for (const field of fields) {
|
|
6365
|
+
if (field.type === "group") {
|
|
6366
|
+
const inner = dropPerNodeFields(field.fields);
|
|
6367
|
+
if (inner.length > 0) kept.push({
|
|
6368
|
+
...field,
|
|
6369
|
+
fields: inner
|
|
6370
|
+
});
|
|
6371
|
+
continue;
|
|
6372
|
+
}
|
|
6373
|
+
if (field.type === "sub-tabs") {
|
|
6374
|
+
const tabs = field.tabs.map((tab) => ({
|
|
6375
|
+
...tab,
|
|
6376
|
+
fields: dropPerNodeFields(tab.fields)
|
|
6377
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
6378
|
+
if (tabs.length > 0) kept.push({
|
|
6379
|
+
...field,
|
|
6380
|
+
tabs
|
|
6381
|
+
});
|
|
6382
|
+
continue;
|
|
6383
|
+
}
|
|
6384
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
6385
|
+
kept.push(field);
|
|
6386
|
+
}
|
|
6387
|
+
return kept;
|
|
6388
|
+
}
|
|
6271
6389
|
function collectPerNodeFieldKeys(fields) {
|
|
6272
6390
|
const collected = [];
|
|
6273
6391
|
for (const field of fields) {
|
|
@@ -9575,6 +9693,9 @@ method(object({
|
|
|
9575
9693
|
kind: "mutation",
|
|
9576
9694
|
auth: "admin"
|
|
9577
9695
|
}), method(object({
|
|
9696
|
+
addonId: string(),
|
|
9697
|
+
nodeId: string().optional()
|
|
9698
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
9578
9699
|
addonId: string(),
|
|
9579
9700
|
deviceId: number(),
|
|
9580
9701
|
nodeId: string().optional()
|
|
@@ -31751,6 +31872,12 @@ Object.freeze({
|
|
|
31751
31872
|
addonId: null,
|
|
31752
31873
|
access: "view"
|
|
31753
31874
|
},
|
|
31875
|
+
"addonSettings.getIntegrationSettings": {
|
|
31876
|
+
capName: "addon-settings",
|
|
31877
|
+
capScope: "system",
|
|
31878
|
+
addonId: null,
|
|
31879
|
+
access: "view"
|
|
31880
|
+
},
|
|
31754
31881
|
"addonSettings.updateDeviceSettings": {
|
|
31755
31882
|
capName: "addon-settings",
|
|
31756
31883
|
capScope: "system",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-import-alexa",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.37",
|
|
4
4
|
"description": "Alexa device-import provider for CamStack — imports the smart-home devices in a user's Alexa account via the unofficial alexa-remote2 cookie/token client (the inverse of the Alexa exporter)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|