rado 0.1.23 → 0.1.25

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/driver/better-sqlite3.d.ts +15 -17
  3. package/dist/driver/better-sqlite3.js +25 -18
  4. package/dist/driver/sql.js.d.ts +15 -17
  5. package/dist/driver/sql.js.js +29 -26
  6. package/dist/driver/sqlite3.d.ts +18 -20
  7. package/dist/driver/sqlite3.js +40 -29
  8. package/dist/index.d.ts +20 -20
  9. package/dist/lib/Column.d.ts +57 -57
  10. package/dist/lib/Cursor.d.ts +78 -77
  11. package/dist/lib/Cursor.js +3 -0
  12. package/dist/lib/Driver.d.ts +105 -89
  13. package/dist/lib/Driver.js +72 -28
  14. package/dist/lib/Expr.d.ts +154 -154
  15. package/dist/lib/Fields.d.ts +13 -13
  16. package/dist/lib/Formatter.d.ts +56 -56
  17. package/dist/lib/Formatter.js +14 -4
  18. package/dist/lib/Functions.d.ts +7 -7
  19. package/dist/lib/Id.d.ts +3 -3
  20. package/dist/lib/Index.d.ts +17 -17
  21. package/dist/lib/Index.js +3 -3
  22. package/dist/lib/Ops.d.ts +8 -8
  23. package/dist/lib/OrderBy.d.ts +9 -9
  24. package/dist/lib/Param.d.ts +20 -15
  25. package/dist/lib/Param.js +10 -1
  26. package/dist/lib/Query.d.ts +108 -108
  27. package/dist/lib/Sanitizer.d.ts +4 -4
  28. package/dist/lib/Schema.d.ts +18 -18
  29. package/dist/lib/Schema.js +4 -4
  30. package/dist/lib/Selection.d.ts +20 -20
  31. package/dist/lib/Statement.d.ts +71 -61
  32. package/dist/lib/Statement.js +46 -5
  33. package/dist/lib/Table.d.ts +59 -58
  34. package/dist/lib/Table.js +4 -7
  35. package/dist/lib/Target.d.ts +30 -30
  36. package/dist/lib/Update.d.ts +4 -4
  37. package/dist/sqlite/SqliteFormatter.d.ts +11 -11
  38. package/dist/sqlite/SqliteFunctions.d.ts +156 -156
  39. package/dist/sqlite/SqliteSchema.d.ts +25 -24
  40. package/dist/sqlite/SqliteSchema.js +5 -4
  41. package/dist/sqlite.d.ts +2 -2
  42. package/package.json +47 -47
  43. package/dist/Column.d.ts +0 -41
  44. package/dist/Column.js +0 -58
  45. package/dist/Cursor.d.ts +0 -77
  46. package/dist/Cursor.js +0 -211
  47. package/dist/Driver.d.ts +0 -72
  48. package/dist/Driver.js +0 -145
  49. package/dist/Expr.d.ts +0 -149
  50. package/dist/Expr.js +0 -284
  51. package/dist/Fields.d.ts +0 -9
  52. package/dist/Fields.js +0 -0
  53. package/dist/Formatter.d.ts +0 -50
  54. package/dist/Formatter.js +0 -453
  55. package/dist/Functions.d.ts +0 -8
  56. package/dist/Functions.js +0 -11
  57. package/dist/Key.d.ts +0 -5
  58. package/dist/Ops.d.ts +0 -8
  59. package/dist/Ops.js +0 -46
  60. package/dist/OrderBy.d.ts +0 -9
  61. package/dist/OrderBy.js +0 -9
  62. package/dist/Param.d.ts +0 -15
  63. package/dist/Param.js +0 -18
  64. package/dist/Query.d.ts +0 -94
  65. package/dist/Query.js +0 -57
  66. package/dist/Sanitizer.d.ts +0 -4
  67. package/dist/Sanitizer.js +0 -0
  68. package/dist/Schema.d.ts +0 -10
  69. package/dist/Selection.d.ts +0 -18
  70. package/dist/Selection.js +0 -0
  71. package/dist/Statement.d.ts +0 -57
  72. package/dist/Statement.js +0 -184
  73. package/dist/Table.d.ts +0 -47
  74. package/dist/Table.js +0 -82
  75. package/dist/Target.d.ts +0 -30
  76. package/dist/Target.js +0 -37
  77. package/dist/Update.d.ts +0 -4
  78. package/dist/Update.js +0 -0
  79. package/dist/sqlite/index.d.ts +0 -2
  80. package/dist/sqlite/index.js +0 -3
