merging with relationship backend work

This commit is contained in:
Martin McKeaveney 2021-06-29 12:05:26 +01:00
commit 47d879c7c2
19 changed files with 1472 additions and 44 deletions

View File

@ -9,7 +9,8 @@
"url": "https://github.com/Budibase/budibase.git"
},
"scripts": {
"build": "rm -rf dist/ && tsc && mv dist/src/* dist/ && rmdir dist/src/",
"build": "rm -rf dist/ && tsc && mv dist/src/* dist/ && rmdir dist/src/ && yarn postbuild",
"postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/",
"test": "jest --coverage --maxWorkers=2",
"test:watch": "jest --watch",
"build:docker": "docker build . -t app-service",
@ -122,6 +123,7 @@
"@types/node": "^15.12.4",
"@typescript-eslint/parser": "^4.28.0",
"babel-jest": "^27.0.2",
"copyfiles": "^2.4.1",
"docker-compose": "^0.23.6",
"eslint": "^6.8.0",
"express": "^4.17.1",

View File

@ -15,3 +15,26 @@ CREATE TABLE Tasks (
FOREIGN KEY(PersonID)
REFERENCES Persons(PersonID)
);
CREATE TABLE Products (
ProductID INT NOT NULL PRIMARY KEY,
ProductName varchar(255)
);
CREATE TABLE Products_Tasks (
ProductID INT NOT NULL,
TaskID INT NOT NULL,
CONSTRAINT fkProducts
FOREIGN KEY(ProductID)
REFERENCES Products(ProductID),
CONSTRAINT fkTasks
FOREIGN KEY(TaskID)
REFERENCES Tasks(TaskID),
PRIMARY KEY (ProductID, TaskID)
);
INSERT INTO Persons (PersonID, FirstName, LastName, Address, City) VALUES (1, 'Mike', 'Hughes', '123 Fake Street', 'Belfast');
INSERT INTO Tasks (TaskID, PersonID, TaskName) VALUES (1, 1, 'assembling');
INSERT INTO Products (ProductID, ProductName) VALUES (1, 'Computers');
INSERT INTO Products (ProductID, ProductName) VALUES (2, 'Laptops');
INSERT INTO Products (ProductID, ProductName) VALUES (3, 'Chairs');
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (1, 1);
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (2, 1);
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (3, 1);

View File

@ -0,0 +1,3 @@
#!/bin/bash
docker-compose down
docker volume prune -f

View File

@ -0,0 +1,78 @@
interface Base {
_id?: string
_rev?: string
}
export interface TableSchema {
[key: string]: {
// TODO: replace with field types enum when done
type: string
fieldName?: string
name: string
constraints?: {
type?: string
email?: boolean
inclusion?: string[]
length?: {
minimum?: string | number
maximum?: string | number
}
presence?: boolean
}
}
}
export interface Table extends Base {
type?: string
views?: {}
name?: string
primary?: string[]
schema: TableSchema
primaryDisplay?: string
sourceId?: string
}
export interface Row extends Base {
type?: string
tableId: string
[key: string]: any
}
interface JsonSchemaField {
properties: {
[key: string]: {
type: string
title: string
customType?: string
}
}
required?: string[]
}
export interface AutomationStep {
description: string
event?: string
icon: string
id: string
inputs: {
[key: string]: any
}
name: string
schema: {
inputs: JsonSchemaField
outputs: JsonSchemaField
}
stepId: string
tagline: string
type: string
}
export interface Automation extends Base {
name: string
type: string
appId?: string
definition: {
steps: AutomationStep[]
trigger?: AutomationStep
}
}

View File

@ -75,11 +75,7 @@ export interface SearchFilters {
}
export interface RelationshipsJson {
through?: {
from: string
to: string
tableName: string
}
through?: string
from: string
to: string
tableName: string

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module AirtableModule {
const Airtable = require("airtable")

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module ArangoModule {
const { Database, aql } = require("arangojs")

View File

@ -7,7 +7,7 @@ import {
SortDirection,
Operation,
RelationshipsJson,
} from "./definitions"
} from "../../definitions/datasource"
type KnexQuery = Knex.QueryBuilder | Knex

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module CouchDBModule {
const PouchDB = require("pouchdb")

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module DynamoModule {
const AWS = require("aws-sdk")

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module ElasticsearchModule {
const { Client } = require("@elastic/elasticsearch")

View File

@ -4,7 +4,7 @@ import {
QueryTypes,
QueryJson,
SqlQuery,
} from "./base/definitions"
} from "../definitions/datasource"
import { getSqlQuery } from "./utils"
module MSSQLModule {

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module MongoDBModule {
const { MongoClient } = require("mongodb")

View File

@ -5,7 +5,8 @@ import {
Operation,
QueryJson,
SqlQuery,
} from "./base/definitions"
} from "../definitions/datasource"
import { Table, TableSchema } from "../definitions/common"
import { getSqlQuery } from "./utils"
module MySQLModule {
@ -139,7 +140,7 @@ module MySQLModule {
}
async buildSchema(datasourceId: string) {
const tables: any = {}
const tables: { [key: string]: Table } = {}
const database = this.config.database
this.client.connect()
@ -154,7 +155,7 @@ module MySQLModule {
)
for (let tableName of tableNames) {
const primaryKeys = []
const schema: any = {}
const schema: TableSchema = {}
const descResp = await internalQuery(
this.client,
{ sql: `DESCRIBE ${tableName};` },
@ -166,7 +167,7 @@ module MySQLModule {
primaryKeys.push(columnName)
}
const constraints = {
required: column.Null !== "YES",
presence: column.Null !== "YES",
}
schema[columnName] = {
name: columnName,
@ -212,7 +213,7 @@ module MySQLModule {
}
async getReturningRow(json: QueryJson) {
if (!json.extra.idFilter) {
if (!json.extra || !json.extra.idFilter) {
return {}
}
const input = this._query({

View File

@ -4,8 +4,8 @@ import {
QueryTypes,
QueryJson,
SqlQuery,
} from "./base/definitions"
import { Table } from "../constants/definitions"
} from "../definitions/datasource"
import { Table } from "../definitions/common"
import { getSqlQuery } from "./utils"
module PostgresModule {

View File

@ -2,7 +2,7 @@ import {
Integration,
DatasourceFieldTypes,
QueryTypes,
} from "./base/definitions"
} from "../definitions/datasource"
module RestModule {
const fetch = require("node-fetch")

View File

@ -1,4 +1,4 @@
import { Integration, QueryTypes } from "./base/definitions"
import { Integration, QueryTypes } from "../definitions/datasource"
module S3Module {
const AWS = require("aws-sdk")

View File

@ -1,4 +1,4 @@
import { SqlQuery } from "./base/definitions"
import { SqlQuery } from "../definitions/datasource"
const { DocumentTypes, SEPARATOR } = require("../db/utils")
const { FieldTypes } = require("../constants")

File diff suppressed because it is too large Load Diff