@camstack/addon-export-hap 1.2.48 → 1.2.49
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/hap-export.addon.js +127 -0
- package/dist/hap-export.addon.mjs +127 -0
- package/package.json +1 -1
package/dist/hap-export.addon.js
CHANGED
|
@@ -6001,6 +6001,40 @@ var BaseAddon = class {
|
|
|
6001
6001
|
deviceSettingsSchema() {
|
|
6002
6002
|
return null;
|
|
6003
6003
|
}
|
|
6004
|
+
/**
|
|
6005
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
6006
|
+
* ARE the configuration of its integration.
|
|
6007
|
+
*
|
|
6008
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
6009
|
+
* operator should find on the addon's integration page (System →
|
|
6010
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
6011
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
6012
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
6013
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
6014
|
+
* nature of the integration.
|
|
6015
|
+
*
|
|
6016
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
6017
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
6018
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
6019
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
6020
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
6021
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
6022
|
+
*
|
|
6023
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
6024
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
6025
|
+
* removed with the reason recorded at
|
|
6026
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
6027
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
6028
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
6029
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
6030
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
6031
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
6032
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
6033
|
+
* ids it names.
|
|
6034
|
+
*/
|
|
6035
|
+
integrationSettingSections() {
|
|
6036
|
+
return [];
|
|
6037
|
+
}
|
|
6004
6038
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
6005
6039
|
const schema = this.globalSettingsSchema(cap);
|
|
6006
6040
|
if (!schema) return { sections: [] };
|
|
@@ -6011,6 +6045,55 @@ var BaseAddon = class {
|
|
|
6011
6045
|
} : projected);
|
|
6012
6046
|
}
|
|
6013
6047
|
/**
|
|
6048
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
6049
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
6050
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
6051
|
+
*
|
|
6052
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
6053
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
6054
|
+
* as a failed load.
|
|
6055
|
+
*
|
|
6056
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
6057
|
+
* and not in whichever UI happens to render this:
|
|
6058
|
+
*
|
|
6059
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
6060
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
6061
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
6062
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
6063
|
+
* not merely discouraged.
|
|
6064
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
6065
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
6066
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
6067
|
+
* who opened the page (D266).
|
|
6068
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
6069
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
6070
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
6071
|
+
*/
|
|
6072
|
+
async getIntegrationSettings(nodeId) {
|
|
6073
|
+
const declared = this.integrationSettingSections();
|
|
6074
|
+
if (declared.length === 0) return null;
|
|
6075
|
+
const schema = this.globalSettingsSchema();
|
|
6076
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
6077
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
6078
|
+
const sections = [];
|
|
6079
|
+
for (const id of declared) {
|
|
6080
|
+
const section = byId.get(id);
|
|
6081
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6082
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6083
|
+
if (fields.length === 0) continue;
|
|
6084
|
+
sections.push({
|
|
6085
|
+
...section,
|
|
6086
|
+
fields
|
|
6087
|
+
});
|
|
6088
|
+
}
|
|
6089
|
+
if (sections.length === 0) return null;
|
|
6090
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6091
|
+
return hydrateSchema({
|
|
6092
|
+
...schema,
|
|
6093
|
+
sections
|
|
6094
|
+
}, projected);
|
|
6095
|
+
}
|
|
6096
|
+
/**
|
|
6014
6097
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
6015
6098
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
6016
6099
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -6314,6 +6397,41 @@ var BaseAddon = class {
|
|
|
6314
6397
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6315
6398
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6316
6399
|
*/
|
|
6400
|
+
/**
|
|
6401
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
6402
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
6403
|
+
* with no child is dropped rather than rendered empty.
|
|
6404
|
+
*
|
|
6405
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
6406
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
6407
|
+
*/
|
|
6408
|
+
function dropPerNodeFields(fields) {
|
|
6409
|
+
const kept = [];
|
|
6410
|
+
for (const field of fields) {
|
|
6411
|
+
if (field.type === "group") {
|
|
6412
|
+
const inner = dropPerNodeFields(field.fields);
|
|
6413
|
+
if (inner.length > 0) kept.push({
|
|
6414
|
+
...field,
|
|
6415
|
+
fields: inner
|
|
6416
|
+
});
|
|
6417
|
+
continue;
|
|
6418
|
+
}
|
|
6419
|
+
if (field.type === "sub-tabs") {
|
|
6420
|
+
const tabs = field.tabs.map((tab) => ({
|
|
6421
|
+
...tab,
|
|
6422
|
+
fields: dropPerNodeFields(tab.fields)
|
|
6423
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
6424
|
+
if (tabs.length > 0) kept.push({
|
|
6425
|
+
...field,
|
|
6426
|
+
tabs
|
|
6427
|
+
});
|
|
6428
|
+
continue;
|
|
6429
|
+
}
|
|
6430
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
6431
|
+
kept.push(field);
|
|
6432
|
+
}
|
|
6433
|
+
return kept;
|
|
6434
|
+
}
|
|
6317
6435
|
function collectPerNodeFieldKeys(fields) {
|
|
6318
6436
|
const collected = [];
|
|
6319
6437
|
for (const field of fields) {
|
|
@@ -10118,6 +10236,9 @@ method(object({
|
|
|
10118
10236
|
kind: "mutation",
|
|
10119
10237
|
auth: "admin"
|
|
10120
10238
|
}), method(object({
|
|
10239
|
+
addonId: string(),
|
|
10240
|
+
nodeId: string().optional()
|
|
10241
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
10121
10242
|
addonId: string(),
|
|
10122
10243
|
deviceId: number(),
|
|
10123
10244
|
nodeId: string().optional()
|
|
@@ -28666,6 +28787,12 @@ Object.freeze({
|
|
|
28666
28787
|
addonId: null,
|
|
28667
28788
|
access: "view"
|
|
28668
28789
|
},
|
|
28790
|
+
"addonSettings.getIntegrationSettings": {
|
|
28791
|
+
capName: "addon-settings",
|
|
28792
|
+
capScope: "system",
|
|
28793
|
+
addonId: null,
|
|
28794
|
+
access: "view"
|
|
28795
|
+
},
|
|
28669
28796
|
"addonSettings.updateDeviceSettings": {
|
|
28670
28797
|
capName: "addon-settings",
|
|
28671
28798
|
capScope: "system",
|
|
@@ -5989,6 +5989,40 @@ var BaseAddon = class {
|
|
|
5989
5989
|
deviceSettingsSchema() {
|
|
5990
5990
|
return null;
|
|
5991
5991
|
}
|
|
5992
|
+
/**
|
|
5993
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
5994
|
+
* ARE the configuration of its integration.
|
|
5995
|
+
*
|
|
5996
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
5997
|
+
* operator should find on the addon's integration page (System →
|
|
5998
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
5999
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
6000
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
6001
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
6002
|
+
* nature of the integration.
|
|
6003
|
+
*
|
|
6004
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
6005
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
6006
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
6007
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
6008
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
6009
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
6010
|
+
*
|
|
6011
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
6012
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
6013
|
+
* removed with the reason recorded at
|
|
6014
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
6015
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
6016
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
6017
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
6018
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
6019
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
6020
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
6021
|
+
* ids it names.
|
|
6022
|
+
*/
|
|
6023
|
+
integrationSettingSections() {
|
|
6024
|
+
return [];
|
|
6025
|
+
}
|
|
5992
6026
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5993
6027
|
const schema = this.globalSettingsSchema(cap);
|
|
5994
6028
|
if (!schema) return { sections: [] };
|
|
@@ -5999,6 +6033,55 @@ var BaseAddon = class {
|
|
|
5999
6033
|
} : projected);
|
|
6000
6034
|
}
|
|
6001
6035
|
/**
|
|
6036
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
6037
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
6038
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
6039
|
+
*
|
|
6040
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
6041
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
6042
|
+
* as a failed load.
|
|
6043
|
+
*
|
|
6044
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
6045
|
+
* and not in whichever UI happens to render this:
|
|
6046
|
+
*
|
|
6047
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
6048
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
6049
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
6050
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
6051
|
+
* not merely discouraged.
|
|
6052
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
6053
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
6054
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
6055
|
+
* who opened the page (D266).
|
|
6056
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
6057
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
6058
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
6059
|
+
*/
|
|
6060
|
+
async getIntegrationSettings(nodeId) {
|
|
6061
|
+
const declared = this.integrationSettingSections();
|
|
6062
|
+
if (declared.length === 0) return null;
|
|
6063
|
+
const schema = this.globalSettingsSchema();
|
|
6064
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
6065
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
6066
|
+
const sections = [];
|
|
6067
|
+
for (const id of declared) {
|
|
6068
|
+
const section = byId.get(id);
|
|
6069
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
6070
|
+
const fields = dropPerNodeFields(section.fields);
|
|
6071
|
+
if (fields.length === 0) continue;
|
|
6072
|
+
sections.push({
|
|
6073
|
+
...section,
|
|
6074
|
+
fields
|
|
6075
|
+
});
|
|
6076
|
+
}
|
|
6077
|
+
if (sections.length === 0) return null;
|
|
6078
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
6079
|
+
return hydrateSchema({
|
|
6080
|
+
...schema,
|
|
6081
|
+
sections
|
|
6082
|
+
}, projected);
|
|
6083
|
+
}
|
|
6084
|
+
/**
|
|
6002
6085
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
6003
6086
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
6004
6087
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -6302,6 +6385,41 @@ var BaseAddon = class {
|
|
|
6302
6385
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6303
6386
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6304
6387
|
*/
|
|
6388
|
+
/**
|
|
6389
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
6390
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
6391
|
+
* with no child is dropped rather than rendered empty.
|
|
6392
|
+
*
|
|
6393
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
6394
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
6395
|
+
*/
|
|
6396
|
+
function dropPerNodeFields(fields) {
|
|
6397
|
+
const kept = [];
|
|
6398
|
+
for (const field of fields) {
|
|
6399
|
+
if (field.type === "group") {
|
|
6400
|
+
const inner = dropPerNodeFields(field.fields);
|
|
6401
|
+
if (inner.length > 0) kept.push({
|
|
6402
|
+
...field,
|
|
6403
|
+
fields: inner
|
|
6404
|
+
});
|
|
6405
|
+
continue;
|
|
6406
|
+
}
|
|
6407
|
+
if (field.type === "sub-tabs") {
|
|
6408
|
+
const tabs = field.tabs.map((tab) => ({
|
|
6409
|
+
...tab,
|
|
6410
|
+
fields: dropPerNodeFields(tab.fields)
|
|
6411
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
6412
|
+
if (tabs.length > 0) kept.push({
|
|
6413
|
+
...field,
|
|
6414
|
+
tabs
|
|
6415
|
+
});
|
|
6416
|
+
continue;
|
|
6417
|
+
}
|
|
6418
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
6419
|
+
kept.push(field);
|
|
6420
|
+
}
|
|
6421
|
+
return kept;
|
|
6422
|
+
}
|
|
6305
6423
|
function collectPerNodeFieldKeys(fields) {
|
|
6306
6424
|
const collected = [];
|
|
6307
6425
|
for (const field of fields) {
|
|
@@ -10106,6 +10224,9 @@ method(object({
|
|
|
10106
10224
|
kind: "mutation",
|
|
10107
10225
|
auth: "admin"
|
|
10108
10226
|
}), method(object({
|
|
10227
|
+
addonId: string(),
|
|
10228
|
+
nodeId: string().optional()
|
|
10229
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
10109
10230
|
addonId: string(),
|
|
10110
10231
|
deviceId: number(),
|
|
10111
10232
|
nodeId: string().optional()
|
|
@@ -28654,6 +28775,12 @@ Object.freeze({
|
|
|
28654
28775
|
addonId: null,
|
|
28655
28776
|
access: "view"
|
|
28656
28777
|
},
|
|
28778
|
+
"addonSettings.getIntegrationSettings": {
|
|
28779
|
+
capName: "addon-settings",
|
|
28780
|
+
capScope: "system",
|
|
28781
|
+
addonId: null,
|
|
28782
|
+
access: "view"
|
|
28783
|
+
},
|
|
28657
28784
|
"addonSettings.updateDeviceSettings": {
|
|
28658
28785
|
capName: "addon-settings",
|
|
28659
28786
|
capScope: "system",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-export-hap",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.49",
|
|
4
4
|
"description": "HomeKit (HAP) exporter for CamStack devices. Publishes each exposed device as its own HomeKit accessory: cameras and doorbells with SRTP streaming, HomeKit Secure Video, motion, two-way audio, PTZ and battery; switches, lights, locks and sensors through a capability→service table.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|