@attraccess/plugin-wago 0.1.0-nightly.1003.1 → 0.1.0-nightly.1005.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.
package/dist/index.js CHANGED
@@ -62252,6 +62252,13 @@ function diagnosticReferences(nodes, channelIds, revision2, capabilities) {
62252
62252
  return nodes.map((node) => {
62253
62253
  const channelId2 = typeof node.data.channelId === "string" ? node.data.channelId : "";
62254
62254
  const control = node.type === "plugin.wago.command";
62255
+ const conflictResourceIds = control ? [
62256
+ ...new Set(
62257
+ nodes.filter(
62258
+ (other) => other.type === "plugin.wago.command" && other.resourceId !== node.resourceId && other.data.channelId === channelId2
62259
+ ).map((other) => other.resourceId)
62260
+ )
62261
+ ] : [];
62255
62262
  return {
62256
62263
  nodeId: node.id,
62257
62264
  resourceId: node.resourceId,
@@ -62259,9 +62266,8 @@ function diagnosticReferences(nodes, channelIds, revision2, capabilities) {
62259
62266
  control,
62260
62267
  href: `/resources/${node.resourceId}/flows?node=${encodeURIComponent(node.id)}`,
62261
62268
  invalid: !channelIds.includes(channelId2) || control && (node.data.expectedConfigurationRevision !== revision2 || capabilities && (!own(capabilities, channelId2)?.includes("output") || node.data.action === "pulse" && !own(capabilities, channelId2)?.includes("pulse"))),
62262
- conflict: control && nodes.some(
62263
- (other) => other.type === "plugin.wago.command" && other.resourceId !== node.resourceId && other.data.channelId === channelId2
62264
- )
62269
+ conflict: conflictResourceIds.length > 0,
62270
+ conflictResourceIds
62265
62271
  };
62266
62272
  });
62267
62273
  }
@@ -62304,12 +62310,16 @@ var WagoDiagnosticsService = class {
62304
62310
  const referencesTruncated = conflictNodes.length > 1e3;
62305
62311
  const conflictNodesByControllerId = /* @__PURE__ */ new Map();
62306
62312
  for (const node of conflictNodes.slice(0, 1e3)) {
62313
+ if (node.resourceId === resourceId) continue;
62307
62314
  const controllerId = node.data.controllerId;
62308
62315
  if (typeof controllerId !== "number") continue;
62309
62316
  const matchingNodes = conflictNodesByControllerId.get(controllerId) ?? [];
62310
62317
  matchingNodes.push(node);
62311
62318
  conflictNodesByControllerId.set(controllerId, matchingNodes);
62312
62319
  }
62320
+ const conflictResourceIds = [...new Set([...conflictNodesByControllerId.values()].flat().map((n) => n.resourceId))];
62321
+ const conflictResources = conflictResourceIds.length ? await this.context.dataSource.getRepository(import_plugins_backend_sdk16.Resource).createQueryBuilder("resource").select(["resource.id", "resource.name"]).where("resource.id IN (:...ids)", { ids: conflictResourceIds }).getMany() : [];
62322
+ const resourceNames = new Map(conflictResources.map((resource) => [resource.id, resource.name]));
62313
62323
  const controllersResult = selectedControllerIds.map((controllerId) => {
62314
62324
  const controller = controllersById.get(controllerId);
62315
62325
  if (!controller)
@@ -62331,7 +62341,13 @@ var WagoDiagnosticsService = class {
62331
62341
  Object.fromEntries(
62332
62342
  appliedSnapshot?.logicalChannels.map((channel) => [channel.id, channel.capabilities]) ?? []
62333
62343
  )
62334
- ).filter((reference) => reference.resourceId === resourceId);
62344
+ ).filter((reference) => reference.resourceId === resourceId).map((reference) => ({
62345
+ ...reference,
62346
+ conflictResources: reference.conflictResourceIds.map((id) => ({
62347
+ id,
62348
+ name: resourceNames.get(id) ?? `Resource ${id}`
62349
+ }))
62350
+ }));
62335
62351
  return {
62336
62352
  controllerId,
62337
62353
  name: controller.name ?? controller.hardwareId,