split all operators
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Operator } from "../functions";
|
||||
import { Operator, OperatorSchema } from "../functions";
|
||||
import i18next from "i18next";
|
||||
|
||||
const compileTimeOperatorList: {basename: string}[] = import.meta.compileTime("../compiletime/operatorDescription.ts"); // The will compile to ["impose", "extractPages", etc...]
|
||||
@@ -7,7 +7,6 @@ export async function getOperatorByName(name: string): Promise<typeof Operator |
|
||||
// Check if exists
|
||||
if(!compileTimeOperatorList.find(e => e.basename == name)) return;
|
||||
|
||||
i18next.loadNamespaces(name, (err, t) => { if (err) throw err; console.log(t) });
|
||||
const loadedModule = await import("../functions/" + name + ".ts");
|
||||
const operator = loadedModule[capitalizeFirstLetter(name)];
|
||||
if(!operator) {
|
||||
@@ -16,6 +15,19 @@ export async function getOperatorByName(name: string): Promise<typeof Operator |
|
||||
return operator;
|
||||
}
|
||||
|
||||
export async function getSchemaByName(name: string): Promise<OperatorSchema | undefined> {
|
||||
// Check if exists
|
||||
if(!compileTimeOperatorList.find(e => e.basename == name)) return;
|
||||
|
||||
i18next.loadNamespaces(name, (err, t) => { if (err) throw err; console.log(t) });
|
||||
const loadedModule = await import("../functions/" + name + ".schema.ts");
|
||||
const schema = loadedModule.default;
|
||||
if(!schema) {
|
||||
throw Error("This operator does not export its class in the correct format.")
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
|
||||
export function listOperatorNames(): string[] {
|
||||
const availableOperators = compileTimeOperatorList.map(e => e.basename);
|
||||
return availableOperators;
|
||||
|
||||
Reference in New Issue
Block a user