@mcp-abap-adt/sap-rfc-lite 0.1.0 → 0.1.2

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/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ This project is based on node-rfc (https://github.com/SAP/node-rfc)
2
+ Copyright 2014 SAP SE, Srdjan Boskovic <srdjan.boskovic@sap.com>
3
+ Licensed under the Apache License, Version 2.0
4
+
5
+ Modifications: Removed Pool, Server, Throughput classes. Simplified Client API to Promise-only.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # sap-rfc-lite
2
+ [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)
3
+
4
+ Lightweight Node.js bindings for SAP NetWeaver RFC SDK.
5
+
6
+ ## Motivation
7
+
8
+ The only existing open-source Node.js binding for SAP NW RFC SDK is [node-rfc](https://github.com/SAP/node-rfc) by SAP. While it served the community well, it has accumulated significant technical debt:
9
+
10
+ - **24 known vulnerabilities** (5 low, 7 moderate, 12 high) in its dependency tree
11
+ - **18 outdated packages**, including runtime dependencies like `bluebird` (a Promise library unnecessary since Node.js 8+) and `decimal.js`
12
+ - **Repository archived** — the source has moved to [SAP-archive/node-rfc](https://github.com/SAP-archive/node-rfc), signaling deprecation
13
+ - **Last published 2+ years ago** with no signs of active maintenance
14
+ - **~14,000 lines of source code** for what is fundamentally an RFC client binding
15
+
16
+ SAP has since created a proprietary replacement (`@sap-rfc/node-rfc-library`), but it is only available through a private npm registry and requires an S-user with a SAP Build Code license — making it inaccessible to the broader community.
17
+
18
+ No other lightweight alternative exists in the Node.js ecosystem. The only other package, [sapnwrfc](https://www.npmjs.com/package/sapnwrfc), was last published over 10 years ago.
19
+
20
+ ### Comparison
21
+
22
+ | | sap-rfc-lite | node-rfc |
23
+ |---|---|---|
24
+ | Source code | ~2,200 lines | ~14,200 lines |
25
+ | Runtime dependencies | 2 | 4 (includes bluebird, decimal.js) |
26
+ | Vulnerabilities (npm audit) | **0** | **24** |
27
+ | Outdated packages | 4 (dev only) | 18 (including runtime) |
28
+ | API | Promise-based Client | Client, Pool, Server, Throughput |
29
+ | Node.js requirement | >= 18 | >= 18 |
30
+ | N-API version | 8 | 8 |
31
+
32
+ This project focuses on what most users actually need — a clean, modern, Promise-based RFC client — without the baggage of unused features and vulnerable dependencies.
33
+
34
+ ## Prerequisites
35
+
36
+ - Node.js >= 18
37
+ - SAP NetWeaver RFC SDK installed
38
+ - C++ build tools (Visual Studio Build Tools on Windows, GCC/Clang on Linux/macOS)
39
+
40
+ Set the `SAPNWRFC_HOME` environment variable to the SDK root directory (the folder containing `lib/` and `include/`).
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ npm install @mcp-abap-adt/sap-rfc-lite
46
+ ```
47
+
48
+ ## Runtime library loading
49
+
50
+ The addon is linked against the SDK shared libraries (`libsapnwrfc`, `libsapucum`) and, on Linux, the system `libuuid`. The dynamic loader must find all of them when the addon is loaded.
51
+
52
+ On Linux and macOS the build embeds an rpath to `$SAPNWRFC_HOME/lib`, so the SDK libraries are found without extra settings as long as the SDK stays where it was at build time. Set the library search path when:
53
+
54
+ - the SDK was moved, or the built addon is deployed to a machine where the SDK lives elsewhere;
55
+ - Node.js ships its own glibc and does not search the system library directories (for example, Node.js installed via Homebrew on Linux). Loading then fails with `ERR_DLOPEN_FAILED` and `libuuid.so.1: cannot open shared object file`.
56
+
57
+ | OS | Variable |
58
+ |---|---|
59
+ | Linux | `LD_LIBRARY_PATH` |
60
+ | macOS | `DYLD_LIBRARY_PATH` |
61
+ | Windows | `PATH` (must include `%SAPNWRFC_HOME%\lib`) |
62
+
63
+ ```bash
64
+ # SDK moved or deployed elsewhere
65
+ export LD_LIBRARY_PATH="$SAPNWRFC_HOME/lib:$LD_LIBRARY_PATH"
66
+ ```
67
+
68
+ For a Node.js with its own glibc, do **not** add the whole system library directory (`/lib/x86_64-linux-gnu`): the loader would then take the system glibc, which may be older than the one Node.js was built against (`GLIBC_2.38 not found`). Expose only the missing library instead:
69
+
70
+ ```bash
71
+ mkdir -p ~/.local/lib/sap-rfc-lite
72
+ ln -sf /lib/x86_64-linux-gnu/libuuid.so.1 ~/.local/lib/sap-rfc-lite/
73
+ export LD_LIBRARY_PATH="$HOME/.local/lib/sap-rfc-lite:$SAPNWRFC_HOME/lib:$LD_LIBRARY_PATH"
74
+ ```
75
+
76
+ `binding.bindingVersions` reports the package version and the loaded SDK version, which is a quick check that the addon loads:
77
+
78
+ ```bash
79
+ node -e "console.log(require('@mcp-abap-adt/sap-rfc-lite').binding.bindingVersions)"
80
+ ```
81
+
82
+ ## Usage
83
+
84
+ ```typescript
85
+ import { Client } from '@mcp-abap-adt/sap-rfc-lite';
86
+
87
+ const client = new Client({
88
+ ashost: '10.0.0.1',
89
+ sysnr: '00',
90
+ client: '100',
91
+ user: 'USER',
92
+ passwd: 'PASSWORD',
93
+ lang: 'EN',
94
+ });
95
+
96
+ await client.open();
97
+
98
+ const result = await client.call('STFC_CONNECTION', {
99
+ REQUTEXT: 'Hello from sap-rfc-lite',
100
+ });
101
+
102
+ console.log(result.ECHOTEXT);
103
+
104
+ await client.close();
105
+ ```
106
+
107
+ ## API
108
+
109
+ ### `new Client(connectionParameters)`
110
+
111
+ Creates a new RFC client instance.
112
+
113
+ - `connectionParameters` — an object with SAP connection parameters (`ashost`, `sysnr`, `client`, `user`, `passwd`, `lang`, etc.)
114
+
115
+ ### `client.open(): Promise<Client>`
116
+
117
+ Opens the RFC connection.
118
+
119
+ ### `client.call(rfmName, rfmParams?): Promise<RfcObject>`
120
+
121
+ Invokes a remote function module.
122
+
123
+ - `rfmName` — name of the function module
124
+ - `rfmParams` — optional input parameters
125
+
126
+ ### `client.close(): Promise<void>`
127
+
128
+ Closes the RFC connection.
129
+
130
+ ### `client.id: number`
131
+
132
+ Unique client instance identifier.
133
+
134
+ ### `client.alive: boolean`
135
+
136
+ Whether the connection is currently open.
137
+
138
+ ## License
139
+
140
+ [Apache-2.0](LICENSE)
package/binding.gyp CHANGED
@@ -13,6 +13,7 @@
13
13
  'nwrfcsdk_lib_dir': '<(nwrfcsdk_dir)/lib',
14
14
  'napi_include_dir': "<!(node -p \"require('node-addon-api').include_dir\")",
15
15
  'napi_version': "<!(node -p \"require('./package.json').config.napi_version\")",
16
+ 'package_version': "<!(node -p \"require('./package.json').version\")",
16
17
  'node_abi_version': '<!(node -p "process.versions.modules")',
17
18
  # per NodeJS build requirements: https://github.com/nodejs/node/blob/main/BUILDING.md
18
19
  'macosx_version_min': '10.15',
@@ -92,6 +93,7 @@
92
93
  'SAPwithTHREADS',
93
94
  'NAPI_CPP_EXCEPTIONS',
94
95
  'NAPI_VERSION=<(napi_version)',
96
+ 'NODERFC_VERSION=<(package_version)',
95
97
  'sapnwrfc_EXPORTS'
96
98
  ],
97
99
  'conditions': [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/sap-rfc-lite",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Lightweight Node.js bindings for SAP NW RFC SDK",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
@@ -8,7 +8,8 @@
8
8
  "files": [
9
9
  "binding.gyp",
10
10
  "src",
11
- "lib"
11
+ "lib",
12
+ "NOTICE"
12
13
  ],
13
14
  "scripts": {
14
15
  "install": "node-gyp-build",
@@ -25,15 +26,15 @@
25
26
  "napi_version": 8
26
27
  },
27
28
  "dependencies": {
28
- "node-addon-api": "^6.1.0",
29
+ "node-addon-api": "^8.9.2",
29
30
  "node-gyp-build": "^4.6.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@biomejs/biome": "^2.3.10",
33
- "@types/jest": "^29.0.0",
33
+ "@biomejs/biome": "^2.5.14",
34
+ "@types/jest": "^30.0.0",
34
35
  "@types/node": "^20.0.0",
35
36
  "husky": "^9.1.7",
36
- "jest": "^29.0.0",
37
+ "jest": "^30.5.1",
37
38
  "ts-jest": "^29.0.0",
38
39
  "ts-node": "^10.9.2",
39
40
  "typescript": "^5.0.0"
package/src/cpp/addon.cc CHANGED
@@ -21,7 +21,7 @@ Napi::Value BindingVersions(Napi::Env env) {
21
21
  nwrfcsdk.Set("patchLevel", patchLevel);
22
22
 
23
23
  Napi::Object version = Napi::Object::New(env);
24
- version.Set("version", "0.1.0");
24
+ version.Set("version", NODERFC_VERSION_STRING);
25
25
  version.Set("nwrfcsdk", nwrfcsdk);
26
26
 
27
27
  return scope.Escape(version);
package/src/cpp/noderfc.h CHANGED
@@ -17,8 +17,15 @@
17
17
  #define uint_t uint32_t
18
18
  #define pointer_t uintptr_t
19
19
 
20
- // client binding version
21
- #define NODERFC_VERSION "0.1.0"
20
+ // client binding version, injected unquoted by binding.gyp from package.json
21
+ // (stringified here to avoid platform-specific quoting of compiler defines)
22
+ #define NODERFC_STRINGIFY_(x) #x
23
+ #define NODERFC_STRINGIFY(x) NODERFC_STRINGIFY_(x)
24
+ #ifdef NODERFC_VERSION
25
+ #define NODERFC_VERSION_STRING NODERFC_STRINGIFY(NODERFC_VERSION)
26
+ #else
27
+ #define NODERFC_VERSION_STRING "unknown"
28
+ #endif
22
29
 
23
30
  // surpress unused parameter warnings
24
31
  #define UNUSED(x) (void)(x)