sasat 0.21.21 → 0.22.0
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/index.cjs +4709 -930
- package/dist/index.d.cts +1047 -987
- package/dist/index.d.mts +1047 -987
- package/dist/index.mjs +4677 -912
- package/package.json +22 -25
- package/dist/cli/cli.cjs +0 -5626
- package/dist/cli/cli.d.cts +0 -1
- package/dist/cli/cli.d.mts +0 -1
- package/dist/cli/cli.d.ts +0 -1
- package/dist/cli/cli.mjs +0 -5601
- package/dist/index.d.ts +0 -1167
- package/dist/shared/sasat.CFfsuShk.mjs +0 -398
- package/dist/shared/sasat.DHiyRw3a.cjs +0 -436
package/dist/index.d.ts
DELETED
|
@@ -1,1167 +0,0 @@
|
|
|
1
|
-
import pkg from 'sqlstring';
|
|
2
|
-
import { GraphQLResolveInfo } from 'graphql/type';
|
|
3
|
-
import Hashids from 'hashids';
|
|
4
|
-
import { NestedPartial as NestedPartial$1 } from 'util/type';
|
|
5
|
-
import { GraphQLResolveInfo as GraphQLResolveInfo$1 } from 'graphql';
|
|
6
|
-
import * as mysql2 from 'mysql2';
|
|
7
|
-
|
|
8
|
-
type ComparisonOperators = '=' | '>' | '<' | '>=' | '<=' | '<>';
|
|
9
|
-
type AndOr = 'AND' | 'OR';
|
|
10
|
-
type ComparisonExpression$1<T> = Partial<{
|
|
11
|
-
[P in keyof T]: T[P] | [ComparisonOperators | 'LIKE' | 'NOT LIKE', T[P]] | ['BETWEEN', T[P], T[P]] | ['IN', ...T[P][]] | ['IS NULL'] | ['IS NOT NULL'];
|
|
12
|
-
}> & {
|
|
13
|
-
__type?: AndOr;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
declare enum QueryNodeKind {
|
|
17
|
-
Field = 0,
|
|
18
|
-
Function = 1,
|
|
19
|
-
Table = 2,
|
|
20
|
-
Join = 3,
|
|
21
|
-
CompoundExpr = 4,
|
|
22
|
-
ComparisonExpr = 5,
|
|
23
|
-
IsNullExpr = 6,
|
|
24
|
-
Parenthesis = 7,
|
|
25
|
-
InExpr = 8,
|
|
26
|
-
BetweenExpr = 9,
|
|
27
|
-
ContainsExpr = 10,
|
|
28
|
-
Literal = 11,
|
|
29
|
-
Sort = 12,
|
|
30
|
-
Identifier = 13,
|
|
31
|
-
Exists = 14,
|
|
32
|
-
Raw = 15,
|
|
33
|
-
GroupBy = 16,
|
|
34
|
-
Over = 17,
|
|
35
|
-
Window = 18
|
|
36
|
-
}
|
|
37
|
-
type LockMode = 'FOR UPDATE' | 'FOR SHARE';
|
|
38
|
-
type Query = {
|
|
39
|
-
select: SelectExpr[];
|
|
40
|
-
from: QueryTable;
|
|
41
|
-
where?: BooleanValueExpression;
|
|
42
|
-
groupBy?: GroupByExpr;
|
|
43
|
-
having?: BooleanValueExpression;
|
|
44
|
-
sort?: Sort[];
|
|
45
|
-
limit?: number;
|
|
46
|
-
offset?: number;
|
|
47
|
-
lock?: LockMode;
|
|
48
|
-
};
|
|
49
|
-
type GroupByExpr = {
|
|
50
|
-
kind: QueryNodeKind.GroupBy;
|
|
51
|
-
cols: (Field | Identifier)[];
|
|
52
|
-
};
|
|
53
|
-
type Field = {
|
|
54
|
-
kind: QueryNodeKind.Field;
|
|
55
|
-
table: string;
|
|
56
|
-
name: string;
|
|
57
|
-
alias?: string;
|
|
58
|
-
};
|
|
59
|
-
type Fn = {
|
|
60
|
-
kind: QueryNodeKind.Function;
|
|
61
|
-
fnName: string;
|
|
62
|
-
args: Value[];
|
|
63
|
-
over?: Over;
|
|
64
|
-
alias?: string;
|
|
65
|
-
};
|
|
66
|
-
type Over = {
|
|
67
|
-
kind: QueryNodeKind.Over;
|
|
68
|
-
orderBy?: Sort[];
|
|
69
|
-
partitionBy?: Identifier[];
|
|
70
|
-
window?: Window;
|
|
71
|
-
};
|
|
72
|
-
type Window = {
|
|
73
|
-
kind: QueryNodeKind.Window;
|
|
74
|
-
type: 'ROWS' | 'RANGE';
|
|
75
|
-
between: true;
|
|
76
|
-
start: WindowContent;
|
|
77
|
-
end: WindowContent;
|
|
78
|
-
} | {
|
|
79
|
-
kind: QueryNodeKind.Window;
|
|
80
|
-
type: 'ROWS' | 'RANGE';
|
|
81
|
-
between: false;
|
|
82
|
-
value: WindowContent;
|
|
83
|
-
};
|
|
84
|
-
type WINDOW_TYPES_NO_ARG = 'UNBOUNDED PRECEDING' | 'UNBOUNDED FOLLOWING' | 'CURRENT ROW';
|
|
85
|
-
type WINDOW_TYPES_ARG = 'PRECEDING' | 'FOLLOWING';
|
|
86
|
-
type WindowContent = {
|
|
87
|
-
type: WINDOW_TYPES_NO_ARG;
|
|
88
|
-
} | {
|
|
89
|
-
type: WINDOW_TYPES_ARG;
|
|
90
|
-
value: number;
|
|
91
|
-
};
|
|
92
|
-
type SelectExpr = Field | Fn | Identifier | RawExpression;
|
|
93
|
-
type QueryTable = {
|
|
94
|
-
kind: QueryNodeKind.Table;
|
|
95
|
-
alias: string;
|
|
96
|
-
joins: Join[];
|
|
97
|
-
} & ({
|
|
98
|
-
subquery?: false;
|
|
99
|
-
name: string;
|
|
100
|
-
} | {
|
|
101
|
-
subquery: true;
|
|
102
|
-
query: Query;
|
|
103
|
-
});
|
|
104
|
-
type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'OUTER';
|
|
105
|
-
type Join = {
|
|
106
|
-
kind: QueryNodeKind.Join;
|
|
107
|
-
type?: JoinType;
|
|
108
|
-
table: QueryTable;
|
|
109
|
-
conditions: BooleanValueExpression;
|
|
110
|
-
};
|
|
111
|
-
type ParenthesisExpression = {
|
|
112
|
-
kind: QueryNodeKind.Parenthesis;
|
|
113
|
-
expression: BooleanValueExpression;
|
|
114
|
-
};
|
|
115
|
-
type RawExpression = {
|
|
116
|
-
kind: QueryNodeKind.Raw;
|
|
117
|
-
expr: string;
|
|
118
|
-
};
|
|
119
|
-
type ExistsExpression = {
|
|
120
|
-
kind: QueryNodeKind.Exists;
|
|
121
|
-
query: Query | RawExpression;
|
|
122
|
-
};
|
|
123
|
-
type BooleanValueExpression = CompoundExpression | ComparisonExpression | IsNullExpression | ParenthesisExpression | InExpression | BetweenExpression | ContainsExpression | ExistsExpression;
|
|
124
|
-
type IsNullExpression = {
|
|
125
|
-
kind: QueryNodeKind.IsNullExpr;
|
|
126
|
-
expr: Value;
|
|
127
|
-
isNot: boolean;
|
|
128
|
-
};
|
|
129
|
-
type CompoundOperator = 'AND' | 'OR';
|
|
130
|
-
type CompoundExpression = {
|
|
131
|
-
kind: QueryNodeKind.CompoundExpr;
|
|
132
|
-
left: BooleanValueExpression;
|
|
133
|
-
operator: CompoundOperator;
|
|
134
|
-
right: BooleanValueExpression;
|
|
135
|
-
};
|
|
136
|
-
type ComparisonExpression = {
|
|
137
|
-
kind: QueryNodeKind.ComparisonExpr;
|
|
138
|
-
left: Value;
|
|
139
|
-
operator: ComparisonOperators;
|
|
140
|
-
right: Value;
|
|
141
|
-
};
|
|
142
|
-
type ContainType = 'start' | 'end' | 'contains';
|
|
143
|
-
type ContainsExpression = {
|
|
144
|
-
kind: QueryNodeKind.ContainsExpr;
|
|
145
|
-
type: ContainType;
|
|
146
|
-
left: Value;
|
|
147
|
-
isNot: boolean;
|
|
148
|
-
right: string;
|
|
149
|
-
};
|
|
150
|
-
type InExpression = {
|
|
151
|
-
kind: QueryNodeKind.InExpr;
|
|
152
|
-
left: Value;
|
|
153
|
-
operator: 'IN' | 'NOT IN';
|
|
154
|
-
} & ({
|
|
155
|
-
query: Query | RawExpression;
|
|
156
|
-
} | {
|
|
157
|
-
right: Value[];
|
|
158
|
-
});
|
|
159
|
-
type BetweenExpression = {
|
|
160
|
-
kind: QueryNodeKind.BetweenExpr;
|
|
161
|
-
left: Value;
|
|
162
|
-
begin: Value;
|
|
163
|
-
end: Value;
|
|
164
|
-
};
|
|
165
|
-
type Value = Literal | Field | Fn | Identifier;
|
|
166
|
-
type Identifier = {
|
|
167
|
-
kind: QueryNodeKind.Identifier;
|
|
168
|
-
identifier: string;
|
|
169
|
-
};
|
|
170
|
-
type Literal = {
|
|
171
|
-
kind: QueryNodeKind.Literal;
|
|
172
|
-
value: string | boolean | number | null;
|
|
173
|
-
};
|
|
174
|
-
type SortDirection = 'ASC' | 'DESC';
|
|
175
|
-
type Sort = {
|
|
176
|
-
kind: QueryNodeKind.Sort;
|
|
177
|
-
field: Field | Fn | Identifier;
|
|
178
|
-
direction?: SortDirection;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
declare const queryToSql: (query: Query) => string;
|
|
182
|
-
|
|
183
|
-
type NestedPartial<T> = {
|
|
184
|
-
[K in keyof T]?: T[K] extends Array<infer R> ? Array<NestedPartial<R>> : NestedPartial<T[K]>;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
interface SasatConfigDb {
|
|
188
|
-
host: string;
|
|
189
|
-
port: number;
|
|
190
|
-
user: string;
|
|
191
|
-
password?: string;
|
|
192
|
-
database: string;
|
|
193
|
-
ssl?: {
|
|
194
|
-
ca?: string[];
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
interface SasatConfigMigration {
|
|
198
|
-
table: string;
|
|
199
|
-
dir: string;
|
|
200
|
-
out: string;
|
|
201
|
-
target?: string;
|
|
202
|
-
db?: SasatConfigDb;
|
|
203
|
-
}
|
|
204
|
-
interface SasatConfigGenerator {
|
|
205
|
-
addJsExtToImportStatement: boolean;
|
|
206
|
-
gql: {
|
|
207
|
-
subscription: boolean;
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
interface SasatConfig {
|
|
211
|
-
db: SasatConfigDb;
|
|
212
|
-
migration: SasatConfigMigration;
|
|
213
|
-
generator: SasatConfigGenerator;
|
|
214
|
-
}
|
|
215
|
-
declare function setConfig(update: NestedPartial<SasatConfig>): SasatConfig;
|
|
216
|
-
|
|
217
|
-
declare const formatQuery: (str: TemplateStringsArray, ...params: any[]) => string;
|
|
218
|
-
|
|
219
|
-
type QueryResponse = Array<{
|
|
220
|
-
[key: string]: SqlValueType;
|
|
221
|
-
}>;
|
|
222
|
-
interface CommandResponse {
|
|
223
|
-
insertId: number;
|
|
224
|
-
affectedRows: number;
|
|
225
|
-
changedRows: number;
|
|
226
|
-
}
|
|
227
|
-
type SqlValueType = string | number | boolean | null;
|
|
228
|
-
interface SQLExecutor {
|
|
229
|
-
rawQuery(sql: string): Promise<QueryResponse>;
|
|
230
|
-
rawCommand(sql: string): Promise<CommandResponse>;
|
|
231
|
-
}
|
|
232
|
-
declare abstract class SQLClient implements SQLExecutor {
|
|
233
|
-
protected logger: (query: string) => void;
|
|
234
|
-
rawQuery(sql: string): Promise<QueryResponse>;
|
|
235
|
-
rawCommand(sql: string): Promise<CommandResponse>;
|
|
236
|
-
query(templateString: TemplateStringsArray, ...params: any[]): Promise<QueryResponse>;
|
|
237
|
-
command(templateString: TemplateStringsArray, ...params: any[]): Promise<CommandResponse>;
|
|
238
|
-
protected abstract execSql(sql: string): Promise<QueryResponse | CommandResponse>;
|
|
239
|
-
}
|
|
240
|
-
declare abstract class SQLTransaction extends SQLClient {
|
|
241
|
-
abstract commit(): Promise<void>;
|
|
242
|
-
abstract rollback(): Promise<void>;
|
|
243
|
-
}
|
|
244
|
-
declare abstract class DBClient extends SQLClient {
|
|
245
|
-
protected _released: boolean;
|
|
246
|
-
protected constructor(logger?: (query: string) => void);
|
|
247
|
-
isReleased(): boolean;
|
|
248
|
-
abstract transaction(): Promise<SQLTransaction>;
|
|
249
|
-
abstract release(): Promise<void>;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
type Fields<Entity, Relation = Record<string, unknown>> = {
|
|
253
|
-
fields: Array<keyof Entity & string>;
|
|
254
|
-
relations?: Relation;
|
|
255
|
-
tableAlias?: string;
|
|
256
|
-
joinOn?: BooleanValueExpression;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
type MakeConditionArg<Context = unknown, Entity = unknown> = {
|
|
260
|
-
childTableAlias: string;
|
|
261
|
-
context?: Context;
|
|
262
|
-
} & ({
|
|
263
|
-
parentTableAlias: string;
|
|
264
|
-
parent?: undefined;
|
|
265
|
-
} | {
|
|
266
|
-
parent: Partial<Entity>;
|
|
267
|
-
parentTableAlias?: undefined;
|
|
268
|
-
});
|
|
269
|
-
type MakeCondition<Context, Entity = any> = (arg: MakeConditionArg<Context, Entity>) => BooleanValueExpression;
|
|
270
|
-
type RelationInfo<Context = unknown> = {
|
|
271
|
-
table: string;
|
|
272
|
-
condition: MakeCondition<Context>;
|
|
273
|
-
array: boolean;
|
|
274
|
-
nullable: boolean;
|
|
275
|
-
requiredColumns: string[];
|
|
276
|
-
};
|
|
277
|
-
type RelationMap<Context = unknown> = {
|
|
278
|
-
[from: string]: {
|
|
279
|
-
[to: string]: RelationInfo<Context>;
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
type TableInfo = {
|
|
283
|
-
[tableName: string]: {
|
|
284
|
-
identifiableKeys: string[];
|
|
285
|
-
identifiableFields: string[];
|
|
286
|
-
columnMap: {
|
|
287
|
-
[fieldName: string]: string;
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
type PagingOption$1 = {
|
|
293
|
-
numberOfItem: number;
|
|
294
|
-
where?: BooleanValueExpression;
|
|
295
|
-
offset?: number;
|
|
296
|
-
sort?: Sort[];
|
|
297
|
-
join?: Join[];
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
type EntityType = Record<string, SqlValueType>;
|
|
301
|
-
type EntityResult<Entity, Identifiable> = Identifiable & Partial<Entity>;
|
|
302
|
-
interface Repository<Entity, Identifiable, Creatable, Updatable> {
|
|
303
|
-
create(entity: Creatable): Promise<Entity>;
|
|
304
|
-
update(entity: Updatable): Promise<CommandResponse>;
|
|
305
|
-
delete(entity: Identifiable): Promise<CommandResponse>;
|
|
306
|
-
}
|
|
307
|
-
type ListQueryOption = {
|
|
308
|
-
numberOfItem: number;
|
|
309
|
-
offset?: number;
|
|
310
|
-
order?: string;
|
|
311
|
-
asc?: boolean;
|
|
312
|
-
join?: Join[];
|
|
313
|
-
};
|
|
314
|
-
type QueryOptions = {
|
|
315
|
-
where?: BooleanValueExpression;
|
|
316
|
-
sort?: Sort[];
|
|
317
|
-
limit?: number;
|
|
318
|
-
offset?: number;
|
|
319
|
-
lock?: LockMode;
|
|
320
|
-
};
|
|
321
|
-
declare abstract class SasatDBDatasource<Entity extends EntityType, Identifiable extends object, Creatable extends EntityType, Updatable extends Identifiable, EntityFields extends Fields<Entity>, QueryResult extends Partial<Entity> & Identifiable> implements Repository<Entity, Identifiable, Creatable, Updatable> {
|
|
322
|
-
protected client: SQLExecutor;
|
|
323
|
-
protected abstract relationMap: RelationMap<any>;
|
|
324
|
-
protected abstract tableInfo: TableInfo;
|
|
325
|
-
abstract readonly tableName: string;
|
|
326
|
-
abstract readonly fields: string[];
|
|
327
|
-
protected abstract readonly primaryKeys: string[];
|
|
328
|
-
protected abstract readonly identifyFields: string[];
|
|
329
|
-
protected abstract readonly autoIncrementColumn?: string | undefined;
|
|
330
|
-
protected queryLogger: (sql: string) => void;
|
|
331
|
-
protected commandLogger: (sql: string) => void;
|
|
332
|
-
constructor(client?: SQLExecutor);
|
|
333
|
-
protected abstract getDefaultValueString(): Partial<{
|
|
334
|
-
[P in keyof Entity]: Entity[P] | string | null | never;
|
|
335
|
-
}> | never;
|
|
336
|
-
create(entity: Creatable, option?: {
|
|
337
|
-
ignore?: boolean;
|
|
338
|
-
upsert?: {
|
|
339
|
-
updateColumns: string[];
|
|
340
|
-
};
|
|
341
|
-
}): Promise<Entity>;
|
|
342
|
-
createBulk(entities: Creatable[], option?: {
|
|
343
|
-
ignore?: boolean;
|
|
344
|
-
upsert?: {
|
|
345
|
-
updateColumns: string[];
|
|
346
|
-
};
|
|
347
|
-
}): Promise<CommandResponse>;
|
|
348
|
-
upsert<T extends Creatable & Partial<Entity>>(entity: T, updateFields?: (keyof T)[]): Promise<Entity>;
|
|
349
|
-
update(entity: Updatable): Promise<CommandResponse>;
|
|
350
|
-
updateWhere(update: Omit<Updatable, keyof Identifiable>, condition: BooleanValueExpression): Promise<CommandResponse>;
|
|
351
|
-
delete(entity: Identifiable): Promise<CommandResponse>;
|
|
352
|
-
deleteWhere(condition: BooleanValueExpression): Promise<CommandResponse>;
|
|
353
|
-
first(fields?: EntityFields, option?: QueryOptions, context?: unknown): Promise<QueryResult | null>;
|
|
354
|
-
find(fields?: EntityFields, options?: QueryOptions, context?: unknown): Promise<QueryResult[]>;
|
|
355
|
-
findPageable(paging: PagingOption$1, fields?: EntityFields, options?: QueryOptions, context?: unknown): Promise<QueryResult[]>;
|
|
356
|
-
private executeQuery;
|
|
357
|
-
private createIdentifiableExpression;
|
|
358
|
-
getRelationMap(): {
|
|
359
|
-
[to: string]: RelationInfo<any>;
|
|
360
|
-
};
|
|
361
|
-
protected fieldToColumn(fields: string[]): string[];
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
declare const Sql: {
|
|
365
|
-
select: (expr: SelectExpr) => string;
|
|
366
|
-
literal: (literal: Literal) => string;
|
|
367
|
-
fieldInCondition: (identifier: Field) => string;
|
|
368
|
-
fieldInSelect: (identifier: Field) => string;
|
|
369
|
-
identifier: (ident: Identifier) => string;
|
|
370
|
-
fn: (fn: Fn) => string;
|
|
371
|
-
value: (v: Value) => string;
|
|
372
|
-
between: (expr: BetweenExpression) => string;
|
|
373
|
-
contains: (expr: ContainsExpression) => string;
|
|
374
|
-
in: (expr: InExpression) => string;
|
|
375
|
-
comparison: (expr: ComparisonExpression) => string;
|
|
376
|
-
compound: (expr: CompoundExpression) => string;
|
|
377
|
-
isNull: (expr: IsNullExpression) => string;
|
|
378
|
-
paren: (expr: ParenthesisExpression) => string;
|
|
379
|
-
table: (table: QueryTable) => string;
|
|
380
|
-
join: (join: Join) => string;
|
|
381
|
-
booleanValue: (expr: BooleanValueExpression) => string;
|
|
382
|
-
exists: (expr: ExistsExpression) => string;
|
|
383
|
-
sort: (expr: Sort) => string;
|
|
384
|
-
sorts: (sorts: Sort[]) => string;
|
|
385
|
-
queryOrRaw: (expr: Query | RawExpression) => string;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
declare const escape: typeof pkg.escape;
|
|
389
|
-
declare const SqlString: {
|
|
390
|
-
escape: (value: Parameters<typeof escape>[0]) => string;
|
|
391
|
-
escapeId: (name: string) => string;
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
type ResolverArgs<Context, Params = unknown> = [
|
|
395
|
-
_: unknown,
|
|
396
|
-
params: Params,
|
|
397
|
-
context: Context,
|
|
398
|
-
info: GraphQLResolveInfo
|
|
399
|
-
];
|
|
400
|
-
type Resolver<Context, Params> = (_: unknown, params: Params, context: Context, info: GraphQLResolveInfo) => unknown;
|
|
401
|
-
declare const makeResolver: <Context, RequiredParams, IncomingParams = RequiredParams>(resolver: Resolver<Context, RequiredParams>, middlewares?: ResolverMiddleware<Context, RequiredParams, IncomingParams>[]) => Resolver<Context, RequiredParams>;
|
|
402
|
-
|
|
403
|
-
type ResolverMiddleware<Context, RequiredParams = any, IncomingParams = RequiredParams> = (args: ResolverArgs<Context, IncomingParams | RequiredParams>) => ResolverArgs<Context, RequiredParams | IncomingParams>;
|
|
404
|
-
declare const makeParamsMiddleware: <RequiredParams, IncomingParams = RequiredParams>(update: (params: RequiredParams) => IncomingParams) => ResolverMiddleware<never, RequiredParams, IncomingParams>;
|
|
405
|
-
|
|
406
|
-
type NumberIdEncoder = {
|
|
407
|
-
encode: (id: number) => string;
|
|
408
|
-
decode: (id: string) => number;
|
|
409
|
-
};
|
|
410
|
-
declare const makeNumberIdEncoder: (hashId: Hashids) => NumberIdEncoder;
|
|
411
|
-
|
|
412
|
-
type CustomCondition<Context> = (args: MakeConditionArg<Context>) => BooleanValueExpression;
|
|
413
|
-
|
|
414
|
-
type ContextConditionValue = {
|
|
415
|
-
kind: 'context';
|
|
416
|
-
field: string;
|
|
417
|
-
onNotDefined: OnNotDefinedAction;
|
|
418
|
-
};
|
|
419
|
-
type FixedConditionValue = {
|
|
420
|
-
kind: 'fixed';
|
|
421
|
-
value: string | number;
|
|
422
|
-
};
|
|
423
|
-
type TodayStartConditionValue = {
|
|
424
|
-
kind: 'today';
|
|
425
|
-
type: 'date' | 'datetime';
|
|
426
|
-
thresholdHour?: number;
|
|
427
|
-
};
|
|
428
|
-
type NowConditionValue = {
|
|
429
|
-
kind: 'now';
|
|
430
|
-
};
|
|
431
|
-
type OnNotDefinedAction = {
|
|
432
|
-
action: 'error';
|
|
433
|
-
message: string;
|
|
434
|
-
} | {
|
|
435
|
-
action: 'defaultValue';
|
|
436
|
-
value: string | number;
|
|
437
|
-
};
|
|
438
|
-
type ConditionValue = ContextConditionValue | FixedConditionValue | TodayStartConditionValue | NowConditionValue;
|
|
439
|
-
|
|
440
|
-
type QueryConditionValue = ConditionValue | FieldQueryConditionValue | ArgQueryConditionValue;
|
|
441
|
-
type FieldQueryConditionValue = {
|
|
442
|
-
kind: 'field';
|
|
443
|
-
column: string;
|
|
444
|
-
};
|
|
445
|
-
type ArgQueryConditionValue = {
|
|
446
|
-
kind: 'arg';
|
|
447
|
-
name: string;
|
|
448
|
-
type: 'Int' | 'Float' | 'String' | string;
|
|
449
|
-
};
|
|
450
|
-
type QueryConditionNode = {
|
|
451
|
-
kind: 'comparison';
|
|
452
|
-
left: QueryConditionValue;
|
|
453
|
-
operator: ComparisonOperators;
|
|
454
|
-
right: QueryConditionValue;
|
|
455
|
-
} | {
|
|
456
|
-
kind: 'between';
|
|
457
|
-
left: QueryConditionValue;
|
|
458
|
-
operator: 'BETWEEN';
|
|
459
|
-
begin: QueryConditionValue;
|
|
460
|
-
end: QueryConditionValue;
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
declare enum DBColumnTypes {
|
|
464
|
-
char = "char",
|
|
465
|
-
varchar = "varchar",
|
|
466
|
-
text = "text",
|
|
467
|
-
tinyInt = "tinyint",
|
|
468
|
-
smallInt = "smallint",
|
|
469
|
-
mediumInt = "mediumint",
|
|
470
|
-
int = "int",
|
|
471
|
-
bigInt = "bigint",
|
|
472
|
-
float = "float",
|
|
473
|
-
double = "double",
|
|
474
|
-
decimal = "decimal",
|
|
475
|
-
year = "year",
|
|
476
|
-
date = "date",
|
|
477
|
-
time = "time",
|
|
478
|
-
dateTime = "datetime",
|
|
479
|
-
timestamp = "timestamp",
|
|
480
|
-
boolean = "boolean"
|
|
481
|
-
}
|
|
482
|
-
type DBType = 'char' | 'varchar' | 'text' | 'tinyint' | 'smallint' | 'mediumint' | 'int' | 'bigint' | 'float' | 'double' | 'decimal' | 'year' | 'date' | 'time' | 'datetime' | 'timestamp' | 'boolean';
|
|
483
|
-
type DBStringTypes = DBColumnTypes.char | DBColumnTypes.varchar;
|
|
484
|
-
type DBTextTypes = DBColumnTypes.text;
|
|
485
|
-
type DBIntegerTypes = DBColumnTypes.tinyInt | DBColumnTypes.smallInt | DBColumnTypes.mediumInt | DBColumnTypes.int | DBColumnTypes.bigInt;
|
|
486
|
-
type DBFloatingTypes = DBColumnTypes.float | DBColumnTypes.double;
|
|
487
|
-
type DBNumberTypes = DBIntegerTypes | DBFloatingTypes | DBColumnTypes.decimal;
|
|
488
|
-
type DBDateTypes = DBColumnTypes.time | DBColumnTypes.date | DBColumnTypes.year;
|
|
489
|
-
|
|
490
|
-
interface Serializable<T> {
|
|
491
|
-
serialize(): T;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
type ForeignKeyReferentialAction = 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'NO ACTION';
|
|
495
|
-
|
|
496
|
-
type Relation = 'One' | 'OneOrZero' | 'Many';
|
|
497
|
-
|
|
498
|
-
type ColumnOptions = {
|
|
499
|
-
updatable: boolean;
|
|
500
|
-
autoIncrementHashId: boolean;
|
|
501
|
-
hashSalt?: string;
|
|
502
|
-
};
|
|
503
|
-
interface SerializedColumnBase {
|
|
504
|
-
hasReference: boolean;
|
|
505
|
-
fieldName: string;
|
|
506
|
-
columnName: string;
|
|
507
|
-
type: DBColumnTypes;
|
|
508
|
-
notNull: boolean;
|
|
509
|
-
default: SqlValueType | undefined;
|
|
510
|
-
zerofill: boolean;
|
|
511
|
-
signed: boolean | undefined;
|
|
512
|
-
autoIncrement: boolean;
|
|
513
|
-
length: number | undefined;
|
|
514
|
-
scale: number | undefined;
|
|
515
|
-
defaultCurrentTimeStamp: boolean;
|
|
516
|
-
onUpdateCurrentTimeStamp: boolean;
|
|
517
|
-
option: ColumnOptions;
|
|
518
|
-
}
|
|
519
|
-
interface SerializedNormalColumn extends SerializedColumnBase {
|
|
520
|
-
hasReference: false;
|
|
521
|
-
}
|
|
522
|
-
interface Reference {
|
|
523
|
-
parentTable: string;
|
|
524
|
-
parentColumn: string;
|
|
525
|
-
columnName: string;
|
|
526
|
-
relation: Relation;
|
|
527
|
-
parentFieldName?: string;
|
|
528
|
-
fieldName?: string;
|
|
529
|
-
relationName?: string;
|
|
530
|
-
onUpdate?: ForeignKeyReferentialAction;
|
|
531
|
-
onDelete?: ForeignKeyReferentialAction;
|
|
532
|
-
noFKey?: boolean;
|
|
533
|
-
}
|
|
534
|
-
interface SerializedReferenceColumn extends SerializedColumnBase {
|
|
535
|
-
hasReference: true;
|
|
536
|
-
reference: Reference;
|
|
537
|
-
}
|
|
538
|
-
type SerializedColumn = SerializedNormalColumn | SerializedReferenceColumn;
|
|
539
|
-
|
|
540
|
-
interface Index {
|
|
541
|
-
constraintName: string;
|
|
542
|
-
columns: string[];
|
|
543
|
-
}
|
|
544
|
-
declare class DBIndex implements Index, Serializable<Index> {
|
|
545
|
-
readonly tableName: string;
|
|
546
|
-
readonly columns: string[];
|
|
547
|
-
readonly constraintName: string;
|
|
548
|
-
constructor(tableName: string, columns: string[]);
|
|
549
|
-
private toConstraintName;
|
|
550
|
-
addSql(): string;
|
|
551
|
-
dropSql(): string;
|
|
552
|
-
serialize(): Index;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
type JoinConditionValue = {
|
|
556
|
-
kind: 'parent' | 'child';
|
|
557
|
-
field: string;
|
|
558
|
-
} | ConditionValue;
|
|
559
|
-
type JoinConditionRangeValue = {
|
|
560
|
-
kind: 'range';
|
|
561
|
-
begin: JoinConditionValue;
|
|
562
|
-
end: JoinConditionValue;
|
|
563
|
-
} | DateRangeConditionValue;
|
|
564
|
-
type DateRangeConditionValue = {
|
|
565
|
-
kind: 'date-range';
|
|
566
|
-
range: 'today';
|
|
567
|
-
thresholdHour?: number;
|
|
568
|
-
};
|
|
569
|
-
type JoinConditionNode = {
|
|
570
|
-
kind: 'comparison';
|
|
571
|
-
left: JoinConditionValue;
|
|
572
|
-
operator: ComparisonOperators;
|
|
573
|
-
right: JoinConditionValue;
|
|
574
|
-
} | {
|
|
575
|
-
kind: 'comparison';
|
|
576
|
-
left: JoinConditionValue;
|
|
577
|
-
operator: 'BETWEEN';
|
|
578
|
-
right: JoinConditionRangeValue;
|
|
579
|
-
} | {
|
|
580
|
-
kind: 'comparison';
|
|
581
|
-
left: JoinConditionValue;
|
|
582
|
-
operator: 'IN';
|
|
583
|
-
right: JoinConditionValue[];
|
|
584
|
-
} | {
|
|
585
|
-
kind: 'isNull';
|
|
586
|
-
value: JoinConditionValue;
|
|
587
|
-
not: boolean;
|
|
588
|
-
} | JoinCustomConditionNode;
|
|
589
|
-
type JoinCustomConditionNode = {
|
|
590
|
-
kind: 'custom';
|
|
591
|
-
conditionName: string;
|
|
592
|
-
parentRequiredFields?: string[];
|
|
593
|
-
childRequiredFields?: string[];
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
type VirtualRelation = {
|
|
597
|
-
parentTable: string;
|
|
598
|
-
childTable: string;
|
|
599
|
-
parentFieldName?: string;
|
|
600
|
-
childFieldName?: string;
|
|
601
|
-
conditions: JoinConditionNode[];
|
|
602
|
-
parentType?: 'array' | 'nullable' | 'notnull';
|
|
603
|
-
childType?: 'array' | 'nullable' | 'notnull';
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
interface SerializedTable {
|
|
607
|
-
columns: SerializedColumn[];
|
|
608
|
-
primaryKey: string[];
|
|
609
|
-
uniqueKeys: string[][];
|
|
610
|
-
indexes: Index[];
|
|
611
|
-
tableName: string;
|
|
612
|
-
gqlOption: GQLOption;
|
|
613
|
-
virtualRelations: VirtualRelation[];
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
type GQLPrimitive = 'Int' | 'Float' | 'String' | 'Boolean' | 'ID';
|
|
617
|
-
|
|
618
|
-
interface Column extends Serializable<SerializedColumn> {
|
|
619
|
-
fieldName(): string;
|
|
620
|
-
columnName(): string;
|
|
621
|
-
dataType(): DBColumnTypes;
|
|
622
|
-
toSql(): string;
|
|
623
|
-
isReference(): this is ReferenceColumn;
|
|
624
|
-
isNullable(): boolean;
|
|
625
|
-
tsType(): string;
|
|
626
|
-
gqlType(): GQLPrimitive;
|
|
627
|
-
isNullableOnCreate(): boolean;
|
|
628
|
-
}
|
|
629
|
-
declare class BaseColumn implements Column {
|
|
630
|
-
data: SerializedColumn;
|
|
631
|
-
table: Table;
|
|
632
|
-
constructor(data: SerializedColumn, table: Table);
|
|
633
|
-
fieldName(): string;
|
|
634
|
-
columnName(): string;
|
|
635
|
-
dataType(): DBColumnTypes;
|
|
636
|
-
tsType(): string;
|
|
637
|
-
gqlType(): GQLPrimitive;
|
|
638
|
-
isNullable(): boolean;
|
|
639
|
-
isNullableOnCreate(): boolean;
|
|
640
|
-
isReference(): this is ReferenceColumn;
|
|
641
|
-
serialize(): SerializedColumn;
|
|
642
|
-
toSql(): string;
|
|
643
|
-
isPrimary(): boolean;
|
|
644
|
-
isUpdatable(): boolean;
|
|
645
|
-
}
|
|
646
|
-
declare class ReferenceColumn extends BaseColumn {
|
|
647
|
-
data: SerializedReferenceColumn;
|
|
648
|
-
constructor(data: SerializedReferenceColumn, table: Table);
|
|
649
|
-
getConstraintName(): string;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
declare class EntityName {
|
|
653
|
-
readonly name: string;
|
|
654
|
-
static fromTableName(tableName: string): EntityName;
|
|
655
|
-
constructor(name: string);
|
|
656
|
-
toString(): string;
|
|
657
|
-
creatableInterface(): string;
|
|
658
|
-
updatable(): string;
|
|
659
|
-
identifiableInterfaceName(): string;
|
|
660
|
-
relationTypeName(): string;
|
|
661
|
-
entityWithRelationTypeName(): string;
|
|
662
|
-
resultType(): string;
|
|
663
|
-
fieldsTypeName(): string;
|
|
664
|
-
dataSourceName(): string;
|
|
665
|
-
generatedDataSourceName(): string;
|
|
666
|
-
lowerCase(): string;
|
|
667
|
-
createInputName(): string;
|
|
668
|
-
updateInputName(): string;
|
|
669
|
-
identifyInputName(): string;
|
|
670
|
-
IDEncoderName(): string;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
interface Table extends Serializable<SerializedTable> {
|
|
674
|
-
column(columnName: string): BaseColumn;
|
|
675
|
-
tableName: string;
|
|
676
|
-
gqlOption: GQLOption;
|
|
677
|
-
primaryKey: string[];
|
|
678
|
-
}
|
|
679
|
-
declare class TableHandler implements Table {
|
|
680
|
-
store: DataStore;
|
|
681
|
-
private indexes;
|
|
682
|
-
get index(): DBIndex[];
|
|
683
|
-
private _columns;
|
|
684
|
-
get columns(): BaseColumn[];
|
|
685
|
-
private readonly _virtualRelations;
|
|
686
|
-
get virtualRelations(): VirtualRelation[];
|
|
687
|
-
addVirtualRelation(relation: Omit<VirtualRelation, 'childTable'>): void;
|
|
688
|
-
primaryKey: string[];
|
|
689
|
-
readonly uniqueKeys: string[][];
|
|
690
|
-
readonly tableName: string;
|
|
691
|
-
private _gqlOption;
|
|
692
|
-
get gqlOption(): GQLOption;
|
|
693
|
-
constructor(table: Partial<SerializedTable> & Pick<SerializedTable, 'tableName'>, store: DataStore);
|
|
694
|
-
column(columnName: string): BaseColumn;
|
|
695
|
-
addColumn(column: BaseColumn, isPrimary?: boolean, isUnique?: boolean): void;
|
|
696
|
-
dropColumn(columnName: string): void;
|
|
697
|
-
serialize(): SerializedTable;
|
|
698
|
-
addReferences(ref: Reference, fieldName?: string, notNull?: boolean): this;
|
|
699
|
-
private getIndexConstraintName;
|
|
700
|
-
addIndex(...columns: string[]): this;
|
|
701
|
-
removeIndex(...columns: string[]): this;
|
|
702
|
-
addUniqueKey(...columnNames: string[]): this;
|
|
703
|
-
setPrimaryKey(...columnNames: string[]): this;
|
|
704
|
-
showCreateTable(): string;
|
|
705
|
-
hasColumn(columnName: string): boolean;
|
|
706
|
-
isColumnPrimary(columnName: string): boolean;
|
|
707
|
-
getEntityName(): EntityName;
|
|
708
|
-
setGQLOption(option: Partial<GQLOption>): void;
|
|
709
|
-
getReferenceColumns(): ReferenceColumn[];
|
|
710
|
-
addForeignKey(reference: Reference): void;
|
|
711
|
-
changeType(columnName: string, type: DBColumnTypes): void;
|
|
712
|
-
setDefault(columnName: string, value: string | number | null): void;
|
|
713
|
-
protected updateColumn(columnName: string, diff: Partial<SerializedColumn>): void;
|
|
714
|
-
getPrimaryKeyColumns(): BaseColumn[];
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
interface DataStore {
|
|
718
|
-
table(tableName: string): Table;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
interface GqlFromContextParam {
|
|
722
|
-
column: string;
|
|
723
|
-
contextName?: string;
|
|
724
|
-
}
|
|
725
|
-
type GQLMutation = {
|
|
726
|
-
type: 'create' | 'update' | 'delete';
|
|
727
|
-
noReFetch: boolean;
|
|
728
|
-
middlewares: string[];
|
|
729
|
-
contextFields: GqlFromContextParam[];
|
|
730
|
-
subscription: {
|
|
731
|
-
enabled: boolean;
|
|
732
|
-
subscriptionFilter: string[];
|
|
733
|
-
};
|
|
734
|
-
};
|
|
735
|
-
type GQLQuery = {
|
|
736
|
-
type: 'single' | 'list-all' | 'list-paging';
|
|
737
|
-
name: string;
|
|
738
|
-
conditions: QueryConditionNode[];
|
|
739
|
-
middlewares: string[];
|
|
740
|
-
} | {
|
|
741
|
-
type: 'primary';
|
|
742
|
-
name?: never;
|
|
743
|
-
conditions: never[];
|
|
744
|
-
middlewares: string[];
|
|
745
|
-
};
|
|
746
|
-
interface GQLOption {
|
|
747
|
-
enabled: boolean;
|
|
748
|
-
queries: GQLQuery[];
|
|
749
|
-
mutations: GQLMutation[];
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
declare const Queries: {
|
|
753
|
-
single: (name: string, options?: {
|
|
754
|
-
conditions?: QueryConditionNode[];
|
|
755
|
-
middlewares?: string[];
|
|
756
|
-
}) => GQLQuery;
|
|
757
|
-
listAll: (name: string, options?: {
|
|
758
|
-
conditions?: QueryConditionNode[];
|
|
759
|
-
middlewares?: string[];
|
|
760
|
-
}) => GQLQuery;
|
|
761
|
-
paging: (name: string, options?: {
|
|
762
|
-
conditions?: QueryConditionNode[];
|
|
763
|
-
middlewares?: string[];
|
|
764
|
-
}) => GQLQuery;
|
|
765
|
-
primary: (middlewares?: string[]) => GQLQuery;
|
|
766
|
-
};
|
|
767
|
-
|
|
768
|
-
type Option = {
|
|
769
|
-
noRefetch?: boolean;
|
|
770
|
-
middlewares?: string[];
|
|
771
|
-
contextFields?: GqlFromContextParam[];
|
|
772
|
-
subscription?: {
|
|
773
|
-
enabled: boolean;
|
|
774
|
-
subscriptionFilter?: string[];
|
|
775
|
-
} | boolean;
|
|
776
|
-
};
|
|
777
|
-
declare const Mutations: {
|
|
778
|
-
create: (options?: Option) => GQLMutation;
|
|
779
|
-
update: (options?: Option) => GQLMutation;
|
|
780
|
-
delete: (options?: Omit<Option, 'noRefetch'>) => GQLMutation;
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
declare const Conditions: {
|
|
784
|
-
readonly betweenRel: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
|
|
785
|
-
readonly betweenQuery: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
|
|
786
|
-
readonly custom: (conditionName: string, parentRequiredFields?: string[], childRequiredFields?: string[]) => JoinConditionNode;
|
|
787
|
-
readonly rel: {
|
|
788
|
-
readonly between: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
|
|
789
|
-
readonly comparison: (left: JoinConditionValue, operator: ComparisonOperators, right: JoinConditionValue) => JoinConditionNode;
|
|
790
|
-
readonly in: (left: JoinConditionValue, right: JoinConditionValue[]) => JoinConditionNode;
|
|
791
|
-
readonly isNull: (value: JoinConditionValue) => JoinConditionNode;
|
|
792
|
-
readonly isNotNull: (value: JoinConditionValue) => JoinConditionNode;
|
|
793
|
-
};
|
|
794
|
-
readonly query: {
|
|
795
|
-
readonly between: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
|
|
796
|
-
readonly comparison: (left: QueryConditionValue, operator: ComparisonOperators, right: QueryConditionValue) => QueryConditionNode;
|
|
797
|
-
};
|
|
798
|
-
readonly value: {
|
|
799
|
-
readonly parent: (field: string) => JoinConditionValue;
|
|
800
|
-
readonly child: (field: string) => JoinConditionValue;
|
|
801
|
-
readonly contextOrError: (field: string, errorMessage: string) => ConditionValue;
|
|
802
|
-
readonly contextOrDefault: (field: string, defaultValue: string | number) => ConditionValue;
|
|
803
|
-
readonly fixed: (value: string | number) => ConditionValue;
|
|
804
|
-
readonly today: (thresholdHour?: number, date?: boolean) => ConditionValue;
|
|
805
|
-
readonly now: () => ConditionValue;
|
|
806
|
-
readonly field: (column: string) => QueryConditionValue;
|
|
807
|
-
readonly arg: (name: string, type: 'Int' | 'Float' | 'String') => QueryConditionValue;
|
|
808
|
-
};
|
|
809
|
-
readonly range: {
|
|
810
|
-
readonly values: (begin: JoinConditionValue, end: JoinConditionValue) => JoinConditionRangeValue;
|
|
811
|
-
readonly today: (thresholdHour?: number) => JoinConditionRangeValue;
|
|
812
|
-
};
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
declare abstract class ColumnBuilderBase {
|
|
816
|
-
readonly columnName: string;
|
|
817
|
-
protected _primary: boolean;
|
|
818
|
-
protected _notNull: boolean;
|
|
819
|
-
protected _unique: boolean;
|
|
820
|
-
protected _option: ColumnOptions;
|
|
821
|
-
protected _fieldName: string;
|
|
822
|
-
protected constructor(columnName: string);
|
|
823
|
-
fieldName(fieldName: string): this;
|
|
824
|
-
notNull(): this;
|
|
825
|
-
nullable(): this;
|
|
826
|
-
primary(): this;
|
|
827
|
-
unique(): this;
|
|
828
|
-
updatable(updatable: boolean): this;
|
|
829
|
-
abstract build(): {
|
|
830
|
-
data: SerializedColumn;
|
|
831
|
-
isPrimary: boolean;
|
|
832
|
-
isUnique: boolean;
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
declare abstract class ColumnBuilder extends ColumnBuilderBase {
|
|
836
|
-
protected type: DBColumnTypes;
|
|
837
|
-
protected length?: number | undefined;
|
|
838
|
-
protected scale?: number | undefined;
|
|
839
|
-
protected _zerofill: boolean;
|
|
840
|
-
protected _signed: boolean | undefined;
|
|
841
|
-
protected _autoIncrement: boolean;
|
|
842
|
-
protected _default: SqlValueType | undefined;
|
|
843
|
-
protected _defaultCurrentTimeStamp: boolean;
|
|
844
|
-
protected _onUpdateCurrentTimeStamp: boolean;
|
|
845
|
-
protected constructor(name: string, type: DBColumnTypes, length?: number | undefined, scale?: number | undefined);
|
|
846
|
-
default(value: SqlValueType | undefined): this;
|
|
847
|
-
build(): {
|
|
848
|
-
data: SerializedNormalColumn;
|
|
849
|
-
isPrimary: boolean;
|
|
850
|
-
isUnique: boolean;
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
declare class StringColumnBuilder extends ColumnBuilder {
|
|
854
|
-
readonly name: string;
|
|
855
|
-
protected type: DBStringTypes;
|
|
856
|
-
protected length?: number | undefined;
|
|
857
|
-
constructor(name: string, type: DBStringTypes, length?: number | undefined);
|
|
858
|
-
default(value: string | null | undefined): this;
|
|
859
|
-
}
|
|
860
|
-
declare class TextColumnBuilder extends ColumnBuilder {
|
|
861
|
-
readonly name: string;
|
|
862
|
-
protected type: DBTextTypes;
|
|
863
|
-
constructor(name: string, type: DBTextTypes);
|
|
864
|
-
default(value: string | null | undefined): this;
|
|
865
|
-
}
|
|
866
|
-
declare class NumberColumnBuilder extends ColumnBuilder {
|
|
867
|
-
constructor(name: string, type: DBNumberTypes, length?: number, scale?: number);
|
|
868
|
-
signed(): this;
|
|
869
|
-
unsigned(): this;
|
|
870
|
-
zerofill(): this;
|
|
871
|
-
default(value: number | null | undefined): this;
|
|
872
|
-
}
|
|
873
|
-
declare class IntegerColumnBuilder extends NumberColumnBuilder {
|
|
874
|
-
readonly name: string;
|
|
875
|
-
protected type: DBIntegerTypes;
|
|
876
|
-
protected length?: number | undefined;
|
|
877
|
-
constructor(name: string, type: DBIntegerTypes, length?: number | undefined);
|
|
878
|
-
autoIncrement(): this;
|
|
879
|
-
}
|
|
880
|
-
declare class FloatColumnBuilder extends NumberColumnBuilder {
|
|
881
|
-
readonly name: string;
|
|
882
|
-
protected type: DBFloatingTypes;
|
|
883
|
-
protected length?: number | undefined;
|
|
884
|
-
protected scale?: number | undefined;
|
|
885
|
-
constructor(name: string, type: DBFloatingTypes, length?: number | undefined, scale?: number | undefined);
|
|
886
|
-
autoIncrement(): this;
|
|
887
|
-
}
|
|
888
|
-
declare class DecimalColumnBuilder extends NumberColumnBuilder {
|
|
889
|
-
readonly name: string;
|
|
890
|
-
protected type: DBColumnTypes.decimal;
|
|
891
|
-
protected length?: number | undefined;
|
|
892
|
-
protected scale?: number | undefined;
|
|
893
|
-
constructor(name: string, type: DBColumnTypes.decimal, length?: number | undefined, scale?: number | undefined);
|
|
894
|
-
}
|
|
895
|
-
declare class DateColumnBuilder extends ColumnBuilder {
|
|
896
|
-
readonly name: string;
|
|
897
|
-
protected type: DBDateTypes;
|
|
898
|
-
constructor(name: string, type: DBDateTypes);
|
|
899
|
-
default(value: string | number | null | undefined): this;
|
|
900
|
-
}
|
|
901
|
-
declare class TimeStampColumnBuilder extends ColumnBuilder {
|
|
902
|
-
readonly name: string;
|
|
903
|
-
protected type: DBColumnTypes.timestamp | DBColumnTypes.dateTime;
|
|
904
|
-
constructor(name: string, type: DBColumnTypes.timestamp | DBColumnTypes.dateTime);
|
|
905
|
-
default(value: 'CURRENT_TIMESTAMP' | string | null | undefined): this;
|
|
906
|
-
defaultCurrentTimeStamp(): this;
|
|
907
|
-
onUpdateCurrentTimeStamp(): this;
|
|
908
|
-
}
|
|
909
|
-
declare class ReferenceColumnBuilder extends ColumnBuilderBase {
|
|
910
|
-
protected readonly ref: Reference;
|
|
911
|
-
protected readonly parent: Column;
|
|
912
|
-
constructor(ref: Reference, parent: Column);
|
|
913
|
-
notNull(): this;
|
|
914
|
-
nullable(): this;
|
|
915
|
-
primary(): this;
|
|
916
|
-
unique(): this;
|
|
917
|
-
build(): {
|
|
918
|
-
data: SerializedReferenceColumn;
|
|
919
|
-
isPrimary: boolean;
|
|
920
|
-
isUnique: boolean;
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
type CreateColumn = {
|
|
925
|
-
char: (length: number) => StringColumnBuilder;
|
|
926
|
-
varchar: (length: number) => StringColumnBuilder;
|
|
927
|
-
text: () => TextColumnBuilder;
|
|
928
|
-
tinyInt: (length?: number) => IntegerColumnBuilder;
|
|
929
|
-
smallInt: (length?: number) => IntegerColumnBuilder;
|
|
930
|
-
mediumInt: (length?: number) => IntegerColumnBuilder;
|
|
931
|
-
int: (length?: number) => IntegerColumnBuilder;
|
|
932
|
-
bigInt: (length?: number) => IntegerColumnBuilder;
|
|
933
|
-
float: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
934
|
-
double: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
935
|
-
decimal: (length?: number, scale?: number) => DecimalColumnBuilder;
|
|
936
|
-
year: () => DateColumnBuilder;
|
|
937
|
-
date: () => DateColumnBuilder;
|
|
938
|
-
time: () => DateColumnBuilder;
|
|
939
|
-
dateTime: () => TimeStampColumnBuilder;
|
|
940
|
-
timestamp: () => TimeStampColumnBuilder;
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
interface MigrationTable extends Table {
|
|
944
|
-
addIndex(...columns: string[]): MigrationTable;
|
|
945
|
-
removeIndex(...columns: string[]): MigrationTable;
|
|
946
|
-
addColumn(name: string, create: (column: CreateColumn) => ColumnBuilder): MigrationTable;
|
|
947
|
-
_addColumn(column: SerializedColumn): MigrationTable;
|
|
948
|
-
dropColumn(columnName: string): MigrationTable;
|
|
949
|
-
addForeignKey(reference: Reference): MigrationTable;
|
|
950
|
-
changeColumnType(columnName: string, type: DBType): MigrationTable;
|
|
951
|
-
setDefault(columnName: string, value: string | number | null): MigrationTable;
|
|
952
|
-
enableGQL(): MigrationTable;
|
|
953
|
-
setGQLOption(option: GQLOption): MigrationTable;
|
|
954
|
-
addGQLQuery(...queries: GQLQuery[]): MigrationTable;
|
|
955
|
-
addGQLMutation(...mutations: GQLMutation[]): MigrationTable;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
declare class ColumnCreator {
|
|
959
|
-
private table;
|
|
960
|
-
private name;
|
|
961
|
-
constructor(table: TableCreator, name: string);
|
|
962
|
-
char: (length: number) => StringColumnBuilder;
|
|
963
|
-
varchar: (length: number) => StringColumnBuilder;
|
|
964
|
-
text: () => TextColumnBuilder;
|
|
965
|
-
tinyInt: (length?: number) => IntegerColumnBuilder;
|
|
966
|
-
smallInt: (length?: number) => IntegerColumnBuilder;
|
|
967
|
-
mediumInt: (length?: number) => IntegerColumnBuilder;
|
|
968
|
-
int: (length?: number) => IntegerColumnBuilder;
|
|
969
|
-
bigInt: (length?: number) => IntegerColumnBuilder;
|
|
970
|
-
float: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
971
|
-
double: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
972
|
-
decimal: (length?: number, scale?: number) => DecimalColumnBuilder;
|
|
973
|
-
year: () => DateColumnBuilder;
|
|
974
|
-
date: () => DateColumnBuilder;
|
|
975
|
-
time: () => DateColumnBuilder;
|
|
976
|
-
dateTime: () => TimeStampColumnBuilder;
|
|
977
|
-
timestamp: () => TimeStampColumnBuilder;
|
|
978
|
-
private create;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
interface TableBuilder {
|
|
982
|
-
autoIncrementHashId(columnName: string, option?: {
|
|
983
|
-
salt?: string;
|
|
984
|
-
bigint?: boolean;
|
|
985
|
-
}): TableBuilder;
|
|
986
|
-
column(columnName: string): ColumnCreator;
|
|
987
|
-
addVirtualRelation(relation: Omit<VirtualRelation, 'childTable'>): TableBuilder;
|
|
988
|
-
references(reference: Reference, notNull?: boolean): ColumnBuilderBase;
|
|
989
|
-
setPrimaryKey(...columnNames: string[]): TableBuilder;
|
|
990
|
-
addUniqueKey(...columnNames: string[]): TableBuilder;
|
|
991
|
-
createdAt(): TableBuilder;
|
|
992
|
-
updatedAt(): TableBuilder;
|
|
993
|
-
addIndex(...columns: string[]): TableBuilder;
|
|
994
|
-
enableGQL(): TableBuilder;
|
|
995
|
-
setGQLOption(option: Partial<GQLOption>): TableBuilder;
|
|
996
|
-
addGQLQuery(...query: GQLQuery[]): TableBuilder;
|
|
997
|
-
addGQLMutation(...mutation: GQLMutation[]): TableBuilder;
|
|
998
|
-
}
|
|
999
|
-
declare class TableCreator implements TableBuilder {
|
|
1000
|
-
tableName: string;
|
|
1001
|
-
protected readonly store: DataStore;
|
|
1002
|
-
private readonly table;
|
|
1003
|
-
private readonly columns;
|
|
1004
|
-
constructor(tableName: string, store: DataStore);
|
|
1005
|
-
autoIncrementHashId(columnName: string, option?: {
|
|
1006
|
-
salt?: string;
|
|
1007
|
-
bigint?: boolean;
|
|
1008
|
-
}): TableBuilder;
|
|
1009
|
-
column(name: string): ColumnCreator;
|
|
1010
|
-
addVirtualRelation(relation: Omit<VirtualRelation, 'childTable'>): this;
|
|
1011
|
-
addColumn(column: ColumnBuilderBase): void;
|
|
1012
|
-
addUniqueKey(...columnNames: string[]): TableBuilder;
|
|
1013
|
-
references(ref: Reference): ReferenceColumnBuilder;
|
|
1014
|
-
setPrimaryKey(...columnNames: string[]): TableBuilder;
|
|
1015
|
-
create(): TableHandler;
|
|
1016
|
-
createdAt(): TableBuilder;
|
|
1017
|
-
updatedAt(): TableBuilder;
|
|
1018
|
-
addIndex(...columns: string[]): TableBuilder;
|
|
1019
|
-
enableGQL(): TableBuilder;
|
|
1020
|
-
setGQLOption(option: Partial<GQLOption>): TableBuilder;
|
|
1021
|
-
addGQLQuery(...query: GQLQuery[]): TableBuilder;
|
|
1022
|
-
addGQLMutation(...mutation: GQLMutation[]): TableBuilder;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
interface MigrationStore extends DataStore {
|
|
1026
|
-
createTable(tableName: string, tableCreator: (table: TableBuilder) => void): MigrationStore;
|
|
1027
|
-
dropTable(tableName: string): MigrationStore;
|
|
1028
|
-
table(tableName: string): MigrationTable;
|
|
1029
|
-
sql(...sql: string[]): MigrationStore;
|
|
1030
|
-
setConfig(config: NestedPartial$1<SasatConfig>): MigrationStore;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
type TypeFieldDefinition = {
|
|
1034
|
-
return: string;
|
|
1035
|
-
args?: {
|
|
1036
|
-
name: string;
|
|
1037
|
-
type: string;
|
|
1038
|
-
}[];
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
interface SasatMigration {
|
|
1042
|
-
up: (store: MigrationStore) => void | Promise<void>;
|
|
1043
|
-
down: (store: MigrationStore) => void | Promise<void>;
|
|
1044
|
-
beforeUp?: () => void | Promise<void>;
|
|
1045
|
-
afterUp?: () => void | Promise<void>;
|
|
1046
|
-
beforeDown?: () => void | Promise<void>;
|
|
1047
|
-
afterDown?: () => void | Promise<void>;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
type StrOrNum = string | number;
|
|
1051
|
-
type ValueType = string | boolean | number | null;
|
|
1052
|
-
declare const QExpr: {
|
|
1053
|
-
readonly field: (table: string, name: string, alias?: string) => Field;
|
|
1054
|
-
readonly fn: (fnName: string, args: Value[], alias?: string) => Fn;
|
|
1055
|
-
readonly window: (type: 'ROWS' | 'RANGE', value: WindowContent) => Window;
|
|
1056
|
-
readonly windowBetween: (type: 'ROWS' | 'RANGE', start: WindowContent, end: WindowContent) => Window;
|
|
1057
|
-
readonly paren: (expression: BooleanValueExpression) => ParenthesisExpression;
|
|
1058
|
-
readonly table: (name: string, joins: Join[], alias: string) => QueryTable;
|
|
1059
|
-
readonly subQueryTable: (query: Query, joins: Join[], alias: string) => QueryTable;
|
|
1060
|
-
readonly join: (table: QueryTable, conditions: BooleanValueExpression, type?: JoinType) => Join;
|
|
1061
|
-
readonly value: (value: ValueType) => Literal;
|
|
1062
|
-
readonly sort: (field: Field | Fn | Identifier, direction?: SortDirection) => Sort;
|
|
1063
|
-
readonly order: (field: Field | Fn | Identifier, direction?: SortDirection) => Sort;
|
|
1064
|
-
readonly ident: (identifier: string) => Identifier;
|
|
1065
|
-
readonly id: (identifier: string) => Identifier;
|
|
1066
|
-
readonly raw: (sql: string) => RawExpression;
|
|
1067
|
-
readonly simpleWhere: (tableNameOrAlias: string, where: {
|
|
1068
|
-
[field: string]: ValueType | [ComparisonOperators, ValueType];
|
|
1069
|
-
}, isOr?: boolean) => BooleanValueExpression;
|
|
1070
|
-
readonly and: (...expr: Array<BooleanValueExpression | undefined | null>) => BooleanValueExpression;
|
|
1071
|
-
readonly or: (...expr: Array<BooleanValueExpression | undefined | null>) => BooleanValueExpression;
|
|
1072
|
-
readonly eq: (left: Value, right: Value) => ComparisonExpression;
|
|
1073
|
-
readonly neq: (left: Value, right: Value) => ComparisonExpression;
|
|
1074
|
-
readonly gt: (left: Value, right: Value) => ComparisonExpression;
|
|
1075
|
-
readonly gte: (left: Value, right: Value) => ComparisonExpression;
|
|
1076
|
-
readonly lt: (left: Value, right: Value) => ComparisonExpression;
|
|
1077
|
-
readonly lte: (left: Value, right: Value) => ComparisonExpression;
|
|
1078
|
-
readonly comparison: (left: Value, operator: ComparisonOperators, right: Value) => ComparisonExpression;
|
|
1079
|
-
readonly contains: (left: Value, right: string) => BooleanValueExpression;
|
|
1080
|
-
readonly notContains: (left: Value, right: string) => BooleanValueExpression;
|
|
1081
|
-
readonly startsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1082
|
-
readonly notStartsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1083
|
-
readonly endsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1084
|
-
readonly notEndsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1085
|
-
readonly in: (left: Value, right: StrOrNum[] | Query | RawExpression) => BooleanValueExpression;
|
|
1086
|
-
readonly notIn: (left: Value, values: StrOrNum[]) => InExpression;
|
|
1087
|
-
readonly between: (left: Value, begin: Value, end: Value) => BetweenExpression;
|
|
1088
|
-
readonly isNull: (expr: Value) => IsNullExpression;
|
|
1089
|
-
readonly isNotNull: (expr: Value) => IsNullExpression;
|
|
1090
|
-
readonly exists: (query: RawExpression | Query) => ExistsExpression;
|
|
1091
|
-
readonly conditions: {
|
|
1092
|
-
simpleWhere: (tableNameOrAlias: string, where: {
|
|
1093
|
-
[field: string]: ValueType | [ComparisonOperators, ValueType];
|
|
1094
|
-
}, isOr?: boolean) => BooleanValueExpression;
|
|
1095
|
-
and: (...expr: Array<BooleanValueExpression | undefined | null>) => BooleanValueExpression;
|
|
1096
|
-
or: (...expr: Array<BooleanValueExpression | undefined | null>) => BooleanValueExpression;
|
|
1097
|
-
eq: (left: Value, right: Value) => ComparisonExpression;
|
|
1098
|
-
neq: (left: Value, right: Value) => ComparisonExpression;
|
|
1099
|
-
gt: (left: Value, right: Value) => ComparisonExpression;
|
|
1100
|
-
gte: (left: Value, right: Value) => ComparisonExpression;
|
|
1101
|
-
lt: (left: Value, right: Value) => ComparisonExpression;
|
|
1102
|
-
lte: (left: Value, right: Value) => ComparisonExpression;
|
|
1103
|
-
comparison: (left: Value, operator: ComparisonOperators, right: Value) => ComparisonExpression;
|
|
1104
|
-
contains: (left: Value, right: string) => BooleanValueExpression;
|
|
1105
|
-
notContains: (left: Value, right: string) => BooleanValueExpression;
|
|
1106
|
-
startsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1107
|
-
notStartsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1108
|
-
endsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1109
|
-
notEndsWith: (left: Value, right: string) => BooleanValueExpression;
|
|
1110
|
-
in: (left: Value, right: StrOrNum[] | Query | RawExpression) => BooleanValueExpression;
|
|
1111
|
-
notIn: (left: Value, values: StrOrNum[]) => InExpression;
|
|
1112
|
-
between: (left: Value, begin: Value, end: Value) => BetweenExpression;
|
|
1113
|
-
isNull: (expr: Value) => IsNullExpression;
|
|
1114
|
-
isNotNull: (expr: Value) => IsNullExpression;
|
|
1115
|
-
exists: (query: RawExpression | Query) => ExistsExpression;
|
|
1116
|
-
};
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
declare const gqlResolveInfoToField: <T extends Fields<any> = Fields<unknown>>(info: GraphQLResolveInfo$1) => T;
|
|
1120
|
-
|
|
1121
|
-
declare const getCurrentDateTimeString: () => string;
|
|
1122
|
-
|
|
1123
|
-
declare const getDbClient: (connectionOption?: Partial<mysql2.ConnectionOptions> | undefined, poolOption?: Partial<mysql2.PoolOptions> | undefined, logger?: ((query: string) => void) | undefined) => DBClient;
|
|
1124
|
-
|
|
1125
|
-
type Obj = {
|
|
1126
|
-
[key: string]: any;
|
|
1127
|
-
};
|
|
1128
|
-
declare const assignDeep: (base: Obj, ...objects: Obj[]) => Obj;
|
|
1129
|
-
|
|
1130
|
-
type TypeDef = Record<string, TypeFieldDefinition>;
|
|
1131
|
-
declare const createTypeDef: (typeDefs: Record<string, TypeDef>, inputs: Record<string, TypeDef>) => string;
|
|
1132
|
-
|
|
1133
|
-
type ConditionExpression<T> = ComparisonExpression$1<T> | CompositeCondition<T>;
|
|
1134
|
-
|
|
1135
|
-
declare class CompositeCondition<T> {
|
|
1136
|
-
private type;
|
|
1137
|
-
private conditions;
|
|
1138
|
-
private constructor();
|
|
1139
|
-
static or<T>(conditions: ConditionExpression<T>[]): CompositeCondition<T>;
|
|
1140
|
-
static and<T>(conditions: ConditionExpression<T>[]): CompositeCondition<T>;
|
|
1141
|
-
toSQL(): string;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
declare const dateOffset: (date: Date, timeZoneHour?: number) => Date;
|
|
1145
|
-
declare const dateToDatetimeString: (d: Date) => string;
|
|
1146
|
-
declare const dateToDateString: (d: Date) => string;
|
|
1147
|
-
declare const getTodayDateString: (timeZoneHour?: number) => string;
|
|
1148
|
-
declare const getTodayDateTimeString: (timeZoneHour?: number) => string;
|
|
1149
|
-
declare const getDayRange: (date: Date, timeZoneHour?: number) => [string, string];
|
|
1150
|
-
declare const getDayRangeQExpr: (date: Date, timeZoneHour?: number) => [Literal, Literal];
|
|
1151
|
-
|
|
1152
|
-
declare const pick: <T extends object>(target: T, keys: Array<keyof T>) => {
|
|
1153
|
-
[k: string]: T[keyof T];
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
type DsPagingOption = {
|
|
1157
|
-
numberOfItem: number;
|
|
1158
|
-
where?: BooleanValueExpression;
|
|
1159
|
-
offset?: number;
|
|
1160
|
-
sort?: Sort[];
|
|
1161
|
-
};
|
|
1162
|
-
declare const pagingOption: (option: ListQueryOption) => DsPagingOption;
|
|
1163
|
-
|
|
1164
|
-
type PagingOption = ListQueryOption;
|
|
1165
|
-
|
|
1166
|
-
export { CompositeCondition, Conditions, Mutations, QExpr, Queries, SQLClient, SQLTransaction, SasatDBDatasource, Sql, SqlString, assignDeep, createTypeDef, dateOffset, dateToDateString, dateToDatetimeString, formatQuery, getCurrentDateTimeString, getDayRange, getDayRangeQExpr, getDbClient, getTodayDateString, getTodayDateTimeString, gqlResolveInfoToField, makeNumberIdEncoder, makeParamsMiddleware, makeResolver, pagingOption, pick, QExpr as qe, queryToSql, setConfig };
|
|
1167
|
-
export type { BooleanValueExpression, CommandResponse, ComparisonOperators, CustomCondition, EntityResult, EntityType, Fields, ListQueryOption, LockMode, MigrationStore, PagingOption, Query, QueryOptions, QueryResponse, Relation, RelationMap, ResolverMiddleware, SQLExecutor, SasatMigration, TableInfo, TypeFieldDefinition };
|