@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.
Files changed (96) hide show
  1. package/.abapgit.xml +27 -0
  2. package/LICENSE +21 -0
  3. package/README.md +23 -0
  4. package/build/AdtClient.d.ts +292 -0
  5. package/build/AdtClient.d.ts.map +1 -0
  6. package/build/AdtClient.js +628 -0
  7. package/build/AdtException.d.ts +62 -0
  8. package/build/AdtException.d.ts.map +1 -0
  9. package/build/AdtException.js +185 -0
  10. package/build/AdtHTTP.d.ts +113 -0
  11. package/build/AdtHTTP.d.ts.map +1 -0
  12. package/build/AdtHTTP.js +285 -0
  13. package/build/api/abapgit.d.ts +86 -0
  14. package/build/api/abapgit.d.ts.map +1 -0
  15. package/build/api/abapgit.js +300 -0
  16. package/build/api/activate.d.ts +39 -0
  17. package/build/api/activate.d.ts.map +1 -0
  18. package/build/api/activate.js +105 -0
  19. package/build/api/atc.d.ts +163 -0
  20. package/build/api/atc.d.ts.map +1 -0
  21. package/build/api/atc.js +440 -0
  22. package/build/api/cds.d.ts +52 -0
  23. package/build/api/cds.d.ts.map +1 -0
  24. package/build/api/cds.js +147 -0
  25. package/build/api/debugger.d.ts +238 -0
  26. package/build/api/debugger.d.ts.map +1 -0
  27. package/build/api/debugger.js +299 -0
  28. package/build/api/delete.d.ts +20 -0
  29. package/build/api/delete.d.ts.map +1 -0
  30. package/build/api/delete.js +29 -0
  31. package/build/api/discovery.d.ts +44 -0
  32. package/build/api/discovery.d.ts.map +1 -0
  33. package/build/api/discovery.js +78 -0
  34. package/build/api/feeds.d.ts +63 -0
  35. package/build/api/feeds.d.ts.map +1 -0
  36. package/build/api/feeds.js +65 -0
  37. package/build/api/index.d.ts +22 -0
  38. package/build/api/index.d.ts.map +1 -0
  39. package/build/api/index.js +37 -0
  40. package/build/api/nodeContents.d.ts +41 -0
  41. package/build/api/nodeContents.d.ts.map +1 -0
  42. package/build/api/nodeContents.js +78 -0
  43. package/build/api/objectcontents.d.ts +21 -0
  44. package/build/api/objectcontents.d.ts.map +1 -0
  45. package/build/api/objectcontents.js +68 -0
  46. package/build/api/objectcreator.d.ts +103 -0
  47. package/build/api/objectcreator.d.ts.map +1 -0
  48. package/build/api/objectcreator.js +372 -0
  49. package/build/api/objectstructure.d.ts +71 -0
  50. package/build/api/objectstructure.d.ts.map +1 -0
  51. package/build/api/objectstructure.js +37 -0
  52. package/build/api/refactor.d.ts +122 -0
  53. package/build/api/refactor.d.ts.map +1 -0
  54. package/build/api/refactor.js +470 -0
  55. package/build/api/revisions.d.ts +12 -0
  56. package/build/api/revisions.d.ts.map +1 -0
  57. package/build/api/revisions.js +61 -0
  58. package/build/api/search.d.ts +25 -0
  59. package/build/api/search.d.ts.map +1 -0
  60. package/build/api/search.js +67 -0
  61. package/build/api/syntax.d.ts +133 -0
  62. package/build/api/syntax.d.ts.map +1 -0
  63. package/build/api/syntax.js +327 -0
  64. package/build/api/tablecontents.d.ts +141 -0
  65. package/build/api/tablecontents.d.ts.map +1 -0
  66. package/build/api/tablecontents.js +186 -0
  67. package/build/api/trace.test.d.ts +2 -0
  68. package/build/api/trace.test.d.ts.map +1 -0
  69. package/build/api/trace.test.js +39 -0
  70. package/build/api/traces.d.ts +13 -0
  71. package/build/api/traces.d.ts.map +1 -0
  72. package/build/api/traces.js +97 -0
  73. package/build/api/tracetypes.d.ts +276 -0
  74. package/build/api/tracetypes.d.ts.map +1 -0
  75. package/build/api/tracetypes.js +474 -0
  76. package/build/api/transports.d.ts +158 -0
  77. package/build/api/transports.d.ts.map +1 -0
  78. package/build/api/transports.js +292 -0
  79. package/build/api/unittest.d.ts +81 -0
  80. package/build/api/unittest.d.ts.map +1 -0
  81. package/build/api/unittest.js +164 -0
  82. package/build/api/urlparser.d.ts +34 -0
  83. package/build/api/urlparser.d.ts.map +1 -0
  84. package/build/api/urlparser.js +86 -0
  85. package/build/index.d.ts +10 -0
  86. package/build/index.d.ts.map +1 -0
  87. package/build/index.js +49 -0
  88. package/build/requestLogger.d.ts +30 -0
  89. package/build/requestLogger.d.ts.map +1 -0
  90. package/build/requestLogger.js +100 -0
  91. package/build/utilities.d.ts +42 -0
  92. package/build/utilities.d.ts.map +1 -0
  93. package/build/utilities.js +221 -0
  94. package/jest.config.js +32 -0
  95. package/package.json +45 -0
  96. package/setenv_sample.js +27 -0
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTransportConfiguration = exports.transportConfigurations = exports.transportReference = exports.systemUsers = exports.transportAddUser = exports.transportSetOwner = exports.transportRelease = exports.transportDelete = exports.setTransportsConfig = exports.createTransportsConfig = exports.transportsByConfig = exports.userTransports = exports.createTransport = exports.transportInfo = exports.TransportDateFilter = void 0;
4
+ const AdtException_1 = require("../AdtException");
5
+ const utilities_1 = require("../utilities");
6
+ var TransportDateFilter;
7
+ (function (TransportDateFilter) {
8
+ TransportDateFilter[TransportDateFilter["SinceYesterday"] = 0] = "SinceYesterday";
9
+ TransportDateFilter[TransportDateFilter["SincleTwoWeeks"] = 1] = "SincleTwoWeeks";
10
+ TransportDateFilter[TransportDateFilter["SinceFourWeeks"] = 2] = "SinceFourWeeks";
11
+ TransportDateFilter[TransportDateFilter["DateRange"] = 3] = "DateRange";
12
+ })(TransportDateFilter = exports.TransportDateFilter || (exports.TransportDateFilter = {}));
13
+ function extractLocks(raw) {
14
+ const lock = raw && raw.CTS_OBJECT_LOCK;
15
+ if (!lock)
16
+ return;
17
+ try {
18
+ const holder = lock.LOCK_HOLDER;
19
+ const TASKS = (0, utilities_1.xmlArray)(holder, "TASK_HEADERS").map((x) => x.CTS_TASK_HEADER);
20
+ return {
21
+ HEADER: holder.REQ_HEADER,
22
+ OBJECT_KEY: (0, utilities_1.xmlNode)(lock, "OBJECT_KEY"),
23
+ TASKS
24
+ };
25
+ }
26
+ catch (_a) {
27
+ return;
28
+ }
29
+ }
30
+ function extractTransports(raw) {
31
+ return (0, utilities_1.xmlArray)(raw, "CTS_REQUEST").map((x) => x.REQ_HEADER);
32
+ }
33
+ async function transportInfo(h, URI, DEVCLASS = "", OPERATION = "I") {
34
+ (0, AdtException_1.ValidateObjectUrl)(URI);
35
+ const body = (0, utilities_1.JSON2AbapXML)({
36
+ DEVCLASS,
37
+ OPERATION,
38
+ URI
39
+ });
40
+ const headers = {
41
+ Accept: "application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.transport.service.checkData",
42
+ "Content-Type": "application/vnd.sap.as+xml; charset=UTF-8; dataname=com.sap.adt.transport.service.checkData"
43
+ };
44
+ const response = await h.request("/sap/bc/adt/cts/transportchecks", {
45
+ body,
46
+ method: "POST",
47
+ headers
48
+ });
49
+ // return parsePackageResponse(response.body)
50
+ // tslint:disable-next-line: prefer-const
51
+ let { REQUESTS, LOCKS, MESSAGES, ...header } = (0, utilities_1.parse)(response.body)["asx:abap"]["asx:values"].DATA;
52
+ if (MESSAGES) {
53
+ MESSAGES = (0, utilities_1.xmlArray)(MESSAGES, "CTS_MESSAGE").map((m) => {
54
+ // tslint:disable-next-line: prefer-const
55
+ let { VARIABLES, ...rest } = m;
56
+ VARIABLES =
57
+ (VARIABLES && (0, utilities_1.xmlArray)(m, "VARIABLES", "CTS_VARIABLE")).map((v) => v.VARIABLE) || [];
58
+ return { VARIABLES, ...rest };
59
+ });
60
+ MESSAGES.filter((m) => m.SEVERITY.match(/[EAX]/)).some((e) => {
61
+ throw (0, AdtException_1.adtException)(e.TEXT);
62
+ });
63
+ }
64
+ const TRANSPORTS = extractTransports(REQUESTS);
65
+ return { ...header, LOCKS: extractLocks(LOCKS), TRANSPORTS };
66
+ }
67
+ exports.transportInfo = transportInfo;
68
+ async function createTransport(h, REF, REQUEST_TEXT, DEVCLASS, OPERATION = "I", transportLayer = "") {
69
+ var _a;
70
+ (0, AdtException_1.ValidateObjectUrl)(REF);
71
+ const body = (0, utilities_1.JSON2AbapXML)({ DEVCLASS, REQUEST_TEXT, REF, OPERATION });
72
+ const qs = transportLayer ? { transportLayer } : {};
73
+ const response = await h.request("/sap/bc/adt/cts/transports", {
74
+ body,
75
+ qs,
76
+ headers: {
77
+ Accept: "text/plain",
78
+ "Content-Type": "application/vnd.sap.as+xml; charset=UTF-8; dataname=com.sap.adt.CreateCorrectionRequest"
79
+ },
80
+ method: "POST"
81
+ });
82
+ const transport = (_a = response.body) === null || _a === void 0 ? void 0 : _a.split("/").pop();
83
+ return transport || "";
84
+ }
85
+ exports.createTransport = createTransport;
86
+ const parseTask = (t) => {
87
+ const task = {
88
+ ...(0, utilities_1.xmlNodeAttr)(t),
89
+ links: (0, utilities_1.xmlArray)(t, "atom:link").map(utilities_1.xmlNodeAttr),
90
+ objects: (0, utilities_1.xmlArray)(t, "tm:abap_object").map(utilities_1.xmlNodeAttr)
91
+ };
92
+ if (task["tm:desc"])
93
+ task["tm:desc"] = task["tm:desc"];
94
+ return task;
95
+ };
96
+ const parseRequest = (r) => {
97
+ const request = {
98
+ ...parseTask(r),
99
+ tasks: (0, utilities_1.xmlArray)(r, "tm:task").map(parseTask)
100
+ };
101
+ return request;
102
+ };
103
+ const parseTargets = (s) => ({
104
+ ...(0, utilities_1.xmlNodeAttr)(s),
105
+ modifiable: (0, utilities_1.xmlArray)(s, "tm:modifiable", "tm:request").map(parseRequest),
106
+ released: (0, utilities_1.xmlArray)(s, "tm:released", "tm:request").map(parseRequest)
107
+ });
108
+ async function userTransports(h, user, targets = true) {
109
+ const response = await h.request("/sap/bc/adt/cts/transportrequests", {
110
+ qs: { user, targets }
111
+ });
112
+ const raw = (0, utilities_1.fullParse)(response.body);
113
+ const workbench = (0, utilities_1.xmlArray)(raw, "tm:root", "tm:workbench", "tm:target").map(parseTargets);
114
+ const customizing = (0, utilities_1.xmlArray)(raw, "tm:root", "tm:customizing", "tm:target").map(parseTargets);
115
+ const retval = { workbench, customizing };
116
+ return retval;
117
+ }
118
+ exports.userTransports = userTransports;
119
+ async function transportsByConfig(h, configUri, targets = true) {
120
+ const response = await h.request("/sap/bc/adt/cts/transportrequests", {
121
+ qs: { configUri, targets }
122
+ });
123
+ const raw = (0, utilities_1.fullParse)(response.body);
124
+ const workbench = (0, utilities_1.xmlArray)(raw, "tm:root", "tm:workbench", "tm:target").map(parseTargets);
125
+ const customizing = (0, utilities_1.xmlArray)(raw, "tm:root", "tm:customizing", "tm:target").map(parseTargets);
126
+ const retval = { workbench, customizing };
127
+ return retval;
128
+ }
129
+ exports.transportsByConfig = transportsByConfig;
130
+ const serializeTransportConfig = (cfg) => {
131
+ const w = (k, v) => `<configuration:property key="${k}">${v}</configuration:property>`;
132
+ const p = (v, k) => w(k, v[k]);
133
+ const td = (d) => `${(0, utilities_1.toSapDate)(new Date(d))}`;
134
+ const datelimit = cfg.DateFilter === TransportDateFilter.DateRange
135
+ ? `${w("FromDate", td(cfg.FromDate))}${w("ToDate", td(cfg.ToDate))}`
136
+ : "";
137
+ return "".concat(`<configuration:configuration xmlns:configuration="http://www.sap.com/adt/configuration"> <configuration:properties>`, p(cfg, "WorkbenchRequests"), p(cfg, "CustomizingRequests"), p(cfg, "TransportOfCopies"), p(cfg, "DateFilter"), p(cfg, "Modifiable"), p(cfg, "Released"), p(cfg, "User"), datelimit, `</configuration:properties> </configuration:configuration>`);
138
+ };
139
+ async function createTransportsConfig(h) {
140
+ const headers = { Accept: "application/vnd.sap.adt.configuration.v1+xml" };
141
+ const uri = "/sap/bc/adt/cts/transportrequests/searchconfiguration/configurations";
142
+ const response = await h.request(uri, { method: "POST", headers });
143
+ return parseTransportConfig(response.body);
144
+ }
145
+ exports.createTransportsConfig = createTransportsConfig;
146
+ async function setTransportsConfig(h, uri, etag, config) {
147
+ const body = serializeTransportConfig(config);
148
+ const headers = {
149
+ Accept: "application/vnd.sap.adt.configuration.v1+xml",
150
+ "Content-Type": "application/vnd.sap.adt.configuration.v1+xml",
151
+ "If-Match": etag
152
+ };
153
+ const response = await h.request(uri, { method: "PUT", headers, body });
154
+ return parseTransportConfig(response.body);
155
+ }
156
+ exports.setTransportsConfig = setTransportsConfig;
157
+ function validateTransport(transportNumber) {
158
+ if (transportNumber.length !== 10 || !transportNumber.match(/^[a-z]\w\wk/i))
159
+ (0, AdtException_1.adtException)("Invalid transport number:" + transportNumber);
160
+ }
161
+ async function transportDelete(h, transportNumber) {
162
+ validateTransport(transportNumber);
163
+ await h.request("/sap/bc/adt/cts/transportrequests/" + transportNumber, {
164
+ method: "DELETE",
165
+ headers: { Accept: "application/*" }
166
+ });
167
+ }
168
+ exports.transportDelete = transportDelete;
169
+ async function transportRelease(h, transportNumber, ignoreLocks = false, IgnoreATC = false) {
170
+ validateTransport(transportNumber);
171
+ const action = IgnoreATC
172
+ ? "relObjigchkatc"
173
+ : ignoreLocks
174
+ ? "relwithignlock"
175
+ : "newreleasejobs";
176
+ const response = await h.request(`/sap/bc/adt/cts/transportrequests/${transportNumber}/${action}`, {
177
+ method: "POST",
178
+ headers: { Accept: "application/*" }
179
+ });
180
+ const raw = (0, utilities_1.fullParse)(response.body);
181
+ const reports = (0, utilities_1.xmlArray)(raw, "tm:root", "tm:releasereports", "chkrun:checkReport").map((r) => {
182
+ return {
183
+ ...(0, utilities_1.xmlNodeAttr)(r),
184
+ messages: (0, utilities_1.xmlArray)(r, "chkrun:checkMessageList", "chkrun:checkMessage").map(utilities_1.xmlNodeAttr)
185
+ };
186
+ });
187
+ return reports;
188
+ }
189
+ exports.transportRelease = transportRelease;
190
+ async function transportSetOwner(h, transportNumber, targetuser) {
191
+ validateTransport(transportNumber);
192
+ const body = `<?xml version="1.0" encoding="ASCII"?><tm:root xmlns:tm="http://www.sap.com/cts/adt/tm" tm:number="${transportNumber}" tm:targetuser="${targetuser}" tm:useraction="changeowner"/>`;
193
+ const response = await h.request("/sap/bc/adt/cts/transportrequests/" + transportNumber, {
194
+ method: "PUT",
195
+ headers: { Accept: "application/*" },
196
+ qs: { targetuser },
197
+ body
198
+ });
199
+ const raw = (0, utilities_1.fullParse)(response.body);
200
+ return (0, utilities_1.xmlNodeAttr)((0, utilities_1.xmlNode)(raw, "tm:root"));
201
+ }
202
+ exports.transportSetOwner = transportSetOwner;
203
+ async function transportAddUser(h, transportNumber, user) {
204
+ validateTransport(transportNumber);
205
+ const body = `<?xml version="1.0" encoding="ASCII"?>
206
+ <tm:root xmlns:tm="http://www.sap.com/cts/adt/tm" tm:number="${transportNumber}"
207
+ tm:targetuser="${user}" tm:useraction="newtask"/>`;
208
+ const response = await h.request("/sap/bc/adt/cts/transportrequests/" + transportNumber + "/tasks", {
209
+ method: "POST",
210
+ body,
211
+ headers: { Accept: "application/*", "Content-Type": "text/plain" }
212
+ });
213
+ const raw = (0, utilities_1.fullParse)(response.body);
214
+ return (0, utilities_1.xmlNodeAttr)((0, utilities_1.xmlNode)(raw, "tm:root"));
215
+ }
216
+ exports.transportAddUser = transportAddUser;
217
+ async function systemUsers(h) {
218
+ const response = await h.request("/sap/bc/adt/system/users", {
219
+ headers: { Accept: "application/atom+xml;type=feed" }
220
+ });
221
+ const raw = (0, utilities_1.parse)(response.body);
222
+ return (0, utilities_1.xmlArray)(raw, "atom:feed", "atom:entry").map((r) => ({ id: r["atom:id"], title: r["atom:title"] }));
223
+ }
224
+ exports.systemUsers = systemUsers;
225
+ // tslint:disable: variable-name
226
+ async function transportReference(h, pgmid, obj_wbtype, obj_name, tr_number = "") {
227
+ const response = await h.request("/sap/bc/adt/cts/transportrequests/reference", {
228
+ headers: { Accept: "application/*" },
229
+ qs: { obj_name, obj_wbtype, pgmid, tr_number }
230
+ });
231
+ const raw = (0, utilities_1.fullParse)(response.body);
232
+ const link = (0, utilities_1.xmlNodeAttr)((0, utilities_1.xmlNode)(raw, "tm:root", "atom:link"));
233
+ return link.href;
234
+ }
235
+ exports.transportReference = transportReference;
236
+ const parseTransportConfigItemList = (body) => {
237
+ const raw = (0, utilities_1.fullParse)(body, { parseAttributeValue: false });
238
+ return (0, utilities_1.xmlArray)(raw, "configurations:configurations", "configuration:configuration").map((conf) => {
239
+ const { "atom:link": { "@_href": link, "@_etag": etag }, ...rest } = conf;
240
+ const { createdAt, changedAt, ...attrs } = (0, utilities_1.xmlNodeAttr)(rest);
241
+ const item = {
242
+ ...attrs,
243
+ link,
244
+ etag,
245
+ createdAt: Date.parse(createdAt),
246
+ changedAt: Date.parse(changedAt)
247
+ };
248
+ return item;
249
+ });
250
+ };
251
+ async function transportConfigurations(h) {
252
+ const headers = { Accept: "application/vnd.sap.adt.configurations.v1+xml" };
253
+ const url = "/sap/bc/adt/cts/transportrequests/searchconfiguration/configurations";
254
+ const response = await h.request(url, { headers });
255
+ return parseTransportConfigItemList(response.body);
256
+ }
257
+ exports.transportConfigurations = transportConfigurations;
258
+ const parseTransportConfig = (r) => {
259
+ const raw = (0, utilities_1.fullParse)(r, { parseAttributeValue: false });
260
+ const props = (0, utilities_1.xmlArray)(raw, "configuration:configuration", "configuration:properties", "configuration:property").map((p) => {
261
+ return { key: p["@_key"], value: p["#text"] };
262
+ });
263
+ const cfg = {};
264
+ for (const { key, value } of props)
265
+ cfg[key] = value;
266
+ const WorkbenchRequests = cfg.WorkbenchRequests;
267
+ const TransportOfCopies = cfg.TransportOfCopies;
268
+ const Released = cfg.Released;
269
+ const User = cfg.User;
270
+ const CustomizingRequests = cfg.CustomizingRequests;
271
+ const FromDate = cfg.FromDate && (0, utilities_1.parseSapDate)(`${cfg.FromDate}`);
272
+ const ToDate = cfg.ToDate && (0, utilities_1.parseSapDate)(`${cfg.ToDate}`);
273
+ const DateFilter = cfg.DateFilter;
274
+ const Modifiable = cfg.Modifiable;
275
+ return {
276
+ WorkbenchRequests,
277
+ TransportOfCopies,
278
+ Released,
279
+ User,
280
+ CustomizingRequests,
281
+ FromDate,
282
+ ToDate,
283
+ DateFilter,
284
+ Modifiable
285
+ };
286
+ };
287
+ async function getTransportConfiguration(h, url) {
288
+ const headers = { Accept: "application/vnd.sap.adt.configuration.v1+xml" };
289
+ const response = await h.request(url, { headers });
290
+ return parseTransportConfig(response.body);
291
+ }
292
+ exports.getTransportConfiguration = getTransportConfiguration;
@@ -0,0 +1,81 @@
1
+ import * as t from "io-ts";
2
+ import { AdtHTTP } from "../AdtHTTP";
3
+ export interface UnitTestStackEntry {
4
+ "adtcore:uri": string;
5
+ "adtcore:type": string;
6
+ "adtcore:name": string;
7
+ "adtcore:description": string;
8
+ }
9
+ export declare enum UnitTestAlertKind {
10
+ exception = "exception",
11
+ failedAssertion = "failedAssertion",
12
+ warning = "warning"
13
+ }
14
+ export declare enum UnitTestSeverity {
15
+ critical = "critical",
16
+ fatal = "fatal",
17
+ tolerable = "tolerable",
18
+ tolerant = "tolerant"
19
+ }
20
+ export interface UnitTestAlert {
21
+ kind: UnitTestAlertKind;
22
+ severity: UnitTestSeverity;
23
+ details: string[];
24
+ stack: UnitTestStackEntry[];
25
+ title: string;
26
+ }
27
+ export interface UnitTestMethod {
28
+ "adtcore:uri": string;
29
+ "adtcore:type": string;
30
+ "adtcore:name": string;
31
+ executionTime: number;
32
+ uriType: string;
33
+ navigationUri?: string;
34
+ unit: string;
35
+ alerts: UnitTestAlert[];
36
+ }
37
+ export interface UnitTestClass {
38
+ "adtcore:uri": string;
39
+ "adtcore:type": string;
40
+ "adtcore:name": string;
41
+ uriType: string;
42
+ navigationUri?: string;
43
+ durationCategory: string;
44
+ riskLevel: string;
45
+ testmethods: UnitTestMethod[];
46
+ alerts: UnitTestAlert[];
47
+ }
48
+ declare const markerCodec: t.TypeC<{
49
+ kind: t.StringC;
50
+ keepsResult: t.BooleanC;
51
+ location: t.TypeC<{
52
+ uri: t.StringC;
53
+ query: t.UnionC<[t.UndefinedC, t.RecordC<t.StringC, t.StringC>]>;
54
+ range: t.TypeC<{
55
+ start: t.TypeC<{
56
+ line: t.NumberC;
57
+ column: t.NumberC;
58
+ }>;
59
+ end: t.TypeC<{
60
+ line: t.NumberC;
61
+ column: t.NumberC;
62
+ }>;
63
+ }>;
64
+ hashparms: t.UnionC<[t.UndefinedC, t.RecordC<t.StringC, t.StringC>]>;
65
+ }>;
66
+ }>;
67
+ export type UnitTestOccurrenceMarker = t.TypeOf<typeof markerCodec>;
68
+ export interface UnitTestRunFlags {
69
+ harmless: boolean;
70
+ dangerous: boolean;
71
+ critical: boolean;
72
+ short: boolean;
73
+ medium: boolean;
74
+ long: boolean;
75
+ }
76
+ export declare const DefaultUnitTestRunFlags: UnitTestRunFlags;
77
+ export declare function runUnitTest(h: AdtHTTP, url: string, flags?: UnitTestRunFlags): Promise<UnitTestClass[]>;
78
+ export declare function unitTestEvaluation(h: AdtHTTP, clas: UnitTestClass, flags?: UnitTestRunFlags): Promise<UnitTestMethod[]>;
79
+ export declare function unitTestOccurrenceMarkers(h: AdtHTTP, uri: string, source: string): Promise<UnitTestOccurrenceMarker[]>;
80
+ export {};
81
+ //# sourceMappingURL=unittest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unittest.d.ts","sourceRoot":"","sources":["../../src/api/unittest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAIpC,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,qBAAqB,EAAE,MAAM,CAAA;CAC9B;AAED,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;IACvB,eAAe,oBAAoB;IACnC,OAAO,YAAY;CACpB;AACD,oBAAY,gBAAgB;IAC1B,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,QAAQ,aAAa;CACtB;AACD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAA;IACvB,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,KAAK,EAAE,kBAAkB,EAAE,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd;AACD,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,aAAa,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,cAAc,EAAE,CAAA;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAA;CACxB;AAED,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;EAIf,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;AA2BnE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,OAAO,CAAA;CACd;AAED,eAAO,MAAM,uBAAuB,EAAE,gBAOrC,CAAA;AAED,wBAAsB,WAAW,CAC/B,CAAC,EAAE,OAAO,EACV,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,gBAA0C,4BA4ClD;AAED,wBAAsB,kBAAkB,CACtC,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,aAAa,EACnB,KAAK,GAAE,gBAA0C,6BAuClD;AAED,wBAAsB,yBAAyB,CAC7C,CAAC,EAAE,OAAO,EACV,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAqBrC"}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.unitTestOccurrenceMarkers = exports.unitTestEvaluation = exports.runUnitTest = exports.DefaultUnitTestRunFlags = exports.UnitTestSeverity = exports.UnitTestAlertKind = void 0;
27
+ const t = __importStar(require("io-ts"));
28
+ const __1 = require("..");
29
+ const utilities_1 = require("../utilities");
30
+ const urlparser_1 = require("./urlparser");
31
+ var UnitTestAlertKind;
32
+ (function (UnitTestAlertKind) {
33
+ UnitTestAlertKind["exception"] = "exception";
34
+ UnitTestAlertKind["failedAssertion"] = "failedAssertion";
35
+ UnitTestAlertKind["warning"] = "warning";
36
+ })(UnitTestAlertKind = exports.UnitTestAlertKind || (exports.UnitTestAlertKind = {}));
37
+ var UnitTestSeverity;
38
+ (function (UnitTestSeverity) {
39
+ UnitTestSeverity["critical"] = "critical";
40
+ UnitTestSeverity["fatal"] = "fatal";
41
+ UnitTestSeverity["tolerable"] = "tolerable";
42
+ UnitTestSeverity["tolerant"] = "tolerant";
43
+ })(UnitTestSeverity = exports.UnitTestSeverity || (exports.UnitTestSeverity = {}));
44
+ const markerCodec = t.type({
45
+ kind: t.string,
46
+ keepsResult: t.boolean,
47
+ location: urlparser_1.uriParts
48
+ });
49
+ const parseDetail = (alert) => (0, utilities_1.xmlArray)(alert, "details", "detail").reduce((result, d) => {
50
+ const main = (d && d["@_text"]) || "";
51
+ const children = (0, utilities_1.xmlArray)(d, "details", "detail")
52
+ .map((dd) => (dd && `\n\t${dd["@_text"]}`) || "")
53
+ .join("");
54
+ return main ? [...result, main + children] : result;
55
+ }, []);
56
+ const parseStack = (alert) => (0, utilities_1.xmlArray)(alert, "stack", "stackEntry").map(x => {
57
+ const entry = (0, utilities_1.xmlNodeAttr)(x);
58
+ entry["adtcore:description"] = entry["adtcore:description"];
59
+ return entry;
60
+ });
61
+ const parseAlert = (alert) => ({
62
+ ...(0, utilities_1.xmlNodeAttr)(alert),
63
+ details: parseDetail(alert),
64
+ stack: parseStack(alert),
65
+ title: (alert === null || alert === void 0 ? void 0 : alert.title) || ""
66
+ });
67
+ const parseMethod = (method) => ({
68
+ ...(0, utilities_1.xmlNodeAttr)(method),
69
+ alerts: (0, utilities_1.xmlArray)(method, "alerts", "alert").map(parseAlert)
70
+ });
71
+ exports.DefaultUnitTestRunFlags = {
72
+ harmless: true,
73
+ dangerous: false,
74
+ critical: false,
75
+ short: true,
76
+ medium: false,
77
+ long: false
78
+ };
79
+ async function runUnitTest(h, url, flags = exports.DefaultUnitTestRunFlags) {
80
+ const headers = { "Content-Type": "application/*", Accept: "application/*" };
81
+ const body = `<?xml version="1.0" encoding="UTF-8"?>
82
+ <aunit:runConfiguration xmlns:aunit="http://www.sap.com/adt/aunit">
83
+ <external>
84
+ <coverage active="false"/>
85
+ </external>
86
+ <options>
87
+ <uriType value="semantic"/>
88
+ <testDeterminationStrategy sameProgram="true" assignedTests="false"/>
89
+ <testRiskLevels harmless="${flags.harmless}" dangerous="${flags.dangerous}" critical="${flags.critical}"/>
90
+ <testDurations short="${flags.short}" medium="${flags.medium}" long="${flags.long}"/>
91
+ <withNavigationUri enabled="true"/>
92
+ </options>
93
+ <adtcore:objectSets xmlns:adtcore="http://www.sap.com/adt/core">
94
+ <objectSet kind="inclusive">
95
+ <adtcore:objectReferences>
96
+ <adtcore:objectReference adtcore:uri="${url}"/>
97
+ </adtcore:objectReferences>
98
+ </objectSet>
99
+ </adtcore:objectSets>
100
+ </aunit:runConfiguration>`;
101
+ const response = await h.request("/sap/bc/adt/abapunit/testruns", {
102
+ method: "POST",
103
+ headers,
104
+ body
105
+ });
106
+ const raw = (0, utilities_1.fullParse)(response.body);
107
+ const classes = (0, utilities_1.xmlFlatArray)(raw, "aunit:runResult", "program", "testClasses", "testClass").map(c => {
108
+ return {
109
+ ...(0, utilities_1.xmlNodeAttr)(c),
110
+ alerts: (0, utilities_1.xmlArray)(c, "alerts", "alert").map(parseAlert),
111
+ testmethods: (0, utilities_1.xmlFlatArray)(c, "testMethods", "testMethod").map(parseMethod)
112
+ };
113
+ });
114
+ return classes;
115
+ }
116
+ exports.runUnitTest = runUnitTest;
117
+ async function unitTestEvaluation(h, clas, flags = exports.DefaultUnitTestRunFlags) {
118
+ const headers = { "Content-Type": "application/*l", Accept: "application/*" };
119
+ const references = clas.testmethods
120
+ .map(m => `<adtcore:objectReference adtcore:uri="${m["adtcore:uri"]}" />`)
121
+ .join("\n");
122
+ const body = `<?xml version="1.0" encoding="UTF-8"?>
123
+ <aunit:runConfiguration xmlns:aunit="http://www.sap.com/adt/aunit">
124
+ <options>
125
+ <uriType value="${clas.uriType}"></uriType>
126
+ <testDeterminationStrategy sameProgram="true" assignedTests="false"></testDeterminationStrategy>
127
+ <testRiskLevels harmless="${flags.harmless}" dangerous="${flags.dangerous}" critical="${flags.critical}"/>
128
+ <testDurations short="${flags.short}" medium="${flags.medium}" long="${flags.long}"/>
129
+ <withNavigationUri enabled="true"></withNavigationUri>
130
+ </options>
131
+ <adtcore:objectSets xmlns:adtcore="http://www.sap.com/adt/core">
132
+ <objectSet kind="inclusive">
133
+ <adtcore:objectReferences>
134
+ ${references}
135
+ </adtcore:objectReferences>
136
+ </objectSet>
137
+ </adtcore:objectSets>
138
+ </aunit:runConfiguration>`;
139
+ const response = await h.request("/sap/bc/adt/abapunit/testruns/evaluation", {
140
+ method: "POST",
141
+ headers,
142
+ body
143
+ });
144
+ const raw = (0, utilities_1.fullParse)(response.body);
145
+ return (0, utilities_1.xmlArray)(raw, "aunit:runResult", "program", "testClasses", "testClass", "testMethods", "testMethod").map(parseMethod);
146
+ }
147
+ exports.unitTestEvaluation = unitTestEvaluation;
148
+ async function unitTestOccurrenceMarkers(h, uri, source) {
149
+ const headers = { "Content-Type": "text/plain", Accept: "application/*" };
150
+ const response = await h.request("/sap/bc/adt/abapsource/occurencemarkers", {
151
+ method: "POST",
152
+ headers,
153
+ body: source,
154
+ qs: { uri }
155
+ });
156
+ const raw = (0, utilities_1.fullParse)(response.body, { removeNSPrefix: true });
157
+ const markers = (0, utilities_1.xmlArray)(raw, "occurrenceInfo", "occurrences", "occurrence").map(o => {
158
+ const { kind, keepsResult } = (0, utilities_1.xmlNodeAttr)(o);
159
+ const { uri } = (0, utilities_1.xmlNodeAttr)(o === null || o === void 0 ? void 0 : o.objectReference);
160
+ return { kind, keepsResult, location: (0, urlparser_1.parseUri)(uri) };
161
+ });
162
+ return (0, __1.validateParseResult)(t.array(markerCodec).decode(markers));
163
+ }
164
+ exports.unitTestOccurrenceMarkers = unitTestOccurrenceMarkers;
@@ -0,0 +1,34 @@
1
+ import { Clean } from "../utilities";
2
+ import * as t from "io-ts";
3
+ declare const range: t.TypeC<{
4
+ start: t.TypeC<{
5
+ line: t.NumberC;
6
+ column: t.NumberC;
7
+ }>;
8
+ end: t.TypeC<{
9
+ line: t.NumberC;
10
+ column: t.NumberC;
11
+ }>;
12
+ }>;
13
+ export declare const uriParts: t.TypeC<{
14
+ uri: t.StringC;
15
+ query: t.UnionC<[t.UndefinedC, t.RecordC<t.StringC, t.StringC>]>;
16
+ range: t.TypeC<{
17
+ start: t.TypeC<{
18
+ line: t.NumberC;
19
+ column: t.NumberC;
20
+ }>;
21
+ end: t.TypeC<{
22
+ line: t.NumberC;
23
+ column: t.NumberC;
24
+ }>;
25
+ }>;
26
+ hashparms: t.UnionC<[t.UndefinedC, t.RecordC<t.StringC, t.StringC>]>;
27
+ }>;
28
+ export type Range = Clean<t.TypeOf<typeof range>>;
29
+ export type UriParts = Clean<t.TypeOf<typeof uriParts>>;
30
+ export declare const rangeToString: (range: Range) => string;
31
+ export declare const uriPartsToString: (parts: UriParts) => string;
32
+ export declare function parseUri(sourceuri: string): UriParts;
33
+ export {};
34
+ //# sourceMappingURL=urlparser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlparser.d.ts","sourceRoot":"","sources":["../../src/api/urlparser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,cAAc,CAAA;AAElD,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAO3B,QAAA,MAAM,KAAK;;;;;;;;;EAGT,CAAA;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;EAKnB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC,CAAA;AACjD,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,UAAW,KAAK,WACoD,CAAA;AAS9F,eAAO,MAAM,gBAAgB,UAAW,QAAQ,WAM/C,CAAA;AAED,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,CA4BpD"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.parseUri = exports.uriPartsToString = exports.rangeToString = exports.uriParts = void 0;
27
+ const utilities_1 = require("../utilities");
28
+ const t = __importStar(require("io-ts"));
29
+ const location = t.type({
30
+ line: t.number,
31
+ column: t.number
32
+ });
33
+ const range = t.type({
34
+ start: location,
35
+ end: location
36
+ });
37
+ exports.uriParts = t.type({
38
+ uri: t.string,
39
+ query: t.union([t.undefined, t.record(t.string, t.string)]),
40
+ range: range,
41
+ hashparms: t.union([t.undefined, t.record(t.string, t.string)]),
42
+ });
43
+ const rangeToString = (range) => `#start=${range.start.line},${range.start.column};end=${range.end.line},${range.end.column}`;
44
+ exports.rangeToString = rangeToString;
45
+ const serializeKv = (r) => {
46
+ const rec = r || {};
47
+ return Object.keys(rec).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(rec[k])}`);
48
+ };
49
+ const isNullRange = (r) => r.start.line === 0 && r.start.column === 0 && r.end.line === 0 && r.end.column === 0;
50
+ const uriPartsToString = (parts) => {
51
+ const range = isNullRange(parts.range) ? "" : (0, exports.rangeToString)(parts.range);
52
+ const parms = serializeKv(parts.hashparms).join(";");
53
+ const query = serializeKv(parts.query).join("&");
54
+ const hash = `${range ? range : ""}${parms ? `${range ? ";" : "#"}${parms}` : ``}`;
55
+ return `${parts.uri}${query ? `?${query}` : ``}${hash}`;
56
+ };
57
+ exports.uriPartsToString = uriPartsToString;
58
+ function parseUri(sourceuri) {
59
+ const [uri, qs, hash] = (0, utilities_1.parts)(sourceuri, /([^\?#]*)(?:\?([^#]*))?(?:#(.*))?/);
60
+ //
61
+ const query = (qs || "").split(/&/).reduce((acc, cur) => {
62
+ const [key, val] = cur.split("=");
63
+ if (key)
64
+ acc[decodeURIComponent(key)] = decodeURIComponent(val);
65
+ return acc;
66
+ }, {});
67
+ const { start, end, ...hashparms } = (hash || "")
68
+ .split(/;/)
69
+ .reduce((acc, cur) => {
70
+ const [key, val] = cur.split("=");
71
+ if (key)
72
+ acc[decodeURIComponent(key)] = decodeURIComponent(val);
73
+ return acc;
74
+ }, {});
75
+ const parsePos = (x) => {
76
+ const [line, column] = x ? x.split(",").map(utilities_1.toInt) : [0, 0];
77
+ return { line: line || 0, column: column || 0 };
78
+ };
79
+ const st = parsePos(start);
80
+ const range = {
81
+ start: st,
82
+ end: end ? parsePos(end) : st
83
+ };
84
+ return { range, uri, query, hashparms };
85
+ }
86
+ exports.parseUri = parseUri;