@webda/core 3.16.0 → 4.0.0-beta.1

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.
Files changed (68) hide show
  1. package/lib/application.d.ts +9 -0
  2. package/lib/application.js.map +1 -1
  3. package/lib/core.d.ts +2 -1
  4. package/lib/core.js +6 -5
  5. package/lib/core.js.map +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js +1 -1
  8. package/lib/index.js.map +1 -1
  9. package/lib/models/coremodel.d.ts +6 -0
  10. package/lib/models/coremodel.js +5 -4
  11. package/lib/models/coremodel.js.map +1 -1
  12. package/lib/queues/queue.spec.js +2 -0
  13. package/lib/queues/queue.spec.js.map +1 -1
  14. package/lib/services/filebinary.spec.js +3 -3
  15. package/lib/services/filebinary.spec.js.map +1 -1
  16. package/lib/services/prometheus.js +3 -2
  17. package/lib/services/prometheus.js.map +1 -1
  18. package/lib/services/resource.d.ts +5 -0
  19. package/lib/services/resource.js +4 -1
  20. package/lib/services/resource.js.map +1 -1
  21. package/lib/stores/aliasstore.d.ts +1 -1
  22. package/lib/stores/aliasstore.js +1 -1
  23. package/lib/stores/aliasstore.js.map +1 -1
  24. package/lib/stores/file.d.ts +1 -1
  25. package/lib/stores/memory.d.ts +1 -1
  26. package/lib/stores/memory.spec.js +1 -1
  27. package/lib/stores/memory.spec.js.map +1 -1
  28. package/lib/stores/store.d.ts +1 -1
  29. package/lib/stores/store.js +1 -1
  30. package/lib/stores/store.js.map +1 -1
  31. package/lib/stores/store.spec.js +12 -12
  32. package/lib/stores/store.spec.js.map +1 -1
  33. package/lib/unpackedapplication.js +1 -1
  34. package/lib/unpackedapplication.js.map +1 -1
  35. package/lib/utils/context.js +5 -1
  36. package/lib/utils/context.js.map +1 -1
  37. package/lib/utils/context.spec.js +1 -1
  38. package/lib/utils/context.spec.js.map +1 -1
  39. package/lib/utils/serializers.d.ts +5 -4
  40. package/lib/utils/serializers.js +22 -19
  41. package/lib/utils/serializers.js.map +1 -1
  42. package/lib/utils/serializers.spec.js +7 -7
  43. package/lib/utils/serializers.spec.js.map +1 -1
  44. package/lib/utils/waiter.js +2 -2
  45. package/lib/utils/waiter.js.map +1 -1
  46. package/package.json +8 -8
  47. package/webda.module.json +5 -0
  48. package/lib/stores/webdaql/WebdaQLLexer.d.ts +0 -54
  49. package/lib/stores/webdaql/WebdaQLLexer.js +0 -295
  50. package/lib/stores/webdaql/WebdaQLLexer.js.map +0 -1
  51. package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +0 -54
  52. package/lib/stores/webdaql/WebdaQLParserLexer.js +0 -295
  53. package/lib/stores/webdaql/WebdaQLParserLexer.js.map +0 -1
  54. package/lib/stores/webdaql/WebdaQLParserListener.d.ts +0 -296
  55. package/lib/stores/webdaql/WebdaQLParserListener.js +0 -3
  56. package/lib/stores/webdaql/WebdaQLParserListener.js.map +0 -1
  57. package/lib/stores/webdaql/WebdaQLParserParser.d.ts +0 -311
  58. package/lib/stores/webdaql/WebdaQLParserParser.js +0 -1807
  59. package/lib/stores/webdaql/WebdaQLParserParser.js.map +0 -1
  60. package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +0 -181
  61. package/lib/stores/webdaql/WebdaQLParserVisitor.js +0 -3
  62. package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +0 -1
  63. package/lib/stores/webdaql/query.d.ts +0 -387
  64. package/lib/stores/webdaql/query.js +0 -667
  65. package/lib/stores/webdaql/query.js.map +0 -1
  66. package/lib/stores/webdaql/query.spec.d.ts +0 -1
  67. package/lib/stores/webdaql/query.spec.js +0 -199
  68. package/lib/stores/webdaql/query.spec.js.map +0 -1
