GenerateCompanyName Class — drizzle-orm Architecture
Architecture documentation for the GenerateCompanyName class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 3e04765f_7007_ae41_d8f4_854c3d007fed["GenerateCompanyName"] e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"] 3e04765f_7007_ae41_d8f4_854c3d007fed -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce b6eebaef_df35_df25_42b3_50afa93dfc13["init()"] 3e04765f_7007_ae41_d8f4_854c3d007fed -->|method| b6eebaef_df35_df25_42b3_50afa93dfc13 f9517c23_ad07_1f0a_cee0_d0251d6c8eb7["generate()"] 3e04765f_7007_ae41_d8f4_854c3d007fed -->|method| f9517c23_ad07_1f0a_cee0_d0251d6c8eb7
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 2588–2658
export class GenerateCompanyName extends AbstractGenerator<{
isUnique?: boolean;
arraySize?: number;
}> {
static override readonly entityKind: string = 'GenerateCompanyName';
private state: {
rng: prand.RandomGenerator;
templates: { template: string; placeholdersCount: number }[];
} | undefined;
override uniqueVersionOfGen = GenerateUniqueCompanyName;
override init({ count, seed }: { count: number; seed: number }) {
super.init({ count, seed });
const rng = prand.xoroshiro128plus(seed);
const templates = [
{ template: '#', placeholdersCount: 1 },
{ template: '# - #', placeholdersCount: 2 },
{ template: '# and #', placeholdersCount: 2 },
{ template: '#, # and #', placeholdersCount: 3 },
];
// max( { template: '#', placeholdersCount: 1 }, { template: '#, # and #', placeholdersCount: 3 } )
const maxCompanyNameLength = Math.max(
maxLastNameLength + maxCompanyNameSuffixLength + 1,
3 * maxLastNameLength + 7,
);
if (this.stringLength !== undefined && this.stringLength < maxCompanyNameLength) {
throw new Error(
`You can't use company name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxCompanyNameLength}.`,
);
}
this.state = { rng, templates };
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
let templateIdx, idx, lastName, companyNameSuffix, companyName;
[templateIdx, this.state.rng] = prand.uniformIntDistribution(0, this.state.templates.length - 1, this.state.rng);
const templateObj = this.state.templates[templateIdx]!;
if (templateObj.template === '#') {
[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);
lastName = lastNames[idx];
[idx, this.state.rng] = prand.uniformIntDistribution(0, companyNameSuffixes.length - 1, this.state.rng);
companyNameSuffix = companyNameSuffixes[idx];
companyName = `${lastName} ${companyNameSuffix}`;
return companyName;
}
const values = [];
for (let i = 0; i < templateObj.placeholdersCount; i++) {
[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);
values.push(lastNames[idx]!);
}
companyName = fillTemplate({
template: templateObj.template,
values,
placeholdersCount: templateObj.placeholdersCount,
});
return companyName;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateCompanyName class?
GenerateCompanyName is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateCompanyName defined?
GenerateCompanyName is defined in drizzle-seed/src/services/Generators.ts at line 2588.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free