domain-spec Pub

// ## Inventory examples

msg diesel.inv.findByRef  (inventory, connection, ref)

msg diesel.inv.findByQuery  (inventory, connection, ref, query, from?, limit?)

msg diesel.inv.listAll  (inventory, connection, ref, from?, limit?)

val tc1:TestClass1(JSON)<-{someValue:"something"}

$when:: diesel.inv.findByRef (ref)
   $ifc::(ref[="class"] == "TestClass1") . (payload=[tc1])
   $else:: . (payload=[])

$when:: diesel.inv.findByQuery (connection, ref, query, from?, limit?)
   . (payload=[])

Defining classes

Note that inside a class definition, you can't have free text, just other constructs.

list | new
class::TestClass1{

   def: simple
   def: withParms (x, y)
   def: withEmptyBody (x, y)
   msg: simpleMsg
   msg: expandedMsg
   def: simple
   def: withParms (x, y)
   def: withEmptyBody (x, y)
   msg: simpleMsg
   msg: expandedMsg

}

$when:: TestClass1.simpleMsg
   a.b

list | new
list | new
class::TestContainer [T]
list | new
class::TestEmptyBody

anno (  prop3<-"value")

anno (  prop1<-"value",   prop2<-"value")

list | new
class::TestAnnotated PROPS(  prop1:String="value",   prop2:String="value",   prop3:String="value")
list | new
class::TestWithParms (
    parm1,
    slainvokedid:<>SLA,
    list3:Array[TestContainer],
    parm1,
    slainvokedid:<>SLA,
    list3:Array[TestContainer])

simple scripting - JS by default

You can embed and use simple JS scripts like this:

fcall | jplay | splay
def: test.util.addMonths (mths)
  m = parseInt(mths);
  d = new Date();
  d.setMonth(d.getMonth() + m);
  x=0;
  // you can use for loops and any other JS construct that 
  // doesn't contain a double curly brace...
  for(i=0; i < 5; i++) {
    x = x+i;
  }
  return d.toISOString().replace(/T.*/g, '');
fcall | jplay | splay
def: test.util.today
  return new Date().toISOString().replace(/T.*/g, '');


Was this useful?    

By: Razie | 2020-10-16 | Tags: spec , dsl


Viewed 7 times ( | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2020, all rights reserved.