<div align="center"> <img src="https://raw.githubusercontent.com/intrigsoft/intrig-core/refs/heads/main/docs/images/intrig-logo.svg" alt="Intrig Logo" width="300"/> </div>
npm install @intrig/coreA powerful TypeScript library and code generator designed to streamline OpenAPI-based network integration.
Intrig Core is a TypeScript library and code generator designed to simplify the process of connecting to APIs described by the OpenAPI specification. It generates type-safe TypeScript code for React and Next.js applications, reducing manual coding effort and potential for errors.
- Multiple Framework Support: Generate client code for both React and Next.js
- Type Safety: Generate TypeScript interfaces from API schemas for reduced runtime errors
- REST API Support: Generate hooks and utilities for REST API endpoints
- File Download Support: Special handling for file download endpoints
- Customizable Templates: Flexible template system for code generation
- Intrig Insight: Project-specific documentation about the generated code
- CLI Tool: Comprehensive command-line interface for managing your project
``bashInstall globally
npm install -g @intrig/core
Usage
$3
Create an
intrig.config.json file in your project root:`json
{
"sources": [
{
"id": "my-api",
"url": "https://example.com/api/swagger.json",
"type": "openapi"
}
],
"generator": "react"
}
`You can set the generator to either "react" or "next" depending on your target framework.
$3
`bash
Initialize Intrig in your project
intrig initAdd sources
intrig sources addList all sources
intrig sources lsRemove a source
intrig sources rmSync all entities
intrig syncGenerate code
intrig generateManage the daemon
intrig daemon up
intrig daemon down
intrig daemon restart
intrig daemon statusSearch for resources
intrig searchPrebuild and postbuild operations
intrig prebuild
intrig postbuildGet help
intrig --help
`Architecture
Intrig Core is built as a monorepo with NestJS, a popular Node.js framework for building scalable server-side applications with TypeScript. The project includes the following components:
- common: Shared utilities, interfaces, and services
- openapi-source: Parser for OpenAPI specifications
- react-binding: Generator for React bindings
- next-binding: Generator for Next.js bindings
- react-client: Client library for React applications
- next-client: Client library for Next.js applications
- intrig: CLI application and daemon for documentation and sync purposes
The code generation process follows these steps:
1. Parse API specifications into resource descriptors
2. Generate code using templates based on the selected framework
3. Output the generated code to the configured directory
Intrig Insight
Intrig Insight is a powerful feature that addresses the "knowledge cost" challenge common with code generators. It provides:
- Project-specific documentation about the generated code
- Customized and personalized documentation for your specific integration
- Reduced learning curve for new team members or those unfamiliar with generated code
- Documentation that stays in sync with the actual generated output
Intrig Insight communicates with a project-specific daemon to provide this documentation. You can start the daemon using:
`bash
intrig daemon up
`Common Workflows
$3
1. Initialize Intrig in your project:
`
intrig init
`2. Add sources:
`
intrig sources add
`3. Sync entities:
`
intrig sync
`4. Generate code:
`
intrig generate
`$3
1. Start the daemon:
`
intrig daemon up
`2. Check daemon status:
`
intrig daemon status
`3. Restart the daemon after configuration changes:
`
intrig daemon restart
`4. Stop the daemon when not needed:
`
intrig daemon down
`Development
$3
- Node.js 18+
- npm or yarn
$3
`bash
Clone the repository
git clone https://github.com/intrigsoft/intrig-core.git
cd intrig-coreInstall dependencies
npm installBuild the project
npm run build
`$3
`bash
npm test
`Release Process
To release new versions of the packages, we use Nx Release, which handles version synchronization and publishing in a single command.
$3
`bash
Default release (patch)
npm run releaseSpecific release types
npm run release:patch # Increment patch version (0.0.x)
npm run release:minor # Increment minor version (0.x.0)
npm run release:major # Increment major version (x.0.0)Test the release process without publishing
npm run release:dry-run
`$3
1. Builds all packages using Nx (configured as a preVersionCommand)
2. Bumps the version according to the release type (major, minor, or patch)
3. Updates all package versions to the new version (syncing them)
4. Publishes all packages to npm with the new version
$3
Nx Release publishes the following packages:
-
@intrig/core
- @intrig/next
- @intrig/reactTroubleshooting
If you encounter issues with Intrig, try the following:
1. Check if the daemon is running:
`
intrig daemon status
`2. Restart the daemon:
`
intrig daemon restart
`3. Ensure your sources are correctly configured:
`
intrig sources ls
``Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.