@rexeus/typeweaver-gen 0.5.0 → 0.6.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.cts CHANGED
@@ -1,56 +1,58 @@
1
- import { IHttpOperationDefinition, IHttpResponseDefinition } from '@rexeus/typeweaver-core';
1
+ import { IHttpOperationDefinition, IHttpResponseDefinition } from "@rexeus/typeweaver-core";
2
2
 
3
+ //#region src/Resource.d.ts
3
4
  type GetResourcesResult = {
4
- entityResources: EntityResources;
5
- sharedResponseResources: SharedResponseResource[];
5
+ entityResources: EntityResources;
6
+ sharedResponseResources: SharedResponseResource[];
6
7
  };
7
8
  type ExtendedResponseDefinition = IHttpResponseDefinition & {
8
- statusCodeName: string;
9
- isReference: boolean;
9
+ statusCodeName: string;
10
+ isReference: boolean;
10
11
  };
11
12
  type EntityName = string;
12
13
  type OperationResource = {
13
- sourceDir: string;
14
- sourceFile: string;
15
- sourceFileName: string;
16
- definition: Omit<IHttpOperationDefinition, "responses"> & {
17
- responses: ExtendedResponseDefinition[];
18
- };
19
- outputDir: string;
20
- entityName: EntityName;
21
- outputRequestFile: string;
22
- outputRequestFileName: string;
23
- outputResponseFile: string;
24
- outputResponseFileName: string;
25
- outputRequestValidationFile: string;
26
- outputRequestValidationFileName: string;
27
- outputResponseValidationFile: string;
28
- outputResponseValidationFileName: string;
29
- outputClientFile: string;
30
- outputClientFileName: string;
14
+ sourceDir: string;
15
+ sourceFile: string;
16
+ sourceFileName: string;
17
+ definition: Omit<IHttpOperationDefinition, "responses"> & {
18
+ responses: ExtendedResponseDefinition[];
19
+ };
20
+ outputDir: string;
21
+ entityName: EntityName;
22
+ outputRequestFile: string;
23
+ outputRequestFileName: string;
24
+ outputResponseFile: string;
25
+ outputResponseFileName: string;
26
+ outputRequestValidationFile: string;
27
+ outputRequestValidationFileName: string;
28
+ outputResponseValidationFile: string;
29
+ outputResponseValidationFileName: string;
30
+ outputClientFile: string;
31
+ outputClientFileName: string;
31
32
  };
32
33
  type EntityResources = Record<EntityName, {
33
- operations: OperationResource[];
34
- responses: EntityResponseResource[];
34
+ operations: OperationResource[];
35
+ responses: EntityResponseResource[];
35
36
  }>;
36
37
  type SharedResponseResource = IHttpResponseDefinition & {
37
- sourceDir: string;
38
- sourceFile: string;
39
- sourceFileName: string;
40
- outputFile: string;
41
- outputFileName: string;
42
- outputDir: string;
38
+ sourceDir: string;
39
+ sourceFile: string;
40
+ sourceFileName: string;
41
+ outputFile: string;
42
+ outputFileName: string;
43
+ outputDir: string;
43
44
  };
44
45
  type EntityResponseResource = IHttpResponseDefinition & {
45
- sourceDir: string;
46
- sourceFile: string;
47
- sourceFileName: string;
48
- outputFile: string;
49
- outputFileName: string;
50
- outputDir: string;
51
- entityName: EntityName;
46
+ sourceDir: string;
47
+ sourceFile: string;
48
+ sourceFileName: string;
49
+ outputFile: string;
50
+ outputFileName: string;
51
+ outputDir: string;
52
+ entityName: EntityName;
52
53
  };
53
-
54
+ //#endregion
55
+ //#region src/plugins/types.d.ts
54
56
  /**
55
57
  * Configuration for a typeweaver plugin
56
58
  */
@@ -59,52 +61,52 @@ type PluginConfig = Record<string, unknown>;
59
61
  * Context provided to plugins during initialization and finalization
60
62
  */
61
63
  type PluginContext = {
62
- outputDir: string;
63
- inputDir: string;
64
- config: PluginConfig;
64
+ outputDir: string;
65
+ inputDir: string;
66
+ config: PluginConfig;
65
67
  };
66
68
  /**
67
69
  * Context provided to plugins during generation
68
70
  */
