-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSnowflakeService.ts
41 lines (33 loc) · 1.19 KB
/
SnowflakeService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Controller, Post } from "sdk/http"
import { FunctionParamsDTO, FunctionResultDTO } from "./function-data-dto"
import { ConcatenateParamsDTO, ConcatenateResultDTO } from "./concatenate-dto"
import { execute } from "/string-util/dist/run.mjs"
@Controller
class SnowflakeService {
@Post("/udf")
public processUDF(dto: FunctionParamsDTO): FunctionResultDTO {
const resultRows: [number, any][] = [];
dto.data.forEach((rowData) => {
const rowIndex: number = rowData[0];
const params: any[] = rowData.slice(1);
const functionReturnValue = params.join("|");
const resultRow: [number, any] = [rowIndex, functionReturnValue];
resultRows.push(resultRow);
});
return {
data: resultRows
};
}
@Post("/concatenate")
public async concatenate(params: ConcatenateParamsDTO): Promise<ConcatenateResultDTO> {
const abapParams = {
iv_string1: params.param1,
iv_string2: params.param2
};
const result = await execute(abapParams);
console.log("Result in REST: " + result);
return {
result: result
};
}
}