/
scxml.d.ts
292 lines (257 loc) · 7.84 KB
/
scxml.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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/* eslint-disable no-use-before-define, @typescript-eslint/no-explicit-any */
/**
* These data types are based on the w3 scxml specification
* https://www.w3.org/TR/scxml/#Basic
*/
export interface ISCXMLAsJSON {
scxml?: any;
}
export interface ISCXMLMetaAttributes {
xmlns: "http://www.w3.org/2005/07/scxml";
version: "1.0";
/**
* The datamodel that this document requires. "null" denotes the Null
* datamodel, "ecmascript" the ECMAScript datamodel, and "xpath" the
* XPath datamodel, as defined in B Data Models.
*
* Note: in the SCXML spec datamodel is both an attribute (this one)
* and a _child_. To prevent duplicate keys we've _renamed_ the datamodel
* attribute to datamodelType.
*/
datamodelType?: "null" | "ecmascript" | "xpath" | string;
/**
* The data binding to use.
* See [5.3.3 Data Binding](https://www.w3.org/TR/scxml/#DataBinding) for details.
*/
binding?: "early" | "late";
/**
* Defines part or all of the data model.
*/
datamodel?: string;
/**
* Provides scripting capability.
*/
script?: any;
}
/**
* W3 specification: [3.2 - scxml](https://www.w3.org/TR/scxml/#scxml)
*/
export interface INormalizedSCXMLMachine extends ISCXMLMetaAttributes {
/**
* The id of the default initial state (or states) for this state.
*
* Valid values: A legal state specification.
*
* In the spec it can be either an attribute xor a child
*/
initial: ISCXMLInitialState[];
/**
* A compound or atomic state.
*/
state: INormalizedSCXMLState[];
/**
* A parallel state.
*/
parallel: ISCXMLParallelState[];
/**
* A top-level final state in the state machine.
* The SCXML processor must terminate processing when the state machine
* reaches this state.
*/
final: ISCXMLFinalState[];
/**
* In SCXML the top level object does not have an id. However, we use
* SCXMLMachines nested into (sub)states, and there they're massively useful -
* hence allowed nonetheless
*/
id?: string;
/**
* In SCXML the top level no history state can be specified. As we're re-using
* the ISCXMLMachine for nesting we allow it nonetheless.
*/
history: ISCXMLHistoryState[];
/**
* The name of this state machine. It is for purely informational purposes.
*
* Valid values: any valid NMTOKEN
*/
name?: string;
}
/**
* W3 specification: [3.3 - state](https://www.w3.org/TR/scxml/#state)
*/
export interface INormalizedSCXMLState {
/**
* The identifier for this state. See [3.14 IDs](https://www.w3.org/TR/scxml/#IDs)
* for details.
*
* Valid values: A valid id as defined in [XML Schema](https://www.w3.org/TR/scxml/#Schema)
*/
id?: string;
/**
* The id of the default initial state (or states) for this state.
*
* Valid values: A legal state specification.
*
* In the spec it can be either an attribute xor a child
*/
initial?: ISCXMLInitialState | string;
/**
* Optional element holding executable content to be run upon entering
* this state. [3.4 - onentry](https://www.w3.org/TR/scxml/#onentry)
*/
onentry?: string[];
/**
* Optional element holding executable content to be run when exiting
* this state. [3.4 - onexit](https://www.w3.org/TR/scxml/#onexit)
*/
onexit?: string[];
/**
* Defines an outgoing transition from this state.
*/
transition?: ISCXMLTransition[];
/**
* Defines a sequential substate of the parent state.
*/
state?: INormalizedSCXMLState[];
/**
* Defines a parallel substate.
*/
parallel?: ISCXMLParallelState[];
/**
* Defines a final substate.
*/
final?: ISCXMLFinalState[];
/**
* A child pseudo-state which records the descendant state(s) that the
* parent state was in the last time the system transitioned from the
* parent.
*/
history?: ISCXMLHistoryState[];
/**
* Defines part or all of the data model.
*/
datamodel?: any;
/**
* Invokes an external service.
*/
invoke?: (ISCXMLInvoke | string)[];
}
/**
* W3 specification: [3.4 - parallel](https://www.w3.org/TR/scxml/#parallel)
*/
export interface ISCXMLParallelState {
id?: string;
onentry?: string[];
onexit?: string[];
transition?: ISCXMLTransition[];
state?: INormalizedSCXMLState[];
parallel?: INormalizedSCXMLState[];
history?: ISCXMLHistoryState[];
datamodel?: any;
invoke?: (ISCXMLInvoke | string)[];
}
/**
* W3 specification: [3.5 - transition](https://www.w3.org/TR/scxml/#transition)
*/
export interface ISCXMLTransition {
event?: string;
cond?: string;
target?: string;
type?: "external" | "internal";
"#text"?: string;
}
/**
* W3 specification: [3.6 - initial](https://www.w3.org/TR/scxml/#initial)
*/
export interface ISCXMLInitialState {
/**
* The id for the `<initial>` state is _not_ part of the SCXML specification.
* However, we use it anyway for convenience and consistency.
*/
id: string;
/**
* A transition whose 'target' specifies the default initial state(s).
* Occurs once. In a conformant SCXML document, this transition must not
* contain 'cond' or 'event' attributes, and must specify a non-null 'target'
* whose value is a valid state specification consisting solely of descendants
* of the containing state (see
* [3.11 Legal State Configurations and Specifications](https://www.w3.org/TR/scxml/#LegalStateConfigurations)
* for details) This transition _may_ contain executable content.
*
* According to the specification can occur once. For convenience and
* consistency with other states we allow more than one, though.
*/
transition?: ISCXMLTransition[];
}
/**
* W3 specification: [3.7 - final](https://www.w3.org/TR/scxml/#final)
*/
export interface ISCXMLFinalState {
id?: string;
onentry?: string[];
onexit?: string[];
donedata?: {
content?: { expr?: string };
param?: ISCXMLParameter[];
};
}
/**
* W3 specification: [3.10 - history](https://www.w3.org/TR/scxml/#history)
*/
export interface ISCXMLHistoryState {
/**
* The identifier for this pseudo state. See [3.14 IDs](https://www.w3.org/TR/scxml/#IDs)
* for details.
*/
id?: string;
/**
* Determines whether the active atomic substate(s) of the current state or
* only its immediate active substate(s) are recorded.
*/
type?: "shallow" | "deep";
/**
* A transition whose 'target' specifies the default history configuration.
* In a conformant SCXML document, this transition must not contain 'cond'
* or 'event' attributes, and must specify a non-null 'target' whose value is
* a valid state specification (see
* [3.11 Legal State Configurations and Specifications](https://www.w3.org/TR/scxml/#LegalStateConfigurations)
* for details) This transition _may_ contain executable content.
*
* If 'type' is "shallow", then the 'target' of this `<transition>` must contain
* only immediate children of the parent state. Otherwise it must contain only
* descendants of the parent.
*
* Occurs once. (Note that under the definition of a legal state specification,
* if the parent of the history element is `<state>` and the default state
* specification contains a multiple states, then, in a conformant SCXML
* document, the 'type' of the history element must be "deep" and the states
* must be atomic descendants of a `<parallel>` element that is itself a
* descendant of the parent `<state>` element.)
*/
transition?: ISCXMLTransition;
}
/**
* W3 specification: [5.7 - param](https://www.w3.org/TR/scxml/#param)
*/
export interface ISCXMLParameter {
name: string;
expr?: string;
location?: string;
}
/**
* W3 specification: [6.4 - invoke](https://www.w3.org/TR/scxml/#invoke)
*/
export interface ISCXMLInvoke {
type?: string;
typeexpr?: string;
src?: string;
srcexpr?: string;
id?: string;
idlocation?: string;
namelist?: string;
autoforward?: boolean;
param?: ISCXMLParameter[];
finalize?: any;
content?: any;
}