package/dist/Driver.js DELETED
@@ -1,145 +0,0 @@
1
- // src/Driver.ts
2
- import { Cursor } from "./Cursor";
3
- import { Query, QueryType } from "./Query";
4
- var Callable = class extends Function {
5
- constructor(fn) {
6
- super();
7
- return new Proxy(this, {
8
- apply(_, thisArg, input) {
9
- return fn.apply(thisArg, input);
10
- }
11
- });
12
- }
13
- };
14
- var DriverBase = class extends Callable {
15
- constructor() {
16
- super((...args) => {
17
- const [input, ...rest] = args;
18
- if (input instanceof Cursor)
19
- return this.executeQuery(input.query());
20
- return this.executeTemplate(void 0, input, ...rest);
21
- });
22
- }
23
- all(strings, ...params) {
24
- return this.executeTemplate("rows", strings, ...params);
25
- }
26
- get(strings, ...params) {
27
- return this.executeTemplate("row", strings, ...params);
28
- }
29
- executeTemplate(expectedReturn, strings, ...params) {
30
- if (strings.some((chunk) => chunk.includes("?")))
31
- throw new TypeError("SQL injection hazard");
32
- return this.executeQuery(Query.Raw({ strings, params, expectedReturn }));
33
- }
34
- };
35
- var Driver;
36
- ((Driver2) => {
37
- class Sync extends DriverBase {
38
- transactionId = 0;
39
- executeQuery(query) {
40
- switch (query.type) {
41
- case QueryType.Batch:
42
- let result;
43
- const stmts = query.queries;
44
- for (const query2 of stmts)
45
- result = this.execute(query2);
46
- return result;
47
- default:
48
- return this.execute(query);
49
- }
50
- }
51
- all(strings, ...params) {
52
- return super.all(strings, ...params);
53
- }
54
- get(strings, ...params) {
55
- return super.get(strings, ...params);
56
- }
57
- transaction(run) {
58
- const id = `t${this.transactionId++}`;
59
- this.execute(
60
- Query.Transaction({ op: Query.TransactionOperation.Begin, id })
61
- );
62
- try {
63
- const res = run(this);
64
- this.execute(
65
- Query.Transaction({ op: Query.TransactionOperation.Commit, id })
66
- );
67
- return res;
68
- } catch (e) {
69
- this.execute(
70
- Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
71
- );
72
- throw e;
73
- }
74
- }
75
- toAsync() {
76
- return new SyncWrapper(this);
77
- }
78
- }
79
- Driver2.Sync = Sync;
80
- class Async extends DriverBase {
81
- transactionId = 0;
82
- async executeQuery(query) {
83
- switch (query.type) {
84
- case QueryType.Batch:
85
- let result;
86
- const stmts = query.queries;
87
- for (const query2 of stmts)
88
- result = await this.execute(query2);
89
- return result;
90
- default:
91
- return this.execute(query);
92
- }
93
- }
94
- all(strings, ...params) {
95
- return super.all(strings, ...params);
96
- }
97
- get(strings, ...params) {
98
- return super.get(strings, ...params);
99
- }
100
- async transaction(run) {
101
- const id = `t${this.transactionId++}`;
102
- const [connection, release] = this.isolate();
103
- await connection.execute(
104
- Query.Transaction({ op: Query.TransactionOperation.Begin, id })
105
- );
106
- try {
107
- const res = await run(connection);
108
- await connection.execute(
109
- Query.Transaction({ op: Query.TransactionOperation.Commit, id })
110
- );
111
- return res;
112
- } catch (e) {
113
- await connection.execute(
114
- Query.Transaction({ op: Query.TransactionOperation.Rollback, id })
115
- );
116
- throw e;
117
- } finally {
118
- await release();
119
- }
120
- }
121
- }
122
- Driver2.Async = Async;
123
- class SyncWrapper extends Async {
124
- constructor(sync) {
125
- super();
126
- this.sync = sync;
127
- }
128
- lock;
129
- async execute(query) {
130
- await this.lock;
131
- return this.sync.execute(query);
132
- }
133
- isolate() {
134
- const connection = new SyncWrapper(this.sync);
135
- let release, trigger = new Promise((resolve) => {
136
- release = async () => resolve();
137
- });
138
- this.lock = Promise.resolve(this.lock).then(() => trigger);
139
- return [connection, release];
140
- }
141
- }
142
- })(Driver || (Driver = {}));
143
- export {
144
- Driver
145
- };
package/dist/Expr.d.ts DELETED
@@ -1,149 +0,0 @@
1
- import { Cursor } from './Cursor';
2
- import { Fields } from './Fields';
3
- import { OrderBy } from './OrderBy';
4
- import { ParamData } from './Param';
5
- import { Query } from './Query';
6
- import { Selection } from './Selection';
7
- import { Target } from './Target';
8
- export declare const enum UnOp {
9
- Not = "Not",
10
- IsNull = "IsNull"
11
- }
12
- export declare const enum BinOp {
13
- Add = "Add",
14
- Subt = "Subt",
15
- Mult = "Mult",
16
- Mod = "Mod",
17
- Div = "Div",
18
- Greater = "Greater",
19
- GreaterOrEqual = "GreaterOrEqual",
20
- Less = "Less",
21
- LessOrEqual = "LessOrEqual",
22
- Equals = "Equals",
23
- NotEquals = "NotEquals",
24
- And = "And",
25
- Or = "Or",
26
- Like = "Like",
27
- Glob = "Glob",
28
- Match = "Match",
29
- In = "In",
30
- NotIn = "NotIn",
31
- Concat = "Concat"
32
- }
33
- export declare const enum ExprType {
34
- UnOp = "UnOp",
35
- BinOp = "BinOp",
36
- Field = "Field",
37
- Param = "Param",
38
- Call = "Call",
39
- Query = "Query",
40
- Record = "Record",
41
- Row = "Row",
42
- Map = "Map",
43
- Filter = "Filter",
44
- Merge = "Merge",
45
- Case = "Case"
46
- }
47
- export type ExprData = {
48
- type: ExprType.UnOp;
49
- op: UnOp;
50
- expr: ExprData;
51
- } | {
52
- type: ExprType.BinOp;
53
- op: BinOp;
54
- a: ExprData;
55
- b: ExprData;
56
- } | {
57
- type: ExprType.Field;
58
- expr: ExprData;
59
- field: string;
60
- } | {
61
- type: ExprType.Param;
62
- param: ParamData;
63
- } | {
64
- type: ExprType.Call;
65
- method: string;
66
- params: Array<ExprData>;
67
- } | {
68
- type: ExprType.Query;
69
- query: Query.Select;
70
- } | {
71
- type: ExprType.Record;
72
- fields: Record<string, ExprData>;
73
- } | {
74
- type: ExprType.Merge;
75
- a: ExprData;
76
- b: ExprData;
77
- } | {
78
- type: ExprType.Row;
79
- target: Target;
80
- } | {
81
- type: ExprType.Map;
82
- target: Target;
83
- result: ExprData;
84
- } | {
85
- type: ExprType.Filter;
86
- target: Target;
87
- condition: ExprData;
88
- } | {
89
- type: ExprType.Case;
90
- expr: ExprData;
91
- cases: Record<string, ExprData>;
92
- defaultCase?: ExprData;
93
- };
94
- export declare const ExprData: {
95
- UnOp(op: UnOp, expr: ExprData): ExprData;
96
- BinOp(op: BinOp, a: ExprData, b: ExprData): ExprData;
97
- Field(expr: ExprData, field: string): ExprData;
98
- Param(param: ParamData): ExprData;
99
- Call(method: string, params: Array<ExprData>): ExprData;
100
- Query(query: Query.Select): ExprData;
101
- Record(fields: Record<string, ExprData>): ExprData;
102
- Merge(a: ExprData, b: ExprData): ExprData;
103
- Row(target: Target): ExprData;
104
- Map(target: Target, result: ExprData): ExprData;
105
- Filter(target: Target, condition: ExprData): ExprData;
106
- Case(expr: ExprData, cases: Record<string, ExprData>, defaultCase?: ExprData): ExprData;
107
- create(input: any): ExprData;
108
- };
109
- /** Expression or value of type T */
110
- export type EV<T> = Expr<T> | T;
111
- export declare class Expr<T> {
112
- expr: ExprData;
113
- static NULL: ExprData;
114
- static value<T>(value: T): Expr<T>;
115
- static create<T>(input: EV<T>): Expr<T>;
116
- static and(...conditions: Array<EV<boolean>>): Expr<boolean>;
117
- static or(...conditions: Array<EV<boolean>>): Expr<boolean>;
118
- constructor(expr: ExprData);
119
- asc(): OrderBy;
120
- desc(): OrderBy;
121
- not(): Expr<boolean>;
122
- or(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
123
- and(this: Expr<boolean>, that: EV<boolean>): Expr<boolean>;
124
- isNull(): Expr<boolean>;
125
- isNotNull(): Expr<boolean>;
126
- isNot(that: EV<T>): Expr<boolean>;
127
- is(that: EV<T> | Cursor.SelectSingle<T>): Expr<boolean>;
128
- isIn(that: EV<Array<T>> | Cursor<T>): Expr<boolean>;
129
- isNotIn(that: EV<Array<T>> | Cursor<T>): Expr<boolean>;
130
- add(this: Expr<number>, that: EV<number>): Expr<number>;
131
- substract(this: Expr<number>, that: EV<number>): Expr<number>;
132
- multiply(this: Expr<number>, that: EV<number>): Expr<number>;
133
- remainder(this: Expr<number>, that: EV<number>): Expr<number>;
134
- divide(this: Expr<number>, that: EV<number>): Expr<number>;
135
- greater(that: EV<any>): Expr<boolean>;
136
- greaterOrEqual(that: EV<any>): Expr<boolean>;
137
- less(that: EV<any>): Expr<boolean>;
138
- lessOrEqual(that: EV<any>): Expr<boolean>;
139
- concat(this: Expr<string>, that: EV<string>): Expr<string>;
140
- like(this: Expr<string>, that: EV<string>): Expr<boolean>;
141
- glob(this: Expr<string>, that: EV<string>): Expr<boolean>;
142
- match(this: Expr<string>, that: EV<string>): Expr<boolean>;
143
- with<X extends Selection>(that: X): Selection.With<T, X>;
144
- at<T>(this: Expr<Array<T>>, index: number): Expr<T | null>;
145
- filter<T>(this: Expr<Array<T>>, fn: (cursor: Fields<T>) => Expr<boolean>): Expr<Array<T>>;
146
- map<T, X extends Selection>(this: Expr<Array<T>>, fn: (cursor: Fields<T>) => X): Expr<Array<Selection.Infer<X>>>;
147
- sure(): Expr<NonNullable<T>>;
148
- get<T>(name: string): Expr<T>;
149
- }
package/dist/Expr.js DELETED
@@ -1,284 +0,0 @@
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
-
8
- // src/Expr.ts
9
- import { OrderDirection } from "./OrderBy";
10
- import { ParamData, ParamType } from "./Param";
11
- import { Target } from "./Target";
12
- var UnOp = /* @__PURE__ */ ((UnOp2) => {
13
- UnOp2["Not"] = "Not";
14
- UnOp2["IsNull"] = "IsNull";
15
- return UnOp2;
16
- })(UnOp || {});
17
- var BinOp = /* @__PURE__ */ ((BinOp2) => {
18
- BinOp2["Add"] = "Add";
19
- BinOp2["Subt"] = "Subt";
20
- BinOp2["Mult"] = "Mult";
21
- BinOp2["Mod"] = "Mod";
22
- BinOp2["Div"] = "Div";
23
- BinOp2["Greater"] = "Greater";
24
- BinOp2["GreaterOrEqual"] = "GreaterOrEqual";
25
- BinOp2["Less"] = "Less";
26
- BinOp2["LessOrEqual"] = "LessOrEqual";
27
- BinOp2["Equals"] = "Equals";
28
- BinOp2["NotEquals"] = "NotEquals";
29
- BinOp2["And"] = "And";
30
- BinOp2["Or"] = "Or";
31
- BinOp2["Like"] = "Like";
32
- BinOp2["Glob"] = "Glob";
33
- BinOp2["Match"] = "Match";
34
- BinOp2["In"] = "In";
35
- BinOp2["NotIn"] = "NotIn";
36
- BinOp2["Concat"] = "Concat";
37
- return BinOp2;
38
- })(BinOp || {});
39
- var ExprType = /* @__PURE__ */ ((ExprType2) => {
40
- ExprType2["UnOp"] = "UnOp";
41
- ExprType2["BinOp"] = "BinOp";
42
- ExprType2["Field"] = "Field";
43
- ExprType2["Param"] = "Param";
44
- ExprType2["Call"] = "Call";
45
- ExprType2["Query"] = "Query";
46
- ExprType2["Record"] = "Record";
47
- ExprType2["Row"] = "Row";
48
- ExprType2["Map"] = "Map";
49
- ExprType2["Filter"] = "Filter";
50
- ExprType2["Merge"] = "Merge";
51
- ExprType2["Case"] = "Case";
52
- return ExprType2;
53
- })(ExprType || {});
54
- var ExprData = {
55
- UnOp(op, expr) {
56
- return { type: "UnOp" /* UnOp */, op, expr };
57
- },
58
- BinOp(op, a, b) {
59
- return { type: "BinOp" /* BinOp */, op, a, b };
60
- },
61
- Field(expr, field) {
62
- return { type: "Field" /* Field */, expr, field };
63
- },
64
- Param(param) {
65
- return { type: "Param" /* Param */, param };
66
- },
67
- Call(method, params) {
68
- return { type: "Call" /* Call */, method, params };
69
- },
70
- Query(query) {
71
- return { type: "Query" /* Query */, query };
72
- },
73
- Record(fields) {
74
- return { type: "Record" /* Record */, fields };
75
- },
76
- Merge(a, b) {
77
- return { type: "Merge" /* Merge */, a, b };
78
- },
79
- Row(target) {
80
- return { type: "Row" /* Row */, target };
81
- },
82
- Map(target, result) {
83
- return { type: "Map" /* Map */, target, result };
84
- },
85
- Filter(target, condition) {
86
- return { type: "Filter" /* Filter */, target, condition };
87
- },
88
- Case(expr, cases, defaultCase) {
89
- return { type: "Case" /* Case */, expr, cases, defaultCase };
90
- },
91
- create(input) {
92
- if (input === null || input === void 0)
93
- return ExprData.Param(ParamData.Value(null));
94
- if (input && typeof input === "object" && typeof input.toExpr === "function")
95
- input = input.toExpr();
96
- if (input instanceof Expr)
97
- return input.expr;
98
- if (input && typeof input === "object" && !Array.isArray(input))
99
- return ExprData.Record(
100
- Object.fromEntries(
101
- Object.entries(input).map(([key, value]) => [
102
- key,
103
- ExprData.create(value)
104
- ])
105
- )
106
- );
107
- return ExprData.Param(ParamData.Value(input));
108
- }
109
- };
110
- var toExpr = ExprData.create;
111
- function isConstant(e, value) {
112
- switch (e.type) {
113
- case "Param" /* Param */:
114
- switch (e.param.type) {
115
- case ParamType.Value:
116
- return e.param.value == value;
117
- default:
118
- return false;
119
- }
120
- default:
121
- return false;
122
- }
123
- }
124
- var _Expr = class {
125
- constructor(expr) {
126
- this.expr = expr;
127
- return new Proxy(this, {
128
- get(target, key) {
129
- return key in target ? target[key] : target.get(key);
130
- }
131
- });
132
- }
133
- static value(value) {
134
- return new _Expr(ExprData.Param(ParamData.Value(value)));
135
- }
136
- static create(input) {
137
- if (input instanceof _Expr)
138
- return input;
139
- return new _Expr(ExprData.create(input));
140
- }
141
- static and(...conditions) {
142
- return conditions.map(_Expr.create).reduce((condition, expr) => condition.and(expr), _Expr.value(true));
143
- }
144
- static or(...conditions) {
145
- return conditions.map(_Expr.create).reduce((condition, expr) => condition.or(expr), _Expr.value(false));
146
- }
147
- asc() {
148
- return { expr: this.expr, order: OrderDirection.Asc };
149
- }
150
- desc() {
151
- return { expr: this.expr, order: OrderDirection.Desc };
152
- }
153
- not() {
154
- return unop(this, "Not" /* Not */);
155
- }
156
- or(that) {
157
- const a = this.expr;
158
- const b = toExpr(that);
159
- if (isConstant(b, true) || isConstant(a, false))
160
- return new _Expr(b);
161
- if (isConstant(a, true) || isConstant(b, false))
162
- return this;
163
- return new _Expr(ExprData.BinOp("Or" /* Or */, a, b));
164
- }
165
- and(that) {
166
- const a = this.expr;
167
- const b = toExpr(that);
168
- if (isConstant(b, true) || isConstant(a, false))
169
- return this;
170
- if (isConstant(a, true) || isConstant(b, false))
171
- return new _Expr(b);
172
- return new _Expr(ExprData.BinOp("And" /* And */, a, b));
173
- }
174
- isNull() {
175
- return unop(this, "IsNull" /* IsNull */);
176
- }
177
- isNotNull() {
178
- return this.isNull().not();
179
- }
180
- isNot(that) {
181
- if (that == null || that instanceof _Expr && isConstant(that.expr, null))
182
- return this.isNotNull();
183
- return binop(this, "NotEquals" /* NotEquals */, that);
184
- }
185
- is(that) {
186
- if (that === null || that instanceof _Expr && isConstant(that.expr, null))
187
- return this.isNull();
188
- return binop(this, "Equals" /* Equals */, that);
189
- }
190
- isIn(that) {
191
- return binop(this, "In" /* In */, that);
192
- }
193
- isNotIn(that) {
194
- return binop(this, "NotIn" /* NotIn */, that);
195
- }
196
- add(that) {
197
- return binop(this, "Add" /* Add */, that);
198
- }
199
- substract(that) {
200
- return binop(this, "Subt" /* Subt */, that);
201
- }
202
- multiply(that) {
203
- return binop(this, "Mult" /* Mult */, that);
204
- }
205
- remainder(that) {
206
- return binop(this, "Mod" /* Mod */, that);
207
- }
208
- divide(that) {
209
- return binop(this, "Div" /* Div */, that);
210
- }
211
- greater(that) {
212
- return binop(this, "Greater" /* Greater */, that);
213
- }
214
- greaterOrEqual(that) {
215
- return binop(this, "GreaterOrEqual" /* GreaterOrEqual */, that);
216
- }
217
- less(that) {
218
- return binop(this, "Less" /* Less */, that);
219
- }
220
- lessOrEqual(that) {
221
- return binop(this, "LessOrEqual" /* LessOrEqual */, that);
222
- }
223
- concat(that) {
224
- return binop(this, "Concat" /* Concat */, that);
225
- }
226
- like(that) {
227
- return binop(this, "Like" /* Like */, that);
228
- }
229
- glob(that) {
230
- return binop(this, "Glob" /* Glob */, that);
231
- }
232
- match(that) {
233
- return binop(this, "Match" /* Match */, that);
234
- }
235
- with(that) {
236
- return new _Expr(
237
- ExprData.Merge(this.expr, ExprData.create(that))
238
- );
239
- }
240
- at(index) {
241
- return this.get(`[${Number(index)}]`);
242
- }
243
- filter(fn) {
244
- const alias = `__${Math.random().toString(36).slice(2, 9)}`;
245
- const target = Target.Each(this.expr, alias);
246
- return new _Expr(
247
- ExprData.Filter(
248
- target,
249
- ExprData.create(fn(new _Expr(ExprData.Row(target))))
250
- )
251
- );
252
- }
253
- map(fn) {
254
- const alias = `__${Math.random().toString(36).slice(2, 9)}`;
255
- const target = Target.Each(this.expr, alias);
256
- return new _Expr(
257
- ExprData.Map(
258
- target,
259
- ExprData.create(fn(new _Expr(ExprData.Row(target))))
260
- )
261
- );
262
- }
263
- sure() {
264
- return this;
265
- }
266
- get(name) {
267
- return new _Expr(ExprData.Field(this.expr, name));
268
- }
269
- };
270
- var Expr = _Expr;
271
- __publicField(Expr, "NULL", toExpr(null));
272
- function unop(self, type) {
273
- return new Expr(ExprData.UnOp(type, self.expr));
274
- }
275
- function binop(self, type, that) {
276
- return new Expr(ExprData.BinOp(type, self.expr, toExpr(that)));
277
- }
278
- export {
279
- BinOp,
280
- Expr,
281
- ExprData,
282
- ExprType,
283
- UnOp
284
- };
package/dist/Fields.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { Column } from './Column';
2
- import { Expr } from './Expr';
3
- type Field<T> = [T] extends [Array<any>] ? Expr<T> : [T] extends [Column.Optional & infer V] ? Field<V> : [T] extends [Record<string, any>] ? FieldsOf<T> : Expr<T>;
4
- type FieldsOf<Row> = Row extends Record<string, any> ? {
5
- [K in keyof Row]-?: Field<Row[K]>;
6
- } : never;
7
- type IsStrictlyAny<T> = (T extends never ? true : false) extends false ? false : true;
8
- export type Fields<T> = IsStrictlyAny<T> extends true ? any : Field<T>;
9
- export {};
package/dist/Fields.js DELETED
File without changes
@@ -1,50 +0,0 @@
1
- import { ColumnData, ColumnType } from './Column';
2
- import { ExprData } from './Expr';
3
- import { OrderBy } from './OrderBy';
4
- import { Query } from './Query';
5
- import { Sanitizer } from './Sanitizer';
6
- import { Statement } from './Statement';
7
- import { Target } from './Target';
8
- export interface FormatContext {
9
- nameResult?: string;
10
- formatAsJson?: boolean;
11
- formatSubject?: (subject: Statement) => Statement;
12
- }
13
- export declare abstract class Formatter implements Sanitizer {
14
- constructor();
15
- abstract escapeValue(value: any): string;
16
- abstract escapeIdentifier(ident: string): string;
17
- abstract formatSqlAccess(on: Statement, field: string): Statement;
18
- abstract formatJsonAccess(on: Statement, field: string): Statement;
19
- formatAccess(on: Statement, field: string, formatAsJson?: boolean): Statement;
20
- compile<T>(query: Query<T>, formatInline?: boolean): Statement.Compiled;
21
- format<T>(query: Query<T>, ctx?: FormatContext): Statement;
22
- formatSelect(query: Query.Select, ctx: FormatContext): Statement;
23
- formatInsert(query: Query.Insert, ctx: FormatContext): Statement;
24
- formatUpdate(query: Query.Update, ctx: FormatContext): Statement;
25
- formatDelete(query: Query.Delete, ctx: FormatContext): Statement;
26
- formatCreateTable(query: Query.CreateTable, ctx: FormatContext): Statement;
27
- formatTransaction({ op, id }: Query.Transaction, ctx: FormatContext): Statement;
28
- formatBatch(queries: Query[], ctx: FormatContext): Statement;
29
- formatRaw({ strings, params }: Query.Raw, ctx: FormatContext): Statement;
30
- formatColumn(column: ColumnData): Statement;
31
- formatType(type: ColumnType): Statement;
32
- formatInsertRow(columns: Record<string, ColumnData>, row: Record<string, any>): Statement;
33
- formatColumnValue(column: ColumnData, columnValue: any): Statement;
34
- formatTarget(target: Target, ctx: FormatContext): Statement;
35
- formatWhere(expr: ExprData | undefined, ctx: FormatContext): Statement | undefined;
36
- formatHaving(expr: ExprData | undefined, ctx: FormatContext): Statement | undefined;
37
- formatGroupBy(groupBy: Array<ExprData> | undefined, ctx: FormatContext): Statement | undefined;
38
- formatOrderBy(orderBy: Array<OrderBy> | undefined, ctx: FormatContext): Statement | undefined;
39
- formatLimit({ limit, offset, singleResult }: Query.QueryBase, ctx: FormatContext): Statement | undefined;
40
- formatSelection(selection: ExprData, ctx: FormatContext): Statement;
41
- formatExprValue(expr: ExprData, ctx: FormatContext): Statement;
42
- formatIn(expr: ExprData, ctx: FormatContext): Statement;
43
- formatUnwrapArray(stmt: Statement): Statement;
44
- retrieveField(expr: ExprData, field: string): ExprData | undefined;
45
- formatField(expr: ExprData, field: string, ctx: FormatContext): Statement;
46
- formatString(input: string): Statement;
47
- formatInlineValue(rawValue: any): Statement;
48
- formatValue(rawValue: any, formatAsJson?: boolean): Statement;
49
- formatExpr(expr: ExprData, ctx: FormatContext): Statement;
50
- }