strapi2front 0.4.2 → 0.5.0

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 CHANGED
@@ -1,45 +1,33 @@
1
- <div align="center">
2
- <!-- <a href="https://strapi2front.dev">
3
- <picture>
4
- <source media="(prefers-color-scheme: dark)" srcset="https://strapi2front.dev/logo-dark.svg">
5
- <img alt="strapi2front logo" src="https://strapi2front.dev/logo-light.svg" height="128">
6
- </picture>
7
- </a> -->
8
- <h1>strapi2front</h1>
1
+ # strapi2front
9
2
 
10
3
  <a href="https://elevenestudio.com"><img alt="Made by Eleven Estudio" src="https://img.shields.io/badge/MADE%20BY%20Eleven%20Estudio-000000.svg?style=for-the-badge&labelColor=000"></a>
11
4
  <a href="https://www.npmjs.com/package/strapi2front"><img alt="NPM version" src="https://img.shields.io/npm/v/strapi2front.svg?style=for-the-badge&labelColor=000000"></a>
12
5
  <a href="https://github.com/Eleven-Estudio/strapi2front/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/strapi2front.svg?style=for-the-badge&labelColor=000000"></a>
13
6
 
14
- </div>
15
7
 
16
- ## The Strapi TypeScript Generator
8
+ Generate TypeScript types, services, Zod schemas, and Astro Actions from your Strapi schema.
17
9
 