69
71
  type GeneratorContext = PluginContext & {
70
- resources: GetResourcesResult;
71
- templateDir: string;
72
- coreDir: string;
73
- writeFile: (relativePath: string, content: string) => void;
74
- renderTemplate: (templatePath: string, data: unknown) => string;
75
- addGeneratedFile: (relativePath: string) => void;
76
- getGeneratedFiles: () => string[];
72
+ resources: GetResourcesResult;
73
+ templateDir: string;
74
+ coreDir: string;
75
+ writeFile: (relativePath: string, content: string) => void;
76
+ renderTemplate: (templatePath: string, data: unknown) => string;
77
+ addGeneratedFile: (relativePath: string) => void;
78
+ getGeneratedFiles: () => string[];
77
79
  };
78
80
  /**
79
81
  * Plugin metadata
80
82
  */
81
83
  type PluginMetadata = {
82
- name: string;
84
+ name: string;
83
85
  };
84
86
  /**
85
87
  * typeweaver plugin interface
86
88
  */
87
89
  type TypeweaverPlugin = PluginMetadata & {
88
- /**
89
- * Initialize the plugin
90
- * Called before any generation happens
91
- */
92
- initialize?(context: PluginContext): Promise<void> | void;
93
- /**
94
- * Collect and transform resources
95
- * Allows plugins to modify the resource collection
96
- */
97
- collectResources?(resources: GetResourcesResult): Promise<GetResourcesResult> | GetResourcesResult;
98
- /**
99
- * Main generation logic
100
- * Called with all resources and utilities
101
- */
102
- generate?(context: GeneratorContext): Promise<void> | void;
103
- /**
104
- * Finalize the plugin
105
- * Called after all generation is complete
106
- */
107
- finalize?(context: PluginContext): Promise<void> | void;
90
+ /**
91
+ * Initialize the plugin
92
+ * Called before any generation happens
93
+ */
94
+ initialize?(context: PluginContext): Promise<void> | void;
95
+ /**
96
+ * Collect and transform resources
97
+ * Allows plugins to modify the resource collection
98
+ */
99
+ collectResources?(resources: GetResourcesResult): Promise<GetResourcesResult> | GetResourcesResult;
100
+ /**
101
+ * Main generation logic
102
+ * Called with all resources and utilities
103
+ */
104
+ generate?(context: GeneratorContext): Promise<void> | void;
105
+ /**
106
+ * Finalize the plugin
107
+ * Called after all generation is complete
108
+ */
109
+ finalize?(context: PluginContext): Promise<void> | void;
108
110
  };
109
111
  /**
110
112
  * Plugin constructor type
@@ -114,163 +116,169 @@ type PluginConstructor = new (config?: PluginConfig) => TypeweaverPlugin;
114
116
  * Plugin module export
115
117
  */
116
118
  type PluginModule = {
117
- default: PluginConstructor;
119
+ default: PluginConstructor;
118
120
  };
119
121
  /**
120
122
  * Plugin registration entry
121
123
  */
122
124
  type PluginRegistration = {
123
- name: string;
124
- plugin: TypeweaverPlugin;
125
- config?: PluginConfig;
125
+ name: string;
126
+ plugin: TypeweaverPlugin;
127
+ config?: PluginConfig;
126
128
  };
127
129
  /**
128
130
  * typeweaver configuration
129
131
  */
130
132
  type TypeweaverConfig = {
131
- input: string;
132
- output: string;
133
- shared?: string;
134
- plugins?: (string | [string, PluginConfig])[];
135
- prettier?: boolean;
136
- clean?: boolean;
133
+ input: string;
134
+ output: string;
135
+ shared?: string;
136
+ plugins?: (string | [string, PluginConfig])[];
137
+ format?: boolean;
138
+ clean?: boolean;
137
139
  };
138
140
  /**
139
141
  * Plugin loading error
140
142
  */
141
143
  declare class PluginLoadError extends Error {
142
- pluginName: string;
143
- constructor(pluginName: string, message: string);
144
+ pluginName: string;
145
+ constructor(pluginName: string, message: string);
144
146
  }
145
147
  /**
146
148
  * Plugin dependency error
147
149
  */
148
150
  declare class PluginDependencyError extends Error {
149
- pluginName: string;
150
- missingDependency: string;
151
- constructor(pluginName: string, missingDependency: string);
151
+ pluginName: string;
152
+ missingDependency: string;
153
+ constructor(pluginName: string, missingDependency: string);
152
154
  }
