@uns-kit/cli 2.0.25 → 2.0.26

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 (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +175 -175
  3. package/dist/index.js +0 -37
  4. package/package.json +6 -6
  5. package/templates/api/src/examples/api-example.ts +91 -91
  6. package/templates/azure-pipelines.yml +21 -21
  7. package/templates/codegen/codegen.ts +15 -15
  8. package/templates/codegen/src/uns/uns-tags.ts +1 -1
  9. package/templates/codegen/src/uns/uns-topics.ts +1 -1
  10. package/templates/config-files/config-docker.json +26 -26
  11. package/templates/config-files/config-localhost.json +26 -26
  12. package/templates/cron/AGENTS.md +24 -24
  13. package/templates/cron/src/examples/cron-example.ts +71 -71
  14. package/templates/default/.prettierignore +1 -1
  15. package/templates/default/.prettierrc +7 -7
  16. package/templates/default/AGENTS.md +24 -24
  17. package/templates/default/README.md +43 -43
  18. package/templates/default/config.json +27 -27
  19. package/templates/default/eslint.config.js +30 -30
  20. package/templates/default/gitignore +51 -51
  21. package/templates/default/package.json +49 -49
  22. package/templates/default/src/config/project.config.extension.example +23 -23
  23. package/templates/default/src/config/project.config.extension.ts +6 -6
  24. package/templates/default/src/examples/data-example.ts +86 -86
  25. package/templates/default/src/examples/load-test-data.ts +110 -110
  26. package/templates/default/src/examples/table-example.ts +97 -97
  27. package/templates/default/src/examples/table-window-load-test.ts +446 -446
  28. package/templates/default/src/examples/uns-gateway-cli.ts +10 -10
  29. package/templates/default/src/index.ts +15 -15
  30. package/templates/default/src/uns/uns-assets.ts +12 -12
  31. package/templates/default/src/uns/uns-dictionary.generated.ts +758 -758
  32. package/templates/default/src/uns/uns-measurements.generated.ts +366 -366
  33. package/templates/default/src/uns/uns-tags.ts +2 -2
  34. package/templates/default/src/uns/uns-topics.ts +2 -2
  35. package/templates/default/tsconfig.json +29 -29
  36. package/templates/python/app/README.md +8 -8
  37. package/templates/python/examples/README.md +134 -134
  38. package/templates/python/examples/api_handler.py +28 -28
  39. package/templates/python/examples/data_publish.py +11 -11
  40. package/templates/python/examples/data_subscribe.py +8 -8
  41. package/templates/python/examples/data_transformer.py +17 -17
  42. package/templates/python/examples/table_transformer.py +15 -15
  43. package/templates/python/gateway/cli.py +75 -75
  44. package/templates/python/gateway/client.py +155 -155
  45. package/templates/python/gateway/manager.py +97 -97
  46. package/templates/python/gen/__init__.py +1 -0
  47. package/templates/python/gen/uns_gateway_pb2.py +70 -0
  48. package/templates/python/gen/uns_gateway_pb2_grpc.py +312 -0
  49. package/templates/python/gitignore +47 -47
  50. package/templates/python/proto/uns-gateway.proto +102 -102
  51. package/templates/python/pyproject.toml +4 -4
  52. package/templates/python/runtime.json +4 -4
  53. package/templates/python/scripts/setup.sh +87 -87
  54. package/templates/temporal/src/examples/temporal-example.ts +37 -37
  55. package/templates/uns-dictionary/uns-dictionary.json +650 -650
  56. package/templates/uns-measurements/uns-measurements.json +360 -360
  57. package/templates/vscode/.vscode/launch.json +164 -164
  58. package/templates/vscode/.vscode/settings.json +9 -9
  59. package/templates/vscode/.vscode/tasks.json +27 -27
  60. package/templates/vscode/uns-kit.code-workspace +13 -13
@@ -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,4 +1,4 @@
1
- {
2
- "runtime": "python",
3
- "entry": "main.py"
4
- }
1
+ {
2
+ "runtime": "python",
3
+ "entry": "main.py"
4
+ }
@@ -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,37 +1,37 @@
1
- /**
2
- * Change this file according to your specifications and rename it to index.ts
3
- */
4
- import { UnsProxyProcess, ConfigFile, getLogger } 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
- const logger = getLogger(import.meta.url);
11
-
12
- /**
13
- * Load the configuration from a file.
14
- * On the server, this file is provided by the `uns-datahub-controller`.
15
- * In the development environment, you are responsible for creating and maintaining this file and its contents.
16
- */
17
- const config = await ConfigFile.loadConfig();
18
-
19
- /**
20
- * Connect to the temporal and register uns topic for temporal
21
- */
22
- const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithTemporal;
23
- const temporalTopic: ITemporalTopic = {
24
- attribute: "temporal-data",
25
- topic: "example/",
26
- attributeType: UnsAttributeType.Data,
27
- attributeNeedsPersistence: true,
28
- dataGroup: "temporal",
29
- description: "Temporal data example",
30
- tags: ["temporal"],
31
- }
32
- const temporalProxy = await unsProxyProcess.createTemporalProxy("templateUnsTemporal", "temporal.example.local:7233", "line-namespace");
33
- await temporalProxy.initializeTemporalProxy(temporalTopic);
34
-
35
- // Start temporal workflow
36
- const result = await temporalProxy.startWorkflow("TransformLineData", {'coil_id': "42"}, "ETL_LINE_TASK_QUEUE");
37
- 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, getLogger } 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
+ const logger = getLogger(import.meta.url);
11
+
12
+ /**
13
+ * Load the configuration from a file.
14
+ * On the server, this file is provided by the `uns-datahub-controller`.
15
+ * In the development environment, you are responsible for creating and maintaining this file and its contents.
16
+ */
17
+ const config = await ConfigFile.loadConfig();
18
+
19
+ /**
20
+ * Connect to the temporal and register uns topic for temporal
21
+ */
22
+ const unsProxyProcess = new UnsProxyProcess(config.infra.host!, {processName:config.uns.processName}) as UnsProxyProcessWithTemporal;
23
+ const temporalTopic: ITemporalTopic = {
24
+ attribute: "temporal-data",
25
+ topic: "example/",
26
+ attributeType: UnsAttributeType.Data,
27
+ attributeNeedsPersistence: true,
28
+ dataGroup: "temporal",
29
+ description: "Temporal data example",
30
+ tags: ["temporal"],
31
+ }
32
+ const temporalProxy = await unsProxyProcess.createTemporalProxy("templateUnsTemporal", "temporal.example.local:7233", "line-namespace");
33
+ await temporalProxy.initializeTemporalProxy(temporalTopic);
34
+
35
+ // Start temporal workflow
36
+ const result = await temporalProxy.startWorkflow("TransformLineData", {'coil_id': "42"}, "ETL_LINE_TASK_QUEUE");
37
+ logger.info(`Workflow result: ${JSON.stringify(result)}`);