@uns-kit/cli 0.0.36 → 0.0.38
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 +128 -128
- package/dist/index.js +11 -5
- package/package.json +8 -2
- package/templates/api/src/examples/api-example.ts +62 -62
- 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/src/examples/cron-example.ts +46 -46
- package/templates/default/README.md +32 -30
- package/templates/default/config.json +27 -27
- package/templates/default/gitignore +51 -51
- package/templates/default/package.json +38 -19
- 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 +68 -68
- package/templates/default/src/examples/load-test-data.ts +108 -108
- package/templates/default/src/examples/table-example.ts +66 -66
- package/templates/default/src/examples/uns-gateway-cli.ts +7 -7
- package/templates/default/src/index.ts +15 -15
- 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 -16
- 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/proto/uns-gateway.proto +102 -102
- package/templates/python/pyproject.toml +4 -4
- package/templates/python/scripts/setup.sh +87 -87
- package/templates/temporal/src/examples/temporal-example.ts +35 -35
- package/templates/vscode/.vscode/launch.json +164 -164
- package/templates/vscode/.vscode/settings.json +9 -9
- 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,102 +1,102 @@
|
|
|
1
|
-
syntax = "proto3";
|
|
2
|
-
|
|
3
|
-
package uns;
|
|
4
|
-
|
|
5
|
-
service UnsGateway {
|
|
6
|
-
rpc Publish (PublishRequest) returns (Ack);
|
|
7
|
-
rpc Subscribe (SubscribeRequest) returns (stream MqttMessage);
|
|
8
|
-
rpc RegisterApiGet (RegisterApiGetRequest) returns (Ack);
|
|
9
|
-
rpc UnregisterApiGet (UnregisterApiGetRequest) returns (Ack);
|
|
10
|
-
rpc ApiEventStream (stream ApiEventResponse) returns (stream ApiEvent);
|
|
11
|
-
rpc Ready (ReadyRequest) returns (Ack);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
message PublishRequest {
|
|
15
|
-
string topic = 1;
|
|
16
|
-
string attribute = 2;
|
|
17
|
-
string description = 3;
|
|
18
|
-
repeated string tags = 4;
|
|
19
|
-
bool attribute_needs_persistence = 5;
|
|
20
|
-
oneof content {
|
|
21
|
-
Data data = 6;
|
|
22
|
-
Table table = 7;
|
|
23
|
-
}
|
|
24
|
-
bool value_is_cumulative = 8; // for Data: publish as delta
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
message Data {
|
|
28
|
-
string time = 1;
|
|
29
|
-
double value_number = 2;
|
|
30
|
-
string value_string = 3;
|
|
31
|
-
string uom = 4;
|
|
32
|
-
string data_group = 5;
|
|
33
|
-
string foreign_event_key = 6;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
message TableValue {
|
|
37
|
-
string key = 1;
|
|
38
|
-
double value_number = 2;
|
|
39
|
-
string value_string = 3;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
message Table {
|
|
43
|
-
string time = 1;
|
|
44
|
-
repeated TableValue values = 2;
|
|
45
|
-
string data_group = 3;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
message SubscribeRequest {
|
|
49
|
-
repeated string topics = 1;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
message MqttMessage {
|
|
53
|
-
string topic = 1;
|
|
54
|
-
string payload = 2; // UNS packet JSON
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
message Ack {
|
|
58
|
-
bool ok = 1;
|
|
59
|
-
string error = 2;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
message ReadyRequest {
|
|
63
|
-
int32 timeout_ms = 1; // default 15000
|
|
64
|
-
bool wait_output = 2; // wait for publisher active (output)
|
|
65
|
-
bool wait_input = 3; // wait for subscriber active (input)
|
|
66
|
-
bool wait_api = 4; // wait for API server (optional)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
message ApiQueryParam {
|
|
70
|
-
string name = 1;
|
|
71
|
-
string type = 2; // string | number | boolean
|
|
72
|
-
bool required = 3;
|
|
73
|
-
string description = 4;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
message RegisterApiGetRequest {
|
|
77
|
-
string topic = 1;
|
|
78
|
-
string attribute = 2;
|
|
79
|
-
string api_description = 3;
|
|
80
|
-
repeated string tags = 4;
|
|
81
|
-
repeated ApiQueryParam query_params = 5;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
message UnregisterApiGetRequest {
|
|
85
|
-
string topic = 1;
|
|
86
|
-
string attribute = 2;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
message ApiEvent {
|
|
90
|
-
string id = 1;
|
|
91
|
-
string method = 2; // GET only for now
|
|
92
|
-
string path = 3; // /{topic}{attribute}
|
|
93
|
-
map<string, string> query = 4;
|
|
94
|
-
string bearer = 5; // access token (optional)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
message ApiEventResponse {
|
|
98
|
-
string id = 1; // correlation
|
|
99
|
-
int32 status = 2; // HTTP status
|
|
100
|
-
string body = 3; // response body as string (JSON string if needed)
|
|
101
|
-
map<string, string> headers = 4; // optional extra headers
|
|
102
|
-
}
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package uns;
|
|
4
|
+
|
|
5
|
+
service UnsGateway {
|
|
6
|
+
rpc Publish (PublishRequest) returns (Ack);
|
|
7
|
+
rpc Subscribe (SubscribeRequest) returns (stream MqttMessage);
|
|
8
|
+
rpc RegisterApiGet (RegisterApiGetRequest) returns (Ack);
|
|
9
|
+
rpc UnregisterApiGet (UnregisterApiGetRequest) returns (Ack);
|
|
10
|
+
rpc ApiEventStream (stream ApiEventResponse) returns (stream ApiEvent);
|
|
11
|
+
rpc Ready (ReadyRequest) returns (Ack);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
message PublishRequest {
|
|
15
|
+
string topic = 1;
|
|
16
|
+
string attribute = 2;
|
|
17
|
+
string description = 3;
|
|
18
|
+
repeated string tags = 4;
|
|
19
|
+
bool attribute_needs_persistence = 5;
|
|
20
|
+
oneof content {
|
|
21
|
+
Data data = 6;
|
|
22
|
+
Table table = 7;
|
|
23
|
+
}
|
|
24
|
+
bool value_is_cumulative = 8; // for Data: publish as delta
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message Data {
|
|
28
|
+
string time = 1;
|
|
29
|
+
double value_number = 2;
|
|
30
|
+
string value_string = 3;
|
|
31
|
+
string uom = 4;
|
|
32
|
+
string data_group = 5;
|
|
33
|
+
string foreign_event_key = 6;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
message TableValue {
|
|
37
|
+
string key = 1;
|
|
38
|
+
double value_number = 2;
|
|
39
|
+
string value_string = 3;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message Table {
|
|
43
|
+
string time = 1;
|
|
44
|
+
repeated TableValue values = 2;
|
|
45
|
+
string data_group = 3;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
message SubscribeRequest {
|
|
49
|
+
repeated string topics = 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
message MqttMessage {
|
|
53
|
+
string topic = 1;
|
|
54
|
+
string payload = 2; // UNS packet JSON
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
message Ack {
|
|
58
|
+
bool ok = 1;
|
|
59
|
+
string error = 2;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message ReadyRequest {
|
|
63
|
+
int32 timeout_ms = 1; // default 15000
|
|
64
|
+
bool wait_output = 2; // wait for publisher active (output)
|
|
65
|
+
bool wait_input = 3; // wait for subscriber active (input)
|
|
66
|
+
bool wait_api = 4; // wait for API server (optional)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
message ApiQueryParam {
|
|
70
|
+
string name = 1;
|
|
71
|
+
string type = 2; // string | number | boolean
|
|
72
|
+
bool required = 3;
|
|
73
|
+
string description = 4;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
message RegisterApiGetRequest {
|
|
77
|
+
string topic = 1;
|
|
78
|
+
string attribute = 2;
|
|
79
|
+
string api_description = 3;
|
|
80
|
+
repeated string tags = 4;
|
|
81
|
+
repeated ApiQueryParam query_params = 5;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
message UnregisterApiGetRequest {
|
|
85
|
+
string topic = 1;
|
|
86
|
+
string attribute = 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
message ApiEvent {
|
|
90
|
+
string id = 1;
|
|
91
|
+
string method = 2; // GET only for now
|
|
92
|
+
string path = 3; // /{topic}{attribute}
|
|
93
|
+
map<string, string> query = 4;
|
|
94
|
+
string bearer = 5; // access token (optional)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
message ApiEventResponse {
|
|
98
|
+
string id = 1; // correlation
|
|
99
|
+
int32 status = 2; // HTTP status
|
|
100
|
+
string body = 3; // response body as string (JSON string if needed)
|
|
101
|
+
map<string, string> headers = 4; // optional extra headers
|
|
102
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "uns-example"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
description = "A new gRPC project"
|
|
1
|
+
[project]
|
|
2
|
+
name = "uns-example"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A new gRPC project"
|
|
5
5
|
dependencies = ["grpcio", "grpcio-tools", "httpx>=0.27.2"]
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
# Navigate to the project root
|
|
6
|
-
cd "$(dirname "$0")/.."
|
|
7
|
-
|
|
8
|
-
# Detect OS and set paths
|
|
9
|
-
PLATFORM="$(uname)"
|
|
10
|
-
if [[ "$PLATFORM" == "Linux" || "$PLATFORM" == "Darwin" ]]; then
|
|
11
|
-
PYTHON_EXEC="python3"
|
|
12
|
-
VENV_DIR="venv"
|
|
13
|
-
VENV_ACTIVATE="./venv/bin/activate"
|
|
14
|
-
elif [[ "$PLATFORM" =~ MINGW.* || "$PLATFORM" =~ CYGWIN.* || "$PLATFORM" == "MSYS_NT"* ]]; then
|
|
15
|
-
PYTHON_EXEC="python"
|
|
16
|
-
VENV_DIR="venv"
|
|
17
|
-
VENV_ACTIVATE="./venv/Scripts/activate"
|
|
18
|
-
else
|
|
19
|
-
echo "[setup] Unsupported OS: $PLATFORM"
|
|
20
|
-
exit 1
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
if [[ "$PLATFORM" =~ MINGW.*|MSYS.*|CYGWIN.*|Windows_NT ]]; then
|
|
24
|
-
UV_CMD="$HOME/.local/bin/uv.exe"
|
|
25
|
-
else
|
|
26
|
-
UV_CMD="$HOME/.cargo/bin/uv"
|
|
27
|
-
fi
|
|
28
|
-
|
|
29
|
-
if [ ! -f "$UV_CMD" ]; then
|
|
30
|
-
echo "[setup] uv not found. Installing it..."
|
|
31
|
-
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
32
|
-
else
|
|
33
|
-
echo "[setup] uv already installed at $UV_CMD"
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# Create virtual environment using uv
|
|
37
|
-
if [ ! -d "$VENV_DIR" ]; then
|
|
38
|
-
echo "[setup] Creating virtual environment in $VENV_DIR using uv..."
|
|
39
|
-
"$UV_CMD" venv "$VENV_DIR"
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
# Create gen directory if it doesn't exist
|
|
43
|
-
if [ ! -d "gen" ]; then
|
|
44
|
-
echo "[setup] Creating gen directory..."
|
|
45
|
-
mkdir -p gen
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
# Ensure gen is a package for imports
|
|
49
|
-
if [ ! -f "gen/__init__.py" ]; then
|
|
50
|
-
echo "[setup] Creating gen/__init__.py..."
|
|
51
|
-
echo "# generated" > gen/__init__.py
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
# Activate the virtual environment
|
|
55
|
-
echo "[setup] Activating virtual environment..."
|
|
56
|
-
if [[ "$PLATFORM" =~ MINGW.*|MSYS.*|CYGWIN.* ]]; then
|
|
57
|
-
# Windows Git Bash / MSYS
|
|
58
|
-
. "$VENV_ACTIVATE"
|
|
59
|
-
else
|
|
60
|
-
# Linux / macOS
|
|
61
|
-
source "$VENV_ACTIVATE"
|
|
62
|
-
fi
|
|
63
|
-
|
|
64
|
-
# Install dependencies using uv (much faster than pip)
|
|
65
|
-
echo "[setup] Installing requirements using uv..."
|
|
66
|
-
"$UV_CMD" sync --active
|
|
67
|
-
|
|
68
|
-
# Generate Python gRPC code from proto
|
|
69
|
-
echo "[setup] Generating gRPC Python code..."
|
|
70
|
-
"$PYTHON_EXEC" -m grpc_tools.protoc \
|
|
71
|
-
-I=proto \
|
|
72
|
-
--python_out=gen \
|
|
73
|
-
--grpc_python_out=gen \
|
|
74
|
-
proto/uns-gateway.proto
|
|
75
|
-
|
|
76
|
-
# Patch the generated _pb2_grpc.py to use relative imports
|
|
77
|
-
GRPC_FILE="gen/uns_gateway_pb2_grpc.py"
|
|
78
|
-
if [[ -f "$GRPC_FILE" ]]; then
|
|
79
|
-
echo "[setup] Patching $GRPC_FILE to use relative imports..."
|
|
80
|
-
if [[ "$PLATFORM" == "Linux" || "$PLATFORM" == "Darwin" ]]; then
|
|
81
|
-
sed -i 's/^import \(.*_pb2\) as/from . import \1 as/' "$GRPC_FILE"
|
|
82
|
-
elif [[ "$PLATFORM" =~ MINGW.*|MSYS.*|CYGWIN.* ]]; then
|
|
83
|
-
sed -i'' 's/^import \(.*_pb2\) as/from . import \1 as/' "$GRPC_FILE"
|
|
84
|
-
fi
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
echo "[setup] Setup complete!"
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
# Navigate to the project root
|
|
6
|
+
cd "$(dirname "$0")/.."
|
|
7
|
+
|
|
8
|
+
# Detect OS and set paths
|
|
9
|
+
PLATFORM="$(uname)"
|
|
10
|
+
if [[ "$PLATFORM" == "Linux" || "$PLATFORM" == "Darwin" ]]; then
|
|
11
|
+
PYTHON_EXEC="python3"
|
|
12
|
+
VENV_DIR="venv"
|
|
13
|
+
VENV_ACTIVATE="./venv/bin/activate"
|
|
14
|
+
elif [[ "$PLATFORM" =~ MINGW.* || "$PLATFORM" =~ CYGWIN.* || "$PLATFORM" == "MSYS_NT"* ]]; then
|
|
15
|
+
PYTHON_EXEC="python"
|
|
16
|
+
VENV_DIR="venv"
|
|
17
|
+
VENV_ACTIVATE="./venv/Scripts/activate"
|
|
18
|
+
else
|
|
19
|
+
echo "[setup] Unsupported OS: $PLATFORM"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
if [[ "$PLATFORM" =~ MINGW.*|MSYS.*|CYGWIN.*|Windows_NT ]]; then
|
|
24
|
+
UV_CMD="$HOME/.local/bin/uv.exe"
|
|
25
|
+
else
|
|
26
|
+
UV_CMD="$HOME/.cargo/bin/uv"
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
if [ ! -f "$UV_CMD" ]; then
|
|
30
|
+
echo "[setup] uv not found. Installing it..."
|
|
31
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
32
|
+
else
|
|
33
|
+
echo "[setup] uv already installed at $UV_CMD"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Create virtual environment using uv
|
|
37
|
+
if [ ! -d "$VENV_DIR" ]; then
|
|
38
|
+
echo "[setup] Creating virtual environment in $VENV_DIR using uv..."
|
|
39
|
+
"$UV_CMD" venv "$VENV_DIR"
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
# Create gen directory if it doesn't exist
|
|
43
|
+
if [ ! -d "gen" ]; then
|
|
44
|
+
echo "[setup] Creating gen directory..."
|
|
45
|
+
mkdir -p gen
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Ensure gen is a package for imports
|
|
49
|
+
if [ ! -f "gen/__init__.py" ]; then
|
|
50
|
+
echo "[setup] Creating gen/__init__.py..."
|
|
51
|
+
echo "# generated" > gen/__init__.py
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
# Activate the virtual environment
|
|
55
|
+
echo "[setup] Activating virtual environment..."
|
|
56
|
+
if [[ "$PLATFORM" =~ MINGW.*|MSYS.*|CYGWIN.* ]]; then
|
|
57
|
+
# Windows Git Bash / MSYS
|
|
58
|
+
. "$VENV_ACTIVATE"
|
|
59
|
+
else
|
|
60
|
+
# Linux / macOS
|
|
61
|
+
source "$VENV_ACTIVATE"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Install dependencies using uv (much faster than pip)
|
|
65
|
+
echo "[setup] Installing requirements using uv..."
|
|
66
|
+
"$UV_CMD" sync --active
|
|
67
|
+
|
|
68
|
+
# Generate Python gRPC code from proto
|
|
69
|
+
echo "[setup] Generating gRPC Python code..."
|
|
70
|
+
"$PYTHON_EXEC" -m grpc_tools.protoc \
|
|
71
|
+
-I=proto \
|
|
72
|
+
--python_out=gen \
|
|
73
|
+
--grpc_python_out=gen \
|
|
74
|
+
proto/uns-gateway.proto
|
|
75
|
+
|
|
76
|
+
# Patch the generated _pb2_grpc.py to use relative imports
|
|
77
|
+
GRPC_FILE="gen/uns_gateway_pb2_grpc.py"
|
|
78
|
+
if [[ -f "$GRPC_FILE" ]]; then
|
|
79
|
+
echo "[setup] Patching $GRPC_FILE to use relative imports..."
|
|
80
|
+
if [[ "$PLATFORM" == "Linux" || "$PLATFORM" == "Darwin" ]]; then
|
|
81
|
+
sed -i 's/^import \(.*_pb2\) as/from . import \1 as/' "$GRPC_FILE"
|
|
82
|
+
elif [[ "$PLATFORM" =~ MINGW.*|MSYS.*|CYGWIN.* ]]; then
|
|
83
|
+
sed -i'' 's/^import \(.*_pb2\) as/from . import \1 as/' "$GRPC_FILE"
|
|
84
|
+
fi
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
echo "[setup] Setup complete!"
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Change this file according to your specifications and rename it to index.ts
|
|
3
|
-
*/
|
|
4
|
-
import { UnsProxyProcess, ConfigFile, logger } from "@uns-kit/core
|
|
5
|
-
import { ITemporalTopic } from "@uns-kit/temporal.js";
|
|
6
|
-
import "@uns-kit/temporal";
|
|
7
|
-
import { type UnsProxyProcessWithTemporal } from "@uns-kit/temporal.js";
|
|
8
|
-
import { UnsAttributeType } from "@uns-kit/core/graphql/schema.js";
|
|
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 temporal and register uns topic for temporal
|
|
19
|
-
*/
|
|
20
|
-
const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithTemporal;
|
|
21
|
-
const temporalTopic: ITemporalTopic = {
|
|
22
|
-
attribute: "temporal-data",
|
|
23
|
-
topic: "example/",
|
|
24
|
-
attributeType: UnsAttributeType.Data,
|
|
25
|
-
attributeNeedsPersistence: true,
|
|
26
|
-
dataGroup: "temporal",
|
|
27
|
-
description: "Temporal data example",
|
|
28
|
-
tags: ["temporal"],
|
|
29
|
-
}
|
|
30
|
-
const temporalProxy = await unsProxyProcess.createTemporalProxy("templateUnsTemporal", "temporal.example.local:7233", "line-namespace");
|
|
31
|
-
await temporalProxy.initializeTemporalProxy(temporalTopic);
|
|
32
|
-
|
|
33
|
-
// Start temporal workflow
|
|
34
|
-
const result = await temporalProxy.startWorkflow("TransformLineData", {'coil_id': "42"}, "ETL_LINE_TASK_QUEUE");
|
|
35
|
-
logger.info(`Workflow result: ${JSON.stringify(result)}`);
|
|
1
|
+
/**
|
|
2
|
+
* Change this file according to your specifications and rename it to index.ts
|
|
3
|
+
*/
|
|
4
|
+
import { UnsProxyProcess, ConfigFile, logger } from "@uns-kit/core";
|
|
5
|
+
import { ITemporalTopic } from "@uns-kit/temporal.js";
|
|
6
|
+
import "@uns-kit/temporal";
|
|
7
|
+
import { type UnsProxyProcessWithTemporal } from "@uns-kit/temporal.js";
|
|
8
|
+
import { UnsAttributeType } from "@uns-kit/core/graphql/schema.js";
|
|
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 temporal and register uns topic for temporal
|
|
19
|
+
*/
|
|
20
|
+
const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithTemporal;
|
|
21
|
+
const temporalTopic: ITemporalTopic = {
|
|
22
|
+
attribute: "temporal-data",
|
|
23
|
+
topic: "example/",
|
|
24
|
+
attributeType: UnsAttributeType.Data,
|
|
25
|
+
attributeNeedsPersistence: true,
|
|
26
|
+
dataGroup: "temporal",
|
|
27
|
+
description: "Temporal data example",
|
|
28
|
+
tags: ["temporal"],
|
|
29
|
+
}
|
|
30
|
+
const temporalProxy = await unsProxyProcess.createTemporalProxy("templateUnsTemporal", "temporal.example.local:7233", "line-namespace");
|
|
31
|
+
await temporalProxy.initializeTemporalProxy(temporalTopic);
|
|
32
|
+
|
|
33
|
+
// Start temporal workflow
|
|
34
|
+
const result = await temporalProxy.startWorkflow("TransformLineData", {'coil_id': "42"}, "ETL_LINE_TASK_QUEUE");
|
|
35
|
+
logger.info(`Workflow result: ${JSON.stringify(result)}`);
|