@constela/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.ts +750 -0
- package/dist/index.js +976 -0
- package/package.json +38 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Type Definitions for Constela UI Framework
|
|
3
|
+
*
|
|
4
|
+
* This module defines the complete Abstract Syntax Tree (AST) types
|
|
5
|
+
* for representing Constela UI applications.
|
|
6
|
+
*/
|
|
7
|
+
declare const BINARY_OPERATORS: readonly ["+", "-", "*", "/", "==", "!=", "<", "<=", ">", ">=", "&&", "||"];
|
|
8
|
+
type BinaryOperator = (typeof BINARY_OPERATORS)[number];
|
|
9
|
+
declare const UPDATE_OPERATIONS: readonly ["increment", "decrement", "push", "pop", "remove"];
|
|
10
|
+
type UpdateOperation = (typeof UPDATE_OPERATIONS)[number];
|
|
11
|
+
declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "DELETE"];
|
|
12
|
+
type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* Literal expression - represents a constant value
|
|
15
|
+
*/
|
|
16
|
+
interface LitExpr {
|
|
17
|
+
expr: 'lit';
|
|
18
|
+
value: string | number | boolean | null | unknown[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* State expression - references a state field
|
|
22
|
+
*/
|
|
23
|
+
interface StateExpr {
|
|
24
|
+
expr: 'state';
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Variable expression - references a loop variable or event data
|
|
29
|
+
*/
|
|
30
|
+
interface VarExpr {
|
|
31
|
+
expr: 'var';
|
|
32
|
+
name: string;
|
|
33
|
+
path?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Binary expression - arithmetic, comparison, or logical operation
|
|
37
|
+
*/
|
|
38
|
+
interface BinExpr {
|
|
39
|
+
expr: 'bin';
|
|
40
|
+
op: BinaryOperator;
|
|
41
|
+
left: Expression;
|
|
42
|
+
right: Expression;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Not expression - logical negation
|
|
46
|
+
*/
|
|
47
|
+
interface NotExpr {
|
|
48
|
+
expr: 'not';
|
|
49
|
+
operand: Expression;
|
|
50
|
+
}
|
|
51
|
+
type Expression = LitExpr | StateExpr | VarExpr | BinExpr | NotExpr;
|
|
52
|
+
/**
|
|
53
|
+
* Number state field
|
|
54
|
+
*/
|
|
55
|
+
interface NumberField {
|
|
56
|
+
type: 'number';
|
|
57
|
+
initial: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* String state field
|
|
61
|
+
*/
|
|
62
|
+
interface StringField {
|
|
63
|
+
type: 'string';
|
|
64
|
+
initial: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* List state field
|
|
68
|
+
*/
|
|
69
|
+
interface ListField {
|
|
70
|
+
type: 'list';
|
|
71
|
+
initial: unknown[];
|
|
72
|
+
}
|
|
73
|
+
type StateField = NumberField | StringField | ListField;
|
|
74
|
+
/**
|
|
75
|
+
* Set step - sets a state field to a new value
|
|
76
|
+
*/
|
|
77
|
+
interface SetStep {
|
|
78
|
+
do: 'set';
|
|
79
|
+
target: string;
|
|
80
|
+
value: Expression;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Update step - performs an operation on a state field
|
|
84
|
+
*/
|
|
85
|
+
interface UpdateStep {
|
|
86
|
+
do: 'update';
|
|
87
|
+
target: string;
|
|
88
|
+
operation: UpdateOperation;
|
|
89
|
+
value?: Expression;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Fetch step - makes an HTTP request
|
|
93
|
+
*/
|
|
94
|
+
interface FetchStep {
|
|
95
|
+
do: 'fetch';
|
|
96
|
+
url: Expression;
|
|
97
|
+
method?: HttpMethod;
|
|
98
|
+
body?: Expression;
|
|
99
|
+
result?: string;
|
|
100
|
+
onSuccess?: ActionStep[];
|
|
101
|
+
onError?: ActionStep[];
|
|
102
|
+
}
|
|
103
|
+
type ActionStep = SetStep | UpdateStep | FetchStep;
|
|
104
|
+
/**
|
|
105
|
+
* Event handler - binds an event to an action
|
|
106
|
+
*/
|
|
107
|
+
interface EventHandler {
|
|
108
|
+
event: string;
|
|
109
|
+
action: string;
|
|
110
|
+
payload?: Expression;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Action definition - a named sequence of steps
|
|
114
|
+
*/
|
|
115
|
+
interface ActionDefinition {
|
|
116
|
+
name: string;
|
|
117
|
+
steps: ActionStep[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Element node - represents an HTML element
|
|
121
|
+
*/
|
|
122
|
+
interface ElementNode {
|
|
123
|
+
kind: 'element';
|
|
124
|
+
tag: string;
|
|
125
|
+
props?: Record<string, Expression | EventHandler>;
|
|
126
|
+
children?: ViewNode[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Text node - represents text content
|
|
130
|
+
*/
|
|
131
|
+
interface TextNode {
|
|
132
|
+
kind: 'text';
|
|
133
|
+
value: Expression;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* If node - conditional rendering
|
|
137
|
+
*/
|
|
138
|
+
interface IfNode {
|
|
139
|
+
kind: 'if';
|
|
140
|
+
condition: Expression;
|
|
141
|
+
then: ViewNode;
|
|
142
|
+
else?: ViewNode;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Each node - list rendering
|
|
146
|
+
*/
|
|
147
|
+
interface EachNode {
|
|
148
|
+
kind: 'each';
|
|
149
|
+
items: Expression;
|
|
150
|
+
as: string;
|
|
151
|
+
index?: string;
|
|
152
|
+
key?: Expression;
|
|
153
|
+
body: ViewNode;
|
|
154
|
+
}
|
|
155
|
+
type ViewNode = ElementNode | TextNode | IfNode | EachNode;
|
|
156
|
+
/**
|
|
157
|
+
* Program - the root of a Constela AST
|
|
158
|
+
*/
|
|
159
|
+
interface Program {
|
|
160
|
+
version: '1.0';
|
|
161
|
+
state: Record<string, StateField>;
|
|
162
|
+
actions: ActionDefinition[];
|
|
163
|
+
view: ViewNode;
|
|
164
|
+
}
|
|
165
|
+
type ConstelaAst = Program;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Type Guards for Constela AST Types
|
|
169
|
+
*
|
|
170
|
+
* This module provides runtime type checking functions for all AST types.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Checks if value is a literal expression
|
|
175
|
+
*/
|
|
176
|
+
declare function isLitExpr(value: unknown): value is LitExpr;
|
|
177
|
+
/**
|
|
178
|
+
* Checks if value is a state expression
|
|
179
|
+
*/
|
|
180
|
+
declare function isStateExpr(value: unknown): value is StateExpr;
|
|
181
|
+
/**
|
|
182
|
+
* Checks if value is a variable expression
|
|
183
|
+
*/
|
|
184
|
+
declare function isVarExpr(value: unknown): value is VarExpr;
|
|
185
|
+
/**
|
|
186
|
+
* Checks if value is a binary expression
|
|
187
|
+
*
|
|
188
|
+
* Note: This performs shallow validation only - it checks that `left` and `right`
|
|
189
|
+
* are objects but does not recursively validate they are valid Expressions.
|
|
190
|
+
* This is intentional for performance: deep validation would require traversing
|
|
191
|
+
* potentially deeply nested expression trees on every type guard call.
|
|
192
|
+
* Use the AST validator for full recursive validation instead.
|
|
193
|
+
*/
|
|
194
|
+
declare function isBinExpr(value: unknown): value is BinExpr;
|
|
195
|
+
/**
|
|
196
|
+
* Checks if value is a not expression
|
|
197
|
+
*
|
|
198
|
+
* Note: This performs shallow validation only - it checks that `operand` is
|
|
199
|
+
* an object but does not recursively validate it is a valid Expression.
|
|
200
|
+
* This is intentional for performance: deep validation would require traversing
|
|
201
|
+
* potentially deeply nested expression trees on every type guard call.
|
|
202
|
+
* Use the AST validator for full recursive validation instead.
|
|
203
|
+
*/
|
|
204
|
+
declare function isNotExpr(value: unknown): value is NotExpr;
|
|
205
|
+
/**
|
|
206
|
+
* Checks if value is any valid expression
|
|
207
|
+
*/
|
|
208
|
+
declare function isExpression(value: unknown): value is Expression;
|
|
209
|
+
/**
|
|
210
|
+
* Checks if value is an element node
|
|
211
|
+
*/
|
|
212
|
+
declare function isElementNode(value: unknown): value is ElementNode;
|
|
213
|
+
/**
|
|
214
|
+
* Checks if value is a text node
|
|
215
|
+
*/
|
|
216
|
+
declare function isTextNode(value: unknown): value is TextNode;
|
|
217
|
+
/**
|
|
218
|
+
* Checks if value is an if node
|
|
219
|
+
*/
|
|
220
|
+
declare function isIfNode(value: unknown): value is IfNode;
|
|
221
|
+
/**
|
|
222
|
+
* Checks if value is an each node
|
|
223
|
+
*/
|
|
224
|
+
declare function isEachNode(value: unknown): value is EachNode;
|
|
225
|
+
/**
|
|
226
|
+
* Checks if value is any valid view node
|
|
227
|
+
*/
|
|
228
|
+
declare function isViewNode(value: unknown): value is ViewNode;
|
|
229
|
+
/**
|
|
230
|
+
* Checks if value is a set step
|
|
231
|
+
*/
|
|
232
|
+
declare function isSetStep(value: unknown): value is SetStep;
|
|
233
|
+
/**
|
|
234
|
+
* Checks if value is an update step
|
|
235
|
+
*/
|
|
236
|
+
declare function isUpdateStep(value: unknown): value is UpdateStep;
|
|
237
|
+
/**
|
|
238
|
+
* Checks if value is a fetch step
|
|
239
|
+
*/
|
|
240
|
+
declare function isFetchStep(value: unknown): value is FetchStep;
|
|
241
|
+
/**
|
|
242
|
+
* Checks if value is any valid action step
|
|
243
|
+
*/
|
|
244
|
+
declare function isActionStep(value: unknown): value is ActionStep;
|
|
245
|
+
/**
|
|
246
|
+
* Checks if value is a number field
|
|
247
|
+
*/
|
|
248
|
+
declare function isNumberField(value: unknown): value is NumberField;
|
|
249
|
+
/**
|
|
250
|
+
* Checks if value is a string field
|
|
251
|
+
*/
|
|
252
|
+
declare function isStringField(value: unknown): value is StringField;
|
|
253
|
+
/**
|
|
254
|
+
* Checks if value is a list field
|
|
255
|
+
*/
|
|
256
|
+
declare function isListField(value: unknown): value is ListField;
|
|
257
|
+
/**
|
|
258
|
+
* Checks if value is any valid state field
|
|
259
|
+
*/
|
|
260
|
+
declare function isStateField(value: unknown): value is StateField;
|
|
261
|
+
/**
|
|
262
|
+
* Checks if value is an event handler
|
|
263
|
+
*/
|
|
264
|
+
declare function isEventHandler(value: unknown): value is EventHandler;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Error Types for Constela
|
|
268
|
+
*
|
|
269
|
+
* This module defines error types, the ConstelaError class,
|
|
270
|
+
* and factory functions for creating specific errors.
|
|
271
|
+
*/
|
|
272
|
+
type ErrorCode = 'SCHEMA_INVALID' | 'UNDEFINED_STATE' | 'UNDEFINED_ACTION' | 'VAR_UNDEFINED' | 'DUPLICATE_ACTION' | 'UNSUPPORTED_VERSION';
|
|
273
|
+
/**
|
|
274
|
+
* Custom error class for Constela validation errors
|
|
275
|
+
*/
|
|
276
|
+
declare class ConstelaError extends Error {
|
|
277
|
+
readonly code: ErrorCode;
|
|
278
|
+
readonly path: string | undefined;
|
|
279
|
+
constructor(code: ErrorCode, message: string, path?: string | undefined);
|
|
280
|
+
/**
|
|
281
|
+
* Converts the error to a JSON-serializable object
|
|
282
|
+
*/
|
|
283
|
+
toJSON(): {
|
|
284
|
+
code: ErrorCode;
|
|
285
|
+
message: string;
|
|
286
|
+
path: string | undefined;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Checks if value is a ConstelaError instance
|
|
291
|
+
*/
|
|
292
|
+
declare function isConstelaError(value: unknown): value is ConstelaError;
|
|
293
|
+
/**
|
|
294
|
+
* Creates a schema validation error
|
|
295
|
+
*/
|
|
296
|
+
declare function createSchemaError(message: string, path?: string): ConstelaError;
|
|
297
|
+
/**
|
|
298
|
+
* Creates an undefined state reference error
|
|
299
|
+
*/
|
|
300
|
+
declare function createUndefinedStateError(stateName: string, path?: string): ConstelaError;
|
|
301
|
+
/**
|
|
302
|
+
* Creates an undefined action reference error
|
|
303
|
+
*/
|
|
304
|
+
declare function createUndefinedActionError(actionName: string, path?: string): ConstelaError;
|
|
305
|
+
/**
|
|
306
|
+
* Creates a duplicate action name error
|
|
307
|
+
*/
|
|
308
|
+
declare function createDuplicateActionError(actionName: string, path?: string): ConstelaError;
|
|
309
|
+
/**
|
|
310
|
+
* Creates an undefined variable reference error
|
|
311
|
+
*/
|
|
312
|
+
declare function createUndefinedVarError(varName: string, path?: string): ConstelaError;
|
|
313
|
+
/**
|
|
314
|
+
* Creates an unsupported version error
|
|
315
|
+
*/
|
|
316
|
+
declare function createUnsupportedVersionError(version: string): ConstelaError;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* AST Validator for Constela
|
|
320
|
+
*
|
|
321
|
+
* This module provides validation for Constela AST structures using
|
|
322
|
+
* JSON Schema validation (AJV) and semantic validation.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
interface ValidationSuccess {
|
|
326
|
+
ok: true;
|
|
327
|
+
ast: Program;
|
|
328
|
+
}
|
|
329
|
+
interface ValidationFailure {
|
|
330
|
+
ok: false;
|
|
331
|
+
error: ConstelaError;
|
|
332
|
+
}
|
|
333
|
+
type ValidationResult = ValidationSuccess | ValidationFailure;
|
|
334
|
+
/**
|
|
335
|
+
* Validates a Constela AST
|
|
336
|
+
*
|
|
337
|
+
* @param input - The input to validate
|
|
338
|
+
* @returns A validation result with either the valid AST or an error
|
|
339
|
+
*/
|
|
340
|
+
declare function validateAst(input: unknown): ValidationResult;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* JSON Schema for Constela AST
|
|
344
|
+
*
|
|
345
|
+
* This module defines the JSON Schema for validating Constela AST structures.
|
|
346
|
+
*/
|
|
347
|
+
declare const astSchema: {
|
|
348
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
349
|
+
readonly $id: "https://constela.dev/schemas/ast.json";
|
|
350
|
+
readonly title: "Constela AST";
|
|
351
|
+
readonly description: "Schema for Constela UI framework AST";
|
|
352
|
+
readonly type: "object";
|
|
353
|
+
readonly required: readonly ["version", "state", "actions", "view"];
|
|
354
|
+
readonly additionalProperties: false;
|
|
355
|
+
readonly properties: {
|
|
356
|
+
readonly version: {
|
|
357
|
+
readonly type: "string";
|
|
358
|
+
readonly const: "1.0";
|
|
359
|
+
};
|
|
360
|
+
readonly state: {
|
|
361
|
+
readonly type: "object";
|
|
362
|
+
readonly additionalProperties: {
|
|
363
|
+
readonly $ref: "#/$defs/StateField";
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
readonly actions: {
|
|
367
|
+
readonly type: "array";
|
|
368
|
+
readonly items: {
|
|
369
|
+
readonly $ref: "#/$defs/ActionDefinition";
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
readonly view: {
|
|
373
|
+
readonly $ref: "#/$defs/ViewNode";
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
readonly $defs: {
|
|
377
|
+
readonly Expression: {
|
|
378
|
+
readonly oneOf: readonly [{
|
|
379
|
+
readonly $ref: "#/$defs/LitExpr";
|
|
380
|
+
}, {
|
|
381
|
+
readonly $ref: "#/$defs/StateExpr";
|
|
382
|
+
}, {
|
|
383
|
+
readonly $ref: "#/$defs/VarExpr";
|
|
384
|
+
}, {
|
|
385
|
+
readonly $ref: "#/$defs/BinExpr";
|
|
386
|
+
}, {
|
|
387
|
+
readonly $ref: "#/$defs/NotExpr";
|
|
388
|
+
}];
|
|
389
|
+
};
|
|
390
|
+
readonly LitExpr: {
|
|
391
|
+
readonly type: "object";
|
|
392
|
+
readonly required: readonly ["expr", "value"];
|
|
393
|
+
readonly additionalProperties: false;
|
|
394
|
+
readonly properties: {
|
|
395
|
+
readonly expr: {
|
|
396
|
+
readonly type: "string";
|
|
397
|
+
readonly const: "lit";
|
|
398
|
+
};
|
|
399
|
+
readonly value: {
|
|
400
|
+
readonly oneOf: readonly [{
|
|
401
|
+
readonly type: "string";
|
|
402
|
+
}, {
|
|
403
|
+
readonly type: "number";
|
|
404
|
+
}, {
|
|
405
|
+
readonly type: "boolean";
|
|
406
|
+
}, {
|
|
407
|
+
readonly type: "null";
|
|
408
|
+
}, {
|
|
409
|
+
readonly type: "array";
|
|
410
|
+
}];
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
readonly StateExpr: {
|
|
415
|
+
readonly type: "object";
|
|
416
|
+
readonly required: readonly ["expr", "name"];
|
|
417
|
+
readonly additionalProperties: false;
|
|
418
|
+
readonly properties: {
|
|
419
|
+
readonly expr: {
|
|
420
|
+
readonly type: "string";
|
|
421
|
+
readonly const: "state";
|
|
422
|
+
};
|
|
423
|
+
readonly name: {
|
|
424
|
+
readonly type: "string";
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
readonly VarExpr: {
|
|
429
|
+
readonly type: "object";
|
|
430
|
+
readonly required: readonly ["expr", "name"];
|
|
431
|
+
readonly additionalProperties: false;
|
|
432
|
+
readonly properties: {
|
|
433
|
+
readonly expr: {
|
|
434
|
+
readonly type: "string";
|
|
435
|
+
readonly const: "var";
|
|
436
|
+
};
|
|
437
|
+
readonly name: {
|
|
438
|
+
readonly type: "string";
|
|
439
|
+
};
|
|
440
|
+
readonly path: {
|
|
441
|
+
readonly type: "string";
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
readonly BinExpr: {
|
|
446
|
+
readonly type: "object";
|
|
447
|
+
readonly required: readonly ["expr", "op", "left", "right"];
|
|
448
|
+
readonly additionalProperties: false;
|
|
449
|
+
readonly properties: {
|
|
450
|
+
readonly expr: {
|
|
451
|
+
readonly type: "string";
|
|
452
|
+
readonly const: "bin";
|
|
453
|
+
};
|
|
454
|
+
readonly op: {
|
|
455
|
+
readonly type: "string";
|
|
456
|
+
readonly enum: readonly ["+", "-", "*", "/", "==", "!=", "<", "<=", ">", ">=", "&&", "||"];
|
|
457
|
+
};
|
|
458
|
+
readonly left: {
|
|
459
|
+
readonly $ref: "#/$defs/Expression";
|
|
460
|
+
};
|
|
461
|
+
readonly right: {
|
|
462
|
+
readonly $ref: "#/$defs/Expression";
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
};
|
|
466
|
+
readonly NotExpr: {
|
|
467
|
+
readonly type: "object";
|
|
468
|
+
readonly required: readonly ["expr", "operand"];
|
|
469
|
+
readonly additionalProperties: false;
|
|
470
|
+
readonly properties: {
|
|
471
|
+
readonly expr: {
|
|
472
|
+
readonly type: "string";
|
|
473
|
+
readonly const: "not";
|
|
474
|
+
};
|
|
475
|
+
readonly operand: {
|
|
476
|
+
readonly $ref: "#/$defs/Expression";
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
readonly StateField: {
|
|
481
|
+
readonly oneOf: readonly [{
|
|
482
|
+
readonly $ref: "#/$defs/NumberField";
|
|
483
|
+
}, {
|
|
484
|
+
readonly $ref: "#/$defs/StringField";
|
|
485
|
+
}, {
|
|
486
|
+
readonly $ref: "#/$defs/ListField";
|
|
487
|
+
}];
|
|
488
|
+
};
|
|
489
|
+
readonly NumberField: {
|
|
490
|
+
readonly type: "object";
|
|
491
|
+
readonly required: readonly ["type", "initial"];
|
|
492
|
+
readonly additionalProperties: false;
|
|
493
|
+
readonly properties: {
|
|
494
|
+
readonly type: {
|
|
495
|
+
readonly type: "string";
|
|
496
|
+
readonly const: "number";
|
|
497
|
+
};
|
|
498
|
+
readonly initial: {
|
|
499
|
+
readonly type: "number";
|
|
500
|
+
};
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
readonly StringField: {
|
|
504
|
+
readonly type: "object";
|
|
505
|
+
readonly required: readonly ["type", "initial"];
|
|
506
|
+
readonly additionalProperties: false;
|
|
507
|
+
readonly properties: {
|
|
508
|
+
readonly type: {
|
|
509
|
+
readonly type: "string";
|
|
510
|
+
readonly const: "string";
|
|
511
|
+
};
|
|
512
|
+
readonly initial: {
|
|
513
|
+
readonly type: "string";
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
readonly ListField: {
|
|
518
|
+
readonly type: "object";
|
|
519
|
+
readonly required: readonly ["type", "initial"];
|
|
520
|
+
readonly additionalProperties: false;
|
|
521
|
+
readonly properties: {
|
|
522
|
+
readonly type: {
|
|
523
|
+
readonly type: "string";
|
|
524
|
+
readonly const: "list";
|
|
525
|
+
};
|
|
526
|
+
readonly initial: {
|
|
527
|
+
readonly type: "array";
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
readonly ActionStep: {
|
|
532
|
+
readonly oneOf: readonly [{
|
|
533
|
+
readonly $ref: "#/$defs/SetStep";
|
|
534
|
+
}, {
|
|
535
|
+
readonly $ref: "#/$defs/UpdateStep";
|
|
536
|
+
}, {
|
|
537
|
+
readonly $ref: "#/$defs/FetchStep";
|
|
538
|
+
}];
|
|
539
|
+
};
|
|
540
|
+
readonly SetStep: {
|
|
541
|
+
readonly type: "object";
|
|
542
|
+
readonly required: readonly ["do", "target", "value"];
|
|
543
|
+
readonly additionalProperties: false;
|
|
544
|
+
readonly properties: {
|
|
545
|
+
readonly do: {
|
|
546
|
+
readonly type: "string";
|
|
547
|
+
readonly const: "set";
|
|
548
|
+
};
|
|
549
|
+
readonly target: {
|
|
550
|
+
readonly type: "string";
|
|
551
|
+
};
|
|
552
|
+
readonly value: {
|
|
553
|
+
readonly $ref: "#/$defs/Expression";
|
|
554
|
+
};
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
readonly UpdateStep: {
|
|
558
|
+
readonly type: "object";
|
|
559
|
+
readonly required: readonly ["do", "target", "operation"];
|
|
560
|
+
readonly additionalProperties: false;
|
|
561
|
+
readonly properties: {
|
|
562
|
+
readonly do: {
|
|
563
|
+
readonly type: "string";
|
|
564
|
+
readonly const: "update";
|
|
565
|
+
};
|
|
566
|
+
readonly target: {
|
|
567
|
+
readonly type: "string";
|
|
568
|
+
};
|
|
569
|
+
readonly operation: {
|
|
570
|
+
readonly type: "string";
|
|
571
|
+
readonly enum: readonly ["increment", "decrement", "push", "pop", "remove"];
|
|
572
|
+
};
|
|
573
|
+
readonly value: {
|
|
574
|
+
readonly $ref: "#/$defs/Expression";
|
|
575
|
+
};
|
|
576
|
+
};
|
|
577
|
+
};
|
|
578
|
+
readonly FetchStep: {
|
|
579
|
+
readonly type: "object";
|
|
580
|
+
readonly required: readonly ["do", "url"];
|
|
581
|
+
readonly additionalProperties: false;
|
|
582
|
+
readonly properties: {
|
|
583
|
+
readonly do: {
|
|
584
|
+
readonly type: "string";
|
|
585
|
+
readonly const: "fetch";
|
|
586
|
+
};
|
|
587
|
+
readonly url: {
|
|
588
|
+
readonly $ref: "#/$defs/Expression";
|
|
589
|
+
};
|
|
590
|
+
readonly method: {
|
|
591
|
+
readonly type: "string";
|
|
592
|
+
readonly enum: readonly ["GET", "POST", "PUT", "DELETE"];
|
|
593
|
+
};
|
|
594
|
+
readonly body: {
|
|
595
|
+
readonly $ref: "#/$defs/Expression";
|
|
596
|
+
};
|
|
597
|
+
readonly result: {
|
|
598
|
+
readonly type: "string";
|
|
599
|
+
};
|
|
600
|
+
readonly onSuccess: {
|
|
601
|
+
readonly type: "array";
|
|
602
|
+
readonly items: {
|
|
603
|
+
readonly $ref: "#/$defs/ActionStep";
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
readonly onError: {
|
|
607
|
+
readonly type: "array";
|
|
608
|
+
readonly items: {
|
|
609
|
+
readonly $ref: "#/$defs/ActionStep";
|
|
610
|
+
};
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
};
|
|
614
|
+
readonly EventHandler: {
|
|
615
|
+
readonly type: "object";
|
|
616
|
+
readonly required: readonly ["event", "action"];
|
|
617
|
+
readonly additionalProperties: false;
|
|
618
|
+
readonly properties: {
|
|
619
|
+
readonly event: {
|
|
620
|
+
readonly type: "string";
|
|
621
|
+
};
|
|
622
|
+
readonly action: {
|
|
623
|
+
readonly type: "string";
|
|
624
|
+
};
|
|
625
|
+
readonly payload: {
|
|
626
|
+
readonly $ref: "#/$defs/Expression";
|
|
627
|
+
};
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
readonly ActionDefinition: {
|
|
631
|
+
readonly type: "object";
|
|
632
|
+
readonly required: readonly ["name", "steps"];
|
|
633
|
+
readonly additionalProperties: false;
|
|
634
|
+
readonly properties: {
|
|
635
|
+
readonly name: {
|
|
636
|
+
readonly type: "string";
|
|
637
|
+
};
|
|
638
|
+
readonly steps: {
|
|
639
|
+
readonly type: "array";
|
|
640
|
+
readonly items: {
|
|
641
|
+
readonly $ref: "#/$defs/ActionStep";
|
|
642
|
+
};
|
|
643
|
+
};
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
readonly ViewNode: {
|
|
647
|
+
readonly oneOf: readonly [{
|
|
648
|
+
readonly $ref: "#/$defs/ElementNode";
|
|
649
|
+
}, {
|
|
650
|
+
readonly $ref: "#/$defs/TextNode";
|
|
651
|
+
}, {
|
|
652
|
+
readonly $ref: "#/$defs/IfNode";
|
|
653
|
+
}, {
|
|
654
|
+
readonly $ref: "#/$defs/EachNode";
|
|
655
|
+
}];
|
|
656
|
+
};
|
|
657
|
+
readonly ElementNode: {
|
|
658
|
+
readonly type: "object";
|
|
659
|
+
readonly required: readonly ["kind", "tag"];
|
|
660
|
+
readonly additionalProperties: false;
|
|
661
|
+
readonly properties: {
|
|
662
|
+
readonly kind: {
|
|
663
|
+
readonly type: "string";
|
|
664
|
+
readonly const: "element";
|
|
665
|
+
};
|
|
666
|
+
readonly tag: {
|
|
667
|
+
readonly type: "string";
|
|
668
|
+
};
|
|
669
|
+
readonly props: {
|
|
670
|
+
readonly type: "object";
|
|
671
|
+
readonly additionalProperties: {
|
|
672
|
+
readonly oneOf: readonly [{
|
|
673
|
+
readonly $ref: "#/$defs/Expression";
|
|
674
|
+
}, {
|
|
675
|
+
readonly $ref: "#/$defs/EventHandler";
|
|
676
|
+
}];
|
|
677
|
+
};
|
|
678
|
+
};
|
|
679
|
+
readonly children: {
|
|
680
|
+
readonly type: "array";
|
|
681
|
+
readonly items: {
|
|
682
|
+
readonly $ref: "#/$defs/ViewNode";
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
readonly TextNode: {
|
|
688
|
+
readonly type: "object";
|
|
689
|
+
readonly required: readonly ["kind", "value"];
|
|
690
|
+
readonly additionalProperties: false;
|
|
691
|
+
readonly properties: {
|
|
692
|
+
readonly kind: {
|
|
693
|
+
readonly type: "string";
|
|
694
|
+
readonly const: "text";
|
|
695
|
+
};
|
|
696
|
+
readonly value: {
|
|
697
|
+
readonly $ref: "#/$defs/Expression";
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
};
|
|
701
|
+
readonly IfNode: {
|
|
702
|
+
readonly type: "object";
|
|
703
|
+
readonly required: readonly ["kind", "condition", "then"];
|
|
704
|
+
readonly additionalProperties: false;
|
|
705
|
+
readonly properties: {
|
|
706
|
+
readonly kind: {
|
|
707
|
+
readonly type: "string";
|
|
708
|
+
readonly const: "if";
|
|
709
|
+
};
|
|
710
|
+
readonly condition: {
|
|
711
|
+
readonly $ref: "#/$defs/Expression";
|
|
712
|
+
};
|
|
713
|
+
readonly then: {
|
|
714
|
+
readonly $ref: "#/$defs/ViewNode";
|
|
715
|
+
};
|
|
716
|
+
readonly else: {
|
|
717
|
+
readonly $ref: "#/$defs/ViewNode";
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
};
|
|
721
|
+
readonly EachNode: {
|
|
722
|
+
readonly type: "object";
|
|
723
|
+
readonly required: readonly ["kind", "items", "as", "body"];
|
|
724
|
+
readonly additionalProperties: false;
|
|
725
|
+
readonly properties: {
|
|
726
|
+
readonly kind: {
|
|
727
|
+
readonly type: "string";
|
|
728
|
+
readonly const: "each";
|
|
729
|
+
};
|
|
730
|
+
readonly items: {
|
|
731
|
+
readonly $ref: "#/$defs/Expression";
|
|
732
|
+
};
|
|
733
|
+
readonly as: {
|
|
734
|
+
readonly type: "string";
|
|
735
|
+
};
|
|
736
|
+
readonly index: {
|
|
737
|
+
readonly type: "string";
|
|
738
|
+
};
|
|
739
|
+
readonly key: {
|
|
740
|
+
readonly $ref: "#/$defs/Expression";
|
|
741
|
+
};
|
|
742
|
+
readonly body: {
|
|
743
|
+
readonly $ref: "#/$defs/ViewNode";
|
|
744
|
+
};
|
|
745
|
+
};
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type ConstelaAst, ConstelaError, type EachNode, type ElementNode, type ErrorCode, type EventHandler, type Expression, type FetchStep, HTTP_METHODS, type HttpMethod, type IfNode, type ListField, type LitExpr, type NotExpr, type NumberField, type Program, type SetStep, type StateExpr, type StateField, type StringField, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, type ValidationFailure, type ValidationResult, type ValidationSuccess, type VarExpr, type ViewNode, astSchema, createDuplicateActionError, createSchemaError, createUndefinedActionError, createUndefinedStateError, createUndefinedVarError, createUnsupportedVersionError, isActionStep, isBinExpr, isConstelaError, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isIfNode, isListField, isLitExpr, isNotExpr, isNumberField, isSetStep, isStateExpr, isStateField, isStringField, isTextNode, isUpdateStep, isVarExpr, isViewNode, validateAst };
|