squirreling 0.3.1 → 0.4.1

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/src/types.d.ts CHANGED
@@ -6,15 +6,13 @@
6
6
  export interface AsyncDataSource {
7
7
  getRows(): AsyncIterable<AsyncRow>
8
8
  }
9
- export interface AsyncRow {
10
- getCell(name: string): any
11
- getKeys(): string[]
12
- }
9
+ export type AsyncRow = Record<string, AsyncCell>
10
+ export type AsyncCell = () => Promise<SqlPrimitive>
13
11
 
14
- export type RawData = Record<string, any>[]
12
+ export type Row = Record<string, SqlPrimitive>[]
15
13
 
16
14
  export interface ExecuteSqlOptions {
17
- tables: Record<string, RawData | AsyncDataSource>
15
+ tables: Record<string, Row | AsyncDataSource>
18
16
  query: string
19
17
  }
20
18
 
@@ -23,7 +21,7 @@ export type SqlPrimitive = string | number | bigint | boolean | null
23
21
  export interface SelectStatement {
24
22
  distinct: boolean
25
23
  columns: SelectColumn[]
26
- from?: string | FromSubquery
24
+ from: FromTable | FromSubquery
27
25
  joins: JoinClause[]
28
26
  where?: ExprNode
29
27
  groupBy: ExprNode[]
@@ -33,6 +31,12 @@ export interface SelectStatement {
33
31
  offset?: number
34
32
  }
35
33
 
34
+ export interface FromTable {
35
+ kind: 'table'
36
+ table: string
37
+ alias?: string
38
+ }
39
+
36
40
  export interface FromSubquery {
37
41
  kind: 'subquery'
38
42
  query: SelectStatement
@@ -186,8 +190,9 @@ export interface OrderByItem {
186
190
  export type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS'
187
191
 
188
192
  export interface JoinClause {
189
- type: JoinType
193
+ joinType: JoinType
190
194
  table: string
195
+ alias?: string
191
196
  on?: ExprNode
192
197
  }
193
198