@st-gr/abap-adt-skill 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.
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transportInfoCommand = transportInfoCommand;
4
+ exports.transportCreateCommand = transportCreateCommand;
5
+ exports.transportReleaseCommand = transportReleaseCommand;
6
+ exports.transportListCommand = transportListCommand;
7
+ exports.transportDeleteCommand = transportDeleteCommand;
8
+ const client_1 = require("../client");
9
+ const formatter_1 = require("../util/formatter");
10
+ async function transportInfoCommand(objectUrl, options) {
11
+ const client = await (0, client_1.getClient)();
12
+ const info = await client.transportInfo(objectUrl, options.devclass);
13
+ if (options.json) {
14
+ (0, formatter_1.output)(info, true);
15
+ return;
16
+ }
17
+ console.log(`Object: ${info.OBJECTNAME} (${info.OBJECT})`);
18
+ console.log(`Package: ${info.DEVCLASS}`);
19
+ console.log(`Operation: ${info.OPERATION}`);
20
+ console.log(`Result: ${info.RESULT}`);
21
+ console.log(`Recording: ${info.RECORDING}`);
22
+ if (info.LOCKS) {
23
+ console.log(`\nLocked by transport: ${info.LOCKS.HEADER.TRKORR}`);
24
+ console.log(` Owner: ${info.LOCKS.HEADER.AS4USER}`);
25
+ console.log(` Description: ${info.LOCKS.HEADER.AS4TEXT}`);
26
+ }
27
+ if (info.TRANSPORTS && info.TRANSPORTS.length > 0) {
28
+ console.log("\nAvailable transports:");
29
+ for (const t of info.TRANSPORTS) {
30
+ console.log(` ${t.TRKORR} - ${t.AS4TEXT} (${t.AS4USER}, ${t.TRSTATUS})`);
31
+ }
32
+ }
33
+ }
34
+ async function transportCreateCommand(objectUrl, options) {
35
+ const client = await (0, client_1.getClient)();
36
+ const transport = await client.createTransport(objectUrl, options.description, options.devclass);
37
+ if (options.json) {
38
+ (0, formatter_1.output)({ transport }, true);
39
+ return;
40
+ }
41
+ console.log(`Transport created: ${transport}`);
42
+ }
43
+ async function transportReleaseCommand(transportNumber, options) {
44
+ const client = await (0, client_1.getClient)();
45
+ const reports = await client.transportRelease(transportNumber, options.ignoreLocks || false, options.ignoreAtc || false);
46
+ if (options.json) {
47
+ (0, formatter_1.output)(reports, true);
48
+ return;
49
+ }
50
+ for (const report of reports) {
51
+ console.log(`Reporter: ${report["chkrun:reporter"]}`);
52
+ console.log(`Status: ${report["chkrun:status"]}`);
53
+ console.log(`Status Text: ${report["chkrun:statusText"]}`);
54
+ if (report.messages && report.messages.length > 0) {
55
+ for (const msg of report.messages) {
56
+ console.log(` [${msg["chkrun:type"]}] ${msg["chkrun:shortText"]}`);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ async function transportListCommand(options) {
62
+ const client = await (0, client_1.getClient)();
63
+ const user = options.user || client.username;
64
+ const transports = await client.userTransports(user);
65
+ if (options.json) {
66
+ (0, formatter_1.output)(transports, true);
67
+ return;
68
+ }
69
+ const printRequests = (requests, indent) => {
70
+ for (const req of requests) {
71
+ console.log(`${indent}${req["tm:number"]} - ${req["tm:desc"]} (${req["tm:owner"]}, ${req["tm:status"]})`);
72
+ if (req.tasks) {
73
+ for (const task of req.tasks) {
74
+ console.log(`${indent} Task: ${task["tm:number"]} - ${task["tm:desc"]} (${task["tm:owner"]})`);
75
+ }
76
+ }
77
+ }
78
+ };
79
+ for (const target of transports.workbench) {
80
+ console.log(`\nWorkbench Target: ${target["tm:name"]} (${target["tm:desc"]})`);
81
+ if (target.modifiable.length > 0) {
82
+ console.log(" Modifiable:");
83
+ printRequests(target.modifiable, " ");
84
+ }
85
+ if (target.released.length > 0) {
86
+ console.log(" Released:");
87
+ printRequests(target.released, " ");
88
+ }
89
+ }
90
+ for (const target of transports.customizing) {
91
+ console.log(`\nCustomizing Target: ${target["tm:name"]} (${target["tm:desc"]})`);
92
+ if (target.modifiable.length > 0) {
93
+ console.log(" Modifiable:");
94
+ printRequests(target.modifiable, " ");
95
+ }
96
+ if (target.released.length > 0) {
97
+ console.log(" Released:");
98
+ printRequests(target.released, " ");
99
+ }
100
+ }
101
+ }
102
+ async function transportDeleteCommand(transportNumber, options) {
103
+ const client = await (0, client_1.getClient)();
104
+ await client.transportDelete(transportNumber);
105
+ if (options.json) {
106
+ (0, formatter_1.output)({ deleted: transportNumber }, true);
107
+ return;
108
+ }
109
+ console.log(`Transport deleted: ${transportNumber}`);
110
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usersCommand = usersCommand;
4
+ const client_1 = require("../client");
5
+ async function usersCommand(options) {
6
+ const client = await (0, client_1.getStatelessClient)();
7
+ const users = await client.systemUsers();
8
+ if (options.json) {
9
+ console.log(JSON.stringify(users, null, 2));
10
+ return;
11
+ }
12
+ if (users.length === 0) {
13
+ console.log("No users found.");
14
+ return;
15
+ }
16
+ for (const u of users) {
17
+ console.log(`${u.id} ${u.title || ""}`);
18
+ }
19
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.whereusedCommand = whereusedCommand;
4
+ const client_1 = require("../client");
5
+ async function whereusedCommand(objectUrl, options) {
6
+ var _a;
7
+ const client = await (0, client_1.getStatelessClient)();
8
+ const line = options.line ? parseInt(options.line) : undefined;
9
+ const column = options.column ? parseInt(options.column) : undefined;
10
+ const refs = await client.usageReferences(objectUrl, line, column);
11
+ if (options.json) {
12
+ console.log(JSON.stringify(refs, null, 2));
13
+ return;
14
+ }
15
+ if (refs.length === 0) {
16
+ console.log("No references found.");
17
+ return;
18
+ }
19
+ console.log(`Found ${refs.length} reference(s):\n`);
20
+ for (const ref of refs) {
21
+ const name = ref["adtcore:name"] || "";
22
+ const type = ref["adtcore:type"] || "";
23
+ const uri = ref.uri || "";
24
+ const pkg = ((_a = ref.packageRef) === null || _a === void 0 ? void 0 : _a["adtcore:name"]) || "";
25
+ console.log(` ${padRight(name, 30)} ${padRight(type, 12)} ${padRight(pkg, 16)} ${uri}`);
26
+ }
27
+ }
28
+ function padRight(s, len) {
29
+ return s.length >= len ? s : s + " ".repeat(len - s.length);
30
+ }
@@ -0,0 +1,131 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.writeCommand = writeCommand;
37
+ const fs = __importStar(require("fs"));
38
+ const abap_adt_api_patched_1 = require("@st-gr/abap-adt-api-patched");
39
+ const client_1 = require("../client");
40
+ async function writeCommand(objectUrl, options) {
41
+ if (!fs.existsSync(options.sourceFile)) {
42
+ console.error(`Source file not found: ${options.sourceFile}`);
43
+ process.exit(1);
44
+ }
45
+ const source = fs.readFileSync(options.sourceFile, "utf-8");
46
+ // Resolve source URL and object URL BEFORE entering stateful session
47
+ const client = await (0, client_1.getClient)();
48
+ let sourceUrl = objectUrl;
49
+ let lockUrl = objectUrl;
50
+ let needsTestIncludeCreation = false;
51
+ let className = "";
52
+ // Handle class includes (e.g. /sap/bc/adt/oo/classes/zcl_foo/includes/testclasses)
53
+ const includeMatch = objectUrl.match(/^(\/sap\/bc\/adt\/oo\/classes\/([^/]+))\/includes\/(\w+)$/);
54
+ if (includeMatch) {
55
+ lockUrl = includeMatch[1]; // lock the class, not the include
56
+ className = includeMatch[2];
57
+ const includeName = includeMatch[3];
58
+ // Check if this include already exists
59
+ const struct = await client.statelessClone.objectStructure(lockUrl);
60
+ if ((0, abap_adt_api_patched_1.isClassStructure)(struct)) {
61
+ const includes = abap_adt_api_patched_1.ADTClient.classIncludes(struct);
62
+ const existing = includes.get(includeName);
63
+ if (existing) {
64
+ sourceUrl = existing;
65
+ }
66
+ else if (includeName === "testclasses") {
67
+ needsTestIncludeCreation = true;
68
+ sourceUrl = objectUrl;
69
+ }
70
+ else {
71
+ console.error(`Include '${includeName}' not found. Available: ${Array.from(includes.keys()).join(", ")}`);
72
+ process.exit(1);
73
+ }
74
+ }
75
+ }
76
+ else if (!objectUrl.includes("/source/")) {
77
+ const struct = await client.statelessClone.objectStructure(objectUrl);
78
+ sourceUrl = abap_adt_api_patched_1.ADTClient.mainInclude(struct);
79
+ }
80
+ await (0, client_1.withStatefulSession)(async (c) => {
81
+ // Lock the OBJECT URL (not the source URL) — SAP ADT requires locking the object, not its source
82
+ const lock = await c.lock(lockUrl);
83
+ const lockHandle = lock.LOCK_HANDLE;
84
+ try {
85
+ // Determine transport
86
+ let transport = options.transport || lock.CORRNR;
87
+ if (!transport) {
88
+ const info = await c.transportInfo(sourceUrl !== objectUrl ? sourceUrl : lockUrl);
89
+ if (info.RECORDING && info.RECORDING !== " ") {
90
+ if (info.TRANSPORTS && info.TRANSPORTS.length > 0) {
91
+ transport = info.TRANSPORTS[0].TRKORR;
92
+ console.log(`Using transport: ${transport} (${info.TRANSPORTS[0].AS4TEXT})`);
93
+ }
94
+ else {
95
+ console.error("Transport required but none available. Create one with: transport create");
96
+ console.error(`Package: ${info.DEVCLASS}`);
97
+ await c.unLock(lockUrl, lockHandle);
98
+ process.exit(1);
99
+ }
100
+ }
101
+ }
102
+ // Create testclasses include if it doesn't exist yet
103
+ if (needsTestIncludeCreation) {
104
+ await c.createTestInclude(className, lockHandle, transport || "");
105
+ // Re-read structure to get the actual source URI
106
+ const struct = await c.objectStructure(lockUrl);
107
+ if ((0, abap_adt_api_patched_1.isClassStructure)(struct)) {
108
+ const includes = abap_adt_api_patched_1.ADTClient.classIncludes(struct);
109
+ const testUrl = includes.get("testclasses");
110
+ if (testUrl) {
111
+ sourceUrl = testUrl;
112
+ }
113
+ }
114
+ }
115
+ // Write source to the SOURCE URL (with lock handle obtained from object lock)
116
+ await c.setObjectSource(sourceUrl, source, lockHandle, transport || undefined);
117
+ console.log(`Source written successfully to ${sourceUrl}`);
118
+ if (transport) {
119
+ console.log(`Transport: ${transport}`);
120
+ }
121
+ }
122
+ finally {
123
+ try {
124
+ await c.unLock(lockUrl, lockHandle);
125
+ }
126
+ catch (_a) {
127
+ // Ignore unlock errors
128
+ }
129
+ }
130
+ });
131
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Combined debug test: set breakpoint + listen in a single stateful session.
5
+ */
6
+ const abap_adt_api_1 = require("abap-adt-api");
7
+ const ADT_URL = process.env.ADT_URL;
8
+ const ADT_USER = process.env.ADT_USER;
9
+ const ADT_PASS = process.env.ADT_PASS;
10
+ const ADT_CLIENT = process.env.ADT_CLIENT || "";
11
+ async function main() {
12
+ const client = new abap_adt_api_1.ADTClient(ADT_URL, ADT_USER, ADT_PASS, ADT_CLIENT, "EN", (0, abap_adt_api_1.createSSLConfig)(true));
13
+ await client.login();
14
+ client.stateful = abap_adt_api_1.session_types.stateful;
15
+ const terminalId = "DEBUG-TEST-001";
16
+ const ideId = "DEBUG-IDE-TEST-001";
17
+ const clientId = "BP-CLIENT-001";
18
+ const user = ADT_USER;
19
+ // Step 1: Set external breakpoint on line 5 of ZSGR_TEST_42
20
+ console.log("\n=== Setting external breakpoint on line 5 ===");
21
+ const bpUri = "/sap/bc/adt/programs/programs/zsgr_test_42/source/main#start=5";
22
+ const bpResult = await client.debuggerSetBreakpoints("user", terminalId, ideId, clientId, [bpUri], user);
23
+ console.log("Breakpoint result:", JSON.stringify(bpResult, null, 2));
24
+ // Step 3: Listen (blocks until breakpoint hit or timeout)
25
+ console.log("\n=== Listening for debuggee (90s timeout) ===");
26
+ console.log(">>> Run ZSGR_TEST_42 in SE38 now! <<<");
27
+ // Use a timeout wrapper
28
+ const timeoutMs = 90000;
29
+ const listenPromise = client.debuggerListen("user", terminalId, ideId, user);
30
+ const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(null), timeoutMs));
31
+ const result = await Promise.race([listenPromise, timeoutPromise]);
32
+ if (!result) {
33
+ console.log("\nTimeout — no debuggee caught.");
34
+ }
35
+ else {
36
+ console.log("\n=== DEBUGGEE CAUGHT! ===");
37
+ console.log(JSON.stringify(result, null, 2));
38
+ }
39
+ // Cleanup
40
+ try {
41
+ await client.debuggerDeleteListener("user", terminalId, ideId, user);
42
+ }
43
+ catch (_a) { }
44
+ client.stateful = abap_adt_api_1.session_types.stateless;
45
+ client.dropSession();
46
+ }
47
+ main().catch(e => { console.error("Fatal:", e.message); process.exit(1); });
@@ -0,0 +1,144 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ /**
37
+ * Raw HTTP diagnostic: manually construct the lock → write → unlock sequence
38
+ * and dump every detail. Uses Node.js http module directly (no axios).
39
+ */
40
+ const http = __importStar(require("http"));
41
+ const abap_adt_api_1 = require("abap-adt-api");
42
+ const ADT_URL = process.env.ADT_URL;
43
+ const ADT_USER = process.env.ADT_USER;
44
+ const ADT_PASS = process.env.ADT_PASS;
45
+ const ADT_CLIENT = process.env.ADT_CLIENT || "";
46
+ async function main() {
47
+ // Step 1: Use the library to log in + lock (these work fine via POST)
48
+ const client = new abap_adt_api_1.ADTClient(ADT_URL, ADT_USER, ADT_PASS, ADT_CLIENT, "EN", (0, abap_adt_api_1.createSSLConfig)(true));
49
+ await client.login();
50
+ client.stateful = abap_adt_api_1.session_types.stateful;
51
+ const objectUrl = "/sap/bc/adt/programs/programs/zsgr_test_42";
52
+ const sourceUrl = objectUrl + "/source/main";
53
+ console.log("=== LOCKING (via library) ===");
54
+ const lock = await client.lock(objectUrl);
55
+ console.log("Lock handle:", lock.LOCK_HANDLE);
56
+ console.log("Transport:", lock.CORRNR);
57
+ // Step 2: Extract session state from the library's HTTP handler
58
+ const h = client.h; // Access private AdtHTTP instance
59
+ const cookies = h.ascookies();
60
+ const csrfToken = h.csrfToken;
61
+ const baseURL = h.baseURL;
62
+ console.log("\n=== SESSION STATE ===");
63
+ console.log("Base URL:", baseURL);
64
+ console.log("Cookies:", cookies);
65
+ console.log("CSRF token:", csrfToken);
66
+ // Step 3: Make PUT request with raw Node.js http
67
+ const source = `REPORT zsgr_test_42.\n\nDATA lv_value TYPE i.\n\nBREAK-POINT.\nlv_value = 42.\nBREAK-POINT.\n\nWRITE: / 'The value is:', lv_value.\n`;
68
+ const sourceBytes = Buffer.from(source, "utf-8");
69
+ const parsed = new URL(baseURL);
70
+ const putPath = `${sourceUrl}?lockHandle=${encodeURIComponent(lock.LOCK_HANDLE)}${ADT_CLIENT ? `&sap-client=${ADT_CLIENT}` : ""}`;
71
+ const putHeaders = {
72
+ "Content-Type": "text/plain; charset=utf-8",
73
+ "Content-Length": String(sourceBytes.length),
74
+ "Cookie": cookies,
75
+ "x-csrf-token": csrfToken,
76
+ "X-sap-adt-sessiontype": "stateful",
77
+ "Authorization": "Basic " + Buffer.from(`${ADT_USER}:${ADT_PASS}`).toString("base64"),
78
+ "Accept": "*/*",
79
+ "Cache-Control": "no-cache",
80
+ "Connection": "keep-alive"
81
+ };
82
+ if (lock.CORRNR) {
83
+ // Add transport to path
84
+ }
85
+ console.log("\n=== RAW PUT REQUEST ===");
86
+ console.log(`PUT ${putPath}`);
87
+ for (const [k, v] of Object.entries(putHeaders)) {
88
+ if (k === "Authorization")
89
+ console.log(`${k}: Basic ***`);
90
+ else
91
+ console.log(`${k}: ${v}`);
92
+ }
93
+ console.log(`\nBody (${sourceBytes.length} bytes):\n${source}`);
94
+ const putResult = await new Promise((resolve, reject) => {
95
+ const req = http.request({
96
+ hostname: parsed.hostname,
97
+ port: parseInt(parsed.port || "8000"),
98
+ path: putPath,
99
+ method: "PUT",
100
+ headers: putHeaders,
101
+ }, (res) => {
102
+ let body = "";
103
+ res.on("data", (chunk) => { body += chunk.toString(); });
104
+ res.on("end", () => resolve({ status: res.statusCode, headers: res.headers, body }));
105
+ });
106
+ req.on("error", reject);
107
+ req.write(sourceBytes);
108
+ req.end();
109
+ });
110
+ console.log("\n=== RAW PUT RESPONSE ===");
111
+ console.log("Status:", putResult.status);
112
+ console.log("Headers:", JSON.stringify(putResult.headers, null, 2));
113
+ console.log("Body:", putResult.body);
114
+ // Step 4: Also try the SAME request as POST (for comparison)
115
+ console.log("\n\n=== RAW POST REQUEST (same params, different method) ===");
116
+ const postResult = await new Promise((resolve, reject) => {
117
+ const req = http.request({
118
+ hostname: parsed.hostname,
119
+ port: parseInt(parsed.port || "8000"),
120
+ path: putPath,
121
+ method: "POST",
122
+ headers: putHeaders,
123
+ }, (res) => {
124
+ let body = "";
125
+ res.on("data", (chunk) => { body += chunk.toString(); });
126
+ res.on("end", () => resolve({ status: res.statusCode, headers: res.headers, body }));
127
+ });
128
+ req.on("error", reject);
129
+ req.write(sourceBytes);
130
+ req.end();
131
+ });
132
+ console.log("Status:", postResult.status);
133
+ console.log("Headers:", JSON.stringify(postResult.headers, null, 2));
134
+ console.log("Body:", postResult.body);
135
+ // Cleanup
136
+ try {
137
+ await client.unLock(objectUrl, lock.LOCK_HANDLE);
138
+ console.log("\n=== UNLOCKED ===");
139
+ }
140
+ catch (e) {
141
+ console.log("\nUnlock failed:", e.message);
142
+ }
143
+ }
144
+ main().catch(e => { console.error("Fatal:", e.message); process.exit(1); });
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const abap_adt_api_1 = require("abap-adt-api");
4
+ async function main() {
5
+ const baseUrl = process.env.ADT_URL;
6
+ const user = process.env.ADT_USER;
7
+ const pass = process.env.ADT_PASS;
8
+ const sapClient = process.env.ADT_CLIENT || "";
9
+ const language = process.env.ADT_LANGUAGE || "EN";
10
+ // Match extension behavior: for HTTP, pass empty options (no httpsAgent)
11
+ const isHttps = baseUrl.match(/^https:/i);
12
+ const options = isHttps ? { httpsAgent: new (require("https").Agent)({ keepAlive: true, rejectUnauthorized: false }) } : {};
13
+ console.log("URL protocol:", isHttps ? "HTTPS" : "HTTP");
14
+ console.log("Options:", JSON.stringify(Object.keys(options)));
15
+ const c = new abap_adt_api_1.ADTClient(baseUrl, user, pass, sapClient, language, options);
16
+ const objectUrl = "/sap/bc/adt/programs/programs/zsgr_test_42";
17
+ const sourceUrl = "/sap/bc/adt/programs/programs/zsgr_test_42/source/main";
18
+ const source = "REPORT zsgr_test_42.\n\nDATA lv_value TYPE i.\n\nBREAK-POINT.\nlv_value = 42.\nBREAK-POINT.\n\nWRITE: / 'Value of lv_value:', lv_value.\n";
19
+ console.log("=== Login ===");
20
+ await c.login();
21
+ console.log("Logged in");
22
+ c.stateful = abap_adt_api_1.session_types.stateful;
23
+ console.log("=== Lock ===");
24
+ const lock = await c.lock(objectUrl);
25
+ console.log("Lock handle:", lock.LOCK_HANDLE);
26
+ console.log("=== Write ===");
27
+ try {
28
+ await c.setObjectSource(sourceUrl, source, lock.LOCK_HANDLE);
29
+ console.log("SUCCESS!");
30
+ }
31
+ catch (e) {
32
+ console.log("FAILED:", e.message);
33
+ }
34
+ console.log("=== Unlock ===");
35
+ try {
36
+ await c.unLock(objectUrl, lock.LOCK_HANDLE);
37
+ }
38
+ catch (_a) { }
39
+ c.stateful = abap_adt_api_1.session_types.stateless;
40
+ await c.dropSession();
41
+ }
42
+ main().catch(e => { console.error(e); process.exit(1); });