@camstack/addon-provider-petkit 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
|
@@ -7018,6 +7018,40 @@ var BaseAddon = class {
|
|
|
7018
7018
|
deviceSettingsSchema() {
|
|
7019
7019
|
return null;
|
|
7020
7020
|
}
|
|
7021
|
+
/**
|
|
7022
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
7023
|
+
* ARE the configuration of its integration.
|
|
7024
|
+
*
|
|
7025
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
7026
|
+
* operator should find on the addon's integration page (System →
|
|
7027
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
7028
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
7029
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
7030
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
7031
|
+
* nature of the integration.
|
|
7032
|
+
*
|
|
7033
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
7034
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
7035
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
7036
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
7037
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
7038
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
7039
|
+
*
|
|
7040
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
7041
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
7042
|
+
* removed with the reason recorded at
|
|
7043
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
7044
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
7045
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
7046
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
7047
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
7048
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
7049
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
7050
|
+
* ids it names.
|
|
7051
|
+
*/
|
|
7052
|
+
integrationSettingSections() {
|
|
7053
|
+
return [];
|
|
7054
|
+
}
|
|
7021
7055
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7022
7056
|
const schema = this.globalSettingsSchema(cap);
|
|
7023
7057
|
if (!schema) return { sections: [] };
|
|
@@ -7028,6 +7062,55 @@ var BaseAddon = class {
|
|
|
7028
7062
|
} : projected);
|
|
7029
7063
|
}
|
|
7030
7064
|
/**
|
|
7065
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
7066
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
7067
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
7068
|
+
*
|
|
7069
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
7070
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
7071
|
+
* as a failed load.
|
|
7072
|
+
*
|
|
7073
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
7074
|
+
* and not in whichever UI happens to render this:
|
|
7075
|
+
*
|
|
7076
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
7077
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
7078
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
7079
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
7080
|
+
* not merely discouraged.
|
|
7081
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
7082
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
7083
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
7084
|
+
* who opened the page (D266).
|
|
7085
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
7086
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
7087
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
7088
|
+
*/
|
|
7089
|
+
async getIntegrationSettings(nodeId) {
|
|
7090
|
+
const declared = this.integrationSettingSections();
|
|
7091
|
+
if (declared.length === 0) return null;
|
|
7092
|
+
const schema = this.globalSettingsSchema();
|
|
7093
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
7094
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
7095
|
+
const sections = [];
|
|
7096
|
+
for (const id of declared) {
|
|
7097
|
+
const section = byId.get(id);
|
|
7098
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
7099
|
+
const fields = dropPerNodeFields(section.fields);
|
|
7100
|
+
if (fields.length === 0) continue;
|
|
7101
|
+
sections.push({
|
|
7102
|
+
...section,
|
|
7103
|
+
fields
|
|
7104
|
+
});
|
|
7105
|
+
}
|
|
7106
|
+
if (sections.length === 0) return null;
|
|
7107
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
7108
|
+
return hydrateSchema({
|
|
7109
|
+
...schema,
|
|
7110
|
+
sections
|
|
7111
|
+
}, projected);
|
|
7112
|
+
}
|
|
7113
|
+
/**
|
|
7031
7114
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
7032
7115
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
7033
7116
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -7331,6 +7414,41 @@ var BaseAddon = class {
|
|
|
7331
7414
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
7332
7415
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
7333
7416
|
*/
|
|
7417
|
+
/**
|
|
7418
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
7419
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
7420
|
+
* with no child is dropped rather than rendered empty.
|
|
7421
|
+
*
|
|
7422
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
7423
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
7424
|
+
*/
|
|
7425
|
+
function dropPerNodeFields(fields) {
|
|
7426
|
+
const kept = [];
|
|
7427
|
+
for (const field of fields) {
|
|
7428
|
+
if (field.type === "group") {
|
|
7429
|
+
const inner = dropPerNodeFields(field.fields);
|
|
7430
|
+
if (inner.length > 0) kept.push({
|
|
7431
|
+
...field,
|
|
7432
|
+
fields: inner
|
|
7433
|
+
});
|
|
7434
|
+
continue;
|
|
7435
|
+
}
|
|
7436
|
+
if (field.type === "sub-tabs") {
|
|
7437
|
+
const tabs = field.tabs.map((tab) => ({
|
|
7438
|
+
...tab,
|
|
7439
|
+
fields: dropPerNodeFields(tab.fields)
|
|
7440
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
7441
|
+
if (tabs.length > 0) kept.push({
|
|
7442
|
+
...field,
|
|
7443
|
+
tabs
|
|
7444
|
+
});
|
|
7445
|
+
continue;
|
|
7446
|
+
}
|
|
7447
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
7448
|
+
kept.push(field);
|
|
7449
|
+
}
|
|
7450
|
+
return kept;
|
|
7451
|
+
}
|
|
7334
7452
|
function collectPerNodeFieldKeys(fields) {
|
|
7335
7453
|
const collected = [];
|
|
7336
7454
|
for (const field of fields) {
|
|
@@ -10500,6 +10618,9 @@ method(object({
|
|
|
10500
10618
|
kind: "mutation",
|
|
10501
10619
|
auth: "admin"
|
|
10502
10620
|
}), method(object({
|
|
10621
|
+
addonId: string(),
|
|
10622
|
+
nodeId: string().optional()
|
|
10623
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
10503
10624
|
addonId: string(),
|
|
10504
10625
|
deviceId: number(),
|
|
10505
10626
|
nodeId: string().optional()
|
|
@@ -32618,6 +32739,12 @@ Object.freeze({
|
|
|
32618
32739
|
addonId: null,
|
|
32619
32740
|
access: "view"
|
|
32620
32741
|
},
|
|
32742
|
+
"addonSettings.getIntegrationSettings": {
|
|
32743
|
+
capName: "addon-settings",
|
|
32744
|
+
capScope: "system",
|
|
32745
|
+
addonId: null,
|
|
32746
|
+
access: "view"
|
|
32747
|
+
},
|
|
32621
32748
|
"addonSettings.updateDeviceSettings": {
|
|
32622
32749
|
capName: "addon-settings",
|
|
32623
32750
|
capScope: "system",
|
package/dist/addon.mjs
CHANGED
|
@@ -7017,6 +7017,40 @@ var BaseAddon = class {
|
|
|
7017
7017
|
deviceSettingsSchema() {
|
|
7018
7018
|
return null;
|
|
7019
7019
|
}
|
|
7020
|
+
/**
|
|
7021
|
+
* INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
|
|
7022
|
+
* ARE the configuration of its integration.
|
|
7023
|
+
*
|
|
7024
|
+
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
7025
|
+
* operator should find on the addon's integration page (System →
|
|
7026
|
+
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
7027
|
+
* addon. Empty (the default) means the addon has no integration-level
|
|
7028
|
+
* settings and no such surface is offered — this is opt-in, because whether
|
|
7029
|
+
* an addon's configuration IS its integration's configuration depends on the
|
|
7030
|
+
* nature of the integration.
|
|
7031
|
+
*
|
|
7032
|
+
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
7033
|
+
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
7034
|
+
* `updateGlobalSettings` path. There is deliberately no
|
|
7035
|
+
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
7036
|
+
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
7037
|
+
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
7038
|
+
*
|
|
7039
|
+
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
7040
|
+
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
7041
|
+
* removed with the reason recorded at
|
|
7042
|
+
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
7043
|
+
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
7044
|
+
* marker sprinkled across sections also has to borrow a field that already
|
|
7045
|
+
* means something else; borrowing `section.tab` put the literal word
|
|
7046
|
+
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
7047
|
+
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
7048
|
+
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
7049
|
+
* ids it names.
|
|
7050
|
+
*/
|
|
7051
|
+
integrationSettingSections() {
|
|
7052
|
+
return [];
|
|
7053
|
+
}
|
|
7020
7054
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7021
7055
|
const schema = this.globalSettingsSchema(cap);
|
|
7022
7056
|
if (!schema) return { sections: [] };
|
|
@@ -7027,6 +7061,55 @@ var BaseAddon = class {
|
|
|
7027
7061
|
} : projected);
|
|
7028
7062
|
}
|
|
7029
7063
|
/**
|
|
7064
|
+
* The integration-level view of this addon's settings: exactly the sections
|
|
7065
|
+
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
7066
|
+
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
7067
|
+
*
|
|
7068
|
+
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
7069
|
+
* no integration settings surface at all, rather than an empty one that reads
|
|
7070
|
+
* as a failed load.
|
|
7071
|
+
*
|
|
7072
|
+
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
7073
|
+
* and not in whichever UI happens to render this:
|
|
7074
|
+
*
|
|
7075
|
+
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
7076
|
+
* shown here is the same field, with the same bare key, that the addon's
|
|
7077
|
+
* own page shows. There is no integration-specific writer — callers save
|
|
7078
|
+
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
7079
|
+
* not merely discouraged.
|
|
7080
|
+
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
7081
|
+
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
7082
|
+
* such a field silently picked would be a wrong answer for the operator
|
|
7083
|
+
* who opened the page (D266).
|
|
7084
|
+
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
7085
|
+
* alternative — skip it — turns a rename into a surface that quietly
|
|
7086
|
+
* empties, which looks exactly like an addon with nothing to configure.
|
|
7087
|
+
*/
|
|
7088
|
+
async getIntegrationSettings(nodeId) {
|
|
7089
|
+
const declared = this.integrationSettingSections();
|
|
7090
|
+
if (declared.length === 0) return null;
|
|
7091
|
+
const schema = this.globalSettingsSchema();
|
|
7092
|
+
if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
|
|
7093
|
+
const byId = new Map(schema.sections.map((section) => [section.id, section]));
|
|
7094
|
+
const sections = [];
|
|
7095
|
+
for (const id of declared) {
|
|
7096
|
+
const section = byId.get(id);
|
|
7097
|
+
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
7098
|
+
const fields = dropPerNodeFields(section.fields);
|
|
7099
|
+
if (fields.length === 0) continue;
|
|
7100
|
+
sections.push({
|
|
7101
|
+
...section,
|
|
7102
|
+
fields
|
|
7103
|
+
});
|
|
7104
|
+
}
|
|
7105
|
+
if (sections.length === 0) return null;
|
|
7106
|
+
const projected = await this.resolveGlobalStore(nodeId);
|
|
7107
|
+
return hydrateSchema({
|
|
7108
|
+
...schema,
|
|
7109
|
+
sections
|
|
7110
|
+
}, projected);
|
|
7111
|
+
}
|
|
7112
|
+
/**
|
|
7030
7113
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
7031
7114
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
7032
7115
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -7330,6 +7413,41 @@ var BaseAddon = class {
|
|
|
7330
7413
|
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
7331
7414
|
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
7332
7415
|
*/
|
|
7416
|
+
/**
|
|
7417
|
+
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
7418
|
+
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
7419
|
+
* with no child is dropped rather than rendered empty.
|
|
7420
|
+
*
|
|
7421
|
+
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
7422
|
+
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
7423
|
+
*/
|
|
7424
|
+
function dropPerNodeFields(fields) {
|
|
7425
|
+
const kept = [];
|
|
7426
|
+
for (const field of fields) {
|
|
7427
|
+
if (field.type === "group") {
|
|
7428
|
+
const inner = dropPerNodeFields(field.fields);
|
|
7429
|
+
if (inner.length > 0) kept.push({
|
|
7430
|
+
...field,
|
|
7431
|
+
fields: inner
|
|
7432
|
+
});
|
|
7433
|
+
continue;
|
|
7434
|
+
}
|
|
7435
|
+
if (field.type === "sub-tabs") {
|
|
7436
|
+
const tabs = field.tabs.map((tab) => ({
|
|
7437
|
+
...tab,
|
|
7438
|
+
fields: dropPerNodeFields(tab.fields)
|
|
7439
|
+
})).filter((tab) => tab.fields.length > 0);
|
|
7440
|
+
if (tabs.length > 0) kept.push({
|
|
7441
|
+
...field,
|
|
7442
|
+
tabs
|
|
7443
|
+
});
|
|
7444
|
+
continue;
|
|
7445
|
+
}
|
|
7446
|
+
if ("perNode" in field && field.perNode === true) continue;
|
|
7447
|
+
kept.push(field);
|
|
7448
|
+
}
|
|
7449
|
+
return kept;
|
|
7450
|
+
}
|
|
7333
7451
|
function collectPerNodeFieldKeys(fields) {
|
|
7334
7452
|
const collected = [];
|
|
7335
7453
|
for (const field of fields) {
|
|
@@ -10499,6 +10617,9 @@ method(object({
|
|
|
10499
10617
|
kind: "mutation",
|
|
10500
10618
|
auth: "admin"
|
|
10501
10619
|
}), method(object({
|
|
10620
|
+
addonId: string(),
|
|
10621
|
+
nodeId: string().optional()
|
|
10622
|
+
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
10502
10623
|
addonId: string(),
|
|
10503
10624
|
deviceId: number(),
|
|
10504
10625
|
nodeId: string().optional()
|
|
@@ -32617,6 +32738,12 @@ Object.freeze({
|
|
|
32617
32738
|
addonId: null,
|
|
32618
32739
|
access: "view"
|
|
32619
32740
|
},
|
|
32741
|
+
"addonSettings.getIntegrationSettings": {
|
|
32742
|
+
capName: "addon-settings",
|
|
32743
|
+
capScope: "system",
|
|
32744
|
+
addonId: null,
|
|
32745
|
+
access: "view"
|
|
32746
|
+
},
|
|
32620
32747
|
"addonSettings.updateDeviceSettings": {
|
|
32621
32748
|
capName: "addon-settings",
|
|
32622
32749
|
capScope: "system",
|
package/package.json
CHANGED