{"id":23764458,"url":"https://github.com/chaqchase/type-explorer","last_synced_at":"2026-01-11T23:50:05.280Z","repository":{"id":267195482,"uuid":"900513972","full_name":"chaqchase/type-explorer","owner":"chaqchase","description":"A powerful runtime type analysis utility for JavaScript/TypeScript that provides detailed structural analysis of values and their types, with support for automatic schema generation.","archived":false,"fork":false,"pushed_at":"2024-12-09T01:05:20.000Z","size":63,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T00:24:38.422Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaqchase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-09T00:15:14.000Z","updated_at":"2024-12-15T09:31:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"bcdf2b3c-c3d2-4e03-bd8a-f7100338e9ba","html_url":"https://github.com/chaqchase/type-explorer","commit_stats":null,"previous_names":["triyanox/type-explorer","chaqchase/type-explorer"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Ftype-explorer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Ftype-explorer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Ftype-explorer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Ftype-explorer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaqchase","download_url":"https://codeload.github.com/chaqchase/type-explorer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232032227,"owners_count":18462986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-31T22:18:14.244Z","updated_at":"2026-01-11T23:50:05.230Z","avatar_url":"https://github.com/chaqchase.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# type-explorer\n\nA 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.\n\n## Key Features\n\n- **Deep Type Analysis**\n\n  - Comprehensive inspection of complex data structures\n  - Circular reference detection\n  - Support for all JavaScript built-in types\n  - Custom type handler registration\n  - Configurable analysis depth\n\n- **Schema Generation**\n\n  - Multi-library support (Zod, Joi, Yup, OpenAPI)\n  - Type-safe schema generation\n  - Automatic type inference\n  - Support for complex nested structures\n\n- **Developer Experience**\n  - TypeScript-first design\n  - Extensive configuration options\n  - Predefined analysis presets\n  - Detailed type information\n\n## Installation\n\n```bash\n# Using bun\nbun add type-explorer\n\n# Using npm\nnpm install type-explorer\n\n# Using yarn\nyarn add type-explorer\n\n# Using pnpm\npnpm add type-explorer\n```\n\n## Quick Start\n\n```typescript\nimport { TypeAnalyzer } from \"type-explorer\";\n\n// Initialize analyzer\nconst analyzer = new TypeAnalyzer();\n\n// Analyze data structure\nconst result = analyzer.analyze({\n  user: {\n    id: 1,\n    name: \"John Doe\",\n    roles: [\"admin\", \"user\"],\n    lastLogin: new Date(),\n  },\n});\n\n// Generate schema (e.g., using Zod)\nimport { ZodSchemaAdapter } from \"type-explorer\";\nconst zodAdapter = new ZodSchemaAdapter();\nconst schema = zodAdapter.generateSchemaFromData(data);\n```\n\n## Core Concepts\n\n### Type Analysis\n\nThe `TypeAnalyzer` provides detailed information about your data structures:\n\n```typescript\nconst analysis = analyzer.analyze({\n  name: \"John\",\n  age: 30,\n  hobbies: [\"reading\", \"coding\"],\n  metadata: {\n    lastLogin: new Date(),\n    preferences: { theme: \"dark\" },\n  },\n});\n```\n\n### Analysis Configuration\n\nCustomize the analysis depth and detail level:\n\n```typescript\nconst analyzer = new TypeAnalyzer({\n  maxDepth: 10, // Maximum recursion depth\n  includeMethods: true, // Include function analysis\n  includeGettersSetters: true, // Include accessor properties\n  includePrototype: true, // Include prototype chain\n  includePrivateProps: false, // Exclude private properties\n});\n```\n\n### Preset Configurations\n\n```typescript\nimport { CONFIG_PRESETS } from \"type-explorer\";\n\n// Quick surface-level analysis\nconst minimalAnalyzer = new TypeAnalyzer(CONFIG_PRESETS.MINIMAL);\n\n// Balanced depth and detail (default)\nconst standardAnalyzer = new TypeAnalyzer(CONFIG_PRESETS.STANDARD);\n\n// Deep inspection including private properties\nconst detailedAnalyzer = new TypeAnalyzer(CONFIG_PRESETS.DETAILED);\n```\n\n## Schema Generation\n\n### Zod Schemas\n\n```typescript\nimport { ZodSchemaAdapter } from \"type-explorer\";\nimport { z } from \"zod\";\n\nconst zodAdapter = new ZodSchemaAdapter();\nconst schemaString = zodAdapter.generateSchemaFromData(data);\nconst schema = new Function(\"z\", `return ${schemaString}`)(z);\n\nconsole.log(schema.parse(data));\n```\n\nSupported types:\n\n- Primitives (`string`, `number`, `boolean`, `null`, `undefined`)\n- Complex types (`object`, `array`, `Date`, `enum`, `union`)\n- Modifiers (`optional`, `nullable`)\n\n### Joi Schemas\n\n```typescript\nimport { JoiSchemaAdapter } from \"type-explorer\";\nimport * as Joi from \"joi\";\n\nconst joiAdapter = new JoiSchemaAdapter();\nconst schemaString = joiAdapter.generateSchemaFromData(data);\nconst schema = new Function(\"Joi\", `return ${schemaString}`)(Joi);\n\nconsole.log(schema.validate(data));\n```\n\nSupported types:\n\n- Primitives (`string`, `number`, `boolean`, `null`, `undefined`)\n- Complex types (`object`, `array`, `Date`)\n- Validation features (`valid()`, `alternatives().try()`, `allow(null)`)\n\n### Yup Schemas\n\n```typescript\nimport { YupSchemaAdapter } from \"type-explorer\";\nimport * as yup from \"yup\";\n\nconst yupAdapter = new YupSchemaAdapter();\nconst schemaString = yupAdapter.generateSchemaFromData(data);\nconst schema = new Function(\"yup\", `return ${schemaString}`)(yup);\n\nconsole.log(schema.validateSync(data));\n```\n\nSupported types:\n\n- Primitives (`string`, `number`, `boolean`, `null`, `undefined`)\n- Complex types (`object`, `array`, `Date`)\n- Validation features (`oneOf()`, `nullable()`, `optional()`)\n\n### OpenAPI Schemas\n\n```typescript\nimport { OpenAPISchemaAdapter } from \"type-explorer\";\n\nconst openAPIAdapter = new OpenAPISchemaAdapter();\nconst schemaString = openAPIAdapter.generateSchemaFromData(data);\nconst schema = JSON.parse(schemaString);\nconsole.log(schema);\n```\n\nSupported features:\n\n- OpenAPI 3.0 specification\n- All standard JSON Schema types\n- Nullable properties\n- References (`$ref`)\n- Property descriptions\n\n## Advanced Usage\n\n### Custom Type Handlers\n\nRegister custom type handlers for specialized classes:\n\n```typescript\nanalyzer.registerCustomType(\"MyClass\", (value, context) =\u003e ({\n  type: \"MyClass\",\n  customProperty: value.someProperty,\n  path: [...context.path],\n}));\n```\n\n### Error Handling\n\n```typescript\ntry {\n  const schema = adapter.generateSchemaFromData(data);\n  const validationResult = schema.safeParse(testData);\n\n  if (!validationResult.success) {\n    console.error(\"Validation errors:\", validationResult.error);\n  }\n} catch (error) {\n  console.error(\"Schema generation error:\", error);\n}\n```\n\n### Type Analysis Results\n\nThe analyzer provides detailed type information:\n\n```typescript\ninterface AnalysisResult {\n  type: string; // Type identifier\n  path: (string | number)[]; // Property path\n  properties?: Record\u003cstring, AnalysisResult\u003e; // For objects\n  elementTypes?: Array\u003c{\n    // For arrays\n    type: AnalysisResult;\n    frequency: number;\n    count: number;\n    indices: number[];\n  }\u003e;\n  // ... additional type-specific properties\n}\n```\n\n## Contributing\n\nContributions 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.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Links\n\n- [GitHub Repository](https://github.com/triyanox/type-explorer)\n- [Issue Tracker](https://github.com/triyanox/type-explorer/issues)\n- [Documentation](https://github.com/triyanox/type-explorer#readme)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaqchase%2Ftype-explorer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaqchase%2Ftype-explorer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaqchase%2Ftype-explorer/lists"}