18
- `strapi2front` is a CLI tool that generates TypeScript types, services, and Astro Actions from your Strapi CMS schema. One command syncs everything, keeping your frontend perfectly typed.
10
+ **[View Documentation →](https://strapi2front.dev/docs)**
19
11
 
20
- ## Getting Started
12
+ ---
21
13
 
22
- Initialize strapi2front in your project:
14
+ ## Quick Start
23
15
 
24
16
  ```bash
25
17
  npx strapi2front@latest init
26
- ```
27
-
28
- Then sync your types whenever your Strapi schema changes:
29
-
30
- ```bash
31
18
  npx strapi2front sync
32
19
  ```
33
20
 
34
21
  ## Features
35
22
 
36
- **Type Generation** - Auto-generate TypeScript interfaces from your Strapi schema\
37
- **Service Generation** - Create typed service functions for all content types\
38
- **Astro Actions** - Generate type-safe Astro Actions for client/server data fetching\
39
- **JSDoc Support** - Generate JavaScript files with JSDoc annotations (no TypeScript required)\
40
- **Smart Detection** - Automatically detects framework, TypeScript, and package manager\
41
- **Strapi v4 & v5** - Full support for both Strapi versions\
42
- ⊹ **By-Feature Structure** - Organize generated code by feature (screaming architecture)
23
+ - **Type Generation** TypeScript interfaces from your Strapi schema
24
+ - **Service Generation** Typed CRUD functions for all content types
25
+ - **Zod Schemas** Validation schemas for forms
26
+ - **Astro Actions** — Type-safe server actions
27
+ - **File Upload** Upload helpers for Astro and browser
28
+ - **JSDoc Support** JavaScript files with JSDoc annotations (no TypeScript required)
29
+ - **Strapi v4 & v5** Full support for both versions
30
+ - **By-Feature Structure** — Organize generated code by feature (screaming architecture)
43
31
 
44
32
  ## Generated Output
45
33
 
@@ -48,140 +36,50 @@ src/strapi/
48
36
  ├── collections/
49
37
  │ └── article/
50
38
  │ ├── types.ts # TypeScript interfaces
39
+ │ ├── schemas.ts # Zod validation schemas
51
40
  │ ├── service.ts # Data fetching functions
52
41
  │ └── actions.ts # Astro Actions
53
42
  ├── singles/
54
43
  │ └── homepage/
55
44
  │ ├── types.ts
45
+ │ ├── schemas.ts
56
46
  │ └── service.ts
57
47
  ├── components/
58
48
  │ └── seo.ts
59
49
  └── shared/
60
50
  ├── utils.ts # Utility types
61
51
  ├── client.ts # Strapi client
62
- └── locales.ts # i18n support
52
+ ├── locales.ts # i18n support
53
+ └── upload-action.ts # File upload helpers
63
54
  ```
64
55
 
65
- ## Requirements
66
-
67
- - Node.js 18+
68
- - Strapi v4 or v5
69
- - Astro 4+ (for Astro Actions, more frameworks coming soon)
70
-
71
- ---
72
-
73
- ## Quick Setup
74
-
75
- ### 1. Create a Strapi API Token
76
-
77
- You need an API token with **read-only access** to the Content-Type Builder:
78
-
79
- 1. Go to **Strapi Admin** → **Settings** → **API Tokens**
80
- 2. Create a new **Custom** token
81
- 3. Enable these permissions:
82
- - **Content-type-builder**: `getComponents`, `getComponent`, `getContentTypes`, `getContentType`
83
- - **I18n** (optional): `listLocales`
84
- 4. Add the token to your `.env`:
85
-
86
- ```env
87
- STRAPI_TOKEN=your-token-here
88
- ```
89
-
90
- > This token only reads schema structure, not your content data.
91
-
92
- ### 2. Initialize
93
-
94
- ```bash
95
- npx strapi2front@latest init
96
- ```
97
-
98
- ### 3. Sync Types
99
-
100
- ```bash
101
- npx strapi2front sync
102
- ```
103
-
104
- ---
105
-
106
- ## Configuration
107
-
108
- After init, a `strapi.config.ts` is created:
109
-
110
- ```typescript
111
- import { defineConfig } from "strapi2front";
112
-
113
- export default defineConfig({
114
- url: "http://localhost:1337",
115
- strapiVersion: "v5",
116
- apiPrefix: "/api",
117
- output: {
118
- path: "src/strapi",
119
- },
120
- features: {
121
- types: true,
122
- services: true,
123
- actions: true,
124
- },
125
- });
126
- ```
127
-
128
- ### Key Options
129
-
130
- | Option | Description |
131
- |--------|-------------|
132
- | `url` | Your Strapi instance URL |
133
- | `strapiVersion` | `"v4"` or `"v5"` |
134
- | `apiPrefix` | API prefix (default: `/api`) |
135
- | `outputFormat` | `"typescript"` or `"jsdoc"` |
136
- | `moduleType` | `"esm"` or `"commonjs"` (auto-detected) |
137
- | `output.path` | Where to generate files |
138
- | `output.structure` | `"by-feature"` or `"by-layer"` |
139
-
140
- ### Environment Variables
141
-
142
- ```env
143
- STRAPI_URL=http://localhost:1337
144
- STRAPI_TOKEN=your-api-token
145
- STRAPI_API_PREFIX=/api
146
- ```
147
-
148
- ---
149
-
150
56
  ## Framework Support
151
57
 
152
- | Framework | Types | Services | Actions |
153
- |-----------|-------|----------|---------|
154
- | Astro 4+ | ✅ | ✅ | ✅ |
155
- | Next.js | ✅ | ✅ | 🔜 Soon |
156
- | Nuxt | ✅ | ✅ | 🔜 Soon |
157
- | Other | ✅ | ✅ | ❌ |
158
58
 
159
- ---
160
-
161
- ## Full Documentation
59
+ | Framework | Types | Services | Schemas | Actions |
60
+ | -------------- | ----- | -------- | ------- | ------- |
61
+ | Astro 4+ | ✅ | ✅ | ✅ | ✅ |
62
+ | Next.js | ✅ | ✅ | ✅ | 🔜 |
63
+ | Nuxt | ✅ | ✅ | ✅ | 🔜 |
64
+ | SvelteKit | ✅ | ✅ | ✅ | 🔜 |
65
+ | TanStack Start | ✅ | ✅ | ✅ | 🔜 |
162
66
 
163
- For complete documentation including troubleshooting, advanced configuration, and examples, see the [main README](https://github.com/eleven-estudio/strapi2front#readme).
164
67
 
165
- ## Contributing
68
+ > Types, Services, and Schemas work with any framework. Actions are framework-specific and more are coming soon.
166
69
 
167
- We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
70
+ ## Requirements
168
71
 
169
- ## Security
72
+ - Node.js 18+
73
+ - Strapi v4 or v5
170
74
 
171
- If you believe you have found a security vulnerability, we encourage you to let us know right away.
75
+ ## Contributing
172
76
 
173
- Please report any issues to [hello@elevenestudio.com](mailto:hello@elevenestudio.com).
77
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
174
78
 
175
79
  ## License
176
80
 
177
- MIT - see [LICENSE](../../LICENSE) for details.
178
-
179
- ## Disclaimer
180
-
181
- This is a community project and is not affiliated with, endorsed by, or officially connected to [Strapi](https://strapi.io). The name "Strapi" is used solely to indicate compatibility with the Strapi CMS.
81
+ MIT © [Eleven Estudio](https://elevenestudio.com)
182
82
 
183
83
  ---
184
84
 
185
- <div align="center">
186
- Made with ❤️ by <a href="https://elevenestudio.com">Eleven Estudio</a>
187
- </div>
85
+ Made with ❤️ by [Eleven Estudio](https://elevenestudio.com)