[res]
This commit is contained in:
commit
910028908f
142
doc/examples/calendar.sindri.json
Normal file
142
doc/examples/calendar.sindri.json
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
{
|
||||||
|
"domains": [
|
||||||
|
{
|
||||||
|
"name": "calendar",
|
||||||
|
"key_field": {
|
||||||
|
"name": "id"
|
||||||
|
},
|
||||||
|
"data_fields": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"nullable": false,
|
||||||
|
"type": "string_short"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "description",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string_long"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "color",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string_short"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "calendar_appointment",
|
||||||
|
"key_field": {
|
||||||
|
"name": "id"
|
||||||
|
},
|
||||||
|
"data_fields": [
|
||||||
|
{
|
||||||
|
"name": "calendar_id",
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "title",
|
||||||
|
"nullable": false,
|
||||||
|
"type": "string_short"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "description",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string_long"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "location",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string_short"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "begin",
|
||||||
|
"description": "UNIX timestamp",
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "end",
|
||||||
|
"description": "UNIX timestamp",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "contact",
|
||||||
|
"nullable": true,
|
||||||
|
"type": "string_short"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"constraints": [
|
||||||
|
{
|
||||||
|
"kind": "foreign_key",
|
||||||
|
"parameters": {
|
||||||
|
"fields": [
|
||||||
|
"calendar_id"
|
||||||
|
],
|
||||||
|
"reference": {
|
||||||
|
"name": "calendar",
|
||||||
|
"fields": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "organization",
|
||||||
|
"key_field": {
|
||||||
|
"name": "id"
|
||||||
|
},
|
||||||
|
"data_fields": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "organization_calendars",
|
||||||
|
"data_fields": [
|
||||||
|
{
|
||||||
|
"name": "organization_id",
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "calendar_id",
|
||||||
|
"nullable": false,
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"constraints": [
|
||||||
|
{
|
||||||
|
"kind": "foreign_key",
|
||||||
|
"parameters": {
|
||||||
|
"fields": [
|
||||||
|
"organization_id"
|
||||||
|
],
|
||||||
|
"reference": {
|
||||||
|
"name": "organization",
|
||||||
|
"fields": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kind": "foreign_key",
|
||||||
|
"parameters": {
|
||||||
|
"fields": [
|
||||||
|
"calendar_id"
|
||||||
|
],
|
||||||
|
"reference": {
|
||||||
|
"name": "calendar",
|
||||||
|
"fields": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -126,4 +126,4 @@
|
||||||
"required": [
|
"required": [
|
||||||
"domains"
|
"domains"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
312
lib/plankton/plankton.d.ts
vendored
312
lib/plankton/plankton.d.ts
vendored
|
|
@ -925,6 +925,318 @@ declare namespace lib_plankton.file {
|
||||||
*/
|
*/
|
||||||
function write_buffer(path: string, content: Buffer, options?: {}): Promise<void>;
|
function write_buffer(path: string, content: Buffer, options?: {}): Promise<void>;
|
||||||
}
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
abstract class struct_expression {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_variable extends struct_expression {
|
||||||
|
name: string;
|
||||||
|
constructor(name: string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_literal extends struct_expression {
|
||||||
|
value: any;
|
||||||
|
constructor(value: any);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_dict extends struct_expression {
|
||||||
|
fields: Array<{
|
||||||
|
key: string;
|
||||||
|
value: struct_expression;
|
||||||
|
}>;
|
||||||
|
constructor(fields: Array<{
|
||||||
|
key: string;
|
||||||
|
value: struct_expression;
|
||||||
|
}>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_abstraction extends struct_expression {
|
||||||
|
arguments: Array<{
|
||||||
|
name: string;
|
||||||
|
type: (null | struct_type);
|
||||||
|
}>;
|
||||||
|
output_type: (null | struct_type);
|
||||||
|
body: Array<struct_statement>;
|
||||||
|
constructor(arguments_: Array<{
|
||||||
|
name: string;
|
||||||
|
type: (null | struct_type);
|
||||||
|
}>, output_type: (null | struct_type), body: Array<struct_statement>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_function_application extends struct_expression {
|
||||||
|
head: struct_expression;
|
||||||
|
arguments: Array<struct_expression>;
|
||||||
|
constructor(head: struct_expression, arguments_: Array<struct_expression>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_projection extends struct_expression {
|
||||||
|
source: struct_expression;
|
||||||
|
index: struct_expression;
|
||||||
|
constructor(source: struct_expression, index: struct_expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_fieldaccess extends struct_expression {
|
||||||
|
structure: struct_expression;
|
||||||
|
fieldname: string;
|
||||||
|
constructor(structure: struct_expression, fieldname: string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_expression_operation_comparison extends struct_expression {
|
||||||
|
left: struct_expression;
|
||||||
|
right: struct_expression;
|
||||||
|
constructor(left: struct_expression, right: struct_expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
abstract class struct_type {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_literal extends struct_type {
|
||||||
|
value: struct_expression;
|
||||||
|
constructor(value: struct_expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_any extends struct_type {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_void extends struct_type {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_boolean extends struct_type {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_integer extends struct_type {
|
||||||
|
constructor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_string extends struct_type {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_list extends struct_type {
|
||||||
|
element: struct_type;
|
||||||
|
constructor(element: struct_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_map extends struct_type {
|
||||||
|
key: struct_type;
|
||||||
|
value: struct_type;
|
||||||
|
constructor(key: struct_type, value: struct_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_record extends struct_type {
|
||||||
|
fields: Array<{
|
||||||
|
name: string;
|
||||||
|
type: struct_type;
|
||||||
|
mandatory: boolean;
|
||||||
|
}>;
|
||||||
|
constructor(fields: Array<{
|
||||||
|
name: string;
|
||||||
|
type: struct_type;
|
||||||
|
mandatory: boolean;
|
||||||
|
}>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_function extends struct_type {
|
||||||
|
arguments: Array<struct_type>;
|
||||||
|
target: struct_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_construction extends struct_type {
|
||||||
|
name: string;
|
||||||
|
arguments: (null | Array<struct_type>);
|
||||||
|
constructor(name: string, arguments_: (null | Array<struct_type>));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_union extends struct_type {
|
||||||
|
left: struct_type;
|
||||||
|
right: struct_type;
|
||||||
|
constructor(left: struct_type, right: struct_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_type_intersection extends struct_type {
|
||||||
|
left: struct_type;
|
||||||
|
right: struct_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
abstract class struct_statement {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_statement_block extends struct_statement {
|
||||||
|
statements: Array<struct_statement>;
|
||||||
|
constructor(statements: Array<struct_statement>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_statement_type_definition extends struct_statement {
|
||||||
|
name: string;
|
||||||
|
type: struct_type;
|
||||||
|
constructor(name: string, type: struct_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_statement_declaration extends struct_statement {
|
||||||
|
constant: boolean;
|
||||||
|
name: string;
|
||||||
|
type: (null | struct_type);
|
||||||
|
value: (null | struct_expression);
|
||||||
|
constructor(constant: boolean, name: string, type: (null | struct_type), value: (null | struct_expression));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_statement_assignment extends struct_statement {
|
||||||
|
name: string;
|
||||||
|
value: (null | struct_expression);
|
||||||
|
constructor(name: string, value: (null | struct_expression));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_statement_function_definition extends struct_statement {
|
||||||
|
name: string;
|
||||||
|
arguments: Array<{
|
||||||
|
name: string;
|
||||||
|
type: (null | struct_type);
|
||||||
|
}>;
|
||||||
|
output_type: (null | struct_type);
|
||||||
|
body: Array<struct_statement>;
|
||||||
|
constructor(name: string, arguments_: Array<{
|
||||||
|
name: string;
|
||||||
|
type: (null | struct_type);
|
||||||
|
}>, output_type: (null | struct_type), body: Array<struct_statement>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_statement_return extends struct_statement {
|
||||||
|
expression: struct_expression;
|
||||||
|
constructor(expression: struct_expression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_program {
|
||||||
|
statements: Array<struct_statement>;
|
||||||
|
constructor(statements: Array<struct_statement>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
type type_output = {
|
||||||
|
render_expression: ((expression: struct_expression) => string);
|
||||||
|
render_type: ((type: struct_type) => string);
|
||||||
|
render_statement: ((program: struct_statement) => string);
|
||||||
|
render_program: ((program: struct_program) => string);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
declare namespace lib_plankton.prog {
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function render_type(type: struct_type, options?: {
|
||||||
|
indent?: boolean;
|
||||||
|
level?: int;
|
||||||
|
}): string;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function render_expression(expression: struct_expression, options?: {
|
||||||
|
indent?: boolean;
|
||||||
|
level?: int;
|
||||||
|
}): string;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function render_statement(statement: struct_statement, options?: {
|
||||||
|
indent?: boolean;
|
||||||
|
level?: int;
|
||||||
|
}): string;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function render_program(program: struct_program): string;
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function output_typescript(): type_output;
|
||||||
|
}
|
||||||
declare namespace lib_plankton.args {
|
declare namespace lib_plankton.args {
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -5,10 +5,10 @@ async function main(
|
||||||
) : Promise<void>
|
) : Promise<void>
|
||||||
{
|
{
|
||||||
const outputs : Record<string, type_output> = {
|
const outputs : Record<string, type_output> = {
|
||||||
"sqlite": output_sqlite,
|
|
||||||
"mysql": output_mysql,
|
|
||||||
"backend-typescript": output_typescript,
|
|
||||||
"jsonschema": output_jsonschema,
|
"jsonschema": output_jsonschema,
|
||||||
|
"database-sqlite": output_database_sqlite,
|
||||||
|
"database-mysql": output_database_mysql,
|
||||||
|
"backend-typescript": output_backend_typescript,
|
||||||
};
|
};
|
||||||
|
|
||||||
const arg_handler = new lib_plankton.args.class_handler(
|
const arg_handler = new lib_plankton.args.class_handler(
|
||||||
|
|
@ -18,7 +18,7 @@ async function main(
|
||||||
"type": lib_plankton.args.enum_type.string,
|
"type": lib_plankton.args.enum_type.string,
|
||||||
"kind": lib_plankton.args.enum_kind.volatile,
|
"kind": lib_plankton.args.enum_kind.volatile,
|
||||||
"mode": lib_plankton.args.enum_mode.replace,
|
"mode": lib_plankton.args.enum_mode.replace,
|
||||||
"default": "sqlite",
|
"default": "database-sqlite",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"indicators_long": ["format"],
|
"indicators_long": ["format"],
|
||||||
"indicators_short": ["f"],
|
"indicators_short": ["f"],
|
||||||
|
|
|
||||||
646
source/outputs/backend_typescript.ts
Normal file
646
source/outputs/backend_typescript.ts
Normal file
|
|
@ -0,0 +1,646 @@
|
||||||
|
namespace _sindri.outputs.backend.typescript
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function render(
|
||||||
|
input_data
|
||||||
|
) : string
|
||||||
|
{
|
||||||
|
const map_primitive_type = function (typename : string) : lib_plankton.prog.struct_type {
|
||||||
|
const mymap : Record<string, lib_plankton.prog.struct_type> = {
|
||||||
|
"boolean": new lib_plankton.prog.struct_type_boolean(),
|
||||||
|
"integer": new lib_plankton.prog.struct_type_integer(),
|
||||||
|
// "float": new lib_plankton.prog.struct_type_integer(),
|
||||||
|
"string_short": new lib_plankton.prog.struct_type_string(),
|
||||||
|
"string_medium": new lib_plankton.prog.struct_type_string(),
|
||||||
|
"string_long": new lib_plankton.prog.struct_type_string(),
|
||||||
|
};
|
||||||
|
return mymap[typename];
|
||||||
|
};
|
||||||
|
const prog_output : lib_plankton.prog.type_output = lib_plankton.prog.output_typescript();
|
||||||
|
const name_table = function (domain) : string {return (domain.name);};
|
||||||
|
const name_type = function (domain) : string {return ("type_" + domain.name);};
|
||||||
|
const name_collection = function (domain) : string {return ("collection_" + domain.name);};
|
||||||
|
const name_repository_function_list = function (domain) : string {
|
||||||
|
return lib_plankton.string.coin(
|
||||||
|
"repository_{{name}}_list",
|
||||||
|
{
|
||||||
|
"name": domain.name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const name_repository_function_read = function (domain) : string {
|
||||||
|
return lib_plankton.string.coin(
|
||||||
|
"repository_{{name}}_read",
|
||||||
|
{
|
||||||
|
"name": domain.name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const name_repository_function_create = function (domain) : string {
|
||||||
|
return lib_plankton.string.coin(
|
||||||
|
"repository_{{name}}_create",
|
||||||
|
{
|
||||||
|
"name": domain.name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const name_repository_function_update = function (domain) : string {
|
||||||
|
return lib_plankton.string.coin(
|
||||||
|
"repository_{{name}}_update",
|
||||||
|
{
|
||||||
|
"name": domain.name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const name_repository_function_delete = function (domain) : string {
|
||||||
|
return lib_plankton.string.coin(
|
||||||
|
"repository_{{name}}_delete",
|
||||||
|
{
|
||||||
|
"name": domain.name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return prog_output.render_program(
|
||||||
|
new lib_plankton.prog.struct_program(
|
||||||
|
[]
|
||||||
|
// base
|
||||||
|
.concat(
|
||||||
|
[
|
||||||
|
]
|
||||||
|
)
|
||||||
|
// lib (database)
|
||||||
|
.concat(
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
"sql_query_get",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "template",
|
||||||
|
"type": new lib_plankton.prog.struct_type_string(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "arguments",
|
||||||
|
"type": new lib_plankton.prog.struct_type_map(
|
||||||
|
new lib_plankton.prog.struct_type_string(),
|
||||||
|
new lib_plankton.prog.struct_type_any()
|
||||||
|
),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Array",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Record",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_string(),
|
||||||
|
new lib_plankton.prog.struct_type_any(),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
new lib_plankton.prog.struct_expression_literal(null)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
"sql_query_put",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "template",
|
||||||
|
"type": new lib_plankton.prog.struct_type_string(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "arguments",
|
||||||
|
"type": new lib_plankton.prog.struct_type_map(
|
||||||
|
new lib_plankton.prog.struct_type_string(),
|
||||||
|
new lib_plankton.prog.struct_type_any()
|
||||||
|
),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_integer(),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
new lib_plankton.prog.struct_expression_literal(null)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
"sql_query_set",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "template",
|
||||||
|
"type": new lib_plankton.prog.struct_type_string(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "arguments",
|
||||||
|
"type": new lib_plankton.prog.struct_type_map(
|
||||||
|
new lib_plankton.prog.struct_type_string(),
|
||||||
|
new lib_plankton.prog.struct_type_any()
|
||||||
|
),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_void(),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
new lib_plankton.prog.struct_expression_literal(null)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
// entities
|
||||||
|
.concat(
|
||||||
|
input_data["domains"]
|
||||||
|
.map(
|
||||||
|
(domain) => new lib_plankton.prog.struct_statement_type_definition(
|
||||||
|
name_type(domain),
|
||||||
|
new lib_plankton.prog.struct_type_record(
|
||||||
|
domain.data_fields
|
||||||
|
.map(
|
||||||
|
(data_field) => ({
|
||||||
|
"name": data_field.name,
|
||||||
|
"type": (
|
||||||
|
data_field.nullable
|
||||||
|
? new lib_plankton.prog.struct_type_union(
|
||||||
|
new lib_plankton.prog.struct_type_literal(
|
||||||
|
new lib_plankton.prog.struct_expression_literal(
|
||||||
|
null
|
||||||
|
)
|
||||||
|
),
|
||||||
|
map_primitive_type(data_field["type"])
|
||||||
|
)
|
||||||
|
: map_primitive_type(data_field["type"])
|
||||||
|
),
|
||||||
|
"mandatory": true,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// repositories
|
||||||
|
.concat(
|
||||||
|
input_data["domains"]
|
||||||
|
.map(
|
||||||
|
(domain) => (
|
||||||
|
(domain.key_field === null)
|
||||||
|
? [
|
||||||
|
// TODO
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
// list
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
name_repository_function_list(domain),
|
||||||
|
[],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Array",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_record(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "key",
|
||||||
|
"type": new lib_plankton.prog.struct_type_integer(),
|
||||||
|
"mandatory": true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": new lib_plankton.prog.struct_type_construction(
|
||||||
|
name_type(domain),
|
||||||
|
null
|
||||||
|
),
|
||||||
|
"mandatory": true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_fieldaccess(
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("sql_query_get"),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_literal(
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"SELECT {{fields}} FROM {{name}};",
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
[domain.key_field.name]
|
||||||
|
.concat(domain.data_fields.map(field => field.name))
|
||||||
|
.join(",")
|
||||||
|
),
|
||||||
|
"name": name_table(domain),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
[
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
"then"
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_abstraction(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "rows",
|
||||||
|
"type": null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_fieldaccess(
|
||||||
|
new lib_plankton.prog.struct_expression_variable(
|
||||||
|
"rows"
|
||||||
|
),
|
||||||
|
"map"
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_abstraction(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "row",
|
||||||
|
"type": null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "key",
|
||||||
|
"value": new lib_plankton.prog.struct_expression_projection(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("row"),
|
||||||
|
new lib_plankton.prog.struct_expression_literal(domain.key_field.name)
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "value",
|
||||||
|
"value": new lib_plankton.prog.struct_expression_dict(
|
||||||
|
domain.data_fields
|
||||||
|
.map(
|
||||||
|
field => ({
|
||||||
|
"key": field.name,
|
||||||
|
"value": new lib_plankton.prog.struct_expression_projection(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("row"),
|
||||||
|
new lib_plankton.prog.struct_expression_literal(field.name)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
// read
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
name_repository_function_read(domain),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "key",
|
||||||
|
"type": new lib_plankton.prog.struct_type_integer(
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
name_type(domain),
|
||||||
|
null
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_fieldaccess(
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("sql_query_get"),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_literal(
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"SELECT {{fields}} FROM {{name}} WHERE ({{key}} = :key);",
|
||||||
|
{
|
||||||
|
"fields": (
|
||||||
|
[]
|
||||||
|
.concat(domain.data_fields.map(field => field.name))
|
||||||
|
.join(",")
|
||||||
|
),
|
||||||
|
"name": name_table(domain),
|
||||||
|
"key": domain.key_field.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "key",
|
||||||
|
"value": new lib_plankton.prog.struct_expression_variable("key"),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
"then"
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_abstraction(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "rows",
|
||||||
|
"type": null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_declaration(
|
||||||
|
true,
|
||||||
|
"row",
|
||||||
|
null,
|
||||||
|
new lib_plankton.prog.struct_expression_projection(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("rows"),
|
||||||
|
new lib_plankton.prog.struct_expression_literal(0),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
domain.data_fields
|
||||||
|
.map(
|
||||||
|
field => ({
|
||||||
|
"key": field.name,
|
||||||
|
"value": new lib_plankton.prog.struct_expression_projection(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("row"),
|
||||||
|
new lib_plankton.prog.struct_expression_literal(field.name)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
// create
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
name_repository_function_create(domain),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": new lib_plankton.prog.struct_type_construction(
|
||||||
|
name_type(domain),
|
||||||
|
null
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_integer(
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("sql_query_put"),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_literal(
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"INSERT INTO {{name}}({{fields}}) VALUES ({{values}});",
|
||||||
|
{
|
||||||
|
"name": name_table(domain),
|
||||||
|
"fields": (
|
||||||
|
domain.data_fields
|
||||||
|
.map(field => field.name)
|
||||||
|
.join(",")
|
||||||
|
),
|
||||||
|
"values": (
|
||||||
|
domain.data_fields
|
||||||
|
.map(field => (":" + field.name))
|
||||||
|
.join(",")
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
domain.data_fields
|
||||||
|
.map(
|
||||||
|
field => ({
|
||||||
|
"key": field.name,
|
||||||
|
"value": new lib_plankton.prog.struct_expression_fieldaccess(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("value"),
|
||||||
|
field.name,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
// update
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
name_repository_function_update(domain),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "key",
|
||||||
|
"type": new lib_plankton.prog.struct_type_integer(
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "value",
|
||||||
|
"type": new lib_plankton.prog.struct_type_construction(
|
||||||
|
name_type(domain),
|
||||||
|
null
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_void(
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("sql_query_set"),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_literal(
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"UPDATE {{name}} SET {{settings}} WHERE ({{key}} = :key);",
|
||||||
|
{
|
||||||
|
"name": name_table(domain),
|
||||||
|
"key": domain.key_field.name,
|
||||||
|
"settings": (
|
||||||
|
domain.data_fields
|
||||||
|
.map(
|
||||||
|
field => lib_plankton.string.coin(
|
||||||
|
"{{key}} = {{value}}",
|
||||||
|
{
|
||||||
|
"key": field.name,
|
||||||
|
"value": (":" + field.name),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.join(", ")
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
[]
|
||||||
|
.concat(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "key",
|
||||||
|
"value": new lib_plankton.prog.struct_expression_variable("key"),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.concat(
|
||||||
|
domain.data_fields
|
||||||
|
.map(
|
||||||
|
field => ({
|
||||||
|
"key": field.name,
|
||||||
|
"value": new lib_plankton.prog.struct_expression_fieldaccess(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("value"),
|
||||||
|
field.name,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
// delete
|
||||||
|
new lib_plankton.prog.struct_statement_function_definition(
|
||||||
|
name_repository_function_delete(domain),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "key",
|
||||||
|
"type": new lib_plankton.prog.struct_type_integer(
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
new lib_plankton.prog.struct_type_construction(
|
||||||
|
"Promise",
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_type_void(),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_statement_return(
|
||||||
|
// TODO
|
||||||
|
new lib_plankton.prog.struct_expression_function_application(
|
||||||
|
new lib_plankton.prog.struct_expression_variable("sql_query_set"),
|
||||||
|
[
|
||||||
|
new lib_plankton.prog.struct_expression_literal(
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"DELETE FROM {{name}} WHERE ({{key}} = :key);",
|
||||||
|
{
|
||||||
|
"name": name_table(domain),
|
||||||
|
"key": domain.key_field.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
new lib_plankton.prog.struct_expression_dict(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"key": "key",
|
||||||
|
"value": new lib_plankton.prog.struct_expression_variable("key"),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.reduce(
|
||||||
|
(x, y) => x.concat(y),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// services
|
||||||
|
.concat(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
// api
|
||||||
|
.concat(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
// server
|
||||||
|
.concat(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const output_backend_typescript : type_output = {
|
||||||
|
"render": _sindri.outputs.backend.typescript.render,
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace _sindri.outputs.mysql
|
namespace _sindri.outputs.database.mysql
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -212,6 +212,6 @@ namespace _sindri.outputs.mysql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
const output_mysql : type_output = {
|
const output_database_mysql : type_output = {
|
||||||
"render": _sindri.outputs.mysql.render,
|
"render": _sindri.outputs.database.mysql.render,
|
||||||
};
|
};
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace _sindri.outputs.sqlite
|
namespace _sindri.outputs.database.sqlite
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -174,6 +174,6 @@ namespace _sindri.outputs.sqlite
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const output_sqlite : type_output = {
|
const output_database_sqlite : type_output = {
|
||||||
"render": _sindri.outputs.sqlite.render,
|
"render": _sindri.outputs.database.sqlite.render,
|
||||||
};
|
};
|
||||||
|
|
@ -1,173 +0,0 @@
|
||||||
namespace _sindri.outputs.typescript
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function render_entity_type(
|
|
||||||
domain
|
|
||||||
) : string
|
|
||||||
{
|
|
||||||
return lib_plankton.string.coin(
|
|
||||||
"type type_{{name}} = {\n{{fields}}\n};\n",
|
|
||||||
{
|
|
||||||
"name": domain.name,
|
|
||||||
"fields": (
|
|
||||||
domain.data_fields
|
|
||||||
.map(
|
|
||||||
(data_field) => lib_plankton.string.coin(
|
|
||||||
"\t{{name}} : {{type}};{{macro_comment}}",
|
|
||||||
{
|
|
||||||
"name": data_field.name,
|
|
||||||
"type": lib_plankton.string.coin(
|
|
||||||
(data_field.nullable ? "(null | {{core}})" : "{{core}}"),
|
|
||||||
{
|
|
||||||
"core": {
|
|
||||||
"boolean": "boolean",
|
|
||||||
"integer": "number",
|
|
||||||
"float": "number",
|
|
||||||
"string_short": "string",
|
|
||||||
"string_medium": "string",
|
|
||||||
"string_long": "string",
|
|
||||||
}[data_field["type"]],
|
|
||||||
}
|
|
||||||
),
|
|
||||||
"macro_comment": (
|
|
||||||
(data_field.description !== null)
|
|
||||||
? lib_plankton.string.coin(
|
|
||||||
" // {{comment}}",
|
|
||||||
{
|
|
||||||
"comment": data_field.description,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
: ""
|
|
||||||
),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// .map(x => ("\t" + x))
|
|
||||||
.join("\n")
|
|
||||||
),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function render_entity_collection(
|
|
||||||
domain
|
|
||||||
) : string
|
|
||||||
{
|
|
||||||
return lib_plankton.string.coin(
|
|
||||||
"let collection_{{name}} : {{collection_type}} = {{collection_value}};\n",
|
|
||||||
{
|
|
||||||
"name": domain.name,
|
|
||||||
"collection_type": (
|
|
||||||
(domain.key_field === null)
|
|
||||||
? lib_plankton.string.coin(
|
|
||||||
"Array<type_{{name}}>",
|
|
||||||
{
|
|
||||||
"name": domain.name,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
: lib_plankton.string.coin(
|
|
||||||
"Record<number, type_{{name}}>",
|
|
||||||
{
|
|
||||||
"name": domain.name,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"collection_value": (
|
|
||||||
(domain.key_field === null)
|
|
||||||
? "[]"
|
|
||||||
: "{}"
|
|
||||||
),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function render_entity(
|
|
||||||
domain
|
|
||||||
) : string
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
render_entity_type(domain)
|
|
||||||
+
|
|
||||||
render_entity_collection(domain)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function render_functions(
|
|
||||||
domain
|
|
||||||
) : string
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
[
|
|
||||||
// list
|
|
||||||
"function {{name}}_list() : Promise<type_{{name}}> {return sql_query_get(\"SELECT * FROM {{name}};\");}",
|
|
||||||
// read
|
|
||||||
"",
|
|
||||||
// create
|
|
||||||
"",
|
|
||||||
// update
|
|
||||||
"",
|
|
||||||
// delete
|
|
||||||
"",
|
|
||||||
]
|
|
||||||
.join("\n\n")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
function render_api_actions(
|
|
||||||
domain
|
|
||||||
) : string
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
[
|
|
||||||
// list
|
|
||||||
"",
|
|
||||||
// read
|
|
||||||
"",
|
|
||||||
// create
|
|
||||||
"",
|
|
||||||
// update
|
|
||||||
"",
|
|
||||||
// delete
|
|
||||||
"",
|
|
||||||
]
|
|
||||||
.join("\n\n")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function render(
|
|
||||||
input_data
|
|
||||||
) : string
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
input_data["domains"]
|
|
||||||
.map(
|
|
||||||
(domain) => render_entity(domain)
|
|
||||||
)
|
|
||||||
.map(x => (x + "\n"))
|
|
||||||
.join("\n")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const output_typescript : type_output = {
|
|
||||||
"render": _sindri.outputs.typescript.render,
|
|
||||||
};
|
|
||||||
|
|
@ -6,6 +6,7 @@ modules="${modules} base"
|
||||||
modules="${modules} string"
|
modules="${modules} string"
|
||||||
modules="${modules} json"
|
modules="${modules} json"
|
||||||
modules="${modules} file"
|
modules="${modules} file"
|
||||||
|
modules="${modules} prog"
|
||||||
modules="${modules} args"
|
modules="${modules} args"
|
||||||
|
|
||||||
mkdir -p lib/plankton
|
mkdir -p lib/plankton
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ cmd_typescript_compile := tsc
|
||||||
cmd_concatenate := cat
|
cmd_concatenate := cat
|
||||||
cmd_chmod := chmod
|
cmd_chmod := chmod
|
||||||
cmd_echo := echo -e
|
cmd_echo := echo -e
|
||||||
|
cmd_echox := echo
|
||||||
cmd_log := echo -e "--"
|
cmd_log := echo -e "--"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,10 +17,10 @@ all: build/sindri
|
||||||
temp/sindri-unlinked.js: \
|
temp/sindri-unlinked.js: \
|
||||||
lib/plankton/plankton.d.ts \
|
lib/plankton/plankton.d.ts \
|
||||||
source/types.ts \
|
source/types.ts \
|
||||||
source/outputs/sqlite.ts \
|
|
||||||
source/outputs/mysql.ts \
|
|
||||||
source/outputs/jsonschema.ts \
|
source/outputs/jsonschema.ts \
|
||||||
source/outputs/typescript.ts \
|
source/outputs/database_sqlite.ts \
|
||||||
|
source/outputs/database_mysql.ts \
|
||||||
|
source/outputs/backend_typescript.ts \
|
||||||
source/conf.ts \
|
source/conf.ts \
|
||||||
source/main.ts
|
source/main.ts
|
||||||
@ ${cmd_log} "compiling …"
|
@ ${cmd_log} "compiling …"
|
||||||
|
|
@ -29,7 +30,7 @@ source/main.ts
|
||||||
build/sindri: lib/plankton/plankton.js temp/sindri-unlinked.js
|
build/sindri: lib/plankton/plankton.js temp/sindri-unlinked.js
|
||||||
@ ${cmd_log} "linking …"
|
@ ${cmd_log} "linking …"
|
||||||
@ ${cmd_create_directory} build
|
@ ${cmd_create_directory} build
|
||||||
@ ${cmd_echo} "#!/usr/bin/env node\n" > temp/head.js
|
@ ${cmd_echo} "#!/usr/bin/env node" > temp/head.js
|
||||||
@ ${cmd_concatenate} temp/head.js $^ > $@
|
@ ${cmd_concatenate} temp/head.js $^ > $@
|
||||||
@ ${cmd_chmod} +x $@
|
@ ${cmd_chmod} +x $@
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue