@camstack/addon-smtp-nodemailer 1.2.36 → 1.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.
@@ -5953,6 +5953,40 @@ var BaseAddon = class {
5953
5953
  deviceSettingsSchema() {
5954
5954
  return null;
5955
5955
  }
5956
+ /**
5957
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5958
+ * ARE the configuration of its integration.
5959
+ *
5960
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5961
+ * operator should find on the addon's integration page (System →
5962
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5963
+ * addon. Empty (the default) means the addon has no integration-level
5964
+ * settings and no such surface is offered — this is opt-in, because whether
5965
+ * an addon's configuration IS its integration's configuration depends on the
5966
+ * nature of the integration.
5967
+ *
5968
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5969
+ * the ONE global schema, in the ONE addon store, written by the ONE
5970
+ * `updateGlobalSettings` path. There is deliberately no
5971
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5972
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5973
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5974
+ *
5975
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5976
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5977
+ * removed with the reason recorded at
5978
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5979
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5980
+ * marker sprinkled across sections also has to borrow a field that already
5981
+ * means something else; borrowing `section.tab` put the literal word
5982
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5983
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5984
+ * supersedes D268). One declaration, in one place, next to the schema whose
5985
+ * ids it names.
5986
+ */
5987
+ integrationSettingSections() {
5988
+ return [];
5989
+ }
5956
5990
  async getGlobalSettings(overlay, cap, nodeId) {
5957
5991
  const schema = this.globalSettingsSchema(cap);
5958
5992
  if (!schema) return { sections: [] };
@@ -5963,6 +5997,55 @@ var BaseAddon = class {
5963
5997
  } : projected);
5964
5998
  }
5965
5999
  /**
6000
+ * The integration-level view of this addon's settings: exactly the sections
6001
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6002
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6003
+ *
6004
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6005
+ * no integration settings surface at all, rather than an empty one that reads
6006
+ * as a failed load.
6007
+ *
6008
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6009
+ * and not in whichever UI happens to render this:
6010
+ *
6011
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6012
+ * shown here is the same field, with the same bare key, that the addon's
6013
+ * own page shows. There is no integration-specific writer — callers save
6014
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6015
+ * not merely discouraged.
6016
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6017
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6018
+ * such a field silently picked would be a wrong answer for the operator
6019
+ * who opened the page (D266).
6020
+ * 3. **No silent typo.** A declared id that names no section throws. The
6021
+ * alternative — skip it — turns a rename into a surface that quietly
6022
+ * empties, which looks exactly like an addon with nothing to configure.
6023
+ */
6024
+ async getIntegrationSettings(nodeId) {
6025
+ const declared = this.integrationSettingSections();
6026
+ if (declared.length === 0) return null;
6027
+ const schema = this.globalSettingsSchema();
6028
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6029
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6030
+ const sections = [];
6031
+ for (const id of declared) {
6032
+ const section = byId.get(id);
6033
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6034
+ const fields = dropPerNodeFields(section.fields);
6035
+ if (fields.length === 0) continue;
6036
+ sections.push({
6037
+ ...section,
6038
+ fields
6039
+ });
6040
+ }
6041
+ if (sections.length === 0) return null;
6042
+ const projected = await this.resolveGlobalStore(nodeId);
6043
+ return hydrateSchema({
6044
+ ...schema,
6045
+ sections
6046
+ }, projected);
6047
+ }
6048
+ /**
5966
6049
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5967
6050
  * every `perNode: true` field carries THAT node's scoped value on its bare
5968
6051
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6266,6 +6349,41 @@ var BaseAddon = class {
6266
6349
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6267
6350
  * don't declare `perNode` and are excluded by the `in` narrowing.
6268
6351
  */
