-
Notifications
You must be signed in to change notification settings - Fork 5
/
openmath2.d.ts
256 lines (197 loc) · 5 KB
/
openmath2.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/**
* TypeScript Definitions for an OpenMath JSON encoding
*
* (c) Tom Wiesing 2018-19
* @license CC-BY-3.0
*/
// WARNING: After updating this file, run "yarn saveschema" to generate the new schema
/** Any OpenMath element (or related element) */
export type omany = OMOBJ | OMFOREIGN | omel;
/** OpenMath Object Constructor */
export interface OMOBJ extends withCD {
kind: 'OMOBJ'
openmath?: '2.0'
object: omel
}
/** Elements which can appear inside an OpenMath object */
export type omel = OMS | OMV | OMI | OMB | OMSTR | OMF | OMA | OMBIND | OME | OMATTR | OMR;
/** Symbol */
export interface OMS extends withCD {
kind: 'OMS'
/** content dictonary the symbol is in */
cd: name
/** name of the symbol */
name: name
}
/** Variable */
export interface OMV extends referencable {
kind: 'OMV'
/** the name of the variable */
name: name
}
/** an integer */
export type OMI = omiint | omidec | omihex;
interface omikind extends referencable { kind: 'OMI' }
interface omiint extends omikind { integer: integer }
interface omidec extends omikind { decimal: decimalInteger }
interface omihex extends omikind { hexadecimal: hexInteger }
/** IEEE floating point */
export type OMF = omffloat | omfdec | omfhex;
interface omfkind extends referencable { kind: 'OMF' }
interface omffloat extends omfkind { float: float }
interface omfdec extends omfkind { decimal: decimalFloat }
interface omfhex extends omfkind { hexadecimal: hexFloat }
/** bytes */
export type OMB = ombbytes | ombbase64;
interface ombkind extends referencable { kind: 'OMB' }
interface ombbytes extends ombkind { bytes: byte[] }
interface ombbase64 extends ombkind { base64: base64string }
/** String */
export interface OMSTR extends referencable {
kind: 'OMSTR'
/** the string */
string: string
}
/** Application */
export interface OMA extends withCD {
kind: 'OMA'
/** the term that is being applied */
applicant: omel
/** the arguments that the applicant is being applied to */
arguments?: omel[]
}
/** Attributed object */
export interface OMATTR extends withCD {
kind: 'OMATTR'
/** attributes attributed to this object */
attributes: omattributes
/** object that is being attributed */
object: omel
}
/**
* Attributes for the OMATTR Constructor
* @minItems 1
*/
type omattributes = ([OMS, omel|OMFOREIGN])[];
/** Binding */
export interface OMBIND extends withCD {
kind: 'OMBIND'
/** the binder being used */
binder: omel
/** the variables being bound */
variables: attvars
/** the object that is being bound */
object: omel
}
/**
* List of variables or attributed variables
* @minItems 1
*/
type attvars = (OMV | attvar)[];
/** Attributed variable */
interface attvar extends OMATTR {
object: OMV
}
/** Error */
export interface OME extends referencable {
kind: 'OME'
/** the error that has occured */
error: OMS
/** arguments to the error */
arguments?: (omel|OMFOREIGN)[]
}
/** Non-OpenMath object */
export interface OMFOREIGN extends withCD {
kind: 'OMFOREIGN'
/** encoding of the foreign object */
encoding?: string
/** the foreign object, usually a string */
foreign: any
}
/** Reference to another element within the same structure */
export interface OMR extends referencable {
kind: 'OMR'
/** element that is being referenced */
href: uri
}
// #region "base"
/** any element */
interface element {
/** the kind of OpenMath Element this type describes */
kind: string
}
/** any element that can be referenced */
interface referencable extends element {
/** id of this element, if it is used for structure sharing */
id?: name
}
/** any elements that can have a CDBase */
interface withCD extends referencable {
/** base URI to use for any cds within this element */
cdbase?: uri
}
// #endregion
// #region "Helpers"
/**
* A URI
*
* @format uri-reference
*/
type uri = string;
/**
* A valid name
*/
type name = string;
/**
* An integer
*
* @asType integer
*/
type integer = number;
/**
* A string representing a decimal integer
*
* @pattern ^-?[0-9]+$
*/
type decimalInteger = string;
/**
* A string representing a hexadecimal integer
*
* @pattern ^-?x[0-9A-F]+$
*/
type hexInteger = string;
/**
* A floating point number.
* Should not be NaN, +Infinity or -Infinity.
*
* Represented via a native JSON representation
*/
type float = number;
/**
* A string representing a decimal floating-point number
*
* @pattern ^(-?)([0-9]+)?(\.[0-9]+)?([eE](-?)[0-9]+)?$
*/
type decimalFloat = string;
/** A string representing a hexa-decimal floating-point number
*
* @pattern ^([0-9A-F]+)$
*/
type hexFloat = string;
/**
* A byte
*
* @minimum 0
* @exclusiveMinimum false
* @maximum 255
* @exclusiveMaximum false
* @asType integer
*/
type byte = number;
/**
* Base64-encoded string
*
* @pattern ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
*/
type base64string = string;
// #endregion