Skip to content

Commit c0702a1

Browse files
authoredMar 7, 2023
feat: add metamodel and use metamodel in ciceromark and templatemark (#167)
Signed-off-by: Dan Selman <danscode@selman.org>
1 parent 7577d15 commit c0702a1

8 files changed

+1081
-3859
lines changed
 

‎build.js

+125-243
Large diffs are not rendered by default.

‎concertoVersions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ module.exports = {
3636
defaultVersion: '2.0.0',
3737
// '0.82.11': concertoFromVersion('0.82'),
3838
'2.0.0': concertoFromVersion('2.0'),
39-
'3.5.0': concertoFromVersion('3.5'),
39+
'3.6.0': concertoFromVersion('3.6'),
4040
};

‎package-lock.json

+555-3,600
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
"bulma": "^0.7.5",
2121
"concerto-core-0.82": "npm:@accordproject/concerto-core@0.82.11",
2222
"concerto-core-2.0": "npm:@accordproject/concerto-core@2.1.0",
23-
"concerto-core-3.5": "npm:@accordproject/concerto-core@3.5.0",
23+
"concerto-core-3.6": "npm:@accordproject/concerto-core@3.6.0",
2424
"concerto-cto-2.0": "npm:@accordproject/concerto-cto@2.1.0",
25-
"concerto-cto-3.5": "npm:@accordproject/concerto-cto@3.5.0",
25+
"concerto-cto-3.6": "npm:@accordproject/concerto-cto@3.6.0",
2626
"concerto-tools-0.82": "npm:@accordproject/concerto-tools@0.82.11",
2727
"concerto-tools-2.0": "npm:@accordproject/concerto-tools@2.1.0",
28-
"concerto-tools-3.5": "npm:@accordproject/concerto-tools@3.5.0",
28+
"concerto-tools-3.6": "npm:@accordproject/concerto-tools@3.6.0",
2929
"concerto-util-2.0": "npm:@accordproject/concerto-util@2.1.0",
30-
"concerto-util-3.5": "npm:@accordproject/concerto-util@3.5.0",
30+
"concerto-util-3.6": "npm:@accordproject/concerto-util@3.6.0",
3131
"fs-extra": "^6.0.1",
3232
"lodash": "^4.17.20",
3333
"mkdirp": "^1.0.4",

‎src/concerto/metamodel@1.0.0.cto

+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
concerto version "^3.0.0"
15+
16+
@DotNetNamespace("AccordProject.Concerto.Metamodel")
17+
namespace concerto.metamodel@1.0.0
18+
19+
concept Position {
20+
o Integer line
21+
o Integer column
22+
o Integer offset
23+
}
24+
25+
concept Range {
26+
o Position start
27+
o Position end
28+
o String source optional
29+
}
30+
31+
concept TypeIdentifier {
32+
o String name
33+
o String namespace optional
34+
}
35+
36+
abstract concept DecoratorLiteral {
37+
o Range location optional
38+
}
39+
40+
concept DecoratorString extends DecoratorLiteral {
41+
o String value
42+
}
43+
44+
concept DecoratorNumber extends DecoratorLiteral {
45+
o Double value
46+
}
47+
48+
concept DecoratorBoolean extends DecoratorLiteral {
49+
o Boolean value
50+
}
51+
52+
concept DecoratorTypeReference extends DecoratorLiteral {
53+
o TypeIdentifier type
54+
o Boolean isArray default=false
55+
}
56+
57+
concept Decorator {
58+
o String name
59+
o DecoratorLiteral[] arguments optional
60+
o Range location optional
61+
}
62+
63+
concept Identified {
64+
}
65+
66+
concept IdentifiedBy extends Identified {
67+
o String name
68+
}
69+
70+
abstract concept Declaration {
71+
o String name regex=/^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$/u
72+
o Decorator[] decorators optional
73+
o Range location optional
74+
}
75+
76+
concept EnumDeclaration extends Declaration {
77+
o EnumProperty[] properties
78+
}
79+
80+
concept EnumProperty {
81+
o String name regex=/^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$/u
82+
o Decorator[] decorators optional
83+
o Range location optional
84+
}
85+
86+
concept ConceptDeclaration extends Declaration {
87+
o Boolean isAbstract default=false
88+
o Identified identified optional
89+
o TypeIdentifier superType optional
90+
o Property[] properties
91+
}
92+
93+
concept AssetDeclaration extends ConceptDeclaration {
94+
}
95+
96+
concept ParticipantDeclaration extends ConceptDeclaration {
97+
}
98+
99+
concept TransactionDeclaration extends ConceptDeclaration {
100+
}
101+
102+
concept EventDeclaration extends ConceptDeclaration {
103+
}
104+
105+
abstract concept Property {
106+
o String name regex=/^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$/u
107+
o Boolean isArray default=false
108+
o Boolean isOptional default=false
109+
o Decorator[] decorators optional
110+
o Range location optional
111+
}
112+
113+
concept RelationshipProperty extends Property {
114+
o TypeIdentifier type
115+
}
116+
117+
concept ObjectProperty extends Property {
118+
o String defaultValue optional
119+
o TypeIdentifier type
120+
}
121+
122+
concept BooleanProperty extends Property {
123+
o Boolean defaultValue optional
124+
}
125+
126+
concept DateTimeProperty extends Property {
127+
}
128+
129+
concept StringProperty extends Property {
130+
o String defaultValue optional
131+
o StringRegexValidator validator optional
132+
}
133+
134+
concept StringRegexValidator {
135+
o String pattern
136+
o String flags
137+
}
138+
139+
concept DoubleProperty extends Property {
140+
o Double defaultValue optional
141+
o DoubleDomainValidator validator optional
142+
}
143+
144+
concept DoubleDomainValidator {
145+
o Double lower optional
146+
o Double upper optional
147+
}
148+
149+
concept IntegerProperty extends Property {
150+
o Integer defaultValue optional
151+
o IntegerDomainValidator validator optional
152+
}
153+
154+
concept IntegerDomainValidator {
155+
o Integer lower optional
156+
o Integer upper optional
157+
}
158+
159+
concept LongProperty extends Property {
160+
o Long defaultValue optional
161+
o LongDomainValidator validator optional
162+
}
163+
164+
concept LongDomainValidator {
165+
o Long lower optional
166+
o Long upper optional
167+
}
168+
169+
abstract concept Import {
170+
o String namespace
171+
o String uri optional
172+
}
173+
174+
concept ImportAll extends Import {
175+
}
176+
177+
concept ImportType extends Import {
178+
o String name
179+
}
180+
181+
concept ImportTypes extends Import {
182+
o String[] types
183+
}
184+
185+
concept Model {
186+
o String namespace
187+
o String sourceUri optional
188+
o String concertoVersion optional
189+
o Import[] imports optional
190+
o Declaration[] declarations optional
191+
o Decorator[] decorators optional
192+
}
193+
194+
concept Models {
195+
o Model[] models
196+
}
197+
198+
abstract concept ScalarDeclaration extends Declaration {
199+
}
200+
201+
concept BooleanScalar extends ScalarDeclaration {
202+
o Boolean defaultValue
203+
}
204+
205+
concept IntegerScalar extends ScalarDeclaration {
206+
o Integer defaultValue optional
207+
o IntegerDomainValidator validator optional
208+
}
209+
210+
concept LongScalar extends ScalarDeclaration {
211+
o Long defaultValue optional
212+
o LongDomainValidator validator optional
213+
}
214+
215+
concept DoubleScalar extends ScalarDeclaration {
216+
o Double defaultValue optional
217+
o DoubleDomainValidator validator optional
218+
}
219+
220+
concept StringScalar extends ScalarDeclaration {
221+
o String defaultValue optional
222+
o StringRegexValidator validator optional
223+
}
224+
225+
concept DateTimeScalar extends ScalarDeclaration {
226+
o String defaultValue optional
227+
}

‎src/markdown/ciceromark@0.5.0.cto

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
concerto version "^3.0.0"
15+
namespace org.accordproject.ciceromark@0.5.0
16+
17+
import org.accordproject.commonmark@0.5.0.Child from https://models.accordproject.org/markdown/commonmark@0.5.0.cto
18+
import concerto.metamodel@1.0.0.Decorator from https://models.accordproject.org/concerto/metamodel@1.0.0.cto
19+
20+
/**
21+
* A model for Accord Project extensions to commonmark
22+
*/
23+
24+
abstract concept Element extends Child {
25+
o String name
26+
o String elementType optional
27+
o Decorator[] decorators optional
28+
}
29+
30+
concept Variable extends Element {
31+
o String value
32+
o String identifiedBy optional
33+
}
34+
35+
concept FormattedVariable extends Variable {
36+
o String format
37+
}
38+
39+
concept EnumVariable extends Variable {
40+
o String[] enumValues
41+
}
42+
43+
concept Formula extends Element {
44+
o String value
45+
o String[] dependencies optional
46+
o String code optional
47+
}
48+
49+
abstract concept Block extends Element {
50+
}
51+
52+
concept Clause extends Block {
53+
o String src optional
54+
}
55+
56+
concept Conditional extends Block {
57+
o Boolean isTrue
58+
o Child[] whenTrue
59+
o Child[] whenFalse
60+
}
61+
62+
concept Optional extends Block {
63+
o Boolean hasSome
64+
o Child[] whenSome
65+
o Child[] whenNone
66+
}
67+
68+
concept ListBlock extends Block {
69+
o String type
70+
o String tight
71+
o String start optional
72+
o String delimiter optional
73+
}

‎src/markdown/templatemark@0.3.0.cto

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
concerto version "^3.0.0"
15+
namespace org.accordproject.templatemark@0.3.0
16+
17+
import org.accordproject.commonmark@0.5.0.Child from https://models.accordproject.org/markdown/commonmark@0.5.0.cto
18+
import concerto.metamodel@1.0.0.Decorator from https://models.accordproject.org/concerto/metamodel@1.0.0.cto
19+
20+
/**
21+
* A model for Accord Project template extensions to commonmark
22+
*/
23+
abstract concept ElementDefinition extends Child {
24+
o String name // Add Concerto regex
25+
o String elementType optional
26+
o Decorator[] decorators optional
27+
}
28+
29+
concept VariableDefinition extends ElementDefinition {
30+
o String identifiedBy optional
31+
}
32+
33+
concept FormattedVariableDefinition extends VariableDefinition {
34+
o String format
35+
}
36+
37+
concept EnumVariableDefinition extends VariableDefinition {
38+
o String[] enumValues
39+
}
40+
41+
concept FormulaDefinition extends ElementDefinition {
42+
o String[] dependencies optional // name of variables on which the formula depends
43+
o String code // Ergo expression
44+
}
45+
46+
abstract concept BlockDefinition extends ElementDefinition {
47+
}
48+
49+
concept ClauseDefinition extends BlockDefinition {
50+
}
51+
52+
concept ContractDefinition extends BlockDefinition {
53+
}
54+
55+
concept WithDefinition extends BlockDefinition {
56+
}
57+
58+
concept ConditionalDefinition extends BlockDefinition {
59+
o Child[] whenTrue
60+
o Child[] whenFalse
61+
}
62+
63+
concept OptionalDefinition extends BlockDefinition {
64+
o Child[] whenSome
65+
o Child[] whenNone
66+
}
67+
68+
concept JoinDefinition extends BlockDefinition {
69+
o String separator
70+
}
71+
72+
concept ListBlockDefinition extends BlockDefinition {
73+
o String type
74+
o String tight
75+
o String start optional
76+
o String delimiter optional
77+
}
78+
79+
concept ForeachBlockDefinition extends BlockDefinition {
80+
}
81+
82+
concept WithBlockDefinition extends BlockDefinition {
83+
}
84+
85+
concept ConditionalBlockDefinition extends BlockDefinition {
86+
o Child[] whenTrue
87+
o Child[] whenFalse
88+
}
89+
90+
concept OptionalBlockDefinition extends BlockDefinition {
91+
o Child[] whenSome
92+
o Child[] whenNone
93+
}

‎views/model.njk

+3-11
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,9 @@
2828
{% if concerto.MetaModel %}
2929
<a href="{{filePath}}.ast.json" alt="JSON Syntax Tree" title="JSON" class="button is-rounded is-primary">JSON AST</a>
3030
{% endif %}
31-
<a href="{{filePath}}.puml" alt="UML Diagram" title="UML Diagram" class="button is-rounded is-primary">UML</a>
32-
<a href="{{filePath}}.json" alt="JSON Schema" title="JSON Schema" class="button is-rounded is-primary">JSON Schema</a>
33-
<a href="{{filePath}}.xsd.zip" alt="XML Schema" title="XML Schema" class="button is-rounded is-primary">XML Schema</a>
34-
{% if concerto.CodeGen.GraphQLVisitor %}
35-
<a href="{{filePath}}.gql" alt="GraphQL Schema" title="GraphQL Schema" class="button is-rounded is-primary">GraphQL</a>
36-
{% endif %}
37-
<a href="{{filePath}}.ts.zip" alt="TypeScript Source Code" title="TypeScript Source Code" class="button is-rounded is-primary">TypeScript</a>
38-
<a href="{{filePath}}.cs.zip" alt="CSharp Source Code" title="CSharp Source Code" class="button is-rounded is-primary">CSharp</a>
39-
<a href="{{filePath}}.jar" alt="Java Source Code" title="Java Source Code" class="button is-rounded is-primary">Java</a>
40-
<a href="{{filePath}}.go.zip" alt="Go Source Code" title="Go Source Code" class="button is-rounded is-primary">Go</a>
41-
<a href="{{filePath}}.csdl.zip" alt="OData Source Code" title="OData Source Code" class="button is-rounded is-primary">OData</a>
31+
{% for gen in codeGenerators %}
32+
<a href="{{filePath}}.{{gen.ext}}.zip" alt="{{gen.name}}" title="{{gen.name}}" class="button is-rounded is-primary">{{gen.name}}</a>
33+
{% endfor %}
4234
</p>
4335
<img src="{{umlURL}}" class="box" style="margin-top:40px;" />
4436

0 commit comments

Comments
 (0)
Please sign in to comment.