@@ -1,387 +0,0 @@
1
- import { AbstractParseTreeVisitor, ParseTree } from "antlr4ts/tree/index.js";
2
- import { WebdaQLLexer } from "./WebdaQLLexer.js";
3
- import { AndLogicExpressionContext, BinaryComparisonExpressionContext, BooleanLiteralContext, ContainsExpressionContext, InExpressionContext, IntegerLiteralContext, LikeExpressionContext, LimitExpressionContext, OffsetExpressionContext, OrLogicExpressionContext, OrderExpressionContext, OrderFieldExpressionContext, SetExpressionContext, StringLiteralContext, WebdaqlContext } from "./WebdaQLParserParser.js";
4
- import { WebdaQLParserVisitor } from "./WebdaQLParserVisitor.js";
5
- type value = boolean | string | number;
6
- /**
7
- * Meta Query Language
8
- *
9
- *
10
- */
11
- export declare namespace WebdaQL {
12
- interface OrderBy {
13
- field: string;
14
- direction: "ASC" | "DESC";
15
- }
16
- function PrependCondition(query?: string, condition?: string): string;
17
- /**
18
- * Create Expression based on the parsed token
19
- *
20
- * Expression allow to optimize and split between Query and Filter
21
- */
22
- class ExpressionBuilder extends AbstractParseTreeVisitor<Query> implements WebdaQLParserVisitor<any> {
23
- /**
24
- * Contain the parsed limit
25
- */
26
- limit: number;
27
- /**
28
- * Contain the parsed offset
29
- */
30
- offset: string;
31
- orderBy: OrderBy[];
32
- /**
33
- * Default result for the override
34
- * @returns
35
- */
36
- protected defaultResult(): Query;
37
- /**
38
- * Get offset
39
- * @returns
40
- */
41
- getOffset(): string;
42
- /**
43
- * Get limit
44
- * @returns
45
- */
46
- getLimit(): number;
47
- /**
48
- * Read the limit
49
- * @param ctx
50
- */
51
- visitLimitExpression(ctx: LimitExpressionContext): void;
52
- /**
53
- * Read the offset if provided
54
- * @param ctx
55
- */
56
- visitOffsetExpression(ctx: OffsetExpressionContext): void;
57
- /**
58
- * Visit a order field expression
59
- */
60
- visitOrderFieldExpression(ctx: OrderFieldExpressionContext): OrderBy;
61
- /**
62
- * Read the order by values
63
- */
64
- visitOrderExpression(ctx: OrderExpressionContext): void;
65
- /**
66
- * Return only AndExpression
67
- * @param ctx
68
- * @returns
69
- */
70
- visitWebdaql(ctx: WebdaqlContext): Query;
71
- /**
72
- * Simplify Logic expression and regroup them
73
- * @param ctx
74
- * @returns
75
- */
76
- getComparison(ctx: AndLogicExpressionContext | OrLogicExpressionContext): any[];
77
- /**
78
- * Get the AndExpression, regrouping all the parameters
79
- *
80
- * By default the parser is doing a AND (b AND (c AND d)) creating 3 depth expressions
81
- * This visitor simplify to a AND b AND c AND d with only one Expression
82
- */
83
- visitAndLogicExpression(ctx: AndLogicExpressionContext): AndExpression;
84
- /**
85
- * Implement the BinaryComparison with all methods managed
86
- */
87
- visitBinaryComparisonExpression(ctx: BinaryComparisonExpressionContext): ComparisonExpression<ComparisonOperator>;
88
- /**
89
- * Visit each value of the [..., ..., ...] set
90
- */
91
- visitSetExpression(ctx: SetExpressionContext): value[];
92
- /**
93
- * a LIKE "%A?"
94
- * @param ctx
95
- * @returns
96
- */
97
- visitLikeExpression(ctx: LikeExpressionContext): ComparisonExpression<"LIKE">;
98
- /**
99
- * Map the a IN ['b','c']
100
- */
101
- visitInExpression(ctx: InExpressionContext): ComparisonExpression<"IN">;
102
- /**
103
- * Map the a CONTAINS 'b'
104
- */
105
- visitContainsExpression(ctx: ContainsExpressionContext): ComparisonExpression<"CONTAINS">;
106
- /**
107
- * Get the OrExpression, regrouping all the parameters
108
- *
109
- * By default the parser is doing a OR (b OR (c OR d)) creating 3 depth expressions
110
- * This visitor simplify to a OR b OR c OR d with only one Expression
111
- */
112
- visitOrLogicExpression(ctx: OrLogicExpressionContext): OrExpression;
113
- /**
114
- * Read the string literal (removing the simple or double bracket)
115
- */
116
- visitStringLiteral(ctx: StringLiteralContext): string;
117
- /**
118
- * Read the boolean literal
119
- */
120
- visitBooleanLiteral(ctx: BooleanLiteralContext): boolean;
121
- /**
122
- * Read the number literal
123
- */
124
- visitIntegerLiteral(ctx: IntegerLiteralContext): number;
125
- }
126
- /**
127
- * Represent a full Query
128
- */
129
- interface Query {
130
- /**
131
- * Filtering part of the expression
132
- */
133
- filter: Expression;
134
- /**
135
- * Limit value
136
- */
137
- limit?: number;
138
- /**
139
- * Offset value
140
- */
141
- continuationToken?: string;
142
- /**
143
- * Order by clause
144
- */
145
- orderBy?: OrderBy[];
146
- /**
147
- * Get the string representation of the query
148
- */
149
- toString(): string;
150
- }
151
- /**
152
- * Represent the query expression or subset
153
- */
154
- abstract class Expression<T = string> {
155
- operator: T;
156
- constructor(operator: T);
157
- /**
158
- * Evaluate the expression for the target object
159
- * @param target to evaluate
160
- */
161
- abstract eval(target: any): boolean;
162
- /**
163
- * Return the representation of the expression
164
- * @param depth
165
- */
166
- abstract toString(depth?: number): string;
167
- }
168
- type ComparisonOperator = "=" | "<=" | ">=" | "<" | ">" | "!=" | "LIKE" | "IN" | "CONTAINS";
169
- /**
170
- * Comparison expression
171
- */
172
- class ComparisonExpression<T extends ComparisonOperator = ComparisonOperator> extends Expression<T> {
173
- /**
174
- * Right side of the comparison
175
- */
176
- value: value | value[];
177
- /**
178
- * Attribute to read from the object (split by .)
179
- */
180
- attribute: string[];
181
- /**
182
- *
183
- * @param operator of the expression
184
- * @param attribute of the object to read
185
- * @param value
186
- */
187
- constructor(operator: T, attribute: string, value: value | any[]);
188
- static likeToRegex(like: string): RegExp;
189
- /**
190
- * Read the value from the object
191
- *
192
- * @param target
193
- * @returns
194
- */
195
- static getAttributeValue(target: any, attribute: string[]): any;
196
- /**
197
- * Set the value of the attribute based on the assignment
198
- *
199
- * If used as a Set expression
200
- * @param target
201
- */
202
- setAttributeValue(target: any): void;
203
- /**
204
- * @override
205
- */
206
- eval(target: any): boolean;
207
- /**
208
- * Return a string represantation of a value
209
- */
210
- toStringValue(value: value | value[]): string;
211
- /**
212
- * Allow subclass to create different display
213
- */
214
- toStringAttribute(): string;
215
- /**
216
- * Allow subclass to create different display
217
- */
218
- toStringOperator(): T;
219
- /**
220
- * @override
221
- */
222
- toString(): string;
223
- }
224
- /**
225
- * Abstract logic expression (AND|OR)
226
- *
227
- * Could add XOR in the future
228
- */
229
- abstract class LogicalExpression<T> extends Expression<T> {
230
- /**
231
- * Contains the members of the logical expression
232
- */
233
- children: Expression[];
234
- /**
235
- *
236
- * @param operator
237
- * @param children
238
- */
239
- constructor(operator: T, children: Expression[]);
240
- /**
241
- * @override
242
- */
243
- toString(depth?: number): string;
244
- }
245
- /**
246
- * AND Expression implementation
247
- */
248
- class AndExpression extends LogicalExpression<"AND"> {
249
- /**
250
- * @param children Expressions to use for AND
251
- */
252
- constructor(children: Expression[]);
253
- /**
254
- * @override
255
- */
256
- eval(target: any): boolean;
257
- }
258
- /**
259
- * OR Expression implementation
260
- */
261
- class OrExpression extends LogicalExpression<"OR"> {
262
- /**
263
- * @param children Expressions to use for OR
264
- */
265
- constructor(children: Expression[]);
266
- /**
267
- * @override
268
- */
269
- eval(target: any): boolean;
270
- }
271
- /**
272
- *
273
- */
274
- class QueryValidator {
275
- protected sql: string;
276
- protected lexer: WebdaQLLexer;
277
- protected tree: WebdaqlContext;
278
- protected query: Query;
279
- protected builder: ExpressionBuilder;
280
- constructor(sql: string, builder?: ExpressionBuilder);
281
- /**
282
- * Get offset
283
- * @returns
284
- */
285
- getOffset(): string;
286
- /**
287
- * Get limit
288
- * @returns
289
- */
290
- getLimit(): number;
291
- /**
292
- * Get the expression by itself
293
- * @returns
294
- */
295
- getExpression(): Expression;
296
- /**
297
- * Retrieve parsed query
298
- * @returns
299
- */
300
- getQuery(): Query;
301
- /**
302
- * Verify if a target fit the expression
303
- * @param target
304
- * @returns
305
- */
306
- eval(target: any): boolean;
307
- /**
308
- * Display parse tree back as query
309
- * @param tree
310
- * @returns
311
- */
312
- displayTree(tree?: ParseTree): string;
313
- }
314
- /**
315
- * For now reuse same parser
316
- */
317
- class SetterValidator extends QueryValidator {
318
- constructor(sql: string);
319
- eval(target: any): boolean;
320
- assign(target: any, expression: Expression): void;
321
- }
322
- class PartialValidator extends QueryValidator {
323
- builder: PartialExpressionBuilder;
324
- constructor(query: string, builder?: PartialExpressionBuilder);
325
- /**
326
- * Eval the query
327
- * @param target
328
- * @param partial
329
- * @returns
330
- */
331
- eval(target: any, partial?: boolean): boolean;
332
- /**
333
- * Return if the result ignored some fields
334
- * @returns
335
- */
336
- wasPartialMatch(): boolean;
337
- }
338
- class PartialComparisonExpression<T extends ComparisonOperator = ComparisonOperator> extends ComparisonExpression<T> {
339
- protected builder: PartialExpressionBuilder;
340
- constructor(builder: PartialExpressionBuilder, op: T, attribute: string, value: any);
341
- /**
342
- * Override the eval to check if the attribute is present
343
- * if not and we are in partial mode, return true
344
- *
345
- * @param target
346
- * @returns
347
- */
348
- eval(target: any): boolean;
349
- }
350
- class PartialExpressionBuilder extends ExpressionBuilder {
351
- /**
352
- * Enforce the partial mode
353
- */
354
- partial: boolean;
355
- /**
356
- * If eval was called in partial mode
357
- */
358
- partialMatch: boolean;
359
- setPartial(partial: boolean): void;
360
- setPartialMatch(partial: boolean): void;
361
- /**
362
- * a LIKE "%A?"
363
- * @param ctx
364
- * @returns
365
- */
366
- visitLikeExpression(ctx: any): PartialComparisonExpression<"LIKE">;
367
- /**
368
- * Implement the BinaryComparison with all methods managed
369
- */
370
- visitBinaryComparisonExpression(ctx: any): PartialComparisonExpression<any>;
371
- /**
372
- * Map the a IN ['b','c']
373
- */
374
- visitInExpression(ctx: any): PartialComparisonExpression<"IN">;
375
- /**
376
- * Map the a CONTAINS 'b'
377
- */
378
- visitContainsExpression(ctx: any): PartialComparisonExpression<"CONTAINS">;
379
- }
380
- /**
381
- * Remove artifact from sanitize-html inside query
382
- * @param query
383
- * @returns
384
- */
385
- function unsanitize(query: string): string;
386
- }
387
- export {};