sqliteIntrospect.ts — drizzle-orm Source File
Architecture documentation for sqliteIntrospect.ts, a typescript file in the drizzle-orm codebase. 15 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR cea479b5_7704_0339_de4e_3cc844834ec0["sqliteIntrospect.ts"] 8f03c4cf_4fdf_b056_3b24_d493cab0cc81["global.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 8f03c4cf_4fdf_b056_3b24_d493cab0cc81 c1c349dd_2e31_d056_728c_c034cebb41c0["introspect-sqlite.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> c1c349dd_2e31_d056_728c_c034cebb41c0 5a8c82ee_a5ea_c82a_7f3f_71133b91a28a["schemaToTypeScript"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 5a8c82ee_a5ea_c82a_7f3f_71133b91a28a 03c276d3_0efe_66e2_9ba9_e67edbf29418["sqliteSchema.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 03c276d3_0efe_66e2_9ba9_e67edbf29418 8e6879a2_2b61_04aa_8765_25bc6cfe77be["sqliteSerializer.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 8e6879a2_2b61_04aa_8765_25bc6cfe77be 31460848_0b68_376e_2389_5130b321a073["fromDatabase"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 31460848_0b68_376e_2389_5130b321a073 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a 9135e6b6_37f7_c980_ee35_90f5531de5a4["common.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 9135e6b6_37f7_c980_ee35_90f5531de5a4 aa32f2a7_8cd8_4461_8bdc_c44a0b8de20e["Casing"] cea479b5_7704_0339_de4e_3cc844834ec0 --> aa32f2a7_8cd8_4461_8bdc_c44a0b8de20e 340acff6_8c1f_b0b5_9358_222e8b76d050["sqlite.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 340acff6_8c1f_b0b5_9358_222e8b76d050 217e2cbd_4fb7_ceab_251c_5733ece08a8f["views.ts"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f 4d3a78f8_0730_e394_e2da_0f213c03b618["IntrospectProgress"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 4d3a78f8_0730_e394_e2da_0f213c03b618 946a5474_7e86_7977_562a_290de1fdc827["ProgressView"] cea479b5_7704_0339_de4e_3cc844834ec0 --> 946a5474_7e86_7977_562a_290de1fdc827 a506b568_7d24_7568_35df_af935066e9fd["hanji"] cea479b5_7704_0339_de4e_3cc844834ec0 --> a506b568_7d24_7568_35df_af935066e9fd style cea479b5_7704_0339_de4e_3cc844834ec0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { renderWithTask } from 'hanji';
import { Minimatch } from 'minimatch';
import { originUUID } from '../../global';
import { schemaToTypeScript } from '../../introspect-sqlite';
import type { SQLiteSchema } from '../../serializer/sqliteSchema';
import { fromDatabase } from '../../serializer/sqliteSerializer';
import type { SQLiteDB } from '../../utils';
import { Casing } from '../validations/common';
import type { SqliteCredentials } from '../validations/sqlite';
import { IntrospectProgress, ProgressView } from '../views';
export const sqliteIntrospect = async (
credentials: SqliteCredentials,
filters: string[],
casing: Casing,
) => {
const { connectToSQLite } = await import('../connections');
const db = await connectToSQLite(credentials);
const matchers = filters.map((it) => {
return new Minimatch(it);
});
const filter = (tableName: string) => {
if (matchers.length === 0) return true;
let flags: boolean[] = [];
for (let matcher of matchers) {
if (matcher.negate) {
if (!matcher.match(tableName)) {
flags.push(false);
}
}
if (matcher.match(tableName)) {
flags.push(true);
}
}
if (flags.length > 0) {
return flags.every(Boolean);
}
return false;
};
const progress = new IntrospectProgress();
const res = await renderWithTask(
progress,
fromDatabase(db, filter, (stage, count, status) => {
progress.update(stage, count, status);
}),
);
const schema = { id: originUUID, prevId: '', ...res } as SQLiteSchema;
const ts = schemaToTypeScript(schema, casing);
return { schema, ts };
};
export const sqlitePushIntrospect = async (db: SQLiteDB, filters: string[]) => {
const matchers = filters.map((it) => {
return new Minimatch(it);
});
const filter = (tableName: string) => {
if (matchers.length === 0) return true;
let flags: boolean[] = [];
for (let matcher of matchers) {
if (matcher.negate) {
if (!matcher.match(tableName)) {
flags.push(false);
}
}
if (matcher.match(tableName)) {
flags.push(true);
}
}
if (flags.length > 0) {
return flags.every(Boolean);
}
return false;
};
const progress = new ProgressView(
'Pulling schema from database...',
'Pulling schema from database...',
);
const res = await renderWithTask(progress, fromDatabase(db, filter));
const schema = { id: originUUID, prevId: '', ...res } as SQLiteSchema;
return { schema };
};
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does sqliteIntrospect.ts do?
sqliteIntrospect.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleKit domain, CLIWorkflow subdomain.
What functions are defined in sqliteIntrospect.ts?
sqliteIntrospect.ts defines 2 function(s): sqliteIntrospect, sqlitePushIntrospect.
What does sqliteIntrospect.ts depend on?
sqliteIntrospect.ts imports 15 module(s): Casing, IntrospectProgress, ProgressView, common.ts, fromDatabase, global.ts, hanji, introspect-sqlite.ts, and 7 more.
What files import sqliteIntrospect.ts?
sqliteIntrospect.ts is imported by 1 file(s): api.ts.
Where is sqliteIntrospect.ts in the architecture?
sqliteIntrospect.ts is located at drizzle-kit/src/cli/commands/sqliteIntrospect.ts (domain: DrizzleKit, subdomain: CLIWorkflow, directory: drizzle-kit/src/cli/commands).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free