1 /**
2  * Hand-written definition of Schema Salad v1.2
3  * Authors: Tomoya Tanjo
4  * Copyright: © 2021 Tomoya Tanjo
5  * License: Apache-2.0
6  */
7 module salad.schema_original;
8 
9 import salad.context : LoadingContext;
10 import salad.exception;
11 import salad.meta;
12 import salad.type;
13 import salad.util;
14 
15 import std.typecons : Tuple;
16 
17 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#SaladRecordSchema
18 @documentRoot class SaladRecordSchema
19 {
20     @id string name_;
21     immutable type_ = "record";
22     Optional!bool inVocab_;
23     @idMap("name", "type") Optional!(SaladRecordField[]) fields_;
24     Optional!(string, string[]) doc_;
25     Optional!string docParent_;
26     Optional!(string, string[]) docChild_;
27     Optional!string docAfter_;
28     Optional!(string, JsonldPredicate) jsonldPredicate_;
29     Optional!bool documentRoot_;
30     Optional!bool abstract_;
31     Optional!(string, string[]) extends_;
32     @idMap("specializeFrom", "specializeTo") Optional!(SpecializeDef[]) specialize_;
33 
34     mixin genCtor;
35     mixin genIdentifier;
36     mixin genToString;
37 }
38 
39 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#SaladRecordField
40 class SaladRecordField
41 {
42     @id string name_;
43     @typeDSL
44     Either!(
45         PrimitiveType,
46         RecordSchema,
47         EnumSchema,
48         ArraySchema,
49         string,
50         Either!(
51             PrimitiveType,
52             RecordSchema,
53             EnumSchema,
54             ArraySchema,
55             string)[]
56     ) type_;
57     Optional!(string, string[]) doc_;
58     Optional!(string, JsonldPredicate) jsonldPredicate_;
59     Optional!Any default_;
60 
61     mixin genCtor;
62     mixin genIdentifier;
63     mixin genToString;
64 }
65 
66 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#PrimitiveType
67 class PrimitiveType
68 {
69     import dyaml : Node;
70 
71     enum Types{
72         null_ = "null",
73         boolean_ = "boolean",
74         int_ = "int",
75         long_ = "long",
76         float_ = "float",
77         double_ = "double",
78         string_ = "string",
79     }
80 
81     string type_;
82 
83     this(in Node node, in LoadingContext context = LoadingContext.init) @safe
84     {
85         type_ = node.as!string;
86         // enforce
87     }
88 }
89 
90 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#Any
91 class Any
92 {
93     import dyaml : Node;
94 
95     enum Types{
96         Any = "Any",
97     }
98 
99     string type_;
100 
101     this(in Node node, in LoadingContext context = LoadingContext.init) @safe
102     {
103         type_ = node.as!string;
104         // enforce
105     }
106 }
107 
108 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#RecordSchema
109 class RecordSchema
110 {
111     immutable type_ = "record";
112     @idMap("name", "type") Optional!(RecordField[]) fields_;
113 
114     mixin genCtor;
115     mixin genIdentifier;
116     mixin genToString;
117 }
118 
119 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#RecordField
120 class RecordField
121 {
122     @id string name_;
123     @typeDSL 
124     Either!(
125         PrimitiveType,
126         RecordSchema,
127         EnumSchema,
128         ArraySchema,
129         string,
130         Either!(
131             PrimitiveType,
132             RecordSchema,
133             EnumSchema,
134             ArraySchema,
135             string)[]
136     ) type_;
137     Optional!(string, string[]) doc_;
138 
139     mixin genCtor;
140     mixin genIdentifier;
141     mixin genToString;
142 }
143 
144 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#EnumSchema
145 class EnumSchema
146 {
147     string[] symbols_;
148     immutable type_ = "enum";
149 
150     mixin genCtor;
151     mixin genIdentifier;
152     mixin genToString;
153 }
154 
155 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#ArraySchema
156 class ArraySchema
157 {
158     Either!(
159         PrimitiveType,
160         RecordSchema,
161         EnumSchema,
162         ArraySchema,
163         string,
164         Either!(
165             PrimitiveType,
166             RecordSchema,
167             EnumSchema,
168             ArraySchema,
169             string)[]
170     ) items_;
171     immutable type_ = "array";
172 
173     mixin genCtor;
174     mixin genIdentifier;
175     mixin genToString;
176 }
177 
178 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#JsonldPredicate
179 class JsonldPredicate
180 {
181     Optional!string _id_;
182     Optional!string _type_;
183     Optional!string _container_;
184     Optional!bool identity_;
185     Optional!bool noLinkCheck_;
186     Optional!string mapSubject_;
187     Optional!string mapPredicate_;
188     Optional!int refScope_;
189     Optional!bool typeDSL_;
190     Optional!bool secondaryFilesDSL_;
191     Optional!string subscope_;
192 
193     mixin genCtor;
194     mixin genIdentifier;
195     mixin genToString;
196 }
197 
198 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#SpecializeDef
199 class SpecializeDef
200 {
201     string specializeFrom_;
202     string specializeTo_;
203 
204     mixin genCtor;
205     mixin genIdentifier;
206     mixin genToString;
207 }
208 
209 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#SaladEnumSchema
210 @documentRoot class SaladEnumSchema
211 {
212     @id string name_;
213     string[] symbols_;
214     immutable type_ = "enum";
215     Optional!bool inVocab_;
216     Optional!(string, string[]) doc_;
217     Optional!string docParent_;
218     Optional!(string, string[]) docChild_;
219     Optional!string docAfter_;
220     Optional!(string, JsonldPredicate) jsonldPredicate_;
221     Optional!bool documentRoot_;
222     Optional!(string, string[]) extends_;
223 
224     mixin genCtor;
225     mixin genIdentifier;
226     mixin genToString;
227 }
228 
229 /// See_Also: https://www.commonwl.org/v1.2/SchemaSalad.html#Documentation
230 @documentRoot class Documentation
231 {
232     @id string name_;
233     immutable type_ = "documentation";
234     Optional!bool inVocab_;
235     Optional!(string, string[]) doc_;
236     Optional!string docParent_;
237     Optional!(string, string[]) docChild_;
238     Optional!string docAfter_;
239 
240     mixin genCtor;
241     mixin genIdentifier;
242     mixin genToString;
243 }