@mseep/bw-modeling-mcp 0.8.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/CHANGELOG.md +140 -0
- package/LICENSE +21 -0
- package/README.md +598 -0
- package/dist/bw-client.js +774 -0
- package/dist/index.js +2199 -0
- package/dist/tools/activation.js +171 -0
- package/dist/tools/adso.js +895 -0
- package/dist/tools/composite_provider.js +169 -0
- package/dist/tools/cp_components.js +347 -0
- package/dist/tools/dataflow.js +148 -0
- package/dist/tools/datasource.js +536 -0
- package/dist/tools/delete.js +22 -0
- package/dist/tools/dtp.js +602 -0
- package/dist/tools/infoarea.js +117 -0
- package/dist/tools/infoobject.js +447 -0
- package/dist/tools/infosource.js +225 -0
- package/dist/tools/processchain.js +154 -0
- package/dist/tools/processvariant.js +49 -0
- package/dist/tools/push.js +100 -0
- package/dist/tools/query.js +631 -0
- package/dist/tools/reporting.js +558 -0
- package/dist/tools/repository.js +84 -0
- package/dist/tools/request_monitor.js +174 -0
- package/dist/tools/roles.js +503 -0
- package/dist/tools/search.js +107 -0
- package/dist/tools/transformation.js +1392 -0
- package/package.json +51 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse <atom:entry> elements from a BW search or xref Atom feed.
|
|
3
|
+
*/
|
|
4
|
+
function parseAtomEntries(xml) {
|
|
5
|
+
const entries = [];
|
|
6
|
+
const entryRegex = /<atom:entry>([\s\S]*?)<\/atom:entry>/g;
|
|
7
|
+
let match;
|
|
8
|
+
while ((match = entryRegex.exec(xml)) !== null) {
|
|
9
|
+
const body = match[1];
|
|
10
|
+
const nameMatch = body.match(/objectName="([^"]+)"/);
|
|
11
|
+
const typeMatch = body.match(/objectType="([^"]+)"/);
|
|
12
|
+
const statusMatch = body.match(/objectStatus="([^"]+)"/);
|
|
13
|
+
const versionMatch = body.match(/objectVersion="([^"]+)"/);
|
|
14
|
+
const titleMatch = body.match(/<atom:title>([^<]+)<\/atom:title>/);
|
|
15
|
+
const hrefMatch = body.match(/href="([^"]+)"/);
|
|
16
|
+
if (nameMatch && typeMatch) {
|
|
17
|
+
entries.push({
|
|
18
|
+
objectName: nameMatch[1],
|
|
19
|
+
objectType: typeMatch[1],
|
|
20
|
+
objectStatus: statusMatch?.[1] ?? 'unknown',
|
|
21
|
+
objectVersion: versionMatch?.[1] ?? '',
|
|
22
|
+
title: titleMatch?.[1] ?? '',
|
|
23
|
+
href: hrefMatch?.[1] ?? '',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return entries;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format search/xref entries as a human-readable list.
|
|
31
|
+
*/
|
|
32
|
+
function formatEntries(entries, header) {
|
|
33
|
+
if (entries.length === 0) {
|
|
34
|
+
return `${header}\n\nNo results found.`;
|
|
35
|
+
}
|
|
36
|
+
const lines = [header, '', `Found ${entries.length} result(s):`, ''];
|
|
37
|
+
for (let i = 0; i < entries.length; i++) {
|
|
38
|
+
const e = entries[i];
|
|
39
|
+
const version = e.objectVersion ? ` [v${e.objectVersion}]` : '';
|
|
40
|
+
lines.push(`${i + 1}. ${e.objectName} (${e.objectType}) — ${e.objectStatus}${version}` +
|
|
41
|
+
(e.title ? ` — "${e.title}"` : '') +
|
|
42
|
+
(e.href ? `\n Path: ${e.href}` : ''));
|
|
43
|
+
}
|
|
44
|
+
return lines.join('\n');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* bw_search — search BW objects by name/description, optionally filtered by type.
|
|
48
|
+
*
|
|
49
|
+
* Uses: GET /sap/bw/modeling/repo/is/bwsearch
|
|
50
|
+
* Parameters:
|
|
51
|
+
* searchTerm — supports wildcards (e.g. "NJ_*")
|
|
52
|
+
* objectType — optional: ADSO, TRFN, DTPA, IOBJ, etc. (empty = all types)
|
|
53
|
+
*
|
|
54
|
+
* Returns a formatted list of matching objects.
|
|
55
|
+
*/
|
|
56
|
+
export async function bwSearch(client, searchTerm, objectType) {
|
|
57
|
+
// Wide date range = no date filtering
|
|
58
|
+
const from = '1970-01-01T00%3A00%3A00Z';
|
|
59
|
+
const to = '2099-12-31T23%3A59%3A59Z';
|
|
60
|
+
const type = objectType ? encodeURIComponent(objectType.toUpperCase()) : '';
|
|
61
|
+
const path = `/sap/bw/modeling/repo/is/bwsearch` +
|
|
62
|
+
`?searchTerm=${encodeURIComponent(searchTerm)}` +
|
|
63
|
+
`&searchInName=true&searchInDescription=true` +
|
|
64
|
+
`&objectType=${type}` +
|
|
65
|
+
`&createdOnFrom=${from}&createdOnTo=${to}` +
|
|
66
|
+
`&changedOnFrom=${from}&changedOnTo=${to}`;
|
|
67
|
+
const result = await client.get(path, 'application/atom+xml;type=feed');
|
|
68
|
+
const entries = parseAtomEntries(result.body);
|
|
69
|
+
const header = `BW Search: "${searchTerm}"` + (objectType ? ` (type: ${objectType.toUpperCase()})` : '');
|
|
70
|
+
return formatEntries(entries, header);
|
|
71
|
+
}
|
|
72
|
+
function padRsdsObjectName(objectName) {
|
|
73
|
+
const upper = objectName.trim().toUpperCase();
|
|
74
|
+
if (upper.length >= 40)
|
|
75
|
+
return upper;
|
|
76
|
+
const match = upper.match(/^(.*\S)\s+(\S+)$/);
|
|
77
|
+
if (!match)
|
|
78
|
+
return upper;
|
|
79
|
+
return match[1].padEnd(30) + match[2];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* bw_xref — find where-used / dependencies for any BW object.
|
|
83
|
+
*
|
|
84
|
+
* Uses: GET /sap/bw/modeling/repo/is/xref?objectType=...&objectName=...
|
|
85
|
+
* Supported objectTypes: ADSO, TRFN, DTPA, IOBJ, etc.
|
|
86
|
+
*
|
|
87
|
+
* Returns all objects that use (reference) the given object.
|
|
88
|
+
* Key use: find the Transformation and DTPs that reference an aDSO.
|
|
89
|
+
*/
|
|
90
|
+
export async function bwXref(client, objectType, objectName, sourceSystem) {
|
|
91
|
+
let resolvedName;
|
|
92
|
+
if (objectType.toUpperCase() === 'RSDS') {
|
|
93
|
+
if (!sourceSystem)
|
|
94
|
+
throw new Error('bw_xref with object_type RSDS requires source_system parameter.');
|
|
95
|
+
resolvedName = objectName.toUpperCase().padEnd(30) + sourceSystem.toUpperCase();
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolvedName = objectName.toUpperCase();
|
|
99
|
+
}
|
|
100
|
+
const path = `/sap/bw/modeling/repo/is/xref` +
|
|
101
|
+
`?objectType=${encodeURIComponent(objectType.toUpperCase())}` +
|
|
102
|
+
`&objectName=${encodeURIComponent(resolvedName)}`;
|
|
103
|
+
const result = await client.get(path, 'application/atom+xml;type=feed');
|
|
104
|
+
const entries = parseAtomEntries(result.body);
|
|
105
|
+
const header = `Where-used (xref): ${objectType.toUpperCase()} ${objectName.toUpperCase()}`;
|
|
106
|
+
return formatEntries(entries, header);
|
|
107
|
+
}
|