@uns-kit/cli 2.0.27 → 2.0.28
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 +175 -175
- package/dist/index.js +67 -9
- package/package.json +5 -5
- package/templates/api/src/examples/api-example.ts +91 -91
- 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 +26 -26
- package/templates/config-files/config-localhost.json +26 -26
- package/templates/cron/AGENTS.md +24 -24
- 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 +24 -24
- package/templates/default/README.md +43 -43
- package/templates/default/config.json +27 -27
- package/templates/default/eslint.config.js +30 -30
- package/templates/default/gitignore +51 -51
- package/templates/default/package.json +45 -49
- 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 +86 -86
- package/templates/default/src/examples/load-test-data.ts +110 -110
- package/templates/default/src/examples/table-example.ts +97 -97
- package/templates/default/src/examples/table-window-load-test.ts +446 -446
- package/templates/default/src/examples/uns-gateway-cli.ts +10 -10
- package/templates/default/src/index.ts +15 -15
- 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 +102 -102
- package/templates/python/pyproject.toml +4 -4
- package/templates/python/runtime.json +4 -4
- package/templates/python/scripts/setup.sh +87 -87
- package/templates/temporal/src/examples/temporal-example.ts +37 -37
- 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,91 +1,91 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Change this file according to your specifications and rename it to index.ts
|
|
3
|
-
*/
|
|
4
|
-
import { UnsProxyProcess, ConfigFile } from "@uns-kit/core";
|
|
5
|
-
import { IApiProxyOptions } from "@uns-kit/core";
|
|
6
|
-
import type { UnsEvents } from "@uns-kit/core";
|
|
7
|
-
import "@uns-kit/api";
|
|
8
|
-
import { type UnsProxyProcessWithApi } from "@uns-kit/api";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Load the configuration from a file.
|
|
12
|
-
* On the server, this file is provided by the `uns-datahub-controller`.
|
|
13
|
-
* In the development environment, you are responsible for creating and maintaining this file and its contents.
|
|
14
|
-
*/
|
|
15
|
-
const config = await ConfigFile.loadConfig();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Connect to the API proxy process
|
|
19
|
-
*/
|
|
20
|
-
const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName: config.uns.processName}) as UnsProxyProcessWithApi;
|
|
21
|
-
const apiOptions: IApiProxyOptions = config.uns?.jwksWellKnownUrl
|
|
22
|
-
? {
|
|
23
|
-
jwks: {
|
|
24
|
-
wellKnownJwksUrl: config.uns.jwksWellKnownUrl,
|
|
25
|
-
...(config.uns.kidWellKnownUrl !== undefined
|
|
26
|
-
? { activeKidUrl: config.uns.kidWellKnownUrl }
|
|
27
|
-
: {}),
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
: {
|
|
31
|
-
jwtSecret: "CHANGEME",
|
|
32
|
-
};
|
|
33
|
-
const apiInput = await unsProxyProcess.createApiProxy("templateUnsApiInput", apiOptions);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Register an API endpoint and event handler
|
|
37
|
-
*/
|
|
38
|
-
apiInput.get(
|
|
39
|
-
"enterprise/site/area/line/",
|
|
40
|
-
"line-3-furnace",
|
|
41
|
-
"energy-resource",
|
|
42
|
-
"main-bus",
|
|
43
|
-
"summary-1",
|
|
44
|
-
{
|
|
45
|
-
tags: ["Tag1"],
|
|
46
|
-
apiDescription: "Test API endpoint 1",
|
|
47
|
-
queryParams: [
|
|
48
|
-
{ name: "filter", type: "string", required: true, description: "Filter za podatke" },
|
|
49
|
-
{ name: "limit", type: "number", required: false, description: "Koliko podatkov želiš" },
|
|
50
|
-
],
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
apiInput.get(
|
|
55
|
-
"enterprise/site/area/line/",
|
|
56
|
-
"line-3-compressor",
|
|
57
|
-
"utility-resource",
|
|
58
|
-
"air-loop-1",
|
|
59
|
-
"summary-2",
|
|
60
|
-
{
|
|
61
|
-
tags: ["Tag2"],
|
|
62
|
-
apiDescription: "Test API endpoint 2",
|
|
63
|
-
queryParams: [
|
|
64
|
-
{ name: "filter", type: "string", required: true, description: "Filter za podatke" },
|
|
65
|
-
{ name: "limit", type: "number", required: false, description: "Koliko podatkov želiš" },
|
|
66
|
-
],
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Optional: register a catch-all API mapping for a topic prefix.
|
|
72
|
-
* This does not create per-attribute API nodes; the controller treats it as a fallback handler.
|
|
73
|
-
* You can provide a separate Swagger doc for catch-all so it stays distinct from normal APIs (optional).
|
|
74
|
-
*/
|
|
75
|
-
await apiInput.registerCatchAll("sij/acroni/#", {
|
|
76
|
-
apiDescription: "Catch-all handler for sij/acroni/*",
|
|
77
|
-
tags: ["CatchAll"],
|
|
78
|
-
queryParams: [
|
|
79
|
-
{ name: "filter", type: "string", required: false, description: "Filter parameter" },
|
|
80
|
-
]
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
apiInput.event.on("apiGetEvent", (event: UnsEvents["apiGetEvent"]) => {
|
|
84
|
-
try {
|
|
85
|
-
const appContext = event.req.appContext;
|
|
86
|
-
// Add SQL query or any other code here
|
|
87
|
-
event.res.send("OK");
|
|
88
|
-
} catch (error) {
|
|
89
|
-
event.res.status(400).send("Error");
|
|
90
|
-
}
|
|
91
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Change this file according to your specifications and rename it to index.ts
|
|
3
|
+
*/
|
|
4
|
+
import { UnsProxyProcess, ConfigFile } from "@uns-kit/core";
|
|
5
|
+
import { IApiProxyOptions } from "@uns-kit/core";
|
|
6
|
+
import type { UnsEvents } from "@uns-kit/core";
|
|
7
|
+
import "@uns-kit/api";
|
|
8
|
+
import { type UnsProxyProcessWithApi } from "@uns-kit/api";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Load the configuration from a file.
|
|
12
|
+
* On the server, this file is provided by the `uns-datahub-controller`.
|
|
13
|
+
* In the development environment, you are responsible for creating and maintaining this file and its contents.
|
|
14
|
+
*/
|
|
15
|
+
const config = await ConfigFile.loadConfig();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Connect to the API proxy process
|
|
19
|
+
*/
|
|
20
|
+
const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName: config.uns.processName}) as UnsProxyProcessWithApi;
|
|
21
|
+
const apiOptions: IApiProxyOptions = config.uns?.jwksWellKnownUrl
|
|
22
|
+
? {
|
|
23
|
+
jwks: {
|
|
24
|
+
wellKnownJwksUrl: config.uns.jwksWellKnownUrl,
|
|
25
|
+
...(config.uns.kidWellKnownUrl !== undefined
|
|
26
|
+
? { activeKidUrl: config.uns.kidWellKnownUrl }
|
|
27
|
+
: {}),
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
: {
|
|
31
|
+
jwtSecret: "CHANGEME",
|
|
32
|
+
};
|
|
33
|
+
const apiInput = await unsProxyProcess.createApiProxy("templateUnsApiInput", apiOptions);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Register an API endpoint and event handler
|
|
37
|
+
*/
|
|
38
|
+
apiInput.get(
|
|
39
|
+
"enterprise/site/area/line/",
|
|
40
|
+
"line-3-furnace",
|
|
41
|
+
"energy-resource",
|
|
42
|
+
"main-bus",
|
|
43
|
+
"summary-1",
|
|
44
|
+
{
|
|
45
|
+
tags: ["Tag1"],
|
|
46
|
+
apiDescription: "Test API endpoint 1",
|
|
47
|
+
queryParams: [
|
|
48
|
+
{ name: "filter", type: "string", required: true, description: "Filter za podatke" },
|
|
49
|
+
{ name: "limit", type: "number", required: false, description: "Koliko podatkov želiš" },
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
apiInput.get(
|
|
55
|
+
"enterprise/site/area/line/",
|
|
56
|
+
"line-3-compressor",
|
|
57
|
+
"utility-resource",
|
|
58
|
+
"air-loop-1",
|
|
59
|
+
"summary-2",
|
|
60
|
+
{
|
|
61
|
+
tags: ["Tag2"],
|
|
62
|
+
apiDescription: "Test API endpoint 2",
|
|
63
|
+
queryParams: [
|
|
64
|
+
{ name: "filter", type: "string", required: true, description: "Filter za podatke" },
|
|
65
|
+
{ name: "limit", type: "number", required: false, description: "Koliko podatkov želiš" },
|
|
66
|
+
],
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Optional: register a catch-all API mapping for a topic prefix.
|
|
72
|
+
* This does not create per-attribute API nodes; the controller treats it as a fallback handler.
|
|
73
|
+
* You can provide a separate Swagger doc for catch-all so it stays distinct from normal APIs (optional).
|
|
74
|
+
*/
|
|
75
|
+
await apiInput.registerCatchAll("sij/acroni/#", {
|
|
76
|
+
apiDescription: "Catch-all handler for sij/acroni/*",
|
|
77
|
+
tags: ["CatchAll"],
|
|
78
|
+
queryParams: [
|
|
79
|
+
{ name: "filter", type: "string", required: false, description: "Filter parameter" },
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
apiInput.event.on("apiGetEvent", (event: UnsEvents["apiGetEvent"]) => {
|
|
84
|
+
try {
|
|
85
|
+
const appContext = event.req.appContext;
|
|
86
|
+
// Add SQL query or any other code here
|
|
87
|
+
event.res.send("OK");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
event.res.status(400).send("Error");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
variables:
|
|
2
|
-
privatePool: 'Azure private pool'
|
|
3
|
-
|
|
4
|
-
trigger:
|
|
5
|
-
- master
|
|
6
|
-
|
|
7
|
-
stages:
|
|
8
|
-
- stage: version_tag
|
|
9
|
-
displayName: Add Version Tag
|
|
10
|
-
pool: $(privatePool)
|
|
11
|
-
jobs:
|
|
12
|
-
- job: add_tags
|
|
13
|
-
steps:
|
|
14
|
-
- checkout: self
|
|
15
|
-
persistCredentials: true
|
|
16
|
-
clean: true
|
|
17
|
-
- script: |
|
|
18
|
-
tag=$(node -pe "require('./package.json').version")
|
|
19
|
-
git tag $tag
|
|
20
|
-
git push origin $tag
|
|
21
|
-
displayName: "Add version tag from package.json"
|
|
1
|
+
variables:
|
|
2
|
+
privatePool: 'Azure private pool'
|
|
3
|
+
|
|
4
|
+
trigger:
|
|
5
|
+
- master
|
|
6
|
+
|
|
7
|
+
stages:
|
|
8
|
+
- stage: version_tag
|
|
9
|
+
displayName: Add Version Tag
|
|
10
|
+
pool: $(privatePool)
|
|
11
|
+
jobs:
|
|
12
|
+
- job: add_tags
|
|
13
|
+
steps:
|
|
14
|
+
- checkout: self
|
|
15
|
+
persistCredentials: true
|
|
16
|
+
clean: true
|
|
17
|
+
- script: |
|
|
18
|
+
tag=$(node -pe "require('./package.json').version")
|
|
19
|
+
git tag $tag
|
|
20
|
+
git push origin $tag
|
|
21
|
+
displayName: "Add version tag from package.json"
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
2
|
-
import { ConfigFile } from '@uns-kit/core';
|
|
3
|
-
|
|
4
|
-
const appConfig = await ConfigFile.loadConfig();
|
|
5
|
-
|
|
6
|
-
const config: CodegenConfig = {
|
|
7
|
-
schema: appConfig.uns.graphql,
|
|
8
|
-
generates: {
|
|
9
|
-
'src/graphql/schema.ts': {
|
|
10
|
-
plugins: ['typescript', 'typescript-operations', 'typescript-resolvers'],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default config;
|
|
1
|
+
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
2
|
+
import { ConfigFile } from '@uns-kit/core';
|
|
3
|
+
|
|
4
|
+
const appConfig = await ConfigFile.loadConfig();
|
|
5
|
+
|
|
6
|
+
const config: CodegenConfig = {
|
|
7
|
+
schema: appConfig.uns.graphql,
|
|
8
|
+
generates: {
|
|
9
|
+
'src/graphql/schema.ts': {
|
|
10
|
+
plugins: ['typescript', 'typescript-operations', 'typescript-resolvers'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type UnsTags = string & {};
|
|
1
|
+
export type UnsTags = string & {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type UnsTopics = string & {};
|
|
1
|
+
export type UnsTopics = string & {};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"uns": {
|
|
3
|
-
"graphql": "http://uns-datahub-controller:3200/graphql",
|
|
4
|
-
"rest": "http://uns-datahub-controller:3200/api",
|
|
5
|
-
"processName": "__APP_NAME__",
|
|
6
|
-
"instanceMode": "wait",
|
|
7
|
-
"handover": true,
|
|
8
|
-
"jwksWellKnownUrl": "http://uns-datahub-controller:3200/api/.well-known/jwks.json",
|
|
9
|
-
"kidWellKnownUrl": "http://uns-datahub-controller:3200/api/.well-known/kid",
|
|
10
|
-
"email": "user@example-org.com",
|
|
11
|
-
"password": "secret"
|
|
12
|
-
},
|
|
13
|
-
"infra": {
|
|
14
|
-
"host": "mosquitto:1883"
|
|
15
|
-
},
|
|
16
|
-
"output": {
|
|
17
|
-
"host": "mosquitto:1883"
|
|
18
|
-
},
|
|
19
|
-
"input": {
|
|
20
|
-
"host": "mosquitto:1883"
|
|
21
|
-
},
|
|
22
|
-
"devops": {
|
|
23
|
-
"provider": "azure-devops",
|
|
24
|
-
"organization": "example-org",
|
|
25
|
-
"project": "example-project"
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"uns": {
|
|
3
|
+
"graphql": "http://uns-datahub-controller:3200/graphql",
|
|
4
|
+
"rest": "http://uns-datahub-controller:3200/api",
|
|
5
|
+
"processName": "__APP_NAME__",
|
|
6
|
+
"instanceMode": "wait",
|
|
7
|
+
"handover": true,
|
|
8
|
+
"jwksWellKnownUrl": "http://uns-datahub-controller:3200/api/.well-known/jwks.json",
|
|
9
|
+
"kidWellKnownUrl": "http://uns-datahub-controller:3200/api/.well-known/kid",
|
|
10
|
+
"email": "user@example-org.com",
|
|
11
|
+
"password": "secret"
|
|
12
|
+
},
|
|
13
|
+
"infra": {
|
|
14
|
+
"host": "mosquitto:1883"
|
|
15
|
+
},
|
|
16
|
+
"output": {
|
|
17
|
+
"host": "mosquitto:1883"
|
|
18
|
+
},
|
|
19
|
+
"input": {
|
|
20
|
+
"host": "mosquitto:1883"
|
|
21
|
+
},
|
|
22
|
+
"devops": {
|
|
23
|
+
"provider": "azure-devops",
|
|
24
|
+
"organization": "example-org",
|
|
25
|
+
"project": "example-project"
|
|
26
|
+
}
|
|
27
27
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"uns": {
|
|
3
|
-
"graphql": "http://localhost:3200/graphql",
|
|
4
|
-
"rest": "http://localhost:3200/api",
|
|
5
|
-
"processName": "__APP_NAME__",
|
|
6
|
-
"instanceMode": "wait",
|
|
7
|
-
"handover": true,
|
|
8
|
-
"jwksWellKnownUrl": "http://localhost:3200/api/.well-known/jwks.json",
|
|
9
|
-
"kidWellKnownUrl": "http://localhost:3200/api/.well-known/kid",
|
|
10
|
-
"email": "user@example-org.com",
|
|
11
|
-
"password": "secret"
|
|
12
|
-
},
|
|
13
|
-
"infra": {
|
|
14
|
-
"host": "localhost:1883"
|
|
15
|
-
},
|
|
16
|
-
"output": {
|
|
17
|
-
"host": "localhost:1883"
|
|
18
|
-
},
|
|
19
|
-
"input": {
|
|
20
|
-
"host": "localhost:1883"
|
|
21
|
-
},
|
|
22
|
-
"devops": {
|
|
23
|
-
"provider": "azure-devops",
|
|
24
|
-
"organization": "example-org",
|
|
25
|
-
"project": "example-project"
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"uns": {
|
|
3
|
+
"graphql": "http://localhost:3200/graphql",
|
|
4
|
+
"rest": "http://localhost:3200/api",
|
|
5
|
+
"processName": "__APP_NAME__",
|
|
6
|
+
"instanceMode": "wait",
|
|
7
|
+
"handover": true,
|
|
8
|
+
"jwksWellKnownUrl": "http://localhost:3200/api/.well-known/jwks.json",
|
|
9
|
+
"kidWellKnownUrl": "http://localhost:3200/api/.well-known/kid",
|
|
10
|
+
"email": "user@example-org.com",
|
|
11
|
+
"password": "secret"
|
|
12
|
+
},
|
|
13
|
+
"infra": {
|
|
14
|
+
"host": "localhost:1883"
|
|
15
|
+
},
|
|
16
|
+
"output": {
|
|
17
|
+
"host": "localhost:1883"
|
|
18
|
+
},
|
|
19
|
+
"input": {
|
|
20
|
+
"host": "localhost:1883"
|
|
21
|
+
},
|
|
22
|
+
"devops": {
|
|
23
|
+
"provider": "azure-devops",
|
|
24
|
+
"organization": "example-org",
|
|
25
|
+
"project": "example-project"
|
|
26
|
+
}
|
|
27
27
|
}
|
package/templates/cron/AGENTS.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# Agent Onboarding (template)
|
|
2
|
-
|
|
3
|
-
Pointers for AI/code-assist tools when working in this generated project.
|
|
4
|
-
|
|
5
|
-
## What to read locally
|
|
6
|
-
|
|
7
|
-
- `package.json` for scripts (`generate-uns-*`, `generate-codegen`, etc.).
|
|
8
|
-
- `config.schema.json` for the app config shape; `processName` is required.
|
|
9
|
-
- `src/examples/*.ts` for cron-driven publish patterns and description registration.
|
|
10
|
-
- Installed docs (under `node_modules`):
|
|
11
|
-
- `@uns-kit/core/README.md`
|
|
12
|
-
- `@uns-kit/api/README.md` (if installed)
|
|
13
|
-
- `@uns-kit/cron/README.md` (if installed)
|
|
14
|
-
- `@uns-kit/temporal/README.md` (if installed)
|
|
15
|
-
- `@uns-kit/cli/README.md` (if installed)
|
|
16
|
-
|
|
17
|
-
## Generators in this project
|
|
18
|
-
|
|
19
|
-
- `pnpm run generate-uns-dictionary` -> updates `src/uns/uns-dictionary.generated.ts`
|
|
20
|
-
- `pnpm run generate-uns-measurements` -> updates `src/uns/uns-measurements.generated.ts`
|
|
21
|
-
- `pnpm run generate-uns-reference` -> runs both
|
|
22
|
-
- `pnpm run generate-uns-metadata` -> refreshes topic/tag unions (requires GraphQL connectivity)
|
|
23
|
-
- `pnpm run generate-codegen` -> GraphQL codegen (after configure-codegen)
|
|
24
|
-
- `pnpm run sync-uns-schema -- --controller-url ... --token ...` -> pulls `uns-dictionary.json` + `uns-measurements.json` from the controller and regenerates local TS helpers
|
|
1
|
+
# Agent Onboarding (template)
|
|
2
|
+
|
|
3
|
+
Pointers for AI/code-assist tools when working in this generated project.
|
|
4
|
+
|
|
5
|
+
## What to read locally
|
|
6
|
+
|
|
7
|
+
- `package.json` for scripts (`generate-uns-*`, `generate-codegen`, etc.).
|
|
8
|
+
- `config.schema.json` for the app config shape; `processName` is required.
|
|
9
|
+
- `src/examples/*.ts` for cron-driven publish patterns and description registration.
|
|
10
|
+
- Installed docs (under `node_modules`):
|
|
11
|
+
- `@uns-kit/core/README.md`
|
|
12
|
+
- `@uns-kit/api/README.md` (if installed)
|
|
13
|
+
- `@uns-kit/cron/README.md` (if installed)
|
|
14
|
+
- `@uns-kit/temporal/README.md` (if installed)
|
|
15
|
+
- `@uns-kit/cli/README.md` (if installed)
|
|
16
|
+
|
|
17
|
+
## Generators in this project
|
|
18
|
+
|
|
19
|
+
- `pnpm run generate-uns-dictionary` -> updates `src/uns/uns-dictionary.generated.ts`
|
|
20
|
+
- `pnpm run generate-uns-measurements` -> updates `src/uns/uns-measurements.generated.ts`
|
|
21
|
+
- `pnpm run generate-uns-reference` -> runs both
|
|
22
|
+
- `pnpm run generate-uns-metadata` -> refreshes topic/tag unions (requires GraphQL connectivity)
|
|
23
|
+
- `pnpm run generate-codegen` -> GraphQL codegen (after configure-codegen)
|
|
24
|
+
- `pnpm run sync-uns-schema -- --controller-url ... --token ...` -> pulls `uns-dictionary.json` + `uns-measurements.json` from the controller and regenerates local TS helpers
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Change this file according to your specifications and rename it to index.ts
|
|
3
|
-
*/
|
|
4
|
-
import { UnsProxyProcess, ConfigFile, UnsEvents, getLogger } from "@uns-kit/core";
|
|
5
|
-
import { registerAttributeDescriptions, registerObjectTypeDescriptions } from "@uns-kit/core/uns/uns-dictionary-registry.js";
|
|
6
|
-
import "@uns-kit/cron";
|
|
7
|
-
import { type UnsProxyProcessWithCron } from "@uns-kit/cron";
|
|
8
|
-
import { UnsTopics } from "@uns-kit/core/uns/uns-topics.js";
|
|
9
|
-
import { UnsPacket } from "@uns-kit/core/uns/uns-packet.js";
|
|
10
|
-
import {
|
|
11
|
-
GeneratedObjectTypes,
|
|
12
|
-
GeneratedAttributes,
|
|
13
|
-
GeneratedAttributesByType,
|
|
14
|
-
GeneratedAttributeDescriptions,
|
|
15
|
-
GeneratedObjectTypeDescriptions,
|
|
16
|
-
} from "../uns/uns-dictionary.generated.js";
|
|
17
|
-
import { GeneratedPhysicalMeasurements } from "../uns/uns-measurements.generated.js";
|
|
18
|
-
import { GeneratedAssets, resolveGeneratedAsset } from "../uns/uns-assets.js";
|
|
19
|
-
|
|
20
|
-
const logger = getLogger(import.meta.url);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Load the configuration from a file.
|
|
25
|
-
* On the server, this file is provided by the `uns-datahub-controller`.
|
|
26
|
-
* In the development environment, you are responsible for creating and maintaining this file and its contents.
|
|
27
|
-
*/
|
|
28
|
-
const config = await ConfigFile.loadConfig();
|
|
29
|
-
registerObjectTypeDescriptions(GeneratedObjectTypeDescriptions);
|
|
30
|
-
registerAttributeDescriptions(GeneratedAttributeDescriptions);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Connect to the output broker and create a crontab proxy
|
|
34
|
-
*/
|
|
35
|
-
const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithCron;;
|
|
36
|
-
const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host)!, "templateUnsRttOutput", config.uns.instanceMode!, config.uns.handover!, { publishThrottlingDelay: 1000});
|
|
37
|
-
const cronInput = await unsProxyProcess.createCrontabProxy("* * * * * *");
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Event listener for cron events.
|
|
41
|
-
* On each cron event, publish a message to the MQTT output broker.
|
|
42
|
-
*/
|
|
43
|
-
cronInput.event.on("cronEvent", async (event: UnsEvents["cronEvent"]) => {
|
|
44
|
-
try {
|
|
45
|
-
const time = UnsPacket.formatToISO8601(new Date());
|
|
46
|
-
const numberValue: number = 42;
|
|
47
|
-
const topic: UnsTopics = "example/";
|
|
48
|
-
const asset = resolveGeneratedAsset("asset");
|
|
49
|
-
const assetDescription = "Sample asset";
|
|
50
|
-
|
|
51
|
-
const dataGroup = "sensor";
|
|
52
|
-
|
|
53
|
-
mqttOutput.publishMqttMessage({
|
|
54
|
-
topic,
|
|
55
|
-
asset,
|
|
56
|
-
assetDescription,
|
|
57
|
-
objectType: GeneratedObjectTypes.equipment,
|
|
58
|
-
objectId: "main",
|
|
59
|
-
attributes: [
|
|
60
|
-
{
|
|
61
|
-
attribute: GeneratedAttributesByType["energy-resource"]["current"],
|
|
62
|
-
data: { dataGroup, time, value: numberValue, uom: GeneratedPhysicalMeasurements.Ampere }
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
});
|
|
66
|
-
} catch (error) {
|
|
67
|
-
const reason = error instanceof Error ? error : new Error(String(error));
|
|
68
|
-
logger.error(`Error publishing message to MQTT: ${reason.message}`);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Change this file according to your specifications and rename it to index.ts
|
|
3
|
+
*/
|
|
4
|
+
import { UnsProxyProcess, ConfigFile, UnsEvents, getLogger } from "@uns-kit/core";
|
|
5
|
+
import { registerAttributeDescriptions, registerObjectTypeDescriptions } from "@uns-kit/core/uns/uns-dictionary-registry.js";
|
|
6
|
+
import "@uns-kit/cron";
|
|
7
|
+
import { type UnsProxyProcessWithCron } from "@uns-kit/cron";
|
|
8
|
+
import { UnsTopics } from "@uns-kit/core/uns/uns-topics.js";
|
|
9
|
+
import { UnsPacket } from "@uns-kit/core/uns/uns-packet.js";
|
|
10
|
+
import {
|
|
11
|
+
GeneratedObjectTypes,
|
|
12
|
+
GeneratedAttributes,
|
|
13
|
+
GeneratedAttributesByType,
|
|
14
|
+
GeneratedAttributeDescriptions,
|
|
15
|
+
GeneratedObjectTypeDescriptions,
|
|
16
|
+
} from "../uns/uns-dictionary.generated.js";
|
|
17
|
+
import { GeneratedPhysicalMeasurements } from "../uns/uns-measurements.generated.js";
|
|
18
|
+
import { GeneratedAssets, resolveGeneratedAsset } from "../uns/uns-assets.js";
|
|
19
|
+
|
|
20
|
+
const logger = getLogger(import.meta.url);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Load the configuration from a file.
|
|
25
|
+
* On the server, this file is provided by the `uns-datahub-controller`.
|
|
26
|
+
* In the development environment, you are responsible for creating and maintaining this file and its contents.
|
|
27
|
+
*/
|
|
28
|
+
const config = await ConfigFile.loadConfig();
|
|
29
|
+
registerObjectTypeDescriptions(GeneratedObjectTypeDescriptions);
|
|
30
|
+
registerAttributeDescriptions(GeneratedAttributeDescriptions);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Connect to the output broker and create a crontab proxy
|
|
34
|
+
*/
|
|
35
|
+
const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithCron;;
|
|
36
|
+
const mqttOutput = await unsProxyProcess.createUnsMqttProxy((config.output?.host)!, "templateUnsRttOutput", config.uns.instanceMode!, config.uns.handover!, { publishThrottlingDelay: 1000});
|
|
37
|
+
const cronInput = await unsProxyProcess.createCrontabProxy("* * * * * *");
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Event listener for cron events.
|
|
41
|
+
* On each cron event, publish a message to the MQTT output broker.
|
|
42
|
+
*/
|
|
43
|
+
cronInput.event.on("cronEvent", async (event: UnsEvents["cronEvent"]) => {
|
|
44
|
+
try {
|
|
45
|
+
const time = UnsPacket.formatToISO8601(new Date());
|
|
46
|
+
const numberValue: number = 42;
|
|
47
|
+
const topic: UnsTopics = "example/";
|
|
48
|
+
const asset = resolveGeneratedAsset("asset");
|
|
49
|
+
const assetDescription = "Sample asset";
|
|
50
|
+
|
|
51
|
+
const dataGroup = "sensor";
|
|
52
|
+
|
|
53
|
+
mqttOutput.publishMqttMessage({
|
|
54
|
+
topic,
|
|
55
|
+
asset,
|
|
56
|
+
assetDescription,
|
|
57
|
+
objectType: GeneratedObjectTypes.equipment,
|
|
58
|
+
objectId: "main",
|
|
59
|
+
attributes: [
|
|
60
|
+
{
|
|
61
|
+
attribute: GeneratedAttributesByType["energy-resource"]["current"],
|
|
62
|
+
data: { dataGroup, time, value: numberValue, uom: GeneratedPhysicalMeasurements.Ampere }
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const reason = error instanceof Error ? error : new Error(String(error));
|
|
68
|
+
logger.error(`Error publishing message to MQTT: ${reason.message}`);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
dist
|
|
1
|
+
dist
|
|
2
2
|
node_modules
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
{
|
|
2
|
-
"semi": true,
|
|
3
|
-
"singleQuote": true,
|
|
4
|
-
"tabWidth": 2,
|
|
5
|
-
"trailingComma": "all",
|
|
6
|
-
"printWidth": 140
|
|
7
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"tabWidth": 2,
|
|
5
|
+
"trailingComma": "all",
|
|
6
|
+
"printWidth": 140
|
|
7
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# Agent Onboarding (template)
|
|
2
|
-
|
|
3
|
-
Pointers for AI/code-assist tools when working in this generated project.
|
|
4
|
-
|
|
5
|
-
## What to read locally
|
|
6
|
-
|
|
7
|
-
- `package.json` for scripts (`generate-uns-*`, `generate-codegen`, etc.).
|
|
8
|
-
- `config.schema.json` for the app config shape; `processName` is required.
|
|
9
|
-
- `src/examples/*.ts` for idiomatic publishing (multi-attribute) and description registration.
|
|
10
|
-
- Installed docs (under `node_modules`):
|
|
11
|
-
- `@uns-kit/core/README.md`
|
|
12
|
-
- `@uns-kit/api/README.md` (if installed)
|
|
13
|
-
- `@uns-kit/cron/README.md` (if installed)
|
|
14
|
-
- `@uns-kit/temporal/README.md` (if installed)
|
|
15
|
-
- `@uns-kit/cli/README.md` (if installed)
|
|
16
|
-
|
|
17
|
-
## Generators in this project
|
|
18
|
-
|
|
19
|
-
- `pnpm run generate-uns-dictionary` -> updates `src/uns/uns-dictionary.generated.ts`
|
|
20
|
-
- `pnpm run generate-uns-measurements` -> updates `src/uns/uns-measurements.generated.ts`
|
|
21
|
-
- `pnpm run generate-uns-reference` -> runs both
|
|
22
|
-
- `pnpm run generate-uns-metadata` -> refreshes topic/tag unions (requires GraphQL connectivity)
|
|
23
|
-
- `pnpm run generate-codegen` -> GraphQL codegen (after configure-codegen)
|
|
24
|
-
- `pnpm run sync-uns-schema -- --controller-url ... --token ...` -> pulls `uns-dictionary.json` + `uns-measurements.json` from the controller and regenerates local TS helpers
|
|
1
|
+
# Agent Onboarding (template)
|
|
2
|
+
|
|
3
|
+
Pointers for AI/code-assist tools when working in this generated project.
|
|
4
|
+
|
|
5
|
+
## What to read locally
|
|
6
|
+
|
|
7
|
+
- `package.json` for scripts (`generate-uns-*`, `generate-codegen`, etc.).
|
|
8
|
+
- `config.schema.json` for the app config shape; `processName` is required.
|
|
9
|
+
- `src/examples/*.ts` for idiomatic publishing (multi-attribute) and description registration.
|
|
10
|
+
- Installed docs (under `node_modules`):
|
|
11
|
+
- `@uns-kit/core/README.md`
|
|
12
|
+
- `@uns-kit/api/README.md` (if installed)
|
|
13
|
+
- `@uns-kit/cron/README.md` (if installed)
|
|
14
|
+
- `@uns-kit/temporal/README.md` (if installed)
|
|
15
|
+
- `@uns-kit/cli/README.md` (if installed)
|
|
16
|
+
|
|
17
|
+
## Generators in this project
|
|
18
|
+
|
|
19
|
+
- `pnpm run generate-uns-dictionary` -> updates `src/uns/uns-dictionary.generated.ts`
|
|
20
|
+
- `pnpm run generate-uns-measurements` -> updates `src/uns/uns-measurements.generated.ts`
|
|
21
|
+
- `pnpm run generate-uns-reference` -> runs both
|
|
22
|
+
- `pnpm run generate-uns-metadata` -> refreshes topic/tag unions (requires GraphQL connectivity)
|
|
23
|
+
- `pnpm run generate-codegen` -> GraphQL codegen (after configure-codegen)
|
|
24
|
+
- `pnpm run sync-uns-schema -- --controller-url ... --token ...` -> pulls `uns-dictionary.json` + `uns-measurements.json` from the controller and regenerates local TS helpers
|