@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,300 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.switchRepoBranch = exports.remoteRepoInfo = exports.stageRepo = exports.pushRepo = exports.checkRepo = exports.unlinkRepo = exports.pullRepo = exports.createRepo = exports.externalRepoInfo = exports.gitRepos = void 0;
4
+ const utilities_1 = require("../utilities");
5
+ const AdtException_1 = require("../AdtException");
6
+ const parseDate = (d) => {
7
+ const match = d.match(/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/);
8
+ if (!match)
9
+ return new Date(); // wrong but valid
10
+ const [Y, M, D, h, m, s] = match.slice(1);
11
+ return new Date(Date.UTC((0, utilities_1.toInt)(Y), (0, utilities_1.toInt)(M) - 1, (0, utilities_1.toInt)(D), (0, utilities_1.toInt)(h), (0, utilities_1.toInt)(m), (0, utilities_1.toInt)(s)));
12
+ };
13
+ async function gitRepos(h) {
14
+ const headers = { Accept: "application/abapgit.adt.repos.v2+xml" };
15
+ const response = await h.request(`/sap/bc/adt/abapgit/repos`, { headers });
16
+ const raw = (0, utilities_1.parse)(response.body, {
17
+ ignoreAttributes: false,
18
+ parseAttributeValue: false,
19
+ parseTagValue: false,
20
+ removeNSPrefix: true
21
+ });
22
+ return (0, utilities_1.xmlArray)(raw, "repositories", "repository").map((x) => {
23
+ const { key, package: sapPackage, url, status, status_text, } = x;
24
+ // tslint:disable: variable-name
25
+ const branch_name = x.branch_name || x.branchName || "";
26
+ const created_by = x.created_by || x.createdBy || "";
27
+ const created_at = x.created_at || x.createdAt || "";
28
+ const created_email = x.created_email || x.createdEmail || "";
29
+ const deserialized_by = x.deserialized_by || x.deserializedBy || "";
30
+ const deserialized_email = x.deserialized_email || x.deserializedEmail || "";
31
+ const deserialized_at = x.deserialized_at || x.deserializedAt || "";
32
+ const links = (0, utilities_1.xmlArray)(x, "link").map(utilities_1.xmlNodeAttr);
33
+ const repo = {
34
+ key,
35
+ sapPackage,
36
+ url,
37
+ branch_name,
38
+ created_by,
39
+ created_at: parseDate(created_at),
40
+ created_email,
41
+ deserialized_by,
42
+ deserialized_email,
43
+ deserialized_at: deserialized_at && parseDate(deserialized_at),
44
+ status,
45
+ status_text,
46
+ links,
47
+ };
48
+ return repo;
49
+ });
50
+ }
51
+ exports.gitRepos = gitRepos;
52
+ async function externalRepoInfo(h, repourl, user = "", password = "") {
53
+ const headers = {
54
+ "Content-Type": "application/abapgit.adt.repo.info.ext.request.v2+xml",
55
+ Accept: "application/abapgit.adt.repo.info.ext.response.v2+xml",
56
+ };
57
+ const body = `<?xml version="1.0" ?>
58
+ <abapgitexternalrepo:externalRepoInfoRequest xmlns:abapgitexternalrepo="http://www.sap.com/adt/abapgit/externalRepo">
59
+ <abapgitexternalrepo:url>${repourl}</abapgitexternalrepo:url>
60
+ <abapgitexternalrepo:user>${user}</abapgitexternalrepo:user>
61
+ <abapgitexternalrepo:password>${password}</abapgitexternalrepo:password>
62
+ </abapgitexternalrepo:externalRepoInfoRequest>`;
63
+ const response = await h.request(`/sap/bc/adt/abapgit/externalrepoinfo`, {
64
+ method: "POST",
65
+ body,
66
+ headers,
67
+ });
68
+ const raw = (0, utilities_1.fullParse)(response.body, { removeNSPrefix: true });
69
+ // tslint:disable-next-line: variable-name
70
+ const access_mode = (0, utilities_1.xmlNode)(raw, "externalRepoInfo", "accessMode");
71
+ const branches = (0, utilities_1.xmlArray)(raw, "externalRepoInfo", "branch").map((branch) => ({
72
+ name: branch.name,
73
+ type: branch.type,
74
+ sha1: branch.sha1,
75
+ display_name: branch.displayName,
76
+ is_head: (0, utilities_1.boolFromAbap)(branch && branch.is_head),
77
+ }));
78
+ return { access_mode, branches };
79
+ }
80
+ exports.externalRepoInfo = externalRepoInfo;
81
+ const parseObjects = (body) => {
82
+ const raw = (0, utilities_1.fullParse)(body);
83
+ return (0, utilities_1.xmlArray)(raw, "objects", "object").map((r) => {
84
+ const { type, name, package: pkg, status, msgType, msgText, } = r;
85
+ const obj = {
86
+ obj_type: type,
87
+ obj_name: name,
88
+ package: pkg,
89
+ obj_status: status,
90
+ msg_type: msgType,
91
+ msg_text: msgText,
92
+ };
93
+ });
94
+ };
95
+ async function createRepo(h, packageName, repourl, branch = "refs/heads/master", transport = "", user = "", password = "") {
96
+ const headers = {
97
+ "Content-Type": "application/abapgit.adt.repo.v3+xml",
98
+ };
99
+ const body = `<?xml version="1.0" ?>
100
+ <abapgitrepo:repository xmlns:abapgitrepo="http://www.sap.com/adt/abapgit/repositories">
101
+ <abapgitrepo:package>${packageName}</abapgitrepo:package>
102
+ <abapgitrepo:url>${repourl}</abapgitrepo:url>
103
+ <abapgitrepo:branchName>${branch}</abapgitrepo:branchName>
104
+ <abapgitrepo:transportRequest>${transport}</abapgitrepo:transportRequest>
105
+ <abapgitrepo:remoteUser>${user}</abapgitrepo:remoteUser>
106
+ <abapgitrepo:remotePassword>${password}</abapgitrepo:remotePassword>
107
+ </abapgitrepo:repository>`;
108
+ const response = await h.request(`/sap/bc/adt/abapgit/repos`, {
109
+ method: "POST",
110
+ body,
111
+ headers, // encodeEntity?
112
+ });
113
+ return parseObjects(response.body);
114
+ }
115
+ exports.createRepo = createRepo;
116
+ async function pullRepo(h, repoId, branch = "refs/heads/master", transport = "", user = "", password = "") {
117
+ const headers = {
118
+ "Content-Type": "application/abapgit.adt.repo.v3+xml",
119
+ };
120
+ branch = `<abapgitrepo:branchName>${branch}</abapgitrepo:branchName>`;
121
+ transport = transport
122
+ ? `<abapgitrepo:transportRequest>${transport}</abapgitrepo:transportRequest>`
123
+ : "";
124
+ user = user ? `<abapgitrepo:remoteUser>${user}</abapgitrepo:remoteUser>` : "";
125
+ password = password ? `<abapgitrepo:remotePassword>${password}</abapgitrepo:remotePassword>` : "";
126
+ const body = `<?xml version="1.0" ?><abapgitrepo:repository xmlns:abapgitrepo="http://www.sap.com/adt/abapgit/repositories">
127
+ ${branch}${transport}${user}${password}</abapgitrepo:repository>`;
128
+ const response = await h.request(`/sap/bc/adt/abapgit/repos/${repoId}/pull`, {
129
+ method: "POST",
130
+ body,
131
+ headers,
132
+ });
133
+ return parseObjects(response.body);
134
+ }
135
+ exports.pullRepo = pullRepo;
136
+ async function unlinkRepo(h, repoId) {
137
+ const headers = {
138
+ "Content-Type": "application/abapgit.adt.repo.v3+xml",
139
+ };
140
+ await h.request(`/sap/bc/adt/abapgit/repos/${repoId}`, {
141
+ method: "DELETE",
142
+ headers,
143
+ });
144
+ }
145
+ exports.unlinkRepo = unlinkRepo;
146
+ const deserializeStaging = (body) => {
147
+ const raw = (0, utilities_1.xmlNode)((0, utilities_1.fullParse)(body), "abapgitstaging:abapgitstaging");
148
+ const parsefile = (x) => ({
149
+ ...(0, utilities_1.stripNs)((0, utilities_1.xmlNodeAttr)(x)),
150
+ links: (0, utilities_1.xmlArray)(x, "atom:link")
151
+ .map(utilities_1.xmlNodeAttr)
152
+ .map(utilities_1.stripNs)
153
+ .map((l) => ({ ...l, href: l.href })),
154
+ });
155
+ const parseObject = (x) => {
156
+ const attrs = (0, utilities_1.stripNs)((0, utilities_1.xmlNodeAttr)(x));
157
+ const abapGitFiles = (0, utilities_1.xmlArray)(x, "abapgitstaging:abapgitfile").map(parsefile);
158
+ return { ...attrs, abapGitFiles };
159
+ };
160
+ const unstaged = (0, utilities_1.xmlArray)(raw, "abapgitstaging:unstaged_objects", "abapgitstaging:abapgitobject").map(parseObject);
161
+ const staged = (0, utilities_1.xmlArray)(raw, "abapgitstaging:staged_objects", "abapgitstaging:abapgitobject").map(parseObject);
162
+ const ignored = (0, utilities_1.xmlArray)(raw, "abapgitstaging:ignored_objects", "abapgitstaging:abapgitobject").map(parseObject);
163
+ const commentNode = (0, utilities_1.xmlNode)(raw, "abapgitstaging:abapgit_comment");
164
+ const extractUser = (p) => (0, utilities_1.stripNs)((0, utilities_1.xmlNodeAttr)((0, utilities_1.xmlNode)(commentNode, p)));
165
+ const comment = commentNode["@_abapgitstaging:comment"] || "";
166
+ const author = extractUser("abapgitstaging:author");
167
+ const committer = extractUser("abapgitstaging:author");
168
+ const result = {
169
+ staged,
170
+ unstaged,
171
+ ignored,
172
+ comment,
173
+ author,
174
+ committer,
175
+ };
176
+ return result;
177
+ };
178
+ const serializeStaging = (s) => {
179
+ const formatFile = (f) => {
180
+ const { links, ...rest } = f;
181
+ return ` <abapgitstaging:abapgitfile ${(0, utilities_1.toXmlAttributes)(rest, "abapgitstaging")}>${links
182
+ .map((l) => ({ ...l, href: (0, utilities_1.encodeEntity)(l.href) }))
183
+ .map((l) => `<atom:link ${(0, utilities_1.toXmlAttributes)(l, "")}/>`)
184
+ .join("")}
185
+ </abapgitstaging:abapgitfile>`;
186
+ };
187
+ const formatObject = (obj) => {
188
+ const { abapGitFiles, wbkey, ...rest } = obj;
189
+ return `<abapgitstaging:abapgitobject ${(0, utilities_1.toXmlAttributes)(rest, "adtcore")} abapgitstaging:wbkey="${obj.wbkey}">
190
+ ${obj.abapGitFiles.map(formatFile).join("")}
191
+ </abapgitstaging:abapgitobject>`;
192
+ };
193
+ const formatObjects = (objects, root) => {
194
+ if (!objects.length)
195
+ return `<${root}/>`;
196
+ return `<${root}>${objects.map(formatObject).join("")}</${root}>`;
197
+ };
198
+ const unstaged = formatObjects(s.unstaged, "abapgitstaging:unstaged_objects");
199
+ const staged = formatObjects(s.staged, "abapgitstaging:staged_objects");
200
+ const ignored = formatObjects(s.ignored, "abapgitstaging:ignored_objects");
201
+ const comment = `<abapgitstaging:abapgit_comment abapgitstaging:comment="${s.comment}">
202
+ <abapgitstaging:author abapgitstaging:name="${s.author.name}" abapgitstaging:email="${s.author.email}"/>
203
+ <abapgitstaging:committer abapgitstaging:name="${s.committer.name}" abapgitstaging:email="${s.committer.email}"/>
204
+ </abapgitstaging:abapgit_comment>
205
+ `;
206
+ return `<?xml version="1.0" encoding="UTF-8"?>
207
+ <abapgitstaging:abapgitstaging xmlns:abapgitstaging="http://www.sap.com/adt/abapgit/staging"
208
+ xmlns:adtcore="http://www.sap.com/adt/core"
209
+ xmlns:atom="http://www.w3.org/2005/Atom">
210
+ ${unstaged}
211
+ ${staged}
212
+ ${ignored}
213
+ ${comment}
214
+ </abapgitstaging:abapgitstaging>`;
215
+ };
216
+ async function checkRepo(h, repo, user = "", password = "") {
217
+ const clink = repo.links.find((l) => l.type === "check_link");
218
+ if (!(clink === null || clink === void 0 ? void 0 : clink.href))
219
+ throw (0, AdtException_1.adtException)("Check link not found");
220
+ const headers = {
221
+ Accept: "text/plain",
222
+ };
223
+ if (user)
224
+ headers.Username = user;
225
+ if (password)
226
+ headers.Password = (0, utilities_1.btoa)(password);
227
+ await h.request(clink.href, { method: "POST", headers });
228
+ }
229
+ exports.checkRepo = checkRepo;
230
+ async function pushRepo(h, repo, staging, user = "", password = "") {
231
+ const link = repo.links.find((l) => l.type === "push_link");
232
+ if (!(link === null || link === void 0 ? void 0 : link.href))
233
+ throw (0, AdtException_1.adtException)("Push link not found");
234
+ const headers = {
235
+ Accept: "application/abapgit.adt.repo.stage.v1+xml",
236
+ };
237
+ headers["Content-Type"] = headers.Accept;
238
+ if (user)
239
+ headers.Username = user;
240
+ if (password)
241
+ headers.Password = (0, utilities_1.btoa)(password);
242
+ const body = serializeStaging(staging);
243
+ await h.request(link.href, { method: "POST", headers, body });
244
+ }
245
+ exports.pushRepo = pushRepo;
246
+ async function stageRepo(h, repo, user = "", password = "") {
247
+ const link = repo.links.find((l) => l.type === "stage_link");
248
+ if (!(link === null || link === void 0 ? void 0 : link.href))
249
+ throw (0, AdtException_1.adtException)("Stage link not found");
250
+ const headers = {
251
+ "Content-Type": "application/abapgit.adt.repo.stage.v1+xml",
252
+ };
253
+ if (user)
254
+ headers.Username = user;
255
+ if (password)
256
+ headers.Password = (0, utilities_1.btoa)(password);
257
+ const resp = await h.request(link.href, { headers });
258
+ return deserializeStaging(resp.body);
259
+ }
260
+ exports.stageRepo = stageRepo;
261
+ /**
262
+ * @deprecated since 1.2.1, duplicate of externalRepoInfo
263
+ */
264
+ async function remoteRepoInfo(h, repo, user = "", password = "") {
265
+ var _a;
266
+ const headers = {
267
+ "Content-Type": "application/abapgit.adt.repo.info.ext.request.v1+xml",
268
+ Accept: "application/abapgit.adt.repo.info.ext.response.v1+xml",
269
+ };
270
+ const body = `<?xml version="1.0" encoding="UTF-8"?>
271
+ <repository_ext>
272
+ <url>${repo.url}</url>
273
+ <user>${user}</user>
274
+ <password>${password}</password>
275
+ </repository_ext>`;
276
+ const resp = await h.request("/sap/bc/adt/abapgit/externalrepoinfo", {
277
+ headers,
278
+ body,
279
+ method: "POST",
280
+ });
281
+ const raw = (_a = (0, utilities_1.parse)(resp.body)) === null || _a === void 0 ? void 0 : _a.repository_external;
282
+ const { access_mode, branches } = raw;
283
+ return {
284
+ access_mode,
285
+ branches: (0, utilities_1.xmlArray)(branches, "branch"),
286
+ };
287
+ }
288
+ exports.remoteRepoInfo = remoteRepoInfo;
289
+ async function switchRepoBranch(h, repo, branch, create = false, user = "", password = "") {
290
+ const headers = {};
291
+ if (user)
292
+ headers.Username = user;
293
+ if (password)
294
+ headers.Password = (0, utilities_1.btoa)(password);
295
+ await h.request(`/sap/bc/adt/abapgit/repos/${repo.key}/branches/${encodeURIComponent(branch)}?create=${create}`, {
296
+ headers,
297
+ method: "POST",
298
+ });
299
+ }
300
+ exports.switchRepoBranch = switchRepoBranch;
@@ -0,0 +1,39 @@
1
+ import { AdtHTTP } from "../AdtHTTP";
2
+ export interface InactiveObject {
3
+ "adtcore:uri": string;
4
+ "adtcore:type": string;
5
+ "adtcore:name": string;
6
+ "adtcore:parentUri": string;
7
+ }
8
+ export interface InactiveObjectElement extends InactiveObject {
9
+ user: string;
10
+ deleted: boolean;
11
+ }
12
+ export interface InactiveObjectRecord {
13
+ object?: InactiveObjectElement;
14
+ transport?: InactiveObjectElement;
15
+ }
16
+ export interface ActivationResultMessage {
17
+ objDescr: string;
18
+ type: string;
19
+ line: number;
20
+ href: string;
21
+ forceSupported: boolean;
22
+ shortText: string;
23
+ }
24
+ export interface ActivationResult {
25
+ success: boolean;
26
+ messages: ActivationResultMessage[];
27
+ inactive: InactiveObjectRecord[];
28
+ }
29
+ export interface MainInclude {
30
+ "adtcore:uri": string;
31
+ "adtcore:type": string;
32
+ "adtcore:name": string;
33
+ }
34
+ export declare function activate(h: AdtHTTP, object: InactiveObject | InactiveObject[], preauditRequested?: boolean): Promise<ActivationResult>;
35
+ export declare function activate(h: AdtHTTP, objectName: string, objectUrl: string, mainInclude?: string, preauditRequested?: boolean): Promise<ActivationResult>;
36
+ export declare function mainPrograms(h: AdtHTTP, IncludeUrl: string): Promise<MainInclude[]>;
37
+ export declare function inactiveObjectsInResults(results: ActivationResult): InactiveObject[];
38
+ export declare function inactiveObjects(h: AdtHTTP): Promise<InactiveObjectRecord[]>;
39
+ //# sourceMappingURL=activate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activate.d.ts","sourceRoot":"","sources":["../../src/api/activate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AACD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB;AACD,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,SAAS,CAAC,EAAE,qBAAqB,CAAA;CAClC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,OAAO,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB;AACD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,uBAAuB,EAAE,CAAA;IACnC,QAAQ,EAAE,oBAAoB,EAAE,CAAA;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;CACvB;AAoBD,wBAAsB,QAAQ,CAC5B,CAAC,EAAE,OAAO,EACV,MAAM,EAAE,cAAc,GAAG,cAAc,EAAE,EACzC,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC5B,wBAAsB,QAAQ,CAC5B,CAAC,EAAE,OAAO,EACV,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAoE5B,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAShE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,gBAAgB,GACxB,cAAc,EAAE,CAMlB;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,mCAW/C"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inactiveObjects = exports.inactiveObjectsInResults = exports.mainPrograms = exports.activate = void 0;
4
+ const AdtException_1 = require("../AdtException");
5
+ const utilities_1 = require("../utilities");
6
+ function toElement(source) {
7
+ if (!source || !source["ioc:ref"])
8
+ return undefined;
9
+ return {
10
+ deleted: source["@_ioc:deleted"],
11
+ user: source["@_ioc:user"],
12
+ ...(0, utilities_1.xmlNodeAttr)(source["ioc:ref"])
13
+ };
14
+ }
15
+ function parseInactive(raw) {
16
+ return (0, utilities_1.xmlArray)(raw, "ioc:inactiveObjects", "ioc:entry").map((obj) => {
17
+ return {
18
+ object: toElement((0, utilities_1.xmlNode)(obj, "ioc:object")),
19
+ transport: toElement((0, utilities_1.xmlNode)(obj, "ioc:transport"))
20
+ };
21
+ });
22
+ }
23
+ async function activate(h, objectNameOrObjects, objectUrlOrPreauditReq = true, mainInclude, preauditRequested = true) {
24
+ let objects = [];
25
+ let incl = "";
26
+ if ((0, utilities_1.isString)(objectNameOrObjects)) {
27
+ if (!(0, utilities_1.isString)(objectUrlOrPreauditReq))
28
+ throw (0, AdtException_1.adtException)("Invalid parameters, objectUrl should be a string");
29
+ (0, AdtException_1.ValidateObjectUrl)(objectUrlOrPreauditReq || "");
30
+ if (mainInclude)
31
+ incl = `?context=${encodeURIComponent(mainInclude)}`;
32
+ objects.push(`<adtcore:objectReference adtcore:uri="${objectUrlOrPreauditReq}${incl}" adtcore:name="${objectNameOrObjects}"/>`);
33
+ }
34
+ else {
35
+ let inactives;
36
+ if ((0, utilities_1.isString)(objectUrlOrPreauditReq))
37
+ throw (0, AdtException_1.adtException)("Invalid parameters, preauditRequested should be a boolean");
38
+ preauditRequested = objectUrlOrPreauditReq;
39
+ if ((0, utilities_1.isArray)(objectNameOrObjects)) {
40
+ inactives = objectNameOrObjects;
41
+ }
42
+ else
43
+ inactives = [objectNameOrObjects];
44
+ inactives.forEach(i => (0, AdtException_1.ValidateObjectUrl)(i["adtcore:uri"]));
45
+ objects = inactives.map(i => `<adtcore:objectReference adtcore:uri="${i["adtcore:uri"]}" adtcore:type="${i["adtcore:type"]}" adtcore:parentUri="${i["adtcore:parentUri"]}" adtcore:name="${i["adtcore:name"]}"/>`);
46
+ }
47
+ const qs = { method: "activate", preauditRequested };
48
+ const body = `<?xml version="1.0" encoding="UTF-8"?>` +
49
+ `<adtcore:objectReferences xmlns:adtcore="http://www.sap.com/adt/core">` +
50
+ objects.join(`\n`) +
51
+ `</adtcore:objectReferences>`;
52
+ const response = await h.request("/sap/bc/adt/activation", {
53
+ body,
54
+ method: "POST",
55
+ qs
56
+ });
57
+ let messages = [];
58
+ let success = true;
59
+ let inactive = [];
60
+ if (response.body) {
61
+ const raw = (0, utilities_1.fullParse)(response.body);
62
+ inactive = parseInactive(raw);
63
+ messages = (0, utilities_1.xmlArray)(raw, "chkl:messages", "msg").map((m) => {
64
+ const message = (0, utilities_1.xmlNodeAttr)(m);
65
+ message.shortText = (m.shortText && m.shortText.txt) || "Syntax error";
66
+ return message;
67
+ });
68
+ if (inactive.length > 0)
69
+ success = false;
70
+ else
71
+ messages.some(m => {
72
+ if (m.type.match(/[EAX]/))
73
+ success = false;
74
+ return !success;
75
+ });
76
+ }
77
+ return { messages, success, inactive };
78
+ }
79
+ exports.activate = activate;
80
+ async function mainPrograms(h, IncludeUrl) {
81
+ (0, AdtException_1.ValidateObjectUrl)(IncludeUrl);
82
+ const response = await h.request(`${IncludeUrl}/mainprograms`);
83
+ const parsed = (0, utilities_1.fullParse)(response.body);
84
+ const includes = (0, utilities_1.xmlArray)(parsed["adtcore:objectReferences"], "adtcore:objectReference").map(utilities_1.xmlNodeAttr);
85
+ return includes;
86
+ }
87
+ exports.mainPrograms = mainPrograms;
88
+ function inactiveObjectsInResults(results) {
89
+ const obj = results.inactive.filter(x => x.object).map(x => x.object);
90
+ return obj.map(o => {
91
+ const { user, deleted, ...rest } = o;
92
+ return rest;
93
+ });
94
+ }
95
+ exports.inactiveObjectsInResults = inactiveObjectsInResults;
96
+ async function inactiveObjects(h) {
97
+ const headers = {
98
+ Accept: "application/vnd.sap.adt.inactivectsobjects.v1+xml, application/xml;q=0.8"
99
+ };
100
+ const response = await h.request("/sap/bc/adt/activation/inactiveobjects", {
101
+ headers
102
+ });
103
+ return parseInactive((0, utilities_1.fullParse)(response.body));
104
+ }
105
+ exports.inactiveObjects = inactiveObjects;
@@ -0,0 +1,163 @@
1
+ import { AdtHTTP } from "../AdtHTTP";
2
+ import { Clean } from "../utilities";
3
+ import * as t from "io-ts";
4
+ declare const atcProposal: t.IntersectionC<[t.TypeC<{
5
+ finding: t.UnionC<[t.IntersectionC<[t.TypeC<{
6
+ uri: t.StringC;
7
+ type: t.StringC;
8
+ name: t.StringC;
9
+ location: t.StringC;
10
+ processor: t.StringC;
11
+ lastChangedBy: t.StringC;
12
+ priority: t.NumberC;
13
+ checkId: t.StringC;
14
+ checkTitle: t.StringC;
15
+ messageId: t.StringC;
16
+ messageTitle: t.StringC;
17
+ exemptionApproval: t.StringC;
18
+ exemptionKind: t.UnionC<[t.LiteralC<"A">, t.LiteralC<"I">, t.LiteralC<"">, t.StringC]>;
19
+ checksum: t.NumberC;
20
+ quickfixInfo: t.StringC;
21
+ }>, t.PartialC<{
22
+ quickfixes: t.PartialC<{
23
+ automatic: t.BooleanC;
24
+ manual: t.BooleanC;
25
+ pseudo: t.BooleanC;
26
+ }>;
27
+ }>]>, t.StringC]>;
28
+ package: t.StringC;
29
+ subObject: t.StringC;
30
+ subObjectType: t.StringC;
31
+ subObjectTypeDescr: t.StringC;
32
+ objectTypeDescr: t.StringC;
33
+ approver: t.StringC;
34
+ reason: t.UnionC<[t.LiteralC<"FPOS">, t.LiteralC<"OTHR">, t.LiteralC<"">]>;
35
+ justification: t.StringC;
36
+ notify: t.UnionC<[t.LiteralC<"never">, t.LiteralC<"on_rejection">, t.LiteralC<"always">]>;
37
+ restriction: t.TypeC<{
38
+ enabled: t.BooleanC;
39
+ singlefinding: t.BooleanC;
40
+ rangeOfFindings: t.TypeC<{
41
+ enabled: t.BooleanC;
42
+ restrictByObject: t.TypeC<{
43
+ object: t.BooleanC;
44
+ package: t.BooleanC;
45
+ subobject: t.BooleanC;
46
+ target: t.UnionC<[t.LiteralC<"subobject">, t.LiteralC<"object">, t.LiteralC<"package">, t.LiteralC<"">]>;
47
+ }>;
48
+ restrictByCheck: t.TypeC<{
49
+ check: t.BooleanC;
50
+ message: t.BooleanC;
51
+ target: t.UnionC<[t.LiteralC<"message">, t.LiteralC<"check">, t.LiteralC<"">]>;
52
+ }>;
53
+ }>;
54
+ }>;
55
+ }>, t.PartialC<{
56
+ apprIsArea: t.StringC;
57
+ checkClass: t.StringC;
58
+ validUntil: t.StringC;
59
+ }>]>;
60
+ declare const atcProposalMessage: t.TypeC<{
61
+ type: t.StringC;
62
+ message: t.StringC;
63
+ }>;
64
+ export interface RestrictByObject {
65
+ object: boolean;
66
+ package: boolean;
67
+ subobject: boolean;
68
+ text: string;
69
+ }
70
+ declare const atcRunResult: t.TypeC<{
71
+ id: t.StringC;
72
+ timestamp: t.NumberC;
73
+ infos: t.ArrayC<t.TypeC<{
74
+ type: t.StringC;
75
+ description: t.StringC;
76
+ }>>;
77
+ }>;
78
+ declare const atcCustomizingi: t.TypeC<{
79
+ properties: t.ArrayC<t.TypeC<{
80
+ name: t.StringC;
81
+ value: t.UnionC<[t.BooleanC, t.StringC]>;
82
+ }>>;
83
+ excemptions: t.ArrayC<t.TypeC<{
84
+ id: t.StringC;
85
+ justificationMandatory: t.BooleanC;
86
+ title: t.StringC;
87
+ }>>;
88
+ }>;
89
+ declare const atcWorklist: t.TypeC<{
90
+ id: t.StringC;
91
+ timestamp: t.NumberC;
92
+ usedObjectSet: t.StringC;
93
+ objectSetIsComplete: t.BooleanC;
94
+ objectSets: t.ArrayC<t.TypeC<{
95
+ name: t.StringC;
96
+ title: t.StringC;
97
+ kind: t.StringC;
98
+ }>>;
99
+ objects: t.ArrayC<t.TypeC<{
100
+ uri: t.StringC;
101
+ type: t.StringC;
102
+ name: t.StringC;
103
+ packageName: t.StringC;
104
+ author: t.StringC;
105
+ objectTypeId: t.UnionC<[t.UndefinedC, t.StringC]>;
106
+ findings: t.ArrayC<t.TypeC<{
107
+ uri: t.StringC;
108
+ location: t.TypeC<{
109
+ uri: t.StringC;
110
+ query: t.UnionC<[t.UndefinedC, t.RecordC<t.StringC, t.StringC>]>;
111
+ range: t.TypeC<{
112
+ start: t.TypeC<{
113
+ line: t.NumberC;
114
+ column: t.NumberC;
115
+ }>;
116
+ end: t.TypeC<{
117
+ line: t.NumberC;
118
+ column: t.NumberC;
119
+ }>;
120
+ }>;
121
+ hashparms: t.UnionC<[t.UndefinedC, t.RecordC<t.StringC, t.StringC>]>;
122
+ }>;
123
+ priority: t.NumberC;
124
+ checkId: t.StringC;
125
+ checkTitle: t.StringC;
126
+ messageId: t.StringC;
127
+ messageTitle: t.StringC;
128
+ exemptionApproval: t.StringC;
129
+ exemptionKind: t.UnionC<[t.LiteralC<"A">, t.LiteralC<"I">, t.LiteralC<"">, t.StringC]>;
130
+ quickfixInfo: t.UnionC<[t.UndefinedC, t.StringC]>;
131
+ link: t.TypeC<{
132
+ href: t.StringC;
133
+ rel: t.StringC;
134
+ type: t.StringC;
135
+ }>;
136
+ }>>;
137
+ }>>;
138
+ }>;
139
+ declare const atcUser: t.TypeC<{
140
+ id: t.StringC;
141
+ title: t.StringC;
142
+ }>;
143
+ export type AtcRunResult = Clean<t.TypeOf<typeof atcRunResult>>;
144
+ export type AtcCustomizing = Clean<t.TypeOf<typeof atcCustomizingi>>;
145
+ export type AtcWorkList = Clean<t.TypeOf<typeof atcWorklist>>;
146
+ export type AtcUser = Clean<t.TypeOf<typeof atcUser>>;
147
+ export type AtcProposal = Clean<t.TypeOf<typeof atcProposal>>;
148
+ export type AtcProposalMessage = Clean<t.TypeOf<typeof atcProposalMessage>>;
149
+ export declare const isProposalMessage: t.Is<{
150
+ type: string;
151
+ message: string;
152
+ }>;
153
+ export declare function atcCustomizing(h: AdtHTTP): Promise<AtcCustomizing>;
154
+ export declare function atcCheckVariant(h: AdtHTTP, variant: string): Promise<string>;
155
+ export declare function createAtcRun(h: AdtHTTP, variant: string, mainUrl: string, maxResults?: number): Promise<AtcRunResult>;
156
+ export declare function atcWorklists(h: AdtHTTP, runResultId: string, timestamp?: number, usedObjectSet?: string, includeExemptedFindings?: boolean): Promise<AtcWorkList>;
157
+ export declare function atcUsers(h: AdtHTTP): Promise<AtcUser[]>;
158
+ export declare function atcExemptProposal(h: AdtHTTP, markerId: string): Promise<AtcProposal | AtcProposalMessage>;
159
+ export declare function atcRequestExemption(h: AdtHTTP, proposal: AtcProposal): Promise<AtcProposalMessage>;
160
+ export declare function atcContactUri(h: AdtHTTP, findingUri: string): Promise<string>;
161
+ export declare function atcChangeContact(h: AdtHTTP, itemUri: string, userId: string): Promise<void>;
162
+ export {};
163
+ //# sourceMappingURL=atc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atc.d.ts","sourceRoot":"","sources":["../../src/api/atc.ts"],"names":[],"mappings":"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"}