
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
type-explorer
Advanced tools
A powerful runtime type analysis and schema generation utility for TypeScript/JavaScript that provides deep structural analysis of values and automatic schema generation for popular validation libraries.
Deep Type Analysis
Schema Generation
Developer Experience
# Using bun
bun add type-explorer
# Using npm
npm install type-explorer
# Using yarn
yarn add type-explorer
# Using pnpm
pnpm add type-explorer
import { TypeAnalyzer } from "type-explorer";
// Initialize analyzer
const analyzer = new TypeAnalyzer();
// Analyze data structure
const result = analyzer.analyze({
user: {
id: 1,
name: "John Doe",
roles: ["admin", "user"],
lastLogin: new Date(),
},
});
// Generate schema (e.g., using Zod)
import { ZodSchemaAdapter } from "type-explorer";
const zodAdapter = new ZodSchemaAdapter();
const schema = zodAdapter.generateSchemaFromData(data);
The TypeAnalyzer provides detailed information about your data structures:
const analysis = analyzer.analyze({
name: "John",
age: 30,
hobbies: ["reading", "coding"],
metadata: {
lastLogin: new Date(),
preferences: { theme: "dark" },
},
});
Customize the analysis depth and detail level:
const analyzer = new TypeAnalyzer({
maxDepth: 10, // Maximum recursion depth
includeMethods: true, // Include function analysis
includeGettersSetters: true, // Include accessor properties
includePrototype: true, // Include prototype chain
includePrivateProps: false, // Exclude private properties
});
import { CONFIG_PRESETS } from "type-explorer";
// Quick surface-level analysis
const minimalAnalyzer = new TypeAnalyzer(CONFIG_PRESETS.MINIMAL);
// Balanced depth and detail (default)
const standardAnalyzer = new TypeAnalyzer(CONFIG_PRESETS.STANDARD);
// Deep inspection including private properties
const detailedAnalyzer = new TypeAnalyzer(CONFIG_PRESETS.DETAILED);
import { ZodSchemaAdapter } from "type-explorer";
import { z } from "zod";
const zodAdapter = new ZodSchemaAdapter();
const schemaString = zodAdapter.generateSchemaFromData(data);
const schema = new Function("z", `return ${schemaString}`)(z);
console.log(schema.parse(data));
Supported types:
string, number, boolean, null, undefined)object, array, Date, enum, union)optional, nullable)import { JoiSchemaAdapter } from "type-explorer";
import * as Joi from "joi";
const joiAdapter = new JoiSchemaAdapter();
const schemaString = joiAdapter.generateSchemaFromData(data);
const schema = new Function("Joi", `return ${schemaString}`)(Joi);
console.log(schema.validate(data));
Supported types:
string, number, boolean, null, undefined)object, array, Date)valid(), alternatives().try(), allow(null))import { YupSchemaAdapter } from "type-explorer";
import * as yup from "yup";
const yupAdapter = new YupSchemaAdapter();
const schemaString = yupAdapter.generateSchemaFromData(data);
const schema = new Function("yup", `return ${schemaString}`)(yup);
console.log(schema.validateSync(data));
Supported types:
string, number, boolean, null, undefined)object, array, Date)oneOf(), nullable(), optional())import { OpenAPISchemaAdapter } from "type-explorer";
const openAPIAdapter = new OpenAPISchemaAdapter();
const schemaString = openAPIAdapter.generateSchemaFromData(data);
const schema = JSON.parse(schemaString);
console.log(schema);
Supported features:
$ref)Register custom type handlers for specialized classes:
analyzer.registerCustomType("MyClass", (value, context) => ({
type: "MyClass",
customProperty: value.someProperty,
path: [...context.path],
}));
try {
const schema = adapter.generateSchemaFromData(data);
const validationResult = schema.safeParse(testData);
if (!validationResult.success) {
console.error("Validation errors:", validationResult.error);
}
} catch (error) {
console.error("Schema generation error:", error);
}
The analyzer provides detailed type information:
interface AnalysisResult {
type: string; // Type identifier
path: (string | number)[]; // Property path
properties?: Record<string, AnalysisResult>; // For objects
elementTypes?: Array<{
// For arrays
type: AnalysisResult;
frequency: number;
count: number;
indices: number[];
}>;
// ... additional type-specific properties
}
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A runtime type analysis tool with support for multiple schema adapters
We found that type-explorer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.