@mcp-abap-adt/adt-clients 2.2.0 → 2.2.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlQuery.d.ts","sourceRoot":"","sources":["../../../src/core/shared/sqlQuery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,YAAY,IAAI,aAAa,EAC7B,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"sqlQuery.d.ts","sourceRoot":"","sources":["../../../src/core/shared/sqlQuery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,YAAY,IAAI,aAAa,EAC7B,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,aAAa,CAAC,CAmBxB"}
|
|
@@ -29,7 +29,7 @@ async function getSqlQuery(connection, params) {
|
|
|
29
29
|
data: params.sql_query,
|
|
30
30
|
headers: {
|
|
31
31
|
'Content-Type': 'text/plain; charset=utf-8',
|
|
32
|
-
Accept: 'application/xml',
|
|
32
|
+
Accept: 'application/xml, application/vnd.sap.adt.datapreview.table.v1+xml',
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Table contents operations via ADT Data Preview API
|
|
2
|
+
* Table contents operations via ADT DDIC Data Preview API
|
|
3
|
+
*
|
|
4
|
+
* Retrieves table metadata to build field list, then uses the DDIC Data Preview
|
|
5
|
+
* endpoint with POST and SQL query in body (TABLE~FIELD syntax, same as Eclipse ADT).
|
|
3
6
|
*
|
|
4
7
|
* ⚠️ ABAP Cloud Limitation: Direct access to table data through ADT Data Preview
|
|
5
8
|
* is blocked by SAP BTP backend policies when using JWT/XSUAA authentication.
|
|
@@ -8,7 +11,7 @@
|
|
|
8
11
|
import type { IAdtResponse as AxiosResponse, IAbapConnection } from '@mcp-abap-adt/interfaces';
|
|
9
12
|
import type { IGetTableContentsParams } from './types';
|
|
10
13
|
/**
|
|
11
|
-
* Get table contents via ADT Data Preview API
|
|
14
|
+
* Get table contents via ADT DDIC Data Preview API
|
|
12
15
|
*
|
|
13
16
|
* @param connection - ABAP connection
|
|
14
17
|
* @param params - Table contents parameters
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableContents.d.ts","sourceRoot":"","sources":["../../../src/core/shared/tableContents.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tableContents.d.ts","sourceRoot":"","sources":["../../../src/core/shared/tableContents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,YAAY,IAAI,aAAa,EAC7B,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAwCvD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,aAAa,CAAC,CA+BxB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Table contents operations via ADT Data Preview API
|
|
3
|
+
* Table contents operations via ADT DDIC Data Preview API
|
|
4
|
+
*
|
|
5
|
+
* Retrieves table metadata to build field list, then uses the DDIC Data Preview
|
|
6
|
+
* endpoint with POST and SQL query in body (TABLE~FIELD syntax, same as Eclipse ADT).
|
|
4
7
|
*
|
|
5
8
|
* ⚠️ ABAP Cloud Limitation: Direct access to table data through ADT Data Preview
|
|
6
9
|
* is blocked by SAP BTP backend policies when using JWT/XSUAA authentication.
|
|
@@ -10,8 +13,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
13
|
exports.getTableContents = getTableContents;
|
|
11
14
|
const internalUtils_1 = require("../../utils/internalUtils");
|
|
12
15
|
const timeouts_1 = require("../../utils/timeouts");
|
|
16
|
+
const ACCEPT_HEADER = 'application/xml, application/vnd.sap.adt.datapreview.table.v1+xml';
|
|
17
|
+
/**
|
|
18
|
+
* Get column names for a DDIC entity via metadata endpoint
|
|
19
|
+
*/
|
|
20
|
+
async function getColumnNames(connection, tableName) {
|
|
21
|
+
const encodedName = (0, internalUtils_1.encodeSapObjectName)(tableName);
|
|
22
|
+
const url = `/sap/bc/adt/datapreview/ddic/${encodedName}/metadata`;
|
|
23
|
+
const response = await connection.makeAdtRequest({
|
|
24
|
+
url,
|
|
25
|
+
method: 'GET',
|
|
26
|
+
timeout: (0, timeouts_1.getTimeout)('default'),
|
|
27
|
+
headers: {
|
|
28
|
+
Accept: ACCEPT_HEADER,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const xml = response.data;
|
|
32
|
+
const fields = [];
|
|
33
|
+
const fieldMatches = xml.match(/dataPreview:name="([^"]+)"/g);
|
|
34
|
+
if (fieldMatches) {
|
|
35
|
+
for (const match of fieldMatches) {
|
|
36
|
+
const nameMatch = match.match(/dataPreview:name="([^"]+)"/);
|
|
37
|
+
if (nameMatch) {
|
|
38
|
+
fields.push(nameMatch[1]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return fields;
|
|
43
|
+
}
|
|
13
44
|
/**
|
|
14
|
-
* Get table contents via ADT Data Preview API
|
|
45
|
+
* Get table contents via ADT DDIC Data Preview API
|
|
15
46
|
*
|
|
16
47
|
* @param connection - ABAP connection
|
|
17
48
|
* @param params - Table contents parameters
|
|
@@ -22,70 +53,24 @@ async function getTableContents(connection, params) {
|
|
|
22
53
|
throw new Error('Table name is required');
|
|
23
54
|
}
|
|
24
55
|
const maxRows = params.max_rows || 100;
|
|
25
|
-
const
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
// Get table structure
|
|
29
|
-
const structureResponse = await connection.makeAdtRequest({
|
|
30
|
-
url: structureUrl,
|
|
31
|
-
method: 'GET',
|
|
32
|
-
timeout: (0, timeouts_1.getTimeout)('default'),
|
|
33
|
-
headers: {},
|
|
34
|
-
});
|
|
35
|
-
// Parse table structure to extract field names
|
|
36
|
-
const structureText = structureResponse.data;
|
|
37
|
-
const fields = [];
|
|
38
|
-
// Extract field names from ABAP table definition
|
|
39
|
-
// Support both old and new CDS view syntax
|
|
40
|
-
if (structureText.includes('define table')) {
|
|
41
|
-
// New CDS syntax
|
|
42
|
-
const lines = structureText.split('\n');
|
|
43
|
-
for (const line of lines) {
|
|
44
|
-
const trimmedLine = line.trim();
|
|
45
|
-
const fieldMatch = trimmedLine.match(/^(key\s+)?([a-z0-9_]+)\s*:\s*[a-z0-9_]+/i);
|
|
46
|
-
if (fieldMatch) {
|
|
47
|
-
const fieldName = fieldMatch[2].trim().toUpperCase();
|
|
48
|
-
if (fieldName && fieldName.length > 0) {
|
|
49
|
-
fields.push(`${params.table_name}~${fieldName}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
// Old ABAP syntax
|
|
56
|
-
const patterns = [
|
|
57
|
-
/^\s+([A-Z0-9_]+)\s*:\s*(TYPE|LIKE)/gim,
|
|
58
|
-
/^\s+([A-Z0-9_]+)\s+(TYPE|LIKE)/gim,
|
|
59
|
-
/^\s+([A-Z0-9_]+)\s*:\s*[A-Z0-9_]+/gim,
|
|
60
|
-
];
|
|
61
|
-
for (const pattern of patterns) {
|
|
62
|
-
let match = pattern.exec(structureText);
|
|
63
|
-
while (match !== null) {
|
|
64
|
-
const fieldName = match[1].trim().toUpperCase();
|
|
65
|
-
if (fieldName &&
|
|
66
|
-
fieldName.length > 0 &&
|
|
67
|
-
!fields.includes(`${params.table_name}~${fieldName}`)) {
|
|
68
|
-
fields.push(`${params.table_name}~${fieldName}`);
|
|
69
|
-
}
|
|
70
|
-
match = pattern.exec(structureText);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
56
|
+
const tableName = params.table_name.toUpperCase();
|
|
57
|
+
// Get column names via metadata endpoint (as Eclipse ADT does)
|
|
58
|
+
const fields = await getColumnNames(connection, tableName);
|
|
74
59
|
if (fields.length === 0) {
|
|
75
|
-
throw new Error('Could not
|
|
60
|
+
throw new Error('Could not retrieve column names from table metadata');
|
|
76
61
|
}
|
|
77
|
-
// Build SQL
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const url = `/sap/bc/adt/datapreview/
|
|
62
|
+
// Build SQL with TABLE~FIELD syntax (as Eclipse ADT does)
|
|
63
|
+
const fieldList = fields.map((f) => `${tableName}~${f}`).join(', ');
|
|
64
|
+
const sqlQuery = `SELECT ${fieldList} FROM ${tableName}`;
|
|
65
|
+
const url = `/sap/bc/adt/datapreview/ddic?rowNumber=${maxRows}&ddicEntityName=${encodeURIComponent(tableName)}`;
|
|
81
66
|
return connection.makeAdtRequest({
|
|
82
67
|
url,
|
|
83
68
|
method: 'POST',
|
|
84
69
|
timeout: (0, timeouts_1.getTimeout)('long'),
|
|
85
70
|
data: sqlQuery,
|
|
86
71
|
headers: {
|
|
87
|
-
'Content-Type': 'text/plain
|
|
88
|
-
Accept:
|
|
72
|
+
'Content-Type': 'text/plain',
|
|
73
|
+
Accept: ACCEPT_HEADER,
|
|
89
74
|
},
|
|
90
75
|
});
|
|
91
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/adt-clients",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "ADT clients for SAP ABAP systems - AdtClient and AdtRuntimeClient",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@mcp-abap-adt/interfaces": "^2.6.0",
|
|
65
65
|
"@mcp-abap-adt/logger": "^0.1.3",
|
|
66
|
-
"axios": "^1.
|
|
67
|
-
"fast-xml-parser": "^5.
|
|
66
|
+
"axios": "^1.13.6",
|
|
67
|
+
"fast-xml-parser": "^5.4.1",
|
|
68
68
|
"yaml": "^2.3.4"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@biomejs/biome": "^2.4.
|
|
71
|
+
"@biomejs/biome": "^2.4.4",
|
|
72
72
|
"@mcp-abap-adt/connection": "^1.1.0",
|
|
73
73
|
"@types/jest": "^30.0.0",
|
|
74
|
-
"@types/node": "^25.3.
|
|
74
|
+
"@types/node": "^25.3.3",
|
|
75
75
|
"dotenv": "^17.3.1",
|
|
76
76
|
"jest": "^30.0.5",
|
|
77
77
|
"jest-util": "^30.2.0",
|