(exports: Record<string, unknown>)
| 14 | import { safeRegister } from '../cli/commands/utils'; |
| 15 | |
| 16 | export const prepareFromExports = (exports: Record<string, unknown>) => { |
| 17 | const tables: AnyPgTable[] = []; |
| 18 | const enums: PgEnum<any>[] = []; |
| 19 | const schemas: PgSchema[] = []; |
| 20 | const sequences: PgSequence[] = []; |
| 21 | const roles: PgRole[] = []; |
| 22 | const policies: PgPolicy[] = []; |
| 23 | const views: PgView[] = []; |
| 24 | const matViews: PgMaterializedView[] = []; |
| 25 | const relations: Relations[] = []; |
| 26 | |
| 27 | const i0values = Object.values(exports); |
| 28 | i0values.forEach((t) => { |
| 29 | if (isPgEnum(t)) { |
| 30 | enums.push(t); |
| 31 | return; |
| 32 | } |
| 33 | if (is(t, PgTable)) { |
| 34 | tables.push(t); |
| 35 | } |
| 36 | |
| 37 | if (is(t, PgSchema)) { |
| 38 | schemas.push(t); |
| 39 | } |
| 40 | |
| 41 | if (isPgView(t)) { |
| 42 | views.push(t); |
| 43 | } |
| 44 | |
| 45 | if (isPgMaterializedView(t)) { |
| 46 | matViews.push(t); |
| 47 | } |
| 48 | |
| 49 | if (isPgSequence(t)) { |
| 50 | sequences.push(t); |
| 51 | } |
| 52 | |
| 53 | if (is(t, PgRole)) { |
| 54 | roles.push(t); |
| 55 | } |
| 56 | |
| 57 | if (is(t, PgPolicy)) { |
| 58 | policies.push(t); |
| 59 | } |
| 60 | |
| 61 | if (is(t, Relations)) { |
| 62 | relations.push(t); |
| 63 | } |
| 64 | }); |
| 65 | |
| 66 | return { tables, enums, schemas, sequences, views, matViews, roles, policies, relations }; |
| 67 | }; |
| 68 | |
| 69 | export const prepareFromPgImports = async (imports: string[]) => { |
| 70 | const tables: AnyPgTable[] = []; |
no test coverage detected