rado 0.2.14 → 0.2.16
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/define/Column.d.ts +19 -17
- package/dist/define/Column.js +33 -33
- package/dist/define/Cursor.d.ts +16 -7
- package/dist/define/Cursor.js +83 -84
- package/dist/define/Expr.d.ts +41 -28
- package/dist/define/Expr.js +202 -152
- package/dist/define/Functions.js +1 -1
- package/dist/define/Ops.js +6 -6
- package/dist/define/Schema.js +1 -1
- package/dist/define/Selection.d.ts +4 -4
- package/dist/define/Table.d.ts +8 -6
- package/dist/define/Table.js +25 -12
- package/dist/lib/Driver.js +12 -12
- package/dist/lib/Formatter.js +2 -2
- package/package.json +2 -2
package/dist/define/Cursor.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
// src/define/Cursor.ts
|
|
2
9
|
import { Expr, ExprData } from "./Expr.js";
|
|
3
10
|
import { Functions } from "./Functions.js";
|
|
4
11
|
import { Query } from "./Query.js";
|
|
5
12
|
import { Schema } from "./Schema.js";
|
|
6
13
|
import { Selection } from "./Selection.js";
|
|
7
|
-
import {
|
|
14
|
+
import { Table, createTable } from "./Table.js";
|
|
8
15
|
import { Target } from "./Target.js";
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
16
|
+
var QUERY = Symbol("Cursor.Query");
|
|
17
|
+
var _Cursor = class {
|
|
18
|
+
[(Selection.CursorType, QUERY)];
|
|
13
19
|
constructor(query) {
|
|
14
|
-
|
|
15
|
-
enumerable: false,
|
|
16
|
-
value: () => query
|
|
17
|
-
});
|
|
20
|
+
this[QUERY] = query;
|
|
18
21
|
}
|
|
19
22
|
static all(strings, ...params) {
|
|
20
|
-
return new
|
|
21
|
-
}
|
|
22
|
-
query() {
|
|
23
|
-
throw new Error("Not implemented");
|
|
23
|
+
return new _Cursor(Query.Raw({ expectedReturn: "rows", strings, params }));
|
|
24
24
|
}
|
|
25
25
|
next(cursor) {
|
|
26
|
-
return new
|
|
26
|
+
return new _Cursor(
|
|
27
27
|
Query.Batch({
|
|
28
|
-
queries: [this
|
|
28
|
+
queries: [this[QUERY], cursor[QUERY]]
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
on(driver) {
|
|
33
|
-
return driver.executeQuery(this
|
|
33
|
+
return driver.executeQuery(this[QUERY]);
|
|
34
34
|
}
|
|
35
35
|
toSql(driver, options = { forceInline: true }) {
|
|
36
|
-
return driver.formatter.compile(this
|
|
36
|
+
return driver.formatter.compile(this[QUERY], options).sql;
|
|
37
37
|
}
|
|
38
38
|
toJSON() {
|
|
39
|
-
return this
|
|
39
|
+
return this[QUERY];
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
var Cursor = _Cursor;
|
|
43
|
+
__publicField(Cursor, "Query", QUERY);
|
|
42
44
|
function addWhere(query, where) {
|
|
43
45
|
const conditions = where.slice();
|
|
44
46
|
if (query.where)
|
|
45
47
|
conditions.push(new Expr(query.where));
|
|
46
48
|
return {
|
|
47
49
|
...query,
|
|
48
|
-
where: Expr.and(...conditions).
|
|
50
|
+
where: Expr.and(...conditions)[Expr.Data]
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
((Cursor2) => {
|
|
52
54
|
class Delete extends Cursor2 {
|
|
53
55
|
query() {
|
|
54
|
-
return super
|
|
56
|
+
return super[QUERY];
|
|
55
57
|
}
|
|
56
58
|
where(...where) {
|
|
57
|
-
return new Delete(addWhere(this
|
|
59
|
+
return new Delete(addWhere(this[QUERY], where));
|
|
58
60
|
}
|
|
59
61
|
take(limit) {
|
|
60
|
-
return new Delete({ ...this
|
|
62
|
+
return new Delete({ ...this[QUERY], limit });
|
|
61
63
|
}
|
|
62
64
|
skip(offset) {
|
|
63
|
-
return new Delete({ ...this
|
|
65
|
+
return new Delete({ ...this[QUERY], offset });
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
Cursor2.Delete = Delete;
|
|
67
|
-
class
|
|
68
|
-
query() {
|
|
69
|
-
return super.query();
|
|
70
|
-
}
|
|
69
|
+
const _Update = class extends Cursor2 {
|
|
71
70
|
set(set) {
|
|
72
|
-
return new
|
|
71
|
+
return new _Update({ ...this[QUERY], set });
|
|
73
72
|
}
|
|
74
73
|
where(...where) {
|
|
75
|
-
return new
|
|
74
|
+
return new _Update(addWhere(this[QUERY], where));
|
|
76
75
|
}
|
|
77
76
|
take(limit) {
|
|
78
|
-
return new
|
|
77
|
+
return new _Update({ ...this[QUERY], limit });
|
|
79
78
|
}
|
|
80
79
|
skip(offset) {
|
|
81
|
-
return new
|
|
80
|
+
return new _Update({ ...this[QUERY], offset });
|
|
82
81
|
}
|
|
83
|
-
}
|
|
82
|
+
};
|
|
83
|
+
let Update = _Update;
|
|
84
|
+
QUERY;
|
|
84
85
|
Cursor2.Update = Update;
|
|
85
86
|
class InsertValuesReturning extends Cursor2 {
|
|
86
87
|
}
|
|
87
88
|
Cursor2.InsertValuesReturning = InsertValuesReturning;
|
|
88
89
|
class Inserted extends Cursor2 {
|
|
89
|
-
query
|
|
90
|
-
|
|
90
|
+
constructor(query) {
|
|
91
|
+
super(query);
|
|
91
92
|
}
|
|
92
93
|
returning(selection) {
|
|
93
94
|
return new InsertValuesReturning(
|
|
94
|
-
Query.Insert({ ...this
|
|
95
|
+
Query.Insert({ ...this[QUERY], selection: ExprData.create(selection) })
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
QUERY;
|
|
98
100
|
Cursor2.Inserted = Inserted;
|
|
99
101
|
class Insert {
|
|
100
102
|
constructor(into) {
|
|
101
103
|
this.into = into;
|
|
102
104
|
}
|
|
103
105
|
selection(query) {
|
|
104
|
-
return new Inserted(
|
|
105
|
-
Query.Insert({ into: this.into, select: query.query() })
|
|
106
|
-
);
|
|
106
|
+
return new Inserted(Query.Insert({ into: this.into, select: query[QUERY] }));
|
|
107
107
|
}
|
|
108
108
|
values(...data) {
|
|
109
109
|
return new Inserted(Query.Insert({ into: this.into, data }));
|
|
@@ -111,9 +111,9 @@ function addWhere(query, where) {
|
|
|
111
111
|
}
|
|
112
112
|
Cursor2.Insert = Insert;
|
|
113
113
|
class CreateTable extends Cursor2 {
|
|
114
|
-
constructor(
|
|
115
|
-
super(Schema.create(
|
|
116
|
-
this.table =
|
|
114
|
+
constructor(table) {
|
|
115
|
+
super(Schema.create(table));
|
|
116
|
+
this.table = table;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
Cursor2.CreateTable = CreateTable;
|
|
@@ -122,21 +122,19 @@ function addWhere(query, where) {
|
|
|
122
122
|
super(Query.Batch({ queries }));
|
|
123
123
|
this.queries = queries;
|
|
124
124
|
}
|
|
125
|
-
query() {
|
|
126
|
-
return super.query();
|
|
127
|
-
}
|
|
128
125
|
next(cursor) {
|
|
129
126
|
return new Cursor2(
|
|
130
127
|
Query.Batch({
|
|
131
|
-
queries: [...this.
|
|
128
|
+
queries: [...this[QUERY].queries, cursor[QUERY]]
|
|
132
129
|
})
|
|
133
130
|
);
|
|
134
131
|
}
|
|
135
132
|
}
|
|
133
|
+
QUERY;
|
|
136
134
|
Cursor2.Batch = Batch;
|
|
137
135
|
function joinTarget(joinType, query, to, on) {
|
|
138
|
-
const toQuery = to instanceof Cursor2 ? to
|
|
139
|
-
const target = toQuery ? toQuery.from : Target.Table(to[
|
|
136
|
+
const toQuery = to instanceof Cursor2 ? to[QUERY] : void 0;
|
|
137
|
+
const target = toQuery ? toQuery.from : Target.Table(to[Table.Data]);
|
|
140
138
|
if (!query.from || !target)
|
|
141
139
|
throw new Error("No from clause");
|
|
142
140
|
const conditions = [...on];
|
|
@@ -149,22 +147,22 @@ function addWhere(query, where) {
|
|
|
149
147
|
query.from,
|
|
150
148
|
target,
|
|
151
149
|
joinType,
|
|
152
|
-
Expr.and(...conditions).
|
|
150
|
+
Expr.and(...conditions)[Expr.Data]
|
|
153
151
|
);
|
|
154
152
|
}
|
|
155
153
|
class SelectMultiple extends Cursor2 {
|
|
156
|
-
query
|
|
157
|
-
|
|
154
|
+
constructor(query) {
|
|
155
|
+
super(query);
|
|
158
156
|
}
|
|
159
157
|
leftJoin(that, ...on) {
|
|
160
|
-
const query = this
|
|
158
|
+
const query = this[QUERY];
|
|
161
159
|
return new SelectMultiple({
|
|
162
160
|
...query,
|
|
163
161
|
from: joinTarget("left", query, that, on)
|
|
164
162
|
});
|
|
165
163
|
}
|
|
166
164
|
innerJoin(that, ...on) {
|
|
167
|
-
const query = this
|
|
165
|
+
const query = this[QUERY];
|
|
168
166
|
return new SelectMultiple({
|
|
169
167
|
...query,
|
|
170
168
|
from: joinTarget("inner", query, that, on)
|
|
@@ -172,20 +170,20 @@ function addWhere(query, where) {
|
|
|
172
170
|
}
|
|
173
171
|
select(selection) {
|
|
174
172
|
return new SelectMultiple({
|
|
175
|
-
...this
|
|
173
|
+
...this[QUERY],
|
|
176
174
|
selection: ExprData.create(selection)
|
|
177
175
|
});
|
|
178
176
|
}
|
|
179
177
|
count() {
|
|
180
178
|
return new SelectSingle({
|
|
181
|
-
...this
|
|
182
|
-
selection: Functions.count().
|
|
179
|
+
...this[QUERY],
|
|
180
|
+
selection: Functions.count()[Expr.Data],
|
|
183
181
|
singleResult: true
|
|
184
182
|
});
|
|
185
183
|
}
|
|
186
184
|
orderBy(...orderBy) {
|
|
187
185
|
return new SelectMultiple({
|
|
188
|
-
...this
|
|
186
|
+
...this[QUERY],
|
|
189
187
|
orderBy: orderBy.map((e) => {
|
|
190
188
|
return Expr.isExpr(e) ? e.asc() : e;
|
|
191
189
|
})
|
|
@@ -193,45 +191,45 @@ function addWhere(query, where) {
|
|
|
193
191
|
}
|
|
194
192
|
groupBy(...groupBy) {
|
|
195
193
|
return new SelectMultiple({
|
|
196
|
-
...this
|
|
194
|
+
...this[QUERY],
|
|
197
195
|
groupBy: groupBy.map(ExprData.create)
|
|
198
196
|
});
|
|
199
197
|
}
|
|
200
198
|
first() {
|
|
201
|
-
return new SelectSingle({ ...this
|
|
199
|
+
return new SelectSingle({ ...this[QUERY], singleResult: true });
|
|
202
200
|
}
|
|
203
201
|
sure() {
|
|
204
202
|
return new SelectSingle({
|
|
205
|
-
...this
|
|
203
|
+
...this[QUERY],
|
|
206
204
|
singleResult: true,
|
|
207
205
|
validate: true
|
|
208
206
|
});
|
|
209
207
|
}
|
|
210
208
|
where(...where) {
|
|
211
|
-
return new SelectMultiple(addWhere(this
|
|
209
|
+
return new SelectMultiple(addWhere(this[QUERY], where));
|
|
212
210
|
}
|
|
213
211
|
take(limit) {
|
|
214
|
-
return new SelectMultiple({ ...this
|
|
212
|
+
return new SelectMultiple({ ...this[QUERY], limit });
|
|
215
213
|
}
|
|
216
214
|
skip(offset) {
|
|
217
|
-
return new SelectMultiple({ ...this
|
|
215
|
+
return new SelectMultiple({ ...this[QUERY], offset });
|
|
218
216
|
}
|
|
219
|
-
[Expr.
|
|
220
|
-
return new Expr(ExprData.Query(this
|
|
217
|
+
[(QUERY, Expr.ToExpr)]() {
|
|
218
|
+
return new Expr(ExprData.Query(this[QUERY]));
|
|
221
219
|
}
|
|
222
220
|
}
|
|
223
221
|
Cursor2.SelectMultiple = SelectMultiple;
|
|
224
222
|
class TableSelect extends SelectMultiple {
|
|
225
|
-
constructor(
|
|
226
|
-
const target = Target.Table(
|
|
223
|
+
constructor(table, conditions = []) {
|
|
224
|
+
const target = Target.Table(table);
|
|
227
225
|
super(
|
|
228
226
|
Query.Select({
|
|
229
227
|
from: target,
|
|
230
228
|
selection: ExprData.Row(target),
|
|
231
|
-
where: Expr.and(...conditions).
|
|
229
|
+
where: Expr.and(...conditions)[Expr.Data]
|
|
232
230
|
})
|
|
233
231
|
);
|
|
234
|
-
this.table =
|
|
232
|
+
this.table = table;
|
|
235
233
|
}
|
|
236
234
|
as(alias) {
|
|
237
235
|
return createTable({ ...this.table, alias });
|
|
@@ -241,7 +239,7 @@ function addWhere(query, where) {
|
|
|
241
239
|
}
|
|
242
240
|
insertSelect(query) {
|
|
243
241
|
return new Cursor2.Inserted(
|
|
244
|
-
Query.Insert({ into: this.table, select: query
|
|
242
|
+
Query.Insert({ into: this.table, select: query[QUERY] })
|
|
245
243
|
);
|
|
246
244
|
}
|
|
247
245
|
insertOne(record) {
|
|
@@ -261,7 +259,7 @@ function addWhere(query, where) {
|
|
|
261
259
|
return new Cursor2.Update(
|
|
262
260
|
Query.Update({
|
|
263
261
|
table: this.table,
|
|
264
|
-
where: this.
|
|
262
|
+
where: this[QUERY].where
|
|
265
263
|
})
|
|
266
264
|
).set(data);
|
|
267
265
|
}
|
|
@@ -269,7 +267,7 @@ function addWhere(query, where) {
|
|
|
269
267
|
return new Cursor2.Delete(
|
|
270
268
|
Query.Delete({
|
|
271
269
|
table: this.table,
|
|
272
|
-
where: this.
|
|
270
|
+
where: this[QUERY].where
|
|
273
271
|
})
|
|
274
272
|
);
|
|
275
273
|
}
|
|
@@ -279,20 +277,21 @@ function addWhere(query, where) {
|
|
|
279
277
|
);
|
|
280
278
|
}
|
|
281
279
|
}
|
|
280
|
+
QUERY;
|
|
282
281
|
Cursor2.TableSelect = TableSelect;
|
|
283
282
|
class SelectSingle extends Cursor2 {
|
|
284
|
-
query
|
|
285
|
-
|
|
283
|
+
constructor(query) {
|
|
284
|
+
super(query);
|
|
286
285
|
}
|
|
287
286
|
leftJoin(that, ...on) {
|
|
288
|
-
const query = this
|
|
287
|
+
const query = this[QUERY];
|
|
289
288
|
return new SelectSingle({
|
|
290
289
|
...query,
|
|
291
290
|
from: joinTarget("left", query, that, on)
|
|
292
291
|
});
|
|
293
292
|
}
|
|
294
293
|
innerJoin(that, ...on) {
|
|
295
|
-
const query = this
|
|
294
|
+
const query = this[QUERY];
|
|
296
295
|
return new SelectSingle({
|
|
297
296
|
...query,
|
|
298
297
|
from: joinTarget("inner", query, that, on)
|
|
@@ -300,36 +299,36 @@ function addWhere(query, where) {
|
|
|
300
299
|
}
|
|
301
300
|
select(selection) {
|
|
302
301
|
return new SelectSingle({
|
|
303
|
-
...this
|
|
302
|
+
...this[QUERY],
|
|
304
303
|
selection: ExprData.create(selection)
|
|
305
304
|
});
|
|
306
305
|
}
|
|
307
306
|
orderBy(...orderBy) {
|
|
308
307
|
return new SelectSingle({
|
|
309
|
-
...this
|
|
308
|
+
...this[QUERY],
|
|
310
309
|
orderBy
|
|
311
310
|
});
|
|
312
311
|
}
|
|
313
312
|
groupBy(...groupBy) {
|
|
314
313
|
return new SelectSingle({
|
|
315
|
-
...this
|
|
314
|
+
...this[QUERY],
|
|
316
315
|
groupBy: groupBy.map(ExprData.create)
|
|
317
316
|
});
|
|
318
317
|
}
|
|
319
318
|
where(...where) {
|
|
320
|
-
return new SelectSingle(addWhere(this
|
|
319
|
+
return new SelectSingle(addWhere(this[QUERY], where));
|
|
321
320
|
}
|
|
322
321
|
take(limit) {
|
|
323
|
-
return new SelectSingle({ ...this
|
|
322
|
+
return new SelectSingle({ ...this[QUERY], limit });
|
|
324
323
|
}
|
|
325
324
|
skip(offset) {
|
|
326
|
-
return new SelectSingle({ ...this
|
|
325
|
+
return new SelectSingle({ ...this[QUERY], offset });
|
|
327
326
|
}
|
|
328
327
|
all() {
|
|
329
|
-
return new SelectMultiple({ ...this
|
|
328
|
+
return new SelectMultiple({ ...this[QUERY], singleResult: false });
|
|
330
329
|
}
|
|
331
|
-
[Expr.
|
|
332
|
-
return new Expr(ExprData.Query(this
|
|
330
|
+
[(QUERY, Expr.ToExpr)]() {
|
|
331
|
+
return new Expr(ExprData.Query(this[QUERY]));
|
|
333
332
|
}
|
|
334
333
|
}
|
|
335
334
|
Cursor2.SelectSingle = SelectSingle;
|
package/dist/define/Expr.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ import { ParamData } from './Param';
|
|
|
5
5
|
import { Query } from './Query';
|
|
6
6
|
import { Selection } from './Selection';
|
|
7
7
|
import { Target } from './Target';
|
|
8
|
+
declare const TO_EXPR: unique symbol;
|
|
9
|
+
declare const IS_EXPR: unique symbol;
|
|
10
|
+
declare const DATA: unique symbol;
|
|
8
11
|
export declare enum UnOpType {
|
|
9
12
|
Not = "Not",
|
|
10
13
|
IsNull = "IsNull"
|
|
@@ -109,41 +112,38 @@ export declare namespace ExprData {
|
|
|
109
112
|
defaultCase?: ExprData;
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
|
-
export declare
|
|
113
|
-
UnOp(op: UnOpType, expr: ExprData): ExprData;
|
|
114
|
-
BinOp(op: BinOpType, a: ExprData, b: ExprData): ExprData;
|
|
115
|
-
Field(expr: ExprData, field: string): ExprData;
|
|
116
|
-
Param(param: ParamData): ExprData;
|
|
117
|
-
Call(method: string, params: Array<ExprData>): ExprData;
|
|
118
|
-
Query(query: Query.Select): ExprData;
|
|
119
|
-
Record(fields:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
export declare namespace ExprData {
|
|
116
|
+
function UnOp(op: UnOpType, expr: ExprData): ExprData;
|
|
117
|
+
function BinOp(op: BinOpType, a: ExprData, b: ExprData): ExprData;
|
|
118
|
+
function Field(expr: ExprData, field: string): ExprData;
|
|
119
|
+
function Param(param: ParamData): ExprData;
|
|
120
|
+
function Call(method: string, params: Array<ExprData>): ExprData;
|
|
121
|
+
function Query(query: Query.Select): ExprData;
|
|
122
|
+
function Record(fields: {
|
|
123
|
+
[key: string]: ExprData;
|
|
124
|
+
}): ExprData;
|
|
125
|
+
function Merge(a: ExprData, b: ExprData): ExprData;
|
|
126
|
+
function Row(target: Target): ExprData;
|
|
127
|
+
function Map(target: Target, result: ExprData): ExprData;
|
|
128
|
+
function Filter(target: Target, condition: ExprData): ExprData;
|
|
129
|
+
function Case(expr: ExprData, cases: {
|
|
130
|
+
[key: string]: ExprData;
|
|
131
|
+
}, defaultCase?: ExprData): ExprData;
|
|
132
|
+
function create(input: any): ExprData;
|
|
133
|
+
}
|
|
127
134
|
/** Expression or value of type T */
|
|
128
135
|
export type EV<T> = Expr<T> | T;
|
|
129
|
-
declare const isExpr: unique symbol;
|
|
130
136
|
export declare class Expr<T> {
|
|
131
|
-
expr: ExprData;
|
|
132
|
-
static NULL: Expr<null>;
|
|
133
|
-
static toExpr: symbol;
|
|
134
|
-
static value<T>(value: T): Expr<T>;
|
|
135
|
-
static create<T>(input: EV<T>): Expr<T>;
|
|
136
|
-
static and(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
137
|
-
static or(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
138
|
-
static isExpr<T>(input: any): input is Expr<T>;
|
|
139
137
|
constructor(expr: ExprData);
|
|
140
|
-
[
|
|
138
|
+
[DATA]: ExprData;
|
|
139
|
+
[IS_EXPR]: boolean;
|
|
141
140
|
asc(): OrderBy;
|
|
142
141
|
desc(): OrderBy;
|
|
143
142
|
not(): Expr<boolean>;
|
|
144
143
|
or(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
|
|
145
144
|
and(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
|
|
146
145
|
is(that: EV<T> | Cursor.SelectSingle<T>): Expr<boolean>;
|
|
146
|
+
isConstant(value: T): boolean;
|
|
147
147
|
isNot(that: EV<T>): Expr<boolean>;
|
|
148
148
|
isNull(): Expr<boolean>;
|
|
149
149
|
isNotNull(): Expr<boolean>;
|
|
@@ -163,6 +163,13 @@ export declare class Expr<T> {
|
|
|
163
163
|
glob(this: Expr<string>, that: EV<string>): Expr<boolean>;
|
|
164
164
|
match(this: Expr<string>, that: EV<string>): Expr<boolean>;
|
|
165
165
|
with<X extends Selection>(that: X): Selection.With<T, X>;
|
|
166
|
+
/**
|
|
167
|
+
* Dynamic expressions allow accessing runtime fields of JSON properties
|
|
168
|
+
* through a Proxy.
|
|
169
|
+
*
|
|
170
|
+
* Expr.value({a: {b: 1}}).dynamic().a.b.is(1) // true
|
|
171
|
+
**/
|
|
172
|
+
dynamic<X = T>(...path: Array<string>): Fields<X>;
|
|
166
173
|
at<T>(this: Expr<Array<T>>, index: number): Expr<T | null>;
|
|
167
174
|
includes<T>(this: Expr<Array<T>>, value: EV<T>): Expr<boolean>;
|
|
168
175
|
filter<T>(this: Expr<Array<T>>, fn: (cursor: Fields<T>) => Expr<boolean>): Expr<Array<T>>;
|
|
@@ -171,8 +178,14 @@ export declare class Expr<T> {
|
|
|
171
178
|
get<T>(name: string): Expr<T>;
|
|
172
179
|
}
|
|
173
180
|
export declare namespace Expr {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
181
|
+
const NULL: Expr<null>;
|
|
182
|
+
const Data: typeof DATA;
|
|
183
|
+
const IsExpr: typeof IS_EXPR;
|
|
184
|
+
const ToExpr: typeof TO_EXPR;
|
|
185
|
+
function value<T>(value: T): Expr<T>;
|
|
186
|
+
function create<T>(input: EV<T>): Expr<T>;
|
|
187
|
+
function and(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
188
|
+
function or(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
|
189
|
+
function isExpr<T>(input: any): input is Expr<T>;
|
|
177
190
|
}
|
|
178
191
|
export {};
|