sonamu 0.2.49 → 0.2.50
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/bin/cli-wrapper.d.mts +1 -0
- package/dist/bin/cli-wrapper.mjs +44 -0
- package/dist/bin/cli-wrapper.mjs.map +1 -0
- package/dist/bin/cli.d.mts +2 -0
- package/dist/bin/cli.js +48 -48
- package/dist/bin/cli.mjs +879 -0
- package/dist/bin/cli.mjs.map +1 -0
- package/dist/{chunk-HATLA54Z.js → chunk-4EET56IE.js} +7 -3
- package/dist/chunk-4EET56IE.js.map +1 -0
- package/dist/chunk-HEPO4HGK.mjs +7834 -0
- package/dist/chunk-HEPO4HGK.mjs.map +1 -0
- package/dist/chunk-JXJTFHF7.mjs +20 -0
- package/dist/chunk-JXJTFHF7.mjs.map +1 -0
- package/dist/index.d.mts +1492 -0
- package/dist/index.js +3 -3
- package/dist/index.mjs +429 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +1 -1
- package/src/templates/service.template.ts +9 -1
- package/tsup.config.js +1 -4
- package/dist/chunk-HATLA54Z.js.map +0 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1492 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Knex } from 'knex';
|
|
3
|
+
import { HTTPMethods, FastifyReply, FastifyInstance, FastifyRequest } from 'fastify';
|
|
4
|
+
import { RouteGenericInterface } from 'fastify/types/route';
|
|
5
|
+
import { Server, IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
6
|
+
import ts from 'typescript';
|
|
7
|
+
|
|
8
|
+
type EnumsLabel<T extends string, L extends "ko" | "en"> = {
|
|
9
|
+
[key in T]: {
|
|
10
|
+
[lang in L]: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type EnumsLabelKo<T extends string> = EnumsLabel<T, "ko">;
|
|
14
|
+
declare const SQLDateTimeString: z.ZodString;
|
|
15
|
+
type SQLDateTimeString = z.infer<typeof SQLDateTimeString>;
|
|
16
|
+
declare function zArrayable<T extends z.ZodTypeAny>(shape: T): z.ZodUnion<[T, z.ZodArray<T, "many">]>;
|
|
17
|
+
type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
|
|
18
|
+
type CommonProp = {
|
|
19
|
+
name: string;
|
|
20
|
+
nullable?: boolean;
|
|
21
|
+
toFilter?: true;
|
|
22
|
+
desc?: string;
|
|
23
|
+
dbDefault?: string;
|
|
24
|
+
};
|
|
25
|
+
type IntegerProp = CommonProp & {
|
|
26
|
+
type: "integer";
|
|
27
|
+
unsigned?: true;
|
|
28
|
+
};
|
|
29
|
+
type BigIntegerProp = CommonProp & {
|
|
30
|
+
type: "bigInteger";
|
|
31
|
+
unsigned?: true;
|
|
32
|
+
};
|
|
33
|
+
type TextProp = CommonProp & {
|
|
34
|
+
type: "text";
|
|
35
|
+
textType: "text" | "mediumtext" | "longtext";
|
|
36
|
+
};
|
|
37
|
+
type StringProp = CommonProp & {
|
|
38
|
+
type: "string";
|
|
39
|
+
length: number;
|
|
40
|
+
};
|
|
41
|
+
type EnumProp = CommonProp & {
|
|
42
|
+
type: "enum";
|
|
43
|
+
length: number;
|
|
44
|
+
id: string;
|
|
45
|
+
};
|
|
46
|
+
type FloatProp = CommonProp & {
|
|
47
|
+
type: "float";
|
|
48
|
+
unsigned?: true;
|
|
49
|
+
precision: number;
|
|
50
|
+
scale: number;
|
|
51
|
+
};
|
|
52
|
+
type DoubleProp = CommonProp & {
|
|
53
|
+
type: "double";
|
|
54
|
+
unsigned?: true;
|
|
55
|
+
precision: number;
|
|
56
|
+
scale: number;
|
|
57
|
+
};
|
|
58
|
+
type DecimalProp = CommonProp & {
|
|
59
|
+
type: "decimal";
|
|
60
|
+
unsigned?: true;
|
|
61
|
+
precision: number;
|
|
62
|
+
scale: number;
|
|
63
|
+
};
|
|
64
|
+
type BooleanProp = CommonProp & {
|
|
65
|
+
type: "boolean";
|
|
66
|
+
};
|
|
67
|
+
type DateProp = CommonProp & {
|
|
68
|
+
type: "date";
|
|
69
|
+
};
|
|
70
|
+
type DateTimeProp = CommonProp & {
|
|
71
|
+
type: "dateTime";
|
|
72
|
+
};
|
|
73
|
+
type TimeProp = CommonProp & {
|
|
74
|
+
type: "time";
|
|
75
|
+
};
|
|
76
|
+
type TimestampProp = CommonProp & {
|
|
77
|
+
type: "timestamp";
|
|
78
|
+
};
|
|
79
|
+
type JsonProp = CommonProp & {
|
|
80
|
+
type: "json";
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
type UuidProp = CommonProp & {
|
|
84
|
+
type: "uuid";
|
|
85
|
+
};
|
|
86
|
+
type VirtualProp = CommonProp & {
|
|
87
|
+
type: "virtual";
|
|
88
|
+
id: string;
|
|
89
|
+
};
|
|
90
|
+
type RelationType = "HasMany" | "BelongsToOne" | "ManyToMany" | "OneToOne";
|
|
91
|
+
type RelationOn = "CASCADE" | "SET NULL" | "NO ACTION" | "SET DEFAULT" | "RESTRICT";
|
|
92
|
+
type _RelationProp = {
|
|
93
|
+
type: "relation";
|
|
94
|
+
name: string;
|
|
95
|
+
with: string;
|
|
96
|
+
nullable?: boolean;
|
|
97
|
+
toFilter?: true;
|
|
98
|
+
desc?: string;
|
|
99
|
+
};
|
|
100
|
+
type OneToOneRelationProp = _RelationProp & {
|
|
101
|
+
relationType: "OneToOne";
|
|
102
|
+
customJoinClause?: string;
|
|
103
|
+
} & ({
|
|
104
|
+
hasJoinColumn: true;
|
|
105
|
+
onUpdate: RelationOn;
|
|
106
|
+
onDelete: RelationOn;
|
|
107
|
+
} | {
|
|
108
|
+
hasJoinColumn: false;
|
|
109
|
+
});
|
|
110
|
+
type BelongsToOneRelationProp = _RelationProp & {
|
|
111
|
+
relationType: "BelongsToOne";
|
|
112
|
+
customJoinClause?: string;
|
|
113
|
+
onUpdate: RelationOn;
|
|
114
|
+
onDelete: RelationOn;
|
|
115
|
+
};
|
|
116
|
+
type HasManyRelationProp = _RelationProp & {
|
|
117
|
+
relationType: "HasMany";
|
|
118
|
+
joinColumn: string;
|
|
119
|
+
fromColumn?: string;
|
|
120
|
+
};
|
|
121
|
+
type ManyToManyRelationProp = _RelationProp & {
|
|
122
|
+
relationType: "ManyToMany";
|
|
123
|
+
joinTable: `${string}__${string}`;
|
|
124
|
+
onUpdate: RelationOn;
|
|
125
|
+
onDelete: RelationOn;
|
|
126
|
+
};
|
|
127
|
+
type RelationProp = OneToOneRelationProp | BelongsToOneRelationProp | HasManyRelationProp | ManyToManyRelationProp;
|
|
128
|
+
type EntityProp = IntegerProp | BigIntegerProp | TextProp | StringProp | FloatProp | DoubleProp | DecimalProp | BooleanProp | DateProp | DateTimeProp | TimeProp | TimestampProp | JsonProp | UuidProp | EnumProp | VirtualProp | RelationProp;
|
|
129
|
+
type EntityIndex = {
|
|
130
|
+
type: "index" | "unique";
|
|
131
|
+
columns: string[];
|
|
132
|
+
name?: string;
|
|
133
|
+
};
|
|
134
|
+
type EntityJson = {
|
|
135
|
+
id: string;
|
|
136
|
+
parentId?: string;
|
|
137
|
+
table: string;
|
|
138
|
+
title?: string;
|
|
139
|
+
props: EntityProp[];
|
|
140
|
+
indexes: EntityIndex[];
|
|
141
|
+
subsets: {
|
|
142
|
+
[subset: string]: string[];
|
|
143
|
+
};
|
|
144
|
+
enums: {
|
|
145
|
+
[enumId: string]: {
|
|
146
|
+
[key: string]: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
type EntitySubsetRow = {
|
|
151
|
+
field: string;
|
|
152
|
+
has: {
|
|
153
|
+
[key: string]: boolean;
|
|
154
|
+
};
|
|
155
|
+
children: EntitySubsetRow[];
|
|
156
|
+
prefixes: string[];
|
|
157
|
+
relationEntity?: string;
|
|
158
|
+
isOpen?: boolean;
|
|
159
|
+
};
|
|
160
|
+
type FlattenSubsetRow = Omit<EntitySubsetRow, "children">;
|
|
161
|
+
type SMDInput<T extends string> = {
|
|
162
|
+
id: string;
|
|
163
|
+
parentId?: string;
|
|
164
|
+
table?: string;
|
|
165
|
+
title?: string;
|
|
166
|
+
props?: EntityProp[];
|
|
167
|
+
indexes?: EntityIndex[];
|
|
168
|
+
subsets?: {
|
|
169
|
+
[subset: string]: T[];
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
type EntityPropNode = {
|
|
173
|
+
nodeType: "plain";
|
|
174
|
+
prop: EntityProp;
|
|
175
|
+
} | {
|
|
176
|
+
nodeType: "object" | "array";
|
|
177
|
+
prop?: EntityProp;
|
|
178
|
+
children: EntityPropNode[];
|
|
179
|
+
};
|
|
180
|
+
declare function isIntegerProp(p: any): p is IntegerProp;
|
|
181
|
+
declare function isBigIntegerProp(p: any): p is BigIntegerProp;
|
|
182
|
+
declare function isTextProp(p: any): p is TextProp;
|
|
183
|
+
declare function isStringProp(p: any): p is StringProp;
|
|
184
|
+
declare function isEnumProp(p: any): p is EnumProp;
|
|
185
|
+
declare function isFloatProp(p: any): p is FloatProp;
|
|
186
|
+
declare function isDoubleProp(p: any): p is DoubleProp;
|
|
187
|
+
declare function isDecimalProp(p: any): p is DecimalProp;
|
|
188
|
+
declare function isBooleanProp(p: any): p is BooleanProp;
|
|
189
|
+
declare function isDateProp(p: any): p is DateProp;
|
|
190
|
+
declare function isDateTimeProp(p: any): p is DateTimeProp;
|
|
191
|
+
declare function isTimeProp(p: any): p is TimeProp;
|
|
192
|
+
declare function isTimestampProp(p: any): p is TimestampProp;
|
|
193
|
+
declare function isJsonProp(p: any): p is JsonProp;
|
|
194
|
+
declare function isUuidProp(p: any): p is UuidProp;
|
|
195
|
+
declare function isVirtualProp(p: any): p is VirtualProp;
|
|
196
|
+
declare function isRelationProp(p: any): p is RelationProp;
|
|
197
|
+
declare function isOneToOneRelationProp(p: any): p is OneToOneRelationProp;
|
|
198
|
+
declare function isBelongsToOneRelationProp(p: any): p is BelongsToOneRelationProp;
|
|
199
|
+
declare function isHasManyRelationProp(p: any): p is HasManyRelationProp;
|
|
200
|
+
declare function isManyToManyRelationProp(p: any): p is ManyToManyRelationProp;
|
|
201
|
+
type JoinClause = {
|
|
202
|
+
from: string;
|
|
203
|
+
to: string;
|
|
204
|
+
} | {
|
|
205
|
+
custom: string;
|
|
206
|
+
};
|
|
207
|
+
declare function isCustomJoinClause(p: any): p is {
|
|
208
|
+
custom: string;
|
|
209
|
+
};
|
|
210
|
+
type SubsetLoader = {
|
|
211
|
+
as: string;
|
|
212
|
+
table: string;
|
|
213
|
+
manyJoin: {
|
|
214
|
+
fromTable: string;
|
|
215
|
+
fromCol: string;
|
|
216
|
+
idField: string;
|
|
217
|
+
toTable: string;
|
|
218
|
+
toCol: string;
|
|
219
|
+
through?: {
|
|
220
|
+
table: string;
|
|
221
|
+
fromCol: string;
|
|
222
|
+
toCol: string;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
oneJoins: ({
|
|
226
|
+
as: string;
|
|
227
|
+
join: "inner" | "outer";
|
|
228
|
+
table: string;
|
|
229
|
+
} & JoinClause)[];
|
|
230
|
+
select: (string | Knex.Raw)[];
|
|
231
|
+
loaders?: SubsetLoader[];
|
|
232
|
+
};
|
|
233
|
+
type SubsetQuery = {
|
|
234
|
+
select: (string | Knex.Raw)[];
|
|
235
|
+
virtual: string[];
|
|
236
|
+
joins: ({
|
|
237
|
+
as: string;
|
|
238
|
+
join: "inner" | "outer";
|
|
239
|
+
table: string;
|
|
240
|
+
} & JoinClause)[];
|
|
241
|
+
loaders: SubsetLoader[];
|
|
242
|
+
};
|
|
243
|
+
declare const SonamuQueryMode: z.ZodEnum<["both", "list", "count"]>;
|
|
244
|
+
type SonamuQueryMode = z.infer<typeof SonamuQueryMode>;
|
|
245
|
+
type KnexError = {
|
|
246
|
+
code: string;
|
|
247
|
+
errno: number;
|
|
248
|
+
sql: string;
|
|
249
|
+
sqlMessage: string;
|
|
250
|
+
sqlState: string;
|
|
251
|
+
};
|
|
252
|
+
declare function isKnexError(e: any): e is KnexError;
|
|
253
|
+
type KnexColumnType = "string" | "text" | "smalltext" | "mediumtext" | "longtext" | "integer" | "bigInteger" | "decimal" | "timestamp" | "boolean" | "foreign" | "uuid" | "json" | "float" | "date" | "time" | "dateTime";
|
|
254
|
+
type MigrationColumn = {
|
|
255
|
+
name: string;
|
|
256
|
+
type: KnexColumnType;
|
|
257
|
+
nullable: boolean;
|
|
258
|
+
unsigned?: boolean;
|
|
259
|
+
length?: number;
|
|
260
|
+
defaultTo?: string;
|
|
261
|
+
precision?: number;
|
|
262
|
+
scale?: number;
|
|
263
|
+
};
|
|
264
|
+
type MigrationIndex = {
|
|
265
|
+
columns: string[];
|
|
266
|
+
type: "unique" | "index";
|
|
267
|
+
};
|
|
268
|
+
type MigrationForeign = {
|
|
269
|
+
columns: string[];
|
|
270
|
+
to: string;
|
|
271
|
+
onUpdate: RelationOn;
|
|
272
|
+
onDelete: RelationOn;
|
|
273
|
+
};
|
|
274
|
+
type MigrationJoinTable = {
|
|
275
|
+
table: string;
|
|
276
|
+
indexes: MigrationIndex[];
|
|
277
|
+
columns: MigrationColumn[];
|
|
278
|
+
foreigns: MigrationForeign[];
|
|
279
|
+
};
|
|
280
|
+
type MigrationSet = {
|
|
281
|
+
table: string;
|
|
282
|
+
columns: MigrationColumn[];
|
|
283
|
+
indexes: MigrationIndex[];
|
|
284
|
+
foreigns: MigrationForeign[];
|
|
285
|
+
};
|
|
286
|
+
type MigrationSetAndJoinTable = MigrationSet & {
|
|
287
|
+
joinTables: MigrationJoinTable[];
|
|
288
|
+
};
|
|
289
|
+
type GenMigrationCode = {
|
|
290
|
+
title: string;
|
|
291
|
+
table: string;
|
|
292
|
+
type: "normal" | "foreign";
|
|
293
|
+
formatted: string | null;
|
|
294
|
+
};
|
|
295
|
+
type ApiParam = {
|
|
296
|
+
name: string;
|
|
297
|
+
type: ApiParamType;
|
|
298
|
+
optional: boolean;
|
|
299
|
+
defaultDef?: string;
|
|
300
|
+
};
|
|
301
|
+
declare namespace ApiParamType {
|
|
302
|
+
type Object = {
|
|
303
|
+
t: "object";
|
|
304
|
+
props: ApiParam[];
|
|
305
|
+
};
|
|
306
|
+
type Union = {
|
|
307
|
+
t: "union";
|
|
308
|
+
types: ApiParamType[];
|
|
309
|
+
};
|
|
310
|
+
type Intersection = {
|
|
311
|
+
t: "intersection";
|
|
312
|
+
types: ApiParamType[];
|
|
313
|
+
};
|
|
314
|
+
type StringLiteral = {
|
|
315
|
+
t: "string-literal";
|
|
316
|
+
value: string;
|
|
317
|
+
};
|
|
318
|
+
type NumericLiteral = {
|
|
319
|
+
t: "numeric-literal";
|
|
320
|
+
value: number;
|
|
321
|
+
};
|
|
322
|
+
type Array = {
|
|
323
|
+
t: "array";
|
|
324
|
+
elementsType: ApiParamType;
|
|
325
|
+
};
|
|
326
|
+
type Ref = {
|
|
327
|
+
t: "ref";
|
|
328
|
+
id: string;
|
|
329
|
+
args?: ApiParamType[];
|
|
330
|
+
};
|
|
331
|
+
type IndexedAccess = {
|
|
332
|
+
t: "indexed-access";
|
|
333
|
+
object: ApiParamType;
|
|
334
|
+
index: ApiParamType;
|
|
335
|
+
};
|
|
336
|
+
type TupleType = {
|
|
337
|
+
t: "tuple-type";
|
|
338
|
+
elements: ApiParamType[];
|
|
339
|
+
};
|
|
340
|
+
type Pick = Ref & {
|
|
341
|
+
t: "ref";
|
|
342
|
+
id: "Pick";
|
|
343
|
+
};
|
|
344
|
+
type Omit = Ref & {
|
|
345
|
+
t: "ref";
|
|
346
|
+
id: "Omit";
|
|
347
|
+
};
|
|
348
|
+
type Partial = Ref & {
|
|
349
|
+
t: "ref";
|
|
350
|
+
id: "Partial";
|
|
351
|
+
};
|
|
352
|
+
type Promise = Ref & {
|
|
353
|
+
t: "ref";
|
|
354
|
+
id: "Promise";
|
|
355
|
+
};
|
|
356
|
+
type Context = Ref & {
|
|
357
|
+
t: "ref";
|
|
358
|
+
id: "Context";
|
|
359
|
+
};
|
|
360
|
+
type TypeParam = {
|
|
361
|
+
t: "type-param";
|
|
362
|
+
id: string;
|
|
363
|
+
constraint?: ApiParamType;
|
|
364
|
+
};
|
|
365
|
+
function isObject(v: any): v is ApiParamType.Object;
|
|
366
|
+
function isUnion(v: any): v is ApiParamType.Union;
|
|
367
|
+
function isIntersection(v: any): v is ApiParamType.Intersection;
|
|
368
|
+
function isStringLiteral(v: any): v is ApiParamType.StringLiteral;
|
|
369
|
+
function isNumericLiteral(v: any): v is ApiParamType.NumericLiteral;
|
|
370
|
+
function isArray(v: any): v is ApiParamType.Array;
|
|
371
|
+
function isRef(v: any): v is ApiParamType.Ref;
|
|
372
|
+
function isIndexedAccess(v: any): v is ApiParamType.IndexedAccess;
|
|
373
|
+
function isTupleType(v: any): v is ApiParamType.TupleType;
|
|
374
|
+
function isPick(v: any): v is ApiParamType.Pick;
|
|
375
|
+
function isOmit(v: any): v is ApiParamType.Omit;
|
|
376
|
+
function isPartial(v: any): v is ApiParamType.Partial;
|
|
377
|
+
function isPromise(v: any): v is ApiParamType.Promise;
|
|
378
|
+
function isContext(v: any): v is ApiParamType.Context;
|
|
379
|
+
function isRefKnex(v: any): v is ApiParamType.Ref;
|
|
380
|
+
function isTypeParam(v: any): v is ApiParamType.TypeParam;
|
|
381
|
+
}
|
|
382
|
+
type ApiParamType = "string" | "number" | "boolean" | "null" | "undefined" | "void" | "any" | "unknown" | "true" | "false" | ApiParamType.StringLiteral | ApiParamType.NumericLiteral | ApiParamType.Object | ApiParamType.Union | ApiParamType.Intersection | ApiParamType.Array | ApiParamType.Ref | ApiParamType.IndexedAccess | ApiParamType.TypeParam | ApiParamType.TupleType;
|
|
383
|
+
declare const RenderingNode: z.ZodAny;
|
|
384
|
+
type RenderingNode = {
|
|
385
|
+
name: string;
|
|
386
|
+
label: string;
|
|
387
|
+
renderType: "string-plain" | "string-image" | "string-datetime" | "string-date" | "number-plain" | "number-id" | "number-fk_id" | "boolean" | "enums" | "array" | "array-images" | "object" | "object-pick" | "record";
|
|
388
|
+
zodType: z.ZodTypeAny;
|
|
389
|
+
element?: RenderingNode;
|
|
390
|
+
children?: RenderingNode[];
|
|
391
|
+
config?: {
|
|
392
|
+
picked: string;
|
|
393
|
+
};
|
|
394
|
+
optional?: boolean;
|
|
395
|
+
nullable?: boolean;
|
|
396
|
+
};
|
|
397
|
+
declare const TemplateOptions: z.ZodObject<{
|
|
398
|
+
entity: z.ZodObject<{
|
|
399
|
+
entityId: z.ZodString;
|
|
400
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
401
|
+
title: z.ZodString;
|
|
402
|
+
table: z.ZodOptional<z.ZodString>;
|
|
403
|
+
props: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, "many">>;
|
|
404
|
+
indexes: z.ZodOptional<z.ZodArray<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, "many">>;
|
|
405
|
+
subsets: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
406
|
+
enums: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
|
|
407
|
+
}, "strip", z.ZodTypeAny, {
|
|
408
|
+
entityId: string;
|
|
409
|
+
title: string;
|
|
410
|
+
parentId?: string | undefined;
|
|
411
|
+
table?: string | undefined;
|
|
412
|
+
props?: {}[] | undefined;
|
|
413
|
+
indexes?: {}[] | undefined;
|
|
414
|
+
subsets?: {} | undefined;
|
|
415
|
+
enums?: {} | undefined;
|
|
416
|
+
}, {
|
|
417
|
+
entityId: string;
|
|
418
|
+
title: string;
|
|
419
|
+
parentId?: string | undefined;
|
|
420
|
+
table?: string | undefined;
|
|
421
|
+
props?: {}[] | undefined;
|
|
422
|
+
indexes?: {}[] | undefined;
|
|
423
|
+
subsets?: {} | undefined;
|
|
424
|
+
enums?: {} | undefined;
|
|
425
|
+
}>;
|
|
426
|
+
init_types: z.ZodObject<{
|
|
427
|
+
entityId: z.ZodString;
|
|
428
|
+
}, "strip", z.ZodTypeAny, {
|
|
429
|
+
entityId: string;
|
|
430
|
+
}, {
|
|
431
|
+
entityId: string;
|
|
432
|
+
}>;
|
|
433
|
+
generated: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
434
|
+
generated_sso: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
435
|
+
generated_http: z.ZodObject<{
|
|
436
|
+
entityId: z.ZodString;
|
|
437
|
+
}, "strip", z.ZodTypeAny, {
|
|
438
|
+
entityId: string;
|
|
439
|
+
}, {
|
|
440
|
+
entityId: string;
|
|
441
|
+
}>;
|
|
442
|
+
model: z.ZodObject<{
|
|
443
|
+
entityId: z.ZodString;
|
|
444
|
+
defaultSearchField: z.ZodString;
|
|
445
|
+
defaultOrderBy: z.ZodString;
|
|
446
|
+
}, "strip", z.ZodTypeAny, {
|
|
447
|
+
entityId: string;
|
|
448
|
+
defaultSearchField: string;
|
|
449
|
+
defaultOrderBy: string;
|
|
450
|
+
}, {
|
|
451
|
+
entityId: string;
|
|
452
|
+
defaultSearchField: string;
|
|
453
|
+
defaultOrderBy: string;
|
|
454
|
+
}>;
|
|
455
|
+
model_test: z.ZodObject<{
|
|
456
|
+
entityId: z.ZodString;
|
|
457
|
+
}, "strip", z.ZodTypeAny, {
|
|
458
|
+
entityId: string;
|
|
459
|
+
}, {
|
|
460
|
+
entityId: string;
|
|
461
|
+
}>;
|
|
462
|
+
bridge: z.ZodObject<{
|
|
463
|
+
entityId: z.ZodString;
|
|
464
|
+
}, "strip", z.ZodTypeAny, {
|
|
465
|
+
entityId: string;
|
|
466
|
+
}, {
|
|
467
|
+
entityId: string;
|
|
468
|
+
}>;
|
|
469
|
+
service: z.ZodObject<{
|
|
470
|
+
entityId: z.ZodString;
|
|
471
|
+
}, "strip", z.ZodTypeAny, {
|
|
472
|
+
entityId: string;
|
|
473
|
+
}, {
|
|
474
|
+
entityId: string;
|
|
475
|
+
}>;
|
|
476
|
+
view_list: z.ZodObject<{
|
|
477
|
+
entityId: z.ZodString;
|
|
478
|
+
extra: z.ZodUnknown;
|
|
479
|
+
}, "strip", z.ZodTypeAny, {
|
|
480
|
+
entityId: string;
|
|
481
|
+
extra?: unknown;
|
|
482
|
+
}, {
|
|
483
|
+
entityId: string;
|
|
484
|
+
extra?: unknown;
|
|
485
|
+
}>;
|
|
486
|
+
view_list_columns: z.ZodObject<{
|
|
487
|
+
entityId: z.ZodString;
|
|
488
|
+
columns: z.ZodArray<z.ZodObject<{
|
|
489
|
+
name: z.ZodString;
|
|
490
|
+
label: z.ZodString;
|
|
491
|
+
tc: z.ZodString;
|
|
492
|
+
}, "strip", z.ZodTypeAny, {
|
|
493
|
+
name: string;
|
|
494
|
+
label: string;
|
|
495
|
+
tc: string;
|
|
496
|
+
}, {
|
|
497
|
+
name: string;
|
|
498
|
+
label: string;
|
|
499
|
+
tc: string;
|
|
500
|
+
}>, "many">;
|
|
501
|
+
columnImports: z.ZodString;
|
|
502
|
+
}, "strip", z.ZodTypeAny, {
|
|
503
|
+
entityId: string;
|
|
504
|
+
columns: {
|
|
505
|
+
name: string;
|
|
506
|
+
label: string;
|
|
507
|
+
tc: string;
|
|
508
|
+
}[];
|
|
509
|
+
columnImports: string;
|
|
510
|
+
}, {
|
|
511
|
+
entityId: string;
|
|
512
|
+
columns: {
|
|
513
|
+
name: string;
|
|
514
|
+
label: string;
|
|
515
|
+
tc: string;
|
|
516
|
+
}[];
|
|
517
|
+
columnImports: string;
|
|
518
|
+
}>;
|
|
519
|
+
view_search_input: z.ZodObject<{
|
|
520
|
+
entityId: z.ZodString;
|
|
521
|
+
}, "strip", z.ZodTypeAny, {
|
|
522
|
+
entityId: string;
|
|
523
|
+
}, {
|
|
524
|
+
entityId: string;
|
|
525
|
+
}>;
|
|
526
|
+
view_form: z.ZodObject<{
|
|
527
|
+
entityId: z.ZodString;
|
|
528
|
+
}, "strip", z.ZodTypeAny, {
|
|
529
|
+
entityId: string;
|
|
530
|
+
}, {
|
|
531
|
+
entityId: string;
|
|
532
|
+
}>;
|
|
533
|
+
view_id_all_select: z.ZodObject<{
|
|
534
|
+
entityId: z.ZodString;
|
|
535
|
+
}, "strip", z.ZodTypeAny, {
|
|
536
|
+
entityId: string;
|
|
537
|
+
}, {
|
|
538
|
+
entityId: string;
|
|
539
|
+
}>;
|
|
540
|
+
view_id_async_select: z.ZodObject<{
|
|
541
|
+
entityId: z.ZodString;
|
|
542
|
+
textField: z.ZodString;
|
|
543
|
+
}, "strip", z.ZodTypeAny, {
|
|
544
|
+
entityId: string;
|
|
545
|
+
textField: string;
|
|
546
|
+
}, {
|
|
547
|
+
entityId: string;
|
|
548
|
+
textField: string;
|
|
549
|
+
}>;
|
|
550
|
+
view_enums_select: z.ZodObject<{
|
|
551
|
+
entityId: z.ZodString;
|
|
552
|
+
enumId: z.ZodString;
|
|
553
|
+
}, "strip", z.ZodTypeAny, {
|
|
554
|
+
entityId: string;
|
|
555
|
+
enumId: string;
|
|
556
|
+
}, {
|
|
557
|
+
entityId: string;
|
|
558
|
+
enumId: string;
|
|
559
|
+
}>;
|
|
560
|
+
view_enums_dropdown: z.ZodObject<{
|
|
561
|
+
entityId: z.ZodString;
|
|
562
|
+
enumId: z.ZodString;
|
|
563
|
+
}, "strip", z.ZodTypeAny, {
|
|
564
|
+
entityId: string;
|
|
565
|
+
enumId: string;
|
|
566
|
+
}, {
|
|
567
|
+
entityId: string;
|
|
568
|
+
enumId: string;
|
|
569
|
+
}>;
|
|
570
|
+
view_enums_buttonset: z.ZodObject<{
|
|
571
|
+
entityId: z.ZodString;
|
|
572
|
+
enumId: z.ZodString;
|
|
573
|
+
}, "strip", z.ZodTypeAny, {
|
|
574
|
+
entityId: string;
|
|
575
|
+
enumId: string;
|
|
576
|
+
}, {
|
|
577
|
+
entityId: string;
|
|
578
|
+
enumId: string;
|
|
579
|
+
}>;
|
|
580
|
+
}, "strip", z.ZodTypeAny, {
|
|
581
|
+
entity: {
|
|
582
|
+
entityId: string;
|
|
583
|
+
title: string;
|
|
584
|
+
parentId?: string | undefined;
|
|
585
|
+
table?: string | undefined;
|
|
586
|
+
props?: {}[] | undefined;
|
|
587
|
+
indexes?: {}[] | undefined;
|
|
588
|
+
subsets?: {} | undefined;
|
|
589
|
+
enums?: {} | undefined;
|
|
590
|
+
};
|
|
591
|
+
init_types: {
|
|
592
|
+
entityId: string;
|
|
593
|
+
};
|
|
594
|
+
generated: {};
|
|
595
|
+
generated_sso: {};
|
|
596
|
+
generated_http: {
|
|
597
|
+
entityId: string;
|
|
598
|
+
};
|
|
599
|
+
model: {
|
|
600
|
+
entityId: string;
|
|
601
|
+
defaultSearchField: string;
|
|
602
|
+
defaultOrderBy: string;
|
|
603
|
+
};
|
|
604
|
+
model_test: {
|
|
605
|
+
entityId: string;
|
|
606
|
+
};
|
|
607
|
+
bridge: {
|
|
608
|
+
entityId: string;
|
|
609
|
+
};
|
|
610
|
+
service: {
|
|
611
|
+
entityId: string;
|
|
612
|
+
};
|
|
613
|
+
view_list: {
|
|
614
|
+
entityId: string;
|
|
615
|
+
extra?: unknown;
|
|
616
|
+
};
|
|
617
|
+
view_list_columns: {
|
|
618
|
+
entityId: string;
|
|
619
|
+
columns: {
|
|
620
|
+
name: string;
|
|
621
|
+
label: string;
|
|
622
|
+
tc: string;
|
|
623
|
+
}[];
|
|
624
|
+
columnImports: string;
|
|
625
|
+
};
|
|
626
|
+
view_search_input: {
|
|
627
|
+
entityId: string;
|
|
628
|
+
};
|
|
629
|
+
view_form: {
|
|
630
|
+
entityId: string;
|
|
631
|
+
};
|
|
632
|
+
view_id_all_select: {
|
|
633
|
+
entityId: string;
|
|
634
|
+
};
|
|
635
|
+
view_id_async_select: {
|
|
636
|
+
entityId: string;
|
|
637
|
+
textField: string;
|
|
638
|
+
};
|
|
639
|
+
view_enums_select: {
|
|
640
|
+
entityId: string;
|
|
641
|
+
enumId: string;
|
|
642
|
+
};
|
|
643
|
+
view_enums_dropdown: {
|
|
644
|
+
entityId: string;
|
|
645
|
+
enumId: string;
|
|
646
|
+
};
|
|
647
|
+
view_enums_buttonset: {
|
|
648
|
+
entityId: string;
|
|
649
|
+
enumId: string;
|
|
650
|
+
};
|
|
651
|
+
}, {
|
|
652
|
+
entity: {
|
|
653
|
+
entityId: string;
|
|
654
|
+
title: string;
|
|
655
|
+
parentId?: string | undefined;
|
|
656
|
+
table?: string | undefined;
|
|
657
|
+
props?: {}[] | undefined;
|
|
658
|
+
indexes?: {}[] | undefined;
|
|
659
|
+
subsets?: {} | undefined;
|
|
660
|
+
enums?: {} | undefined;
|
|
661
|
+
};
|
|
662
|
+
init_types: {
|
|
663
|
+
entityId: string;
|
|
664
|
+
};
|
|
665
|
+
generated: {};
|
|
666
|
+
generated_sso: {};
|
|
667
|
+
generated_http: {
|
|
668
|
+
entityId: string;
|
|
669
|
+
};
|
|
670
|
+
model: {
|
|
671
|
+
entityId: string;
|
|
672
|
+
defaultSearchField: string;
|
|
673
|
+
defaultOrderBy: string;
|
|
674
|
+
};
|
|
675
|
+
model_test: {
|
|
676
|
+
entityId: string;
|
|
677
|
+
};
|
|
678
|
+
bridge: {
|
|
679
|
+
entityId: string;
|
|
680
|
+
};
|
|
681
|
+
service: {
|
|
682
|
+
entityId: string;
|
|
683
|
+
};
|
|
684
|
+
view_list: {
|
|
685
|
+
entityId: string;
|
|
686
|
+
extra?: unknown;
|
|
687
|
+
};
|
|
688
|
+
view_list_columns: {
|
|
689
|
+
entityId: string;
|
|
690
|
+
columns: {
|
|
691
|
+
name: string;
|
|
692
|
+
label: string;
|
|
693
|
+
tc: string;
|
|
694
|
+
}[];
|
|
695
|
+
columnImports: string;
|
|
696
|
+
};
|
|
697
|
+
view_search_input: {
|
|
698
|
+
entityId: string;
|
|
699
|
+
};
|
|
700
|
+
view_form: {
|
|
701
|
+
entityId: string;
|
|
702
|
+
};
|
|
703
|
+
view_id_all_select: {
|
|
704
|
+
entityId: string;
|
|
705
|
+
};
|
|
706
|
+
view_id_async_select: {
|
|
707
|
+
entityId: string;
|
|
708
|
+
textField: string;
|
|
709
|
+
};
|
|
710
|
+
view_enums_select: {
|
|
711
|
+
entityId: string;
|
|
712
|
+
enumId: string;
|
|
713
|
+
};
|
|
714
|
+
view_enums_dropdown: {
|
|
715
|
+
entityId: string;
|
|
716
|
+
enumId: string;
|
|
717
|
+
};
|
|
718
|
+
view_enums_buttonset: {
|
|
719
|
+
entityId: string;
|
|
720
|
+
enumId: string;
|
|
721
|
+
};
|
|
722
|
+
}>;
|
|
723
|
+
type TemplateOptions = z.infer<typeof TemplateOptions>;
|
|
724
|
+
declare const TemplateKey: z.ZodEnum<["entity", "init_types", "generated", "generated_sso", "generated_http", "model", "model_test", "bridge", "service", "view_list", "view_list_columns", "view_search_input", "view_form", "view_id_all_select", "view_id_async_select", "view_enums_select", "view_enums_dropdown", "view_enums_buttonset"]>;
|
|
725
|
+
type TemplateKey = z.infer<typeof TemplateKey>;
|
|
726
|
+
declare const GenerateOptions: z.ZodObject<{
|
|
727
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
728
|
+
}, "strip", z.ZodTypeAny, {
|
|
729
|
+
overwrite?: boolean | undefined;
|
|
730
|
+
}, {
|
|
731
|
+
overwrite?: boolean | undefined;
|
|
732
|
+
}>;
|
|
733
|
+
type GenerateOptions = z.infer<typeof GenerateOptions>;
|
|
734
|
+
declare const PathAndCode: z.ZodObject<{
|
|
735
|
+
path: z.ZodString;
|
|
736
|
+
code: z.ZodString;
|
|
737
|
+
}, "strip", z.ZodTypeAny, {
|
|
738
|
+
path: string;
|
|
739
|
+
code: string;
|
|
740
|
+
}, {
|
|
741
|
+
path: string;
|
|
742
|
+
code: string;
|
|
743
|
+
}>;
|
|
744
|
+
type PathAndCode = z.infer<typeof PathAndCode>;
|
|
745
|
+
type FixtureSearchOptions = {
|
|
746
|
+
entityId: string;
|
|
747
|
+
field: string;
|
|
748
|
+
value: string;
|
|
749
|
+
searchType: "equals" | "like";
|
|
750
|
+
};
|
|
751
|
+
type FixtureRecord = {
|
|
752
|
+
fixtureId: string;
|
|
753
|
+
entityId: string;
|
|
754
|
+
id: number;
|
|
755
|
+
columns: {
|
|
756
|
+
[key: string]: {
|
|
757
|
+
prop: EntityProp;
|
|
758
|
+
value: any;
|
|
759
|
+
};
|
|
760
|
+
};
|
|
761
|
+
fetchedRecords: string[];
|
|
762
|
+
belongsRecords: string[];
|
|
763
|
+
target?: FixtureRecord;
|
|
764
|
+
unique?: FixtureRecord;
|
|
765
|
+
override?: boolean;
|
|
766
|
+
};
|
|
767
|
+
type FixtureImportResult = {
|
|
768
|
+
entityId: string;
|
|
769
|
+
data: {
|
|
770
|
+
[key: string]: any;
|
|
771
|
+
};
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
type ServiceClient = "axios" | "axios-multipart" | "swr" | "socketio" | "window-fetch";
|
|
775
|
+
type ApiDecoratorOptions = {
|
|
776
|
+
httpMethod?: HTTPMethods;
|
|
777
|
+
contentType?: "text/plain" | "text/html" | "text/xml" | "application/json" | "application/octet-stream";
|
|
778
|
+
clients?: ServiceClient[];
|
|
779
|
+
path?: string;
|
|
780
|
+
resourceName?: string;
|
|
781
|
+
guards?: string[];
|
|
782
|
+
description?: string;
|
|
783
|
+
};
|
|
784
|
+
declare const registeredApis: {
|
|
785
|
+
modelName: string;
|
|
786
|
+
methodName: string;
|
|
787
|
+
path: string;
|
|
788
|
+
options: ApiDecoratorOptions;
|
|
789
|
+
}[];
|
|
790
|
+
type ExtendedApi = {
|
|
791
|
+
modelName: string;
|
|
792
|
+
methodName: string;
|
|
793
|
+
path: string;
|
|
794
|
+
options: ApiDecoratorOptions;
|
|
795
|
+
typeParameters: ApiParamType.TypeParam[];
|
|
796
|
+
parameters: ApiParam[];
|
|
797
|
+
returnType: ApiParamType;
|
|
798
|
+
};
|
|
799
|
+
declare function api(options?: ApiDecoratorOptions): (target: Object, propertyKey: string) => void;
|
|
800
|
+
|
|
801
|
+
declare function getZodObjectFromApi(api: ExtendedApi, references?: {
|
|
802
|
+
[id: string]: z.ZodObject<any>;
|
|
803
|
+
}): z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
804
|
+
declare function getZodObjectFromApiParams(apiParams: ApiParam[], references?: {
|
|
805
|
+
[id: string]: z.ZodObject<any>;
|
|
806
|
+
}): z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
807
|
+
declare function getZodTypeFromApiParamType(paramType: ApiParamType, references: {
|
|
808
|
+
[id: string]: z.ZodObject<any>;
|
|
809
|
+
}): z.ZodType<unknown>;
|
|
810
|
+
declare function propNodeToZodTypeDef(propNode: EntityPropNode, injectImportKeys: string[]): string;
|
|
811
|
+
declare function getTextTypeLength(textType: TextProp["textType"]): number;
|
|
812
|
+
declare function propToZodTypeDef(prop: EntityProp, injectImportKeys: string[]): string;
|
|
813
|
+
declare function zodTypeToZodCode(zt: z.ZodFirstPartySchemaTypes | z.ZodObject<any>): string;
|
|
814
|
+
declare function apiParamToTsCode(params: ApiParam[], injectImportKeys: string[]): string;
|
|
815
|
+
declare function apiParamTypeToTsType(paramType: ApiParamType, injectImportKeys: string[]): string;
|
|
816
|
+
declare function unwrapPromiseOnce(paramType: ApiParamType): ApiParamType;
|
|
817
|
+
declare function serializeZodType(zt: z.ZodTypeAny): any;
|
|
818
|
+
declare function zodTypeToTsTypeDef(zt: z.ZodFirstPartySchemaTypes | z.ZodObject<any>): string;
|
|
819
|
+
|
|
820
|
+
interface ContextExtend {
|
|
821
|
+
}
|
|
822
|
+
type Context = {
|
|
823
|
+
reply: FastifyReply<Server, IncomingMessage, ServerResponse, RouteGenericInterface, unknown>;
|
|
824
|
+
headers: IncomingHttpHeaders;
|
|
825
|
+
} & ContextExtend;
|
|
826
|
+
|
|
827
|
+
declare class Entity {
|
|
828
|
+
id: string;
|
|
829
|
+
parentId?: string;
|
|
830
|
+
table: string;
|
|
831
|
+
title: string;
|
|
832
|
+
names: {
|
|
833
|
+
parentFs: string;
|
|
834
|
+
fs: string;
|
|
835
|
+
module: string;
|
|
836
|
+
};
|
|
837
|
+
props: EntityProp[];
|
|
838
|
+
propsDict: {
|
|
839
|
+
[key: string]: EntityProp;
|
|
840
|
+
};
|
|
841
|
+
relations: {
|
|
842
|
+
[key: string]: RelationProp;
|
|
843
|
+
};
|
|
844
|
+
indexes: EntityIndex[];
|
|
845
|
+
subsets: {
|
|
846
|
+
[key: string]: string[];
|
|
847
|
+
};
|
|
848
|
+
types: {
|
|
849
|
+
[name: string]: z.ZodTypeAny;
|
|
850
|
+
};
|
|
851
|
+
enums: {
|
|
852
|
+
[enumId: string]: z.ZodEnum<any>;
|
|
853
|
+
};
|
|
854
|
+
enumLabels: {
|
|
855
|
+
[enumId: string]: {
|
|
856
|
+
[key: string]: string;
|
|
857
|
+
};
|
|
858
|
+
};
|
|
859
|
+
constructor({ id, parentId, table, title, props, indexes, subsets, enums, }: EntityJson);
|
|
860
|
+
getSubsetQuery(subsetKey: string): SubsetQuery;
|
|
861
|
+
resolveSubsetQuery(prefix: string, fields: string[], isAlreadyOuterJoined?: boolean): SubsetQuery;
|
|
862
|
+
fieldExprsToPropNodes(fieldExprs: string[], entity?: Entity): EntityPropNode[];
|
|
863
|
+
getFieldExprs(prefix?: string, maxDepth?: number, froms?: string[]): string[];
|
|
864
|
+
getTableColumns(): string[];
|
|
865
|
+
registerModulePaths(): void;
|
|
866
|
+
registerTableSpecs(): void;
|
|
867
|
+
toJson(): EntityJson;
|
|
868
|
+
save(): Promise<void>;
|
|
869
|
+
getSubsetRows(_subsets?: {
|
|
870
|
+
[key: string]: string[];
|
|
871
|
+
}, prefixes?: string[]): EntitySubsetRow[];
|
|
872
|
+
subsetRowsToSubsetFields(subsetRows: EntitySubsetRow[], subsetKey: string): string[];
|
|
873
|
+
createProp(prop: EntityProp, at?: number): Promise<void>;
|
|
874
|
+
analyzeSubsetField(subsetField: string): {
|
|
875
|
+
entityId: string;
|
|
876
|
+
propName: string;
|
|
877
|
+
}[];
|
|
878
|
+
modifyProp(newProp: EntityProp, at: number): Promise<void>;
|
|
879
|
+
delProp(at: number): Promise<void>;
|
|
880
|
+
getEntityIdFromSubsetField(subsetField: string): string;
|
|
881
|
+
moveProp(at: number, to: number): Promise<void>;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
type EntityNamesRecord = Record<"fs" | "fsPlural" | "camel" | "camelPlural" | "capital" | "capitalPlural" | "upper" | "constant", string>;
|
|
885
|
+
type TableSpec = {
|
|
886
|
+
name: string;
|
|
887
|
+
uniqueIndexes: {
|
|
888
|
+
name?: string;
|
|
889
|
+
columns: string[];
|
|
890
|
+
}[];
|
|
891
|
+
};
|
|
892
|
+
declare class EntityManagerClass {
|
|
893
|
+
private entities;
|
|
894
|
+
modulePaths: Map<string, string>;
|
|
895
|
+
private tableSpecs;
|
|
896
|
+
isAutoloaded: boolean;
|
|
897
|
+
autoload(doSilent?: boolean): Promise<unknown>;
|
|
898
|
+
reload(doSilent?: boolean): Promise<unknown>;
|
|
899
|
+
register(json: EntityJson): void;
|
|
900
|
+
get(entityId: string): Entity;
|
|
901
|
+
exists(entityId: string): boolean;
|
|
902
|
+
getAllIds(): string[];
|
|
903
|
+
getAllParentIds(): string[];
|
|
904
|
+
getChildrenIds(parentId: string): string[];
|
|
905
|
+
setModulePath(key: string, modulePath: string): void;
|
|
906
|
+
getModulePath(key: string): string;
|
|
907
|
+
setTableSpec(tableSpec: TableSpec): void;
|
|
908
|
+
getTableSpec(key: string): TableSpec;
|
|
909
|
+
getNamesFromId(entityId: string): EntityNamesRecord;
|
|
910
|
+
}
|
|
911
|
+
declare const EntityManager: EntityManagerClass;
|
|
912
|
+
|
|
913
|
+
declare abstract class Template {
|
|
914
|
+
key: TemplateKey;
|
|
915
|
+
constructor(key: TemplateKey);
|
|
916
|
+
abstract render(options: TemplateOptions[TemplateKey], ...extra: unknown[]): RenderedTemplate | Promise<RenderedTemplate>;
|
|
917
|
+
abstract getTargetAndPath(names?: EntityNamesRecord, ...extra: unknown[]): {
|
|
918
|
+
target: string;
|
|
919
|
+
path: string;
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
type PathAndChecksum = {
|
|
924
|
+
path: string;
|
|
925
|
+
checksum: string;
|
|
926
|
+
};
|
|
927
|
+
type RenderedTemplate = {
|
|
928
|
+
target: string;
|
|
929
|
+
path: string;
|
|
930
|
+
body: string;
|
|
931
|
+
importKeys: string[];
|
|
932
|
+
customHeaders?: string[];
|
|
933
|
+
preTemplates?: {
|
|
934
|
+
key: TemplateKey;
|
|
935
|
+
options: TemplateOptions[TemplateKey];
|
|
936
|
+
}[];
|
|
937
|
+
};
|
|
938
|
+
declare class Syncer {
|
|
939
|
+
apis: {
|
|
940
|
+
typeParameters: ApiParamType.TypeParam[];
|
|
941
|
+
parameters: ApiParam[];
|
|
942
|
+
returnType: ApiParamType;
|
|
943
|
+
modelName: string;
|
|
944
|
+
methodName: string;
|
|
945
|
+
path: string;
|
|
946
|
+
options: ApiDecoratorOptions;
|
|
947
|
+
}[];
|
|
948
|
+
types: {
|
|
949
|
+
[typeName: string]: z.ZodObject<any>;
|
|
950
|
+
};
|
|
951
|
+
models: {
|
|
952
|
+
[modelName: string]: unknown;
|
|
953
|
+
};
|
|
954
|
+
get checksumsPath(): string;
|
|
955
|
+
constructor();
|
|
956
|
+
sync(): Promise<void>;
|
|
957
|
+
getEntityIdFromPath(filePaths: string[]): string[];
|
|
958
|
+
actionGenerateSchemas(): Promise<string[]>;
|
|
959
|
+
actionGenerateServices(entityIds: string[]): Promise<string[]>;
|
|
960
|
+
actionGenerateHttps(entityIds: string[]): Promise<string[]>;
|
|
961
|
+
copyFileWithReplaceCoreToShared(fromPath: string, toPath: string): Promise<void>;
|
|
962
|
+
actionSyncFilesToTargets(tsPaths: string[]): Promise<string[]>;
|
|
963
|
+
getCurrentChecksums(): Promise<PathAndChecksum[]>;
|
|
964
|
+
getPreviousChecksums(): Promise<PathAndChecksum[]>;
|
|
965
|
+
saveChecksums(checksums: PathAndChecksum[]): Promise<void>;
|
|
966
|
+
getChecksumOfFile(filePath: string): Promise<string>;
|
|
967
|
+
readApisFromFile(filePath: string): Promise<{
|
|
968
|
+
typeParameters: ApiParamType.TypeParam[];
|
|
969
|
+
parameters: ApiParam[];
|
|
970
|
+
returnType: ApiParamType;
|
|
971
|
+
modelName: string;
|
|
972
|
+
methodName: string;
|
|
973
|
+
path: string;
|
|
974
|
+
options: ApiDecoratorOptions;
|
|
975
|
+
}[]>;
|
|
976
|
+
resolveTypeNode(typeNode: ts.TypeNode): ApiParamType;
|
|
977
|
+
resolveParamDec: (paramDec: {
|
|
978
|
+
name: ts.BindingName;
|
|
979
|
+
type: ts.TypeNode;
|
|
980
|
+
optional?: boolean;
|
|
981
|
+
defaultDef?: string;
|
|
982
|
+
}, index?: number) => ApiParam;
|
|
983
|
+
printNode(node: ts.Node | undefined, sourceFile: ts.SourceFile): string | undefined;
|
|
984
|
+
autoloadApis(): Promise<{
|
|
985
|
+
typeParameters: ApiParamType.TypeParam[];
|
|
986
|
+
parameters: ApiParam[];
|
|
987
|
+
returnType: ApiParamType;
|
|
988
|
+
modelName: string;
|
|
989
|
+
methodName: string;
|
|
990
|
+
path: string;
|
|
991
|
+
options: ApiDecoratorOptions;
|
|
992
|
+
}[]>;
|
|
993
|
+
autoloadModels(): Promise<{
|
|
994
|
+
[modelName: string]: unknown;
|
|
995
|
+
}>;
|
|
996
|
+
autoloadTypes(doRefresh?: boolean): Promise<{
|
|
997
|
+
[typeName: string]: z.ZodObject<any>;
|
|
998
|
+
}>;
|
|
999
|
+
getTemplate(key: TemplateKey): Template;
|
|
1000
|
+
renderTemplate<T extends keyof TemplateOptions>(key: T, options: TemplateOptions[T]): Promise<PathAndCode[]>;
|
|
1001
|
+
resolveRenderedTemplate(key: TemplateKey, result: RenderedTemplate): Promise<PathAndCode>;
|
|
1002
|
+
writeCodeToPath(pathAndCode: PathAndCode): Promise<string[]>;
|
|
1003
|
+
generateTemplate(key: TemplateKey, templateOptions: any, _generateOptions?: GenerateOptions): Promise<string[][]>;
|
|
1004
|
+
checkExistsGenCode(entityId: string, templateKey: TemplateKey, enumId?: string): {
|
|
1005
|
+
subPath: string;
|
|
1006
|
+
fullPath: string;
|
|
1007
|
+
isExists: boolean;
|
|
1008
|
+
};
|
|
1009
|
+
checkExists(entityId: string, enums: {
|
|
1010
|
+
[name: string]: z.ZodEnum<any>;
|
|
1011
|
+
}): Record<`${TemplateKey}${string}`, boolean>;
|
|
1012
|
+
getZodTypeById(zodTypeId: string): Promise<z.ZodTypeAny>;
|
|
1013
|
+
propNodeToZodType(propNode: EntityPropNode): Promise<z.ZodTypeAny>;
|
|
1014
|
+
propToZodType(prop: EntityProp): Promise<z.ZodTypeAny>;
|
|
1015
|
+
resolveRenderType(key: string, zodType: z.ZodTypeAny): RenderingNode["renderType"];
|
|
1016
|
+
zodTypeToRenderingNode(zodType: z.ZodTypeAny, baseKey?: string): RenderingNode;
|
|
1017
|
+
getColumnsNode(entityId: string, subsetKey: string): Promise<RenderingNode>;
|
|
1018
|
+
createEntity(form: Omit<TemplateOptions["entity"], "title"> & {
|
|
1019
|
+
title?: string;
|
|
1020
|
+
}): Promise<void>;
|
|
1021
|
+
delEntity(entityId: string): Promise<{
|
|
1022
|
+
delPaths: string[];
|
|
1023
|
+
}>;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
type DBPreset = "w" | "r";
|
|
1027
|
+
|
|
1028
|
+
type SonamuDBConfig = {
|
|
1029
|
+
development_master: Knex.Config;
|
|
1030
|
+
development_slave: Knex.Config;
|
|
1031
|
+
test: Knex.Config;
|
|
1032
|
+
fixture_local: Knex.Config;
|
|
1033
|
+
fixture_remote: Knex.Config;
|
|
1034
|
+
production_master: Knex.Config;
|
|
1035
|
+
production_slave: Knex.Config;
|
|
1036
|
+
};
|
|
1037
|
+
declare class DBClass {
|
|
1038
|
+
private wdb?;
|
|
1039
|
+
private rdb?;
|
|
1040
|
+
readKnexfile(): Promise<SonamuDBConfig>;
|
|
1041
|
+
getDB(which: DBPreset): Knex;
|
|
1042
|
+
destroy(): Promise<void>;
|
|
1043
|
+
}
|
|
1044
|
+
declare const DB: DBClass;
|
|
1045
|
+
|
|
1046
|
+
type SonamuConfig = {
|
|
1047
|
+
api: {
|
|
1048
|
+
dir: string;
|
|
1049
|
+
};
|
|
1050
|
+
sync: {
|
|
1051
|
+
targets: string[];
|
|
1052
|
+
};
|
|
1053
|
+
route: {
|
|
1054
|
+
prefix: string;
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
type SonamuSecrets = {
|
|
1058
|
+
[key: string]: string;
|
|
1059
|
+
};
|
|
1060
|
+
type SonamuFastifyConfig = {
|
|
1061
|
+
contextProvider: (defaultContext: Pick<Context, "headers" | "reply">, request: FastifyRequest, reply: FastifyReply) => Context;
|
|
1062
|
+
guardHandler: (guard: string, request: FastifyRequest, api: {
|
|
1063
|
+
typeParameters: ApiParamType.TypeParam[];
|
|
1064
|
+
parameters: ApiParam[];
|
|
1065
|
+
returnType: ApiParamType;
|
|
1066
|
+
modelName: string;
|
|
1067
|
+
methodName: string;
|
|
1068
|
+
path: string;
|
|
1069
|
+
options: ApiDecoratorOptions;
|
|
1070
|
+
}) => void;
|
|
1071
|
+
cache?: {
|
|
1072
|
+
get: (key: string) => Promise<unknown | null>;
|
|
1073
|
+
put: (key: string, value: unknown, ttl?: number) => Promise<void>;
|
|
1074
|
+
resolveKey: (path: string, reqBody: {
|
|
1075
|
+
[key: string]: unknown;
|
|
1076
|
+
}) => {
|
|
1077
|
+
cache: false;
|
|
1078
|
+
} | {
|
|
1079
|
+
cache: true;
|
|
1080
|
+
key: string;
|
|
1081
|
+
ttl?: number;
|
|
1082
|
+
};
|
|
1083
|
+
};
|
|
1084
|
+
};
|
|
1085
|
+
declare class SonamuClass {
|
|
1086
|
+
isInitialized: boolean;
|
|
1087
|
+
private _apiRootPath;
|
|
1088
|
+
set apiRootPath(apiRootPath: string);
|
|
1089
|
+
get apiRootPath(): string;
|
|
1090
|
+
get appRootPath(): string;
|
|
1091
|
+
private _dbConfig;
|
|
1092
|
+
set dbConfig(dbConfig: SonamuDBConfig);
|
|
1093
|
+
get dbConfig(): SonamuDBConfig;
|
|
1094
|
+
private _syncer;
|
|
1095
|
+
set syncer(syncer: Syncer);
|
|
1096
|
+
get syncer(): Syncer;
|
|
1097
|
+
private _config;
|
|
1098
|
+
set config(config: SonamuConfig);
|
|
1099
|
+
get config(): SonamuConfig;
|
|
1100
|
+
private _secrets;
|
|
1101
|
+
set secrets(secrets: SonamuSecrets);
|
|
1102
|
+
get secrets(): SonamuSecrets | null;
|
|
1103
|
+
init(doSilent?: boolean, enableSync?: boolean, apiRootPath?: string): Promise<void>;
|
|
1104
|
+
withFastify(server: FastifyInstance<Server, IncomingMessage, ServerResponse>, config: SonamuFastifyConfig, options?: {
|
|
1105
|
+
enableSync?: boolean;
|
|
1106
|
+
doSilent?: boolean;
|
|
1107
|
+
}): Promise<void>;
|
|
1108
|
+
destroy(): Promise<void>;
|
|
1109
|
+
}
|
|
1110
|
+
declare const Sonamu: SonamuClass;
|
|
1111
|
+
|
|
1112
|
+
type ListResult<T> = {
|
|
1113
|
+
rows: T[];
|
|
1114
|
+
total?: number;
|
|
1115
|
+
};
|
|
1116
|
+
type ArrayOr<T> = T | T[];
|
|
1117
|
+
declare function asArray<T>(param: T | T[]): T[];
|
|
1118
|
+
declare function objToMap<T>(obj: {
|
|
1119
|
+
[k: string]: T;
|
|
1120
|
+
}): Map<number, T> | Map<string, T>;
|
|
1121
|
+
interface BaseListParams {
|
|
1122
|
+
id?: number | number[];
|
|
1123
|
+
num?: number;
|
|
1124
|
+
page?: number;
|
|
1125
|
+
keyword?: string;
|
|
1126
|
+
queryMode?: "list" | "count" | "both";
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
type TableData = {
|
|
1130
|
+
references: Set<string>;
|
|
1131
|
+
rows: any[];
|
|
1132
|
+
uniqueIndexes: {
|
|
1133
|
+
name?: string;
|
|
1134
|
+
columns: string[];
|
|
1135
|
+
}[];
|
|
1136
|
+
uniquesMap: Map<string, string>;
|
|
1137
|
+
};
|
|
1138
|
+
type UBRef = {
|
|
1139
|
+
uuid: string;
|
|
1140
|
+
of: string;
|
|
1141
|
+
use?: string;
|
|
1142
|
+
};
|
|
1143
|
+
declare function isRefField(field: any): field is UBRef;
|
|
1144
|
+
declare class UpsertBuilder {
|
|
1145
|
+
tables: Map<string, TableData>;
|
|
1146
|
+
constructor();
|
|
1147
|
+
getTable(tableName: string): TableData;
|
|
1148
|
+
hasTable(tableName: string): boolean;
|
|
1149
|
+
register<T extends string>(tableName: string, row: {
|
|
1150
|
+
[key in T]?: UBRef | string | number | boolean | bigint | null | object | unknown;
|
|
1151
|
+
}): UBRef;
|
|
1152
|
+
upsert(wdb: Knex, tableName: string, chunkSize?: number): Promise<number[]>;
|
|
1153
|
+
insertOnly(wdb: Knex, tableName: string, chunkSize?: number): Promise<number[]>;
|
|
1154
|
+
upsertOrInsert(wdb: Knex, tableName: string, mode: "upsert" | "insert", chunkSize?: number): Promise<number[]>;
|
|
1155
|
+
updateBatch(wdb: Knex, tableName: string, options?: {
|
|
1156
|
+
chunkSize?: number;
|
|
1157
|
+
where?: string | string[];
|
|
1158
|
+
}): Promise<void>;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
declare class BaseModelClass {
|
|
1162
|
+
modelName: string;
|
|
1163
|
+
getDB(which: DBPreset): Knex;
|
|
1164
|
+
destroy(): Promise<void>;
|
|
1165
|
+
myNow(timestamp?: number): string;
|
|
1166
|
+
getInsertedIds(wdb: Knex, rows: any[], tableName: string, unqKeyFields: string[], chunkSize?: number): Promise<number[]>;
|
|
1167
|
+
useLoaders(db: Knex, rows: any[], loaders: SubsetQuery["loaders"]): Promise<any[]>;
|
|
1168
|
+
hydrate<T>(rows: T[]): T[];
|
|
1169
|
+
runSubsetQuery<T extends BaseListParams, U extends string>({ params, baseTable, subset, subsetQuery, build, debug, db: _db, optimizeCountQuery, }: {
|
|
1170
|
+
subset: U;
|
|
1171
|
+
params: T;
|
|
1172
|
+
subsetQuery: SubsetQuery;
|
|
1173
|
+
build: (buildParams: {
|
|
1174
|
+
qb: Knex.QueryBuilder;
|
|
1175
|
+
db: Knex;
|
|
1176
|
+
select: (string | Knex.Raw)[];
|
|
1177
|
+
joins: SubsetQuery["joins"];
|
|
1178
|
+
virtual: string[];
|
|
1179
|
+
}) => Knex.QueryBuilder;
|
|
1180
|
+
baseTable?: string;
|
|
1181
|
+
debug?: boolean | "list" | "count";
|
|
1182
|
+
db?: Knex;
|
|
1183
|
+
optimizeCountQuery?: boolean;
|
|
1184
|
+
}): Promise<{
|
|
1185
|
+
rows: any[];
|
|
1186
|
+
total?: number | undefined;
|
|
1187
|
+
subsetQuery: SubsetQuery;
|
|
1188
|
+
qb: Knex.QueryBuilder;
|
|
1189
|
+
}>;
|
|
1190
|
+
getJoinClause(db: Knex<any, unknown>, join: SubsetQuery["joins"][number]): Knex.Raw<any>;
|
|
1191
|
+
getUpsertBuilder(): UpsertBuilder;
|
|
1192
|
+
}
|
|
1193
|
+
declare const BaseModel: BaseModelClass;
|
|
1194
|
+
|
|
1195
|
+
declare function setupErrorHandler(server: FastifyInstance): void;
|
|
1196
|
+
|
|
1197
|
+
declare abstract class SoException extends Error {
|
|
1198
|
+
readonly statusCode: number;
|
|
1199
|
+
message: string;
|
|
1200
|
+
payload?: unknown;
|
|
1201
|
+
constructor(statusCode: number, message: string, payload?: unknown);
|
|
1202
|
+
}
|
|
1203
|
+
declare function isSoException(err: any): err is SoException;
|
|
1204
|
+
declare class BadRequestException extends SoException {
|
|
1205
|
+
message: string;
|
|
1206
|
+
payload?: unknown;
|
|
1207
|
+
constructor(message?: string, payload?: unknown);
|
|
1208
|
+
}
|
|
1209
|
+
declare class UnauthorizedException extends SoException {
|
|
1210
|
+
message: string;
|
|
1211
|
+
payload?: unknown;
|
|
1212
|
+
constructor(message?: string, payload?: unknown);
|
|
1213
|
+
}
|
|
1214
|
+
declare class NotFoundException extends SoException {
|
|
1215
|
+
message: string;
|
|
1216
|
+
payload?: unknown;
|
|
1217
|
+
constructor(message?: string, payload?: unknown);
|
|
1218
|
+
}
|
|
1219
|
+
declare class ServiceUnavailableException extends SoException {
|
|
1220
|
+
message: string;
|
|
1221
|
+
payload?: unknown;
|
|
1222
|
+
constructor(message?: string, payload?: unknown);
|
|
1223
|
+
}
|
|
1224
|
+
declare class InternalServerErrorException extends SoException {
|
|
1225
|
+
message: string;
|
|
1226
|
+
payload?: unknown;
|
|
1227
|
+
constructor(message?: string, payload?: unknown);
|
|
1228
|
+
}
|
|
1229
|
+
declare class AlreadyProcessedException extends SoException {
|
|
1230
|
+
message: string;
|
|
1231
|
+
payload?: unknown;
|
|
1232
|
+
constructor(message?: string, payload?: unknown);
|
|
1233
|
+
}
|
|
1234
|
+
declare class DuplicateRowException extends SoException {
|
|
1235
|
+
message: string;
|
|
1236
|
+
payload?: unknown;
|
|
1237
|
+
constructor(message?: string, payload?: unknown);
|
|
1238
|
+
}
|
|
1239
|
+
declare class TargetNotFoundException extends SoException {
|
|
1240
|
+
message: string;
|
|
1241
|
+
payload?: unknown;
|
|
1242
|
+
constructor(message?: string, payload?: unknown);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
declare const p: {
|
|
1246
|
+
integer: typeof integer;
|
|
1247
|
+
bigInteger: typeof bigInteger;
|
|
1248
|
+
text: typeof text;
|
|
1249
|
+
string: typeof string;
|
|
1250
|
+
float: typeof float;
|
|
1251
|
+
double: typeof double;
|
|
1252
|
+
decimal: typeof decimal;
|
|
1253
|
+
boolean: typeof boolean;
|
|
1254
|
+
date: typeof date;
|
|
1255
|
+
dateTime: typeof dateTime;
|
|
1256
|
+
time: typeof time;
|
|
1257
|
+
timestamp: typeof timestamp;
|
|
1258
|
+
json: typeof json;
|
|
1259
|
+
uuid: typeof uuid;
|
|
1260
|
+
enums: typeof enums;
|
|
1261
|
+
virtual: typeof virtual;
|
|
1262
|
+
relationOneToOne: typeof relationOneToOne;
|
|
1263
|
+
relationBelongsToOne: typeof relationBelongsToOne;
|
|
1264
|
+
relationHasMany: typeof relationHasMany;
|
|
1265
|
+
relationManyToMany: typeof relationManyToMany;
|
|
1266
|
+
};
|
|
1267
|
+
declare function integer(name: string, option?: Omit<IntegerProp, "name" | "type">): IntegerProp;
|
|
1268
|
+
declare function bigInteger(name: string, option?: Omit<BigIntegerProp, "name" | "type">): BigIntegerProp;
|
|
1269
|
+
declare function text(name: string, option: Omit<TextProp, "name" | "type">): TextProp;
|
|
1270
|
+
declare function string(name: string, option: Omit<StringProp, "name" | "type">): StringProp;
|
|
1271
|
+
declare function float(name: string, option?: Omit<FloatProp, "name" | "type">): FloatProp;
|
|
1272
|
+
declare function double(name: string, option?: Omit<DoubleProp, "name" | "type">): DoubleProp;
|
|
1273
|
+
declare function decimal(name: string, option?: Omit<DecimalProp, "name" | "type">): DecimalProp;
|
|
1274
|
+
declare function boolean(name: string, option?: Omit<BooleanProp, "name" | "type">): BooleanProp;
|
|
1275
|
+
declare function date(name: string, option?: Omit<DateProp, "name" | "type"> & {
|
|
1276
|
+
now?: true;
|
|
1277
|
+
}): DateProp;
|
|
1278
|
+
declare function dateTime(name: string, option?: Omit<DateTimeProp, "name" | "type"> & {
|
|
1279
|
+
now?: true;
|
|
1280
|
+
}): DateTimeProp;
|
|
1281
|
+
declare function time(name: string, option?: Omit<TimeProp, "name" | "type"> & {
|
|
1282
|
+
now?: true;
|
|
1283
|
+
}): TimeProp;
|
|
1284
|
+
declare function timestamp(name: string, option?: Omit<TimestampProp, "name" | "type"> & {
|
|
1285
|
+
now?: true;
|
|
1286
|
+
}): TimestampProp;
|
|
1287
|
+
declare function json(name: string, option: Omit<JsonProp, "name" | "type">): JsonProp;
|
|
1288
|
+
declare function uuid(name: string, option: Omit<UuidProp, "name" | "type">): UuidProp;
|
|
1289
|
+
declare function enums(name: string, option: Omit<EnumProp, "name" | "type" | "id"> & {
|
|
1290
|
+
id?: string;
|
|
1291
|
+
}): EnumProp;
|
|
1292
|
+
declare function virtual(name: string, option: Omit<VirtualProp, "name" | "type" | "dbDefault" | "toFilter">): VirtualProp;
|
|
1293
|
+
declare function relationOneToOne(name: string, option: DistributiveOmit<OneToOneRelationProp, "name" | "type" | "relationType">): OneToOneRelationProp;
|
|
1294
|
+
declare function relationBelongsToOne(name: string, option: Omit<BelongsToOneRelationProp, "name" | "type" | "relationType">): BelongsToOneRelationProp;
|
|
1295
|
+
declare function relationHasMany(name: string, option: Omit<HasManyRelationProp, "name" | "type" | "relationType">): HasManyRelationProp;
|
|
1296
|
+
declare function relationManyToMany(name: string, option: Omit<ManyToManyRelationProp, "name" | "type" | "relationType">): ManyToManyRelationProp;
|
|
1297
|
+
declare const i: {
|
|
1298
|
+
index: typeof index;
|
|
1299
|
+
unique: typeof unique;
|
|
1300
|
+
};
|
|
1301
|
+
declare function index(columns: string | string[]): EntityIndex;
|
|
1302
|
+
declare function unique(columns: string | string[]): EntityIndex;
|
|
1303
|
+
|
|
1304
|
+
type MigratorMode = "dev" | "deploy";
|
|
1305
|
+
type MigratorOptions = {
|
|
1306
|
+
readonly mode: MigratorMode;
|
|
1307
|
+
};
|
|
1308
|
+
type MigrationCode = {
|
|
1309
|
+
name: string;
|
|
1310
|
+
path: string;
|
|
1311
|
+
};
|
|
1312
|
+
type ConnString = `${"mysql2"}://${string}@${string}:${number}/${string}`;
|
|
1313
|
+
type MigrationStatus = {
|
|
1314
|
+
codes: MigrationCode[];
|
|
1315
|
+
conns: {
|
|
1316
|
+
name: string;
|
|
1317
|
+
connKey: string;
|
|
1318
|
+
connString: ConnString;
|
|
1319
|
+
currentVersion: string;
|
|
1320
|
+
status: string | number;
|
|
1321
|
+
pending: string[];
|
|
1322
|
+
}[];
|
|
1323
|
+
preparedCodes: GenMigrationCode[];
|
|
1324
|
+
};
|
|
1325
|
+
declare class Migrator {
|
|
1326
|
+
readonly mode: MigratorMode;
|
|
1327
|
+
targets: {
|
|
1328
|
+
compare?: Knex;
|
|
1329
|
+
pending: Knex;
|
|
1330
|
+
shadow: Knex;
|
|
1331
|
+
apply: Knex[];
|
|
1332
|
+
};
|
|
1333
|
+
constructor(options: MigratorOptions);
|
|
1334
|
+
getMigrationCodes(): Promise<{
|
|
1335
|
+
normal: MigrationCode[];
|
|
1336
|
+
onlyTs: MigrationCode[];
|
|
1337
|
+
onlyJs: MigrationCode[];
|
|
1338
|
+
}>;
|
|
1339
|
+
getStatus(): Promise<MigrationStatus>;
|
|
1340
|
+
runAction(action: "latest" | "rollback", targets: string[]): Promise<{
|
|
1341
|
+
connKey: string;
|
|
1342
|
+
batchNo: number;
|
|
1343
|
+
applied: string[];
|
|
1344
|
+
}[]>;
|
|
1345
|
+
delCodes(codeNames: string[]): Promise<number>;
|
|
1346
|
+
generatePreparedCodes(): Promise<number>;
|
|
1347
|
+
clearPendingList(): Promise<void>;
|
|
1348
|
+
check(): Promise<void>;
|
|
1349
|
+
run(): Promise<void>;
|
|
1350
|
+
rollback(): Promise<void>;
|
|
1351
|
+
cleanUpDist(force?: boolean): Promise<void>;
|
|
1352
|
+
runShadowTest(): Promise<{
|
|
1353
|
+
connKey: string;
|
|
1354
|
+
batchNo: number;
|
|
1355
|
+
applied: string[];
|
|
1356
|
+
}[]>;
|
|
1357
|
+
resetAll(): Promise<void>;
|
|
1358
|
+
compareMigrations(compareDB: Knex): Promise<GenMigrationCode[]>;
|
|
1359
|
+
getMigrationSetFromDB(compareDB: Knex, table: string): Promise<MigrationSet | null>;
|
|
1360
|
+
resolveDBColType(colType: string, colField: string): Pick<MigrationColumn, "type" | "unsigned" | "length" | "precision" | "scale">;
|
|
1361
|
+
readTable(compareDB: Knex, tableName: string): Promise<[DBColumn[], DBIndex[], DBForeign[]]>;
|
|
1362
|
+
getMigrationSetFromMD(entity: Entity): MigrationSetAndJoinTable;
|
|
1363
|
+
genColumnDefinitions(columns: MigrationColumn[]): string[];
|
|
1364
|
+
genIndexDefinitions(indexes: MigrationIndex[]): string[];
|
|
1365
|
+
genForeignDefinitions(table: string, foreigns: MigrationForeign[]): {
|
|
1366
|
+
up: string[];
|
|
1367
|
+
down: string[];
|
|
1368
|
+
};
|
|
1369
|
+
generateCreateCode_ColumnAndIndexes(table: string, columns: MigrationColumn[], indexes: MigrationIndex[]): Promise<GenMigrationCode>;
|
|
1370
|
+
generateCreateCode_Foreign(table: string, foreigns: MigrationForeign[]): Promise<GenMigrationCode[]>;
|
|
1371
|
+
showMigrationSet(which: string, migrationSet: MigrationSet): void;
|
|
1372
|
+
generateAlterCode_ColumnAndIndexes(table: string, entityColumns: MigrationColumn[], entityIndexes: MigrationIndex[], dbColumns: MigrationColumn[], dbIndexes: MigrationIndex[]): Promise<GenMigrationCode[]>;
|
|
1373
|
+
getAlterColumnsTo(entityColumns: MigrationColumn[], dbColumns: MigrationColumn[]): {
|
|
1374
|
+
add: MigrationColumn[];
|
|
1375
|
+
drop: MigrationColumn[];
|
|
1376
|
+
alter: MigrationColumn[];
|
|
1377
|
+
};
|
|
1378
|
+
getAlterColumnLinesTo(columnsTo: ReturnType<Migrator["getAlterColumnsTo"]>, entityColumns: MigrationColumn[]): {
|
|
1379
|
+
add: {
|
|
1380
|
+
up: string[];
|
|
1381
|
+
down: string[];
|
|
1382
|
+
};
|
|
1383
|
+
drop: {
|
|
1384
|
+
up: string[];
|
|
1385
|
+
down: string[];
|
|
1386
|
+
};
|
|
1387
|
+
alter: {
|
|
1388
|
+
up: string[];
|
|
1389
|
+
down: string[];
|
|
1390
|
+
};
|
|
1391
|
+
};
|
|
1392
|
+
getAlterIndexesTo(entityIndexes: MigrationIndex[], dbIndexes: MigrationIndex[]): {
|
|
1393
|
+
add: MigrationIndex[];
|
|
1394
|
+
drop: MigrationIndex[];
|
|
1395
|
+
};
|
|
1396
|
+
getAlterIndexLinesTo(indexesTo: ReturnType<Migrator["getAlterIndexesTo"]>, columnsTo: ReturnType<Migrator["getAlterColumnsTo"]>): {
|
|
1397
|
+
add: {
|
|
1398
|
+
up: string[];
|
|
1399
|
+
down: string[];
|
|
1400
|
+
};
|
|
1401
|
+
drop: {
|
|
1402
|
+
up: string[];
|
|
1403
|
+
down: string[];
|
|
1404
|
+
};
|
|
1405
|
+
};
|
|
1406
|
+
generateAlterCode_Foreigns(table: string, entityForeigns: MigrationForeign[], dbForeigns: MigrationForeign[]): Promise<GenMigrationCode[]>;
|
|
1407
|
+
destroy(): Promise<void>;
|
|
1408
|
+
}
|
|
1409
|
+
type DBColumn = {
|
|
1410
|
+
Field: string;
|
|
1411
|
+
Type: string;
|
|
1412
|
+
Null: string;
|
|
1413
|
+
Key: string;
|
|
1414
|
+
Default: string | null;
|
|
1415
|
+
Extra: string;
|
|
1416
|
+
};
|
|
1417
|
+
type DBIndex = {
|
|
1418
|
+
Table: string;
|
|
1419
|
+
Non_unique: number;
|
|
1420
|
+
Key_name: string;
|
|
1421
|
+
Seq_in_index: number;
|
|
1422
|
+
Column_name: string;
|
|
1423
|
+
Collation: string | null;
|
|
1424
|
+
Cardinality: number | null;
|
|
1425
|
+
Sub_part: number | null;
|
|
1426
|
+
Packed: string | null;
|
|
1427
|
+
Null: string;
|
|
1428
|
+
Index_type: string;
|
|
1429
|
+
Comment: string;
|
|
1430
|
+
Index_comment: string;
|
|
1431
|
+
Visible: string;
|
|
1432
|
+
Expression: string | null;
|
|
1433
|
+
};
|
|
1434
|
+
type DBForeign = {
|
|
1435
|
+
keyName: string;
|
|
1436
|
+
from: string;
|
|
1437
|
+
referencesTable: string;
|
|
1438
|
+
referencesField: string;
|
|
1439
|
+
onDelete: string;
|
|
1440
|
+
onUpdate: string;
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
declare class FixtureManagerClass {
|
|
1444
|
+
private _tdb;
|
|
1445
|
+
set tdb(tdb: Knex);
|
|
1446
|
+
get tdb(): Knex;
|
|
1447
|
+
private _fdb;
|
|
1448
|
+
set fdb(fdb: Knex);
|
|
1449
|
+
get fdb(): Knex;
|
|
1450
|
+
private dependencyGraph;
|
|
1451
|
+
init(): void;
|
|
1452
|
+
cleanAndSeed(usingTables?: string[]): Promise<void>;
|
|
1453
|
+
getChecksum(db: Knex, tableName: string): Promise<any>;
|
|
1454
|
+
sync(): Promise<void>;
|
|
1455
|
+
importFixture(entityId: string, ids: number[]): Promise<void>;
|
|
1456
|
+
getImportQueries(entityId: string, field: string, id: number): Promise<string[]>;
|
|
1457
|
+
destory(): Promise<void>;
|
|
1458
|
+
getFixtures(sourceDBName: keyof SonamuDBConfig, targetDBName: keyof SonamuDBConfig, searchOptions: FixtureSearchOptions): Promise<FixtureRecord[]>;
|
|
1459
|
+
createFixtureRecord(entity: Entity, row: any, options?: {
|
|
1460
|
+
singleRecord?: boolean;
|
|
1461
|
+
_db?: Knex;
|
|
1462
|
+
}, visitedEntities?: Set<string>): Promise<FixtureRecord[]>;
|
|
1463
|
+
insertFixtures(dbName: keyof SonamuDBConfig, _fixtures: FixtureRecord[]): Promise<FixtureImportResult[]>;
|
|
1464
|
+
private getInsertionOrder;
|
|
1465
|
+
private prepareInsertData;
|
|
1466
|
+
private buildDependencyGraph;
|
|
1467
|
+
private insertFixture;
|
|
1468
|
+
private handleManyToManyRelations;
|
|
1469
|
+
addFixtureLoader(code: string): Promise<void>;
|
|
1470
|
+
private checkUniqueViolation;
|
|
1471
|
+
}
|
|
1472
|
+
declare const FixtureManager: FixtureManagerClass;
|
|
1473
|
+
|
|
1474
|
+
declare function isLocal(): boolean;
|
|
1475
|
+
declare function isRemote(): boolean;
|
|
1476
|
+
declare function isInDocker(): boolean;
|
|
1477
|
+
declare function isDaemonServer(): boolean;
|
|
1478
|
+
declare function isDevelopment(): boolean;
|
|
1479
|
+
declare function isStaging(): boolean;
|
|
1480
|
+
declare function isProduction(): boolean;
|
|
1481
|
+
declare function isTest(): boolean;
|
|
1482
|
+
|
|
1483
|
+
declare function globAsync(pathPattern: string): Promise<string[]>;
|
|
1484
|
+
declare function importMultiple(filePaths: string[], doRefresh?: boolean): Promise<{
|
|
1485
|
+
filePath: string;
|
|
1486
|
+
imported: any;
|
|
1487
|
+
}[]>;
|
|
1488
|
+
declare function findAppRootPath(): Promise<string>;
|
|
1489
|
+
declare function findApiRootPath(): Promise<string>;
|
|
1490
|
+
declare function nonNullable<T>(value: T): value is NonNullable<T>;
|
|
1491
|
+
|
|
1492
|
+
export { AlreadyProcessedException, type ApiDecoratorOptions, type ApiParam, ApiParamType, type ArrayOr, BadRequestException, type BaseListParams, BaseModel, BaseModelClass, type BelongsToOneRelationProp, type BigIntegerProp, type BooleanProp, type CommonProp, type Context, type ContextExtend, DB, type DBPreset, type DateProp, type DateTimeProp, type DecimalProp, type DistributiveOmit, type DoubleProp, DuplicateRowException, Entity, type EntityIndex, type EntityJson, EntityManager, type EntityNamesRecord, type EntityProp, type EntityPropNode, type EntitySubsetRow, type EnumProp, type EnumsLabel, type EnumsLabelKo, type ExtendedApi, type FixtureImportResult, FixtureManager, FixtureManagerClass, type FixtureRecord, type FixtureSearchOptions, type FlattenSubsetRow, type FloatProp, type GenMigrationCode, GenerateOptions, type HasManyRelationProp, type IntegerProp, InternalServerErrorException, type JsonProp, type KnexColumnType, type KnexError, type ListResult, type ManyToManyRelationProp, type MigrationColumn, type MigrationForeign, type MigrationIndex, type MigrationJoinTable, type MigrationSet, type MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, type OneToOneRelationProp, PathAndCode, type RelationOn, type RelationProp, type RelationType, type RenderedTemplate, RenderingNode, type SMDInput, SQLDateTimeString, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, type SonamuDBConfig, SonamuQueryMode, type SonamuSecrets, type StringProp, type SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, type TextProp, type TimeProp, type TimestampProp, type UBRef, UnauthorizedException, UpsertBuilder, type UuidProp, type VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, asArray, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, i, importMultiple, isBelongsToOneRelationProp, isBigIntegerProp, isBooleanProp, isCustomJoinClause, isDaemonServer, isDateProp, isDateTimeProp, isDecimalProp, isDevelopment, isDoubleProp, isEnumProp, isFloatProp, isHasManyRelationProp, isInDocker, isIntegerProp, isJsonProp, isKnexError, isLocal, isManyToManyRelationProp, isOneToOneRelationProp, isProduction, isRefField, isRelationProp, isRemote, isSoException, isStaging, isStringProp, isTest, isTextProp, isTimeProp, isTimestampProp, isUuidProp, isVirtualProp, nonNullable, objToMap, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zArrayable, zodTypeToTsTypeDef, zodTypeToZodCode };
|