sasat 0.22.4 → 0.22.5
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/cli/index.cjs +16 -15
- package/dist/cli/index.mjs +2 -1
- package/dist/comparison-BpTtc1iD.d.mts +42 -0
- package/dist/comparison-CIb9xu5T.d.cts +42 -0
- package/dist/dbClient-2mFJTQw7.d.mts +35 -0
- package/dist/dbClient-Bnk1JKBU.d.cts +35 -0
- package/dist/index.cjs +31 -94
- package/dist/index.d.cts +3 -738
- package/dist/index.d.mts +4 -739
- package/dist/index.mjs +3 -62
- package/dist/makeCondition-3MdYUm5k.mjs +134 -0
- package/dist/makeCondition-DKSyAkri.cjs +139 -0
- package/dist/{migrate-BRNxkHCx.cjs → migrate-BDE07ocG.cjs} +3013 -3511
- package/dist/{migrate-Cbj2OVbY.mjs → migrate-DnqBdQ6r.mjs} +3019 -3385
- package/dist/migration/index.cjs +64 -0
- package/dist/migration/index.d.cts +657 -0
- package/dist/migration/index.d.mts +657 -0
- package/dist/migration/index.mjs +61 -0
- package/dist/testing/index.cjs +3 -0
- package/dist/testing/index.d.cts +12 -0
- package/dist/testing/index.d.mts +12 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/util-C5Jevn5B.cjs +377 -0
- package/dist/util-Dkw5bD7a.mjs +239 -0
- package/package.json +9 -1
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
import { a as NestedPartial, n as ComparisonOperators, r as SasatConfig } from "../comparison-CIb9xu5T.cjs";
|
|
2
|
+
import { s as SqlValueType } from "../dbClient-Bnk1JKBU.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/migration/data/relation.d.ts
|
|
5
|
+
type Relation = "One" | "OneOrZero" | "Many";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/migration/column/columnTypes.d.ts
|
|
8
|
+
declare enum DBColumnTypes {
|
|
9
|
+
char = "char",
|
|
10
|
+
varchar = "varchar",
|
|
11
|
+
text = "text",
|
|
12
|
+
tinyInt = "tinyint",
|
|
13
|
+
smallInt = "smallint",
|
|
14
|
+
mediumInt = "mediumint",
|
|
15
|
+
int = "int",
|
|
16
|
+
bigInt = "bigint",
|
|
17
|
+
float = "float",
|
|
18
|
+
double = "double",
|
|
19
|
+
decimal = "decimal",
|
|
20
|
+
year = "year",
|
|
21
|
+
date = "date",
|
|
22
|
+
time = "time",
|
|
23
|
+
dateTime = "datetime",
|
|
24
|
+
timestamp = "timestamp",
|
|
25
|
+
boolean = "boolean"
|
|
26
|
+
}
|
|
27
|
+
type DBType = "char" | "varchar" | "text" | "tinyint" | "smallint" | "mediumint" | "int" | "bigint" | "float" | "double" | "decimal" | "year" | "date" | "time" | "datetime" | "timestamp" | "boolean";
|
|
28
|
+
type DBStringTypes = DBColumnTypes.char | DBColumnTypes.varchar;
|
|
29
|
+
type DBTextTypes = DBColumnTypes.text;
|
|
30
|
+
type DBIntegerTypes = DBColumnTypes.tinyInt | DBColumnTypes.smallInt | DBColumnTypes.mediumInt | DBColumnTypes.int | DBColumnTypes.bigInt;
|
|
31
|
+
type DBFloatingTypes = DBColumnTypes.float | DBColumnTypes.double;
|
|
32
|
+
type DBDateTypes = DBColumnTypes.time | DBColumnTypes.date | DBColumnTypes.year;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/generatorv2/nodes/ConditionValues.d.ts
|
|
35
|
+
type ContextConditionValue = {
|
|
36
|
+
kind: "context";
|
|
37
|
+
field: string;
|
|
38
|
+
onNotDefined: OnNotDefinedAction;
|
|
39
|
+
};
|
|
40
|
+
type FixedConditionValue = {
|
|
41
|
+
kind: "fixed";
|
|
42
|
+
value: string | number;
|
|
43
|
+
};
|
|
44
|
+
type TodayStartConditionValue = {
|
|
45
|
+
kind: "today";
|
|
46
|
+
type: "date" | "datetime";
|
|
47
|
+
thresholdHour?: number;
|
|
48
|
+
};
|
|
49
|
+
type NowConditionValue = {
|
|
50
|
+
kind: "now";
|
|
51
|
+
};
|
|
52
|
+
type OnNotDefinedAction = {
|
|
53
|
+
action: "error";
|
|
54
|
+
message: string;
|
|
55
|
+
} | {
|
|
56
|
+
action: "defaultValue";
|
|
57
|
+
value: string | number;
|
|
58
|
+
};
|
|
59
|
+
type ConditionValue = ContextConditionValue | FixedConditionValue | TodayStartConditionValue | NowConditionValue;
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/generatorv2/nodes/JoinConditionNode.d.ts
|
|
62
|
+
type JoinConditionValue = {
|
|
63
|
+
kind: "parent" | "child";
|
|
64
|
+
field: string;
|
|
65
|
+
} | ConditionValue;
|
|
66
|
+
type JoinConditionRangeValue = {
|
|
67
|
+
kind: "range";
|
|
68
|
+
begin: JoinConditionValue;
|
|
69
|
+
end: JoinConditionValue;
|
|
70
|
+
} | DateRangeConditionValue;
|
|
71
|
+
type DateRangeConditionValue = {
|
|
72
|
+
kind: "date-range";
|
|
73
|
+
range: "today";
|
|
74
|
+
thresholdHour?: number;
|
|
75
|
+
};
|
|
76
|
+
type JoinConditionNode = {
|
|
77
|
+
kind: "comparison";
|
|
78
|
+
left: JoinConditionValue;
|
|
79
|
+
operator: ComparisonOperators;
|
|
80
|
+
right: JoinConditionValue;
|
|
81
|
+
} | {
|
|
82
|
+
kind: "comparison";
|
|
83
|
+
left: JoinConditionValue;
|
|
84
|
+
operator: "BETWEEN";
|
|
85
|
+
right: JoinConditionRangeValue;
|
|
86
|
+
} | {
|
|
87
|
+
kind: "comparison";
|
|
88
|
+
left: JoinConditionValue;
|
|
89
|
+
operator: "IN";
|
|
90
|
+
right: JoinConditionValue[];
|
|
91
|
+
} | {
|
|
92
|
+
kind: "isNull";
|
|
93
|
+
value: JoinConditionValue;
|
|
94
|
+
not: boolean;
|
|
95
|
+
} | JoinCustomConditionNode;
|
|
96
|
+
type JoinCustomConditionNode = {
|
|
97
|
+
kind: "custom";
|
|
98
|
+
conditionName: string;
|
|
99
|
+
parentRequiredFields?: string[];
|
|
100
|
+
childRequiredFields?: string[];
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/migration/data/virtualRelation.d.ts
|
|
104
|
+
type VirtualRelation = {
|
|
105
|
+
parentTable: string;
|
|
106
|
+
childTable: string;
|
|
107
|
+
parentFieldName?: string;
|
|
108
|
+
childFieldName?: string;
|
|
109
|
+
conditions: JoinConditionNode[];
|
|
110
|
+
parentType?: "array" | "nullable" | "notnull";
|
|
111
|
+
childType?: "array" | "nullable" | "notnull";
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/generatorv2/scripts/gqlTypes.d.ts
|
|
115
|
+
type GQLPrimitive = "Int" | "Float" | "String" | "Boolean" | "ID";
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/migration/data/foreignKey.d.ts
|
|
118
|
+
type ForeignKeyReferentialAction = "RESTRICT" | "CASCADE" | "SET NULL" | "NO ACTION";
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/migration/serialized/serializedColumn.d.ts
|
|
121
|
+
type ColumnOptions = {
|
|
122
|
+
updatable: boolean;
|
|
123
|
+
autoIncrementHashId: boolean;
|
|
124
|
+
hashSalt?: string;
|
|
125
|
+
};
|
|
126
|
+
interface SerializedColumnBase {
|
|
127
|
+
hasReference: boolean;
|
|
128
|
+
fieldName: string;
|
|
129
|
+
columnName: string;
|
|
130
|
+
type: DBColumnTypes;
|
|
131
|
+
notNull: boolean;
|
|
132
|
+
default: SqlValueType | undefined;
|
|
133
|
+
zerofill: boolean;
|
|
134
|
+
signed: boolean | undefined;
|
|
135
|
+
autoIncrement: boolean;
|
|
136
|
+
length: number | undefined;
|
|
137
|
+
scale: number | undefined;
|
|
138
|
+
defaultCurrentTimeStamp: boolean;
|
|
139
|
+
onUpdateCurrentTimeStamp: boolean;
|
|
140
|
+
option: ColumnOptions;
|
|
141
|
+
}
|
|
142
|
+
interface SerializedNormalColumn extends SerializedColumnBase {
|
|
143
|
+
hasReference: false;
|
|
144
|
+
}
|
|
145
|
+
interface Reference {
|
|
146
|
+
parentTable: string;
|
|
147
|
+
parentColumn: string;
|
|
148
|
+
columnName: string;
|
|
149
|
+
relation: Relation;
|
|
150
|
+
parentFieldName?: string;
|
|
151
|
+
fieldName?: string;
|
|
152
|
+
relationName?: string;
|
|
153
|
+
onUpdate?: ForeignKeyReferentialAction;
|
|
154
|
+
onDelete?: ForeignKeyReferentialAction;
|
|
155
|
+
noFKey?: boolean;
|
|
156
|
+
}
|
|
157
|
+
interface SerializedReferenceColumn extends SerializedColumnBase {
|
|
158
|
+
hasReference: true;
|
|
159
|
+
reference: Reference;
|
|
160
|
+
}
|
|
161
|
+
type SerializedColumn = SerializedNormalColumn | SerializedReferenceColumn;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/migration/serializable/serializable.d.ts
|
|
164
|
+
interface Serializable<T> {
|
|
165
|
+
serialize(): T;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/generatorv2/nodes/entityName.d.ts
|
|
169
|
+
declare class EntityName {
|
|
170
|
+
readonly name: string;
|
|
171
|
+
static fromTableName(tableName: string): EntityName;
|
|
172
|
+
constructor(name: string);
|
|
173
|
+
toString(): string;
|
|
174
|
+
creatableInterface(): string;
|
|
175
|
+
updatable(): string;
|
|
176
|
+
identifiableInterfaceName(): string;
|
|
177
|
+
relationTypeName(): string;
|
|
178
|
+
entityWithRelationTypeName(): string;
|
|
179
|
+
resultType(): string;
|
|
180
|
+
fieldsTypeName(): string;
|
|
181
|
+
dataSourceName(): string;
|
|
182
|
+
generatedDataSourceName(): string;
|
|
183
|
+
lowerCase(): string;
|
|
184
|
+
createInputName(): string;
|
|
185
|
+
updateInputName(): string;
|
|
186
|
+
identifyInputName(): string;
|
|
187
|
+
IDEncoderName(): string;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/migration/data/index.d.ts
|
|
191
|
+
interface Index {
|
|
192
|
+
constraintName: string;
|
|
193
|
+
columns: string[];
|
|
194
|
+
}
|
|
195
|
+
declare class DBIndex implements Index, Serializable<Index> {
|
|
196
|
+
readonly tableName: string;
|
|
197
|
+
readonly columns: string[];
|
|
198
|
+
readonly constraintName: string;
|
|
199
|
+
constructor(tableName: string, columns: string[]);
|
|
200
|
+
private toConstraintName;
|
|
201
|
+
addSql(): string;
|
|
202
|
+
dropSql(): string;
|
|
203
|
+
serialize(): Index;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/migration/serialized/serializedStore.d.ts
|
|
207
|
+
interface SerializedTable {
|
|
208
|
+
columns: SerializedColumn[];
|
|
209
|
+
primaryKey: string[];
|
|
210
|
+
uniqueKeys: string[][];
|
|
211
|
+
indexes: Index[];
|
|
212
|
+
tableName: string;
|
|
213
|
+
gqlOption: GQLOption;
|
|
214
|
+
virtualRelations: VirtualRelation[];
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/migration/serializable/table.d.ts
|
|
218
|
+
interface Table extends Serializable<SerializedTable> {
|
|
219
|
+
column(columnName: string): BaseColumn;
|
|
220
|
+
tableName: string;
|
|
221
|
+
gqlOption: GQLOption;
|
|
222
|
+
primaryKey: string[];
|
|
223
|
+
}
|
|
224
|
+
declare class TableHandler implements Table {
|
|
225
|
+
store: DataStore;
|
|
226
|
+
private indexes;
|
|
227
|
+
get index(): DBIndex[];
|
|
228
|
+
private _columns;
|
|
229
|
+
get columns(): BaseColumn[];
|
|
230
|
+
private readonly _virtualRelations;
|
|
231
|
+
get virtualRelations(): VirtualRelation[];
|
|
232
|
+
addVirtualRelation(relation: Omit<VirtualRelation, "childTable">): void;
|
|
233
|
+
primaryKey: string[];
|
|
234
|
+
readonly uniqueKeys: string[][];
|
|
235
|
+
readonly tableName: string;
|
|
236
|
+
private _gqlOption;
|
|
237
|
+
get gqlOption(): GQLOption;
|
|
238
|
+
constructor(table: Partial<SerializedTable> & Pick<SerializedTable, "tableName">, store: DataStore);
|
|
239
|
+
column(columnName: string): BaseColumn;
|
|
240
|
+
addColumn(column: BaseColumn, isPrimary?: boolean, isUnique?: boolean): void;
|
|
241
|
+
dropColumn(columnName: string): void;
|
|
242
|
+
serialize(): SerializedTable;
|
|
243
|
+
addReferences(ref: Reference, fieldName?: string, notNull?: boolean): this;
|
|
244
|
+
private getIndexConstraintName;
|
|
245
|
+
addIndex(...columns: string[]): this;
|
|
246
|
+
removeIndex(...columns: string[]): this;
|
|
247
|
+
addUniqueKey(...columnNames: string[]): this;
|
|
248
|
+
setPrimaryKey(...columnNames: string[]): this;
|
|
249
|
+
showCreateTable(): string;
|
|
250
|
+
hasColumn(columnName: string): boolean;
|
|
251
|
+
isColumnPrimary(columnName: string): boolean;
|
|
252
|
+
getEntityName(): EntityName;
|
|
253
|
+
setGQLOption(option: Partial<GQLOption>): void;
|
|
254
|
+
getReferenceColumns(): ReferenceColumn[];
|
|
255
|
+
addForeignKey(reference: Reference): void;
|
|
256
|
+
changeType(columnName: string, type: DBColumnTypes): void;
|
|
257
|
+
setDefault(columnName: string, value: string | number | null): void;
|
|
258
|
+
protected updateColumn(columnName: string, diff: Partial<SerializedColumn>): void;
|
|
259
|
+
getPrimaryKeyColumns(): BaseColumn[];
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/migration/serializable/column.d.ts
|
|
263
|
+
interface Column extends Serializable<SerializedColumn> {
|
|
264
|
+
fieldName(): string;
|
|
265
|
+
columnName(): string;
|
|
266
|
+
dataType(): DBColumnTypes;
|
|
267
|
+
toSql(): string;
|
|
268
|
+
isReference(): this is ReferenceColumn;
|
|
269
|
+
isNullable(): boolean;
|
|
270
|
+
tsType(): string;
|
|
271
|
+
gqlType(): GQLPrimitive;
|
|
272
|
+
isNullableOnCreate(): boolean;
|
|
273
|
+
}
|
|
274
|
+
declare class BaseColumn implements Column {
|
|
275
|
+
data: SerializedColumn;
|
|
276
|
+
table: Table;
|
|
277
|
+
constructor(data: SerializedColumn, table: Table);
|
|
278
|
+
fieldName(): string;
|
|
279
|
+
columnName(): string;
|
|
280
|
+
dataType(): DBColumnTypes;
|
|
281
|
+
tsType(): string;
|
|
282
|
+
gqlType(): GQLPrimitive;
|
|
283
|
+
isNullable(): boolean;
|
|
284
|
+
isNullableOnCreate(): boolean;
|
|
285
|
+
isReference(): this is ReferenceColumn;
|
|
286
|
+
serialize(): SerializedColumn;
|
|
287
|
+
toSql(): string;
|
|
288
|
+
isPrimary(): boolean;
|
|
289
|
+
isUpdatable(): boolean;
|
|
290
|
+
}
|
|
291
|
+
declare class ReferenceColumn extends BaseColumn {
|
|
292
|
+
data: SerializedReferenceColumn;
|
|
293
|
+
constructor(data: SerializedReferenceColumn, table: Table);
|
|
294
|
+
getConstraintName(): string;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region src/migration/dataStore.d.ts
|
|
298
|
+
interface DataStore {
|
|
299
|
+
table(tableName: string): Table;
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/generatorv2/nodes/QueryConditionNode.d.ts
|
|
303
|
+
type QueryConditionValue = ConditionValue | FieldQueryConditionValue | ArgQueryConditionValue;
|
|
304
|
+
type FieldQueryConditionValue = {
|
|
305
|
+
kind: "field";
|
|
306
|
+
column: string;
|
|
307
|
+
};
|
|
308
|
+
type ArgQueryConditionValue = {
|
|
309
|
+
kind: "arg";
|
|
310
|
+
name: string;
|
|
311
|
+
type: "Int" | "Float" | "String" | string;
|
|
312
|
+
};
|
|
313
|
+
type QueryConditionNode = {
|
|
314
|
+
kind: "comparison";
|
|
315
|
+
left: QueryConditionValue;
|
|
316
|
+
operator: ComparisonOperators;
|
|
317
|
+
right: QueryConditionValue;
|
|
318
|
+
} | {
|
|
319
|
+
kind: "between";
|
|
320
|
+
left: QueryConditionValue;
|
|
321
|
+
operator: "BETWEEN";
|
|
322
|
+
begin: QueryConditionValue;
|
|
323
|
+
end: QueryConditionValue;
|
|
324
|
+
};
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/migration/data/GQLOption.d.ts
|
|
327
|
+
interface GqlFromContextParam {
|
|
328
|
+
column: string;
|
|
329
|
+
contextName?: string;
|
|
330
|
+
}
|
|
331
|
+
type GQLMutation = {
|
|
332
|
+
type: "create" | "update" | "delete";
|
|
333
|
+
noReFetch: boolean;
|
|
334
|
+
middlewares: string[];
|
|
335
|
+
contextFields: GqlFromContextParam[];
|
|
336
|
+
subscription: {
|
|
337
|
+
enabled: boolean;
|
|
338
|
+
subscriptionFilter: string[];
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
type GQLQuery = {
|
|
342
|
+
type: "single" | "list-all" | "list-paging";
|
|
343
|
+
name: string;
|
|
344
|
+
conditions: QueryConditionNode[];
|
|
345
|
+
middlewares: string[];
|
|
346
|
+
} | {
|
|
347
|
+
type: "primary";
|
|
348
|
+
name?: never;
|
|
349
|
+
conditions: never[];
|
|
350
|
+
middlewares: string[];
|
|
351
|
+
};
|
|
352
|
+
interface GQLOption {
|
|
353
|
+
enabled: boolean;
|
|
354
|
+
queries: GQLQuery[];
|
|
355
|
+
mutations: GQLMutation[];
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/migration/creators/columnBuilder.d.ts
|
|
359
|
+
declare abstract class ColumnBuilderBase {
|
|
360
|
+
readonly columnName: string;
|
|
361
|
+
protected _primary: boolean;
|
|
362
|
+
protected _notNull: boolean;
|
|
363
|
+
protected _unique: boolean;
|
|
364
|
+
protected _option: ColumnOptions;
|
|
365
|
+
protected _fieldName: string;
|
|
366
|
+
protected constructor(columnName: string);
|
|
367
|
+
fieldName(fieldName: string): this;
|
|
368
|
+
notNull(): this;
|
|
369
|
+
nullable(): this;
|
|
370
|
+
primary(): this;
|
|
371
|
+
unique(): this;
|
|
372
|
+
updatable(updatable: boolean): this;
|
|
373
|
+
abstract build(): {
|
|
374
|
+
data: SerializedColumn;
|
|
375
|
+
isPrimary: boolean;
|
|
376
|
+
isUnique: boolean;
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
declare abstract class ColumnBuilder extends ColumnBuilderBase {
|
|
380
|
+
protected type: DBColumnTypes;
|
|
381
|
+
protected length?: number | undefined;
|
|
382
|
+
protected scale?: number | undefined;
|
|
383
|
+
protected _zerofill: boolean;
|
|
384
|
+
protected _signed: boolean | undefined;
|
|
385
|
+
protected _autoIncrement: boolean;
|
|
386
|
+
protected _default: SqlValueType | undefined;
|
|
387
|
+
protected _defaultCurrentTimeStamp: boolean;
|
|
388
|
+
protected _onUpdateCurrentTimeStamp: boolean;
|
|
389
|
+
protected constructor(name: string, type: DBColumnTypes, length?: number | undefined, scale?: number | undefined);
|
|
390
|
+
default(value: SqlValueType | undefined): this;
|
|
391
|
+
build(): {
|
|
392
|
+
data: SerializedNormalColumn;
|
|
393
|
+
isPrimary: boolean;
|
|
394
|
+
isUnique: boolean;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
declare class StringColumnBuilder extends ColumnBuilder {
|
|
398
|
+
readonly name: string;
|
|
399
|
+
protected type: DBStringTypes;
|
|
400
|
+
protected length?: number | undefined;
|
|
401
|
+
constructor(name: string, type: DBStringTypes, length?: number | undefined);
|
|
402
|
+
default(value: string | null | undefined): this;
|
|
403
|
+
}
|
|
404
|
+
declare class TextColumnBuilder extends ColumnBuilder {
|
|
405
|
+
readonly name: string;
|
|
406
|
+
protected type: DBTextTypes;
|
|
407
|
+
constructor(name: string, type: DBTextTypes);
|
|
408
|
+
default(value: string | null | undefined): this;
|
|
409
|
+
}
|
|
410
|
+
declare class NumberColumnBuilder extends ColumnBuilder {
|
|
411
|
+
signed(): this;
|
|
412
|
+
unsigned(): this;
|
|
413
|
+
zerofill(): this;
|
|
414
|
+
default(value: number | null | undefined): this;
|
|
415
|
+
}
|
|
416
|
+
declare class IntegerColumnBuilder extends NumberColumnBuilder {
|
|
417
|
+
readonly name: string;
|
|
418
|
+
protected type: DBIntegerTypes;
|
|
419
|
+
protected length?: number | undefined;
|
|
420
|
+
constructor(name: string, type: DBIntegerTypes, length?: number | undefined);
|
|
421
|
+
autoIncrement(): this;
|
|
422
|
+
}
|
|
423
|
+
declare class FloatColumnBuilder extends NumberColumnBuilder {
|
|
424
|
+
readonly name: string;
|
|
425
|
+
protected type: DBFloatingTypes;
|
|
426
|
+
protected length?: number | undefined;
|
|
427
|
+
protected scale?: number | undefined;
|
|
428
|
+
constructor(name: string, type: DBFloatingTypes, length?: number | undefined, scale?: number | undefined);
|
|
429
|
+
autoIncrement(): this;
|
|
430
|
+
}
|
|
431
|
+
declare class DecimalColumnBuilder extends NumberColumnBuilder {
|
|
432
|
+
readonly name: string;
|
|
433
|
+
protected type: DBColumnTypes.decimal;
|
|
434
|
+
protected length?: number | undefined;
|
|
435
|
+
protected scale?: number | undefined;
|
|
436
|
+
constructor(name: string, type: DBColumnTypes.decimal, length?: number | undefined, scale?: number | undefined);
|
|
437
|
+
}
|
|
438
|
+
declare class DateColumnBuilder extends ColumnBuilder {
|
|
439
|
+
readonly name: string;
|
|
440
|
+
protected type: DBDateTypes;
|
|
441
|
+
constructor(name: string, type: DBDateTypes);
|
|
442
|
+
default(value: string | number | null | undefined): this;
|
|
443
|
+
}
|
|
444
|
+
declare class TimeStampColumnBuilder extends ColumnBuilder {
|
|
445
|
+
readonly name: string;
|
|
446
|
+
protected type: DBColumnTypes.timestamp | DBColumnTypes.dateTime;
|
|
447
|
+
constructor(name: string, type: DBColumnTypes.timestamp | DBColumnTypes.dateTime);
|
|
448
|
+
default(value: "CURRENT_TIMESTAMP" | string | null | undefined): this;
|
|
449
|
+
defaultCurrentTimeStamp(): this;
|
|
450
|
+
onUpdateCurrentTimeStamp(): this;
|
|
451
|
+
}
|
|
452
|
+
declare class ReferenceColumnBuilder extends ColumnBuilderBase {
|
|
453
|
+
protected readonly ref: Reference;
|
|
454
|
+
protected readonly parent: Column;
|
|
455
|
+
constructor(ref: Reference, parent: Column);
|
|
456
|
+
notNull(): this;
|
|
457
|
+
nullable(): this;
|
|
458
|
+
primary(): this;
|
|
459
|
+
unique(): this;
|
|
460
|
+
build(): {
|
|
461
|
+
data: SerializedReferenceColumn;
|
|
462
|
+
isPrimary: boolean;
|
|
463
|
+
isUnique: boolean;
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/migration/creators/columnCreator.d.ts
|
|
468
|
+
declare class ColumnCreator {
|
|
469
|
+
private table;
|
|
470
|
+
private name;
|
|
471
|
+
constructor(table: TableCreator, name: string);
|
|
472
|
+
char: (length: number) => StringColumnBuilder;
|
|
473
|
+
varchar: (length: number) => StringColumnBuilder;
|
|
474
|
+
text: () => TextColumnBuilder;
|
|
475
|
+
tinyInt: (length?: number) => IntegerColumnBuilder;
|
|
476
|
+
smallInt: (length?: number) => IntegerColumnBuilder;
|
|
477
|
+
mediumInt: (length?: number) => IntegerColumnBuilder;
|
|
478
|
+
int: (length?: number) => IntegerColumnBuilder;
|
|
479
|
+
bigInt: (length?: number) => IntegerColumnBuilder;
|
|
480
|
+
float: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
481
|
+
double: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
482
|
+
decimal: (length?: number, scale?: number) => DecimalColumnBuilder;
|
|
483
|
+
year: () => DateColumnBuilder;
|
|
484
|
+
date: () => DateColumnBuilder;
|
|
485
|
+
time: () => DateColumnBuilder;
|
|
486
|
+
dateTime: () => TimeStampColumnBuilder;
|
|
487
|
+
timestamp: () => TimeStampColumnBuilder;
|
|
488
|
+
private create;
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/migration/creators/tableCreator.d.ts
|
|
492
|
+
interface TableBuilder {
|
|
493
|
+
autoIncrementHashId(columnName: string, option?: {
|
|
494
|
+
salt?: string;
|
|
495
|
+
bigint?: boolean;
|
|
496
|
+
}): TableBuilder;
|
|
497
|
+
column(columnName: string): ColumnCreator;
|
|
498
|
+
addVirtualRelation(relation: Omit<VirtualRelation, "childTable">): TableBuilder;
|
|
499
|
+
references(reference: Reference, notNull?: boolean): ColumnBuilderBase;
|
|
500
|
+
setPrimaryKey(...columnNames: string[]): TableBuilder;
|
|
501
|
+
addUniqueKey(...columnNames: string[]): TableBuilder;
|
|
502
|
+
createdAt(): TableBuilder;
|
|
503
|
+
updatedAt(): TableBuilder;
|
|
504
|
+
addIndex(...columns: string[]): TableBuilder;
|
|
505
|
+
enableGQL(): TableBuilder;
|
|
506
|
+
setGQLOption(option: Partial<GQLOption>): TableBuilder;
|
|
507
|
+
addGQLQuery(...query: GQLQuery[]): TableBuilder;
|
|
508
|
+
addGQLMutation(...mutation: GQLMutation[]): TableBuilder;
|
|
509
|
+
}
|
|
510
|
+
declare class TableCreator implements TableBuilder {
|
|
511
|
+
tableName: string;
|
|
512
|
+
protected readonly store: DataStore;
|
|
513
|
+
private readonly table;
|
|
514
|
+
private readonly columns;
|
|
515
|
+
constructor(tableName: string, store: DataStore);
|
|
516
|
+
autoIncrementHashId(columnName: string, option?: {
|
|
517
|
+
salt?: string;
|
|
518
|
+
bigint?: boolean;
|
|
519
|
+
}): TableBuilder;
|
|
520
|
+
column(name: string): ColumnCreator;
|
|
521
|
+
addVirtualRelation(relation: Omit<VirtualRelation, "childTable">): this;
|
|
522
|
+
addColumn(column: ColumnBuilderBase): void;
|
|
523
|
+
addUniqueKey(...columnNames: string[]): TableBuilder;
|
|
524
|
+
references(ref: Reference): ReferenceColumnBuilder;
|
|
525
|
+
setPrimaryKey(...columnNames: string[]): TableBuilder;
|
|
526
|
+
create(): TableHandler;
|
|
527
|
+
createdAt(): TableBuilder;
|
|
528
|
+
updatedAt(): TableBuilder;
|
|
529
|
+
addIndex(...columns: string[]): TableBuilder;
|
|
530
|
+
enableGQL(): TableBuilder;
|
|
531
|
+
setGQLOption(option: Partial<GQLOption>): TableBuilder;
|
|
532
|
+
addGQLQuery(...query: GQLQuery[]): TableBuilder;
|
|
533
|
+
addGQLMutation(...mutation: GQLMutation[]): TableBuilder;
|
|
534
|
+
}
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/migration/creators/createColumn.d.ts
|
|
537
|
+
type CreateColumn = {
|
|
538
|
+
char: (length: number) => StringColumnBuilder;
|
|
539
|
+
varchar: (length: number) => StringColumnBuilder;
|
|
540
|
+
text: () => TextColumnBuilder;
|
|
541
|
+
tinyInt: (length?: number) => IntegerColumnBuilder;
|
|
542
|
+
smallInt: (length?: number) => IntegerColumnBuilder;
|
|
543
|
+
mediumInt: (length?: number) => IntegerColumnBuilder;
|
|
544
|
+
int: (length?: number) => IntegerColumnBuilder;
|
|
545
|
+
bigInt: (length?: number) => IntegerColumnBuilder;
|
|
546
|
+
float: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
547
|
+
double: (length?: number, scale?: number) => FloatColumnBuilder;
|
|
548
|
+
decimal: (length?: number, scale?: number) => DecimalColumnBuilder;
|
|
549
|
+
year: () => DateColumnBuilder;
|
|
550
|
+
date: () => DateColumnBuilder;
|
|
551
|
+
time: () => DateColumnBuilder;
|
|
552
|
+
dateTime: () => TimeStampColumnBuilder;
|
|
553
|
+
timestamp: () => TimeStampColumnBuilder;
|
|
554
|
+
};
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/migration/front/tableMigrator.d.ts
|
|
557
|
+
interface MigrationTable extends Table {
|
|
558
|
+
addIndex(...columns: string[]): MigrationTable;
|
|
559
|
+
removeIndex(...columns: string[]): MigrationTable;
|
|
560
|
+
addColumn(name: string, create: (column: CreateColumn) => ColumnBuilder): MigrationTable;
|
|
561
|
+
_addColumn(column: SerializedColumn): MigrationTable;
|
|
562
|
+
dropColumn(columnName: string): MigrationTable;
|
|
563
|
+
addForeignKey(reference: Reference): MigrationTable;
|
|
564
|
+
changeColumnType(columnName: string, type: DBType): MigrationTable;
|
|
565
|
+
setDefault(columnName: string, value: string | number | null): MigrationTable;
|
|
566
|
+
enableGQL(): MigrationTable;
|
|
567
|
+
setGQLOption(option: GQLOption): MigrationTable;
|
|
568
|
+
addGQLQuery(...queries: GQLQuery[]): MigrationTable;
|
|
569
|
+
addGQLMutation(...mutations: GQLMutation[]): MigrationTable;
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/migration/front/storeMigrator.d.ts
|
|
573
|
+
interface MigrationStore extends DataStore {
|
|
574
|
+
createTable(tableName: string, tableCreator: (table: TableBuilder) => void): MigrationStore;
|
|
575
|
+
dropTable(tableName: string): MigrationStore;
|
|
576
|
+
table(tableName: string): MigrationTable;
|
|
577
|
+
sql(...sql: string[]): MigrationStore;
|
|
578
|
+
setConfig(config: NestedPartial<SasatConfig>): MigrationStore;
|
|
579
|
+
}
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/migration/front/migration.d.ts
|
|
582
|
+
interface SasatMigration {
|
|
583
|
+
up: (store: MigrationStore) => void | Promise<void>;
|
|
584
|
+
down: (store: MigrationStore) => void | Promise<void>;
|
|
585
|
+
beforeUp?: () => void | Promise<void>;
|
|
586
|
+
afterUp?: () => void | Promise<void>;
|
|
587
|
+
beforeDown?: () => void | Promise<void>;
|
|
588
|
+
afterDown?: () => void | Promise<void>;
|
|
589
|
+
}
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region src/migration/makeCondition.d.ts
|
|
592
|
+
declare const Conditions: {
|
|
593
|
+
readonly betweenRel: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
|
|
594
|
+
readonly betweenQuery: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
|
|
595
|
+
readonly custom: (conditionName: string, parentRequiredFields?: string[], childRequiredFields?: string[]) => JoinConditionNode;
|
|
596
|
+
readonly rel: {
|
|
597
|
+
readonly between: (left: JoinConditionValue, range: JoinConditionRangeValue) => JoinConditionNode;
|
|
598
|
+
readonly comparison: (left: JoinConditionValue, operator: ComparisonOperators, right: JoinConditionValue) => JoinConditionNode;
|
|
599
|
+
readonly in: (left: JoinConditionValue, right: JoinConditionValue[]) => JoinConditionNode;
|
|
600
|
+
readonly isNull: (value: JoinConditionValue) => JoinConditionNode;
|
|
601
|
+
readonly isNotNull: (value: JoinConditionValue) => JoinConditionNode;
|
|
602
|
+
};
|
|
603
|
+
readonly query: {
|
|
604
|
+
readonly between: (left: QueryConditionValue, begin: QueryConditionValue, end: QueryConditionValue) => QueryConditionNode;
|
|
605
|
+
readonly comparison: (left: QueryConditionValue, operator: ComparisonOperators, right: QueryConditionValue) => QueryConditionNode;
|
|
606
|
+
};
|
|
607
|
+
readonly value: {
|
|
608
|
+
readonly parent: (field: string) => JoinConditionValue;
|
|
609
|
+
readonly child: (field: string) => JoinConditionValue;
|
|
610
|
+
readonly contextOrError: (field: string, errorMessage: string) => ConditionValue;
|
|
611
|
+
readonly contextOrDefault: (field: string, defaultValue: string | number) => ConditionValue;
|
|
612
|
+
readonly fixed: (value: string | number) => ConditionValue;
|
|
613
|
+
readonly today: (thresholdHour?: number, date?: boolean) => ConditionValue;
|
|
614
|
+
readonly now: () => ConditionValue;
|
|
615
|
+
readonly field: (column: string) => QueryConditionValue;
|
|
616
|
+
readonly arg: (name: string, type: "Int" | "Float" | "String") => QueryConditionValue;
|
|
617
|
+
};
|
|
618
|
+
readonly range: {
|
|
619
|
+
readonly values: (begin: JoinConditionValue, end: JoinConditionValue) => JoinConditionRangeValue;
|
|
620
|
+
readonly today: (thresholdHour?: number) => JoinConditionRangeValue;
|
|
621
|
+
};
|
|
622
|
+
};
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region src/migration/makeMutaion.d.ts
|
|
625
|
+
type Option = {
|
|
626
|
+
noRefetch?: boolean;
|
|
627
|
+
middlewares?: string[];
|
|
628
|
+
contextFields?: GqlFromContextParam[];
|
|
629
|
+
subscription?: {
|
|
630
|
+
enabled: boolean;
|
|
631
|
+
subscriptionFilter?: string[];
|
|
632
|
+
} | boolean;
|
|
633
|
+
};
|
|
634
|
+
declare const Mutations: {
|
|
635
|
+
create: (options?: Option) => GQLMutation;
|
|
636
|
+
update: (options?: Option) => GQLMutation;
|
|
637
|
+
delete: (options?: Omit<Option, "noRefetch">) => GQLMutation;
|
|
638
|
+
};
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region src/migration/makeQuery.d.ts
|
|
641
|
+
declare const Queries: {
|
|
642
|
+
single: (name: string, options?: {
|
|
643
|
+
conditions?: QueryConditionNode[];
|
|
644
|
+
middlewares?: string[];
|
|
645
|
+
}) => GQLQuery;
|
|
646
|
+
listAll: (name: string, options?: {
|
|
647
|
+
conditions?: QueryConditionNode[];
|
|
648
|
+
middlewares?: string[];
|
|
649
|
+
}) => GQLQuery;
|
|
650
|
+
paging: (name: string, options?: {
|
|
651
|
+
conditions?: QueryConditionNode[];
|
|
652
|
+
middlewares?: string[];
|
|
653
|
+
}) => GQLQuery;
|
|
654
|
+
primary: (middlewares?: string[]) => GQLQuery;
|
|
655
|
+
};
|
|
656
|
+
//#endregion
|
|
657
|
+
export { Conditions, type MigrationStore, Mutations, Queries, type Relation, type SasatMigration };
|