forj 0.0.1 → 0.0.3

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,163 +0,0 @@
1
- import z from 'zod';
2
-
3
- declare class QueryBuilder<S, T, C extends keyof T = keyof T> implements IJoinBuilder<S>, IClauseBuilder<T> {
4
- #private;
5
- constructor(table: string, schema?: DBSchema, pipe?: Pipe<S, T, C>);
6
- run(): Promise<Result<T, C>>;
7
- first<K extends keyof T>(...columns: K[] | K[][]): Promise<null | Item<T, C>>;
8
- all<K extends keyof T>(...columns: K[] | K[][]): Promise<Item<T, C>[]>;
9
- select<K extends keyof T>(...columns: K[] | K[][]): QueryBuilder<S, T, K>;
10
- distinct(): this;
11
- join<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
12
- innerJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
13
- leftJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
14
- rightJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
15
- crossJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
16
- where(...args: WhereArgs<T>): this;
17
- on(...args: WhereArgs<T>): this;
18
- orWhere(...args: WhereArgs<T>): this;
19
- orOn(...args: WhereArgs<T>): this;
20
- whereIn(column: C, values: T[C][]): this;
21
- in(column: C, values: T[C][]): this;
22
- whereNotIn(column: C, values: T[C][]): this;
23
- notIn(column: C, values: T[C][]): this;
24
- orWhereIn(column: C, values: T[C][]): this;
25
- orIn(column: C, values: T[C][]): this;
26
- orWhereNotIn(column: C, values: T[C][]): this;
27
- orNotIn(column: C, values: T[C][]): this;
28
- whereBetween(column: C, one: T[C], two: T[C]): this;
29
- between(column: C, one: T[C], two: T[C]): this;
30
- orWhereBetween(column: C, one: T[C], two: T[C]): this;
31
- orBetween(column: C, one: T[C], two: T[C]): this;
32
- whereNotBetween(column: C, one: T[C], two: T[C]): this;
33
- notBetween(column: C, one: T[C], two: T[C]): this;
34
- orWhereNotBetween(column: C, one: T[C], two: T[C]): this;
35
- orNotBetween(column: C, one: T[C], two: T[C]): this;
36
- whereNull(column: C): this;
37
- onNull(column: C): this;
38
- orWhereNull(column: C): this;
39
- orOnNull(column: C): this;
40
- whereNotNull(column: C): this;
41
- onNotNull(column: C): this;
42
- orWhereNotNull(column: C): this;
43
- orNotNull(column: C): this;
44
- groupBy(...columns: string[]): this;
45
- order(column: C, direction?: OrderDirection): this;
46
- orderBy(column: C, direction?: OrderDirection): this;
47
- asc(column: C): this;
48
- desc(column: C): this;
49
- limit(val: number | string): this;
50
- offset(val: number | string): this;
51
- get args(): Values;
52
- get arguments(): Values;
53
- get bindings(): Values;
54
- get query(): string;
55
- get sql(): string;
56
- get raw(): string;
57
- }
58
-
59
- type Primitive = null | number | string | boolean;
60
- type Value = Primitive | undefined;
61
- type Values = Value[];
62
- type Operator = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'LIKE';
63
- type OrderDirection = 'ASC' | 'DESC' | 'asc' | 'desc';
64
- type DBSchema = z.ZodObject<any>;
65
- type SchemaObject = Record<string, z.ZodTypeAny>;
66
- type SchemaKeys<TSchema extends DBSchema> = TSchema extends z.ZodObject<infer TShape> ? keyof TShape : TSchema extends SchemaObject ? keyof TSchema : never;
67
- type RunFn<S, T, C extends keyof T = keyof T> = (qb: QueryBuilder<S, T, C>) => Promise<Result<T, C>>;
68
- type Pipe<S, T, C extends keyof T = keyof T> = {
69
- run: RunFn<S, T, C>;
70
- };
71
- type Result<T, C extends keyof T> = {
72
- changes: number;
73
- duration: number;
74
- lastId?: number | string;
75
- rowsRead: number;
76
- rowsWritten: number;
77
- success: boolean;
78
- results: Item<T, C>[];
79
- };
80
- type Item<B, S extends keyof B, T = Pick<B, S>> = {
81
- [K in keyof T]: T[K];
82
- } & {};
83
- type WhereFn<T, C extends keyof T = keyof T> = (q: IClauseBuilder<T, C>) => void;
84
- type WhereArgs<T, C extends keyof T = keyof T> = [WhereFn<T, C>] | [C, T[C]] | [C, Operator, T[C]];
85
- interface IClauseBuilder<T, C extends keyof T = keyof T> {
86
- where(fn: WhereFn<T, C>): this;
87
- where(column: C, value: T[C]): this;
88
- where(column: C, operator: Operator, value: T[C]): this;
89
- where(...args: WhereArgs<T>): this;
90
- on(fn: WhereFn<T, C>): this;
91
- on(column: C, value: T[C]): this;
92
- on(column: C, operator: Operator, value: T[C]): this;
93
- on(...args: WhereArgs<T>): this;
94
- orWhere(fn: WhereFn<T, C>): this;
95
- orWhere(column: C, value: T[C]): this;
96
- orWhere(column: C, operator: Operator, value: T[C]): this;
97
- orWhere(...args: WhereArgs<T>): this;
98
- orOn(fn: WhereFn<T, C>): this;
99
- orOn(column: C, value: T[C]): this;
100
- orOn(column: C, operator: Operator, value: T[C]): this;
101
- orOn(...args: WhereArgs<T>): this;
102
- whereIn(column: C, values: T[C][]): this;
103
- in(column: C, values: T[C][]): this;
104
- whereNotIn(column: C, values: T[C][]): this;
105
- notIn(column: C, values: T[C][]): this;
106
- orWhereIn(column: C, values: T[C][]): this;
107
- orIn(column: C, values: T[C][]): this;
108
- orWhereNotIn(column: C, values: T[C][]): this;
109
- orNotIn(column: C, values: T[C][]): this;
110
- whereBetween(column: C, one: T[C], two: T[C]): this;
111
- between(column: C, one: T[C], two: T[C]): this;
112
- orWhereBetween(column: C, one: T[C], two: T[C]): this;
113
- orBetween(column: C, one: T[C], two: T[C]): this;
114
- whereNotBetween(column: C, one: T[C], two: T[C]): this;
115
- notBetween(column: C, one: T[C], two: T[C]): this;
116
- orWhereNotBetween(column: C, one: T[C], two: T[C]): this;
117
- orNotBetween(column: C, one: T[C], two: T[C]): this;
118
- whereNull(column: C): this;
119
- onNull(column: C): this;
120
- orWhereNull(column: C): this;
121
- orOnNull(column: C): this;
122
- whereNotNull(column: C): this;
123
- onNotNull(column: C): this;
124
- orWhereNotNull(column: C): this;
125
- orNotNull(column: C): this;
126
- }
127
- type JoinArgs<S, J extends keyof S> = [
128
- WhereFn<S[J]>
129
- ] | [keyof S[J], S[J][keyof S[J]]] | [keyof S[J], Operator, S[J][keyof S[J]]] | [keyof S[J], keyof S, keyof S[keyof S]] | [keyof S[J], Operator, S[J][keyof S[J]]] | [keyof S[J], Operator, keyof S, keyof S[keyof S]];
130
- interface IJoinBuilder<S> {
131
- join<J extends keyof S>(table: J, fn: WhereFn<S[J]>): this;
132
- join<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, value: T[C]): this;
133
- join<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, operator: Operator, value: T[C]): this;
134
- join<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, table2: J2, column2: C2): this;
135
- join<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, operator: Operator, table2: J2, column2: C2): this;
136
- join<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
137
- innerJoin<J extends keyof S>(table: J, fn: WhereFn<S[J]>): this;
138
- innerJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, value: T[C]): this;
139
- innerJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, operator: Operator, value: T[C]): this;
140
- innerJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, table2: J2, column2: C2): this;
141
- innerJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, operator: Operator, table2: J2, column2: C2): this;
142
- innerJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
143
- leftJoin<J extends keyof S>(table: J, fn: WhereFn<S[J]>): this;
144
- leftJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, value: T[C]): this;
145
- leftJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, operator: Operator, value: T[C]): this;
146
- leftJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, table2: J2, column2: C2): this;
147
- leftJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, operator: Operator, table2: J2, column2: C2): this;
148
- leftJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
149
- rightJoin<J extends keyof S>(table: J, fn: WhereFn<S[J]>): this;
150
- rightJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, value: T[C]): this;
151
- rightJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, operator: Operator, value: T[C]): this;
152
- rightJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, table2: J2, column2: C2): this;
153
- rightJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, operator: Operator, table2: J2, column2: C2): this;
154
- rightJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
155
- crossJoin<J extends keyof S>(table: J, fn: WhereFn<S[J]>): this;
156
- crossJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, value: T[C]): this;
157
- crossJoin<J extends keyof S, T extends S[J], C extends keyof T>(table: J, column: C, operator: Operator, value: T[C]): this;
158
- crossJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, table2: J2, column2: C2): this;
159
- crossJoin<J extends keyof S, T extends S[J], C extends keyof T, J2 extends keyof S, C2 extends keyof S[J2]>(table: J, column: C, operator: Operator, table2: J2, column2: C2): this;
160
- crossJoin<J extends keyof S>(table: J, ...args: JoinArgs<S, J>): this;
161
- }
162
-
163
- export { type DBSchema as D, type Operator as O, type Pipe as P, QueryBuilder as Q, type RunFn as R, type SchemaKeys as S, type WhereFn as W, type OrderDirection as a };
@@ -1,2 +0,0 @@
1
- export { Q as QueryBuilder } from './index-CwrzXlna.js';
2
- import 'zod';
package/dist/index.ts.js DELETED
@@ -1 +0,0 @@
1
- export{QueryBuilder}from"./chunk-NVO75XBO.js";