@intrig/core 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Intrig Core
|
|
2
|
+
|
|
3
|
+
A powerful TypeScript library and code generator designed to streamline OpenAPI-based network integration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Multiple Framework Support**: Generate client code for both React and Next.js
|
|
12
|
+
- **Type Safety**: Generate TypeScript interfaces from API schemas for reduced runtime errors
|
|
13
|
+
- **REST API Support**: Generate hooks and utilities for REST API endpoints
|
|
14
|
+
- **File Download Support**: Special handling for file download endpoints
|
|
15
|
+
- **Customizable Templates**: Flexible template system for code generation
|
|
16
|
+
- **Intrig Insight**: Project-specific documentation about the generated code
|
|
17
|
+
- **CLI Tool**: Comprehensive command-line interface for managing your project
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install globally
|
|
23
|
+
npm install -g @intrig/core
|
|
24
|
+
|
|
25
|
+
# Or use with npx
|
|
26
|
+
npx @intrig/core
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Configuration
|
|
32
|
+
|
|
33
|
+
Create an `intrig.config.json` file in your project root:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"sources": [
|
|
38
|
+
{
|
|
39
|
+
"id": "my-api",
|
|
40
|
+
"url": "https://example.com/api/swagger.json",
|
|
41
|
+
"type": "openapi"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"generator": "react"
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
You can set the generator to either "react" or "next" depending on your target framework.
|
|
49
|
+
|
|
50
|
+
### CLI Commands
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Initialize Intrig in your project
|
|
54
|
+
intrig init
|
|
55
|
+
|
|
56
|
+
# Add sources
|
|
57
|
+
intrig sources add
|
|
58
|
+
|
|
59
|
+
# List all sources
|
|
60
|
+
intrig sources ls
|
|
61
|
+
|
|
62
|
+
# Remove a source
|
|
63
|
+
intrig sources rm
|
|
64
|
+
|
|
65
|
+
# Sync all entities
|
|
66
|
+
intrig sync
|
|
67
|
+
|
|
68
|
+
# Generate code
|
|
69
|
+
intrig generate
|
|
70
|
+
|
|
71
|
+
# Manage the daemon
|
|
72
|
+
intrig deamon up
|
|
73
|
+
intrig deamon down
|
|
74
|
+
intrig deamon restart
|
|
75
|
+
intrig deamon status
|
|
76
|
+
|
|
77
|
+
# Search for resources
|
|
78
|
+
intrig search
|
|
79
|
+
|
|
80
|
+
# Prebuild and postbuild operations
|
|
81
|
+
intrig prebuild
|
|
82
|
+
intrig postbuild
|
|
83
|
+
|
|
84
|
+
# Get help
|
|
85
|
+
intrig --help
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Architecture
|
|
89
|
+
|
|
90
|
+
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:
|
|
91
|
+
|
|
92
|
+
- **common**: Shared utilities, interfaces, and services
|
|
93
|
+
- **openapi-source**: Parser for OpenAPI specifications
|
|
94
|
+
- **react-binding**: Generator for React bindings
|
|
95
|
+
- **next-binding**: Generator for Next.js bindings
|
|
96
|
+
- **react-client**: Client library for React applications
|
|
97
|
+
- **next-client**: Client library for Next.js applications
|
|
98
|
+
- **intrig**: CLI application and daemon for documentation and sync purposes
|
|
99
|
+
|
|
100
|
+
The code generation process follows these steps:
|
|
101
|
+
|
|
102
|
+
1. Parse API specifications into resource descriptors
|
|
103
|
+
2. Generate code using templates based on the selected framework
|
|
104
|
+
3. Output the generated code to the configured directory
|
|
105
|
+
|
|
106
|
+
## Intrig Insight
|
|
107
|
+
|
|
108
|
+
Intrig Insight is a powerful feature that addresses the "knowledge cost" challenge common with code generators. It provides:
|
|
109
|
+
|
|
110
|
+
- **Project-specific documentation** about the generated code
|
|
111
|
+
- **Customized and personalized documentation** for your specific integration
|
|
112
|
+
- **Reduced learning curve** for new team members or those unfamiliar with generated code
|
|
113
|
+
- **Documentation that stays in sync** with the actual generated output
|
|
114
|
+
|
|
115
|
+
Intrig Insight communicates with a project-specific daemon to provide this documentation. You can start the daemon using:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
intrig deamon up
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Common Workflows
|
|
122
|
+
|
|
123
|
+
### Setting Up a New Project
|
|
124
|
+
|
|
125
|
+
1. Initialize Intrig in your project:
|
|
126
|
+
```
|
|
127
|
+
intrig init
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
2. Add sources:
|
|
131
|
+
```
|
|
132
|
+
intrig sources add
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
3. Sync entities:
|
|
136
|
+
```
|
|
137
|
+
intrig sync
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
4. Generate code:
|
|
141
|
+
```
|
|
142
|
+
intrig generate
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Managing the Daemon
|
|
146
|
+
|
|
147
|
+
1. Start the daemon:
|
|
148
|
+
```
|
|
149
|
+
intrig deamon up
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
2. Check daemon status:
|
|
153
|
+
```
|
|
154
|
+
intrig deamon status
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
3. Restart the daemon after configuration changes:
|
|
158
|
+
```
|
|
159
|
+
intrig deamon restart
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
4. Stop the daemon when not needed:
|
|
163
|
+
```
|
|
164
|
+
intrig deamon down
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
### Prerequisites
|
|
170
|
+
|
|
171
|
+
- Node.js 18+
|
|
172
|
+
- npm or yarn
|
|
173
|
+
|
|
174
|
+
### Setup
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Clone the repository
|
|
178
|
+
git clone https://github.com/intrigsoft/intrig-core.git
|
|
179
|
+
cd intrig-core
|
|
180
|
+
|
|
181
|
+
# Install dependencies
|
|
182
|
+
npm install
|
|
183
|
+
|
|
184
|
+
# Build the project
|
|
185
|
+
npm run build
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Running Tests
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm test
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Release Process
|
|
195
|
+
|
|
196
|
+
To release new versions of the packages, we use Nx Release, which handles version synchronization and publishing in a single command.
|
|
197
|
+
|
|
198
|
+
### Available Release Commands
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Default release (patch)
|
|
202
|
+
npm run release
|
|
203
|
+
|
|
204
|
+
# Specific release types
|
|
205
|
+
npm run release:patch # Increment patch version (0.0.x)
|
|
206
|
+
npm run release:minor # Increment minor version (0.x.0)
|
|
207
|
+
npm run release:major # Increment major version (x.0.0)
|
|
208
|
+
|
|
209
|
+
# Test the release process without publishing
|
|
210
|
+
npm run release:dry-run
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### What Nx Release Does
|
|
214
|
+
|
|
215
|
+
1. Builds all packages using Nx (configured as a preVersionCommand)
|
|
216
|
+
2. Bumps the version according to the release type (major, minor, or patch)
|
|
217
|
+
3. Updates all package versions to the new version (syncing them)
|
|
218
|
+
4. Publishes all packages to npm with the new version
|
|
219
|
+
|
|
220
|
+
### Packages Published
|
|
221
|
+
|
|
222
|
+
Nx Release publishes the following packages:
|
|
223
|
+
- `@intrig/core`
|
|
224
|
+
- `@intrig/next`
|
|
225
|
+
- `@intrig/react`
|
|
226
|
+
|
|
227
|
+
## Troubleshooting
|
|
228
|
+
|
|
229
|
+
If you encounter issues with Intrig, try the following:
|
|
230
|
+
|
|
231
|
+
1. Check if the daemon is running:
|
|
232
|
+
```
|
|
233
|
+
intrig deamon status
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
2. Restart the daemon:
|
|
237
|
+
```
|
|
238
|
+
intrig deamon restart
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
3. Ensure your sources are correctly configured:
|
|
242
|
+
```
|
|
243
|
+
intrig sources ls
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Contributing
|
|
247
|
+
|
|
248
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intrig/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"intrig": "./main.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"main.js"
|
|
10
|
+
"main.js",
|
|
11
|
+
"README.md"
|
|
11
12
|
],
|
|
12
13
|
"publishConfig": {
|
|
13
14
|
"access": "public"
|