rado 0.2.20 → 0.2.22
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 +4 -3
- package/dist/define/Column.js +12 -17
- package/dist/define/Expr.d.ts +64 -79
- package/dist/define/Expr.js +117 -76
- package/dist/define/Functions.js +1 -1
- package/dist/define/Ops.d.ts +7 -7
- package/dist/define/Ops.js +11 -12
- package/dist/define/Param.d.ts +15 -13
- package/dist/define/Param.js +18 -9
- package/dist/define/Query.d.ts +150 -50
- package/dist/define/Query.js +400 -53
- package/dist/define/Schema.d.ts +5 -4
- package/dist/define/Schema.js +40 -28
- package/dist/define/Selection.d.ts +2 -2
- package/dist/define/Sql.d.ts +6 -0
- package/dist/define/Sql.js +22 -0
- package/dist/define/Table.d.ts +6 -5
- package/dist/define/Table.js +60 -94
- package/dist/define/Target.d.ts +21 -21
- package/dist/define/Target.js +31 -14
- package/dist/driver/bun-sqlite.js +3 -4
- package/dist/driver/sqlite3.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/Driver.d.ts +25 -26
- package/dist/lib/Driver.js +54 -36
- package/dist/lib/Formatter.d.ts +32 -21
- package/dist/lib/Formatter.js +229 -196
- package/dist/lib/Statement.js +1 -1
- package/dist/sqlite/SqliteFormatter.d.ts +1 -1
- package/dist/sqlite/SqliteFormatter.js +15 -19
- package/dist/sqlite/SqliteFunctions.d.ts +3 -3
- package/dist/sqlite/SqliteSchema.d.ts +3 -3
- package/dist/sqlite/SqliteSchema.js +3 -3
- package/dist/util/Callable.d.ts +3 -1
- package/dist/util/Callable.js +7 -12
- package/package.json +4 -4
- package/dist/define/Cursor.d.ts +0 -108
- package/dist/define/Cursor.js +0 -338
package/dist/define/Column.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Callable } from '../util/Callable';
|
|
1
2
|
import { EV, Expr, ExprData } from './Expr';
|
|
2
3
|
import { Fields } from './Fields';
|
|
3
4
|
declare const DATA: unique symbol;
|
|
@@ -38,7 +39,7 @@ export declare namespace Column {
|
|
|
38
39
|
interface ValueColumn<T> extends Expr<T> {
|
|
39
40
|
<X extends T = T>(): ValueColumn<T extends null ? X | null : X>;
|
|
40
41
|
}
|
|
41
|
-
declare class ValueColumn<T> implements Column<T> {
|
|
42
|
+
declare class ValueColumn<T> extends Callable implements Column<T> {
|
|
42
43
|
[TYPE]: T;
|
|
43
44
|
[DATA]: PartialColumnData;
|
|
44
45
|
constructor(data: PartialColumnData);
|
|
@@ -58,7 +59,7 @@ export declare class PrimaryColumn<T, K> extends ValueColumn<PrimaryKey<T, K>> {
|
|
|
58
59
|
interface ObjectColumn<T> {
|
|
59
60
|
<X extends T = T>(): Column<T extends null ? X | null : X> & Fields<X>;
|
|
60
61
|
}
|
|
61
|
-
declare class ObjectColumn<T> implements Column<T> {
|
|
62
|
+
declare class ObjectColumn<T> extends Callable implements Column<T> {
|
|
62
63
|
[TYPE]: T;
|
|
63
64
|
[DATA]: PartialColumnData;
|
|
64
65
|
constructor(data: PartialColumnData);
|
|
@@ -76,7 +77,7 @@ type DefaultValue<T> = EV<T> | (() => EV<T>);
|
|
|
76
77
|
interface UnTyped {
|
|
77
78
|
(name: string): UnTyped;
|
|
78
79
|
}
|
|
79
|
-
declare class UnTyped {
|
|
80
|
+
declare class UnTyped extends Callable {
|
|
80
81
|
[DATA]: PartialColumnData;
|
|
81
82
|
constructor(data?: PartialColumnData);
|
|
82
83
|
get nullable(): NullableUnTyped;
|
package/dist/define/Column.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/define/Column.ts
|
|
2
|
-
import {
|
|
2
|
+
import { Callable } from "../util/Callable.js";
|
|
3
3
|
import { Expr, ExprData } from "./Expr.js";
|
|
4
|
-
var DATA = Symbol("
|
|
5
|
-
var TYPE = Symbol("
|
|
4
|
+
var DATA = Symbol("Column.Data");
|
|
5
|
+
var TYPE = Symbol("Column.Type");
|
|
6
6
|
var ColumnType = /* @__PURE__ */ ((ColumnType2) => {
|
|
7
7
|
ColumnType2["String"] = "String";
|
|
8
8
|
ColumnType2["Integer"] = "Integer";
|
|
@@ -16,16 +16,11 @@ var Column;
|
|
|
16
16
|
Column2.Data = DATA;
|
|
17
17
|
Column2.Type = TYPE;
|
|
18
18
|
})(Column || (Column = {}));
|
|
19
|
-
var ValueColumn = class {
|
|
20
|
-
[
|
|
19
|
+
var ValueColumn = class extends Callable {
|
|
20
|
+
[DATA];
|
|
21
21
|
constructor(data) {
|
|
22
|
+
super(() => this);
|
|
22
23
|
this[DATA] = data;
|
|
23
|
-
return callable(this, (defaultValue) => {
|
|
24
|
-
return new ValueColumn({
|
|
25
|
-
...this[DATA],
|
|
26
|
-
defaultValue: createDefaultValue(defaultValue)
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
24
|
}
|
|
30
25
|
get nullable() {
|
|
31
26
|
return new ValueColumn({ ...this[DATA], nullable: true });
|
|
@@ -67,11 +62,11 @@ var OptionalColumn = class extends ValueColumn {
|
|
|
67
62
|
var PrimaryColumn = class extends ValueColumn {
|
|
68
63
|
[Column.IsPrimary];
|
|
69
64
|
};
|
|
70
|
-
var ObjectColumn = class {
|
|
71
|
-
[
|
|
65
|
+
var ObjectColumn = class extends Callable {
|
|
66
|
+
[DATA];
|
|
72
67
|
constructor(data) {
|
|
68
|
+
super(() => this);
|
|
73
69
|
this[DATA] = data;
|
|
74
|
-
return callable(this, () => this);
|
|
75
70
|
}
|
|
76
71
|
get nullable() {
|
|
77
72
|
return new ObjectColumn({ ...this[DATA], nullable: true });
|
|
@@ -89,13 +84,13 @@ var ObjectColumn = class {
|
|
|
89
84
|
var OptionalObjectColumn = class extends ObjectColumn {
|
|
90
85
|
[Column.IsOptional];
|
|
91
86
|
};
|
|
92
|
-
var UnTyped = class {
|
|
87
|
+
var UnTyped = class extends Callable {
|
|
93
88
|
[DATA];
|
|
94
89
|
constructor(data = {}) {
|
|
95
|
-
|
|
96
|
-
return callable(this, (name) => {
|
|
90
|
+
super((name) => {
|
|
97
91
|
return new ValueColumn({ ...data, name });
|
|
98
92
|
});
|
|
93
|
+
this[DATA] = data;
|
|
99
94
|
}
|
|
100
95
|
get nullable() {
|
|
101
96
|
return new UnTyped({ ...this[DATA], nullable: true });
|
package/dist/define/Expr.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Cursor } from './Cursor';
|
|
2
1
|
import { Fields } from './Fields';
|
|
3
2
|
import { OrderBy } from './OrderBy';
|
|
4
3
|
import { ParamData } from './Param';
|
|
5
|
-
import { Query } from './Query';
|
|
4
|
+
import { Query, QueryData } from './Query';
|
|
6
5
|
import { Selection } from './Selection';
|
|
7
6
|
import { Target } from './Target';
|
|
7
|
+
declare const DATA: unique symbol;
|
|
8
8
|
declare const TO_EXPR: unique symbol;
|
|
9
9
|
declare const IS_EXPR: unique symbol;
|
|
10
|
-
declare const DATA: unique symbol;
|
|
11
10
|
export declare enum UnOpType {
|
|
12
11
|
Not = "Not",
|
|
13
12
|
IsNull = "IsNull"
|
|
@@ -34,101 +33,87 @@ export declare enum BinOpType {
|
|
|
34
33
|
Concat = "Concat"
|
|
35
34
|
}
|
|
36
35
|
export declare enum ExprType {
|
|
37
|
-
UnOp = "UnOp",
|
|
38
|
-
BinOp = "BinOp",
|
|
39
|
-
Field = "Field",
|
|
40
|
-
Param = "Param",
|
|
41
|
-
Call = "Call",
|
|
42
|
-
Query = "Query",
|
|
43
|
-
Record = "Record",
|
|
44
|
-
Row = "Row",
|
|
45
|
-
Map = "Map",
|
|
46
|
-
Filter = "Filter",
|
|
47
|
-
Merge = "Merge"
|
|
48
|
-
Case = "Case"
|
|
36
|
+
UnOp = "ExprData.UnOp",
|
|
37
|
+
BinOp = "ExprData.BinOp",
|
|
38
|
+
Field = "ExprData.Field",
|
|
39
|
+
Param = "ExprData.Param",
|
|
40
|
+
Call = "ExprData.Call",
|
|
41
|
+
Query = "ExprData.Query",
|
|
42
|
+
Record = "ExprData.Record",
|
|
43
|
+
Row = "ExprData.Row",
|
|
44
|
+
Map = "ExprData.Map",
|
|
45
|
+
Filter = "ExprData.Filter",
|
|
46
|
+
Merge = "ExprData.Merge"
|
|
49
47
|
}
|
|
50
|
-
export type ExprData = ExprData.UnOp | ExprData.BinOp | ExprData.Field | ExprData.Param | ExprData.Call | ExprData.Query | ExprData.Record | ExprData.Merge | ExprData.Row | ExprData.Map | ExprData.Filter
|
|
48
|
+
export type ExprData = ExprData.UnOp | ExprData.BinOp | ExprData.Field | ExprData.Param | ExprData.Call | ExprData.Query | ExprData.Record | ExprData.Merge | ExprData.Row | ExprData.Map | ExprData.Filter;
|
|
51
49
|
export declare namespace ExprData {
|
|
52
|
-
|
|
53
|
-
type: ExprType.UnOp;
|
|
50
|
+
class UnOp {
|
|
54
51
|
op: UnOpType;
|
|
55
52
|
expr: ExprData;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
type: ExprType.UnOp;
|
|
54
|
+
constructor(op: UnOpType, expr: ExprData);
|
|
55
|
+
}
|
|
56
|
+
class BinOp {
|
|
59
57
|
op: BinOpType;
|
|
60
58
|
a: ExprData;
|
|
61
59
|
b: ExprData;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
type: ExprType.BinOp;
|
|
61
|
+
constructor(op: BinOpType, a: ExprData, b: ExprData);
|
|
62
|
+
}
|
|
63
|
+
class Field {
|
|
65
64
|
expr: ExprData;
|
|
66
65
|
field: string;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
type: ExprType.Field;
|
|
67
|
+
constructor(expr: ExprData, field: string);
|
|
68
|
+
}
|
|
69
|
+
class Param {
|
|
70
70
|
param: ParamData;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
type: ExprType.Param;
|
|
72
|
+
constructor(param: ParamData);
|
|
73
|
+
}
|
|
74
|
+
class Call {
|
|
74
75
|
method: string;
|
|
75
76
|
params: Array<ExprData>;
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
type: ExprType.Call;
|
|
78
|
+
constructor(method: string, params: Array<ExprData>);
|
|
79
|
+
}
|
|
80
|
+
class Query {
|
|
81
|
+
query: QueryData.Select;
|
|
78
82
|
type: ExprType.Query;
|
|
79
|
-
query:
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
type: ExprType.Record;
|
|
83
|
+
constructor(query: QueryData.Select);
|
|
84
|
+
}
|
|
85
|
+
class Record {
|
|
83
86
|
fields: {
|
|
84
87
|
[key: string]: ExprData;
|
|
85
88
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
type: ExprType.Record;
|
|
90
|
+
constructor(fields: {
|
|
91
|
+
[key: string]: ExprData;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
class Merge {
|
|
89
95
|
a: ExprData;
|
|
90
96
|
b: ExprData;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
type: ExprType.Merge;
|
|
98
|
+
constructor(a: ExprData, b: ExprData);
|
|
99
|
+
}
|
|
100
|
+
class Row {
|
|
94
101
|
target: Target;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
type: ExprType.Row;
|
|
103
|
+
constructor(target: Target);
|
|
104
|
+
}
|
|
105
|
+
class Map {
|
|
98
106
|
target: Target;
|
|
99
107
|
result: ExprData;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
type: ExprType.Map;
|
|
109
|
+
constructor(target: Target, result: ExprData);
|
|
110
|
+
}
|
|
111
|
+
class Filter {
|
|
103
112
|
target: Target;
|
|
104
113
|
condition: ExprData;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
expr: ExprData;
|
|
109
|
-
cases: {
|
|
110
|
-
[key: string]: ExprData;
|
|
111
|
-
};
|
|
112
|
-
defaultCase?: ExprData;
|
|
113
|
-
};
|
|
114
|
-
}
|
|
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;
|
|
114
|
+
type: ExprType.Filter;
|
|
115
|
+
constructor(target: Target, condition: ExprData);
|
|
116
|
+
}
|
|
132
117
|
function create(input: any): ExprData;
|
|
133
118
|
}
|
|
134
119
|
/** Expression or value of type T */
|
|
@@ -142,13 +127,13 @@ export declare class Expr<T> {
|
|
|
142
127
|
not(): Expr<boolean>;
|
|
143
128
|
or(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
|
|
144
129
|
and(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
|
|
145
|
-
is(that: EV<T> |
|
|
130
|
+
is(that: EV<T> | Query.SelectSingle<T>): Expr<boolean>;
|
|
146
131
|
isConstant(value: T): boolean;
|
|
147
132
|
isNot(that: EV<T>): Expr<boolean>;
|
|
148
133
|
isNull(): Expr<boolean>;
|
|
149
134
|
isNotNull(): Expr<boolean>;
|
|
150
|
-
isIn(that: EV<Array<T>> |
|
|
151
|
-
isNotIn(that: EV<Array<T>> |
|
|
135
|
+
isIn(that: EV<Array<T>> | Query.SelectMultiple<T>): Expr<boolean>;
|
|
136
|
+
isNotIn(that: EV<Array<T>> | Query.SelectMultiple<T>): Expr<boolean>;
|
|
152
137
|
isGreater(that: EV<any>): Expr<boolean>;
|
|
153
138
|
isGreaterOrEqual(that: EV<any>): Expr<boolean>;
|
|
154
139
|
isLess(that: EV<any>): Expr<boolean>;
|
|
@@ -178,10 +163,10 @@ export declare class Expr<T> {
|
|
|
178
163
|
get<T>(name: string): Expr<T>;
|
|
179
164
|
}
|
|
180
165
|
export declare namespace Expr {
|
|
181
|
-
const NULL: Expr<null>;
|
|
182
166
|
const Data: typeof DATA;
|
|
183
167
|
const IsExpr: typeof IS_EXPR;
|
|
184
168
|
const ToExpr: typeof TO_EXPR;
|
|
169
|
+
const NULL: Expr<null>;
|
|
185
170
|
function value<T>(value: T): Expr<T>;
|
|
186
171
|
function create<T>(input: EV<T>): Expr<T>;
|
|
187
172
|
function and(...conditions: Array<EV<boolean>>): Expr<boolean>;
|
package/dist/define/Expr.js
CHANGED
|
@@ -3,9 +3,9 @@ import { OrderDirection } from "./OrderBy.js";
|
|
|
3
3
|
import { ParamData, ParamType } from "./Param.js";
|
|
4
4
|
import { Target } from "./Target.js";
|
|
5
5
|
var { fromEntries, entries } = Object;
|
|
6
|
+
var DATA = Symbol("Expr.Data");
|
|
6
7
|
var TO_EXPR = Symbol("Expr.ToExpr");
|
|
7
8
|
var IS_EXPR = Symbol("Expr.IsExpr");
|
|
8
|
-
var DATA = Symbol("Expr.Data");
|
|
9
9
|
var UnOpType = /* @__PURE__ */ ((UnOpType2) => {
|
|
10
10
|
UnOpType2["Not"] = "Not";
|
|
11
11
|
UnOpType2["IsNull"] = "IsNull";
|
|
@@ -34,84 +34,120 @@ var BinOpType = /* @__PURE__ */ ((BinOpType2) => {
|
|
|
34
34
|
return BinOpType2;
|
|
35
35
|
})(BinOpType || {});
|
|
36
36
|
var ExprType = /* @__PURE__ */ ((ExprType2) => {
|
|
37
|
-
ExprType2["UnOp"] = "UnOp";
|
|
38
|
-
ExprType2["BinOp"] = "BinOp";
|
|
39
|
-
ExprType2["Field"] = "Field";
|
|
40
|
-
ExprType2["Param"] = "Param";
|
|
41
|
-
ExprType2["Call"] = "Call";
|
|
42
|
-
ExprType2["Query"] = "Query";
|
|
43
|
-
ExprType2["Record"] = "Record";
|
|
44
|
-
ExprType2["Row"] = "Row";
|
|
45
|
-
ExprType2["Map"] = "Map";
|
|
46
|
-
ExprType2["Filter"] = "Filter";
|
|
47
|
-
ExprType2["Merge"] = "Merge";
|
|
48
|
-
ExprType2["Case"] = "Case";
|
|
37
|
+
ExprType2["UnOp"] = "ExprData.UnOp";
|
|
38
|
+
ExprType2["BinOp"] = "ExprData.BinOp";
|
|
39
|
+
ExprType2["Field"] = "ExprData.Field";
|
|
40
|
+
ExprType2["Param"] = "ExprData.Param";
|
|
41
|
+
ExprType2["Call"] = "ExprData.Call";
|
|
42
|
+
ExprType2["Query"] = "ExprData.Query";
|
|
43
|
+
ExprType2["Record"] = "ExprData.Record";
|
|
44
|
+
ExprType2["Row"] = "ExprData.Row";
|
|
45
|
+
ExprType2["Map"] = "ExprData.Map";
|
|
46
|
+
ExprType2["Filter"] = "ExprData.Filter";
|
|
47
|
+
ExprType2["Merge"] = "ExprData.Merge";
|
|
49
48
|
return ExprType2;
|
|
50
49
|
})(ExprType || {});
|
|
51
50
|
var ExprData;
|
|
52
51
|
((ExprData2) => {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
class UnOp {
|
|
53
|
+
constructor(op, expr) {
|
|
54
|
+
this.op = op;
|
|
55
|
+
this.expr = expr;
|
|
56
|
+
}
|
|
57
|
+
type = "ExprData.UnOp" /* UnOp */;
|
|
55
58
|
}
|
|
56
59
|
ExprData2.UnOp = UnOp;
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
class BinOp {
|
|
61
|
+
constructor(op, a, b) {
|
|
62
|
+
this.op = op;
|
|
63
|
+
this.a = a;
|
|
64
|
+
this.b = b;
|
|
65
|
+
}
|
|
66
|
+
type = "ExprData.BinOp" /* BinOp */;
|
|
59
67
|
}
|
|
60
68
|
ExprData2.BinOp = BinOp;
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
class Field {
|
|
70
|
+
constructor(expr, field) {
|
|
71
|
+
this.expr = expr;
|
|
72
|
+
this.field = field;
|
|
73
|
+
}
|
|
74
|
+
type = "ExprData.Field" /* Field */;
|
|
63
75
|
}
|
|
64
76
|
ExprData2.Field = Field;
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
class Param {
|
|
78
|
+
constructor(param) {
|
|
79
|
+
this.param = param;
|
|
80
|
+
}
|
|
81
|
+
type = "ExprData.Param" /* Param */;
|
|
67
82
|
}
|
|
68
83
|
ExprData2.Param = Param;
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
class Call {
|
|
85
|
+
constructor(method, params) {
|
|
86
|
+
this.method = method;
|
|
87
|
+
this.params = params;
|
|
88
|
+
}
|
|
89
|
+
type = "ExprData.Call" /* Call */;
|
|
71
90
|
}
|
|
72
91
|
ExprData2.Call = Call;
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
class Query {
|
|
93
|
+
constructor(query) {
|
|
94
|
+
this.query = query;
|
|
95
|
+
}
|
|
96
|
+
type = "ExprData.Query" /* Query */;
|
|
75
97
|
}
|
|
76
98
|
ExprData2.Query = Query;
|
|
77
|
-
|
|
78
|
-
|
|
99
|
+
class Record {
|
|
100
|
+
constructor(fields) {
|
|
101
|
+
this.fields = fields;
|
|
102
|
+
}
|
|
103
|
+
type = "ExprData.Record" /* Record */;
|
|
79
104
|
}
|
|
80
105
|
ExprData2.Record = Record;
|
|
81
|
-
|
|
82
|
-
|
|
106
|
+
class Merge {
|
|
107
|
+
constructor(a, b) {
|
|
108
|
+
this.a = a;
|
|
109
|
+
this.b = b;
|
|
110
|
+
}
|
|
111
|
+
type = "ExprData.Merge" /* Merge */;
|
|
83
112
|
}
|
|
84
113
|
ExprData2.Merge = Merge;
|
|
85
|
-
|
|
86
|
-
|
|
114
|
+
class Row {
|
|
115
|
+
constructor(target) {
|
|
116
|
+
this.target = target;
|
|
117
|
+
}
|
|
118
|
+
type = "ExprData.Row" /* Row */;
|
|
87
119
|
}
|
|
88
120
|
ExprData2.Row = Row;
|
|
89
|
-
|
|
90
|
-
|
|
121
|
+
class Map {
|
|
122
|
+
constructor(target, result) {
|
|
123
|
+
this.target = target;
|
|
124
|
+
this.result = result;
|
|
125
|
+
}
|
|
126
|
+
type = "ExprData.Map" /* Map */;
|
|
91
127
|
}
|
|
92
128
|
ExprData2.Map = Map;
|
|
93
|
-
|
|
94
|
-
|
|
129
|
+
class Filter {
|
|
130
|
+
constructor(target, condition) {
|
|
131
|
+
this.target = target;
|
|
132
|
+
this.condition = condition;
|
|
133
|
+
}
|
|
134
|
+
type = "ExprData.Filter" /* Filter */;
|
|
95
135
|
}
|
|
96
136
|
ExprData2.Filter = Filter;
|
|
97
|
-
function Case(expr, cases, defaultCase) {
|
|
98
|
-
return { type: "Case" /* Case */, expr, cases, defaultCase };
|
|
99
|
-
}
|
|
100
|
-
ExprData2.Case = Case;
|
|
101
137
|
function create(input) {
|
|
102
138
|
if (input === null || input === void 0)
|
|
103
|
-
return ExprData2.Param(ParamData.Value(null));
|
|
139
|
+
return new ExprData2.Param(new ParamData.Value(null));
|
|
104
140
|
if (input && (typeof input === "function" || typeof input === "object") && input[TO_EXPR])
|
|
105
141
|
input = input[TO_EXPR]();
|
|
106
142
|
if (Expr.isExpr(input))
|
|
107
143
|
return input[DATA];
|
|
108
144
|
if (input && typeof input === "object" && !Array.isArray(input))
|
|
109
|
-
return ExprData2.Record(
|
|
145
|
+
return new ExprData2.Record(
|
|
110
146
|
fromEntries(
|
|
111
147
|
entries(input).map(([key, value]) => [key, ExprData2.create(value)])
|
|
112
148
|
)
|
|
113
149
|
);
|
|
114
|
-
return ExprData2.Param(ParamData.Value(input));
|
|
150
|
+
return new ExprData2.Param(new ParamData.Value(input));
|
|
115
151
|
}
|
|
116
152
|
ExprData2.create = create;
|
|
117
153
|
})(ExprData || (ExprData = {}));
|
|
@@ -128,7 +164,7 @@ var Expr = class {
|
|
|
128
164
|
return { expr: this[DATA], order: OrderDirection.Desc };
|
|
129
165
|
}
|
|
130
166
|
not() {
|
|
131
|
-
return new Expr(ExprData.UnOp("Not" /* Not */, this[DATA]));
|
|
167
|
+
return new Expr(new ExprData.UnOp("Not" /* Not */, this[DATA]));
|
|
132
168
|
}
|
|
133
169
|
or(that) {
|
|
134
170
|
const a = this;
|
|
@@ -137,7 +173,7 @@ var Expr = class {
|
|
|
137
173
|
return b;
|
|
138
174
|
if (a.isConstant(true) || b.isConstant(false))
|
|
139
175
|
return this;
|
|
140
|
-
return new Expr(ExprData.BinOp("Or" /* Or */, a[DATA], b[DATA]));
|
|
176
|
+
return new Expr(new ExprData.BinOp("Or" /* Or */, a[DATA], b[DATA]));
|
|
141
177
|
}
|
|
142
178
|
and(that) {
|
|
143
179
|
const a = this;
|
|
@@ -146,21 +182,22 @@ var Expr = class {
|
|
|
146
182
|
return this;
|
|
147
183
|
if (a.isConstant(true) || b.isConstant(false))
|
|
148
184
|
return b;
|
|
149
|
-
return new Expr(ExprData.BinOp("And" /* And */, a[DATA], b[DATA]));
|
|
185
|
+
return new Expr(new ExprData.BinOp("And" /* And */, a[DATA], b[DATA]));
|
|
150
186
|
}
|
|
151
187
|
is(that) {
|
|
152
188
|
if (that === null || Expr.isExpr(that) && that.isConstant(null))
|
|
153
189
|
return this.isNull();
|
|
154
190
|
return new Expr(
|
|
155
|
-
ExprData.BinOp("Equals" /* Equals */, this[DATA], ExprData.create(that))
|
|
191
|
+
new ExprData.BinOp("Equals" /* Equals */, this[DATA], ExprData.create(that))
|
|
156
192
|
);
|
|
157
193
|
}
|
|
158
194
|
isConstant(value) {
|
|
159
195
|
switch (this[DATA].type) {
|
|
160
|
-
case "Param" /* Param */:
|
|
161
|
-
|
|
196
|
+
case "ExprData.Param" /* Param */:
|
|
197
|
+
const param = this[DATA].param;
|
|
198
|
+
switch (param.type) {
|
|
162
199
|
case ParamType.Value:
|
|
163
|
-
return
|
|
200
|
+
return param.value === value;
|
|
164
201
|
default:
|
|
165
202
|
return false;
|
|
166
203
|
}
|
|
@@ -172,33 +209,33 @@ var Expr = class {
|
|
|
172
209
|
if (that === null || Expr.isExpr(that) && that.isConstant(null))
|
|
173
210
|
return this.isNotNull();
|
|
174
211
|
return new Expr(
|
|
175
|
-
ExprData.BinOp("NotEquals" /* NotEquals */, this[DATA], ExprData.create(that))
|
|
212
|
+
new ExprData.BinOp("NotEquals" /* NotEquals */, this[DATA], ExprData.create(that))
|
|
176
213
|
);
|
|
177
214
|
}
|
|
178
215
|
isNull() {
|
|
179
|
-
return new Expr(ExprData.UnOp("IsNull" /* IsNull */, this[DATA]));
|
|
216
|
+
return new Expr(new ExprData.UnOp("IsNull" /* IsNull */, this[DATA]));
|
|
180
217
|
}
|
|
181
218
|
isNotNull() {
|
|
182
219
|
return this.isNull().not();
|
|
183
220
|
}
|
|
184
221
|
isIn(that) {
|
|
185
222
|
return new Expr(
|
|
186
|
-
ExprData.BinOp("In" /* In */, this[DATA], ExprData.create(that))
|
|
223
|
+
new ExprData.BinOp("In" /* In */, this[DATA], ExprData.create(that))
|
|
187
224
|
);
|
|
188
225
|
}
|
|
189
226
|
isNotIn(that) {
|
|
190
227
|
return new Expr(
|
|
191
|
-
ExprData.BinOp("NotIn" /* NotIn */, this[DATA], ExprData.create(that))
|
|
228
|
+
new ExprData.BinOp("NotIn" /* NotIn */, this[DATA], ExprData.create(that))
|
|
192
229
|
);
|
|
193
230
|
}
|
|
194
231
|
isGreater(that) {
|
|
195
232
|
return new Expr(
|
|
196
|
-
ExprData.BinOp("Greater" /* Greater */, this[DATA], ExprData.create(that))
|
|
233
|
+
new ExprData.BinOp("Greater" /* Greater */, this[DATA], ExprData.create(that))
|
|
197
234
|
);
|
|
198
235
|
}
|
|
199
236
|
isGreaterOrEqual(that) {
|
|
200
237
|
return new Expr(
|
|
201
|
-
ExprData.BinOp(
|
|
238
|
+
new ExprData.BinOp(
|
|
202
239
|
"GreaterOrEqual" /* GreaterOrEqual */,
|
|
203
240
|
this[DATA],
|
|
204
241
|
ExprData.create(that)
|
|
@@ -207,62 +244,66 @@ var Expr = class {
|
|
|
207
244
|
}
|
|
208
245
|
isLess(that) {
|
|
209
246
|
return new Expr(
|
|
210
|
-
ExprData.BinOp("Less" /* Less */, this[DATA], ExprData.create(that))
|
|
247
|
+
new ExprData.BinOp("Less" /* Less */, this[DATA], ExprData.create(that))
|
|
211
248
|
);
|
|
212
249
|
}
|
|
213
250
|
isLessOrEqual(that) {
|
|
214
251
|
return new Expr(
|
|
215
|
-
ExprData.BinOp(
|
|
252
|
+
new ExprData.BinOp(
|
|
253
|
+
"LessOrEqual" /* LessOrEqual */,
|
|
254
|
+
this[DATA],
|
|
255
|
+
ExprData.create(that)
|
|
256
|
+
)
|
|
216
257
|
);
|
|
217
258
|
}
|
|
218
259
|
add(that) {
|
|
219
260
|
return new Expr(
|
|
220
|
-
ExprData.BinOp("Add" /* Add */, this[DATA], ExprData.create(that))
|
|
261
|
+
new ExprData.BinOp("Add" /* Add */, this[DATA], ExprData.create(that))
|
|
221
262
|
);
|
|
222
263
|
}
|
|
223
264
|
substract(that) {
|
|
224
265
|
return new Expr(
|
|
225
|
-
ExprData.BinOp("Subt" /* Subt */, this[DATA], ExprData.create(that))
|
|
266
|
+
new ExprData.BinOp("Subt" /* Subt */, this[DATA], ExprData.create(that))
|
|
226
267
|
);
|
|
227
268
|
}
|
|
228
269
|
multiply(that) {
|
|
229
270
|
return new Expr(
|
|
230
|
-
ExprData.BinOp("Mult" /* Mult */, this[DATA], ExprData.create(that))
|
|
271
|
+
new ExprData.BinOp("Mult" /* Mult */, this[DATA], ExprData.create(that))
|
|
231
272
|
);
|
|
232
273
|
}
|
|
233
274
|
remainder(that) {
|
|
234
275
|
return new Expr(
|
|
235
|
-
ExprData.BinOp("Mod" /* Mod */, this[DATA], ExprData.create(that))
|
|
276
|
+
new ExprData.BinOp("Mod" /* Mod */, this[DATA], ExprData.create(that))
|
|
236
277
|
);
|
|
237
278
|
}
|
|
238
279
|
divide(that) {
|
|
239
280
|
return new Expr(
|
|
240
|
-
ExprData.BinOp("Div" /* Div */, this[DATA], ExprData.create(that))
|
|
281
|
+
new ExprData.BinOp("Div" /* Div */, this[DATA], ExprData.create(that))
|
|
241
282
|
);
|
|
242
283
|
}
|
|
243
284
|
concat(that) {
|
|
244
285
|
return new Expr(
|
|
245
|
-
ExprData.BinOp("Concat" /* Concat */, this[DATA], ExprData.create(that))
|
|
286
|
+
new ExprData.BinOp("Concat" /* Concat */, this[DATA], ExprData.create(that))
|
|
246
287
|
);
|
|
247
288
|
}
|
|
248
289
|
like(that) {
|
|
249
290
|
return new Expr(
|
|
250
|
-
ExprData.BinOp("Like" /* Like */, this[DATA], ExprData.create(that))
|
|
291
|
+
new ExprData.BinOp("Like" /* Like */, this[DATA], ExprData.create(that))
|
|
251
292
|
);
|
|
252
293
|
}
|
|
253
294
|
glob(that) {
|
|
254
295
|
return new Expr(
|
|
255
|
-
ExprData.BinOp("Glob" /* Glob */, this[DATA], ExprData.create(that))
|
|
296
|
+
new ExprData.BinOp("Glob" /* Glob */, this[DATA], ExprData.create(that))
|
|
256
297
|
);
|
|
257
298
|
}
|
|
258
299
|
match(that) {
|
|
259
300
|
return new Expr(
|
|
260
|
-
ExprData.BinOp("Match" /* Match */, this[DATA], ExprData.create(that))
|
|
301
|
+
new ExprData.BinOp("Match" /* Match */, this[DATA], ExprData.create(that))
|
|
261
302
|
);
|
|
262
303
|
}
|
|
263
304
|
with(that) {
|
|
264
305
|
return new Expr(
|
|
265
|
-
ExprData.Merge(this[DATA], ExprData.create(that))
|
|
306
|
+
new ExprData.Merge(this[DATA], ExprData.create(that))
|
|
266
307
|
);
|
|
267
308
|
}
|
|
268
309
|
/**
|
|
@@ -296,21 +337,21 @@ var Expr = class {
|
|
|
296
337
|
}
|
|
297
338
|
filter(fn) {
|
|
298
339
|
const alias = `__${Math.random().toString(36).slice(2, 9)}`;
|
|
299
|
-
const target = Target.Expr(this[DATA], alias);
|
|
340
|
+
const target = new Target.Expr(this[DATA], alias);
|
|
300
341
|
return new Expr(
|
|
301
|
-
ExprData.Filter(
|
|
342
|
+
new ExprData.Filter(
|
|
302
343
|
target,
|
|
303
|
-
ExprData.create(fn(new Expr(ExprData.Row(target)).dynamic()))
|
|
344
|
+
ExprData.create(fn(new Expr(new ExprData.Row(target)).dynamic()))
|
|
304
345
|
)
|
|
305
346
|
);
|
|
306
347
|
}
|
|
307
348
|
map(fn) {
|
|
308
349
|
const alias = `__${Math.random().toString(36).slice(2, 9)}`;
|
|
309
|
-
const target = Target.Expr(this[DATA], alias);
|
|
350
|
+
const target = new Target.Expr(this[DATA], alias);
|
|
310
351
|
return new Expr(
|
|
311
|
-
ExprData.Map(
|
|
352
|
+
new ExprData.Map(
|
|
312
353
|
target,
|
|
313
|
-
ExprData.create(fn(new Expr(ExprData.Row(target)).dynamic()))
|
|
354
|
+
ExprData.create(fn(new Expr(new ExprData.Row(target)).dynamic()))
|
|
314
355
|
)
|
|
315
356
|
);
|
|
316
357
|
}
|
|
@@ -318,16 +359,16 @@ var Expr = class {
|
|
|
318
359
|
return this;
|
|
319
360
|
}
|
|
320
361
|
get(name) {
|
|
321
|
-
return new Expr(ExprData.Field(this[DATA], name));
|
|
362
|
+
return new Expr(new ExprData.Field(this[DATA], name));
|
|
322
363
|
}
|
|
323
364
|
};
|
|
324
365
|
((Expr2) => {
|
|
325
|
-
Expr2.NULL = create(null);
|
|
326
366
|
Expr2.Data = DATA;
|
|
327
367
|
Expr2.IsExpr = IS_EXPR;
|
|
328
368
|
Expr2.ToExpr = TO_EXPR;
|
|
369
|
+
Expr2.NULL = create(null);
|
|
329
370
|
function value(value2) {
|
|
330
|
-
return new Expr2(ExprData.Param(ParamData.Value(value2)));
|
|
371
|
+
return new Expr2(new ExprData.Param(new ParamData.Value(value2)));
|
|
331
372
|
}
|
|
332
373
|
Expr2.value = value;
|
|
333
374
|
function create(input) {
|