@rayutek/abap-adt-api 6.2.1-pkg-1.0.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/.abapgit.xml +27 -0
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/build/AdtClient.d.ts +292 -0
- package/build/AdtClient.d.ts.map +1 -0
- package/build/AdtClient.js +628 -0
- package/build/AdtException.d.ts +62 -0
- package/build/AdtException.d.ts.map +1 -0
- package/build/AdtException.js +185 -0
- package/build/AdtHTTP.d.ts +113 -0
- package/build/AdtHTTP.d.ts.map +1 -0
- package/build/AdtHTTP.js +285 -0
- package/build/api/abapgit.d.ts +86 -0
- package/build/api/abapgit.d.ts.map +1 -0
- package/build/api/abapgit.js +300 -0
- package/build/api/activate.d.ts +39 -0
- package/build/api/activate.d.ts.map +1 -0
- package/build/api/activate.js +105 -0
- package/build/api/atc.d.ts +163 -0
- package/build/api/atc.d.ts.map +1 -0
- package/build/api/atc.js +440 -0
- package/build/api/cds.d.ts +52 -0
- package/build/api/cds.d.ts.map +1 -0
- package/build/api/cds.js +147 -0
- package/build/api/debugger.d.ts +238 -0
- package/build/api/debugger.d.ts.map +1 -0
- package/build/api/debugger.js +299 -0
- package/build/api/delete.d.ts +20 -0
- package/build/api/delete.d.ts.map +1 -0
- package/build/api/delete.js +29 -0
- package/build/api/discovery.d.ts +44 -0
- package/build/api/discovery.d.ts.map +1 -0
- package/build/api/discovery.js +78 -0
- package/build/api/feeds.d.ts +63 -0
- package/build/api/feeds.d.ts.map +1 -0
- package/build/api/feeds.js +65 -0
- package/build/api/index.d.ts +22 -0
- package/build/api/index.d.ts.map +1 -0
- package/build/api/index.js +37 -0
- package/build/api/nodeContents.d.ts +41 -0
- package/build/api/nodeContents.d.ts.map +1 -0
- package/build/api/nodeContents.js +78 -0
- package/build/api/objectcontents.d.ts +21 -0
- package/build/api/objectcontents.d.ts.map +1 -0
- package/build/api/objectcontents.js +68 -0
- package/build/api/objectcreator.d.ts +103 -0
- package/build/api/objectcreator.d.ts.map +1 -0
- package/build/api/objectcreator.js +372 -0
- package/build/api/objectstructure.d.ts +71 -0
- package/build/api/objectstructure.d.ts.map +1 -0
- package/build/api/objectstructure.js +37 -0
- package/build/api/refactor.d.ts +122 -0
- package/build/api/refactor.d.ts.map +1 -0
- package/build/api/refactor.js +470 -0
- package/build/api/revisions.d.ts +12 -0
- package/build/api/revisions.d.ts.map +1 -0
- package/build/api/revisions.js +61 -0
- package/build/api/search.d.ts +25 -0
- package/build/api/search.d.ts.map +1 -0
- package/build/api/search.js +67 -0
- package/build/api/syntax.d.ts +133 -0
- package/build/api/syntax.d.ts.map +1 -0
- package/build/api/syntax.js +327 -0
- package/build/api/tablecontents.d.ts +141 -0
- package/build/api/tablecontents.d.ts.map +1 -0
- package/build/api/tablecontents.js +186 -0
- package/build/api/trace.test.d.ts +2 -0
- package/build/api/trace.test.d.ts.map +1 -0
- package/build/api/trace.test.js +39 -0
- package/build/api/traces.d.ts +13 -0
- package/build/api/traces.d.ts.map +1 -0
- package/build/api/traces.js +97 -0
- package/build/api/tracetypes.d.ts +276 -0
- package/build/api/tracetypes.d.ts.map +1 -0
- package/build/api/tracetypes.js +474 -0
- package/build/api/transports.d.ts +158 -0
- package/build/api/transports.d.ts.map +1 -0
- package/build/api/transports.js +292 -0
- package/build/api/unittest.d.ts +81 -0
- package/build/api/unittest.d.ts.map +1 -0
- package/build/api/unittest.js +164 -0
- package/build/api/urlparser.d.ts +34 -0
- package/build/api/urlparser.d.ts.map +1 -0
- package/build/api/urlparser.js +86 -0
- package/build/index.d.ts +10 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +49 -0
- package/build/requestLogger.d.ts +30 -0
- package/build/requestLogger.d.ts.map +1 -0
- package/build/requestLogger.js +100 -0
- package/build/utilities.d.ts +42 -0
- package/build/utilities.d.ts.map +1 -0
- package/build/utilities.js +221 -0
- package/jest.config.js +32 -0
- package/package.json +45 -0
- package/setenv_sample.js +27 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractMethodExecute = exports.extractMethodPreview = exports.extractMethodEvaluate = exports.renameExecute = exports.renamePreview = exports.changePackageExecute = exports.changePackagePreview = exports.renameEvaluate = exports.fixEdits = exports.fixProposals = void 0;
|
|
4
|
+
const html_entities_1 = require("html-entities");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const AdtException_1 = require("../AdtException");
|
|
7
|
+
const utilities_1 = require("../utilities");
|
|
8
|
+
const urlparser_1 = require("./urlparser");
|
|
9
|
+
async function fixProposals(h, uri, body, line, column) {
|
|
10
|
+
const qs = { uri: `${uri}#start=${line},${column}` };
|
|
11
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
12
|
+
const response = await h.request("/sap/bc/adt/quickfixes/evaluation", {
|
|
13
|
+
method: "POST",
|
|
14
|
+
qs,
|
|
15
|
+
headers,
|
|
16
|
+
body
|
|
17
|
+
});
|
|
18
|
+
const raw = (0, utilities_1.fullParse)(response.body, { processEntities: false });
|
|
19
|
+
const rawResults = (0, utilities_1.xmlArray)(raw, "qf:evaluationResults", "evaluationResult");
|
|
20
|
+
return rawResults.map(x => {
|
|
21
|
+
const attrs = (0, utilities_1.xmlNodeAttr)((0, utilities_1.xmlNode)(x, "adtcore:objectReference"));
|
|
22
|
+
const userContent = (0, html_entities_1.decode)((0, utilities_1.xmlNode)(x, "userContent") || "");
|
|
23
|
+
return {
|
|
24
|
+
...attrs,
|
|
25
|
+
"adtcore:name": attrs["adtcore:name"],
|
|
26
|
+
"adtcore:description": attrs["adtcore:description"],
|
|
27
|
+
uri,
|
|
28
|
+
line,
|
|
29
|
+
column,
|
|
30
|
+
userContent
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.fixProposals = fixProposals;
|
|
35
|
+
async function fixEdits(h, proposal, source) {
|
|
36
|
+
if (!proposal["adtcore:uri"].match(/\/sap\/bc\/adt\/quickfixes/))
|
|
37
|
+
throw (0, AdtException_1.adtException)("Invalid fix proposal");
|
|
38
|
+
const body = `<?xml version="1.0" encoding="UTF-8"?>
|
|
39
|
+
<quickfixes:proposalRequest xmlns:quickfixes="http://www.sap.com/adt/quickfixes"
|
|
40
|
+
xmlns:adtcore="http://www.sap.com/adt/core">
|
|
41
|
+
<input>
|
|
42
|
+
<content>${(0, utilities_1.encodeEntity)(source)}</content>
|
|
43
|
+
<adtcore:objectReference adtcore:uri="${proposal.uri}#start=${proposal.line},${proposal.column}"/>
|
|
44
|
+
</input>
|
|
45
|
+
<userContent>${(0, utilities_1.encodeEntity)(proposal.userContent)}</userContent>
|
|
46
|
+
</quickfixes:proposalRequest>`;
|
|
47
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
48
|
+
const response = await h.request(proposal["adtcore:uri"], {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers,
|
|
51
|
+
body
|
|
52
|
+
});
|
|
53
|
+
const raw = (0, utilities_1.fullParse)(response.body);
|
|
54
|
+
const parseDelta = (d) => {
|
|
55
|
+
const attr = (0, utilities_1.xmlNodeAttr)((0, utilities_1.xmlNode)(d, "adtcore:objectReference"));
|
|
56
|
+
const content = d.content;
|
|
57
|
+
const { uri, range } = (0, urlparser_1.parseUri)(attr["adtcore:uri"]);
|
|
58
|
+
return {
|
|
59
|
+
uri,
|
|
60
|
+
range,
|
|
61
|
+
name: attr["adtcore:name"],
|
|
62
|
+
type: attr["adtcore:type"],
|
|
63
|
+
content
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const deltas = (0, utilities_1.xmlArray)(raw, "qf:proposalResult", "deltas", "unit").map(parseDelta);
|
|
67
|
+
return deltas;
|
|
68
|
+
}
|
|
69
|
+
exports.fixEdits = fixEdits;
|
|
70
|
+
const parsePackageGeneric = (generic) => {
|
|
71
|
+
// Read the single affectedObject node directly (not as an array)
|
|
72
|
+
const o = (0, utilities_1.xmlNode)(generic, "affectedObjects", "affectedObject");
|
|
73
|
+
if (!o)
|
|
74
|
+
throw new Error("No affectedObject found in generic.affectedObjects");
|
|
75
|
+
const { uri, type, name, parentUri, packageName } = (0, utilities_1.xmlNodeAttr)(o);
|
|
76
|
+
const newPackage = (0, utilities_1.xmlNode)((0, utilities_1.xmlNode)(o, "changePackageDelta"), "newPackage");
|
|
77
|
+
const affectedObjects = {
|
|
78
|
+
uri,
|
|
79
|
+
type,
|
|
80
|
+
name,
|
|
81
|
+
oldPackage: packageName,
|
|
82
|
+
newPackage,
|
|
83
|
+
parentUri,
|
|
84
|
+
userContent: o.userContent
|
|
85
|
+
};
|
|
86
|
+
const { ignoreSyntaxErrorsAllowed, ignoreSyntaxErrors, transport, userContent = "", adtObjectUri = "", title } = generic;
|
|
87
|
+
return {
|
|
88
|
+
title,
|
|
89
|
+
oldPackage: packageName,
|
|
90
|
+
newPackage,
|
|
91
|
+
ignoreSyntaxErrorsAllowed,
|
|
92
|
+
ignoreSyntaxErrors,
|
|
93
|
+
transport,
|
|
94
|
+
adtObjectUri: adtObjectUri,
|
|
95
|
+
userContent: (0, html_entities_1.decode)(userContent),
|
|
96
|
+
affectedObjects: affectedObjects // only one affected object for change package
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const parseGeneric = (generic) => {
|
|
100
|
+
const affectedObjects = (0, utilities_1.xmlArray)(generic, "affectedObjects", "affectedObject").map(o => {
|
|
101
|
+
const { uri, type, name, parentUri } = (0, utilities_1.xmlNodeAttr)(o);
|
|
102
|
+
const textReplaceDeltas = (0, utilities_1.xmlArray)(o, "textReplaceDeltas", "textReplaceDelta").map(z => {
|
|
103
|
+
return {
|
|
104
|
+
rangeFragment: (0, urlparser_1.parseUri)((0, utilities_1.xmlNode)(z, "rangeFragment")).range,
|
|
105
|
+
contentOld: (0, utilities_1.xmlNode)(z, "contentOld"),
|
|
106
|
+
contentNew: (0, utilities_1.xmlNode)(z, "contentNew")
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
uri,
|
|
111
|
+
type,
|
|
112
|
+
name,
|
|
113
|
+
parentUri,
|
|
114
|
+
userContent: o.userContent,
|
|
115
|
+
textReplaceDeltas
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
const { ignoreSyntaxErrorsAllowed, ignoreSyntaxErrors, transport, userContent = "", adtObjectUri = "", title } = generic;
|
|
119
|
+
return {
|
|
120
|
+
title,
|
|
121
|
+
ignoreSyntaxErrorsAllowed,
|
|
122
|
+
ignoreSyntaxErrors,
|
|
123
|
+
transport,
|
|
124
|
+
adtObjectUri: (0, urlparser_1.parseUri)(adtObjectUri),
|
|
125
|
+
userContent: (0, html_entities_1.decode)(userContent),
|
|
126
|
+
affectedObjects
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
function parseChangePackageRefactoring(body) {
|
|
130
|
+
const raw = (0, utilities_1.fullParse)(body, { removeNSPrefix: true });
|
|
131
|
+
const root = (0, utilities_1.xmlNode)(raw, "changePackageRefactoring");
|
|
132
|
+
const { ignoreSyntaxErrorsAllowed, ignoreSyntaxErrors, transport, adtObjectUri, affectedObjects, userContent } = parsePackageGeneric((0, utilities_1.xmlNode)(root || raw, "genericRefactoring")); // depending on the caller the generic refactoring might be wrapped or not
|
|
133
|
+
return {
|
|
134
|
+
oldPackage: (0, utilities_1.xmlNode)(root, "oldPackage") || "",
|
|
135
|
+
newPackage: (0, utilities_1.xmlNode)(root, "newPackage") || "",
|
|
136
|
+
adtObjectUri: adtObjectUri,
|
|
137
|
+
ignoreSyntaxErrorsAllowed: !!ignoreSyntaxErrorsAllowed,
|
|
138
|
+
ignoreSyntaxErrors: !!ignoreSyntaxErrors,
|
|
139
|
+
transport: transport || "",
|
|
140
|
+
affectedObjects,
|
|
141
|
+
userContent: userContent
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function parseRenameRefactoring(body) {
|
|
145
|
+
const raw = (0, utilities_1.fullParse)(body, { removeNSPrefix: true });
|
|
146
|
+
const root = (0, utilities_1.xmlNode)(raw, "renameRefactoring");
|
|
147
|
+
const { ignoreSyntaxErrorsAllowed, ignoreSyntaxErrors, transport, adtObjectUri, affectedObjects, userContent } = parseGeneric((0, utilities_1.xmlNode)(root || raw, "genericRefactoring")); // depending on the caller the generic refactoring might be wrapped or not
|
|
148
|
+
return {
|
|
149
|
+
oldName: (0, utilities_1.xmlNode)(root, "oldName") || "",
|
|
150
|
+
newName: (0, utilities_1.xmlNode)(root, "newName") || "",
|
|
151
|
+
adtObjectUri,
|
|
152
|
+
ignoreSyntaxErrorsAllowed: !!ignoreSyntaxErrorsAllowed,
|
|
153
|
+
ignoreSyntaxErrors: !!ignoreSyntaxErrors,
|
|
154
|
+
transport,
|
|
155
|
+
affectedObjects,
|
|
156
|
+
userContent: userContent
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async function renameEvaluate(h, uri, line, startColumn, endColumn) {
|
|
160
|
+
const qs = {
|
|
161
|
+
step: `evaluate`,
|
|
162
|
+
rel: `http://www.sap.com/adt/relations/refactoring/rename`,
|
|
163
|
+
uri: `${uri}#start=${line},${startColumn};end=${line},${endColumn}`
|
|
164
|
+
};
|
|
165
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
166
|
+
const response = await h.request("/sap/bc/adt/refactorings", {
|
|
167
|
+
method: "POST",
|
|
168
|
+
qs: qs,
|
|
169
|
+
headers: headers
|
|
170
|
+
});
|
|
171
|
+
return parseRenameRefactoring(response.body);
|
|
172
|
+
}
|
|
173
|
+
exports.renameEvaluate = renameEvaluate;
|
|
174
|
+
const serializeAffectedObject = (o) => {
|
|
175
|
+
const pu = o.parentUri ? `adtcore:parentUri="${o.parentUri}"` : "";
|
|
176
|
+
return `<generic:affectedObject adtcore:name="${o.name}" ${pu} adtcore:type="${o.type}" adtcore:uri="${o.uri}">
|
|
177
|
+
<generic:textReplaceDeltas>
|
|
178
|
+
${o.textReplaceDeltas
|
|
179
|
+
.map(y => {
|
|
180
|
+
return `<generic:textReplaceDelta>
|
|
181
|
+
<generic:rangeFragment>${(0, _1.rangeToString)(y.rangeFragment)}</generic:rangeFragment>
|
|
182
|
+
<generic:contentOld>${(0, utilities_1.encodeEntity)(y.contentOld)}</generic:contentOld>
|
|
183
|
+
<generic:contentNew>${(0, utilities_1.encodeEntity)(y.contentNew)}</generic:contentNew>
|
|
184
|
+
</generic:textReplaceDelta>`;
|
|
185
|
+
})
|
|
186
|
+
.join("")}
|
|
187
|
+
</generic:textReplaceDeltas>
|
|
188
|
+
<generic:userContent>${o.userContent}</generic:userContent>
|
|
189
|
+
</generic:affectedObject>`;
|
|
190
|
+
};
|
|
191
|
+
const serializeGenericRefactoring = (g) => {
|
|
192
|
+
return `<?xml version="1.0" encoding="utf-8"?>
|
|
193
|
+
<generic:genericRefactoring xmlns:adtcore="http://www.sap.com/adt/core" xmlns:generic="http://www.sap.com/adt/refactoring/genericrefactoring">
|
|
194
|
+
<generic:title>${g.title}</generic:title>
|
|
195
|
+
<generic:adtObjectUri>${(0, urlparser_1.uriPartsToString)(g.adtObjectUri)}</generic:adtObjectUri>
|
|
196
|
+
<generic:affectedObjects>
|
|
197
|
+
${g.affectedObjects.map(serializeAffectedObject).join("\n")}
|
|
198
|
+
</generic:affectedObjects>
|
|
199
|
+
<generic:transport>${g.transport}</generic:transport>
|
|
200
|
+
<generic:ignoreSyntaxErrorsAllowed>${g.ignoreSyntaxErrorsAllowed}</generic:ignoreSyntaxErrorsAllowed>
|
|
201
|
+
<generic:ignoreSyntaxErrors>${g.ignoreSyntaxErrors}</generic:ignoreSyntaxErrors>
|
|
202
|
+
<generic:userContent/>
|
|
203
|
+
</generic:genericRefactoring>`;
|
|
204
|
+
};
|
|
205
|
+
const addPackageAffectedObject = (o) => {
|
|
206
|
+
return `<generic:affectedObject adtcore:description="Program" adtcore:name="${o.name}" adtcore:packageName="${o.oldPackage}" adtcore:type="${o.type}" adtcore:uri="${o.uri}">
|
|
207
|
+
<generic:userContent></generic:userContent>
|
|
208
|
+
<generic:changePackageDelta>
|
|
209
|
+
<generic:newPackage>${o.newPackage}</generic:newPackage>
|
|
210
|
+
</generic:changePackageDelta>
|
|
211
|
+
</generic:affectedObject>`;
|
|
212
|
+
};
|
|
213
|
+
const serializeChangePackageRefactoring = (changePackageRefactoring, wrapped, transport = "") => {
|
|
214
|
+
const start = wrapped
|
|
215
|
+
? `<changepackage:changePackageRefactoring xmlns:adtcore="http://www.sap.com/adt/core" xmlns:generic="http://www.sap.com/adt/refactoring/genericrefactoring"
|
|
216
|
+
xmlns:changepackage="http://www.sap.com/adt/refactoring/changepackagerefactoring">
|
|
217
|
+
<changepackage:oldPackage>${changePackageRefactoring.oldPackage}</changepackage:oldPackage>
|
|
218
|
+
<changepackage:newPackage>${changePackageRefactoring.newPackage}</changepackage:newPackage>`
|
|
219
|
+
: "";
|
|
220
|
+
const end = wrapped ? `<changepackage:userContent></changepackage:userContent> </changepackage:changePackageRefactoring>` : "";
|
|
221
|
+
const genns = wrapped
|
|
222
|
+
? ""
|
|
223
|
+
: ` xmlns:generic="http://www.sap.com/adt/refactoring/genericrefactoring" xmlns:adtcore="http://www.sap.com/adt/core"`;
|
|
224
|
+
const bodyXml = `<?xml version="1.0" encoding="ASCII"?>
|
|
225
|
+
${start}
|
|
226
|
+
<generic:genericRefactoring ${genns}>
|
|
227
|
+
<generic:title>Change Package</generic:title>
|
|
228
|
+
<generic:adtObjectUri>${changePackageRefactoring.adtObjectUri}</generic:adtObjectUri>
|
|
229
|
+
<generic:affectedObjects>
|
|
230
|
+
${addPackageAffectedObject(changePackageRefactoring.affectedObjects)}
|
|
231
|
+
</generic:affectedObjects>
|
|
232
|
+
<generic:transport>${changePackageRefactoring.transport || transport}</generic:transport>
|
|
233
|
+
<generic:ignoreSyntaxErrorsAllowed>${changePackageRefactoring.ignoreSyntaxErrorsAllowed}</generic:ignoreSyntaxErrorsAllowed>
|
|
234
|
+
<generic:ignoreSyntaxErrors>${changePackageRefactoring.ignoreSyntaxErrors}</generic:ignoreSyntaxErrors>
|
|
235
|
+
<generic:userContent/>
|
|
236
|
+
</generic:genericRefactoring>
|
|
237
|
+
${end}`;
|
|
238
|
+
return bodyXml;
|
|
239
|
+
};
|
|
240
|
+
const srializeRefactoring = (renameRefactoring, wrapped, transport = "") => {
|
|
241
|
+
const start = wrapped
|
|
242
|
+
? `<rename:renameRefactoring xmlns:adtcore="http://www.sap.com/adt/core" xmlns:generic="http://www.sap.com/adt/refactoring/genericrefactoring"
|
|
243
|
+
xmlns:rename="http://www.sap.com/adt/refactoring/renamerefactoring">
|
|
244
|
+
<rename:oldName>${renameRefactoring.oldName}</rename:oldName>
|
|
245
|
+
<rename:newName>${renameRefactoring.newName}</rename:newName>`
|
|
246
|
+
: "";
|
|
247
|
+
const end = wrapped ? `<rename:userContent/></rename:renameRefactoring>` : "";
|
|
248
|
+
const genns = wrapped
|
|
249
|
+
? ""
|
|
250
|
+
: ` xmlns:generic="http://www.sap.com/adt/refactoring/genericrefactoring" xmlns:adtcore="http://www.sap.com/adt/core"`;
|
|
251
|
+
const addAffectedObjects = (affectedObject) => affectedObject.map(serializeAffectedObject);
|
|
252
|
+
const bodyXml = `<?xml version="1.0" encoding="ASCII"?>
|
|
253
|
+
${start}
|
|
254
|
+
<generic:genericRefactoring ${genns}>
|
|
255
|
+
<generic:title>Rename Field</generic:title>
|
|
256
|
+
<generic:adtObjectUri>${renameRefactoring.adtObjectUri.uri}${(0, _1.rangeToString)(renameRefactoring.adtObjectUri.range)}</generic:adtObjectUri>
|
|
257
|
+
<generic:affectedObjects>
|
|
258
|
+
${addAffectedObjects(renameRefactoring.affectedObjects).join("")}
|
|
259
|
+
</generic:affectedObjects>
|
|
260
|
+
<generic:transport>${renameRefactoring.transport || transport}</generic:transport>
|
|
261
|
+
<generic:ignoreSyntaxErrorsAllowed>${renameRefactoring.ignoreSyntaxErrorsAllowed}</generic:ignoreSyntaxErrorsAllowed>
|
|
262
|
+
<generic:ignoreSyntaxErrors>${renameRefactoring.ignoreSyntaxErrors}</generic:ignoreSyntaxErrors>
|
|
263
|
+
<generic:userContent/>
|
|
264
|
+
</generic:genericRefactoring>
|
|
265
|
+
${end}`;
|
|
266
|
+
return bodyXml;
|
|
267
|
+
};
|
|
268
|
+
const extractMethodBody = (proposal) => {
|
|
269
|
+
const parameters = proposal.parameters
|
|
270
|
+
.map(p => `<extractmethod:parameter>
|
|
271
|
+
<extractmethod:id>${(0, utilities_1.encodeEntity)(p.id)}</extractmethod:id>
|
|
272
|
+
<extractmethod:name>${p.name}</extractmethod:name>
|
|
273
|
+
<extractmethod:direction>${p.direction}</extractmethod:direction>
|
|
274
|
+
<extractmethod:byValue>${p.byValue}</extractmethod:byValue>
|
|
275
|
+
<extractmethod:typeType>${p.typeType}</extractmethod:typeType>
|
|
276
|
+
<extractmethod:type>${p.type}</extractmethod:type>
|
|
277
|
+
<extractmethod:userContent>${(0, utilities_1.encodeEntity)(p.userContent)}</extractmethod:userContent>
|
|
278
|
+
</extractmethod:parameter>`)
|
|
279
|
+
.join("\n");
|
|
280
|
+
const exceptions = proposal.exceptions
|
|
281
|
+
.map(e => `<extractmethod:exception>
|
|
282
|
+
<extractmethod:name>${e.name}</extractmethod:name>
|
|
283
|
+
<extractmethod:resumable>${e.resumable}</extractmethod:resumable>
|
|
284
|
+
<extractmethod:userContent>${e.userContent}</extractmethod:userContent>
|
|
285
|
+
</extractmethod:exception>`)
|
|
286
|
+
.join("\n");
|
|
287
|
+
const exc = exceptions.length
|
|
288
|
+
? `<extractmethod:exceptions>${exceptions}</extractmethod:exceptions> `
|
|
289
|
+
: `<extractmethod:exceptions/>`;
|
|
290
|
+
const gr = proposal.genericRefactoring;
|
|
291
|
+
const affected = gr.affectedObjects
|
|
292
|
+
.map(o => {
|
|
293
|
+
const deltas = o.textReplaceDeltas.length === 0
|
|
294
|
+
? undefined
|
|
295
|
+
: o.textReplaceDeltas
|
|
296
|
+
.map(d => `<generic:textReplaceDelta> <generic:rangeFragment>${d.rangeFragment}</generic:rangeFragment> <generic:contentOld>${(0, utilities_1.encodeEntity)(d.contentOld)}</generic:contentOld> <generic:contentNew>${(0, utilities_1.encodeEntity)(d.contentNew)}</generic:contentNew> </generic:textReplaceDelta>`)
|
|
297
|
+
.join("\n");
|
|
298
|
+
const delta = deltas
|
|
299
|
+
? `<generic:textReplaceDeltas>${deltas}</generic:textReplaceDeltas>`
|
|
300
|
+
: ``;
|
|
301
|
+
return `<generic:affectedObject adtcore:name="${o.name}" adtcore:parentUri="${o.parentUri}" adtcore:type="${o.type}" adtcore:uri="${o.uri}">
|
|
302
|
+
<generic:userContent>${o.userContent}</generic:userContent>
|
|
303
|
+
${delta}
|
|
304
|
+
</generic:affectedObject>`;
|
|
305
|
+
})
|
|
306
|
+
.join("\n");
|
|
307
|
+
return `<?xml version="1.0" encoding="ASCII"?>
|
|
308
|
+
<extractmethod:extractMethodRefactoring xmlns:adtcore="http://www.sap.com/adt/core" xmlns:extractmethod="http://www.sap.com/adt/refactoring/extractmethodrefactoring" xmlns:generic="http://www.sap.com/adt/refactoring/genericrefactoring">
|
|
309
|
+
<extractmethod:name>${proposal.name}</extractmethod:name>
|
|
310
|
+
<extractmethod:isStatic>${proposal.isStatic}</extractmethod:isStatic>
|
|
311
|
+
<extractmethod:visibility>${proposal.visibility}</extractmethod:visibility>
|
|
312
|
+
<extractmethod:classBasedExceptions>${proposal.classBasedExceptions}</extractmethod:classBasedExceptions>
|
|
313
|
+
<extractmethod:parameters>
|
|
314
|
+
${parameters}
|
|
315
|
+
</extractmethod:parameters>
|
|
316
|
+
${exc}
|
|
317
|
+
<extractmethod:content>${(0, utilities_1.encodeEntity)(proposal.content)}</extractmethod:content>
|
|
318
|
+
<generic:genericRefactoring>
|
|
319
|
+
<generic:title>${gr.title}</generic:title>
|
|
320
|
+
<generic:adtObjectUri>${(0, urlparser_1.uriPartsToString)(gr.adtObjectUri)}</generic:adtObjectUri>
|
|
321
|
+
<generic:affectedObjects>
|
|
322
|
+
${affected}
|
|
323
|
+
</generic:affectedObjects>
|
|
324
|
+
<generic:transport>${gr.transport}</generic:transport>
|
|
325
|
+
<generic:ignoreSyntaxErrorsAllowed>${gr.ignoreSyntaxErrorsAllowed}</generic:ignoreSyntaxErrorsAllowed>
|
|
326
|
+
<generic:ignoreSyntaxErrors>${gr.ignoreSyntaxErrors}</generic:ignoreSyntaxErrors>
|
|
327
|
+
<generic:userContent>${gr.userContent}</generic:userContent>
|
|
328
|
+
</generic:genericRefactoring>
|
|
329
|
+
<extractmethod:className>ZAPIADT_TESTCASE_CLASS1${proposal}</extractmethod:className>
|
|
330
|
+
<extractmethod:isEventAllowed>${proposal.isEventAllowed}</extractmethod:isEventAllowed>
|
|
331
|
+
<extractmethod:isEvent>${proposal.isEvent}</extractmethod:isEvent>
|
|
332
|
+
<extractmethod:userContent>${(0, utilities_1.encodeEntity)(proposal.userContent)}</extractmethod:userContent>
|
|
333
|
+
<extractmethod:isForTesting>${proposal.isForTesting}</extractmethod:isForTesting>
|
|
334
|
+
</extractmethod:extractMethodRefactoring>`;
|
|
335
|
+
};
|
|
336
|
+
const parseExtractMethodEval = (body) => {
|
|
337
|
+
const root = (0, utilities_1.fullParse)(body, {
|
|
338
|
+
removeNSPrefix: true
|
|
339
|
+
}).extractMethodRefactoring;
|
|
340
|
+
const parameters = (0, utilities_1.xmlArray)(root, "parameters", "parameter");
|
|
341
|
+
const exceptions = (0, utilities_1.xmlArray)(root, "exceptions", "exception");
|
|
342
|
+
const { name, isStatic, visibility, classBasedExceptions, content, className, isEventAllowed, isEvent, userContent } = root;
|
|
343
|
+
const genericRefactoring = parseGeneric(root.genericRefactoring);
|
|
344
|
+
const resp = {
|
|
345
|
+
name,
|
|
346
|
+
isStatic,
|
|
347
|
+
visibility,
|
|
348
|
+
classBasedExceptions,
|
|
349
|
+
genericRefactoring,
|
|
350
|
+
content,
|
|
351
|
+
className,
|
|
352
|
+
isForTesting: false,
|
|
353
|
+
isEventAllowed,
|
|
354
|
+
isEvent,
|
|
355
|
+
userContent: (0, html_entities_1.decode)(userContent),
|
|
356
|
+
parameters,
|
|
357
|
+
exceptions
|
|
358
|
+
};
|
|
359
|
+
return resp;
|
|
360
|
+
};
|
|
361
|
+
async function changePackagePreview(h, changePackageRefactoring, transport) {
|
|
362
|
+
console.log("changePackageRefactoring here", changePackageRefactoring);
|
|
363
|
+
const qs = {
|
|
364
|
+
step: `preview`,
|
|
365
|
+
rel: `http://www.sap.com/adt/relations/refactoring/changepackage`
|
|
366
|
+
};
|
|
367
|
+
const bodyXml = serializeChangePackageRefactoring(changePackageRefactoring, true, transport);
|
|
368
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
369
|
+
console.log(" changePackagePreview bodyXml", bodyXml);
|
|
370
|
+
const response = await h.request("/sap/bc/adt/refactorings", {
|
|
371
|
+
method: "POST",
|
|
372
|
+
qs: qs,
|
|
373
|
+
body: bodyXml,
|
|
374
|
+
headers: headers
|
|
375
|
+
});
|
|
376
|
+
console.log(" changePackagePreview response.body", response.body);
|
|
377
|
+
const parsed = parseChangePackageRefactoring(response.body);
|
|
378
|
+
return { ...parsed, transport: parsed.transport || transport };
|
|
379
|
+
}
|
|
380
|
+
exports.changePackagePreview = changePackagePreview;
|
|
381
|
+
async function changePackageExecute(h, packagename) {
|
|
382
|
+
const qs = {
|
|
383
|
+
step: `execute`
|
|
384
|
+
};
|
|
385
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
386
|
+
const body = serializeChangePackageRefactoring(packagename, false);
|
|
387
|
+
console.log(" changePackageExecute body", body);
|
|
388
|
+
const response = await h.request("/sap/bc/adt/refactorings", {
|
|
389
|
+
method: "POST",
|
|
390
|
+
qs: qs,
|
|
391
|
+
body,
|
|
392
|
+
headers: headers
|
|
393
|
+
});
|
|
394
|
+
console.log(" changePackageExecute response.body", response.body);
|
|
395
|
+
const result = parseChangePackageRefactoring(response.body);
|
|
396
|
+
return { ...result, transport: result.transport || packagename.transport };
|
|
397
|
+
}
|
|
398
|
+
exports.changePackageExecute = changePackageExecute;
|
|
399
|
+
async function renamePreview(h, renameRefactoring, transport) {
|
|
400
|
+
const qs = {
|
|
401
|
+
step: `preview`,
|
|
402
|
+
rel: `http://www.sap.com/adt/relations/refactoring/rename`
|
|
403
|
+
};
|
|
404
|
+
const bodyXml = srializeRefactoring(renameRefactoring, true, transport);
|
|
405
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
406
|
+
const response = await h.request("/sap/bc/adt/refactorings", {
|
|
407
|
+
method: "POST",
|
|
408
|
+
qs: qs,
|
|
409
|
+
body: bodyXml,
|
|
410
|
+
headers: headers
|
|
411
|
+
});
|
|
412
|
+
const parsed = parseRenameRefactoring(response.body);
|
|
413
|
+
return { ...parsed, transport: parsed.transport || transport };
|
|
414
|
+
}
|
|
415
|
+
exports.renamePreview = renamePreview;
|
|
416
|
+
async function renameExecute(h, rename) {
|
|
417
|
+
const qs = {
|
|
418
|
+
step: `execute`
|
|
419
|
+
};
|
|
420
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
421
|
+
const body = srializeRefactoring(rename, false);
|
|
422
|
+
const response = await h.request("/sap/bc/adt/refactorings", {
|
|
423
|
+
method: "POST",
|
|
424
|
+
qs: qs,
|
|
425
|
+
body,
|
|
426
|
+
headers: headers
|
|
427
|
+
});
|
|
428
|
+
const result = parseRenameRefactoring(response.body);
|
|
429
|
+
return { ...result, transport: result.transport || rename.transport };
|
|
430
|
+
}
|
|
431
|
+
exports.renameExecute = renameExecute;
|
|
432
|
+
async function extractMethodEvaluate(h, uri, range) {
|
|
433
|
+
const qs = {
|
|
434
|
+
step: `evaluate`,
|
|
435
|
+
rel: `http://www.sap.com/adt/relations/refactoring/extractmethod`,
|
|
436
|
+
uri: `${uri}#start=${range.start.line},${range.start.column};end=${range.end.line},${range.end.column}`
|
|
437
|
+
};
|
|
438
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
439
|
+
const opts = { method: "POST", qs, headers };
|
|
440
|
+
const response = await h.request("/sap/bc/adt/refactorings", opts);
|
|
441
|
+
return parseExtractMethodEval(response.body);
|
|
442
|
+
}
|
|
443
|
+
exports.extractMethodEvaluate = extractMethodEvaluate;
|
|
444
|
+
async function extractMethodPreview(h, proposal) {
|
|
445
|
+
const body = extractMethodBody(proposal);
|
|
446
|
+
const qs = {
|
|
447
|
+
step: `preview`,
|
|
448
|
+
rel: `http://www.sap.com/adt/relations/refactoring/extractmethod`
|
|
449
|
+
};
|
|
450
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
451
|
+
const opts = { method: "POST", qs, headers, body };
|
|
452
|
+
const response = await h.request("/sap/bc/adt/refactorings", opts);
|
|
453
|
+
const raw = (0, utilities_1.fullParse)(response.body, {
|
|
454
|
+
removeNSPrefix: true
|
|
455
|
+
}).genericRefactoring;
|
|
456
|
+
return parseGeneric(raw);
|
|
457
|
+
}
|
|
458
|
+
exports.extractMethodPreview = extractMethodPreview;
|
|
459
|
+
async function extractMethodExecute(h, refactoring) {
|
|
460
|
+
const body = serializeGenericRefactoring(refactoring);
|
|
461
|
+
const qs = { step: `execute` };
|
|
462
|
+
const headers = { "Content-Type": "application/*", Accept: "application/*" };
|
|
463
|
+
const opts = { method: "POST", qs, headers, body };
|
|
464
|
+
const response = await h.request("/sap/bc/adt/refactorings", opts);
|
|
465
|
+
const raw = (0, utilities_1.fullParse)(response.body, {
|
|
466
|
+
removeNSPrefix: true
|
|
467
|
+
}).genericRefactoring;
|
|
468
|
+
return parseGeneric(raw);
|
|
469
|
+
}
|
|
470
|
+
exports.extractMethodExecute = extractMethodExecute;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdtHTTP } from "../AdtHTTP";
|
|
2
|
+
import { AbapObjectStructure, classIncludes } from "./objectstructure";
|
|
3
|
+
export interface Revision {
|
|
4
|
+
uri: string;
|
|
5
|
+
date: string;
|
|
6
|
+
author: string;
|
|
7
|
+
version: string;
|
|
8
|
+
versionTitle: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getRevisionLink(struct: AbapObjectStructure, includeName?: classIncludes): string;
|
|
11
|
+
export declare function revisions(h: AdtHTTP, objectUrl: string | AbapObjectStructure, includeName?: classIncludes): Promise<Revision[]>;
|
|
12
|
+
//# sourceMappingURL=revisions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revisions.d.ts","sourceRoot":"","sources":["../../src/api/revisions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AASpC,OAAO,EACL,mBAAmB,EACnB,aAAa,EAId,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;CACrB;AAMD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,mBAAmB,EAC3B,WAAW,CAAC,EAAE,aAAa,UAY5B;AAUD,wBAAsB,SAAS,CAC7B,CAAC,EAAE,OAAO,EACV,SAAS,EAAE,MAAM,GAAG,mBAAmB,EACvC,WAAW,CAAC,EAAE,aAAa,uBAgC5B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revisions = exports.getRevisionLink = void 0;
|
|
4
|
+
const AdtException_1 = require("../AdtException");
|
|
5
|
+
const utilities_1 = require("../utilities");
|
|
6
|
+
const objectstructure_1 = require("./objectstructure");
|
|
7
|
+
function extractRevisionLink(links) {
|
|
8
|
+
return links.find(l => l.rel === "http://www.sap.com/adt/relations/versions");
|
|
9
|
+
}
|
|
10
|
+
function getRevisionLink(struct, includeName) {
|
|
11
|
+
let link;
|
|
12
|
+
if ((0, objectstructure_1.isClassStructure)(struct)) {
|
|
13
|
+
const iname = includeName || "main";
|
|
14
|
+
const include = struct.includes.find(i => i["class:includeType"] === iname);
|
|
15
|
+
if (include)
|
|
16
|
+
link = extractRevisionLink(include.links);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
link = extractRevisionLink(struct.links);
|
|
20
|
+
}
|
|
21
|
+
if (link)
|
|
22
|
+
return (0, utilities_1.followUrl)(struct.objectUrl, link.href);
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
exports.getRevisionLink = getRevisionLink;
|
|
26
|
+
const extractVersion = (entry) => {
|
|
27
|
+
const ADTTYPE = "application/vnd.sap.adt.transportrequests.v1+xml";
|
|
28
|
+
const base = (0, utilities_1.xmlNode)(entry, "atom:link");
|
|
29
|
+
if (Array.isArray(base)) {
|
|
30
|
+
const vlink = base.find(l => l["@_type"] === ADTTYPE) || base[0];
|
|
31
|
+
return (0, utilities_1.xmlNode)(vlink, "@_adtcore:name") || "";
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
return (0, utilities_1.xmlNode)(base, "@_adtcore:name") || "";
|
|
35
|
+
};
|
|
36
|
+
async function revisions(h, objectUrl, includeName) {
|
|
37
|
+
const str = (0, utilities_1.isString)(objectUrl)
|
|
38
|
+
? await (0, objectstructure_1.objectStructure)(h, objectUrl)
|
|
39
|
+
: objectUrl;
|
|
40
|
+
const name = str.metaData["adtcore:name"];
|
|
41
|
+
const revisionUrl = getRevisionLink(str, includeName);
|
|
42
|
+
if (!revisionUrl)
|
|
43
|
+
throw (0, AdtException_1.adtException)(`Revision URL not found for object ${name}`);
|
|
44
|
+
const headers = { Accept: "application/atom+xml;type=feed" };
|
|
45
|
+
const response = await h.request(revisionUrl, {
|
|
46
|
+
method: "GET",
|
|
47
|
+
headers
|
|
48
|
+
});
|
|
49
|
+
const raw = (0, utilities_1.fullParse)(response.body);
|
|
50
|
+
const versions = (0, utilities_1.xmlArray)(raw, "atom:feed", "atom:entry").map((entry) => {
|
|
51
|
+
const uri = (0, utilities_1.xmlNode)(entry, "atom:content", "@_src") || "";
|
|
52
|
+
const version = extractVersion(entry);
|
|
53
|
+
const versionTitle = (0, utilities_1.xmlNode)(entry, "atom:title") || "";
|
|
54
|
+
const date = (0, utilities_1.xmlNode)(entry, "atom:updated") || "";
|
|
55
|
+
const author = (0, utilities_1.xmlNode)(entry, "atom:author", "atom:name");
|
|
56
|
+
const r = { uri, version, versionTitle, date, author };
|
|
57
|
+
return r;
|
|
58
|
+
});
|
|
59
|
+
return versions;
|
|
60
|
+
}
|
|
61
|
+
exports.revisions = revisions;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdtHTTP } from "../AdtHTTP";
|
|
2
|
+
export interface SearchResult {
|
|
3
|
+
"adtcore:description"?: string;
|
|
4
|
+
"adtcore:name": string;
|
|
5
|
+
"adtcore:packageName"?: string;
|
|
6
|
+
"adtcore:type": string;
|
|
7
|
+
"adtcore:uri": string;
|
|
8
|
+
}
|
|
9
|
+
export interface PathStep {
|
|
10
|
+
"adtcore:name": string;
|
|
11
|
+
"adtcore:type": string;
|
|
12
|
+
"adtcore:uri": string;
|
|
13
|
+
"projectexplorer:category": string;
|
|
14
|
+
}
|
|
15
|
+
export type PackageValueHelpType = "applicationcomponents" | "softwarecomponents" | "transportlayers" | "translationrelevances";
|
|
16
|
+
export interface PackageValueHelpResult {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
data: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function searchObject(h: AdtHTTP, query: string, objType?: string, maxResults?: number): Promise<SearchResult[]>;
|
|
22
|
+
export declare function findObjectPath(h: AdtHTTP, objectUrl: string): Promise<PathStep[]>;
|
|
23
|
+
export declare function abapDocumentation(h: AdtHTTP, objectUri: string, body: string, line: number, column: number, language?: string): Promise<string>;
|
|
24
|
+
export declare function packageSearchHelp(h: AdtHTTP, type: PackageValueHelpType, name?: string): Promise<PackageValueHelpResult[]>;
|
|
25
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/api/search.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,MAAM,WAAW,YAAY;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,0BAA0B,EAAE,MAAM,CAAA;CACnC;AAED,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GACvB,oBAAoB,GACpB,iBAAiB,GACjB,uBAAuB,CAAA;AAE3B,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb;AACD,wBAAsB,YAAY,CAChC,CAAC,EAAE,OAAO,EACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,GAAE,MAAY,2BAuBzB;AAED,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAcjE;AAED,wBAAsB,iBAAiB,CACrC,CAAC,EAAE,OAAO,EACV,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,SAAO,mBAgBhB;AAED,wBAAsB,iBAAiB,CACrC,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,oBAAoB,EAC1B,IAAI,SAAM,qCAgBX"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageSearchHelp = exports.abapDocumentation = exports.findObjectPath = exports.searchObject = void 0;
|
|
4
|
+
const AdtException_1 = require("../AdtException");
|
|
5
|
+
const utilities_1 = require("../utilities");
|
|
6
|
+
async function searchObject(h, query, objType, maxResults = 100) {
|
|
7
|
+
const qs = { operation: "quickSearch", query, maxResults };
|
|
8
|
+
if (objType)
|
|
9
|
+
qs.objectType = objType.replace(/\/.*$/, "");
|
|
10
|
+
const response = await h.request(`/sap/bc/adt/repository/informationsystem/search`, { qs, headers: { Accept: "application/*" } });
|
|
11
|
+
const raw = (0, utilities_1.fullParse)(response.body);
|
|
12
|
+
return (0, utilities_1.xmlArray)(raw, "adtcore:objectReferences", "adtcore:objectReference").map((sr) => {
|
|
13
|
+
const result = (0, utilities_1.xmlNodeAttr)(sr);
|
|
14
|
+
// older systems return things like "ZREPORT (PROGRAM)"...
|
|
15
|
+
const r = result["adtcore:name"].match(/([^\s]*)\s*\((.*)\)/);
|
|
16
|
+
if (r) {
|
|
17
|
+
result["adtcore:name"] = r[1];
|
|
18
|
+
if (!result["adtcore:description"])
|
|
19
|
+
result["adtcore:description"] = r[2];
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.searchObject = searchObject;
|
|
25
|
+
async function findObjectPath(h, objectUrl) {
|
|
26
|
+
(0, AdtException_1.ValidateObjectUrl)(objectUrl);
|
|
27
|
+
const qs = { uri: objectUrl };
|
|
28
|
+
const response = await h.request(`/sap/bc/adt/repository/nodepath`, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
qs
|
|
31
|
+
});
|
|
32
|
+
const raw = (0, utilities_1.fullParse)(response.body);
|
|
33
|
+
return (0, utilities_1.xmlArray)(raw, "projectexplorer:nodepath", "projectexplorer:objectLinkReferences", "objectLinkReference").map(utilities_1.xmlNodeAttr);
|
|
34
|
+
}
|
|
35
|
+
exports.findObjectPath = findObjectPath;
|
|
36
|
+
async function abapDocumentation(h, objectUri, body, line, column, language = "EN") {
|
|
37
|
+
(0, AdtException_1.ValidateObjectUrl)(objectUri);
|
|
38
|
+
const headers = {
|
|
39
|
+
"Content-Type": "text/plain",
|
|
40
|
+
Accept: "application/vnd.sap.adt.docu.v1+html,text/html"
|
|
41
|
+
};
|
|
42
|
+
const uri = `${objectUri}#start=${line},${column}`;
|
|
43
|
+
const qs = { uri, language, format: "eclipse" };
|
|
44
|
+
const response = await h.request(`/sap/bc/adt/docu/abap/langu`, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
qs,
|
|
47
|
+
headers,
|
|
48
|
+
body
|
|
49
|
+
});
|
|
50
|
+
return response.body;
|
|
51
|
+
}
|
|
52
|
+
exports.abapDocumentation = abapDocumentation;
|
|
53
|
+
async function packageSearchHelp(h, type, name = "*") {
|
|
54
|
+
const headers = { Accept: "application/*" };
|
|
55
|
+
const qs = { name };
|
|
56
|
+
const uri = `/sap/bc/adt/packages/valuehelps/${type}`;
|
|
57
|
+
const response = await h.request(uri, { qs, headers });
|
|
58
|
+
const raw = (0, utilities_1.fullParse)(response.body);
|
|
59
|
+
return (0, utilities_1.xmlArray)(raw, "nameditem:namedItemList", "nameditem:namedItem").map((item) => {
|
|
60
|
+
return {
|
|
61
|
+
name: item["nameditem:name"],
|
|
62
|
+
description: item["nameditem:description"],
|
|
63
|
+
data: item["nameditem:data"]
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.packageSearchHelp = packageSearchHelp;
|