( casing: Casing, out: string, breakpoints: boolean, credentials: GelCredentials | undefined, tablesFilter: string[], schemasFilter: string[], prefix: Prefix, entities: Entities, )
| 179 | }; |
| 180 | |
| 181 | export const introspectGel = async ( |
| 182 | casing: Casing, |
| 183 | out: string, |
| 184 | breakpoints: boolean, |
| 185 | credentials: GelCredentials | undefined, |
| 186 | tablesFilter: string[], |
| 187 | schemasFilter: string[], |
| 188 | prefix: Prefix, |
| 189 | entities: Entities, |
| 190 | ) => { |
| 191 | const { prepareGelDB } = await import('../connections'); |
| 192 | const db = await prepareGelDB(credentials); |
| 193 | |
| 194 | const matchers = tablesFilter.map((it) => { |
| 195 | return new Minimatch(it); |
| 196 | }); |
| 197 | |
| 198 | const filter = (tableName: string) => { |
| 199 | if (matchers.length === 0) return true; |
| 200 | |
| 201 | let flags: boolean[] = []; |
| 202 | |
| 203 | for (let matcher of matchers) { |
| 204 | if (matcher.negate) { |
| 205 | if (!matcher.match(tableName)) { |
| 206 | flags.push(false); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (matcher.match(tableName)) { |
| 211 | flags.push(true); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | if (flags.length > 0) { |
| 216 | return flags.every(Boolean); |
| 217 | } |
| 218 | return false; |
| 219 | }; |
| 220 | |
| 221 | const progress = new IntrospectProgress(true); |
| 222 | |
| 223 | const res = await renderWithTask( |
| 224 | progress, |
| 225 | fromGelDatabase( |
| 226 | db, |
| 227 | filter, |
| 228 | schemasFilter, |
| 229 | entities, |
| 230 | (stage, count, status) => { |
| 231 | progress.update(stage, count, status); |
| 232 | }, |
| 233 | ), |
| 234 | ); |
| 235 | |
| 236 | const schema = { id: originUUID, prevId: '', ...res } as GelSchema; |
| 237 | const ts = gelSchemaToTypeScript(schema, casing); |
| 238 | const relationsTs = relationsToTypeScript(schema, casing); |
no test coverage detected