@uns-kit/cli 2.0.70 → 2.0.71
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/LICENSE +21 -21
- package/README.md +168 -168
- package/dist/index.js +75 -54
- package/package.json +6 -6
- package/templates/api/src/examples/api-example.ts +155 -155
- package/templates/azure-pipelines.yml +21 -21
- package/templates/codegen/codegen.ts +15 -15
- package/templates/codegen/src/uns/uns-tags.ts +1 -1
- package/templates/codegen/src/uns/uns-topics.ts +1 -1
- package/templates/config-files/config-docker.json +32 -32
- package/templates/config-files/config-localhost.json +32 -32
- package/templates/cron/AGENTS.md +20 -20
- package/templates/cron/src/examples/cron-example.ts +71 -71
- package/templates/default/.prettierignore +1 -1
- package/templates/default/.prettierrc +7 -7
- package/templates/default/AGENTS.md +20 -20
- package/templates/default/README.md +101 -99
- package/templates/default/config.json +35 -35
- package/templates/default/eslint.config.js +30 -30
- package/templates/default/gitignore +51 -51
- package/templates/default/package.json +46 -46
- package/templates/default/src/config/project.config.extension.example +23 -23
- package/templates/default/src/config/project.config.extension.ts +6 -6
- package/templates/default/src/examples/data-example.ts +78 -78
- package/templates/default/src/examples/load-test-data.ts +105 -105
- package/templates/default/src/examples/schema-system-metadata-example.ts +121 -123
- package/templates/default/src/examples/subasset-example.ts +72 -74
- package/templates/default/src/examples/table-example.ts +95 -95
- package/templates/default/src/examples/table-window-load-test.ts +440 -440
- package/templates/default/src/examples/uns-gateway-cli.ts +10 -10
- package/templates/default/src/index.ts +59 -38
- package/templates/default/src/uns/uns-assets.ts +12 -12
- package/templates/default/src/uns/uns-dictionary.generated.ts +758 -758
- package/templates/default/src/uns/uns-measurements.generated.ts +366 -366
- package/templates/default/src/uns/uns-tags.ts +2 -2
- package/templates/default/src/uns/uns-topics.ts +2 -2
- package/templates/default/tsconfig.json +29 -29
- package/templates/python/app/README.md +8 -8
- package/templates/python/examples/README.md +134 -134
- package/templates/python/examples/api_handler.py +28 -28
- package/templates/python/examples/data_publish.py +11 -11
- package/templates/python/examples/data_subscribe.py +8 -8
- package/templates/python/examples/data_transformer.py +17 -17
- package/templates/python/examples/table_transformer.py +15 -15
- package/templates/python/gateway/cli.py +75 -75
- package/templates/python/gateway/client.py +155 -155
- package/templates/python/gateway/manager.py +97 -97
- package/templates/python/gitignore +47 -47
- package/templates/python/proto/uns-gateway.proto +105 -105
- package/templates/python/pyproject.toml +4 -4
- package/templates/python/runtime.json +4 -4
- package/templates/python/scripts/setup.sh +87 -87
- package/templates/uns-dictionary/uns-dictionary.json +650 -650
- package/templates/uns-measurements/uns-measurements.json +360 -360
- package/templates/vscode/.vscode/launch.json +164 -164
- package/templates/vscode/.vscode/settings.json +9 -9
- package/templates/vscode/.vscode/tasks.json +27 -27
- package/templates/vscode/uns-kit.code-workspace +13 -13
- package/templates/python/gen/__init__.py +0 -1
- package/templates/python/gen/uns_gateway_pb2.py +0 -70
- package/templates/python/gen/uns_gateway_pb2_grpc.py +0 -312
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { startUnsGateway } from "@uns-kit/core/uns-grpc/uns-gateway-server.js";
|
|
2
|
-
import { getLogger } from "@uns-kit/core";
|
|
3
|
-
|
|
4
|
-
const logger = getLogger(import.meta.url);
|
|
5
|
-
|
|
6
|
-
const addr = await startUnsGateway();
|
|
7
|
-
logger.info(`UNS Gateway listening on ${addr.address} (UDS=${addr.isUDS})`);
|
|
8
|
-
// Keep alive
|
|
9
|
-
setInterval(() => {}, 1 << 30);
|
|
10
|
-
|
|
1
|
+
import { startUnsGateway } from "@uns-kit/core/uns-grpc/uns-gateway-server.js";
|
|
2
|
+
import { getLogger } from "@uns-kit/core";
|
|
3
|
+
|
|
4
|
+
const logger = getLogger(import.meta.url);
|
|
5
|
+
|
|
6
|
+
const addr = await startUnsGateway();
|
|
7
|
+
logger.info(`UNS Gateway listening on ${addr.address} (UDS=${addr.isUDS})`);
|
|
8
|
+
// Keep alive
|
|
9
|
+
setInterval(() => {}, 1 << 30);
|
|
10
|
+
|
|
@@ -1,45 +1,66 @@
|
|
|
1
|
-
import { ConfigFile, UnsProxyProcess } from "@uns-kit/core";
|
|
2
|
-
import type { ISO8601 } from "@uns-kit/core/uns/uns-interfaces.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { ConfigFile, UnsProxyProcess } from "@uns-kit/core";
|
|
2
|
+
import type { ISO8601 } from "@uns-kit/core/uns/uns-interfaces.js";
|
|
3
|
+
|
|
4
|
+
let activeProcess: UnsProxyProcess | undefined;
|
|
5
|
+
|
|
6
|
+
async function main(): Promise<void> {
|
|
7
|
+
const config = await ConfigFile.loadConfig();
|
|
8
|
+
const processName = config.uns.processName ?? "__APP_NAME__";
|
|
9
|
+
const unsProcess = new UnsProxyProcess(config.infra.host ?? "localhost", {
|
|
10
|
+
processName,
|
|
11
|
+
});
|
|
12
|
+
activeProcess = unsProcess;
|
|
13
|
+
const shutdown = (signal: NodeJS.Signals): void => {
|
|
14
|
+
console.log(`Received ${signal}; shutting down UNS process '${processName}'.`);
|
|
15
|
+
void unsProcess.shutdown().catch((error: unknown) => {
|
|
16
|
+
const reason = error instanceof Error ? error : new Error(String(error));
|
|
17
|
+
console.error(`UNS process '${processName}' shutdown failed: ${reason.message}`);
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
process.once("SIGINT", () => shutdown("SIGINT"));
|
|
22
|
+
process.once("SIGTERM", () => shutdown("SIGTERM"));
|
|
23
|
+
|
|
24
|
+
const mqttOutput = await unsProcess.createUnsMqttProxy(
|
|
25
|
+
config.output?.host ?? "localhost",
|
|
26
|
+
"defaultOutput",
|
|
27
|
+
config.uns.instanceMode ?? "wait",
|
|
28
|
+
config.uns.handover ?? true,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const time = new Date().toISOString() as ISO8601;
|
|
32
|
+
|
|
20
33
|
await mqttOutput.publishMqttMessage({
|
|
21
|
-
topic: "example/site/area/line/",
|
|
22
|
-
asset: "demo-asset",
|
|
23
|
-
objectType: "utility-resource",
|
|
24
|
-
objectId: "main",
|
|
25
|
-
attributes: {
|
|
26
|
-
attribute: "status",
|
|
27
|
-
description: "Service startup marker",
|
|
28
|
-
data: {
|
|
29
|
-
time,
|
|
30
|
-
value: "started",
|
|
31
|
-
dataGroup: "runtime",
|
|
32
|
-
},
|
|
33
|
-
validityMode: "lifecycle",
|
|
34
|
-
lifecycleEndValue: "stopped",
|
|
35
|
-
},
|
|
34
|
+
topic: "example/site/area/line/",
|
|
35
|
+
asset: "demo-asset",
|
|
36
|
+
objectType: "utility-resource",
|
|
37
|
+
objectId: "main",
|
|
38
|
+
attributes: {
|
|
39
|
+
attribute: "status",
|
|
40
|
+
description: "Service startup marker",
|
|
41
|
+
data: {
|
|
42
|
+
time,
|
|
43
|
+
value: "started",
|
|
44
|
+
dataGroup: "runtime",
|
|
45
|
+
},
|
|
46
|
+
validityMode: "lifecycle",
|
|
47
|
+
lifecycleEndValue: "stopped",
|
|
48
|
+
},
|
|
36
49
|
});
|
|
37
50
|
|
|
38
51
|
await mqttOutput.flush();
|
|
39
|
-
await mqttOutput.stop();
|
|
40
|
-
await unsProcess.shutdown();
|
|
41
52
|
|
|
42
53
|
console.log(`UNS process '${processName}' is ready. Edit src/index.ts to add your logic.`);
|
|
43
54
|
}
|
|
44
|
-
|
|
45
|
-
void main()
|
|
55
|
+
|
|
56
|
+
void main().catch(async (error: unknown) => {
|
|
57
|
+
const reason = error instanceof Error ? error : new Error(String(error));
|
|
58
|
+
try {
|
|
59
|
+
await activeProcess?.shutdown();
|
|
60
|
+
} catch (shutdownError) {
|
|
61
|
+
const shutdownReason = shutdownError instanceof Error ? shutdownError : new Error(String(shutdownError));
|
|
62
|
+
console.error(`UNS process cleanup failed: ${shutdownReason.message}`);
|
|
63
|
+
}
|
|
64
|
+
console.error(`UNS process startup failed: ${reason.message}`);
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// Generated UNS asset list. Run `pnpm run sync-uns-metadata` to update.
|
|
2
|
-
export const GeneratedAssets = {
|
|
3
|
-
/** Example asset. Replace with your own names after running sync-uns-metadata. */
|
|
4
|
-
"asset": "asset",
|
|
5
|
-
} as const;
|
|
6
|
-
export type GeneratedAssetName = typeof GeneratedAssets[keyof typeof GeneratedAssets];
|
|
7
|
-
|
|
8
|
-
export function resolveGeneratedAsset(name: keyof typeof GeneratedAssets): (typeof GeneratedAssets)[keyof typeof GeneratedAssets];
|
|
9
|
-
export function resolveGeneratedAsset<T extends string>(name: T): (typeof GeneratedAssets)[keyof typeof GeneratedAssets] | T;
|
|
10
|
-
export function resolveGeneratedAsset(name: string): string {
|
|
11
|
-
return (GeneratedAssets as Record<string, string>)[name] ?? name;
|
|
12
|
-
}
|
|
1
|
+
// Generated UNS asset list. Run `pnpm run sync-uns-metadata` to update.
|
|
2
|
+
export const GeneratedAssets = {
|
|
3
|
+
/** Example asset. Replace with your own names after running sync-uns-metadata. */
|
|
4
|
+
"asset": "asset",
|
|
5
|
+
} as const;
|
|
6
|
+
export type GeneratedAssetName = typeof GeneratedAssets[keyof typeof GeneratedAssets];
|
|
7
|
+
|
|
8
|
+
export function resolveGeneratedAsset(name: keyof typeof GeneratedAssets): (typeof GeneratedAssets)[keyof typeof GeneratedAssets];
|
|
9
|
+
export function resolveGeneratedAsset<T extends string>(name: T): (typeof GeneratedAssets)[keyof typeof GeneratedAssets] | T;
|
|
10
|
+
export function resolveGeneratedAsset(name: string): string {
|
|
11
|
+
return (GeneratedAssets as Record<string, string>)[name] ?? name;
|
|
12
|
+
}
|