Add support for submitting the transactions to Actual server

This commit is contained in:
2025-04-01 17:19:50 +02:00
parent 9fa3b7d775
commit 32014f84e8
10 changed files with 155 additions and 18 deletions

9
src/util/code.ts Normal file
View File

@@ -0,0 +1,9 @@
const standardContext = {
};
export function jsMapper<I, O>(code: string, context: Record<string, unknown>): (task: I) => O {
const ctx = { ...standardContext, ...context };
const filter = new Function('$', ...Object.keys(ctx), code);
return (task: I) => filter(task, ...Object.values(ctx));
}

17
src/util/config.ts Normal file
View File

@@ -0,0 +1,17 @@
import { readFileSync } from "fs";
const specialOptions: Record<string, (text: string) => string> = {
$__file: (arg: string) => readFileSync(arg, 'utf8').trim()
};
export const enhancedStringConfig = (value: string) => {
const trimmed = value.trim();
for(const opt of Object.keys(specialOptions)) {
if(trimmed.startsWith(`${opt}:`) && opt in specialOptions) {
return specialOptions[opt](trimmed.slice(opt.length + 1).trim());
}
}
return trimmed;
};