@uns-kit/cli 0.0.54 → 0.0.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/cli",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "description": "Command line scaffolding tool for UNS applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,10 +26,10 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "azure-devops-node-api": "^15.1.1",
29
- "@uns-kit/core": "1.0.20"
29
+ "@uns-kit/core": "1.0.21"
30
30
  },
31
31
  "unsKitPackages": {
32
- "@uns-kit/core": "0.0.36",
32
+ "@uns-kit/core": "1.0.21",
33
33
  "@uns-kit/api": "0.0.19",
34
34
  "@uns-kit/cron": "0.0.18",
35
35
  "@uns-kit/temporal": "0.0.18"
@@ -7,8 +7,8 @@
7
7
  "handover": true,
8
8
  "jwksWellKnownUrl": "http://localhost:3200/api/.well-known/jwks.json",
9
9
  "kidWellKnownUrl": "http://localhost:3200/api/.well-known/kid",
10
- "email": "user@example-org.com",
11
- "password": "secret"
10
+ "email": "user@example.com",
11
+ "password": "123"
12
12
  },
13
13
  "infra": {
14
14
  "host": "localhost:1883"
@@ -24,7 +24,7 @@
24
24
  "dev": "tsx watch src/index.ts",
25
25
  "start": "node dist/index.js",
26
26
  "generate-config-schema": "node ./node_modules/@uns-kit/core/dist/tools/generate-config-schema.js",
27
- "generate-codegen": "graphql-code-generator --config codegen.ts",
27
+ "generate-codegen": "graphql-code-generator --require dotenv/config --config codegen.ts",
28
28
  "generate-uns-topics-tags": "node ./node_modules/@uns-kit/core/dist/tools/refresh-uns.js",
29
29
  "generate-uns-measurements": "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-measurements.js --input uns-measurements.json --output src/uns/uns-measurements.generated.ts"
30
30
  },
@@ -13,6 +13,7 @@ import {
13
13
  GeneratedObjectTypeDescriptions,
14
14
  } from "../uns/uns-dictionary.generated.js";
15
15
  import type { IUnsTableColumn } from "@uns-kit/core/uns/uns-interfaces.js";
16
+ import { GeneratedPhysicalMeasurements } from "../uns/uns-measurements.generated.js";
16
17
 
17
18
  /**
18
19
  * Load the configuration from a file.
@@ -28,13 +29,10 @@ registerAttributeDescriptions(GeneratedAttributeDescriptions);
28
29
  */
29
30
  const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName: config.uns.processName!});
30
31
  const mqttInput = await unsProxyProcess.createUnsMqttProxy((config.input?.host)!, "templateUnsRttInput", config.uns.instanceMode!, config.uns.handover!, {
31
- mqttSubToTopics: ["integration/raw-table"],
32
- publishThrottlingDelay:0,
33
- subscribeThrottlingDelay:0
32
+ mqttSubToTopics: ["raw/#"],
34
33
  });
35
34
  const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host)!, "templateUnsRttOutput", config.uns.instanceMode!, config.uns.handover!, {
36
- publishThrottlingDelay:0,
37
- subscribeThrottlingDelay:0
35
+ publishThrottlingDelay: 1000,
38
36
  });
39
37
 
40
38
  /**
@@ -44,21 +42,37 @@ const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host
44
42
  */
45
43
  mqttInput.event.on("input", async (event) => {
46
44
  try {
47
- if (event.topic === "integration/raw-table") {
48
- const time = UnsPacket.formatToISO8601(new Date());
45
+ if (event.topic === "raw/data") {
46
+ const values = event.message.split(",");
47
+ const [countRaw, timestampRaw, sensorRaw] = values;
48
+ if (!countRaw || !timestampRaw || !sensorRaw) {
49
+ logger.warn(`Skipping malformed raw/data payload: ${event.message}`);
50
+ return;
51
+ }
52
+
53
+ const currentValue = Number.parseFloat(countRaw);
54
+ const eventDate = new Date(Number.parseInt(timestampRaw, 10));
55
+ const sensorValue = Number.parseFloat(sensorRaw);
56
+
57
+ const time = UnsPacket.formatToISO8601(eventDate);
58
+ const dataGroup = "sensor_table";
49
59
  const columns: IUnsTableColumn[] = [
50
- { name: "kolona_a", type: "int", value: 10 },
51
- { name: "kolona_b", type: "symbol", value: "1" },
52
- { name: "kolona_c", type: "varchar", value: "10" },
53
- { name: "kolona_d", type: "double", value: 3 },
60
+ { name: "current", type: "double", value: currentValue, uom: GeneratedPhysicalMeasurements.Ampere },
61
+ { name: "voltage", type: "double", value: sensorValue },
54
62
  ];
55
-
56
- const message: IUnsMessage = { table: { dataGroup: "demo_table", columns, time } };
63
+ const message: IUnsMessage = {
64
+ table: {
65
+ dataGroup,
66
+ time,
67
+ columns,
68
+ },
69
+ };
57
70
  const topic: UnsTopics = "enterprise/site/area/line/";
58
71
  const packet = await UnsPacket.unsPacketFromUnsMessage(message);
59
72
  mqttOutput.publishMqttMessage({
60
73
  topic,
61
- asset:"asset",
74
+ asset: "asset",
75
+ assetDescription: "Sample asset",
62
76
  objectType: GeneratedObjectTypes["resource-status"],
63
77
  objectId: "main",
64
78
  attribute: GeneratedAttributes["status"] ?? "status",