abap-local-client 1.0.0 → 1.1.1

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/bin/config.cjs CHANGED
@@ -1,8 +1,3 @@
1
- #!/usr/bin/env node
2
- // abap-local-config entry point (CommonJS wrapper for ESM package)
3
- (async () => {
4
- await import('../config-cli.mjs');
5
- })().catch(err => {
6
- console.error('Failed to start abap-local-config:', err.message);
7
- process.exit(1);
8
- });
1
+ #!/usr/bin/env node
2
+ // abap-local-config entry point (CJS wrapper dynamic import ESM module)
3
+ (async()=>{await import('../config-cli.mjs')})().catch(e=>{console.error(e.message);process.exit(1)});
package/bin/sso.cjs ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // abap-local-client entry point (CJS wrapper → dynamic import ESM module)
3
+ (async()=>{await import('../sso-sap-client.mjs')})().catch(e=>{console.error(e.message);process.exit(1)});
package/cli-config.cjs ADDED
@@ -0,0 +1,2 @@
1
+ // abap-local-config — CommonJS wrapper for ESM entry point
2
+ import('../config-cli.mjs');
package/cli.cjs ADDED
@@ -0,0 +1,3 @@
1
+ // abap-local-client — CommonJS wrapper for ESM entry point
2
+ // This wrapper is what npm's "bin" generates: node ./cli.js
3
+ import('../sso-sap-client.mjs');
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "abap-local-client",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "SAP Local Client — WebSocket bridge with Basic, SPNEGO, X.509, SAML & SNC authentication",
5
5
  "main": "sso-sap-client.mjs",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "start": "node sso-sap-client.mjs",
9
- "dev": "node sso-sap-client.mjs",
10
9
  "sso": "node sso-sap-client.mjs",
11
- "rfc": "node saprouter-client.mjs",
12
- "kill": "node kill-client.js",
10
+ "config": "node config-cli.mjs",
13
11
  "test": "node test-integration.mjs",
14
12
  "prepublishOnly": "node test-integration.mjs"
15
13
  },
package/xml-utils.js ADDED
@@ -0,0 +1,60 @@
1
+ import { XMLParser } from 'fast-xml-parser';
2
+
3
+ // Create XML parser instance
4
+ const xmlParser = new XMLParser({
5
+ ignoreAttributes: false,
6
+ attributeNamePrefix: '@_'
7
+ });
8
+
9
+ /**
10
+ * Parse SAP XML response and check for errors
11
+ * Returns: { hasErrors: boolean, errorMessages: string[], parsedData: object }
12
+ */
13
+ export function parseSAPResponse(xmlString) {
14
+ if (typeof xmlString !== 'string' || !xmlString.includes('<?xml')) {
15
+ return { hasErrors: false, errorMessages: [], parsedData: null };
16
+ }
17
+
18
+ try {
19
+ const parsed = xmlParser.parse(xmlString);
20
+
21
+ // Check for syntax check errors (chkrun:checkMessage with type="E")
22
+ if (parsed['chkrun:checkRunReports']) {
23
+ const report = parsed['chkrun:checkRunReports']['chkrun:checkReport'];
24
+ const messageList = report?.['chkrun:checkMessageList'];
25
+
26
+ if (messageList && messageList['chkrun:checkMessage']) {
27
+ const messages = Array.isArray(messageList['chkrun:checkMessage'])
28
+ ? messageList['chkrun:checkMessage']
29
+ : [messageList['chkrun:checkMessage']];
30
+
31
+ const errorMessages = [];
32
+ for (const msg of messages) {
33
+ if (msg['@_chkrun:type'] === 'E') {
34
+ let line = null;
35
+ if (msg['@_chkrun:uri'] && msg['@_chkrun:uri'].includes('#start=')) {
36
+ const match = msg['@_chkrun:uri'].match(/#start=(\d+),(\d+)/);
37
+ if (match) {
38
+ line = parseInt(match[1]);
39
+ }
40
+ }
41
+ const text = msg['@_chkrun:shortText'] || 'Unknown error';
42
+ const lineInfo = line ? ` (line ${line})` : '';
43
+ errorMessages.push(`${text}${lineInfo}`);
44
+ }
45
+ }
46
+
47
+ if (errorMessages.length > 0) {
48
+ return { hasErrors: true, errorMessages, parsedData: parsed };
49
+ }
50
+ }
51
+ }
52
+
53
+ // Add other error patterns here if needed (e.g., activation errors, etc.)
54
+
55
+ return { hasErrors: false, errorMessages: [], parsedData: parsed };
56
+ } catch (error) {
57
+ console.error(' ⚠️ XML parsing failed:', error.message);
58
+ return { hasErrors: false, errorMessages: [], parsedData: null };
59
+ }
60
+ }