sonamu 0.2.55 → 0.2.56

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.
Files changed (45) hide show
  1. package/dist/bin/cli.js +89 -118
  2. package/dist/bin/cli.js.map +1 -1
  3. package/dist/bin/cli.mjs +45 -74
  4. package/dist/bin/cli.mjs.map +1 -1
  5. package/dist/{chunk-ZFLQLW37.mjs → chunk-RHSTOLSM.mjs} +5568 -5243
  6. package/dist/chunk-RHSTOLSM.mjs.map +1 -0
  7. package/dist/{chunk-WJGRXAXE.js → chunk-V6CWU5VD.js} +5577 -5252
  8. package/dist/chunk-V6CWU5VD.js.map +1 -0
  9. package/dist/index.d.mts +931 -226
  10. package/dist/index.d.ts +931 -226
  11. package/dist/index.js +26 -13
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +31 -18
  14. package/dist/index.mjs.map +1 -1
  15. package/package.json +1 -1
  16. package/dist/base-model-BzMJ2E_I.d.mts +0 -43
  17. package/dist/base-model-CWRKUX49.d.ts +0 -43
  18. package/dist/chunk-4K2F3SOM.mjs +0 -231
  19. package/dist/chunk-4K2F3SOM.mjs.map +0 -1
  20. package/dist/chunk-6SP5N5ND.mjs +0 -1579
  21. package/dist/chunk-6SP5N5ND.mjs.map +0 -1
  22. package/dist/chunk-EUP6N7EK.js +0 -1579
  23. package/dist/chunk-EUP6N7EK.js.map +0 -1
  24. package/dist/chunk-HVVCQLAU.mjs +0 -280
  25. package/dist/chunk-HVVCQLAU.mjs.map +0 -1
  26. package/dist/chunk-N6N3LENC.js +0 -231
  27. package/dist/chunk-N6N3LENC.js.map +0 -1
  28. package/dist/chunk-UAG3SKFM.js +0 -280
  29. package/dist/chunk-UAG3SKFM.js.map +0 -1
  30. package/dist/chunk-WJGRXAXE.js.map +0 -1
  31. package/dist/chunk-ZFLQLW37.mjs.map +0 -1
  32. package/dist/database/drivers/knex/base-model.d.mts +0 -16
  33. package/dist/database/drivers/knex/base-model.d.ts +0 -16
  34. package/dist/database/drivers/knex/base-model.js +0 -55
  35. package/dist/database/drivers/knex/base-model.js.map +0 -1
  36. package/dist/database/drivers/knex/base-model.mjs +0 -56
  37. package/dist/database/drivers/knex/base-model.mjs.map +0 -1
  38. package/dist/database/drivers/kysely/base-model.d.mts +0 -22
  39. package/dist/database/drivers/kysely/base-model.d.ts +0 -22
  40. package/dist/database/drivers/kysely/base-model.js +0 -64
  41. package/dist/database/drivers/kysely/base-model.js.map +0 -1
  42. package/dist/database/drivers/kysely/base-model.mjs +0 -65
  43. package/dist/database/drivers/kysely/base-model.mjs.map +0 -1
  44. package/dist/model-CAH_4oQh.d.mts +0 -1042
  45. package/dist/model-CAH_4oQh.d.ts +0 -1042
package/dist/index.d.mts CHANGED
@@ -1,14 +1,775 @@
1
1
  import { z } from 'zod';
