analyze.ts — drizzle-orm Source File
Architecture documentation for analyze.ts, a typescript file in the drizzle-orm codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 8bf87654_6856_e67c_24ad_740dca24cecc["analyze.ts"] 2af47223_d8fb_64ce_7445_146727d395d3["grammar.ohm-bundle.js"] 8bf87654_6856_e67c_24ad_740dca24cecc --> 2af47223_d8fb_64ce_7445_146727d395d3 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7["fs"] 8bf87654_6856_e67c_24ad_740dca24cecc --> 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7 bff1577c_3446_c37a_2330_ff198b2b8475["ohm-js"] 8bf87654_6856_e67c_24ad_740dca24cecc --> bff1577c_3446_c37a_2330_ff198b2b8475 c2197456_e6cc_1614_c507_f516244187b1["checker.ts"] c2197456_e6cc_1614_c507_f516244187b1 --> 8bf87654_6856_e67c_24ad_740dca24cecc style 8bf87654_6856_e67c_24ad_740dca24cecc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { readFileSync } from 'fs';
import type { Node } from 'ohm-js';
import JSImports from './grammar/grammar.ohm-bundle';
export type CollectionItem = {
type: 'data' | 'types';
source: string;
};
function recursiveRun(...args: Node[]): boolean {
for (const arg of args) {
if (
arg.ctorName === 'Rest'
|| arg.ctorName === 'comment'
|| arg.ctorName === 'stringLiteral'
) {
continue;
}
if (
arg.ctorName === 'ImportExpr_From'
|| arg.ctorName === 'ImportExpr_NoFrom'
) {
arg['analyze']();
continue;
}
if (arg.isTerminal()) continue;
for (const c of arg.children) {
if (!recursiveRun(c)) return false;
}
}
return true;
}
function init(collection: CollectionItem[]) {
const semantics = JSImports.createSemantics();
semantics.addOperation('analyze', {
JSImports(arg0, arg1) {
recursiveRun(arg0, arg1);
},
ImportExpr_From(kImport, importInner, kFrom, importSource) {
const ruleName = importInner.children[0]!.ctorName;
const importType = ruleName === 'ImportInner_Type' || ruleName === 'ImportInner_Types'
? 'types'
: 'data';
collection.push({
source: importSource.children[1]!.sourceString!,
type: importType,
});
},
ImportExpr_NoFrom(kImport, importSource) {
collection.push({
source: importSource.children[1]!.sourceString!,
type: 'data',
});
},
});
return semantics;
}
export function analyze(path: string) {
const file = readFileSync(path).toString();
const match = JSImports.match(file, 'JSImports');
if (match.failed()) throw new Error(`Failed to parse file: ${path}`);
const collection: CollectionItem[] = [];
init(collection)(match)['analyze']();
return collection;
}
Domain
Subdomains
Functions
Types
Dependencies
- fs
- grammar.ohm-bundle.js
- ohm-js
Imported By
Source
Frequently Asked Questions
What does analyze.ts do?
analyze.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, RelationalQuery subdomain.
What functions are defined in analyze.ts?
analyze.ts defines 3 function(s): analyze, init, recursiveRun.
What does analyze.ts depend on?
analyze.ts imports 3 module(s): fs, grammar.ohm-bundle.js, ohm-js.
What files import analyze.ts?
analyze.ts is imported by 1 file(s): checker.ts.
Where is analyze.ts in the architecture?
analyze.ts is located at drizzle-kit/imports-checker/analyze.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: drizzle-kit/imports-checker).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free