@uns-kit/cli 2.0.56 → 2.0.57
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 +59 -59
- 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 +83 -81
- 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 +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 +41 -41
- 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/gen/__init__.py +1 -0
- package/templates/python/gen/uns_gateway_pb2.py +70 -0
- package/templates/python/gen/uns_gateway_pb2_grpc.py +312 -0
- 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/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/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Aljoša Vister
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Aljoša Vister
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
1
|
-
# @uns-kit/cli
|
|
2
|
-
|
|
3
|
-
Command line scaffolding tool for the UNS toolkit. Bootstraps new projects with `@uns-kit/core` preconfigured and ready to extend with plugins. Also provides configure and upgrade commands for existing projects.
|
|
4
|
-
|
|
5
|
-
Note: Apps built with uns-kit are intended to be managed by the **UNS Datahub controller**.
|
|
6
|
-
|
|
7
|
-
## uns-kit in context
|
|
8
|
-
|
|
9
|
-
| Package | Description |
|
|
10
|
-
| --- | --- |
|
|
11
|
-
| [`@uns-kit/core`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-core) | Base runtime (UnsProxyProcess, MQTT helpers, config tooling, gRPC gateway). |
|
|
12
|
-
| [`@uns-kit/api`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-api) | Express plugin — HTTP endpoints, JWT/JWKS auth, Swagger, UNS metadata. |
|
|
13
|
-
| [`@uns-kit/cron`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cron) | Cron-driven scheduler that emits UNS events on a fixed cadence. |
|
|
14
|
-
| [`@uns-kit/cli`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cli) | CLI for scaffolding new UNS applications. |
|
|
15
|
-
|
|
16
|
-
## Prerequisites
|
|
17
|
-
|
|
18
|
-
- Node.js 22 or newer
|
|
19
|
-
- `pnpm`, `npm`, or `yarn`
|
|
20
|
-
- `git` on PATH (used to initialise new projects and for `configure-devops`)
|
|
21
|
-
|
|
22
|
-
## Create a new project
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
pnpm --package=@uns-kit/cli dlx uns-kit create my-uns-app
|
|
26
|
-
# or with npx
|
|
27
|
-
npx @uns-kit/cli create my-uns-app
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
After scaffolding:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
cd my-uns-app
|
|
34
|
-
pnpm install
|
|
35
|
-
pnpm run dev
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
The scaffold creates a project directory from the default TypeScript template, pins `@uns-kit/core` to the current version, and initialises a git repository if `git` is available.
|
|
39
|
-
|
|
1
|
+
# @uns-kit/cli
|
|
2
|
+
|
|
3
|
+
Command line scaffolding tool for the UNS toolkit. Bootstraps new projects with `@uns-kit/core` preconfigured and ready to extend with plugins. Also provides configure and upgrade commands for existing projects.
|
|
4
|
+
|
|
5
|
+
Note: Apps built with uns-kit are intended to be managed by the **UNS Datahub controller**.
|
|
6
|
+
|
|
7
|
+
## uns-kit in context
|
|
8
|
+
|
|
9
|
+
| Package | Description |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| [`@uns-kit/core`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-core) | Base runtime (UnsProxyProcess, MQTT helpers, config tooling, gRPC gateway). |
|
|
12
|
+
| [`@uns-kit/api`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-api) | Express plugin — HTTP endpoints, JWT/JWKS auth, Swagger, UNS metadata. |
|
|
13
|
+
| [`@uns-kit/cron`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cron) | Cron-driven scheduler that emits UNS events on a fixed cadence. |
|
|
14
|
+
| [`@uns-kit/cli`](https://github.com/uns-datahub/uns-kit/tree/main/packages/uns-cli) | CLI for scaffolding new UNS applications. |
|
|
15
|
+
|
|
16
|
+
## Prerequisites
|
|
17
|
+
|
|
18
|
+
- Node.js 22 or newer
|
|
19
|
+
- `pnpm`, `npm`, or `yarn`
|
|
20
|
+
- `git` on PATH (used to initialise new projects and for `configure-devops`)
|
|
21
|
+
|
|
22
|
+
## Create a new project
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm --package=@uns-kit/cli dlx uns-kit create my-uns-app
|
|
26
|
+
# or with npx
|
|
27
|
+
npx @uns-kit/cli create my-uns-app
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
After scaffolding:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd my-uns-app
|
|
34
|
+
pnpm install
|
|
35
|
+
pnpm run dev
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The scaffold creates a project directory from the default TypeScript template, pins `@uns-kit/core` to the current version, and initialises a git repository if `git` is available.
|
|
39
|
+
|
|
40
40
|
The default template includes a Datahub REST client example (`UnsClient`) for last-value lookups, using a token-first pattern suitable for long-lived service tokens.
|
|
41
|
-
|
|
42
|
-
### Create from a service bundle
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
uns-kit create --bundle ./service.bundle.json
|
|
46
|
-
uns-kit create --bundle ./service.bundle.json --dest ./my-dir
|
|
47
|
-
uns-kit create --bundle ./service.bundle.json --dest . --allow-existing
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Bundle-driven create uses `service.bundle.json` as the source of truth. The CLI scaffolds the base app, copies the bundle into the project root, generates `SERVICE_SPEC.md` and `AGENTS.md`, and applies supported bundle features (`vscode`, `devops`, etc.). Only bundles with `scaffold.stack = "ts"` are accepted by this CLI; use `uns-kit-py` for Python bundles.
|
|
51
|
-
|
|
52
|
-
## Commands
|
|
53
|
-
|
|
54
|
-
### `uns-kit create <name>`
|
|
55
|
-
Scaffold a new project from the default TypeScript template.
|
|
56
|
-
|
|
57
|
-
### `uns-kit create --bundle <path> [--dest <dir>] [--allow-existing]`
|
|
58
|
-
Scaffold from a `service.bundle.json` descriptor.
|
|
59
|
-
|
|
60
|
-
### `uns-kit configure [dir] [features...]`
|
|
61
|
-
Apply one or more feature templates to an existing project in one go.
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
uns-kit configure # prompts for features
|
|
65
|
-
uns-kit configure --all # apply all available features
|
|
66
|
-
uns-kit configure ./my-app api cron # add API and cron scaffolding
|
|
67
|
-
uns-kit configure ./my-app --overwrite # refresh existing files from latest templates
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Available feature names: `devops`, `vscode`, `codegen`, `api`, `cron`, `python`, `uns-reference`.
|
|
71
|
-
|
|
72
|
-
### `uns-kit configure-templates [dir] [templates...]`
|
|
73
|
-
Copy any template directory by name.
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
uns-kit configure-templates --all
|
|
77
|
-
uns-kit configure-templates uns-dictionary uns-measurements --overwrite
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### `uns-kit configure-devops [dir]`
|
|
81
|
-
Add Azure DevOps pull-request tooling. Requires a git repository.
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
uns-kit configure-devops
|
|
85
|
-
pnpm install
|
|
86
|
-
pnpm run pull-request
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### `uns-kit configure-vscode [dir]`
|
|
90
|
-
Copy `.vscode/launch.json` and a workspace file. Skips existing files unless `--overwrite` is passed.
|
|
91
|
-
|
|
92
|
-
### `uns-kit configure-codegen [dir]`
|
|
93
|
-
Scaffold GraphQL code generation (`codegen.ts`, placeholder types in `src/uns/`).
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
uns-kit configure-codegen
|
|
97
|
-
pnpm install
|
|
98
|
-
pnpm run generate-codegen # regenerate strongly-typed GraphQL operations
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### `uns-kit configure-api [dir]`
|
|
102
|
-
Copy API example stubs (`src/examples/api-example.ts`) and add `@uns-kit/api`.
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
uns-kit configure-api
|
|
106
|
-
pnpm install
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
The example shows both GET and POST endpoint registration with JWT auth, query params, request body schemas, and event handlers. Rename and adapt `api-example.ts` to `index.ts` as your starting point.
|
|
110
|
-
|
|
111
|
-
### `uns-kit configure-cron [dir]`
|
|
112
|
-
Copy cron example stubs and add `@uns-kit/cron`.
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
uns-kit configure-cron
|
|
116
|
-
pnpm install
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### `uns-kit configure-python [dir]`
|
|
120
|
-
Copy Python gRPC gateway client scaffolding (no npm dependency required).
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
uns-kit configure-python
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### `uns-kit configure-uns-reference [dir]`
|
|
127
|
-
Copy UNS dictionary and measurements JSON files into the project and add the `sync-uns-schema` script to `package.json`.
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
uns-kit configure-uns-reference
|
|
131
|
-
pnpm run sync-uns-schema # pull latest schema from the controller
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### `uns-kit upgrade [dir]`
|
|
135
|
-
Remove obsolete scripts from `package.json` and migrate to current conventions.
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
uns-kit upgrade # upgrade current directory
|
|
139
|
-
uns-kit upgrade ./my-app # upgrade a specific project
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Removes scripts that have been superseded (`generate-uns-dictionary`, `generate-uns-measurements`, `generate-uns-reference`, `generate-uns-metadata`) and ensures `sync-uns-schema` is present.
|
|
143
|
-
|
|
144
|
-
### `uns-kit help`
|
|
145
|
-
Display usage information.
|
|
146
|
-
|
|
147
|
-
## Extend the config schema
|
|
148
|
-
|
|
149
|
-
Edit `src/config/project.config.extension.ts` inside your project and run:
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
pnpm run generate-config-schema
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
This regenerates `config.schema.json` and `src/config/app-config.ts` so editors and runtime types stay in sync with your extensions.
|
|
156
|
-
|
|
157
|
-
## Sync the UNS schema
|
|
158
|
-
|
|
159
|
-
After scaffolding (or at any time) pull the latest UNS dictionary and measurements from the controller:
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
pnpm run sync-uns-schema
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
The controller URL is read from `config.json` (`uns.rest`) automatically. You will be prompted for the bearer token if `UNS_CONTROLLER_TOKEN` is not set.
|
|
166
|
-
|
|
167
|
-
## License
|
|
168
|
-
|
|
169
|
-
MIT © Aljoša Vister
|
|
41
|
+
|
|
42
|
+
### Create from a service bundle
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uns-kit create --bundle ./service.bundle.json
|
|
46
|
+
uns-kit create --bundle ./service.bundle.json --dest ./my-dir
|
|
47
|
+
uns-kit create --bundle ./service.bundle.json --dest . --allow-existing
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Bundle-driven create uses `service.bundle.json` as the source of truth. The CLI scaffolds the base app, copies the bundle into the project root, generates `SERVICE_SPEC.md` and `AGENTS.md`, and applies supported bundle features (`vscode`, `devops`, etc.). Only bundles with `scaffold.stack = "ts"` are accepted by this CLI; use `uns-kit-py` for Python bundles.
|
|
51
|
+
|
|
52
|
+
## Commands
|
|
53
|
+
|
|
54
|
+
### `uns-kit create <name>`
|
|
55
|
+
Scaffold a new project from the default TypeScript template.
|
|
56
|
+
|
|
57
|
+
### `uns-kit create --bundle <path> [--dest <dir>] [--allow-existing]`
|
|
58
|
+
Scaffold from a `service.bundle.json` descriptor.
|
|
59
|
+
|
|
60
|
+
### `uns-kit configure [dir] [features...]`
|
|
61
|
+
Apply one or more feature templates to an existing project in one go.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uns-kit configure # prompts for features
|
|
65
|
+
uns-kit configure --all # apply all available features
|
|
66
|
+
uns-kit configure ./my-app api cron # add API and cron scaffolding
|
|
67
|
+
uns-kit configure ./my-app --overwrite # refresh existing files from latest templates
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Available feature names: `devops`, `vscode`, `codegen`, `api`, `cron`, `python`, `uns-reference`.
|
|
71
|
+
|
|
72
|
+
### `uns-kit configure-templates [dir] [templates...]`
|
|
73
|
+
Copy any template directory by name.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uns-kit configure-templates --all
|
|
77
|
+
uns-kit configure-templates uns-dictionary uns-measurements --overwrite
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `uns-kit configure-devops [dir]`
|
|
81
|
+
Add Azure DevOps pull-request tooling. Requires a git repository.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
uns-kit configure-devops
|
|
85
|
+
pnpm install
|
|
86
|
+
pnpm run pull-request
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `uns-kit configure-vscode [dir]`
|
|
90
|
+
Copy `.vscode/launch.json` and a workspace file. Skips existing files unless `--overwrite` is passed.
|
|
91
|
+
|
|
92
|
+
### `uns-kit configure-codegen [dir]`
|
|
93
|
+
Scaffold GraphQL code generation (`codegen.ts`, placeholder types in `src/uns/`).
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uns-kit configure-codegen
|
|
97
|
+
pnpm install
|
|
98
|
+
pnpm run generate-codegen # regenerate strongly-typed GraphQL operations
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `uns-kit configure-api [dir]`
|
|
102
|
+
Copy API example stubs (`src/examples/api-example.ts`) and add `@uns-kit/api`.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
uns-kit configure-api
|
|
106
|
+
pnpm install
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The example shows both GET and POST endpoint registration with JWT auth, query params, request body schemas, and event handlers. Rename and adapt `api-example.ts` to `index.ts` as your starting point.
|
|
110
|
+
|
|
111
|
+
### `uns-kit configure-cron [dir]`
|
|
112
|
+
Copy cron example stubs and add `@uns-kit/cron`.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
uns-kit configure-cron
|
|
116
|
+
pnpm install
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `uns-kit configure-python [dir]`
|
|
120
|
+
Copy Python gRPC gateway client scaffolding (no npm dependency required).
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uns-kit configure-python
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### `uns-kit configure-uns-reference [dir]`
|
|
127
|
+
Copy UNS dictionary and measurements JSON files into the project and add the `sync-uns-schema` script to `package.json`.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
uns-kit configure-uns-reference
|
|
131
|
+
pnpm run sync-uns-schema # pull latest schema from the controller
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### `uns-kit upgrade [dir]`
|
|
135
|
+
Remove obsolete scripts from `package.json` and migrate to current conventions.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
uns-kit upgrade # upgrade current directory
|
|
139
|
+
uns-kit upgrade ./my-app # upgrade a specific project
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Removes scripts that have been superseded (`generate-uns-dictionary`, `generate-uns-measurements`, `generate-uns-reference`, `generate-uns-metadata`) and ensures `sync-uns-schema` is present.
|
|
143
|
+
|
|
144
|
+
### `uns-kit help`
|
|
145
|
+
Display usage information.
|
|
146
|
+
|
|
147
|
+
## Extend the config schema
|
|
148
|
+
|
|
149
|
+
Edit `src/config/project.config.extension.ts` inside your project and run:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
pnpm run generate-config-schema
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This regenerates `config.schema.json` and `src/config/app-config.ts` so editors and runtime types stay in sync with your extensions.
|
|
156
|
+
|
|
157
|
+
## Sync the UNS schema
|
|
158
|
+
|
|
159
|
+
After scaffolding (or at any time) pull the latest UNS dictionary and measurements from the controller:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pnpm run sync-uns-schema
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The controller URL is read from `config.json` (`uns.rest`) automatically. You will be prompted for the bearer token if `UNS_CONTROLLER_TOKEN` is not set.
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT © Aljoša Vister
|
package/dist/index.js
CHANGED
|
@@ -334,65 +334,65 @@ function renderBundlePublisherExample(bundle, contracts) {
|
|
|
334
334
|
.map((line) => ` ${line}`)
|
|
335
335
|
.join("\n")
|
|
336
336
|
.trimStart();
|
|
337
|
-
return `import { ConfigFile, UnsProxyProcess } from "@uns-kit/core";
|
|
338
|
-
import type { ISO8601 } from "@uns-kit/core/uns/uns-interfaces.js";
|
|
339
|
-
|
|
340
|
-
type OutputContract = {
|
|
341
|
-
fullPath: string;
|
|
342
|
-
topicPrefix: string;
|
|
343
|
-
asset: string;
|
|
344
|
-
objectType: string;
|
|
345
|
-
objectId: string;
|
|
346
|
-
attribute: string;
|
|
347
|
-
expectedIntervalMs: number;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const outputContracts = ${contractJson} satisfies readonly OutputContract[];
|
|
351
|
-
|
|
352
|
-
function topicPrefixForPublish(topicPrefix: string): string {
|
|
353
|
-
return topicPrefix.endsWith("/") ? topicPrefix : \`\${topicPrefix}/\`;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
async function main(): Promise<void> {
|
|
357
|
-
const config = await ConfigFile.loadConfig();
|
|
358
|
-
const processName = config.uns.processName ?? ${processName};
|
|
359
|
-
const unsProcess = new UnsProxyProcess(config.infra.host ?? "localhost", {
|
|
360
|
-
processName,
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
const mqttOutput = await unsProcess.createUnsMqttProxy(
|
|
364
|
-
config.output?.host ?? "localhost",
|
|
365
|
-
"defaultOutput",
|
|
366
|
-
config.uns.instanceMode ?? "wait",
|
|
367
|
-
config.uns.handover ?? true,
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
const time = new Date().toISOString() as ISO8601;
|
|
371
|
-
|
|
372
|
-
for (const output of outputContracts) {
|
|
373
|
-
await mqttOutput.publishMqttMessage({
|
|
374
|
-
topic: topicPrefixForPublish(output.topicPrefix),
|
|
375
|
-
asset: output.asset,
|
|
376
|
-
objectType: output.objectType,
|
|
377
|
-
objectId: output.objectId,
|
|
378
|
-
attributes: {
|
|
379
|
-
attribute: output.attribute,
|
|
380
|
-
description: \`Generated example publisher for \${output.fullPath}\`,
|
|
381
|
-
data: {
|
|
382
|
-
time,
|
|
383
|
-
value: 0,
|
|
384
|
-
dataGroup: "service-bundle-output",
|
|
385
|
-
},
|
|
386
|
-
validityMode: "interval",
|
|
387
|
-
expectedIntervalMs: output.expectedIntervalMs,
|
|
388
|
-
},
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
console.log(\`UNS process '\${processName}' published \${outputContracts.length} interval example output(s).\`);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
void main();
|
|
337
|
+
return `import { ConfigFile, UnsProxyProcess } from "@uns-kit/core";
|
|
338
|
+
import type { ISO8601 } from "@uns-kit/core/uns/uns-interfaces.js";
|
|
339
|
+
|
|
340
|
+
type OutputContract = {
|
|
341
|
+
fullPath: string;
|
|
342
|
+
topicPrefix: string;
|
|
343
|
+
asset: string;
|
|
344
|
+
objectType: string;
|
|
345
|
+
objectId: string;
|
|
346
|
+
attribute: string;
|
|
347
|
+
expectedIntervalMs: number;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const outputContracts = ${contractJson} satisfies readonly OutputContract[];
|
|
351
|
+
|
|
352
|
+
function topicPrefixForPublish(topicPrefix: string): string {
|
|
353
|
+
return topicPrefix.endsWith("/") ? topicPrefix : \`\${topicPrefix}/\`;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async function main(): Promise<void> {
|
|
357
|
+
const config = await ConfigFile.loadConfig();
|
|
358
|
+
const processName = config.uns.processName ?? ${processName};
|
|
359
|
+
const unsProcess = new UnsProxyProcess(config.infra.host ?? "localhost", {
|
|
360
|
+
processName,
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
const mqttOutput = await unsProcess.createUnsMqttProxy(
|
|
364
|
+
config.output?.host ?? "localhost",
|
|
365
|
+
"defaultOutput",
|
|
366
|
+
config.uns.instanceMode ?? "wait",
|
|
367
|
+
config.uns.handover ?? true,
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
const time = new Date().toISOString() as ISO8601;
|
|
371
|
+
|
|
372
|
+
for (const output of outputContracts) {
|
|
373
|
+
await mqttOutput.publishMqttMessage({
|
|
374
|
+
topic: topicPrefixForPublish(output.topicPrefix),
|
|
375
|
+
asset: output.asset,
|
|
376
|
+
objectType: output.objectType,
|
|
377
|
+
objectId: output.objectId,
|
|
378
|
+
attributes: {
|
|
379
|
+
attribute: output.attribute,
|
|
380
|
+
description: \`Generated example publisher for \${output.fullPath}\`,
|
|
381
|
+
data: {
|
|
382
|
+
time,
|
|
383
|
+
value: 0,
|
|
384
|
+
dataGroup: "service-bundle-output",
|
|
385
|
+
},
|
|
386
|
+
validityMode: "interval",
|
|
387
|
+
expectedIntervalMs: output.expectedIntervalMs,
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
console.log(\`UNS process '\${processName}' published \${outputContracts.length} interval example output(s).\`);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
void main();
|
|
396
396
|
`;
|
|
397
397
|
}
|
|
398
398
|
async function writeServiceBundleArtifacts(targetDir, bundle, rawBundle) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.57",
|
|
4
4
|
"description": "Command line scaffolding tool for UNS applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"azure-devops-node-api": "^15.1.1",
|
|
29
|
-
"@uns-kit/core": "2.0.
|
|
29
|
+
"@uns-kit/core": "2.0.57"
|
|
30
30
|
},
|
|
31
31
|
"unsKitPackages": {
|
|
32
|
-
"@uns-kit/core": "2.0.
|
|
33
|
-
"@uns-kit/api": "2.0.
|
|
34
|
-
"@uns-kit/cron": "2.0.
|
|
35
|
-
"@uns-kit/database": "2.0.
|
|
32
|
+
"@uns-kit/core": "2.0.57",
|
|
33
|
+
"@uns-kit/api": "2.0.57",
|
|
34
|
+
"@uns-kit/cron": "2.0.57",
|
|
35
|
+
"@uns-kit/database": "2.0.57"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc -p tsconfig.build.json",
|