@strapi2front/generators 0.2.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,32 +1,105 @@
1
1
  import { ParsedSchema, StrapiLocale } from '@strapi2front/core';
2
2
 
3
+ /**
4
+ * Shared types for generators
5
+ * Generated by strapi2front
6
+ */
7
+
8
+ /**
9
+ * Supported output formats
10
+ */
11
+ type OutputFormat = 'typescript' | 'jsdoc';
12
+ /**
13
+ * Supported frameworks
14
+ */
15
+ type Framework = 'astro' | 'nextjs' | 'nuxt' | 'generic';
16
+ /**
17
+ * Supported Strapi versions
18
+ */
19
+ type StrapiVersion = 'v4' | 'v5';
20
+ /**
21
+ * Base generator options
22
+ */
23
+ interface BaseGeneratorOptions {
24
+ outputDir: string;
25
+ strapiVersion?: StrapiVersion;
26
+ }
27
+ /**
28
+ * Generator context passed to all generators
29
+ */
30
+ interface GeneratorContext {
31
+ schema: ParsedSchema;
32
+ options: BaseGeneratorOptions;
33
+ outputFormat: OutputFormat;
34
+ strapiVersion: StrapiVersion;
35
+ }
36
+ /**
37
+ * Generator result
38
+ */
39
+ interface GeneratorResult {
40
+ files: string[];
41
+ warnings?: string[];
42
+ }
43
+
44
+ /**
45
+ * Type generator
46
+ * Supports TypeScript (.ts) and JSDoc (.js) output formats
47
+ */
48
+
3
49
  interface TypeGeneratorOptions {
4
50
  outputDir: string;
5
51
  blocksRendererInstalled?: boolean;
6
- strapiVersion?: "v4" | "v5";
52
+ strapiVersion?: StrapiVersion;
53
+ /**
54
+ * Output format: 'typescript' for .ts files, 'jsdoc' for .js with JSDoc annotations
55
+ * @default 'typescript'
56
+ */
57
+ outputFormat?: OutputFormat;
7
58
  }
8
59
  /**
9
- * Generate TypeScript types from parsed schema
60
+ * Generate types from parsed schema
61
+ * Supports both TypeScript and JSDoc output formats
10
62
  */
11
63
  declare function generateTypes(schema: ParsedSchema, options: TypeGeneratorOptions): Promise<string[]>;
12
64
 
65
+ /**
66
+ * Service generator
67
+ * Supports TypeScript (.ts) and JSDoc (.js) output formats
68
+ */
69
+
13
70
  interface ServiceGeneratorOptions {
14
71
  outputDir: string;
15
72
  typesImportPath: string;
16
- strapiVersion?: "v4" | "v5";
73
+ strapiVersion?: StrapiVersion;
74
+ /**
75
+ * Output format: 'typescript' for .ts files, 'jsdoc' for .js with JSDoc annotations
76
+ * @default 'typescript'
77
+ */
78
+ outputFormat?: OutputFormat;
17
79
  }
18
80
  /**
19
81
  * Generate service files from parsed schema
20
82
  */
21
83
  declare function generateServices(schema: ParsedSchema, options: ServiceGeneratorOptions): Promise<string[]>;
22
84
 
85
+ /**
86
+ * Actions generator
87
+ * Re-exports from frameworks/astro for backwards compatibility
88
+ *
89
+ * For framework-specific generators, import directly from:
90
+ * - '@strapi2front/generators/frameworks/astro'
91
+ * - '@strapi2front/generators/frameworks/nextjs' (coming soon)
92
+ * - '@strapi2front/generators/frameworks/nuxt' (coming soon)
93
+ */
94
+
23
95
  interface ActionsGeneratorOptions {
24
96
  outputDir: string;
25
97
  servicesImportPath: string;
26
- strapiVersion?: "v4" | "v5";
98
+ strapiVersion?: StrapiVersion;
27
99
  }
28
100
  /**
29
101
  * Generate Astro Actions from parsed schema
102
+ * @deprecated Use generateAstroActions from '@strapi2front/generators/frameworks/astro' instead
30
103
  */
