tnz3270-node 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.
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/dist/index.cjs +5489 -0
- package/dist/index.d.cts +1305 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1305 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5384 -0
- package/package.json +61 -0
- package/src/automation/ati.ts +1057 -0
- package/src/automation/file-transfer.ts +305 -0
- package/src/core/base.ts +59 -0
- package/src/core/buffer.ts +228 -0
- package/src/core/keyboard.ts +396 -0
- package/src/core/parser.ts +422 -0
- package/src/core/screen.ts +110 -0
- package/src/core/telnet.ts +213 -0
- package/src/core/tnz-state.ts +4 -0
- package/src/core/tnz.ts +2403 -0
- package/src/index.ts +113 -0
- package/src/types.ts +348 -0
- package/src/utils/codepage.ts +281 -0
- package/src/utils/session-utils.ts +94 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 gurungabit@gmail.com
|
|
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
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# TNZ-Node
|
|
2
|
+
|
|
3
|
+
TNZ-Node is a zero-dependency, highly performant TypeScript library. It provides a complete TN3270 data stream parser, protocol negotiator, and screen buffer manager for interacting with IBM Mainframes (z/OS, MVS, TK4-).
|
|
4
|
+
|
|
5
|
+
It includes a powerful automation layer (`Ati`) for headless scripting, screen scraping, and concurrent mainframe interactions, as well as native support for `IND$FILE` (DDM) file transfers.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Full 3270 Protocol Implementation**: Complete support for `Write`, `Erase/Write`, `Read Buffer`, `Read Modified`, and `WSF` operations.
|
|
10
|
+
- **Native Keyboard Emulation**: Maps complex 3270 keys (`[enter]`, `[pf1]`, `[tab]`, `[clear]`) directly to buffer operations handling MDT and protection boundaries.
|
|
11
|
+
- **Enhanced Screen Reading**: `scrstr()` and `scrhas()` implementations with full character-set awareness (EBCDIC/ASCII/GE), control character translation, and password field cloaking.
|
|
12
|
+
- **ATI Automation Engine**: A robust, event-driven scripting layer allowing you to safely type, wait for screen conditions, and trigger conditional actions (`when`).
|
|
13
|
+
- **Concurrent Execution**: The socket logic is entirely event-driven, allowing you to spawn hundreds of mainframe bots simultaneously without blocking the Node.js event loop.
|
|
14
|
+
- **File Transfers**: Natively implements the DDM `IND$FILE` protocol, allowing file uploads and downloads between your local machine and the host.
|
|
15
|
+
- **Zero Runtime Dependencies**: The entire library is built strictly on Node.js built-ins (`net`, `tls`, `events`).
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install tnz3270-node
|
|
21
|
+
# or
|
|
22
|
+
yarn add tnz3270-node
|
|
23
|
+
# or
|
|
24
|
+
bun install tnz3270-node
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
The easiest way to interact with the mainframe programmatically is through the `Ati` automation wrapper.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { Ati } from 'tnz3270-node';
|
|
33
|
+
|
|
34
|
+
async function main() {
|
|
35
|
+
const ati = new Ati();
|
|
36
|
+
|
|
37
|
+
console.log('Connecting...');
|
|
38
|
+
await ati.connectSession('MVS_SESSION', {
|
|
39
|
+
host: '127.0.0.1',
|
|
40
|
+
port: 3270,
|
|
41
|
+
useTn3270e: true,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Wait for the Logon prompt to appear on the screen
|
|
45
|
+
await ati.wait(10, () => ati.scrhas('Logon ===>'));
|
|
46
|
+
|
|
47
|
+
// Clear the screen and type the TSO logon command
|
|
48
|
+
await ati.send('[clear]');
|
|
49
|
+
await ati.wait(2, () => ati.keyLock === false);
|
|
50
|
+
await ati.send('L HERC01[enter]');
|
|
51
|
+
|
|
52
|
+
// Wait for the password prompt
|
|
53
|
+
await ati.wait(10, () => ati.scrhas('PASSWORD'));
|
|
54
|
+
|
|
55
|
+
// Enter the password
|
|
56
|
+
await ati.send('CUL8TR[enter]');
|
|
57
|
+
|
|
58
|
+
// Wait for TSO READY
|
|
59
|
+
await ati.wait(10, () => ati.scrhas('READY'));
|
|
60
|
+
|
|
61
|
+
// Print the screen buffer to the console
|
|
62
|
+
const tnz = ati.getTnz();
|
|
63
|
+
console.log(tnz.scrstr(0, 0, true));
|
|
64
|
+
|
|
65
|
+
console.log('Logged in successfully!');
|
|
66
|
+
ati.dropSession();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main().catch(console.error);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### IND$FILE File Transfers
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// Download a remote dataset to your local machine
|
|
76
|
+
await ati.getFile('sys1.proclib(test) ascii crlf', './local-file.txt');
|
|
77
|
+
|
|
78
|
+
// Upload a local file to the mainframe
|
|
79
|
+
await ati.putFile('./local-file.txt', 'herc01.my.dataset ascii crlf');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Development & Testing
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Start development mode
|
|
86
|
+
bun run dev
|
|
87
|
+
|
|
88
|
+
# Build for production
|
|
89
|
+
bun run build
|
|
90
|
+
|
|
91
|
+
# Run unit tests (289 tests covering 3270 binary protocols)
|
|
92
|
+
bun run test
|
|
93
|
+
|
|
94
|
+
# Run automation integration test against a local TK4- instance
|
|
95
|
+
bun run test-login.ts
|
|
96
|
+
bun run test-stress.ts
|
|
97
|
+
bun run test-concurrency.ts
|
|
98
|
+
```
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|