2
- import { A as ApiParamType, e as ApiParam, E as EntityPropNode, T as TextProp, f as EntityProp, R as RelationProp, g as EntityIndex, h as EntityJson, S as SubsetQuery, i as EntitySubsetRow, j as TemplateKey, k as TemplateOptions, P as PathAndCode, G as GenerateOptions, l as RenderingNode, m as SonamuDBConfig, c as DatabaseDriver, K as KnexClient, b as KyselyClient, D as DBPreset, a as Database, n as SonamuDBBaseConfig, o as KnexConfig, p as KyselyConfig, q as KnexGenerator, r as KnexBaseConfig, s as SonamuKnexDBConfig, C as CodeGenerator, M as MigrationColumn, t as MigrationIndex, u as GenMigrationCode, v as MigrationForeign, w as KyselyBaseConfig, x as SonamuKyselyDBConfig, y as DatabaseExtend, I as IntegerProp, z as BigIntegerProp, F as StringProp, H as FloatProp, J as DoubleProp, L as DecimalProp, N as BooleanProp, O as DateProp, Q as DateTimeProp, V as TimeProp, W as TimestampProp, X as JsonProp, Y as UuidProp, Z as EnumProp, _ as VirtualProp, $ as DistributiveOmit, a0 as OneToOneRelationProp, a1 as BelongsToOneRelationProp, a2 as HasManyRelationProp, a3 as ManyToManyRelationProp, a4 as MigrationSet, a5 as MigrationSetAndJoinTable, a6 as FixtureSearchOptions, a7 as FixtureRecord, a8 as FixtureImportResult } from './model-CAH_4oQh.mjs';
3
- export { aS as ArrayOr, B as BaseListParams, aj as CommonProp, ac as DatabaseClient, d as DriverSpec, af as EnumsLabel, ag as EnumsLabelKo, ad as Environment, am as FlattenSubsetRow, aO as KnexColumnType, aL as KnexError, aR as ListResult, aP as MigrationJoinTable, aQ as RelationNode, al as RelationOn, ak as RelationType, an as SMDInput, ah as SQLDateTimeString, ae as SonamuDBFullConfig, aK as SonamuQueryMode, a9 as UBRef, U as UpsertBuilder, ab as WhereClause, aT as asArray, aG as isBelongsToOneRelationProp, ap as isBigIntegerProp, aw as isBooleanProp, aJ as isCustomJoinClause, ax as isDateProp, ay as isDateTimeProp, av as isDecimalProp, au as isDoubleProp, as as isEnumProp, at as isFloatProp, aH as isHasManyRelationProp, ao as isIntegerProp, aB as isJsonProp, aM as isKnexError, aN as isKyselyError, aI as isManyToManyRelationProp, aF as isOneToOneRelationProp, aa as isRefField, aE as isRelationProp, ar as isStringProp, aq as isTextProp, az as isTimeProp, aA as isTimestampProp, aC as isUuidProp, aD as isVirtualProp, aU as objToMap, ai as zArrayable } from './model-CAH_4oQh.mjs';
2
+ import { Knex } from 'knex';
4
3
  import { HTTPMethods, FastifyReply, FastifyInstance, FastifyRequest } from 'fastify';
5
4
  import { RouteGenericInterface } from 'fastify/types/route';
6
5
  import { Server, IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
7
6
  import ts from 'typescript';
8
- import knex, { Knex } from 'knex';
9
- import * as kysely from 'kysely';
10
- import { Kysely } from 'kysely';
11
- import 'mysql2';
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" | "set" | "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
+ };
12
773
 
13
774
  type ServiceClient = "axios" | "axios-multipart" | "swr" | "socketio" | "window-fetch";
