@strapi2front/generators 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eleven Estudio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,134 @@
1
+ import { ParsedSchema, StrapiLocale } from '@strapi2front/core';
2
+
3
+ interface TypeGeneratorOptions {
4
+ outputDir: string;
5
+ blocksRendererInstalled?: boolean;
6
+ strapiVersion?: "v4" | "v5";
7
+ }
8
+ /**
9
+ * Generate TypeScript types from parsed schema
10
+ */
11
+ declare function generateTypes(schema: ParsedSchema, options: TypeGeneratorOptions): Promise<string[]>;
12
+
13
+ interface ServiceGeneratorOptions {
14
+ outputDir: string;
15
+ typesImportPath: string;
16
+ strapiVersion?: "v4" | "v5";
17
+ }
18
+ /**
19
+ * Generate service files from parsed schema
20
+ */
21
+ declare function generateServices(schema: ParsedSchema, options: ServiceGeneratorOptions): Promise<string[]>;
22
+
23
+ interface ActionsGeneratorOptions {
24
+ outputDir: string;
25
+ servicesImportPath: string;
26
+ strapiVersion?: "v4" | "v5";
27
+ }
28
+ /**
29
+ * Generate Astro Actions from parsed schema
30
+ */
31
+ declare function generateActions(schema: ParsedSchema, options: ActionsGeneratorOptions): Promise<string[]>;
32
+
33
+ interface ClientGeneratorOptions {
34
+ outputDir: string;
35
+ strapiVersion?: "v4" | "v5";
36
+ }
37
+ /**
38
+ * Generate the Strapi client file
39
+ */
40
+ declare function generateClient(options: ClientGeneratorOptions): Promise<string[]>;
41
+
42
+ interface LocalesGeneratorOptions {
43
+ outputDir: string;
44
+ }
45
+ /**
46
+ * Generate locales file from Strapi i18n configuration
47
+ */
48
+ declare function generateLocales(locales: StrapiLocale[], options: LocalesGeneratorOptions): Promise<string[]>;
49
+
50
+ interface ByFeatureGeneratorOptions {
51
+ outputDir: string;
52
+ features: {
53
+ types: boolean;
54
+ services: boolean;
55
+ actions: boolean;
56
+ };
57
+ blocksRendererInstalled?: boolean;
58
+ strapiVersion?: "v4" | "v5";
59
+ }
60
+ /**
61
+ * Generate all files using 'by-feature' structure
62
+ *
63
+ * Output structure:
64
+ * strapi/
65
+ * collections/
66
+ * article/
67
+ * types.ts
68
+ * service.ts
69
+ * actions.ts
70
+ * singles/
71
+ * homepage/
72
+ * types.ts
73
+ * service.ts
74
+ * components/
75
+ * seo.ts
76
+ * shared/
77
+ * utils.ts
78
+ * client.ts
79
+ * locales.ts
80
+ */
81
+ declare function generateByFeature(schema: ParsedSchema, locales: StrapiLocale[], options: ByFeatureGeneratorOptions): Promise<string[]>;
82
+
83
+ /**
84
+ * Format TypeScript code using Prettier
85
+ */
86
+ declare function formatCode(code: string): Promise<string>;
87
+ /**
88
+ * Format JSON code using Prettier
89
+ */
90
+ declare function formatJson(code: string): Promise<string>;
91
+
92
+ /**
93
+ * Ensure a directory exists, creating it if necessary
94
+ */
95
+ declare function ensureDir(dirPath: string): Promise<void>;
96
+ /**
97
+ * Write content to a file, creating parent directories if needed
98
+ */
99
+ declare function writeFile(filePath: string, content: string): Promise<void>;
100
+ /**
101
+ * Read a file's content
102
+ */
103
+ declare function readFile(filePath: string): Promise<string>;
104
+ /**
105
+ * Check if a file exists
106
+ */
107
+ declare function fileExists(filePath: string): Promise<boolean>;
108
+ /**
109
+ * Delete a file if it exists
110
+ */
111
+ declare function deleteFile(filePath: string): Promise<void>;
112
+ /**
113
+ * List files in a directory matching a pattern
114
+ */
115
+ declare function listFiles(dirPath: string, extension?: string): Promise<string[]>;
116
+
117
+ /**
118
+ * Convert string to PascalCase
119
+ */
120
+ declare function toPascalCase(str: string): string;
121
+ /**
122
+ * Convert string to camelCase
123
+ */
124
+ declare function toCamelCase(str: string): string;
125
+ /**
126
+ * Convert string to kebab-case
127
+ */
128
+ declare function toKebabCase(str: string): string;
129
+ /**
130
+ * Pluralize a word (simple version)
131
+ */
132
+ declare function pluralize(word: string): string;
133
+
134
+ 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 };