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

common.ts — drizzle-orm Source File

Architecture documentation for common.ts, a typescript file in the drizzle-orm codebase. 5 imports, 26 dependents.

File typescript DrizzleKit CLIWorkflow 5 imports 26 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  9135e6b6_37f7_c980_ee35_90f5531de5a4["common.ts"]
  5e835bc2_6860_21e3_492c_babcc3e93529["schemaValidator.ts"]
  9135e6b6_37f7_c980_ee35_90f5531de5a4 --> 5e835bc2_6860_21e3_492c_babcc3e93529
  502fb53b_89d2_ec40_3a24_f05850833f68["outputs.ts"]
  9135e6b6_37f7_c980_ee35_90f5531de5a4 --> 502fb53b_89d2_ec40_3a24_f05850833f68
  0f00c7dd_5eba_f1f8_c559_a99431086500["chalk"]
  9135e6b6_37f7_c980_ee35_90f5531de5a4 --> 0f00c7dd_5eba_f1f8_c559_a99431086500
  f0f96eec_e424_76f5_d261_7e6fd227ca33["types"]
  9135e6b6_37f7_c980_ee35_90f5531de5a4 --> f0f96eec_e424_76f5_d261_7e6fd227ca33
  9d8cc145_835b_8147_2ea5_b7b5383ae775["zod"]
  9135e6b6_37f7_c980_ee35_90f5531de5a4 --> 9d8cc145_835b_8147_2ea5_b7b5383ae775
  e668bfef_9125_1ef0_2f94_a0f9605584bd["api.ts"]
  e668bfef_9125_1ef0_2f94_a0f9605584bd --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  c2c22050_0d5c_404e_2b18_5934c728a89c["introspect.ts"]
  c2c22050_0d5c_404e_2b18_5934c728a89c --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  b14d3855_8cce_38c9_8952_a9d014c2fb1b["migrate.ts"]
  b14d3855_8cce_38c9_8952_a9d014c2fb1b --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  6219550e_1686_ca7a_0d96_0838fb90e7cb["push.ts"]
  6219550e_1686_ca7a_0d96_0838fb90e7cb --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  cea479b5_7704_0339_de4e_3cc844834ec0["sqliteIntrospect.ts"]
  cea479b5_7704_0339_de4e_3cc844834ec0 --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  09e5bcf1_0f03_3dbd_fbdb_762440f28855["utils.ts"]
  09e5bcf1_0f03_3dbd_fbdb_762440f28855 --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  5bf76609_579e_d312_b33b_ab5b8b683111["schema.ts"]
  5bf76609_579e_d312_b33b_ab5b8b683111 --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  ce0519f7_91ef_9fe5_de1a_968bd9acd812["cli.ts"]
  ce0519f7_91ef_9fe5_de1a_968bd9acd812 --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  3b06bb5a_5f4f_2e22_4153_4879511c568b["gel.ts"]
  3b06bb5a_5f4f_2e22_4153_4879511c568b --> 9135e6b6_37f7_c980_ee35_90f5531de5a4
  style 9135e6b6_37f7_c980_ee35_90f5531de5a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import chalk from 'chalk';
import { UnionToIntersection } from 'hono/utils/types';
import { any, boolean, enum as enum_, literal, object, string, TypeOf, union } from 'zod';
import { dialect } from '../../schemaValidator';
import { outputs } from './outputs';

export type Commands =
	| 'introspect'
	| 'generate'
	| 'check'
	| 'up'
	| 'drop'
	| 'push'
	| 'export';

type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true;
type LastTupleElement<TArr extends any[]> = TArr extends [
	...start: infer _,
	end: infer Last,
] ? Last
	: never;

export type UniqueArrayOfUnion<TUnion, TArray extends TUnion[]> = Exclude<
	TUnion,
	TArray[number]
> extends never ? [TUnion]
	: [...TArray, Exclude<TUnion, TArray[number]>];

export const assertCollisions = <
	T extends Record<string, unknown>,
	TKeys extends (keyof T)[],
	TRemainingKeys extends Exclude<keyof T, TKeys[number] | 'config'>[],
	Exhaustive extends TRemainingKeys,
	UNIQ extends UniqueArrayOfUnion<TRemainingKeys[number], Exhaustive>,
>(
	command: Commands,
	options: T,
	whitelist: Exclude<TKeys, 'config'>,
	remainingKeys: UniqueArrayOfUnion<TRemainingKeys[number], Exhaustive>,
): IsUnion<LastTupleElement<UNIQ>> extends false ? 'cli' | 'config' : TKeys => {
	const { config, ...rest } = options;

	let atLeastOneParam = false;
	for (const key of Object.keys(rest)) {
		if (whitelist.includes(key)) continue;

		atLeastOneParam = atLeastOneParam || rest[key] !== undefined;
	}

	if (!config && atLeastOneParam) {
		return 'cli' as any;
	}

	if (!atLeastOneParam) {
		return 'config' as any;
	}

	// if config and cli - return error - write a reason
	console.log(outputs.common.ambiguousParams(command));
// ... (134 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does common.ts do?
common.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 common.ts?
common.ts defines 2 function(s): assertCollisions, wrapParam.
What does common.ts depend on?
common.ts imports 5 module(s): chalk, outputs.ts, schemaValidator.ts, types, zod.
What files import common.ts?
common.ts is imported by 26 file(s): api.ts, cli.ts, gel.ts, index.ts, introspect-gel.ts, introspect-mysql.ts, introspect-pg.ts, introspect-singlestore.ts, and 18 more.
Where is common.ts in the architecture?
common.ts is located at drizzle-kit/src/cli/validations/common.ts (domain: DrizzleKit, subdomain: CLIWorkflow, directory: drizzle-kit/src/cli/validations).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free