31
104
  declare function generateActions(schema: ParsedSchema, options: ActionsGeneratorOptions): Promise<string[]>;
32
105
 
@@ -58,6 +131,11 @@ interface ByFeatureGeneratorOptions {
58
131
  blocksRendererInstalled?: boolean;
59
132
  strapiVersion?: "v4" | "v5";
60
133
  apiPrefix?: string;
134
+ /**
135
+ * Output format: 'typescript' for .ts files, 'jsdoc' for .js with JSDoc annotations
136
+ * @default 'typescript'
137
+ */
138
+ outputFormat?: "typescript" | "jsdoc";
61
139
  }
62
140
  /**
63
141
  * Generate all files using 'by-feature' structure
@@ -82,6 +160,152 @@ interface ByFeatureGeneratorOptions {
82
160
  */
83
161
  declare function generateByFeature(schema: ParsedSchema, locales: StrapiLocale[], options: ByFeatureGeneratorOptions): Promise<string[]>;
84
162
 
163
+ /**
164
+ * Astro Actions generator
165
+ * Generates type-safe Astro Actions for Strapi content types
166
+ *
167
+ * Requirements:
168
+ * - Astro v4.0+ (Actions are only available in v4+)
169
+ * - TypeScript enabled
170
+ */
171
+
172
+ interface AstroActionsOptions {
173
+ outputDir: string;
174
+ servicesImportPath: string;
175
+ strapiVersion?: StrapiVersion;
176
+ }
177
+ /**
178
+ * Check if Astro Actions are supported
179
+ * Requires Astro v4.0 or higher
180
+ */
181
+ declare function isAstroActionsSupported(astroVersion: string | null): boolean;
182
+ /**
183
+ * Generate Astro Actions from parsed schema
184
+ */
185
+ declare function generateAstroActions(schema: ParsedSchema, options: AstroActionsOptions): Promise<string[]>;
186
+
187
+ /**
188
+ * Next.js Server Actions generator
189
+ * Generates type-safe Server Actions for Strapi content types
190
+ *
191
+ * Requirements:
192
+ * - Next.js 14+ (Server Actions)
193
+ * - TypeScript enabled
194
+ *
195
+ * Status: COMING SOON
196
+ */
197
+
198
+ interface NextJsActionsOptions {
199
+ outputDir: string;
200
+ servicesImportPath: string;
201
+ strapiVersion?: StrapiVersion;
202
+ }
203
+ /**
204
+ * Generate Next.js Server Actions from parsed schema
205
+ *
206
+ * @throws Error - Not yet implemented
207
+ */
208
+ declare function generateNextJsActions(_schema: ParsedSchema, _options: NextJsActionsOptions): Promise<string[]>;
209
+ /**
210
+ * Check if Next.js Server Actions are supported
211
+ * Requires Next.js 14+ with App Router
212
+ */
213
+ declare function isNextJsActionsSupported(nextVersion: string | null): boolean;
214
+
215
+ /**
216
+ * Nuxt Server Routes generator
217
+ * Generates type-safe server routes for Strapi content types
218
+ *
219
+ * Requirements:
220
+ * - Nuxt 3+
221
+ * - TypeScript enabled
222
+ *
223
+ * Status: COMING SOON
224
+ */
225
+
226
+ interface NuxtServerRoutesOptions {
227
+ outputDir: string;
228
+ servicesImportPath: string;
229
+ strapiVersion?: StrapiVersion;
230
+ }
231
+ /**
232
+ * Generate Nuxt Server Routes from parsed schema
233
+ *
234
+ * @throws Error - Not yet implemented
235
+ */
236
+ declare function generateNuxtServerRoutes(_schema: ParsedSchema, _options: NuxtServerRoutesOptions): Promise<string[]>;
237
+ /**
238
+ * Check if Nuxt Server Routes are supported
239
+ * Requires Nuxt 3+
240
+ */
241
+ declare function isNuxtServerRoutesSupported(nuxtVersion: string | null): boolean;
242
+
243
+ /**
244
+ * Framework-specific generators
245
+ *
246
+ * Each framework has its own approach to server-side data fetching:
247
+ * - Astro: Actions (v4+)
248
+ * - Next.js: Server Actions (v14+) - Coming Soon
249
+ * - Nuxt: Server Routes (v3+) - Coming Soon
250
+ */
251
+
252
+ /**
253
+ * Supported frameworks for action generation
254
+ */
255
+ type SupportedFramework = 'astro' | 'nextjs' | 'nuxt';
256
+ /**
257
+ * Framework support status
258
+ */
259
+ declare const frameworkSupport: Record<SupportedFramework, {
260
+ status: 'stable' | 'coming-soon';
261
+ minVersion: string;
262
+ }>;
263
+
264
+ /**
265
+ * TypeScript type generator
266
+ * Generates .ts files with interfaces
267
+ */
268
+
269
+ interface TypeScriptTypesOptions {
270
+ outputDir: string;
271
+ blocksRendererInstalled?: boolean;
272
+ strapiVersion?: StrapiVersion;
273
+ }
274
+ /**
275
+ * Generate TypeScript types from parsed schema
276
+ */
277
+ declare function generateTypeScriptTypes(schema: ParsedSchema, options: TypeScriptTypesOptions): Promise<string[]>;
278
+
279
+ /**
280
+ * JSDoc type generator
281
+ * Generates .js files with JSDoc annotations for type safety without TypeScript
282
+ */
283
+
284
+ interface JSDocTypesOptions {
285
+ outputDir: string;
286
+ blocksRendererInstalled?: boolean;
287
+ strapiVersion?: StrapiVersion;
288
+ }
289
+ /**
290
+ * Generate JSDoc types from parsed schema
291
+ */
292
+ declare function generateJSDocTypes(schema: ParsedSchema, options: JSDocTypesOptions): Promise<string[]>;
293
+
294
+ /**
295
+ * JSDoc service generator
296
+ * Generates .js files with JSDoc annotations for services
297
+ */
298
+
299
+ interface JSDocServicesOptions {
300
+ outputDir: string;
301
+ typesImportPath: string;
302
+ strapiVersion?: StrapiVersion;
303
+ }
304
+ /**
305
+ * Generate JSDoc service files from parsed schema
306
+ */
307
+ declare function generateJSDocServices(schema: ParsedSchema, options: JSDocServicesOptions): Promise<string[]>;
308
+
85
309
  /**
86
310
  * Format TypeScript code using Prettier
87
311
  */
