DB
This commit is contained in:
32
.vscode/tasks.json
vendored
Normal file
32
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Run case1 test",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "npx ts-node tests/base/case1.ts",
|
||||||
|
"args": [],
|
||||||
|
"isBackground": false,
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": "build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Generate join table migration",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "npm run migration:generate -- src/migrations/query-modules-join",
|
||||||
|
"args": [],
|
||||||
|
"isBackground": false,
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": "build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run DB migrations",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "npm run migration:run",
|
||||||
|
"args": [],
|
||||||
|
"isBackground": false,
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
18
src/migrations/1758550333691-defaults.ts
Normal file
18
src/migrations/1758550333691-defaults.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class Defaults1758550333691 implements MigrationInterface {
|
||||||
|
name = 'Defaults1758550333691'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`module\` DROP COLUMN \`isInjectable\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`plugin\` ADD \`queryId\` uuid NULL`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`plugin\` ADD CONSTRAINT \`FK_5162d18c3653d35ff4d104dd940\` FOREIGN KEY (\`queryId\`) REFERENCES \`query\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`plugin\` DROP FOREIGN KEY \`FK_5162d18c3653d35ff4d104dd940\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`plugin\` DROP COLUMN \`queryId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`module\` ADD \`isInjectable\` tinyint NOT NULL DEFAULT 1`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
20
src/migrations/1758551707113-query-modules-join.ts
Normal file
20
src/migrations/1758551707113-query-modules-join.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class QueryModulesJoin1758551707113 implements MigrationInterface {
|
||||||
|
name = 'QueryModulesJoin1758551707113'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TABLE \`query_modules_module\` (\`queryId\` uuid NOT NULL, \`moduleId\` uuid NOT NULL, INDEX \`IDX_12121324c524e12538de4948ce\` (\`queryId\`), INDEX \`IDX_7fb42dbc85874aafbd4bfb1c10\` (\`moduleId\`), PRIMARY KEY (\`queryId\`, \`moduleId\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`query_modules_module\` ADD CONSTRAINT \`FK_12121324c524e12538de4948cee\` FOREIGN KEY (\`queryId\`) REFERENCES \`query\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`query_modules_module\` ADD CONSTRAINT \`FK_7fb42dbc85874aafbd4bfb1c101\` FOREIGN KEY (\`moduleId\`) REFERENCES \`module\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`query_modules_module\` DROP FOREIGN KEY \`FK_7fb42dbc85874aafbd4bfb1c101\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`query_modules_module\` DROP FOREIGN KEY \`FK_12121324c524e12538de4948cee\``);
|
||||||
|
await queryRunner.query(`DROP INDEX \`IDX_7fb42dbc85874aafbd4bfb1c10\` ON \`query_modules_module\``);
|
||||||
|
await queryRunner.query(`DROP INDEX \`IDX_12121324c524e12538de4948ce\` ON \`query_modules_module\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`query_modules_module\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,14 +1,14 @@
|
|||||||
import { Body, Controller, Inject, Put } from "@nestjs/common";
|
import { Body, Controller, Inject, Put } from "@nestjs/common";
|
||||||
import { ProjectService } from "./project.service";
|
import { ProjectService } from "./project.service";
|
||||||
|
|
||||||
@Controller("")
|
@Controller("project")
|
||||||
export class ProjectController {
|
export class ProjectController {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(ProjectService)
|
@Inject(ProjectService)
|
||||||
private readonly projectService: ProjectService
|
private readonly projectService: ProjectService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Put("project/create")
|
@Put("create")
|
||||||
createProject(@Body() body: { name: string }) {
|
createProject(@Body() body: { name: string }) {
|
||||||
return this.projectService.create(body.name);
|
return this.projectService.create(body.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,9 +12,6 @@ export class VMModule {
|
|||||||
@Column({ type: "varchar", length: 255 })
|
@Column({ type: "varchar", length: 255 })
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@Column({ type: "tinyint", default: 1 })
|
|
||||||
isInjectable: number;
|
|
||||||
|
|
||||||
@ManyToMany(() => Query, (query) => query.modules)
|
@ManyToMany(() => Query, (query) => query.modules)
|
||||||
queries: Query[];
|
queries: Query[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { Query } from "./query.entity";
|
import { Query } from "./query.entity";
|
||||||
|
|
||||||
@Entity("plugin")
|
@Entity("plugin")
|
||||||
@ -12,8 +12,8 @@ export class VmPlugin {
|
|||||||
@Column({ type: "varchar", length: 255, nullable: false })
|
@Column({ type: "varchar", length: 255, nullable: false })
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@ManyToMany(() => Query, (query) => query.plugins)
|
@ManyToOne(() => Query, (query) => query.plugins)
|
||||||
queries: Query[];
|
query: Query;
|
||||||
|
|
||||||
@Column({ type: "varchar", length: 255 })
|
@Column({ type: "varchar", length: 255 })
|
||||||
config: string;
|
config: string;
|
||||||
|
|||||||
@ -4,7 +4,9 @@ import {
|
|||||||
Entity,
|
Entity,
|
||||||
ManyToMany,
|
ManyToMany,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
|
OneToMany,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
|
JoinTable,
|
||||||
} from "typeorm";
|
} from "typeorm";
|
||||||
import { VMModule } from "./module.entity";
|
import { VMModule } from "./module.entity";
|
||||||
import { VmPlugin } from "./plugin.entity";
|
import { VmPlugin } from "./plugin.entity";
|
||||||
@ -24,8 +26,13 @@ export class Query {
|
|||||||
isActive: number;
|
isActive: number;
|
||||||
|
|
||||||
@ManyToMany(() => VMModule, (module) => module.queries)
|
@ManyToMany(() => VMModule, (module) => module.queries)
|
||||||
|
@JoinTable({
|
||||||
|
name: "query_modules_module",
|
||||||
|
joinColumn: { name: "queryId", referencedColumnName: "id" },
|
||||||
|
inverseJoinColumn: { name: "moduleId", referencedColumnName: "id" },
|
||||||
|
})
|
||||||
modules: VMModule[];
|
modules: VMModule[];
|
||||||
|
|
||||||
@ManyToMany(() => VmPlugin, (plugin) => plugin.queries)
|
@OneToMany(() => VmPlugin, (plugin) => plugin.query)
|
||||||
plugins: VmPlugin[];
|
plugins: VmPlugin[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ export class QueryExecuterService {
|
|||||||
async runQuery(token: string, queryData: any) {
|
async runQuery(token: string, queryData: any) {
|
||||||
const query = await this.queryRepository.findOne({
|
const query = await this.queryRepository.findOne({
|
||||||
where: { id: token },
|
where: { id: token },
|
||||||
|
relations: ["modules", "plugins"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
@ -42,16 +43,18 @@ export class QueryExecuterService {
|
|||||||
modules: query.modules.map((module) => {
|
modules: query.modules.map((module) => {
|
||||||
return new VModule(module.name, module.sourcePath);
|
return new VModule(module.name, module.sourcePath);
|
||||||
}),
|
}),
|
||||||
plugins: query.plugins.map((plugin) => {
|
plugins: await Promise.all(
|
||||||
switch (plugin.class) {
|
query.plugins.map((plugin) => {
|
||||||
case "DATABASE": {
|
switch (plugin.class) {
|
||||||
const config = JSON.parse(plugin.config);
|
case "DATABASE": {
|
||||||
return DatabasePlugin.init(plugin.name, config);
|
const config = JSON.parse(plugin.config);
|
||||||
|
return DatabasePlugin.init(plugin.name, config);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown plugin class: ${plugin.class}`);
|
||||||
}
|
}
|
||||||
default:
|
})
|
||||||
throw new Error(`Unknown plugin class: ${plugin.class}`);
|
),
|
||||||
}
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return await vm.init();
|
return await vm.init();
|
||||||
|
|||||||
@ -19,6 +19,84 @@ export class QueryHandlerService {
|
|||||||
private readonly projectService: ProjectService
|
private readonly projectService: ProjectService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
private async createOrGetVmModule(
|
||||||
|
name: string,
|
||||||
|
sourcePath: string
|
||||||
|
): Promise<VMModule> {
|
||||||
|
const vmModule = await this.moduleRepository.findOne({
|
||||||
|
where: {
|
||||||
|
name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (vmModule) {
|
||||||
|
return vmModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newModule = this.moduleRepository.create({
|
||||||
|
sourcePath,
|
||||||
|
name,
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.moduleRepository.save(newModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createOrGetPlugin(
|
||||||
|
name: string,
|
||||||
|
className: string,
|
||||||
|
query: Query,
|
||||||
|
config: Record<string, any>
|
||||||
|
): Promise<VmPlugin> {
|
||||||
|
const plugin = await this.pluginRepository.findOne({
|
||||||
|
where: {
|
||||||
|
name,
|
||||||
|
query: {
|
||||||
|
id: query.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (plugin) {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newPlugin = this.pluginRepository.create({
|
||||||
|
name,
|
||||||
|
class: className,
|
||||||
|
config: JSON.stringify(config),
|
||||||
|
query,
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.pluginRepository.save(newPlugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: make it nice
|
||||||
|
async createDefaults(query: Query): Promise<void> {
|
||||||
|
const asyncCallModule = await this.createOrGetVmModule(
|
||||||
|
"asyncCall",
|
||||||
|
"dist/vm/modules/async.js"
|
||||||
|
);
|
||||||
|
const squelModule = await this.createOrGetVmModule(
|
||||||
|
"query",
|
||||||
|
"node_modules/squel/dist/squel.min.js"
|
||||||
|
);
|
||||||
|
|
||||||
|
query.modules = [asyncCallModule, squelModule];
|
||||||
|
|
||||||
|
const dbPlugin = await this.createOrGetPlugin("db", "DATABASE", query, {
|
||||||
|
// TODO: take it from database handler
|
||||||
|
host: process.env.DB_HOST,
|
||||||
|
user: process.env.DB_USERNAME,
|
||||||
|
port: process.env.DB_PORT,
|
||||||
|
password: process.env.DB_PASSWORD,
|
||||||
|
database: "test",
|
||||||
|
});
|
||||||
|
|
||||||
|
query.plugins = [dbPlugin];
|
||||||
|
|
||||||
|
await this.queryRepository.save(query);
|
||||||
|
}
|
||||||
|
|
||||||
async createQuery(queryData: { projectToken: string; source: string }) {
|
async createQuery(queryData: { projectToken: string; source: string }) {
|
||||||
const project = await this.projectService.findByToken(
|
const project = await this.projectService.findByToken(
|
||||||
queryData.projectToken
|
queryData.projectToken
|
||||||
@ -32,7 +110,11 @@ export class QueryHandlerService {
|
|||||||
delete queryData.projectToken;
|
delete queryData.projectToken;
|
||||||
|
|
||||||
const query = this.queryRepository.create(queryData);
|
const query = this.queryRepository.create(queryData);
|
||||||
return this.queryRepository.save(query);
|
await this.queryRepository.save(query);
|
||||||
|
|
||||||
|
await this.createDefaults(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateQuery(id: string, updateData: Partial<Query>) {
|
async updateQuery(id: string, updateData: Partial<Query>) {
|
||||||
|
|||||||
@ -1,4 +1,12 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
async function asyncCall(reference, args) {
|
async function asyncCall(reference, args) {
|
||||||
return await reference.apply(undefined, args, { result: { promise: true } });
|
if (!Array.isArray(args)) {
|
||||||
|
args = [args];
|
||||||
|
}
|
||||||
|
|
||||||
|
const resJson = await reference.apply(undefined, args, {
|
||||||
|
result: { promise: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
return JSON.parse(resJson);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,31 +12,39 @@ export class DatabasePlugin extends Plugin {
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static init(
|
static async init(
|
||||||
name: string,
|
name: string,
|
||||||
config: {
|
config: {
|
||||||
host: string;
|
host: string;
|
||||||
|
port: number;
|
||||||
user: string;
|
user: string;
|
||||||
password: string;
|
password: string;
|
||||||
database: string;
|
database: string;
|
||||||
}
|
}
|
||||||
): DatabasePlugin {
|
): Promise<DatabasePlugin> {
|
||||||
const dbConnection = mysql.createConnection({
|
const dbConnection = await mysql.createConnection({
|
||||||
host: config.host,
|
host: config.host,
|
||||||
user: config.user,
|
user: config.user,
|
||||||
|
port: config.port,
|
||||||
password: config.password,
|
password: config.password,
|
||||||
database: config.database,
|
database: config.database,
|
||||||
|
enableKeepAlive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return new DatabasePlugin(name, dbConnection);
|
return new DatabasePlugin(name, dbConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(query): Promise<{
|
async run(query): Promise<any> {
|
||||||
rows: any[];
|
try {
|
||||||
fields: any[];
|
const [rows, fields] = await this.dbConnection.execute(query);
|
||||||
}> {
|
|
||||||
const [rows, fields] = await this.dbConnection.execute(query);
|
return JSON.stringify({
|
||||||
return { rows, fields };
|
rows: rows,
|
||||||
|
fields: fields ?? [],
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFinish() {
|
onFinish() {
|
||||||
|
|||||||
@ -28,13 +28,17 @@ export class Vm {
|
|||||||
this.jail.set("global", this.jail.derefInto());
|
this.jail.set("global", this.jail.derefInto());
|
||||||
|
|
||||||
for (const mod of this.modules) {
|
for (const mod of this.modules) {
|
||||||
this.jail.setSync(mod.getName(), mod.getSource());
|
await this.context.eval(mod.getSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const plugin of this.plugins) {
|
for (const plugin of this.plugins) {
|
||||||
this.jail.setSync(
|
this.jail.setSync(
|
||||||
plugin.getName(),
|
plugin.getName(),
|
||||||
new ivm.Reference(plugin.run.bind(plugin))
|
new ivm.Reference(async (...args) => {
|
||||||
|
const res = await plugin.run(...args);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +65,9 @@ export class Vm {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO: log
|
// TODO: log
|
||||||
|
this.setFunction("log", (...args) => {
|
||||||
|
console.log("vm log:", args);
|
||||||
|
});
|
||||||
|
|
||||||
this.setFunction("error", (error: any) => {
|
this.setFunction("error", (error: any) => {
|
||||||
console.error("Script error:", error);
|
console.error("Script error:", error);
|
||||||
@ -82,9 +89,12 @@ export class Vm {
|
|||||||
const compiledScript = await this.isolate.compileScript(scriptWithResult);
|
const compiledScript = await this.isolate.compileScript(scriptWithResult);
|
||||||
|
|
||||||
compiledScript.run(this.context);
|
compiledScript.run(this.context);
|
||||||
this.onFinish();
|
|
||||||
|
|
||||||
return await resultPromise;
|
try {
|
||||||
|
return await resultPromise;
|
||||||
|
} finally {
|
||||||
|
this.onFinish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFinish() {
|
onFinish() {
|
||||||
|
|||||||
28
tests/base/case1-payload.js
Normal file
28
tests/base/case1-payload.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
|
||||||
|
async function insert() {
|
||||||
|
const res = await asyncCall(
|
||||||
|
db,
|
||||||
|
squel.insert().into("testTable").set("col", "test me now").toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSQL(id) {
|
||||||
|
return squel.select().from("testTable").where("id = ?", id).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main(input) {
|
||||||
|
const inserted = await insert();
|
||||||
|
|
||||||
|
log(inserted);
|
||||||
|
|
||||||
|
const sql = createSQL(inserted.rows.insertId);
|
||||||
|
const res = await asyncCall(db, sql);
|
||||||
|
|
||||||
|
log(res.rows);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
@ -1,14 +1,17 @@
|
|||||||
import createProject from "../functions/createProject";
|
import createProject from "../functions/createProject";
|
||||||
import createQuery from "../functions/createQuery";
|
import createQuery from "../functions/createQuery";
|
||||||
import runQuery from "../functions/runQuery";
|
import runQuery from "../functions/runQuery";
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const project = await createProject("Test Project");
|
const project = await createProject("Test Project");
|
||||||
|
|
||||||
|
const payloadPath = path.join(__dirname, "case1-payload.js");
|
||||||
const query = await createQuery(
|
const query = await createQuery(
|
||||||
project,
|
project,
|
||||||
"async function main(input) { return `Hello, ${input.name}!`; }"
|
fs.readFileSync(payloadPath, { encoding: "utf-8" })
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(query);
|
console.log(query);
|
||||||
|
|||||||
3
tests/config.ts
Normal file
3
tests/config.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const config = {
|
||||||
|
url: "http://localhost:3054",
|
||||||
|
};
|
||||||
@ -1,14 +1,12 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "tests/config";
|
||||||
|
|
||||||
export default async (query: { id: string }, module: { id: string }) => {
|
export default async (query: { id: string }, module: { id: string }) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(`${config.url}/query/module/add`, {
|
||||||
"http://localhost:3000/query/module/add",
|
queryId: query.id,
|
||||||
{
|
moduleId: module.id,
|
||||||
queryId: query.id,
|
});
|
||||||
moduleId: module.id,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "tests/config";
|
||||||
|
|
||||||
export default async (query: { id: string }, plugin: { id: string }) => {
|
export default async (query: { id: string }, plugin: { id: string }) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(`${config.url}/query/plugin/add`, {
|
||||||
"http://localhost:3000/query/plugin/add",
|
queryId: query.id,
|
||||||
{
|
pluginId: plugin.id,
|
||||||
queryId: query.id,
|
});
|
||||||
pluginId: plugin.id,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "tests/config";
|
||||||
|
|
||||||
export default async (name: string, sourcePath: string) => {
|
export default async (name: string, sourcePath: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(`${config.url}/query/module/create`, {
|
||||||
"http://localhost:3000/query/module/create",
|
name,
|
||||||
{
|
sourcePath,
|
||||||
name,
|
});
|
||||||
sourcePath,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,15 +1,13 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config as appConfig } from "../config";
|
||||||
|
|
||||||
export default async (name: string, className: string, config: string) => {
|
export default async (name: string, className: string, config: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(`${appConfig.url}/query/plugin/create`, {
|
||||||
"http://localhost:3000/query/plugin/create",
|
name,
|
||||||
{
|
class: className,
|
||||||
name,
|
config,
|
||||||
class: className,
|
});
|
||||||
config,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
const createProject = async (name: string) => {
|
const createProject = async (name: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.put("http://localhost:3000/project/create", {
|
const response = await axios.put(`${config.url}/project/create`, {
|
||||||
name: name,
|
name: name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
export default async (project: { token: string }, source: string) => {
|
export default async (project: { token: string }, source: string) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("http://localhost:3000/query/create", {
|
const response = await axios.post(`${config.url}/query/create`, {
|
||||||
source,
|
source,
|
||||||
projectToken: project.token,
|
projectToken: project.token,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
export default async (token: string, queryData: Record<string, any>) => {
|
export default async (token: string, queryData: Record<string, any>) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`http://localhost:3000/query/run/${token}`,
|
`${config.url}/query/run/${token}`,
|
||||||
queryData
|
queryData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
export default async (query: { id: string; source: string }) => {
|
export default async (query: { id: string; source: string }) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("http://localhost:3000/query/update", {
|
const response = await axios.post(`${config.url}/query/update`, {
|
||||||
queryId: query.id,
|
queryId: query.id,
|
||||||
source: query.source,
|
source: query.source,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user