153
-
155
+ //#endregion
156
+ //#region src/plugins/BasePlugin.d.ts
154
157
  /**
155
158
  * Base class for typeweaver plugins
156
159
  * Provides default implementations and common utilities
157
160
  */
158
161
  declare abstract class BasePlugin implements TypeweaverPlugin {
159
- abstract name: string;
160
- description?: string;
161
- author?: string;
162
- depends?: string[];
163
- protected config: PluginConfig;
164
- constructor(config?: PluginConfig);
165
- /**
166
- * Default implementation - override in subclasses if needed
167
- */
168
- initialize(context: PluginContext): Promise<void>;
169
- /**
170
- * Default implementation - override in subclasses if needed
171
- */
172
- collectResources(resources: GetResourcesResult): GetResourcesResult;
173
- /**
174
- * Main generation logic - must be implemented by subclasses
175
- */
176
- abstract generate(context: GeneratorContext): Promise<void> | void;
177
- /**
178
- * Default implementation - override in subclasses if needed
179
- */
180
- finalize(context: PluginContext): Promise<void>;
181
- /**
182
- * Copy lib files from plugin package to generated lib folder
183
- */
184
- protected copyLibFiles(context: GeneratorContext, libSourceDir: string, libNamespace: string): void;
162
+ abstract name: string;
163
+ description?: string;
164
+ author?: string;
165
+ depends?: string[];
166
+ protected config: PluginConfig;
167
+ constructor(config?: PluginConfig);
168
+ /**
169
+ * Default implementation - override in subclasses if needed
170
+ */
171
+ initialize(_context: PluginContext): Promise<void>;
172
+ /**
173
+ * Default implementation - override in subclasses if needed
174
+ */
175
+ collectResources(resources: GetResourcesResult): GetResourcesResult;
176
+ /**
177
+ * Main generation logic - must be implemented by subclasses
178
+ */
179
+ abstract generate(context: GeneratorContext): Promise<void> | void;
180
+ /**
181
+ * Default implementation - override in subclasses if needed
182
+ */
183
+ finalize(_context: PluginContext): Promise<void>;
184
+ /**
185
+ * Copy lib files from plugin package to generated lib folder
186
+ */
187
+ protected copyLibFiles(context: GeneratorContext, libSourceDir: string, libNamespace: string): void;
185
188
  }
186
-
189
+ //#endregion
190
+ //#region src/plugins/BaseTemplatePlugin.d.ts
187
191
  /**
188
192
  * Base class for template-based generator plugins
189
193
  * Provides utilities for working with EJS templates
190
194
  */
191
195
  declare abstract class BaseTemplatePlugin extends BasePlugin {
192
- /**
193
- * Render an EJS template with the given data
194
- */
195
- protected renderTemplate(templatePath: string, data: unknown): string;
196
- /**
197
- * Write a file relative to the output directory
198
- */
199
- protected writeFile(context: GeneratorContext, relativePath: string, content: string): void;
200
- /**
201
- * Ensure a directory exists
202
- */
203
- protected ensureDir(context: GeneratorContext, relativePath: string): void;
204
- /**
205
- * Get the template path for this plugin
206
- */
207
- protected getTemplatePath(context: GeneratorContext, templateName: string): string;
196
+ /**
197
+ * Render an EJS template with the given data
198
+ */
199
+ protected renderTemplate(templatePath: string, data: unknown): string;
200
+ /**
201
+ * Write a file relative to the output directory
202
+ */
203
+ protected writeFile(context: GeneratorContext, relativePath: string, content: string): void;
204
+ /**
205
+ * Ensure a directory exists
206
+ */
207
+ protected ensureDir(context: GeneratorContext, relativePath: string): void;
208
+ /**
209
+ * Get the template path for this plugin
210
+ */
211
+ protected getTemplatePath(context: GeneratorContext, templateName: string): string;
208
212
  }
209
-
213
+ //#endregion
214
+ //#region src/plugins/PluginRegistry.d.ts
210
215
  /**
211
216
  * Registry for managing typeweaver plugins
212
217
  */