@@ -133,4 +357,4 @@ declare function toKebabCase(str: string): string;
133
357
  */
134
358
  declare function pluralize(word: string): string;
135
359
 
136
- export { type ActionsGeneratorOptions, type ByFeatureGeneratorOptions, type ClientGeneratorOptions, type LocalesGeneratorOptions, type ServiceGeneratorOptions, type TypeGeneratorOptions, deleteFile, ensureDir, fileExists, formatCode, formatJson, generateActions, generateByFeature, generateClient, generateLocales, generateServices, generateTypes, listFiles, pluralize, readFile, toCamelCase, toKebabCase, toPascalCase, writeFile };
360
+ export { type ActionsGeneratorOptions, type AstroActionsOptions, type BaseGeneratorOptions, type ByFeatureGeneratorOptions, type ClientGeneratorOptions, type Framework, type GeneratorContext, type GeneratorResult, type JSDocServicesOptions, type JSDocTypesOptions, type LocalesGeneratorOptions, type NextJsActionsOptions, type NuxtServerRoutesOptions, type OutputFormat, type ServiceGeneratorOptions, type StrapiVersion, type SupportedFramework, type TypeGeneratorOptions, type TypeScriptTypesOptions, deleteFile, ensureDir, fileExists, formatCode, formatJson, frameworkSupport, generateActions, generateAstroActions, generateByFeature, generateClient, generateJSDocServices, generateJSDocTypes, generateLocales, generateNextJsActions, generateNuxtServerRoutes, generateServices, generateTypeScriptTypes, generateTypes, isAstroActionsSupported, isNextJsActionsSupported, isNuxtServerRoutesSupported, listFiles, pluralize, readFile, toCamelCase, toKebabCase, toPascalCase, writeFile };