Class Block Api
Many prefer using a text based format for data modelling. This Schesign DSL (Domain Specific Language) is for writing and reading a schesign data design. Instead of writing and reading a JSON config file directly, this DSL is meant to be easier to read, write, and learn.
Note: When interacting with the schesign API, a pure json format is used. This library converts the Schesign DSL into that json.
Class Block Examples
Class MyClass {}
Class Class1 {
description: "My detailed class description";
subClassOf: Class2;
# required: boolean (optional)
# array: boolean (optional)
# primaryKey: boolean (optional)
# minItems: number (optional)
# maxItems: number (optional)
# Note: required is shorthand for minItems=1. These can't be used together
# Note: array is shorthand for maxItems="null". These can't be used together
properties: a, b required array primary index, c minItems=0 maxItems=10; }
Class Class2 { properties: d, e; }
Property Block Examples
Property propA {
description: "My detailed class description";
# Boolean, Text, Url, Email
# Number, Int, Int8, Int16, Int32, Int64, Float32, Float64
# DateTime, ShortDate, Time
# Enum, LinkedClass, NestedObject
range: Text; }
Property a { range: Boolean; }
Property a { range: Text regex="[a-z]"; } Property a1 { range: Text minLength=8 maxLength=12; } Property a2 { range: Url; } Property a3 { range: Email; }
Property b { range: Number min=10 max=100; } Property b1 { range: Int; } Property b1 { range: Int8; } Property b1 { range: Int16; } Property b1 { range: Int32; } Property b1 { range: Int64; } Property b1 { range: Float32; } Property b1 { range: Float64; }
Property c { range: DateTime; } Property c1 { range: ShortDate; } Property c2 { range: Time; }
Property d { range: Enum values=["one", "two", 1, 2.5]; }
Property e { range: NestedObject; properties: a, b; }
Property e { range: LinkedClass ref=Class2; } Property e1 { range: LinkedClass ref=u/user_a/design_a/1.0.0/class/class_a; }
TODO: excludeParentProperties Geo coordinates LinkedClass relation
[ { type: "block", label: { type: "var", value: "MyClass" }, body: [ { type: "assign", operator: ":", left: { type: "var", value: "description" }, right: { type: "str", value: "some desc" } }, { type: "assign", operator: ":", left: { type: "var", value: "properties" }, right: [ { type: "reference", label: { type: "var", value: "some_prop" }, constraints: [ { type: "var", value: "required" }, { type: "assign", operator: "=", left: { type: "str", value: "minItems" }, right: { type: "num", value: 3 } } ] } ] } ] } ]
[ type: "str", value: "Class",
]