@attraccess/plugin-wago 0.1.0-nightly.952.1 → 0.1.0-nightly.953.1

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -52451,7 +52451,18 @@ var WagoCommandHandler = class {
52451
52451
  const revision = controllerId ? await this.dependencies.appliedRevision(controllerId) : null;
52452
52452
  const snapshot = revision ? JSON.parse(revision.snapshot) : null;
52453
52453
  const channelId = typeof config.channelId === "string" ? config.channelId : void 0;
52454
- const channel = snapshot?.logicalChannels.find((item) => item.id === channelId);
52454
+ const outputChannels = snapshot?.logicalChannels.filter((item) => item.capabilities.includes("output")) ?? [];
52455
+ let names = {};
52456
+ if (controllerId) {
52457
+ const draft = await this.dependencies.context.getRepository(WagoConfigurationDraft).findOneBy({ controllerId });
52458
+ try {
52459
+ const draftMatchesAppliedRevision = typeof draft?.snapshot === "string" && configurationHash(JSON.parse(draft.snapshot)) === revision?.contentHash;
52460
+ const storedNames = draftMatchesAppliedRevision && JSON.parse(draft?.presetProvenance ?? "null")?.editor?.names;
52461
+ if (storedNames && typeof storedNames === "object" && !Array.isArray(storedNames)) names = storedNames;
52462
+ } catch {
52463
+ }
52464
+ }
52465
+ const channel = outputChannels.find((item) => item.id === channelId);
52455
52466
  const references = channelId && controllerId ? await this.references(controllerId, channelId, resourceId) : [];
52456
52467
  const properties = {
52457
52468
  controllerId: {
@@ -52462,16 +52473,20 @@ var WagoCommandHandler = class {
52462
52473
  const: controller.id,
52463
52474
  title: controller.name ?? controller.hardwareId
52464
52475
  })),
52465
- refreshesSchema: true
52476
+ refreshesSchema: true,
52477
+ description: controllerId && !revision ? "Publish a configuration and wait for the controller to apply it before authoring commands." : void 0
52466
52478
  }
52467
52479
  };
52468
52480
  if (controllerId && revision && snapshot) {
52469
52481
  properties.channelId = {
52470
52482
  type: "string",
52471
52483
  title: "Logical Channel",
52472
- oneOf: snapshot.logicalChannels.map((item) => ({ const: item.id, title: `${item.id} (${item.profile})` })),
52484
+ oneOf: outputChannels.map((item) => ({
52485
+ const: item.id,
52486
+ title: typeof names[item.id] === "string" ? names[item.id] : `${item.id} (${item.profile})`
52487
+ })),
52473
52488
  refreshesSchema: true,
52474
- helpText: references.length ? `Also controlled by resource flow node${references.length === 1 ? "" : "s"}: ${references.join(", ")}. Reuse is allowed.` : void 0
52489
+ description: references.length ? `Also controlled by resource flow node${references.length === 1 ? "" : "s"}: ${references.join(", ")}. Reuse is allowed.` : outputChannels.length ? void 0 : "This applied configuration has no output channels. Add an output and publish it first."
52475
52490
  };
52476
52491
  }
52477
52492
  if (channel) {
@@ -52480,7 +52495,7 @@ var WagoCommandHandler = class {
52480
52495
  ...channel.capabilities.includes("pulse") ? [{ const: "pulse", title: "Pulse" }] : []
52481
52496
  ] : [];
52482
52497
  properties.action = { type: "string", title: "Operation", oneOf: actions, refreshesSchema: true };
52483
- if (config.action === "set") properties.value = { type: "boolean", title: "State" };
52498
+ if (config.action === "set") properties.value = { type: "boolean", title: "State", default: false };
52484
52499
  properties.expectedConfigurationRevision = {
52485
52500
  type: "number",
52486
52501
  title: "Configuration revision",
@@ -52521,7 +52536,15 @@ var WagoCommandHandler = class {
52521
52536
  dynamic: true,
52522
52537
  type: "object",
52523
52538
  properties,
52524
- required: Object.keys(properties).filter((key) => key !== "value")
52539
+ required: [
52540
+ .../* @__PURE__ */ new Set([
52541
+ "controllerId",
52542
+ "channelId",
52543
+ "action",
52544
+ "expectedConfigurationRevision",
52545
+ ...Object.keys(properties)
52546
+ ])
52547
+ ]
52525
52548
  };
52526
52549
  }
52527
52550
  async validate(config, validationContext = /* @__PURE__ */ new Map()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attraccess/plugin-wago",
3
- "version": "0.1.0-nightly.952.1",
3
+ "version": "0.1.0-nightly.953.1",
4
4
  "description": "Official Attraccess integration for WAGO CC100 controllers.",
5
5
  "keywords": [
6
6
  "attraccess-plugin",