14
775
  type ApiDecoratorOptions = {
@@ -101,7 +862,7 @@ declare class Entity {
101
862
  fieldExprsToPropNodes(fieldExprs: string[], entity?: Entity): EntityPropNode[];
102
863
  getFieldExprs(prefix?: string, maxDepth?: number, froms?: string[]): string[];
103
864
  getTableColumns(): string[];
104
- registerModulePaths(): Promise<void>;
865
+ registerModulePaths(): void;
105
866
  registerTableSpecs(): void;
106
867
  toJson(): EntityJson;
107
868
  save(): Promise<void>;
@@ -135,7 +896,7 @@ declare class EntityManagerClass {
135
896
  isAutoloaded: boolean;
136
897
  autoload(doSilent?: boolean): Promise<unknown>;
137
898
  reload(doSilent?: boolean): Promise<unknown>;
138
- register(json: EntityJson): Promise<void>;
899
+ register(json: EntityJson): void;
139
900
  get(entityId: string): Entity;
140
901
  exists(entityId: string): boolean;
141
902
  getAllIds(): string[];
@@ -190,7 +951,6 @@ declare class Syncer {
190
951
  models: {
191
952
  [modelName: string]: unknown;
192
953
  };
193
- isSyncing: boolean;
194
954
  get checksumsPath(): string;
195
955
  constructor();
196
956
  sync(): Promise<void>;
@@ -263,8 +1023,27 @@ declare class Syncer {
263
1023
  }>;
264
1024
  }
265
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
+
266
1046
  type SonamuConfig = {
267
- projectName?: string;
268
1047
  api: {
269
1048
  dir: string;
270
1049
  };
@@ -312,9 +1091,6 @@ declare class SonamuClass {
312
1091
  private _dbConfig;
313
1092
  set dbConfig(dbConfig: SonamuDBConfig);
314
1093
  get dbConfig(): SonamuDBConfig;
315
- private _dbClient;
316
- set dbClient(_dbClient: DatabaseDriver);
317
- get dbClient(): DatabaseDriver;
318
1094
  private _syncer;
319
1095
  set syncer(syncer: Syncer);
320
1096
  get syncer(): Syncer;
@@ -324,8 +1100,7 @@ declare class SonamuClass {
324
1100
  private _secrets;
325
1101
  set secrets(secrets: SonamuSecrets);
326
1102
  get secrets(): SonamuSecrets | null;
327
- initForTesting(): Promise<void>;
328
- init(doSilent?: boolean, enableSync?: boolean, apiRootPath?: string, forTesting?: boolean): Promise<void>;
1103
+ init(doSilent?: boolean, enableSync?: boolean, apiRootPath?: string): Promise<void>;
329
1104
  withFastify(server: FastifyInstance<Server, IncomingMessage, ServerResponse>, config: SonamuFastifyConfig, options?: {
330
1105
  enableSync?: boolean;
331
1106
  doSilent?: boolean;
@@ -334,208 +1109,88 @@ declare class SonamuClass {
334
1109
  }
335
1110
  declare const Sonamu: SonamuClass;
336
1111
 
337
- declare abstract class DBClass {
338
- _fullConfig?: SonamuDBConfig;
339
- set fullConfig(config: SonamuDBConfig);
340
- get fullConfig(): SonamuDBConfig;
341
- abstract tdb: KnexClient | KyselyClient;
342
- abstract fdb: KnexClient | KyselyClient;
343
- abstract testInit(): Promise<void>;
344
- abstract getDB(which: DBPreset): Knex | Kysely<Database>;
345
- abstract destroy(): Promise<void>;
346
- abstract raw(db: Knex | Kysely<Database>, query: string): any;
347
- getBaseConfig(rootPath: string): Promise<SonamuDBBaseConfig>;
348
- getCurrentConfig(which?: DBPreset): KnexConfig | KyselyConfig;
349
- toClient(db: Knex | Kysely<Database>): KnexClient | KyselyClient;
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";
350
1127
  }
351
1128
 
352
- declare class DBKnexClass extends DBClass {
353
- migrationTable: string;
354
- generator: KnexGenerator;
355
- baseConfig?: KnexBaseConfig;
356
- _fullConfig?: SonamuKnexDBConfig;
357
- set fullConfig(config: SonamuKnexDBConfig);
358
- get fullConfig(): SonamuKnexDBConfig;
359
- private wdb?;
360
- private rdb?;
361
- private _tdb;
362
- set tdb(tdb: KnexClient);
363
- get tdb(): KnexClient;
364
- private _fdb;
365
- set fdb(fdb: KnexClient);
366
- get fdb(): KnexClient;
367
- get connectionInfo(): {
368
- development_master: {
369
- host: string;
370
- port: number;
371
- database: string | undefined;
372
- user: string | undefined;
373
- password: string | ((() => string | Promise<string>) & string) | undefined;
374
- };
375
- development_slave: {
376
- host: string;
377
- port: number;
378
- database: string | undefined;
379
- user: string | undefined;
380
- password: string | ((() => string | Promise<string>) & string) | undefined;
381
- };
382
- test: {
383
- host: string;
384
- port: number;
385
- database: string | undefined;
386
- user: string | undefined;
387
- password: string | ((() => string | Promise<string>) & string) | undefined;
388
- };
389
- fixture_local: {
390
- host: string;
391
- port: number;
392
- database: string | undefined;
393
- user: string | undefined;
394
- password: string | ((() => string | Promise<string>) & string) | undefined;
395
- };
396
- fixture_remote: {
397
- host: string;
398
- port: number;
399
- database: string | undefined;
400
- user: string | undefined;
401
- password: string | ((() => string | Promise<string>) & string) | undefined;
402
- };
403
- production_master: {
404
- host: string;
405
- port: number;
406
- database: string | undefined;
407
- user: string | undefined;
408
- password: string | ((() => string | Promise<string>) & string) | undefined;
409
- };
410
- production_slave: {
411
- host: string;
412
- port: number;
413
- database: string | undefined;
414
- user: string | undefined;
415
- password: string | ((() => string | Promise<string>) & string) | undefined;
416
- };
417
- };
418
- constructor();
419
- init(config: KnexBaseConfig): void;
420
- testInit(): Promise<void>;
421
- getDB(which: DBPreset): knex.Knex<any, any[]>;
422
- getClient(mode: keyof SonamuKnexDBConfig): KnexClient;
423
- destroy(): Promise<void>;
424
- testDestroy(): Promise<void>;
425
- raw(db: Knex, query: string): Knex.Raw<any>;
426
- private generateDBConfig;
427
- /**
428
- * keys에 해당하는 설정들을 중복없이 가져옵니다. (host/port/database가 같은 설정은 중복으로 처리합니다.)
429
- */
430
- getUniqueConfigs(keys: (keyof SonamuKnexDBConfig)[]): {
431
- connKey: keyof SonamuKnexDBConfig;
432
- options: KnexConfig;
1129
+ type TableData = {
1130
+ references: Set<string>;
1131
+ rows: any[];
1132
+ uniqueIndexes: {
1133
+ name?: string;
1134
+ columns: string[];
433
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>;
434
1159
  }
435
1160
 
436
- declare class KyselyGenerator extends CodeGenerator {
437
- generateCreateCode_ColumnAndIndexes(table: string, columns: MigrationColumn[], indexes: MigrationIndex[]): Promise<GenMigrationCode>;
438
- generateCreateCode_Foreign(table: string, foreigns: MigrationForeign[]): Promise<GenMigrationCode[]>;
439
- generateAlterCode_ColumnAndIndexes(table: string, entityColumns: MigrationColumn[], entityIndexes: MigrationIndex[], dbColumns: MigrationColumn[], dbIndexes: MigrationIndex[]): Promise<GenMigrationCode[]>;
440
- generateAlterCode_Foreigns(table: string, entityForeigns: MigrationForeign[], dbForeigns: MigrationForeign[]): Promise<GenMigrationCode[]>;
441
- generateModelTemplate(entityId: string, def: {
442
- orderBy: string;
443
- search: string;
444
- }): string;
445
- private genColumnDefinitions;
446
- private genIndexDefinitions;
447
- private genForeignDefinitions;
448
- private getAlterColumnLinesTo;
449
- private getAlterIndexLinesTo;
450
- private createIndexName;
451
- }
452
-
453
- declare class DBKyselyClass extends DBClass {
454
- migrationTable: string;
455
- generator: KyselyGenerator;
456
- baseConfig?: KyselyBaseConfig;
457
- _fullConfig?: SonamuKyselyDBConfig;
458
- set fullConfig(config: SonamuKyselyDBConfig);
459
- get fullConfig(): SonamuKyselyDBConfig;
460
- private wdb?;
461
- private rdb?;
462
- private _tdb;
463
- set tdb(tdb: KyselyClient);
464
- get tdb(): KyselyClient;
465
- private _fdb;
466
- set fdb(fdb: KyselyClient);
467
- get fdb(): KyselyClient;
468
- get connectionInfo(): {
469
- development_master: {
470
- host: string;
471
- port: number;
472
- database: string | undefined;
473
- user: string | undefined;
474
- password: string | undefined;
475
- };
476
- development_slave: {
477
- host: string;
478
- port: number;
479
- database: string | undefined;
480
- user: string | undefined;
481
- password: string | undefined;
482
- };
483
- test: {
484
- host: string;
485
- port: number;
486
- database: string | undefined;
487
- user: string | undefined;
488
- password: string | undefined;
489
- };
490
- fixture_local: {
491
- host: string;
492
- port: number;
493
- database: string | undefined;
494
- user: string | undefined;
495
- password: string | undefined;
496
- };
497
- fixture_remote: {
498
- host: string;
499
- port: number;
500
- database: string | undefined;
501
- user: string | undefined;
502
- password: string | undefined;
503
- };
504
- production_master: {
505
- host: string;
506
- port: number;
507
- database: string | undefined;
508
- user: string | undefined;
509
- password: string | undefined;
510
- };
511
- production_slave: {
512
- host: string;
513
- port: number;
514
- database: string | undefined;
515
- user: string | undefined;
516
- password: string | undefined;
517
- };
518
- };
519
- constructor();
520
- init(config: KyselyBaseConfig): void;
521
- testInit(): Promise<void>;
522
- get config(): SonamuKyselyDBConfig;
523
- getDB(which: DBPreset): Kysely<DatabaseExtend>;
524
- getClient(mode: keyof SonamuKyselyDBConfig): KyselyClient;
1161
+ declare class BaseModelClass {
1162
+ modelName: string;
1163
+ getDB(which: DBPreset): Knex;
525
1164
  destroy(): Promise<void>;
526
- testDestroy(): Promise<void>;
527
- raw(db: Kysely<Database>, query: string): Promise<kysely.QueryResult<unknown>>;
528
- private generateDBConfig;
529
- /**
530
- * keys에 해당하는 설정들을 중복없이 가져옵니다. (host/port/database가 같은 설정은 중복으로 처리합니다.)
531
- */
532
- getUniqueConfigs(keys: (keyof SonamuKyselyDBConfig)[]): {
533
- connKey: keyof SonamuKyselyDBConfig;
534
- options: KyselyConfig;
535
- }[];
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;
536
1192
  }
537
-
538
- declare const DB: DBKnexClass | DBKyselyClass;
1193
+ declare const BaseModel: BaseModelClass;
539
1194
 
540
1195
  declare function setupErrorHandler(server: FastifyInstance): void;
541
1196
 
@@ -670,10 +1325,10 @@ type MigrationStatus = {
670
1325
  declare class Migrator {
671
1326
  readonly mode: MigratorMode;
672
1327
  targets: {
673
- compare?: KnexClient | KyselyClient;
674
- pending: KnexClient | KyselyClient;
675
- shadow: KnexClient | KyselyClient;
676
- apply: (KnexClient | KyselyClient)[];
1328
+ compare?: Knex;
1329
+ pending: Knex;
1330
+ shadow: Knex;
1331
+ apply: Knex[];
677
1332
  };
678
1333
  constructor(options: MigratorOptions);
679
1334
  getMigrationCodes(): Promise<{
@@ -700,12 +1355,55 @@ declare class Migrator {
700
1355
  applied: string[];
701
1356
  }[]>;
702
1357
  resetAll(): Promise<void>;
703
- compareMigrations(compareDB: KnexClient | KyselyClient): Promise<GenMigrationCode[]>;
704
- getMigrationSetFromDB(compareDB: KnexClient | KyselyClient, table: string): Promise<MigrationSet | null>;
1358
+ compareMigrations(compareDB: Knex): Promise<GenMigrationCode[]>;
1359
+ getMigrationSetFromDB(compareDB: Knex, table: string): Promise<MigrationSet | null>;
705
1360
  resolveDBColType(colType: string, colField: string): Pick<MigrationColumn, "type" | "unsigned" | "length" | "precision" | "scale">;
706
- readTable(compareDB: KnexClient | KyselyClient, tableName: string): Promise<[DBColumn[], DBIndex[], DBForeign[]]>;
707
- getMigrationSetFromEntity(entity: Entity): MigrationSetAndJoinTable;
708
- showMigrationSet(which: "Entity" | "DB", migrationSet: MigrationSet): void;
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[]>;
709
1407
  destroy(): Promise<void>;
710
1408
  }
711
1409
  type DBColumn = {
@@ -743,10 +1441,16 @@ type DBForeign = {
743
1441
  };
744
1442
 
745
1443
  declare class FixtureManagerClass {
746
- private relationGraph;
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;
747
1451
  init(): void;
748
1452
  cleanAndSeed(usingTables?: string[]): Promise<void>;
749
- getChecksum(db: KnexClient | KyselyClient, tableName: string): Promise<string>;
1453
+ getChecksum(db: Knex, tableName: string): Promise<any>;
750
1454
  sync(): Promise<void>;
751
1455
  importFixture(entityId: string, ids: number[]): Promise<void>;
752
1456
  getImportQueries(entityId: string, field: string, id: number): Promise<string[]>;
@@ -754,10 +1458,12 @@ declare class FixtureManagerClass {
754
1458
  getFixtures(sourceDBName: keyof SonamuDBConfig, targetDBName: keyof SonamuDBConfig, searchOptions: FixtureSearchOptions): Promise<FixtureRecord[]>;
755
1459
  createFixtureRecord(entity: Entity, row: any, options?: {
756
1460
  singleRecord?: boolean;
757
- _db?: KnexClient | KyselyClient;
758
- }): Promise<FixtureRecord[]>;
1461
+ _db?: Knex;
1462
+ }, visitedEntities?: Set<string>): Promise<FixtureRecord[]>;
759
1463
  insertFixtures(dbName: keyof SonamuDBConfig, _fixtures: FixtureRecord[]): Promise<FixtureImportResult[]>;
1464
+ private getInsertionOrder;
760
1465
  private prepareInsertData;
1466
+ private buildDependencyGraph;
761
1467
  private insertFixture;
762
1468
  private handleManyToManyRelations;
763
1469
  addFixtureLoader(code: string): Promise<void>;
@@ -780,8 +1486,7 @@ declare function importMultiple(filePaths: string[], doRefresh?: boolean): Promi
780
1486
  imported: any;
781
1487
  }[]>;
782
1488
  declare function findAppRootPath(): Promise<string>;
783
- declare function findApiRootPath(): string;
1489
+ declare function findApiRootPath(): Promise<string>;
784
1490
  declare function nonNullable<T>(value: T): value is NonNullable<T>;
785
- declare function hydrate<T>(rows: T[]): T[];
786
1491
 
787
- export { AlreadyProcessedException, type ApiDecoratorOptions, ApiParam, ApiParamType, BadRequestException, BelongsToOneRelationProp, BigIntegerProp, BooleanProp, type Context, type ContextExtend, DB, DBPreset, Database, DatabaseDriver, DatabaseExtend, DateProp, DateTimeProp, DecimalProp, DistributiveOmit, DoubleProp, DuplicateRowException, Entity, EntityIndex, EntityJson, EntityManager, type EntityNamesRecord, EntityProp, EntityPropNode, EntitySubsetRow, EnumProp, type ExtendedApi, FixtureImportResult, FixtureManager, FixtureManagerClass, FixtureRecord, FixtureSearchOptions, FloatProp, GenMigrationCode, GenerateOptions, HasManyRelationProp, IntegerProp, InternalServerErrorException, JsonProp, KnexBaseConfig, KnexConfig, KyselyBaseConfig, KyselyConfig, ManyToManyRelationProp, MigrationColumn, MigrationForeign, MigrationIndex, MigrationSet, MigrationSetAndJoinTable, type MigrationStatus, Migrator, type MigratorOptions, NotFoundException, OneToOneRelationProp, PathAndCode, RelationProp, type RenderedTemplate, RenderingNode, type ServiceClient, ServiceUnavailableException, SoException, Sonamu, type SonamuConfig, SonamuDBBaseConfig, SonamuDBConfig, SonamuKnexDBConfig, SonamuKyselyDBConfig, type SonamuSecrets, StringProp, SubsetQuery, Syncer, TargetNotFoundException, TemplateKey, TemplateOptions, TextProp, TimeProp, TimestampProp, UnauthorizedException, UuidProp, VirtualProp, api, apiParamToTsCode, apiParamTypeToTsType, findApiRootPath, findAppRootPath, getTextTypeLength, getZodObjectFromApi, getZodObjectFromApiParams, getZodTypeFromApiParamType, globAsync, hydrate, i, importMultiple, isDaemonServer, isDevelopment, isInDocker, isLocal, isProduction, isRemote, isSoException, isStaging, isTest, nonNullable, p, propNodeToZodTypeDef, propToZodTypeDef, registeredApis, serializeZodType, setupErrorHandler, unwrapPromiseOnce, zodTypeToTsTypeDef, zodTypeToZodCode };
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 };