@webda/ql 4.0.0-beta.7 → 4.0.0-beta.8
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/README.md +38 -0
- package/lib/WebdaQLLexer.d.ts +10 -9
- package/lib/WebdaQLLexer.d.ts.map +1 -1
- package/lib/WebdaQLLexer.js +227 -363
- package/lib/WebdaQLLexer.js.map +1 -1
- package/lib/WebdaQLParserLexer.d.ts +10 -9
- package/lib/WebdaQLParserLexer.d.ts.map +1 -1
- package/lib/WebdaQLParserLexer.js +227 -363
- package/lib/WebdaQLParserLexer.js.map +1 -1
- package/lib/WebdaQLParserListener.d.ts +26 -2
- package/lib/WebdaQLParserListener.d.ts.map +1 -1
- package/lib/WebdaQLParserParser.d.ts +34 -9
- package/lib/WebdaQLParserParser.d.ts.map +1 -1
- package/lib/WebdaQLParserParser.js +585 -732
- package/lib/WebdaQLParserParser.js.map +1 -1
- package/lib/WebdaQLParserVisitor.d.ts +16 -1
- package/lib/WebdaQLParserVisitor.d.ts.map +1 -1
- package/lib/completion.d.ts +84 -0
- package/lib/completion.d.ts.map +1 -0
- package/lib/completion.js +467 -0
- package/lib/completion.js.map +1 -0
- package/lib/completion.spec.d.ts +25 -0
- package/lib/completion.spec.d.ts.map +1 -0
- package/lib/completion.spec.js +409 -0
- package/lib/completion.spec.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/now.spec.d.ts +2 -0
- package/lib/now.spec.d.ts.map +1 -0
- package/lib/now.spec.js +258 -0
- package/lib/now.spec.js.map +1 -0
- package/lib/query.d.ts +126 -7
- package/lib/query.d.ts.map +1 -1
- package/lib/query.js +272 -18
- package/lib/query.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ aggregation syntax, uppercase `COUNT`, `SUM`, `AVG`, `MIN`, `MAX`, `AS`, `DISTIN
|
|
|
54
54
|
**Filter expressions** support:
|
|
55
55
|
|
|
56
56
|
- Comparison: `field = value`, `field != value`, `field > value`, `field >= value`, `field < value`, `field <= value`
|
|
57
|
+
- Time function: `field > NOW()`, `field < NOW('-10m')`, `field >= NOW('+1d')` (millisecond timestamp resolution)
|
|
57
58
|
- Pattern match: `field LIKE "pattern"` (`_` = single char, `%` = any chars)
|
|
58
59
|
- Set membership: `field IN [value, value, ...]`
|
|
59
60
|
- Array contains: `field CONTAINS value`
|
|
@@ -94,6 +95,22 @@ WebdaQL.bind("priority >= ? LIMIT ?", [2, 10]); // priority >= 2 LIMIT 10
|
|
|
94
95
|
|
|
95
96
|
Placeholders are only allowed where a value is expected, values are escaped by type, and `= ?` / `!= ?` with `null` become `IS NULL` / `IS NOT NULL`. Template literals passed straight to a query method are escaped the same way at compile time by `webdac`. See [Parameters](../../docs/pages/Modules/ql/Parameters.md).
|
|
96
97
|
|
|
98
|
+
### NOW() time function
|
|
99
|
+
|
|
100
|
+
WebdaQL supports `NOW()` to produce dynamic numeric timestamps (milliseconds since Unix epoch):
|
|
101
|
+
|
|
102
|
+
- `NOW()`: current timestamp (`Date.now()`).
|
|
103
|
+
- `NOW('-10m')` / `NOW('+1d')`: current timestamp offset by duration string.
|
|
104
|
+
- Units supported: `ms`, `s`/`sec`, `m`/`min`, `h`/`hr`, `d`/`day`, `mo`/`mon`/`month`, `y`/`yr`/`year`. Multi-part durations like `NOW('-1d2h')` are supported.
|
|
105
|
+
- Numeric millisecond offsets: `NOW(-60000)` or `NOW(60000)`.
|
|
106
|
+
- Parameters: `NOW(?)` and `NOW(:offset)` can be bound using `bind()`.
|
|
107
|
+
- Updates: `UPDATE SET lastLoginAt = NOW()`.
|
|
108
|
+
- Dynamic evaluation: Expressions with `NOW()` evaluate dynamically at query execution or access time, allowing cached queries and operation permissions to track real time:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
@Operation({ permission: "mfa = 'verified' AND mfaAt > NOW('-10m')" })
|
|
112
|
+
```
|
|
113
|
+
|
|
97
114
|
### Statements: SELECT, DELETE, UPDATE
|
|
98
115
|
|
|
99
116
|
WebdaQL parses `SELECT`, `DELETE` and `UPDATE` statements; the parsed `Query` carries `type` (`"SELECT"` for a plain filter), `fields` (SELECT) and `assignments` (UPDATE), and `toString()` round-trips them.
|
|
@@ -124,6 +141,24 @@ q.aggregation.metrics; // { n: { fn: "COUNT" }, total: { fn: "SUM", field: "poin
|
|
|
124
141
|
See [Statements](../../docs/pages/Modules/ql/Statements.md#aggregation-select--group-by) and
|
|
125
142
|
[Repositories](../../docs/pages/Concepts/Stores/Repositories.md#aggregation).
|
|
126
143
|
|
|
144
|
+
### Code completion
|
|
145
|
+
|
|
146
|
+
WebdaQL provides grammar-driven code completion powered by `antlr4-c3`. `getCompletions` returns candidates for fields, keywords, operators, enum/boolean values, and parameters for a query and caret offset:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import { getCompletions, fieldsFromSchema } from "@webda/ql";
|
|
150
|
+
|
|
151
|
+
const fields = [
|
|
152
|
+
{ name: "status", type: "string", enum: ["draft", "published"] },
|
|
153
|
+
{ name: "viewCount", type: "integer" }
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
const { items, prefix } = getCompletions("status = 'dr", 12, { fields });
|
|
157
|
+
// => items offer "'draft'", replacing range [9, 13]
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
See [Code Completion](../../docs/pages/Modules/ql/Completion.md).
|
|
161
|
+
|
|
127
162
|
### API reference
|
|
128
163
|
|
|
129
164
|
| Export | Description |
|
|
@@ -147,6 +182,8 @@ See [Statements](../../docs/pages/Modules/ql/Statements.md#aggregation-select--g
|
|
|
147
182
|
| `AggregationError` | Runtime aggregation error with a `code` (`AGGREGATION_NOT_NATIVE`, `AGGREGATION_TOO_MANY_GROUPS`) |
|
|
148
183
|
| `Query` | Parsed query result: `{ type, filter, fields?, assignments?, aggregation?, orderBy?, limit?, continuationToken? }` |
|
|
149
184
|
| `OrderBy` | `{ field: string; direction: "ASC" \| "DESC" }` |
|
|
185
|
+
| `getCompletions(query, caret, opts)` | Returns grammar-driven code completion candidates at a caret offset |
|
|
186
|
+
| `fieldsFromSchema(schema, maxDepth?)` | Flattens a JSON schema into completion fields with dotted paths |
|
|
150
187
|
|
|
151
188
|
### See also
|
|
152
189
|
|
|
@@ -154,6 +191,7 @@ See [Statements](../../docs/pages/Modules/ql/Statements.md#aggregation-select--g
|
|
|
154
191
|
- [Operators](../../docs/pages/Modules/ql/Operators.md)
|
|
155
192
|
- [Parameters](../../docs/pages/Modules/ql/Parameters.md) — binding values safely
|
|
156
193
|
- [Statements](../../docs/pages/Modules/ql/Statements.md) — SELECT, DELETE, UPDATE and repository bulk operations
|
|
194
|
+
- [Code Completion](../../docs/pages/Modules/ql/Completion.md) — autocomplete and suggestions
|
|
157
195
|
- [Store Translators](../../docs/pages/Modules/ql/Translators.md) — how each Store backend converts WQL
|
|
158
196
|
|
|
159
197
|
<!-- README_FOOTER -->
|
package/lib/WebdaQLLexer.d.ts
CHANGED
|
@@ -46,15 +46,16 @@ export declare class WebdaQLLexer extends Lexer {
|
|
|
46
46
|
static readonly MIN = 41;
|
|
47
47
|
static readonly MAX = 42;
|
|
48
48
|
static readonly STAR = 43;
|
|
49
|
-
static readonly
|
|
50
|
-
static readonly
|
|
51
|
-
static readonly
|
|
52
|
-
static readonly
|
|
53
|
-
static readonly
|
|
54
|
-
static readonly
|
|
55
|
-
static readonly
|
|
56
|
-
static readonly
|
|
57
|
-
static readonly
|
|
49
|
+
static readonly NOW = 44;
|
|
50
|
+
static readonly DQUOTED_STRING_LITERAL = 45;
|
|
51
|
+
static readonly SQUOTED_STRING_LITERAL = 46;
|
|
52
|
+
static readonly INTEGER_LITERAL = 47;
|
|
53
|
+
static readonly NUMBER_LITERAL = 48;
|
|
54
|
+
static readonly POSITIONAL_PARAMETER = 49;
|
|
55
|
+
static readonly NAMED_PARAMETER = 50;
|
|
56
|
+
static readonly IDENTIFIER = 51;
|
|
57
|
+
static readonly IDENTIFIER_WITH_NUMBER = 52;
|
|
58
|
+
static readonly FUNCTION_IDENTIFIER_WITH_UNDERSCORE = 53;
|
|
58
59
|
static readonly channelNames: string[];
|
|
59
60
|
static readonly modeNames: string[];
|
|
60
61
|
static readonly ruleNames: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebdaQLLexer.d.ts","sourceRoot":"","sources":["../src/WebdaQLLexer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebdaQLLexer.d.ts","sourceRoot":"","sources":["../src/WebdaQLLexer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMpD,qBAAa,YAAa,SAAQ,KAAK;IACtC,gBAAuB,KAAK,KAAK;IACjC,gBAAuB,UAAU,KAAK;IACtC,gBAAuB,UAAU,KAAK;IACtC,gBAAuB,KAAK,KAAK;IACjC,gBAAuB,iBAAiB,KAAK;IAC7C,gBAAuB,iBAAiB,KAAK;IAC7C,gBAAuB,aAAa,KAAK;IACzC,gBAAuB,aAAa,KAAK;IACzC,gBAAuB,MAAM,KAAK;IAClC,gBAAuB,MAAM,MAAM;IACnC,gBAAuB,MAAM,MAAM;IACnC,gBAAuB,GAAG,MAAM;IAChC,gBAAuB,KAAK,MAAM;IAClC,gBAAuB,GAAG,MAAM;IAChC,gBAAuB,EAAE,MAAM;IAC/B,gBAAuB,KAAK,MAAM;IAClC,gBAAuB,SAAS,MAAM;IACtC,gBAAuB,OAAO,MAAM;IACpC,gBAAuB,gBAAgB,MAAM;IAC7C,gBAAuB,IAAI,MAAM;IACjC,gBAAuB,aAAa,MAAM;IAC1C,gBAAuB,IAAI,M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