@zenstackhq/language 3.5.5 → 3.6.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/dist/ast-Clidp86c.cjs +1465 -0
- package/dist/ast-Clidp86c.cjs.map +1 -0
- package/dist/ast-DEfhnj8j.mjs +765 -0
- package/dist/ast-DEfhnj8j.mjs.map +1 -0
- package/dist/ast-DQDdBZQ3.d.mts +525 -0
- package/dist/ast-W2h6Qtfk.d.cts +525 -0
- package/dist/ast.cjs +130 -1432
- package/dist/ast.cjs.map +1 -1
- package/dist/ast.d.cts +2 -541
- package/dist/ast.d.mts +2 -0
- package/dist/ast.mjs +20 -0
- package/dist/ast.mjs.map +1 -0
- package/dist/factory.cjs +754 -2030
- package/dist/factory.cjs.map +1 -1
- package/dist/factory.d.cts +220 -215
- package/dist/factory.d.mts +289 -0
- package/dist/factory.mjs +778 -0
- package/dist/factory.mjs.map +1 -0
- package/dist/index.cjs +2691 -5454
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +104 -103
- package/dist/index.d.mts +170 -0
- package/dist/index.mjs +6925 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils-BB6L7ug2.mjs +529 -0
- package/dist/utils-BB6L7ug2.mjs.map +1 -0
- package/dist/utils-CfXGZkv7.cjs +842 -0
- package/dist/utils-CfXGZkv7.cjs.map +1 -0
- package/dist/utils.cjs +47 -1650
- package/dist/utils.d.cts +101 -10
- package/dist/{utils.d.ts → utils.d.mts} +101 -10
- package/dist/utils.mjs +2 -0
- package/package.json +16 -15
- package/dist/ast.d.ts +0 -541
- package/dist/ast.js +0 -1288
- package/dist/ast.js.map +0 -1
- package/dist/factory.d.ts +0 -284
- package/dist/factory.js +0 -2020
- package/dist/factory.js.map +0 -1
- package/dist/index.d.ts +0 -169
- package/dist/index.js +0 -9656
- package/dist/index.js.map +0 -1
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js +0 -1572
- package/dist/utils.js.map +0 -1
package/dist/factory.mjs
ADDED
|
@@ -0,0 +1,778 @@
|
|
|
1
|
+
import { A as InternalAttribute, C as EnumField, F as Model, G as ReferenceExpr, I as ModelImport, J as ThisExpr, L as NullExpr, N as MemberAccessExpr, Q as UnsupportedFieldType, R as NumberLiteral, S as Enum, T as FieldInitializer, W as ReferenceArg, Z as UnaryExpr, _ as DataFieldAttribute, a as AttributeArg, b as DataModelAttribute, c as BinaryExpr, g as DataField, i as Attribute, j as InvocationExpr, l as BooleanLiteral, n as Argument, o as AttributeParam, q as StringLiteral, r as ArrayExpr, s as AttributeParamType, v as DataFieldType, y as DataModel, z as ObjectExpr } from "./ast-DEfhnj8j.mjs";
|
|
2
|
+
import "./ast.mjs";
|
|
3
|
+
//#region src/factory/ast-factory.ts
|
|
4
|
+
var AstFactory = class AstFactory {
|
|
5
|
+
node = {};
|
|
6
|
+
constructor({ type, node }) {
|
|
7
|
+
this.node.$type = type;
|
|
8
|
+
if (node) this.update(node);
|
|
9
|
+
}
|
|
10
|
+
setContainer(container) {
|
|
11
|
+
this.node.$container = container;
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
get(params) {
|
|
15
|
+
if (params) this.update(params);
|
|
16
|
+
return this.node;
|
|
17
|
+
}
|
|
18
|
+
update(nodeArg) {
|
|
19
|
+
Object.keys(nodeArg).forEach((key) => {
|
|
20
|
+
const child = nodeArg[key];
|
|
21
|
+
if (child instanceof AstFactory) this.node[key] = child.get({ $container: this.node });
|
|
22
|
+
else if (Array.isArray(child)) this.node[key] = child.map((item) => item instanceof AstFactory ? item.get({ $container: this.node }) : item);
|
|
23
|
+
else this.node[key] = child;
|
|
24
|
+
});
|
|
25
|
+
return this.node;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/factory/primitives.ts
|
|
30
|
+
var ThisExprFactory = class extends AstFactory {
|
|
31
|
+
constructor() {
|
|
32
|
+
super({
|
|
33
|
+
type: ThisExpr,
|
|
34
|
+
node: { value: "this" }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var NullExprFactory = class extends AstFactory {
|
|
39
|
+
constructor() {
|
|
40
|
+
super({
|
|
41
|
+
type: NullExpr,
|
|
42
|
+
node: { value: "null" }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var NumberLiteralFactory = class extends AstFactory {
|
|
47
|
+
value;
|
|
48
|
+
constructor() {
|
|
49
|
+
super({ type: NumberLiteral });
|
|
50
|
+
}
|
|
51
|
+
setValue(value) {
|
|
52
|
+
this.value = value;
|
|
53
|
+
this.update({ value: this.value.toString() });
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var StringLiteralFactory = class extends AstFactory {
|
|
58
|
+
value;
|
|
59
|
+
constructor() {
|
|
60
|
+
super({ type: StringLiteral });
|
|
61
|
+
}
|
|
62
|
+
setValue(value) {
|
|
63
|
+
this.value = value;
|
|
64
|
+
this.update({ value: this.value });
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var BooleanLiteralFactory = class extends AstFactory {
|
|
69
|
+
value;
|
|
70
|
+
constructor() {
|
|
71
|
+
super({ type: BooleanLiteral });
|
|
72
|
+
}
|
|
73
|
+
setValue(value) {
|
|
74
|
+
this.value = value;
|
|
75
|
+
this.update({ value: this.value });
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/factory/expression.ts
|
|
81
|
+
const ExpressionBuilder = () => ({
|
|
82
|
+
get ArrayExpr() {
|
|
83
|
+
return new ArrayExprFactory();
|
|
84
|
+
},
|
|
85
|
+
get BinaryExpr() {
|
|
86
|
+
return new BinaryExprFactory();
|
|
87
|
+
},
|
|
88
|
+
get BooleanLiteral() {
|
|
89
|
+
return new BooleanLiteralFactory();
|
|
90
|
+
},
|
|
91
|
+
get InvocationExpr() {
|
|
92
|
+
return new InvocationExprFactory();
|
|
93
|
+
},
|
|
94
|
+
get MemberAccessExpr() {
|
|
95
|
+
return new MemberAccessExprFactory();
|
|
96
|
+
},
|
|
97
|
+
get NullExpr() {
|
|
98
|
+
return new NullExprFactory();
|
|
99
|
+
},
|
|
100
|
+
get NumberLiteral() {
|
|
101
|
+
return new NumberLiteralFactory();
|
|
102
|
+
},
|
|
103
|
+
get ObjectExpr() {
|
|
104
|
+
return new ObjectExprFactory();
|
|
105
|
+
},
|
|
106
|
+
get ReferenceExpr() {
|
|
107
|
+
return new ReferenceExprFactory();
|
|
108
|
+
},
|
|
109
|
+
get StringLiteral() {
|
|
110
|
+
return new StringLiteralFactory();
|
|
111
|
+
},
|
|
112
|
+
get ThisExpr() {
|
|
113
|
+
return new ThisExprFactory();
|
|
114
|
+
},
|
|
115
|
+
get UnaryExpr() {
|
|
116
|
+
return new UnaryExprFactory();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
var UnaryExprFactory = class extends AstFactory {
|
|
120
|
+
operand;
|
|
121
|
+
constructor() {
|
|
122
|
+
super({
|
|
123
|
+
type: UnaryExpr,
|
|
124
|
+
node: { operator: "!" }
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
setOperand(builder) {
|
|
128
|
+
this.operand = builder(ExpressionBuilder());
|
|
129
|
+
this.update({ operand: this.operand });
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var ReferenceExprFactory = class extends AstFactory {
|
|
134
|
+
target;
|
|
135
|
+
args = [];
|
|
136
|
+
constructor() {
|
|
137
|
+
super({
|
|
138
|
+
type: ReferenceExpr,
|
|
139
|
+
node: { args: [] }
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
setTarget(target) {
|
|
143
|
+
this.target = {
|
|
144
|
+
$refText: target.name,
|
|
145
|
+
ref: target
|
|
146
|
+
};
|
|
147
|
+
this.update({ target: this.target });
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
addArg(builder, name) {
|
|
151
|
+
const arg = new ReferenceArgFactory().setValue(builder);
|
|
152
|
+
if (name) arg.setName(name);
|
|
153
|
+
this.args.push(arg);
|
|
154
|
+
this.update({ args: this.args });
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var ReferenceArgFactory = class extends AstFactory {
|
|
159
|
+
name;
|
|
160
|
+
value;
|
|
161
|
+
constructor() {
|
|
162
|
+
super({ type: ReferenceArg });
|
|
163
|
+
}
|
|
164
|
+
setName(name) {
|
|
165
|
+
this.name = name;
|
|
166
|
+
this.update({ name: this.name });
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
setValue(builder) {
|
|
170
|
+
this.value = builder(ExpressionBuilder());
|
|
171
|
+
this.update({ value: this.value });
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var MemberAccessExprFactory = class extends AstFactory {
|
|
176
|
+
member;
|
|
177
|
+
operand;
|
|
178
|
+
constructor() {
|
|
179
|
+
super({ type: MemberAccessExpr });
|
|
180
|
+
}
|
|
181
|
+
setMember(target) {
|
|
182
|
+
this.member = target;
|
|
183
|
+
this.update({ member: this.member });
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
setOperand(builder) {
|
|
187
|
+
this.operand = builder(ExpressionBuilder());
|
|
188
|
+
this.update({ operand: this.operand });
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var ObjectExprFactory = class extends AstFactory {
|
|
193
|
+
fields = [];
|
|
194
|
+
constructor() {
|
|
195
|
+
super({
|
|
196
|
+
type: ObjectExpr,
|
|
197
|
+
node: { fields: [] }
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
addField(builder) {
|
|
201
|
+
this.fields.push(builder(new FieldInitializerFactory()));
|
|
202
|
+
this.update({ fields: this.fields });
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var FieldInitializerFactory = class extends AstFactory {
|
|
207
|
+
name;
|
|
208
|
+
value;
|
|
209
|
+
constructor() {
|
|
210
|
+
super({ type: FieldInitializer });
|
|
211
|
+
}
|
|
212
|
+
setName(name) {
|
|
213
|
+
this.name = name;
|
|
214
|
+
this.update({ name: this.name });
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
setValue(builder) {
|
|
218
|
+
this.value = builder(ExpressionBuilder());
|
|
219
|
+
this.update({ value: this.value });
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var InvocationExprFactory = class extends AstFactory {
|
|
224
|
+
args = [];
|
|
225
|
+
function;
|
|
226
|
+
constructor() {
|
|
227
|
+
super({
|
|
228
|
+
type: InvocationExpr,
|
|
229
|
+
node: { args: [] }
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
addArg(builder) {
|
|
233
|
+
this.args.push(builder(new ArgumentFactory()));
|
|
234
|
+
this.update({ args: this.args });
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
setFunction(value) {
|
|
238
|
+
this.function = {
|
|
239
|
+
$refText: value.name,
|
|
240
|
+
ref: value
|
|
241
|
+
};
|
|
242
|
+
this.update({ function: this.function });
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var ArgumentFactory = class extends AstFactory {
|
|
247
|
+
value;
|
|
248
|
+
constructor() {
|
|
249
|
+
super({ type: Argument });
|
|
250
|
+
}
|
|
251
|
+
setValue(builder) {
|
|
252
|
+
this.value = builder(ExpressionBuilder());
|
|
253
|
+
this.update({ value: this.value });
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
var ArrayExprFactory = class extends AstFactory {
|
|
258
|
+
items = [];
|
|
259
|
+
constructor() {
|
|
260
|
+
super({
|
|
261
|
+
type: ArrayExpr,
|
|
262
|
+
node: { items: [] }
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
addItem(builder) {
|
|
266
|
+
this.items.push(builder(ExpressionBuilder()));
|
|
267
|
+
this.update({ items: this.items });
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
var BinaryExprFactory = class extends AstFactory {
|
|
272
|
+
operator;
|
|
273
|
+
right;
|
|
274
|
+
left;
|
|
275
|
+
constructor() {
|
|
276
|
+
super({ type: BinaryExpr });
|
|
277
|
+
}
|
|
278
|
+
setOperator(operator) {
|
|
279
|
+
this.operator = operator;
|
|
280
|
+
this.update({ operator: this.operator });
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
setRight(builder) {
|
|
284
|
+
this.right = builder(ExpressionBuilder());
|
|
285
|
+
this.update({ right: this.right });
|
|
286
|
+
return this;
|
|
287
|
+
}
|
|
288
|
+
setLeft(builder) {
|
|
289
|
+
this.left = builder(ExpressionBuilder());
|
|
290
|
+
this.update({ left: this.left });
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/factory/attribute.ts
|
|
296
|
+
var DataFieldAttributeFactory = class extends AstFactory {
|
|
297
|
+
args = [];
|
|
298
|
+
decl;
|
|
299
|
+
constructor() {
|
|
300
|
+
super({
|
|
301
|
+
type: DataFieldAttribute,
|
|
302
|
+
node: { args: [] }
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
setDecl(decl) {
|
|
306
|
+
if (!decl) throw new Error("Attribute declaration is required");
|
|
307
|
+
this.decl = {
|
|
308
|
+
$refText: decl.name,
|
|
309
|
+
ref: decl
|
|
310
|
+
};
|
|
311
|
+
this.update({ decl: this.decl });
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
addArg(builder, name) {
|
|
315
|
+
const factory = new AttributeArgFactory().setValue(builder);
|
|
316
|
+
if (name) factory.setName(name);
|
|
317
|
+
this.args.push(factory);
|
|
318
|
+
this.update({ args: this.args });
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
var DataModelAttributeFactory = class extends AstFactory {
|
|
323
|
+
args = [];
|
|
324
|
+
decl;
|
|
325
|
+
constructor() {
|
|
326
|
+
super({
|
|
327
|
+
type: DataModelAttribute,
|
|
328
|
+
node: { args: [] }
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
setDecl(decl) {
|
|
332
|
+
if (!decl) throw new Error("Attribute declaration is required");
|
|
333
|
+
this.decl = {
|
|
334
|
+
$refText: decl.name,
|
|
335
|
+
ref: decl
|
|
336
|
+
};
|
|
337
|
+
this.update({ decl: this.decl });
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
340
|
+
addArg(builder, name) {
|
|
341
|
+
const factory = new AttributeArgFactory().setValue(builder);
|
|
342
|
+
if (name) factory.setName(name);
|
|
343
|
+
this.args.push(factory);
|
|
344
|
+
this.update({ args: this.args });
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var AttributeArgFactory = class extends AstFactory {
|
|
349
|
+
name = "";
|
|
350
|
+
value;
|
|
351
|
+
constructor() {
|
|
352
|
+
super({ type: AttributeArg });
|
|
353
|
+
}
|
|
354
|
+
setName(name) {
|
|
355
|
+
this.name = name;
|
|
356
|
+
this.update({ name: this.name });
|
|
357
|
+
return this;
|
|
358
|
+
}
|
|
359
|
+
setValue(builder) {
|
|
360
|
+
this.value = builder(ExpressionBuilder());
|
|
361
|
+
this.update({ value: this.value });
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
var InternalAttributeFactory = class extends AstFactory {
|
|
366
|
+
decl;
|
|
367
|
+
args = [];
|
|
368
|
+
constructor() {
|
|
369
|
+
super({
|
|
370
|
+
type: InternalAttribute,
|
|
371
|
+
node: { args: [] }
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
setDecl(decl) {
|
|
375
|
+
this.decl = {
|
|
376
|
+
$refText: decl.name,
|
|
377
|
+
ref: decl
|
|
378
|
+
};
|
|
379
|
+
this.update({ decl: this.decl });
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
addArg(builder, name) {
|
|
383
|
+
const factory = new AttributeArgFactory().setValue(builder);
|
|
384
|
+
if (name) factory.setName(name);
|
|
385
|
+
this.args.push(factory);
|
|
386
|
+
this.update({ args: this.args });
|
|
387
|
+
return this;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
var AttributeParamFactory = class extends AstFactory {
|
|
391
|
+
attributes = [];
|
|
392
|
+
comments = [];
|
|
393
|
+
default;
|
|
394
|
+
name;
|
|
395
|
+
type;
|
|
396
|
+
constructor() {
|
|
397
|
+
super({
|
|
398
|
+
type: AttributeParam,
|
|
399
|
+
node: {
|
|
400
|
+
comments: [],
|
|
401
|
+
attributes: []
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
addAttribute(builder) {
|
|
406
|
+
this.attributes.push(builder(new InternalAttributeFactory()));
|
|
407
|
+
this.update({ attributes: this.attributes });
|
|
408
|
+
return this;
|
|
409
|
+
}
|
|
410
|
+
setComments(comments) {
|
|
411
|
+
this.comments = comments;
|
|
412
|
+
this.update({ comments: this.comments });
|
|
413
|
+
return this;
|
|
414
|
+
}
|
|
415
|
+
setDefault(defaultValue) {
|
|
416
|
+
this.default = defaultValue;
|
|
417
|
+
this.update({ default: this.default });
|
|
418
|
+
return this;
|
|
419
|
+
}
|
|
420
|
+
setName(name) {
|
|
421
|
+
this.name = name;
|
|
422
|
+
this.update({ name: this.name });
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
setType(builder) {
|
|
426
|
+
this.type = builder(new AttributeParamTypeFactory());
|
|
427
|
+
this.update({ type: this.type });
|
|
428
|
+
return this;
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
var AttributeParamTypeFactory = class extends AstFactory {
|
|
432
|
+
array;
|
|
433
|
+
optional;
|
|
434
|
+
reference;
|
|
435
|
+
type;
|
|
436
|
+
constructor() {
|
|
437
|
+
super({ type: AttributeParamType });
|
|
438
|
+
}
|
|
439
|
+
setArray(array) {
|
|
440
|
+
this.array = array;
|
|
441
|
+
this.update({ array: this.array });
|
|
442
|
+
return this;
|
|
443
|
+
}
|
|
444
|
+
setOptional(optional) {
|
|
445
|
+
this.optional = optional;
|
|
446
|
+
this.update({ optional: this.optional });
|
|
447
|
+
return this;
|
|
448
|
+
}
|
|
449
|
+
setReference(reference) {
|
|
450
|
+
this.reference = {
|
|
451
|
+
$refText: reference.name,
|
|
452
|
+
ref: reference
|
|
453
|
+
};
|
|
454
|
+
this.update({ reference: this.reference });
|
|
455
|
+
return this;
|
|
456
|
+
}
|
|
457
|
+
setType(type) {
|
|
458
|
+
this.type = type;
|
|
459
|
+
this.update({ type: this.type });
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var AttributeFactory = class extends AstFactory {
|
|
464
|
+
name;
|
|
465
|
+
comments = [];
|
|
466
|
+
attributes = [];
|
|
467
|
+
params = [];
|
|
468
|
+
constructor() {
|
|
469
|
+
super({
|
|
470
|
+
type: Attribute,
|
|
471
|
+
node: {
|
|
472
|
+
comments: [],
|
|
473
|
+
attributes: [],
|
|
474
|
+
params: []
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
setName(name) {
|
|
479
|
+
this.name = name;
|
|
480
|
+
this.update({ name: this.name });
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
setComments(comments) {
|
|
484
|
+
this.comments = comments;
|
|
485
|
+
this.update({ comments: this.comments });
|
|
486
|
+
return this;
|
|
487
|
+
}
|
|
488
|
+
addAttribute(builder) {
|
|
489
|
+
this.attributes.push(builder(new InternalAttributeFactory()));
|
|
490
|
+
this.update({ attributes: this.attributes });
|
|
491
|
+
return this;
|
|
492
|
+
}
|
|
493
|
+
addParam(builder) {
|
|
494
|
+
this.params.push(builder(new AttributeParamFactory()));
|
|
495
|
+
this.update({ params: this.params });
|
|
496
|
+
return this;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/factory/declaration.ts
|
|
501
|
+
const DeclarationBuilder = () => ({
|
|
502
|
+
get Attribute() {
|
|
503
|
+
return new AttributeFactory();
|
|
504
|
+
},
|
|
505
|
+
get DataModel() {
|
|
506
|
+
return new DataModelFactory();
|
|
507
|
+
},
|
|
508
|
+
get DataSource() {
|
|
509
|
+
throw new Error("DataSource is not implemented");
|
|
510
|
+
},
|
|
511
|
+
get Enum() {
|
|
512
|
+
return new EnumFactory();
|
|
513
|
+
},
|
|
514
|
+
get FunctionDecl() {
|
|
515
|
+
throw new Error("FunctionDecl is not implemented");
|
|
516
|
+
},
|
|
517
|
+
get GeneratorDecl() {
|
|
518
|
+
throw new Error("GeneratorDecl is not implemented");
|
|
519
|
+
},
|
|
520
|
+
get Plugin() {
|
|
521
|
+
throw new Error("Plugin is not implemented");
|
|
522
|
+
},
|
|
523
|
+
get Procedure() {
|
|
524
|
+
throw new Error("Procedure is not implemented");
|
|
525
|
+
},
|
|
526
|
+
get TypeDef() {
|
|
527
|
+
throw new Error("TypeDef is not implemented");
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
var DataModelFactory = class extends AstFactory {
|
|
531
|
+
attributes = [];
|
|
532
|
+
baseModel;
|
|
533
|
+
comments = [];
|
|
534
|
+
fields = [];
|
|
535
|
+
isView;
|
|
536
|
+
mixins = [];
|
|
537
|
+
name;
|
|
538
|
+
constructor() {
|
|
539
|
+
super({
|
|
540
|
+
type: DataModel,
|
|
541
|
+
node: {
|
|
542
|
+
attributes: [],
|
|
543
|
+
comments: [],
|
|
544
|
+
fields: [],
|
|
545
|
+
mixins: []
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
addAttribute(builder) {
|
|
550
|
+
this.attributes.push(builder(new DataModelAttributeFactory()).setContainer(this.node));
|
|
551
|
+
this.update({ attributes: this.attributes });
|
|
552
|
+
return this;
|
|
553
|
+
}
|
|
554
|
+
setBaseModel(model) {
|
|
555
|
+
this.baseModel = model;
|
|
556
|
+
this.update({ baseModel: this.baseModel });
|
|
557
|
+
return this;
|
|
558
|
+
}
|
|
559
|
+
setComments(comments) {
|
|
560
|
+
this.comments = comments;
|
|
561
|
+
this.update({ comments: this.comments });
|
|
562
|
+
return this;
|
|
563
|
+
}
|
|
564
|
+
addComment(comment) {
|
|
565
|
+
this.comments.push(comment);
|
|
566
|
+
this.update({ comments: this.comments });
|
|
567
|
+
return this;
|
|
568
|
+
}
|
|
569
|
+
addField(builder) {
|
|
570
|
+
this.fields.push(builder(new DataFieldFactory()).setContainer(this.node));
|
|
571
|
+
this.update({ fields: this.fields });
|
|
572
|
+
return this;
|
|
573
|
+
}
|
|
574
|
+
setIsView(isView) {
|
|
575
|
+
this.isView = isView;
|
|
576
|
+
this.update({ isView: this.isView });
|
|
577
|
+
return this;
|
|
578
|
+
}
|
|
579
|
+
addMixin(mixin) {
|
|
580
|
+
this.mixins.push(mixin);
|
|
581
|
+
this.update({ mixins: this.mixins });
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
setName(name) {
|
|
585
|
+
this.name = name;
|
|
586
|
+
this.update({ name: this.name });
|
|
587
|
+
return this;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
var DataFieldFactory = class extends AstFactory {
|
|
591
|
+
attributes = [];
|
|
592
|
+
comments = [];
|
|
593
|
+
name;
|
|
594
|
+
type;
|
|
595
|
+
constructor() {
|
|
596
|
+
super({
|
|
597
|
+
type: DataField,
|
|
598
|
+
node: {
|
|
599
|
+
attributes: [],
|
|
600
|
+
comments: []
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
addAttribute(builder) {
|
|
605
|
+
if (builder instanceof DataFieldAttributeFactory) {
|
|
606
|
+
builder.setContainer(this.node);
|
|
607
|
+
this.attributes.push(builder);
|
|
608
|
+
} else {
|
|
609
|
+
const attr = builder(new DataFieldAttributeFactory());
|
|
610
|
+
attr.setContainer(this.node);
|
|
611
|
+
this.attributes.push(attr);
|
|
612
|
+
}
|
|
613
|
+
this.update({ attributes: this.attributes });
|
|
614
|
+
return this;
|
|
615
|
+
}
|
|
616
|
+
setComments(comments) {
|
|
617
|
+
this.comments = comments;
|
|
618
|
+
this.update({ comments: this.comments });
|
|
619
|
+
return this;
|
|
620
|
+
}
|
|
621
|
+
setName(name) {
|
|
622
|
+
this.name = name;
|
|
623
|
+
this.update({ name: this.name });
|
|
624
|
+
return this;
|
|
625
|
+
}
|
|
626
|
+
setType(builder) {
|
|
627
|
+
this.type = builder(new DataFieldTypeFactory()).setContainer(this.node);
|
|
628
|
+
this.update({ type: this.type });
|
|
629
|
+
return this;
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
var DataFieldTypeFactory = class extends AstFactory {
|
|
633
|
+
array;
|
|
634
|
+
optional;
|
|
635
|
+
reference;
|
|
636
|
+
type;
|
|
637
|
+
unsupported;
|
|
638
|
+
constructor() {
|
|
639
|
+
super({ type: DataFieldType });
|
|
640
|
+
}
|
|
641
|
+
setArray(array) {
|
|
642
|
+
this.array = array;
|
|
643
|
+
this.update({ array: this.array });
|
|
644
|
+
return this;
|
|
645
|
+
}
|
|
646
|
+
setOptional(optional) {
|
|
647
|
+
this.optional = optional;
|
|
648
|
+
this.update({ optional: this.optional });
|
|
649
|
+
return this;
|
|
650
|
+
}
|
|
651
|
+
setReference(reference) {
|
|
652
|
+
this.reference = {
|
|
653
|
+
$refText: reference.name,
|
|
654
|
+
ref: reference
|
|
655
|
+
};
|
|
656
|
+
this.update({ reference: this.reference });
|
|
657
|
+
return this;
|
|
658
|
+
}
|
|
659
|
+
setType(type) {
|
|
660
|
+
this.type = type;
|
|
661
|
+
this.update({ type: this.type });
|
|
662
|
+
return this;
|
|
663
|
+
}
|
|
664
|
+
setUnsupported(builder) {
|
|
665
|
+
this.unsupported = builder(new UnsupportedFieldTypeFactory()).setContainer(this.node);
|
|
666
|
+
this.update({ unsupported: this.unsupported });
|
|
667
|
+
return this;
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
var UnsupportedFieldTypeFactory = class extends AstFactory {
|
|
671
|
+
value;
|
|
672
|
+
constructor() {
|
|
673
|
+
super({ type: UnsupportedFieldType });
|
|
674
|
+
}
|
|
675
|
+
setValue(builder) {
|
|
676
|
+
this.value = builder(ExpressionBuilder());
|
|
677
|
+
this.update({ value: this.value });
|
|
678
|
+
return this;
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
var ModelFactory = class extends AstFactory {
|
|
682
|
+
declarations = [];
|
|
683
|
+
imports = [];
|
|
684
|
+
constructor() {
|
|
685
|
+
super({
|
|
686
|
+
type: Model,
|
|
687
|
+
node: {
|
|
688
|
+
declarations: [],
|
|
689
|
+
imports: []
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
addImport(builder) {
|
|
694
|
+
this.imports.push(builder(new ModelImportFactory()).setContainer(this.node));
|
|
695
|
+
this.update({ imports: this.imports });
|
|
696
|
+
return this;
|
|
697
|
+
}
|
|
698
|
+
addDeclaration(builder) {
|
|
699
|
+
this.declarations.push(builder(DeclarationBuilder()).setContainer(this.node));
|
|
700
|
+
this.update({ declarations: this.declarations });
|
|
701
|
+
return this;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
var ModelImportFactory = class extends AstFactory {
|
|
705
|
+
path;
|
|
706
|
+
constructor() {
|
|
707
|
+
super({ type: ModelImport });
|
|
708
|
+
}
|
|
709
|
+
setPath(path) {
|
|
710
|
+
this.path = path;
|
|
711
|
+
this.update({ path: this.path });
|
|
712
|
+
return this;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
var EnumFactory = class extends AstFactory {
|
|
716
|
+
name;
|
|
717
|
+
comments = [];
|
|
718
|
+
fields = [];
|
|
719
|
+
attributes = [];
|
|
720
|
+
constructor() {
|
|
721
|
+
super({
|
|
722
|
+
type: Enum,
|
|
723
|
+
node: {
|
|
724
|
+
comments: [],
|
|
725
|
+
fields: [],
|
|
726
|
+
attributes: []
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
addField(builder) {
|
|
731
|
+
this.fields.push(builder(new EnumFieldFactory()).setContainer(this.node));
|
|
732
|
+
this.update({ fields: this.fields });
|
|
733
|
+
return this;
|
|
734
|
+
}
|
|
735
|
+
addAttribute(builder) {
|
|
736
|
+
this.attributes.push(builder(new DataModelAttributeFactory()).setContainer(this.node));
|
|
737
|
+
this.update({ attributes: this.attributes });
|
|
738
|
+
return this;
|
|
739
|
+
}
|
|
740
|
+
setName(name) {
|
|
741
|
+
this.name = name;
|
|
742
|
+
this.update({ name: this.name });
|
|
743
|
+
return this;
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
var EnumFieldFactory = class extends AstFactory {
|
|
747
|
+
name;
|
|
748
|
+
comments = [];
|
|
749
|
+
attributes = [];
|
|
750
|
+
constructor() {
|
|
751
|
+
super({
|
|
752
|
+
type: EnumField,
|
|
753
|
+
node: {
|
|
754
|
+
comments: [],
|
|
755
|
+
attributes: []
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
setName(name) {
|
|
760
|
+
this.name = name;
|
|
761
|
+
this.update({ name: this.name });
|
|
762
|
+
return this;
|
|
763
|
+
}
|
|
764
|
+
addAttribute(builder) {
|
|
765
|
+
this.attributes.push(builder(new DataFieldAttributeFactory()).setContainer(this.node));
|
|
766
|
+
this.update({ attributes: this.attributes });
|
|
767
|
+
return this;
|
|
768
|
+
}
|
|
769
|
+
addComment(comment) {
|
|
770
|
+
this.comments.push(comment);
|
|
771
|
+
this.update({ comments: this.comments });
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
//#endregion
|
|
776
|
+
export { ArgumentFactory, ArrayExprFactory, AstFactory, AttributeArgFactory, AttributeFactory, AttributeParamFactory, AttributeParamTypeFactory, BinaryExprFactory, BooleanLiteralFactory, DataFieldAttributeFactory, DataFieldFactory, DataFieldTypeFactory, DataModelAttributeFactory, DataModelFactory, DeclarationBuilder, EnumFactory, EnumFieldFactory, ExpressionBuilder, FieldInitializerFactory, InternalAttributeFactory, InvocationExprFactory, MemberAccessExprFactory, ModelFactory, ModelImportFactory, NullExprFactory, NumberLiteralFactory, ObjectExprFactory, ReferenceArgFactory, ReferenceExprFactory, StringLiteralFactory, ThisExprFactory, UnaryExprFactory, UnsupportedFieldTypeFactory };
|
|
777
|
+
|
|
778
|
+
//# sourceMappingURL=factory.mjs.map
|