@camstack/addon-terminal 0.1.42 → 0.1.43

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 CHANGED
@@ -5948,6 +5948,40 @@ var BaseAddon = class {
5948
5948
  deviceSettingsSchema() {
5949
5949
  return null;
5950
5950
  }
5951
+ /**
5952
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5953
+ * ARE the configuration of its integration.
5954
+ *
5955
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5956
+ * operator should find on the addon's integration page (System →
5957
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5958
+ * addon. Empty (the default) means the addon has no integration-level
5959
+ * settings and no such surface is offered — this is opt-in, because whether
5960
+ * an addon's configuration IS its integration's configuration depends on the
5961
+ * nature of the integration.
5962
+ *
5963
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5964
+ * the ONE global schema, in the ONE addon store, written by the ONE
5965
+ * `updateGlobalSettings` path. There is deliberately no
5966
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5967
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5968
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5969
+ *
5970
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5971
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5972
+ * removed with the reason recorded at
5973
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5974
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5975
+ * marker sprinkled across sections also has to borrow a field that already
5976
+ * means something else; borrowing `section.tab` put the literal word
5977
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5978
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5979
+ * supersedes D268). One declaration, in one place, next to the schema whose
5980
+ * ids it names.
5981
+ */
5982
+ integrationSettingSections() {
5983
+ return [];
5984
+ }
5951
5985
  async getGlobalSettings(overlay, cap, nodeId) {
5952
5986
  const schema = this.globalSettingsSchema(cap);
5953
5987
  if (!schema) return { sections: [] };
@@ -5958,6 +5992,55 @@ var BaseAddon = class {
5958
5992
  } : projected);
5959
5993
  }
5960
5994
  /**
5995
+ * The integration-level view of this addon's settings: exactly the sections
5996
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5997
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5998
+ *
5999
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6000
+ * no integration settings surface at all, rather than an empty one that reads
6001
+ * as a failed load.
6002
+ *
6003
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6004
+ * and not in whichever UI happens to render this:
6005
+ *
6006
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6007
+ * shown here is the same field, with the same bare key, that the addon's
6008
+ * own page shows. There is no integration-specific writer — callers save
6009
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6010
+ * not merely discouraged.
6011
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6012
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6013
+ * such a field silently picked would be a wrong answer for the operator
6014
+ * who opened the page (D266).
6015
+ * 3. **No silent typo.** A declared id that names no section throws. The
6016
+ * alternative — skip it — turns a rename into a surface that quietly
6017
+ * empties, which looks exactly like an addon with nothing to configure.
6018
+ */
6019
+ async getIntegrationSettings(nodeId) {
6020
+ const declared = this.integrationSettingSections();
6021
+ if (declared.length === 0) return null;
6022
+ const schema = this.globalSettingsSchema();
6023
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6024
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6025
+ const sections = [];
6026
+ for (const id of declared) {
6027
+ const section = byId.get(id);
6028
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6029
+ const fields = dropPerNodeFields(section.fields);
6030
+ if (fields.length === 0) continue;
6031
+ sections.push({
6032
+ ...section,
6033
+ fields
6034
+ });
6035
+ }
6036
+ if (sections.length === 0) return null;
6037
+ const projected = await this.resolveGlobalStore(nodeId);
6038
+ return hydrateSchema({
6039
+ ...schema,
6040
+ sections
6041
+ }, projected);
6042
+ }
6043
+ /**
5961
6044
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5962
6045
  * every `perNode: true` field carries THAT node's scoped value on its bare
5963
6046
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6261,6 +6344,41 @@ var BaseAddon = class {
6261
6344
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6262
6345
  * don't declare `perNode` and are excluded by the `in` narrowing.
6263
6346
  */
6347
+ /**
6348
+ * The same fields with every `perNode: true` one removed, recursing into layout
6349
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6350
+ * with no child is dropped rather than rendered empty.
6351
+ *
6352
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6353
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6354
+ */
6355
+ function dropPerNodeFields(fields) {
6356
+ const kept = [];
6357
+ for (const field of fields) {
6358
+ if (field.type === "group") {
6359
+ const inner = dropPerNodeFields(field.fields);
6360
+ if (inner.length > 0) kept.push({
6361
+ ...field,
6362
+ fields: inner
6363
+ });
6364
+ continue;
6365
+ }
6366
+ if (field.type === "sub-tabs") {
6367
+ const tabs = field.tabs.map((tab) => ({
6368
+ ...tab,
6369
+ fields: dropPerNodeFields(tab.fields)
6370
+ })).filter((tab) => tab.fields.length > 0);
6371
+ if (tabs.length > 0) kept.push({
6372
+ ...field,
6373
+ tabs
6374
+ });
6375
+ continue;
6376
+ }
6377
+ if ("perNode" in field && field.perNode === true) continue;
6378
+ kept.push(field);
6379
+ }
6380
+ return kept;
6381
+ }
6264
6382
  function collectPerNodeFieldKeys(fields) {
6265
6383
  const collected = [];
6266
6384
  for (const field of fields) {
@@ -9497,6 +9615,9 @@ method(object({
9497
9615
  kind: "mutation",
9498
9616
  auth: "admin"
9499
9617
  }), method(object({
9618
+ addonId: string(),
9619
+ nodeId: string().optional()
9620
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9500
9621
  addonId: string(),
9501
9622
  deviceId: number(),
9502
9623
  nodeId: string().optional()
@@ -31681,6 +31802,12 @@ Object.freeze({
31681
31802
  addonId: null,
31682
31803
  access: "view"
31683
31804
  },
31805
+ "addonSettings.getIntegrationSettings": {
31806
+ capName: "addon-settings",
31807
+ capScope: "system",
31808
+ addonId: null,
31809
+ access: "view"
31810
+ },
31684
31811
  "addonSettings.updateDeviceSettings": {
31685
31812
  capName: "addon-settings",
31686
31813
  capScope: "system",
package/dist/addon.mjs 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) {
@@ -9474,6 +9592,9 @@ method(object({
9474
9592
  kind: "mutation",
9475
9593
  auth: "admin"
9476
9594
  }), method(object({
9595
+ addonId: string(),
9596
+ nodeId: string().optional()
9597
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9477
9598
  addonId: string(),
9478
9599
  deviceId: number(),
9479
9600
  nodeId: string().optional()
@@ -31658,6 +31779,12 @@ Object.freeze({
31658
31779
  addonId: null,
31659
31780
  access: "view"
31660
31781
  },
31782
+ "addonSettings.getIntegrationSettings": {
31783
+ capName: "addon-settings",
31784
+ capScope: "system",
31785
+ addonId: null,
31786
+ access: "view"
31787
+ },
31661
31788
  "addonSettings.updateDeviceSettings": {
31662
31789
  capName: "addon-settings",
31663
31790
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-terminal",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "Interactive terminal sessions (pty + xterm) as a CamStack addon",
5
5
  "keywords": [
6
6
  "camstack",