213
218
  declare class PluginRegistry {
214
- private plugins;
215
- constructor();
216
- /**
217
- * Register a plugin
218
- */
219
- register(plugin: TypeweaverPlugin, config?: unknown): void;
220
- /**
221
- * Get a registered plugin
222
- */
223
- get(name: string): PluginRegistration | undefined;
224
- /**
225
- * Get all registered plugins
226
- */
227
- getAll(): PluginRegistration[];
228
- /**
229
- * Check if a plugin is registered
230
- */
231
- has(name: string): boolean;
232
- /**
233
- * Clear all registered plugins (except required ones)
234
- */
235
- clear(): void;
219
+ private plugins;
220
+ constructor();
221
+ /**
222
+ * Register a plugin
223
+ */
224
+ register(plugin: TypeweaverPlugin, config?: unknown): void;
225
+ /**
226
+ * Get a registered plugin
227
+ */
228
+ get(name: string): PluginRegistration | undefined;
229
+ /**
230
+ * Get all registered plugins
231
+ */
232
+ getAll(): PluginRegistration[];
233
+ /**
234
+ * Check if a plugin is registered
235
+ */
236
+ has(name: string): boolean;
237
+ /**
238
+ * Clear all registered plugins (except required ones)
239
+ */
240
+ clear(): void;
236
241
  }
237
-
242
+ //#endregion
243
+ //#region src/plugins/PluginContext.d.ts
238
244
  /**
239
245
  * Builder for plugin contexts
240
246
  */
241
247
  declare class PluginContextBuilder {
242
- private generatedFiles;
243
- /**
244
- * Create a basic plugin context
245
- */
246
- createPluginContext(params: {
247
- outputDir: string;
248
- inputDir: string;
249
- config: PluginConfig;
250
- }): PluginContext;
251
- /**
252
- * Create a generator context with utilities
253
- */
254
- createGeneratorContext(params: {
255
- outputDir: string;
256
- inputDir: string;
257
- config: PluginConfig;
258
- resources: GetResourcesResult;
259
- templateDir: string;
260
- coreDir: string;
261
- }): GeneratorContext;
262
- /**
263
- * Get all generated files
264
- */
265
- getGeneratedFiles(): string[];
266
- /**
267
- * Clear generated files tracking
268
- */
269
- clearGeneratedFiles(): void;
248
+ private generatedFiles;
249
+ /**
250
+ * Create a basic plugin context
251
+ */
252
+ createPluginContext(params: {
253
+ outputDir: string;
254
+ inputDir: string;
255
+ config: PluginConfig;
256
+ }): PluginContext;
257
+ /**
258
+ * Create a generator context with utilities
259
+ */
260
+ createGeneratorContext(params: {
261
+ outputDir: string;
262
+ inputDir: string;
263
+ config: PluginConfig;
264
+ resources: GetResourcesResult;
265
+ templateDir: string;
266
+ coreDir: string;
267
+ }): GeneratorContext;
268
+ /**
269
+ * Get all generated files
270
+ */
271
+ getGeneratedFiles(): string[];
272
+ /**
273
+ * Clear generated files tracking
274
+ */
275
+ clearGeneratedFiles(): void;
270
276
  }
271
-
277
+ //#endregion
278
+ //#region src/helpers/Path.d.ts
272
279
  declare class Path {
273
- static relative(from: string, to: string): string;
280
+ static relative(from: string, to: string): string;
274
281
  }
275
-
276
- export { BasePlugin, BaseTemplatePlugin, type EntityName, type EntityResources, type EntityResponseResource, type ExtendedResponseDefinition, type GeneratorContext, type GetResourcesResult, type OperationResource, Path, type PluginConfig, type PluginConstructor, type PluginContext, PluginContextBuilder, PluginDependencyError, PluginLoadError, type PluginMetadata, type PluginModule, type PluginRegistration, PluginRegistry, type SharedResponseResource, type TypeweaverConfig, type TypeweaverPlugin };
282
+ //#endregion
283
+ export { BasePlugin, BaseTemplatePlugin, EntityName, EntityResources, EntityResponseResource, ExtendedResponseDefinition, GeneratorContext, GetResourcesResult, OperationResource, Path, PluginConfig, PluginConstructor, PluginContext, PluginContextBuilder, PluginDependencyError, PluginLoadError, PluginMetadata, PluginModule, PluginRegistration, PluginRegistry, SharedResponseResource, TypeweaverConfig, TypeweaverPlugin };
284
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/Resource.ts","../src/plugins/types.ts","../src/plugins/BasePlugin.ts","../src/plugins/BaseTemplatePlugin.ts","../src/plugins/PluginRegistry.ts","../src/plugins/PluginContext.ts","../src/helpers/Path.ts"],"mappings":";;;KAKY,kBAAA;EACV,eAAA,EAAiB,eAAA;E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