Home / File/ pgIntrospect.ts — drizzle-orm Source File

pgIntrospect.ts — drizzle-orm Source File

Architecture documentation for pgIntrospect.ts, a typescript file in the drizzle-orm codebase. 10 imports, 1 dependents.

File typescript DrizzleKit CLIWorkflow 10 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c["pgIntrospect.ts"]
  8f03c4cf_4fdf_b056_3b24_d493cab0cc81["global.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> 8f03c4cf_4fdf_b056_3b24_d493cab0cc81
  cbf63853_6723_30fc_5ded_88a8944f77c4["pgSchema.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> cbf63853_6723_30fc_5ded_88a8944f77c4
  df5ff696_3bb2_dd84_a601_810793c9ec74["pgSerializer.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> df5ff696_3bb2_dd84_a601_810793c9ec74
  5847e5ae_7b4a_4b02_b68f_883ef88b3c1a["utils.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> 5847e5ae_7b4a_4b02_b68f_883ef88b3c1a
  ce0519f7_91ef_9fe5_de1a_968bd9acd812["cli.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> ce0519f7_91ef_9fe5_de1a_968bd9acd812
  99e32ba0_ce20_d8b4_a1e9_b7a00baa9413["Entities"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> 99e32ba0_ce20_d8b4_a1e9_b7a00baa9413
  217e2cbd_4fb7_ceab_251c_5733ece08a8f["views.ts"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> 217e2cbd_4fb7_ceab_251c_5733ece08a8f
  946a5474_7e86_7977_562a_290de1fdc827["ProgressView"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> 946a5474_7e86_7977_562a_290de1fdc827
  a506b568_7d24_7568_35df_af935066e9fd["hanji"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> a506b568_7d24_7568_35df_af935066e9fd
  bcba9db4_12fe_4370_dc2c_c82528eb2bb8["minimatch"]
  9b24aa9e_af00_88e2_5a0a_d67a2b0b670c --> bcba9db4_12fe_4370_dc2c_c82528eb2bb8
  e668bfef_9125_1ef0_2f94_a0f9605584bd["api.ts"]
  e668bfef_9125_1ef0_2f94_a0f9605584bd --> 9b24aa9e_af00_88e2_5a0a_d67a2b0b670c
  style 9b24aa9e_af00_88e2_5a0a_d67a2b0b670c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { renderWithTask } from 'hanji';
import { Minimatch } from 'minimatch';
import { originUUID } from '../../global';
import type { PgSchema, PgSchemaInternal } from '../../serializer/pgSchema';
import { fromDatabase } from '../../serializer/pgSerializer';
import type { DB } from '../../utils';
import { Entities } from '../validations/cli';
import { ProgressView } from '../views';

export const pgPushIntrospect = async (
	db: DB,
	filters: string[],
	schemaFilters: string[],
	entities: Entities,
	tsSchema?: PgSchemaInternal,
) => {
	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, schemaFilters, entities, undefined, tsSchema),
	);

	const schema = { id: originUUID, prevId: '', ...res } as PgSchema;
	const { internal, ...schemaWithoutInternals } = schema;
	return { schema: schemaWithoutInternals };
};

Domain

Subdomains

Functions

Frequently Asked Questions

What does pgIntrospect.ts do?
pgIntrospect.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 pgIntrospect.ts?
pgIntrospect.ts defines 1 function(s): pgPushIntrospect.
What does pgIntrospect.ts depend on?
pgIntrospect.ts imports 10 module(s): Entities, ProgressView, cli.ts, global.ts, hanji, minimatch, pgSchema.ts, pgSerializer.ts, and 2 more.
What files import pgIntrospect.ts?
pgIntrospect.ts is imported by 1 file(s): api.ts.
Where is pgIntrospect.ts in the architecture?
pgIntrospect.ts is located at drizzle-kit/src/cli/commands/pgIntrospect.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