@winccoa-tools-pack/npm-winccoa-ascii 0.0.0-stage → 0.1.0

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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +301 -2
  3. package/dist/api.d.ts +44 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/cjs/api.js +56 -0
  6. package/dist/cjs/api.js.map +1 -0
  7. package/dist/cjs/cli.js +568 -0
  8. package/dist/cjs/cli.js.map +1 -0
  9. package/dist/cjs/index.js +17 -0
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/manager.js +242 -0
  12. package/dist/cjs/manager.js.map +1 -0
  13. package/dist/cjs/types/index.js +8 -0
  14. package/dist/cjs/types/index.js.map +1 -0
  15. package/dist/cjs/types.js +3 -0
  16. package/dist/cjs/types.js.map +1 -0
  17. package/dist/cjs/utils/index.js +8 -0
  18. package/dist/cjs/utils/index.js.map +1 -0
  19. package/dist/cli.d.ts +60 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/esm/api.js +56 -0
  22. package/dist/esm/api.js.map +1 -0
  23. package/dist/esm/cli.js +568 -0
  24. package/dist/esm/cli.js.map +1 -0
  25. package/dist/esm/index.js +17 -0
  26. package/dist/esm/index.js.map +1 -0
  27. package/dist/esm/manager.js +242 -0
  28. package/dist/esm/manager.js.map +1 -0
  29. package/dist/esm/types/index.js +8 -0
  30. package/dist/esm/types/index.js.map +1 -0
  31. package/dist/esm/types.js +3 -0
  32. package/dist/esm/types.js.map +1 -0
  33. package/dist/esm/utils/index.js +8 -0
  34. package/dist/esm/utils/index.js.map +1 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/manager.d.ts +87 -0
  38. package/dist/manager.d.ts.map +1 -0
  39. package/dist/types/index.d.ts +5 -0
  40. package/dist/types/index.d.ts.map +1 -0
  41. package/dist/types.d.ts +218 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/utils/index.d.ts +6 -0
  44. package/dist/utils/index.d.ts.map +1 -0
  45. package/package.json +75 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 winccoa-tools-pack
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,3 +1,302 @@
1
- # Temporary Holding Version
1
+ # WinCC OA ASCII Manager — DPL Import & Export
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A TypeScript library and CLI tool for SIMATIC WinCC Open Architecture projects that wraps the
4
+ `WCCOAascii` / `WCCOAasciiSQLite` executable to import and export **Datapoint List (DPL)** files.
5
+
6
+ This package is part of the modular [winccoa-tools-pack](https://github.com/winccoa-tools-pack)
7
+ ecosystem, delivering modern development tooling and reusable libraries for WinCC OA engineers.
8
+
9
+ ## ✨ Features
10
+
11
+ - **DPL import** — load datapoints, types, aliases, and CNS views from `.dpl` files into a running
12
+ WinCC OA project
13
+ - **DPL export** — extract datapoints from a project to `.dpl` files with granular filter control
14
+ - **Full flag support** — all major `WCCOAascii` / `WCCOAasciiSQLite` flags are exposed via
15
+ TypeScript API and CLI
16
+ - **Standalone mode** — run without a running Data/Event manager using the `-n` flag (SQLite projects)
17
+ - **Dual CJS + ESM output** — compatible with both `require()` and `import`
18
+ - **Modern project template** — TypeScript strict mode, ESLint, Prettier, full test infrastructure
19
+
20
+ ## 📦 Installation
21
+
22
+ ```shell
23
+ npm install @winccoa-tools-pack/npm-winccoa-ascii
24
+ ```
25
+
26
+ Or globally for CLI use:
27
+
28
+ ```shell
29
+ npm install -g @winccoa-tools-pack/npm-winccoa-ascii
30
+ ```
31
+
32
+ ## 🖥 Usage (CLI)
33
+
34
+ The CLI binary is `winccoa-ascii`.
35
+
36
+ ### Import a DPL file
37
+
38
+ ```shell
39
+ winccoa-ascii import data.dpl -v 3.21 -p MyProject
40
+
41
+ # With datapoint type handling and manager number
42
+ winccoa-ascii import data.dpl -v 3.21 -p MyProject --types-yes --num 96
43
+
44
+ # Using a config file instead of a project name
45
+ winccoa-ascii import data.dpl -v 3.21 -c /path/to/project/config/config
46
+
47
+ # Wildcard import
48
+ winccoa-ascii import "*.dpl" -v 3.21 -p MyProject --types-yes
49
+
50
+ # Standalone mode (no running managers needed, SQLite projects only)
51
+ winccoa-ascii import data.dpl -v 3.21 -p MyProject --standalone
52
+ ```
53
+
54
+ ### Export to a DPL file
55
+
56
+ ```shell
57
+ # Export all datapoints
58
+ winccoa-ascii export out.dpl -v 3.21 -p MyProject --filter D
59
+
60
+ # Export a specific datapoint type
61
+ winccoa-ascii export out.dpl -v 3.21 -p MyProject --filter-dp-type MyDPType
62
+
63
+ # Export specific datapoints
64
+ winccoa-ascii export out.dpl -v 3.21 -p MyProject \
65
+ --filter-dp System1:Sensor1 \
66
+ --filter-dp System1:Sensor2
67
+
68
+ # Export with timestamp and output format version
69
+ winccoa-ascii export out.dpl -v 3.21 -p MyProject \
70
+ --filter DPA --output-version 2 --export-timestamp
71
+
72
+ # Export data modified after a date
73
+ winccoa-ascii export out.dpl -v 3.21 -p MyProject --younger 01.01.2024
74
+ ```
75
+
76
+ ### Shared flags
77
+
78
+ | Flag | Short | Description |
79
+ | ------ | ------- | ------------- |
80
+ | `--version <ver>` | `-v` | WinCC OA version (e.g. `3.21`) — **required** |
81
+ | `--project <name>` | `-p` | Project name (`-proj`) |
82
+ | `--config <path>` | `-c` | Path to project config file (`-config`) |
83
+ | `--num <n>` | | Manager number (`-num`) |
84
+ | `--local-time` | | Use local time instead of GMT (`-localTime`) |
85
+ | `--user <user[:pw]>` | `-u` | Authentication (`-user`) |
86
+ | `--data <host[:port]>` | | Data server address (`-data`) |
87
+ | `--event <host[:port]>` | | Event server address (`-event`) |
88
+ | `--standalone` | | Run without Data/Event connection (`-n`) |
89
+ | `--timeout <ms>` | `-t` | Process timeout in ms (default: 120000) |
90
+
91
+ ### Import-only flags
92
+
93
+ | Flag | Description |
94
+ | ------ | ------------- |
95
+ | `--types-yes` | Accept type changes without prompting (`-Typesyes`) |
96
+ | `--types-no` | Reject type changes without prompting (`-Typesno`) |
97
+ | `--cns-yes` | Do not change existing CNS nodes (`-CNSyes`) |
98
+ | `--cns-no` | Do not change existing CNS nodes, suppress warnings (`-CNSno`) |
99
+ | `--commit <n>` | Send N messages before waiting for acknowledgement (`-commit`) |
100
+ | `--no-verbose` | Suppress progress output (`-noVerbose`) |
101
+ | `--inactivate-alert` | Inactivate AlertValue configs on import (`-inactivateAlert`) |
102
+ | `--always-send-common` | Always send alias/description even if unchanged (`-alwaysSendCommon`) |
103
+
104
+ ### Export-only flags
105
+
106
+ | Flag | Description |
107
+ | ------ | ------------- |
108
+ | `--filter <chars>` | Filter string: subset of `T D A C O P H` (`-filter`) |
109
+ | `--filter-dp <name>` | Limit to specific DP (repeatable) (`-filterDp`) |
110
+ | `--filter-dp-type <type>` | Limit to specific DPType (repeatable) (`-filterDpType`) |
111
+ | `--filter-file <path>` | File specifying DPs/types to export (`-filterFile`) |
112
+ | `--filter-cns <view>` | Limit to CNS view/subtree (repeatable) (`-filterCNS`) |
113
+ | `--younger <date>` | Only data newer than date — `DD.[MM.[YYYY]][:HH[:MM]]` (`-younger`) |
114
+ | `--output-version <1-4>` | DPL output format version (`-outputVersion`) |
115
+ | `--lang-list <list>` | Comma-separated language list (`-langList`) |
116
+ | `--keep-system` | Keep system name in DPE references (`-system`) |
117
+ | `--export-timestamp` | Include online value timestamps (`-exportTimestamp`) |
118
+
119
+ ## ⚠️ Important behaviour
120
+
121
+ - **WCCOAasciiSQLite vs WCCOAascii** — this package defaults to the SQLite variant
122
+ (`WCCOAasciiSQLite`) used by most modern WinCC OA 3.x projects.
123
+ - **Exit codes** — `WCCOAasciiSQLite` can return `55` (item already exists) or `56` (byte-count
124
+ warning) even on a successful import; these are informational warnings, not failures.
125
+ - **Manager number** — use distinct `-num` values for concurrent import and export operations
126
+ to avoid conflicts.
127
+ - **Standalone mode** — `-n` bypasses the Data/Event manager and accesses the SQLite database
128
+ directly. Not supported on RAIMA-based projects.
129
+
130
+ ## 🧩 Usage (API)
131
+
132
+ ### Convenience functions
133
+
134
+ ```typescript
135
+ import { importDpl, exportDpl } from "@winccoa-tools-pack/npm-winccoa-ascii";
136
+
137
+ // Import a DPL file
138
+ const importResult = await importDpl({
139
+ version: "3.21",
140
+ projectName: "MyProject",
141
+ inputPath: "/path/to/data.dpl",
142
+ typesAction: "yes",
143
+ managerNumber: 96,
144
+ });
145
+
146
+ if (!importResult.success) {
147
+ console.error(`Import failed: ${importResult.exitCode}`);
148
+ }
149
+
150
+ // Export datapoints by type
151
+ const exportResult = await exportDpl({
152
+ version: "3.21",
153
+ projectName: "MyProject",
154
+ outputPath: "/path/to/out.dpl",
155
+ filterDpType: ["MyDPType"],
156
+ exportTimestamp: true,
157
+ managerNumber: 97,
158
+ });
159
+
160
+ console.log(exportResult.stdout);
161
+ ```
162
+
163
+ ### Full import options
164
+
165
+ ```typescript
166
+ import type { DplImportOptions } from "@winccoa-tools-pack/npm-winccoa-ascii";
167
+
168
+ const options: DplImportOptions = {
169
+ version: "3.21",
170
+ projectName: "MyProject", // or: configPath: "/path/to/config/config"
171
+ inputPath: "data.dpl", // or wildcard: "*.dpl"
172
+ typesAction: "yes", // 'yes' | 'no'
173
+ cnsAction: "no", // 'yes' | 'no'
174
+ commitCount: 200,
175
+ noVerbose: true,
176
+ inactivateAlert: false,
177
+ alwaysSendCommon: false,
178
+ localTime: true,
179
+ managerNumber: 96,
180
+ standalone: false, // true = -n, no Data/Event manager needed
181
+ timeout: 120_000,
182
+ };
183
+ ```
184
+
185
+ ### Full export options
186
+
187
+ ```typescript
188
+ import type { DplExportOptions } from "@winccoa-tools-pack/npm-winccoa-ascii";
189
+
190
+ const options: DplExportOptions = {
191
+ version: "3.21",
192
+ projectName: "MyProject",
193
+ outputPath: "/out/export.dpl",
194
+ filter: "DPA", // T/D/A/C/O/P/H
195
+ filterDp: ["System1:Dp1"],
196
+ filterDpType: ["MyType"],
197
+ filterFile: "/path/to/filter.txt",
198
+ filterCns: ["MyView"],
199
+ younger: "01.01.2024",
200
+ outputVersion: 2, // 1 | 2 | 3 | 4
201
+ langList: "de,en",
202
+ keepSystem: true,
203
+ exportTimestamp: true,
204
+ localTime: false,
205
+ managerNumber: 97,
206
+ standalone: false,
207
+ timeout: 120_000,
208
+ };
209
+ ```
210
+
211
+ ### AsciiManager class
212
+
213
+ For repeated operations, reuse the manager instance directly:
214
+
215
+ ```typescript
216
+ import { AsciiManager } from "@winccoa-tools-pack/npm-winccoa-ascii";
217
+
218
+ const manager = new AsciiManager();
219
+
220
+ if (!manager.exists("3.21")) {
221
+ throw new Error("WCCOAasciiSQLite not found for version 3.21");
222
+ }
223
+
224
+ const result = await manager.import({
225
+ version: "3.21",
226
+ inputPath: "data.dpl",
227
+ projectName: "Proj",
228
+ });
229
+ ```
230
+
231
+ ## 🩺 Troubleshooting
232
+
233
+ | Symptom | Cause / Fix |
234
+ | --------- | ------------- |
235
+ | `WCCOAasciiSQLite not found` | Check `--version` matches your WinCC OA installation |
236
+ | Import times out | Increase `--timeout`; ensure managers are running (or use `--standalone`) |
237
+ | Exit code 55 | DP/type already exists — safe to ignore for idempotent imports |
238
+ | Exit code 56 | Byte-count mismatch warning — usually harmless |
239
+ | Export produces empty file | Check `--filter` value and manager connectivity |
240
+
241
+ ## 📚 Ecosystem Integration
242
+
243
+ This package works alongside the rest of the winccoa-tools-pack suite:
244
+
245
+ - **VS Code extensions** — integrates with WinCC OA developer tooling for panel, script, and
246
+ datapoint management
247
+ - **CI/CD pipelines** — use `winccoa-ascii import` and `winccoa-ascii export` in GitHub Actions
248
+ or GitLab CI for automated data migration and backup workflows
249
+ - **Other libraries** — compatible with `npm-winccoa-core`, `npm-winccoa-ui-pnl-xml`,
250
+ and `npm-winccoa-ctrl`
251
+
252
+ ## 📦 Development
253
+
254
+ ```bash
255
+ # Install dependencies
256
+ npm install
257
+
258
+ # Build (CJS + ESM + types)
259
+ npm run build
260
+
261
+ # Run unit tests
262
+ npm run test:unit
263
+
264
+ # Run integration tests (requires WinCC OA installation)
265
+ npm run test:integration
266
+
267
+ # Full test suite (lint + build + unit tests)
268
+ npm test
269
+
270
+ # Lint and format
271
+ npm run style-check
272
+ npm run style-fix
273
+ ```
274
+
275
+ ## 🏆 Recognition
276
+
277
+ Special thanks to all our [contributors](https://github.com/orgs/winccoa-tools-pack/people) who
278
+ make this project possible!
279
+
280
+ ### Key Contributors
281
+
282
+ - **Richard Janisch** ([@RichardJanisch](https://github.com/RichardJanisch)) — Creator & Lead Developer
283
+
284
+ ---
285
+
286
+ ## 📜 License
287
+
288
+ Licensed under the **MIT License** — see the
289
+ [LICENSE](https://github.com/winccoa-tools-pack/.github/blob/main/LICENSE) file for details.
290
+
291
+ ---
292
+
293
+ ## ⚠️ Disclaimer
294
+
295
+ **WinCC OA** and **Siemens** are trademarks of Siemens AG.
296
+ This project is not affiliated with, endorsed by, or sponsored by Siemens AG.
297
+ This is a community-driven open source project created to enhance the development experience for
298
+ WinCC OA developers.
299
+
300
+ ---
301
+
302
+ Made with ❤️ for and by the WinCC OA community
package/dist/api.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import type { DplImportOptions, DplImportResult, DplExportOptions, DplExportResult } from './types';
2
+ /**
3
+ * Import a DPL file (or wildcard pattern) into a WinCC OA project.
4
+ *
5
+ * This is a convenience wrapper around {@link AsciiManager.import}
6
+ * using a shared singleton instance.
7
+ *
8
+ * @param options - Import options (version, inputPath, project reference, etc.)
9
+ * @returns Import result
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const result = await importDpl({
14
+ * version: '3.21',
15
+ * configPath: '/path/to/project/config/config',
16
+ * inputPath: '/path/to/data.dpl',
17
+ * typesAction: 'yes',
18
+ * });
19
+ * console.log(result.success); // true
20
+ * ```
21
+ */
22
+ export declare function importDpl(options: DplImportOptions): Promise<DplImportResult>;
23
+ /**
24
+ * Export datapoints from a WinCC OA project to a DPL file.
25
+ *
26
+ * This is a convenience wrapper around {@link AsciiManager.export}
27
+ * using a shared singleton instance.
28
+ *
29
+ * @param options - Export options (version, outputPath, project reference, filters, etc.)
30
+ * @returns Export result
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const result = await exportDpl({
35
+ * version: '3.21',
36
+ * configPath: '/path/to/project/config/config',
37
+ * outputPath: '/path/to/out.dpl',
38
+ * filter: 'DP',
39
+ * });
40
+ * console.log(result.success); // true
41
+ * ```
42
+ */
43
+ export declare function exportDpl(options: DplExportOptions): Promise<DplExportResult>;
44
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAOpG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAEnF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAEnF"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importDpl = importDpl;
4
+ exports.exportDpl = exportDpl;
5
+ const manager_1 = require("./manager");
6
+ /**
7
+ * Shared manager instance used by the convenience functions.
8
+ */
9
+ const manager = new manager_1.AsciiManager();
10
+ /**
11
+ * Import a DPL file (or wildcard pattern) into a WinCC OA project.
12
+ *
13
+ * This is a convenience wrapper around {@link AsciiManager.import}
14
+ * using a shared singleton instance.
15
+ *
16
+ * @param options - Import options (version, inputPath, project reference, etc.)
17
+ * @returns Import result
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const result = await importDpl({
22
+ * version: '3.21',
23
+ * configPath: '/path/to/project/config/config',
24
+ * inputPath: '/path/to/data.dpl',
25
+ * typesAction: 'yes',
26
+ * });
27
+ * console.log(result.success); // true
28
+ * ```
29
+ */
30
+ async function importDpl(options) {
31
+ return manager.import(options);
32
+ }
33
+ /**
34
+ * Export datapoints from a WinCC OA project to a DPL file.
35
+ *
36
+ * This is a convenience wrapper around {@link AsciiManager.export}
37
+ * using a shared singleton instance.
38
+ *
39
+ * @param options - Export options (version, outputPath, project reference, filters, etc.)
40
+ * @returns Export result
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const result = await exportDpl({
45
+ * version: '3.21',
46
+ * configPath: '/path/to/project/config/config',
47
+ * outputPath: '/path/to/out.dpl',
48
+ * filter: 'DP',
49
+ * });
50
+ * console.log(result.success); // true
51
+ * ```
52
+ */
53
+ async function exportDpl(options) {
54
+ return manager.export(options);
55
+ }
56
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;AA4BA,8BAEC;AAsBD,8BAEC;AAtDD,uCAAyC;AAGzC;;GAEG;AACH,MAAM,OAAO,GAAG,IAAI,sBAAY,EAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,SAAS,CAAC,OAAyB;IACrD,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACI,KAAK,UAAU,SAAS,CAAC,OAAyB;IACrD,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}