Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function installProg(name, source) {
const client = create();
const path = '/sap/bc/adt/programs/programs/' + name;
const main = path + '/source/main';
try {
await client.createObject({
description: name,
name,
objtype: 'PROG/P',
parentName: '$TMP',
parentPath: '/sap/bc/adt/packages/$TMP'
});
client.stateful = session_types.stateful;
const handle = await client.lock(path);
await client.setObjectSource(main, source, handle.LOCK_HANDLE); // write the program
console.log(`Program ${name} was successfully created`);
await client.unLock(path, handle.LOCK_HANDLE);
// read it for verification
// const newsource = await c.getObjectSource(main)
// console.log(newsource);
const result = await client.activate( name, path );
console.log(`Program ${name} was activated`);
console.log(result);
} finally {
client.dropSession();
}
}
public async relogin() {
this.currentCancel.cancel()
this.currentCancel = new CancellationTokenSource()
this.currentCall = Promise.resolve()
if (this.mainClient.stateful === session_types.stateful) {
try {
this.mainClient.stateful = session_types.stateless
// juts in case I have pending locks...
await this.mainClient.logout()
} catch (error) {
// ignore
}
await this.mainClient.login()
}
}
return this.server.runInSession(async client => {
if (curLock) return curLock
client.stateful = session_types.stateful
const lock = await client.lock(this.main.path)
return lock
})
}
private toHttpRequest(request: RequestData, source: string): HttpRequest {
const { body: requestBody, ...rest } = request
const s = request.headers["X-sap-adt-sessiontype"]
const stateful = s === session_types.stateful || s === session_types.keep
return {
...rest,
requestBody,
source,
stateful,
start: new Date().getTime()
}
}
public httpLog(type: LogPhase, data: LogData, source: Sources) {