rado 0.2.13 → 0.2.15

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.
@@ -1,15 +1,11 @@
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
1
  // src/define/Expr.ts
9
2
  import { OrderDirection } from "./OrderBy.js";
10
3
  import { ParamData, ParamType } from "./Param.js";
11
4
  import { Target } from "./Target.js";
12
- var { fromEntries, entries, getPrototypeOf } = Object;
5
+ var { fromEntries, entries } = Object;
6
+ var TO_EXPR = Symbol("Expr.ToExpr");
7
+ var IS_EXPR = Symbol("Expr.IsExpr");
8
+ var DATA = Symbol("Expr.Data");
13
9
  var UnOpType = /* @__PURE__ */ ((UnOpType2) => {
14
10
  UnOpType2["Not"] = "Not";
15
11
  UnOpType2["IsNull"] = "IsNull";
@@ -52,237 +48,271 @@ var ExprType = /* @__PURE__ */ ((ExprType2) => {
52
48
  ExprType2["Case"] = "Case";
53
49
  return ExprType2;
54
50
  })(ExprType || {});
55
- var ExprData = {
56
- UnOp(op, expr) {
51
+ var ExprData;
52
+ ((ExprData2) => {
53
+ function UnOp(op, expr) {
57
54
  return { type: "UnOp" /* UnOp */, op, expr };
58
- },
59
- BinOp(op, a, b) {
55
+ }
56
+ ExprData2.UnOp = UnOp;
57
+ function BinOp(op, a, b) {
60
58
  return { type: "BinOp" /* BinOp */, op, a, b };
61
- },
62
- Field(expr, field) {
59
+ }
60
+ ExprData2.BinOp = BinOp;
61
+ function Field(expr, field) {
63
62
  return { type: "Field" /* Field */, expr, field };
64
- },
65
- Param(param) {
63
+ }
64
+ ExprData2.Field = Field;
65
+ function Param(param) {
66
66
  return { type: "Param" /* Param */, param };
67
- },
68
- Call(method, params) {
67
+ }
68
+ ExprData2.Param = Param;
69
+ function Call(method, params) {
69
70
  return { type: "Call" /* Call */, method, params };
70
- },
71
- Query(query) {
71
+ }
72
+ ExprData2.Call = Call;
73
+ function Query(query) {
72
74
  return { type: "Query" /* Query */, query };
73
- },
74
- Record(fields) {
75
+ }
76
+ ExprData2.Query = Query;
77
+ function Record(fields) {
75
78
  return { type: "Record" /* Record */, fields };
76
- },
77
- Merge(a, b) {
79
+ }
80
+ ExprData2.Record = Record;
81
+ function Merge(a, b) {
78
82
  return { type: "Merge" /* Merge */, a, b };
79
- },
80
- Row(target) {
83
+ }
84
+ ExprData2.Merge = Merge;
85
+ function Row(target) {
81
86
  return { type: "Row" /* Row */, target };
82
- },
83
- Map(target, result) {
87
+ }
88
+ ExprData2.Row = Row;
89
+ function Map(target, result) {
84
90
  return { type: "Map" /* Map */, target, result };
85
- },
86
- Filter(target, condition) {
91
+ }
92
+ ExprData2.Map = Map;
93
+ function Filter(target, condition) {
87
94
  return { type: "Filter" /* Filter */, target, condition };
88
- },
89
- Case(expr, cases, defaultCase) {
95
+ }
96
+ ExprData2.Filter = Filter;
97
+ function Case(expr, cases, defaultCase) {
90
98
  return { type: "Case" /* Case */, expr, cases, defaultCase };
91
- },
92
- create(input) {
99
+ }
100
+ ExprData2.Case = Case;
101
+ function create(input) {
93
102
  if (input === null || input === void 0)
94
- return ExprData.Param(ParamData.Value(null));
95
- if (input && (typeof input === "function" || typeof input === "object") && input[Expr.toExpr])
96
- input = input[Expr.toExpr]();
97
- if (input instanceof Expr)
98
- return input.expr;
103
+ return ExprData2.Param(ParamData.Value(null));
104
+ if (input && (typeof input === "function" || typeof input === "object") && input[TO_EXPR])
105
+ input = input[TO_EXPR]();
106
+ if (Expr.isExpr(input))
107
+ return input[DATA];
99
108
  if (input && typeof input === "object" && !Array.isArray(input))
100
- return ExprData.Record(
109
+ return ExprData2.Record(
101
110
  fromEntries(
102
- entries(input).map(([key, value]) => [key, ExprData.create(value)])
111
+ entries(input).map(([key, value]) => [key, ExprData2.create(value)])
103
112
  )
104
113
  );
105
- return ExprData.Param(ParamData.Value(input));
114
+ return ExprData2.Param(ParamData.Value(input));
106
115
  }
107
- };
108
- var toExpr = ExprData.create;
109
- function isConstant(e, value) {
110
- switch (e.type) {
111
- case "Param" /* Param */:
112
- switch (e.param.type) {
113
- case ParamType.Value:
114
- return e.param.value === value;
115
- default:
116
- return false;
117
- }
118
- default:
119
- return false;
120
- }
121
- }
122
- function dotAccess(expr, path) {
123
- return new Expr(ExprData.Field(expr.expr, path.join(".")));
124
- }
125
- function exprAccess(expr, ...path) {
126
- return new Proxy(expr, {
127
- apply(target, thisArg, args) {
128
- const proto = getPrototypeOf(expr);
129
- const method = path.pop();
130
- const e = path.length > 0 ? dotAccess(expr, path) : expr;
131
- return proto[method].apply(e, args);
132
- },
133
- get(_, key) {
134
- const e = path.length > 0 ? dotAccess(expr, path) : expr;
135
- if (key === "expr")
136
- return e.expr;
137
- if (typeof key !== "string")
138
- return e[key];
139
- return exprAccess(expr, ...path, key);
140
- }
141
- });
142
- }
143
- var callable = Function;
144
- var _Expr = class extends callable {
116
+ ExprData2.create = create;
117
+ })(ExprData || (ExprData = {}));
118
+ var Expr = class {
145
119
  constructor(expr) {
146
- super();
147
- this.expr = expr;
148
- return exprAccess(this);
149
- }
150
- static value(value) {
151
- return new _Expr(ExprData.Param(ParamData.Value(value)));
152
- }
153
- static create(input) {
154
- if (input instanceof _Expr)
155
- return input;
156
- return new _Expr(ExprData.create(input));
157
- }
158
- static and(...conditions) {
159
- return conditions.map(_Expr.create).reduce((condition, expr) => condition.and(expr), _Expr.value(true));
160
- }
161
- static or(...conditions) {
162
- return conditions.map(_Expr.create).reduce((condition, expr) => condition.or(expr), _Expr.value(false));
120
+ this[DATA] = expr;
163
121
  }
122
+ [DATA];
123
+ [IS_EXPR] = true;
164
124
  asc() {
165
- return { expr: this.expr, order: OrderDirection.Asc };
125
+ return { expr: this[DATA], order: OrderDirection.Asc };
166
126
  }
167
127
  desc() {
168
- return { expr: this.expr, order: OrderDirection.Desc };
128
+ return { expr: this[DATA], order: OrderDirection.Desc };
169
129
  }
170
130
  not() {
171
- return new _Expr(ExprData.UnOp("Not" /* Not */, this.expr));
131
+ return new Expr(ExprData.UnOp("Not" /* Not */, this[DATA]));
172
132
  }
173
133
  or(that) {
174
- const a = this.expr;
175
- const b = toExpr(that);
176
- if (isConstant(b, true) || isConstant(a, false))
177
- return new _Expr(b);
178
- if (isConstant(a, true) || isConstant(b, false))
134
+ const a = this;
135
+ const b = Expr.create(that);
136
+ if (b.isConstant(true) || a.isConstant(false))
137
+ return b;
138
+ if (a.isConstant(true) || b.isConstant(false))
179
139
  return this;
180
- return new _Expr(ExprData.BinOp("Or" /* Or */, a, b));
140
+ return new Expr(ExprData.BinOp("Or" /* Or */, a[DATA], b[DATA]));
181
141
  }
182
142
  and(that) {
183
- const a = this.expr;
184
- const b = toExpr(that);
185
- if (isConstant(b, true) || isConstant(a, false))
143
+ const a = this;
144
+ const b = Expr.create(that);
145
+ if (b.isConstant(true) || a.isConstant(false))
186
146
  return this;
187
- if (isConstant(a, true) || isConstant(b, false))
188
- return new _Expr(b);
189
- return new _Expr(ExprData.BinOp("And" /* And */, a, b));
147
+ if (a.isConstant(true) || b.isConstant(false))
148
+ return b;
149
+ return new Expr(ExprData.BinOp("And" /* And */, a[DATA], b[DATA]));
190
150
  }
191
151
  is(that) {
192
- if (that === null || that instanceof _Expr && isConstant(that.expr, null))
152
+ if (that === null || Expr.isExpr(that) && that.isConstant(null))
193
153
  return this.isNull();
194
- return new _Expr(ExprData.BinOp("Equals" /* Equals */, this.expr, toExpr(that)));
154
+ return new Expr(
155
+ ExprData.BinOp("Equals" /* Equals */, this[DATA], ExprData.create(that))
156
+ );
157
+ }
158
+ isConstant(value) {
159
+ switch (this[DATA].type) {
160
+ case "Param" /* Param */:
161
+ switch (this[DATA].param.type) {
162
+ case ParamType.Value:
163
+ return this[DATA].param.value === value;
164
+ default:
165
+ return false;
166
+ }
167
+ default:
168
+ return false;
169
+ }
195
170
  }
196
171
  isNot(that) {
197
- if (that === null || that instanceof _Expr && isConstant(that.expr, null))
172
+ if (that === null || Expr.isExpr(that) && that.isConstant(null))
198
173
  return this.isNotNull();
199
- return new _Expr(
200
- ExprData.BinOp("NotEquals" /* NotEquals */, this.expr, toExpr(that))
174
+ return new Expr(
175
+ ExprData.BinOp("NotEquals" /* NotEquals */, this[DATA], ExprData.create(that))
201
176
  );
202
177
  }
203
178
  isNull() {
204
- return new _Expr(ExprData.UnOp("IsNull" /* IsNull */, this.expr));
179
+ return new Expr(ExprData.UnOp("IsNull" /* IsNull */, this[DATA]));
205
180
  }
206
181
  isNotNull() {
207
182
  return this.isNull().not();
208
183
  }
209
184
  isIn(that) {
210
- return new _Expr(ExprData.BinOp("In" /* In */, this.expr, toExpr(that)));
185
+ return new Expr(
186
+ ExprData.BinOp("In" /* In */, this[DATA], ExprData.create(that))
187
+ );
211
188
  }
212
189
  isNotIn(that) {
213
- return new _Expr(ExprData.BinOp("NotIn" /* NotIn */, this.expr, toExpr(that)));
190
+ return new Expr(
191
+ ExprData.BinOp("NotIn" /* NotIn */, this[DATA], ExprData.create(that))
192
+ );
214
193
  }
215
194
  isGreater(that) {
216
- return new _Expr(ExprData.BinOp("Greater" /* Greater */, this.expr, toExpr(that)));
195
+ return new Expr(
196
+ ExprData.BinOp("Greater" /* Greater */, this[DATA], ExprData.create(that))
197
+ );
217
198
  }
218
199
  isGreaterOrEqual(that) {
219
- return new _Expr(
220
- ExprData.BinOp("GreaterOrEqual" /* GreaterOrEqual */, this.expr, toExpr(that))
200
+ return new Expr(
201
+ ExprData.BinOp(
202
+ "GreaterOrEqual" /* GreaterOrEqual */,
203
+ this[DATA],
204
+ ExprData.create(that)
205
+ )
221
206
  );
222
207
  }
223
208
  isLess(that) {
224
- return new _Expr(ExprData.BinOp("Less" /* Less */, this.expr, toExpr(that)));
209
+ return new Expr(
210
+ ExprData.BinOp("Less" /* Less */, this[DATA], ExprData.create(that))
211
+ );
225
212
  }
226
213
  isLessOrEqual(that) {
227
- return new _Expr(
228
- ExprData.BinOp("LessOrEqual" /* LessOrEqual */, this.expr, toExpr(that))
214
+ return new Expr(
215
+ ExprData.BinOp("LessOrEqual" /* LessOrEqual */, this[DATA], ExprData.create(that))
229
216
  );
230
217
  }
231
218
  add(that) {
232
- return new _Expr(ExprData.BinOp("Add" /* Add */, this.expr, toExpr(that)));
219
+ return new Expr(
220
+ ExprData.BinOp("Add" /* Add */, this[DATA], ExprData.create(that))
221
+ );
233
222
  }
234
223
  substract(that) {
235
- return new _Expr(ExprData.BinOp("Subt" /* Subt */, this.expr, toExpr(that)));
224
+ return new Expr(
225
+ ExprData.BinOp("Subt" /* Subt */, this[DATA], ExprData.create(that))
226
+ );
236
227
  }
237
228
  multiply(that) {
238
- return new _Expr(ExprData.BinOp("Mult" /* Mult */, this.expr, toExpr(that)));
229
+ return new Expr(
230
+ ExprData.BinOp("Mult" /* Mult */, this[DATA], ExprData.create(that))
231
+ );
239
232
  }
240
233
  remainder(that) {
241
- return new _Expr(ExprData.BinOp("Mod" /* Mod */, this.expr, toExpr(that)));
234
+ return new Expr(
235
+ ExprData.BinOp("Mod" /* Mod */, this[DATA], ExprData.create(that))
236
+ );
242
237
  }
243
238
  divide(that) {
244
- return new _Expr(ExprData.BinOp("Div" /* Div */, this.expr, toExpr(that)));
239
+ return new Expr(
240
+ ExprData.BinOp("Div" /* Div */, this[DATA], ExprData.create(that))
241
+ );
245
242
  }
246
243
  concat(that) {
247
- return new _Expr(ExprData.BinOp("Concat" /* Concat */, this.expr, toExpr(that)));
244
+ return new Expr(
245
+ ExprData.BinOp("Concat" /* Concat */, this[DATA], ExprData.create(that))
246
+ );
248
247
  }
249
248
  like(that) {
250
- return new _Expr(ExprData.BinOp("Like" /* Like */, this.expr, toExpr(that)));
249
+ return new Expr(
250
+ ExprData.BinOp("Like" /* Like */, this[DATA], ExprData.create(that))
251
+ );
251
252
  }
252
253
  glob(that) {
253
- return new _Expr(ExprData.BinOp("Glob" /* Glob */, this.expr, toExpr(that)));
254
+ return new Expr(
255
+ ExprData.BinOp("Glob" /* Glob */, this[DATA], ExprData.create(that))
256
+ );
254
257
  }
255
258
  match(that) {
256
- return new _Expr(ExprData.BinOp("Match" /* Match */, this.expr, toExpr(that)));
259
+ return new Expr(
260
+ ExprData.BinOp("Match" /* Match */, this[DATA], ExprData.create(that))
261
+ );
257
262
  }
258
263
  with(that) {
259
- return new _Expr(
260
- ExprData.Merge(this.expr, ExprData.create(that))
264
+ return new Expr(
265
+ ExprData.Merge(this[DATA], ExprData.create(that))
266
+ );
267
+ }
268
+ /**
269
+ * Dynamic expressions allow accessing runtime fields of JSON properties
270
+ * through a Proxy.
271
+ *
272
+ * Expr.value({a: {b: 1}}).dynamic().a.b.is(1) // true
273
+ **/
274
+ dynamic(...path) {
275
+ return new Proxy(
276
+ (...args) => {
277
+ const method = path.pop();
278
+ const e = path.length > 0 ? this.get(path.join(".")) : this;
279
+ return e[method]?.apply(e, args);
280
+ },
281
+ {
282
+ get: (_, key) => {
283
+ const e = path.length > 0 ? this.get(path.join(".")) : this;
284
+ if (key === "expr")
285
+ return e[DATA];
286
+ if (typeof key !== "string")
287
+ return e[key];
288
+ return this.dynamic(...path, key);
289
+ }
290
+ }
261
291
  );
262
292
  }
263
293
  at(index) {
264
294
  return this.get(`[${Number(index)}]`);
265
295
  }
266
296
  includes(value) {
267
- return _Expr.create(value).isIn(this);
297
+ return Expr.create(value).isIn(this);
268
298
  }
269
299
  filter(fn) {
270
300
  const alias = `__${Math.random().toString(36).slice(2, 9)}`;
271
- const target = Target.Expr(this.expr, alias);
272
- return new _Expr(
301
+ const target = Target.Expr(this[DATA], alias);
302
+ return new Expr(
273
303
  ExprData.Filter(
274
304
  target,
275
- ExprData.create(fn(new _Expr(ExprData.Row(target))))
305
+ ExprData.create(fn(new Expr(ExprData.Row(target)).dynamic()))
276
306
  )
277
307
  );
278
308
  }
279
309
  map(fn) {
280
310
  const alias = `__${Math.random().toString(36).slice(2, 9)}`;
281
- const target = Target.Expr(this.expr, alias);
282
- return new _Expr(
311
+ const target = Target.Expr(this[DATA], alias);
312
+ return new Expr(
283
313
  ExprData.Map(
284
314
  target,
285
- ExprData.create(fn(new _Expr(ExprData.Row(target))))
315
+ ExprData.create(fn(new Expr(ExprData.Row(target)).dynamic()))
286
316
  )
287
317
  );
288
318
  }
@@ -290,12 +320,37 @@ var _Expr = class extends callable {
290
320
  return this;
291
321
  }
292
322
  get(name) {
293
- return new _Expr(ExprData.Field(this.expr, name));
323
+ return new Expr(ExprData.Field(this[DATA], name));
294
324
  }
295
325
  };
296
- var Expr = _Expr;
297
- __publicField(Expr, "NULL", _Expr.create(null));
298
- __publicField(Expr, "toExpr", Symbol("toExpr"));
326
+ ((Expr2) => {
327
+ Expr2.NULL = create(null);
328
+ Expr2.Data = DATA;
329
+ Expr2.IsExpr = IS_EXPR;
330
+ Expr2.ToExpr = TO_EXPR;
331
+ function value(value2) {
332
+ return new Expr2(ExprData.Param(ParamData.Value(value2)));
333
+ }
334
+ Expr2.value = value;
335
+ function create(input) {
336
+ if (isExpr(input))
337
+ return input;
338
+ return new Expr2(ExprData.create(input));
339
+ }
340
+ Expr2.create = create;
341
+ function and(...conditions) {
342
+ return conditions.map(create).reduce((condition, expr) => condition.and(expr), value(true));
343
+ }
344
+ Expr2.and = and;
345
+ function or(...conditions) {
346
+ return conditions.map(create).reduce((condition, expr) => condition.or(expr), value(false));
347
+ }
348
+ Expr2.or = or;
349
+ function isExpr(input) {
350
+ return input !== null && (typeof input === "object" || typeof input === "function") && input[IS_EXPR];
351
+ }
352
+ Expr2.isExpr = isExpr;
353
+ })(Expr || (Expr = {}));
299
354
  export {
300
355
  BinOpType,
301
356
  Expr,
@@ -5,7 +5,7 @@ function get(_, method) {
5
5
  return new Expr(ExprData.Call(method, args.map(ExprData.create)));
6
6
  };
7
7
  }
8
- var Functions = new Proxy({}, { get });
8
+ var Functions = new Proxy(/* @__PURE__ */ Object.create(null), { get });
9
9
  export {
10
10
  Functions
11
11
  };
@@ -3,7 +3,7 @@ import { Cursor } from "./Cursor.js";
3
3
  import { ExprData } from "./Expr.js";
4
4
  import { Query } from "./Query.js";
5
5
  import { Schema } from "./Schema.js";
6
- import { table as createTable } from "./Table.js";
6
+ import { Table } from "./Table.js";
7
7
  import { Target } from "./Target.js";
8
8
  function select(selection) {
9
9
  return new Cursor.SelectMultiple(
@@ -13,7 +13,7 @@ function select(selection) {
13
13
  );
14
14
  }
15
15
  function from(source) {
16
- const target = source instanceof Cursor ? Target.Query(source.query()) : Target.Table(source[createTable.data]);
16
+ const target = source instanceof Cursor ? Target.Query(source[Cursor.Query]) : Target.Table(source[Table.Data]);
17
17
  return new Cursor.SelectMultiple(
18
18
  Query.Select({
19
19
  from: target,
@@ -22,17 +22,17 @@ function from(source) {
22
22
  );
23
23
  }
24
24
  function update(table) {
25
- return new Cursor.Update(Query.Update({ table: table[createTable.data] }));
25
+ return new Cursor.Update(Query.Update({ table: table[Table.Data] }));
26
26
  }
27
27
  function insertInto(table) {
28
- return new Cursor.Insert(table[createTable.data]);
28
+ return new Cursor.Insert(table[Table.Data]);
29
29
  }
30
30
  function deleteFrom(table) {
31
- return new Cursor.Delete(Query.Delete({ table: table[createTable.data] }));
31
+ return new Cursor.Delete(Query.Delete({ table: table[Table.Data] }));
32
32
  }
33
33
  function create(...tables) {
34
34
  return new Cursor.Batch(
35
- tables.flatMap((table) => Schema.create(table[createTable.data]).queries)
35
+ tables.flatMap((table) => Schema.create(table[Table.Data]).queries)
36
36
  );
37
37
  }
38
38
  export {
@@ -33,7 +33,7 @@ var Schema;
33
33
  Object.fromEntries(
34
34
  Object.entries(table.columns).map(([key, column]) => [
35
35
  key,
36
- addedColumns.has(key) ? (typeof column.defaultValue === "function" ? column.defaultValue() : column.defaultValue) || Expr.NULL.expr : ExprData.Field(ExprData.Row(Target.Table(table)), key)
36
+ addedColumns.has(key) ? (typeof column.defaultValue === "function" ? column.defaultValue() : column.defaultValue) || Expr.NULL[Expr.Data] : ExprData.Field(ExprData.Row(Target.Table(table)), key)
37
37
  ])
38
38
  )
39
39
  )
@@ -5,12 +5,12 @@ interface SelectionRecord extends Record<string, Selection> {
5
5
  }
6
6
  export type Selection = SelectionBase | SelectionRecord;
7
7
  export declare namespace Selection {
8
- const __tableType: unique symbol;
9
- const __cursorType: unique symbol;
8
+ const TableType: unique symbol;
9
+ const CursorType: unique symbol;
10
10
  type Infer<T> = T extends {
11
- [__tableType](): infer K;
11
+ [TableType](): infer K;
12
12
  } ? K : T extends {
13
- [__cursorType](): infer K;
13
+ [CursorType](): infer K;
14
14
  } ? K : T extends Expr<infer K> ? K : T extends Record<string, Selection> ? {
15
15
  [K in keyof T]: Infer<T[K]>;
16
16
  } : T extends () => any ? never : unknown extends T ? never : T;
@@ -3,6 +3,8 @@ import { Cursor } from './Cursor';
3
3
  import { EV } from './Expr';
4
4
  import { Index, IndexData } from './Index';
5
5
  import { Selection } from './Selection';
6
+ declare const DATA: unique symbol;
7
+ declare const META: unique symbol;
6
8
  interface TableDefinition {
7
9
  }
8
10
  export interface TableData {
@@ -21,8 +23,8 @@ export interface TableInstance<Definition> {
21
23
  (...conditions: Array<EV<boolean>>): Cursor.TableSelect<Definition>;
22
24
  }
23
25
  export declare class TableInstance<Definition> {
24
- [Selection.__tableType](): Table.Select<Definition>;
25
- get [table.data](): TableData;
26
+ [Selection.TableType](): Table.Select<Definition>;
27
+ get [DATA](): TableData;
26
28
  get name(): unknown;
27
29
  get length(): unknown;
28
30
  get call(): unknown;
@@ -32,6 +34,8 @@ export declare class TableInstance<Definition> {
32
34
  }
33
35
  export type Table<Definition> = Definition & TableInstance<Definition>;
34
36
  export declare namespace Table {
37
+ export const Data: typeof DATA;
38
+ export const Meta: typeof META;
35
39
  export type Of<Row> = Table<{
36
40
  [K in keyof Row as K extends string ? K : never]: Column<Row[K]>;
37
41
  }>;
@@ -52,18 +56,16 @@ export declare namespace Table {
52
56
  export interface TableMeta {
53
57
  indexes?: Record<string, Index>;
54
58
  }
55
- type Definition<T> = {
59
+ type Blueprint<T> = {
56
60
  [K in keyof T as K extends string ? K : never]: Column<any> | (() => any);
57
61
  };
58
62
  interface Define<T> {
59
63
  new (): T;
60
64
  }
61
- type Blueprint<T> = Definition<T>;
62
65
  export type table<T> = T extends Table<infer D> ? Table.Select<D> : never;
63
66
  export declare function createTable<Definition>(data: TableData): Table<Definition>;
64
67
  export declare function table<T extends Blueprint<T>>(define: Record<string, T | Define<T>>): Table<T>;
65
68
  export declare namespace table {
66
- const data: unique symbol;
67
- const meta: unique symbol;
69
+ const meta: typeof META;
68
70
  }
69
71
  export {};