6352
+ /**
6353
+ * The same fields with every `perNode: true` one removed, recursing into layout
6354
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6355
+ * with no child is dropped rather than rendered empty.
6356
+ *
6357
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6358
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6359
+ */
6360
+ function dropPerNodeFields(fields) {
6361
+ const kept = [];
6362
+ for (const field of fields) {
6363
+ if (field.type === "group") {
6364
+ const inner = dropPerNodeFields(field.fields);
6365
+ if (inner.length > 0) kept.push({
6366
+ ...field,
6367
+ fields: inner
6368
+ });
6369
+ continue;
6370
+ }
6371
+ if (field.type === "sub-tabs") {
6372
+ const tabs = field.tabs.map((tab) => ({
6373
+ ...tab,
6374
+ fields: dropPerNodeFields(tab.fields)
6375
+ })).filter((tab) => tab.fields.length > 0);
6376
+ if (tabs.length > 0) kept.push({
6377
+ ...field,
6378
+ tabs
6379
+ });
6380
+ continue;
6381
+ }
6382
+ if ("perNode" in field && field.perNode === true) continue;
6383
+ kept.push(field);
6384
+ }
6385
+ return kept;
6386
+ }
6269
6387
  function collectPerNodeFieldKeys(fields) {
6270
6388
  const collected = [];
6271
6389
  for (const field of fields) {
@@ -9419,6 +9537,9 @@ method(object({
9419
9537
  kind: "mutation",
9420
9538
  auth: "admin"
9421
9539
  }), method(object({
9540
+ addonId: string(),
9541
+ nodeId: string().optional()
9542
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9422
9543
  addonId: string(),
9423
9544
  deviceId: number(),
9424
9545
  nodeId: string().optional()
@@ -27826,6 +27947,12 @@ Object.freeze({
27826
27947
  addonId: null,
27827
27948
  access: "view"
27828
27949
  },
27950
+ "addonSettings.getIntegrationSettings": {
27951
+ capName: "addon-settings",
27952
+ capScope: "system",
27953
+ addonId: null,
27954
+ access: "view"
27955
+ },
27829
27956
  "addonSettings.updateDeviceSettings": {
27830
27957
  capName: "addon-settings",
27831
27958
  capScope: "system",
@@ -5951,6 +5951,40 @@ var BaseAddon = class {
5951
5951
  deviceSettingsSchema() {
5952
5952
  return null;
5953
5953
  }
5954
+ /**
5955
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5956
+ * ARE the configuration of its integration.
5957
+ *
5958
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5959
+ * operator should find on the addon's integration page (System →
5960
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5961
+ * addon. Empty (the default) means the addon has no integration-level
5962
+ * settings and no such surface is offered — this is opt-in, because whether
5963
+ * an addon's configuration IS its integration's configuration depends on the
5964
+ * nature of the integration.
5965
+ *
5966
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5967
+ * the ONE global schema, in the ONE addon store, written by the ONE
5968
+ * `updateGlobalSettings` path. There is deliberately no
5969
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5970
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5971
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5972
+ *
5973
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5974
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5975
+ * removed with the reason recorded at
5976
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5977
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5978
+ * marker sprinkled across sections also has to borrow a field that already
5979
+ * means something else; borrowing `section.tab` put the literal word
5980
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5981
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5982
+ * supersedes D268). One declaration, in one place, next to the schema whose
5983
+ * ids it names.
5984
+ */
5985
+ integrationSettingSections() {
5986
+ return [];
5987
+ }
5954
5988
  async getGlobalSettings(overlay, cap, nodeId) {
5955
5989
  const schema = this.globalSettingsSchema(cap);
5956
5990
  if (!schema) return { sections: [] };
@@ -5961,6 +5995,55 @@ var BaseAddon = class {
5961
5995
  } : projected);
5962
5996
  }
5963
5997
  /**
5998
+ * The integration-level view of this addon's settings: exactly the sections
5999
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6000
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6001
+ *
6002
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6003
+ * no integration settings surface at all, rather than an empty one that reads
6004
+ * as a failed load.
6005
+ *
6006
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6007
+ * and not in whichever UI happens to render this:
6008
+ *
6009
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6010
+ * shown here is the same field, with the same bare key, that the addon's
6011
+ * own page shows. There is no integration-specific writer — callers save
6012
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6013
+ * not merely discouraged.
6014
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6015
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6016
+ * such a field silently picked would be a wrong answer for the operator
6017
+ * who opened the page (D266).
6018
+ * 3. **No silent typo.** A declared id that names no section throws. The
6019
+ * alternative — skip it — turns a rename into a surface that quietly
6020
+ * empties, which looks exactly like an addon with nothing to configure.
6021
+ */
6022
+ async getIntegrationSettings(nodeId) {
6023
+ const declared = this.integrationSettingSections();
6024
+ if (declared.length === 0) return null;
6025
+ const schema = this.globalSettingsSchema();
6026
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6027
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6028
+ const sections = [];
6029
+ for (const id of declared) {
6030
+ const section = byId.get(id);
6031
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6032
+ const fields = dropPerNodeFields(section.fields);
6033
+ if (fields.length === 0) continue;
6034
+ sections.push({
6035
+ ...section,
6036
+ fields
6037
+ });
6038
+ }
6039
+ if (sections.length === 0) return null;
6040
+ const projected = await this.resolveGlobalStore(nodeId);
6041
+ return hydrateSchema({
6042
+ ...schema,
6043
+ sections
6044
+ }, projected);
6045
+ }
6046
+ /**
5964
6047
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5965
6048
  * every `perNode: true` field carries THAT node's scoped value on its bare
5966
6049
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6264,6 +6347,41 @@ var BaseAddon = class {
6264
6347
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6265
6348
  * don't declare `perNode` and are excluded by the `in` narrowing.
6266
6349
  */
6350
+ /**
6351
+ * The same fields with every `perNode: true` one removed, recursing into layout
6352
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6353
+ * with no child is dropped rather than rendered empty.
6354
+ *
6355
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6356
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6357
+ */
6358
+ function dropPerNodeFields(fields) {
6359
+ const kept = [];
6360
+ for (const field of fields) {
6361
+ if (field.type === "group") {
6362
+ const inner = dropPerNodeFields(field.fields);
6363
+ if (inner.length > 0) kept.push({
6364
+ ...field,
6365
+ fields: inner
6366
+ });
6367
+ continue;
6368
+ }
6369
+ if (field.type === "sub-tabs") {
6370
+ const tabs = field.tabs.map((tab) => ({
6371
+ ...tab,
6372
+ fields: dropPerNodeFields(tab.fields)
6373
+ })).filter((tab) => tab.fields.length > 0);
6374
+ if (tabs.length > 0) kept.push({
6375
+ ...field,
6376
+ tabs
6377
+ });
6378
+ continue;
6379
+ }
6380
+ if ("perNode" in field && field.perNode === true) continue;
6381
+ kept.push(field);
6382
+ }
6383
+ return kept;
6384
+ }
6267
6385
  function collectPerNodeFieldKeys(fields) {
6268
6386
  const collected = [];
6269
6387
  for (const field of fields) {
@@ -9417,6 +9535,9 @@ method(object({
9417
9535
  kind: "mutation",
9418
9536
  auth: "admin"
9419
9537
  }), method(object({
9538
+ addonId: string(),
9539
+ nodeId: string().optional()
9540
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9420
9541
  addonId: string(),
9421
9542
  deviceId: number(),
9422
9543
  nodeId: string().optional()
@@ -27824,6 +27945,12 @@ Object.freeze({
27824
27945
  addonId: null,
27825
27946
  access: "view"
27826
27947
  },
27948
+ "addonSettings.getIntegrationSettings": {
27949
+ capName: "addon-settings",
27950
+ capScope: "system",
27951
+ addonId: null,
27952
+ access: "view"
27953
+ },
27827
27954
  "addonSettings.updateDeviceSettings": {
27828
27955
  capName: "addon-settings",
27829
27956
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-smtp-nodemailer",
3
- "version": "1.2.36",
3
+ "version": "1.2.37",
4
4
  "description": "SMTP email provider addon for CamStack — wraps `nodemailer` and registers a `smtp-provider` cap collection entry. Used by magic-link login + notifier addons.",
5
5
  "keywords": [
6
6
  "camstack",