preserve stuff before trying something craz
This commit is contained in:
65
dist/example-def.js
vendored
65
dist/example-def.js
vendored
@ -4,11 +4,11 @@ var def = {
|
||||
storage: {
|
||||
tables: [
|
||||
{
|
||||
name: "tasks",
|
||||
name: "task",
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'lists',
|
||||
table: 'list',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
@ -40,7 +40,7 @@ var def = {
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "lists",
|
||||
name: "list",
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
@ -52,7 +52,7 @@ var def = {
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "users",
|
||||
name: "user",
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
@ -70,9 +70,9 @@ var def = {
|
||||
],
|
||||
relations: [
|
||||
{
|
||||
left: 'lists',
|
||||
left: 'list',
|
||||
relation: 'many-to-many',
|
||||
right: 'users',
|
||||
right: 'user',
|
||||
columns: [
|
||||
{
|
||||
name: 'access',
|
||||
@ -83,6 +83,59 @@ var def = {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
views: [
|
||||
{
|
||||
component: 'task',
|
||||
type: ['list', 'count'],
|
||||
columns: [
|
||||
'name',
|
||||
'description',
|
||||
'completed',
|
||||
'completed_date',
|
||||
],
|
||||
orderBy: [
|
||||
{
|
||||
column: 'modified',
|
||||
direction: 'desc'
|
||||
}
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
param: 'list',
|
||||
column: 'list_id',
|
||||
comparison: '=',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
param: 'completed',
|
||||
column: 'completed',
|
||||
comparison: '=',
|
||||
required: false
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
component: 'list',
|
||||
type: ['list', 'count'],
|
||||
columns: [
|
||||
'name',
|
||||
],
|
||||
orderBy: [
|
||||
{
|
||||
column: 'modified',
|
||||
direction: 'desc'
|
||||
}
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
param: 'user',
|
||||
column: 'user_id',
|
||||
comparison: '=',
|
||||
required: true
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
};
|
||||
exports.default = def;
|
||||
|
19
dist/processDef.d.ts
vendored
19
dist/processDef.d.ts
vendored
@ -1,10 +1,29 @@
|
||||
interface SystemDef {
|
||||
storage: StorageDef;
|
||||
views: ViewDef[];
|
||||
}
|
||||
interface StorageDef {
|
||||
tables: TableDef[];
|
||||
relations: ManyToManyDef[];
|
||||
}
|
||||
interface ViewDef {
|
||||
component: string;
|
||||
type: ('list' | 'count' | 'item' | 'distinct')[];
|
||||
columns: string[];
|
||||
orderBy?: Order[];
|
||||
filters?: Filter[];
|
||||
}
|
||||
interface Order {
|
||||
column: string;
|
||||
direction: 'asc' | 'desc';
|
||||
}
|
||||
interface Filter {
|
||||
param: string;
|
||||
column: string;
|
||||
comparison: '=' | '!=' | '>' | '<' | 'contains';
|
||||
value?: string;
|
||||
required?: boolean;
|
||||
}
|
||||
interface TableDef {
|
||||
name: string;
|
||||
columns: ColumnDef[];
|
||||
|
33
dist/processDef.js
vendored
33
dist/processDef.js
vendored
@ -1,9 +1,30 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var example_def_1 = __importDefault(require("./example-def"));
|
||||
var path = __importStar(require("path"));
|
||||
var simmer_def_example_1 = __importDefault(require("./simmer-def-example"));
|
||||
var ncp = require('ncp').ncp;
|
||||
function createDatabase(storageDef) {
|
||||
var tableCreationQueries = [];
|
||||
for (var i in storageDef.tables) {
|
||||
@ -57,4 +78,12 @@ function getTableRelationsCreationString(relationsDef) {
|
||||
}
|
||||
return "CREATE TABLE IF NOT EXISTS " + relationsDef.left + "_" + relationsDef.right + " (" + columnString + (indexString !== '' ? ', ' + indexString : '') + ");";
|
||||
}
|
||||
createDatabase(example_def_1.default.storage);
|
||||
ncp(path(__dirname, 'frame'), path(__dirname, 'test'), function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
else {
|
||||
console.log('success copying files');
|
||||
}
|
||||
});
|
||||
createDatabase(simmer_def_example_1.default.storage);
|
||||
|
14
package.json
Normal file
14
package.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@types/node": "^14.0.13",
|
||||
"ncp": "^2.0.0",
|
||||
"path": "^0.12.7"
|
||||
},
|
||||
"name": "system-builder",
|
||||
"version": "1.0.0",
|
||||
"main": "dist/processDef.js",
|
||||
"repository": "mason@house.sa.vin:gitServer/system-builder.git",
|
||||
"author": "Mason Payne <mason@masonitestudios.com>",
|
||||
"license": "UNLICENSED",
|
||||
"private": true
|
||||
}
|
@ -4,11 +4,11 @@ let def: SystemDef = {
|
||||
storage: {
|
||||
tables: [
|
||||
{
|
||||
name: "tasks",
|
||||
name: "task",
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'lists',
|
||||
table: 'list',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
@ -40,7 +40,7 @@ let def: SystemDef = {
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "lists",
|
||||
name: "list",
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
@ -52,7 +52,7 @@ let def: SystemDef = {
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "users",
|
||||
name: "user",
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
@ -70,9 +70,9 @@ let def: SystemDef = {
|
||||
],
|
||||
relations: [
|
||||
{
|
||||
left: 'lists',
|
||||
left: 'list',
|
||||
relation: 'many-to-many',
|
||||
right: 'users',
|
||||
right: 'user',
|
||||
columns: [
|
||||
{
|
||||
name: 'access',
|
||||
@ -83,7 +83,60 @@ let def: SystemDef = {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
views: [
|
||||
{
|
||||
component: 'task',
|
||||
type: ['list', 'count'],
|
||||
columns: [
|
||||
'name',
|
||||
'description',
|
||||
'completed',
|
||||
'completed_date',
|
||||
],
|
||||
orderBy: [
|
||||
{
|
||||
column: 'modified',
|
||||
direction: 'desc'
|
||||
}
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
param: 'list',
|
||||
column: 'list_id',
|
||||
comparison: '=',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
param: 'completed',
|
||||
column: 'completed',
|
||||
comparison: '=',
|
||||
required: false
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
component: 'list',
|
||||
type: ['list', 'count'],
|
||||
columns: [
|
||||
'name',
|
||||
],
|
||||
orderBy: [
|
||||
{
|
||||
column: 'modified',
|
||||
direction: 'desc'
|
||||
}
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
param: 'user',
|
||||
column: 'user_id',
|
||||
comparison: '=',
|
||||
required: true
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
export default def;
|
||||
|
@ -1,5 +1,9 @@
|
||||
import * as path from 'path';
|
||||
import simmer from './simmer-def-example';
|
||||
const ncp = require('ncp').ncp;
|
||||
// import defs from './example-def';
|
||||
|
||||
import defs from './example-def';
|
||||
declare var __dirname: any;
|
||||
|
||||
function createDatabase(storageDef: StorageDef) {
|
||||
let tableCreationQueries: string[] = [];
|
||||
@ -66,7 +70,15 @@ function getTableRelationsCreationString(relationsDef: ManyToManyDef): string {
|
||||
}
|
||||
|
||||
|
||||
createDatabase(defs.storage);
|
||||
ncp(path.join(__dirname, 'frame'), path.join(__dirname, 'test'), (err: any) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('success copying files');
|
||||
}
|
||||
});
|
||||
|
||||
createDatabase(simmer.storage);
|
||||
|
||||
|
||||
|
||||
@ -74,6 +86,7 @@ createDatabase(defs.storage);
|
||||
|
||||
interface SystemDef {
|
||||
storage: StorageDef;
|
||||
views: ViewDef[];
|
||||
// TODO: add Views, ACLs, Behaviors, UX
|
||||
}
|
||||
|
||||
@ -82,6 +95,28 @@ interface StorageDef {
|
||||
relations: ManyToManyDef[];
|
||||
}
|
||||
|
||||
interface ViewDef {
|
||||
component: string;
|
||||
type: ('list' | 'count' | 'item' | 'distinct')[];
|
||||
columns: string[];
|
||||
orderBy?: Order[];
|
||||
filters?: Filter[];
|
||||
// if type is 'list' it will always include skip and limit for pagination
|
||||
}
|
||||
|
||||
interface Order {
|
||||
column: string;
|
||||
direction: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
interface Filter {
|
||||
param: string; // the query param used to get the value
|
||||
column: string;
|
||||
comparison: '=' | '!=' | '>' | '<' | 'contains';
|
||||
value?: string;
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
interface TableDef {
|
||||
name: string;
|
||||
columns: ColumnDef[],
|
||||
|
95
src/simmer-def-example.ts
Normal file
95
src/simmer-def-example.ts
Normal file
@ -0,0 +1,95 @@
|
||||
import { SystemDef } from './processDef';
|
||||
|
||||
var simmer: SystemDef = {
|
||||
storage: {
|
||||
tables: [
|
||||
{
|
||||
name: 'cooks',
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'location',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'customers',
|
||||
relations: [],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'location',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'cardInfo',
|
||||
type: 'string',
|
||||
nullable: true
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'dishes',
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'cooks',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'picture',
|
||||
type: 'string',
|
||||
nullable: false
|
||||
},
|
||||
{
|
||||
name: 'prices',
|
||||
type: 'string',
|
||||
nullable: true
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'ratings',
|
||||
relations: [
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'customers',
|
||||
},
|
||||
{
|
||||
type: 'belongs-to',
|
||||
table: 'cooks',
|
||||
}
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'number',
|
||||
nullable: false
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
relations: []
|
||||
},
|
||||
views: []
|
||||
};
|
||||
|
||||
export default simmer;
|
38
yarn.lock
Normal file
38
yarn.lock
Normal file
@ -0,0 +1,38 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/node@^14.0.13":
|
||||
version "14.0.13"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.13.tgz#ee1128e881b874c371374c1f72201893616417c9"
|
||||
integrity sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==
|
||||
|
||||
inherits@2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
|
||||
|
||||
ncp@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ncp/-/ncp-2.0.0.tgz#195a21d6c46e361d2fb1281ba38b91e9df7bdbb3"
|
||||
integrity sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=
|
||||
|
||||
path@^0.12.7:
|
||||
version "0.12.7"
|
||||
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
|
||||
integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=
|
||||
dependencies:
|
||||
process "^0.11.1"
|
||||
util "^0.10.3"
|
||||
|
||||
process@^0.11.1:
|
||||
version "0.11.10"
|
||||
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
|
||||
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=
|
||||
|
||||
util@^0.10.3:
|
||||
version "0.10.4"
|
||||
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
|
||||
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
|
||||
dependencies:
|
||||
inherits "2.0.3"
|
Reference in New Issue
Block a user