node-red-contrib-uos-nats 0.2.43 → 0.2.44

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/lib/payloads.js +21 -17
  2. package/package.json +1 -1
package/lib/payloads.js CHANGED
@@ -432,35 +432,39 @@ function mapDataType(dataType) {
432
432
  return VariableDataType.STRING;
433
433
  }
434
434
  }
435
- // Map string types to Enum integers for hashing
436
- function mapDataTypeToInt(dt) {
435
+ // Map string types to Python-compatible strings for hashing
436
+ function mapDataTypeToHashString(dt) {
437
+ // Python 'models.py': "int64", "float64", "string", "boolean"
437
438
  switch (dt) {
438
- case 'INT64': return VariableDataType.INT64;
439
- case 'FLOAT64': return VariableDataType.FLOAT64;
440
- case 'STRING': return VariableDataType.STRING;
441
- case 'BOOLEAN': return VariableDataType.BOOLEAN;
442
- default: return VariableDataType.STRING;
439
+ case 'INT64': return 'int64';
440
+ case 'FLOAT64': return 'float64';
441
+ case 'STRING': return 'string';
442
+ case 'BOOLEAN': return 'boolean';
443
+ default: return 'string';
443
444
  }
444
445
  }
445
446
 
447
+ // Map access types to Python-compatible strings for hashing
448
+ function mapAccessTypeToHashString(ac) {
449
+ // Python 'models.py': "read-write", "read-only"
450
+ // Node-RED might have 'READWRITE' or 'READONLY'
451
+ if (ac === 'READWRITE' || ac === 'READ_WRITE') return 'read-write';
452
+ return 'read-only';
453
+ }
454
+
446
455
  function computeFingerprint(defs) {
447
456
  const hash = createHash('sha256');
448
457
  for (const def of [...defs].sort((a, b) => a.id - b.id)) {
449
458
  // Must match Python: id:key:type:access:experimental
450
- // Python uses Enum.value (integer) for type and access
451
- const dtInt = mapDataTypeToInt(def.dataType);
452
- const acInt = mapAccessType(def.access);
459
+ // Python uses Enum.value which are STRINGS: "string", "read-write"
460
+ const dtStr = mapDataTypeToHashString(def.dataType);
461
+ const acStr = mapAccessTypeToHashString(def.access);
453
462
  const exp = def.experimental ?? false;
454
463
 
455
- // Note: Python uses "True"/"False" string representation of bool?
456
- // Python: f"{...}:{var.experimental}".encode() -> str(True) is "True"
457
- // JS: String(true) is "true".
458
- // Let's verify Python's bool stringification.
459
- // Python str(True) -> 'True'. JS String(true) -> 'true'. Case mismatch!
460
- // We must capitalize bools to match Python.
464
+ // We must capitalize bools to match Python's str(True) -> 'True'
461
465
  const expStr = exp ? 'True' : 'False';
462
466
 
463
- const preHash = `${def.id}:${def.key}:${dtInt}:${acInt}:${expStr}`;
467
+ const preHash = `${def.id}:${def.key}:${dtStr}:${acStr}:${expStr}`;
464
468
  console.log(`[DataHub Payloads] Fingerprint part: ${preHash}`);
465
469
  hash.update(preHash);
466
470
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-uos-nats",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "Node-RED nodes for Weidmüller u-OS Data Hub. Read, write, and provide variables via NATS protocol with OAuth2 authentication. Features: Variable Key resolution, custom icons, example flows, and provider definition caching.",
5
5
  "author": {
6
6
  "name": "IoTUeli",