@rexeus/typeweaver-gen 0.0.2 → 0.0.4
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 +107 -224
- package/dist/LICENSE +202 -0
- package/dist/NOTICE +4 -0
- package/dist/index.d.ts +41 -27
- package/dist/index.js +4 -715
- package/package.json +13 -7
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type GetResourcesResult = {
|
|
|
6
6
|
};
|
|
7
7
|
type ExtendedResponseDefinition = IHttpResponseDefinition & {
|
|
8
8
|
statusCodeName: string;
|
|
9
|
+
isReference: boolean;
|
|
9
10
|
};
|
|
10
11
|
type EntityName = string;
|
|
11
12
|
type OperationResource = {
|
|
@@ -28,9 +29,11 @@ type OperationResource = {
|
|
|
28
29
|
outputClientFile: string;
|
|
29
30
|
outputClientFileName: string;
|
|
30
31
|
};
|
|
31
|
-
type EntityResources = Record<EntityName,
|
|
32
|
+
type EntityResources = Record<EntityName, {
|
|
33
|
+
operations: OperationResource[];
|
|
34
|
+
responses: EntityResponseResource[];
|
|
35
|
+
}>;
|
|
32
36
|
type SharedResponseResource = IHttpResponseDefinition & {
|
|
33
|
-
isShared: true;
|
|
34
37
|
sourceDir: string;
|
|
35
38
|
sourceFile: string;
|
|
36
39
|
sourceFileName: string;
|
|
@@ -38,23 +41,32 @@ type SharedResponseResource = IHttpResponseDefinition & {
|
|
|
38
41
|
outputFileName: string;
|
|
39
42
|
outputDir: string;
|
|
40
43
|
};
|
|
44
|
+
type EntityResponseResource = IHttpResponseDefinition & {
|
|
45
|
+
sourceDir: string;
|
|
46
|
+
sourceFile: string;
|
|
47
|
+
sourceFileName: string;
|
|
48
|
+
outputFile: string;
|
|
49
|
+
outputFileName: string;
|
|
50
|
+
outputDir: string;
|
|
51
|
+
entityName: EntityName;
|
|
52
|
+
};
|
|
41
53
|
|
|
42
54
|
/**
|
|
43
|
-
* Configuration for a
|
|
55
|
+
* Configuration for a typeweaver plugin
|
|
44
56
|
*/
|
|
45
57
|
type PluginConfig = Record<string, unknown>;
|
|
46
58
|
/**
|
|
47
59
|
* Context provided to plugins during initialization and finalization
|
|
48
60
|
*/
|
|
49
|
-
|
|
61
|
+
type PluginContext = {
|
|
50
62
|
outputDir: string;
|
|
51
63
|
inputDir: string;
|
|
52
64
|
config: PluginConfig;
|
|
53
|
-
}
|
|
65
|
+
};
|
|
54
66
|
/**
|
|
55
67
|
* Context provided to plugins during generation
|
|
56
68
|
*/
|
|
57
|
-
|
|
69
|
+
type GeneratorContext = PluginContext & {
|
|
58
70
|
resources: GetResourcesResult;
|
|
59
71
|
templateDir: string;
|
|
60
72
|
coreDir: string;
|
|
@@ -62,17 +74,17 @@ interface GeneratorContext extends PluginContext {
|
|
|
62
74
|
renderTemplate: (templatePath: string, data: unknown) => string;
|
|
63
75
|
addGeneratedFile: (relativePath: string) => void;
|
|
64
76
|
getGeneratedFiles: () => string[];
|
|
65
|
-
}
|
|
77
|
+
};
|
|
66
78
|
/**
|
|
67
79
|
* Plugin metadata
|
|
68
80
|
*/
|
|
69
|
-
|
|
81
|
+
type PluginMetadata = {
|
|
70
82
|
name: string;
|
|
71
|
-
}
|
|
83
|
+
};
|
|
72
84
|
/**
|
|
73
|
-
*
|
|
85
|
+
* typeweaver plugin interface
|
|
74
86
|
*/
|
|
75
|
-
|
|
87
|
+
type TypeweaverPlugin = PluginMetadata & {
|
|
76
88
|
/**
|
|
77
89
|
* Initialize the plugin
|
|
78
90
|
* Called before any generation happens
|
|
@@ -93,35 +105,36 @@ interface TypeWeaverPlugin extends PluginMetadata {
|
|
|
93
105
|
* Called after all generation is complete
|
|
94
106
|
*/
|
|
95
107
|
finalize?(context: PluginContext): Promise<void> | void;
|
|
96
|
-
}
|
|
108
|
+
};
|
|
97
109
|
/**
|
|
98
110
|
* Plugin constructor type
|
|
99
111
|
*/
|
|
100
|
-
type PluginConstructor = new (config?: PluginConfig) =>
|
|
112
|
+
type PluginConstructor = new (config?: PluginConfig) => TypeweaverPlugin;
|
|
101
113
|
/**
|
|
102
114
|
* Plugin module export
|
|
103
115
|
*/
|
|
104
|
-
|
|
116
|
+
type PluginModule = {
|
|
105
117
|
default: PluginConstructor;
|
|
106
|
-
}
|
|
118
|
+
};
|
|
107
119
|
/**
|
|
108
120
|
* Plugin registration entry
|
|
109
121
|
*/
|
|
110
|
-
|
|
122
|
+
type PluginRegistration = {
|
|
111
123
|
name: string;
|
|
112
|
-
plugin:
|
|
124
|
+
plugin: TypeweaverPlugin;
|
|
113
125
|
config?: PluginConfig;
|
|
114
|
-
}
|
|
126
|
+
};
|
|
115
127
|
/**
|
|
116
|
-
*
|
|
128
|
+
* typeweaver configuration
|
|
117
129
|
*/
|
|
118
|
-
|
|
130
|
+
type TypeweaverConfig = {
|
|
119
131
|
input: string;
|
|
120
132
|
output: string;
|
|
121
|
-
|
|
133
|
+
shared?: string;
|
|
134
|
+
plugins?: (string | [string, PluginConfig])[];
|
|
122
135
|
prettier?: boolean;
|
|
123
136
|
clean?: boolean;
|
|
124
|
-
}
|
|
137
|
+
};
|
|
125
138
|
/**
|
|
126
139
|
* Plugin loading error
|
|
127
140
|
*/
|
|
@@ -139,10 +152,10 @@ declare class PluginDependencyError extends Error {
|
|
|
139
152
|
}
|
|
140
153
|
|
|
141
154
|
/**
|
|
142
|
-
* Base class for
|
|
155
|
+
* Base class for typeweaver plugins
|
|
143
156
|
* Provides default implementations and common utilities
|
|
144
157
|
*/
|
|
145
|
-
declare abstract class BasePlugin implements
|
|
158
|
+
declare abstract class BasePlugin implements TypeweaverPlugin {
|
|
146
159
|
abstract name: string;
|
|
147
160
|
description?: string;
|
|
148
161
|
author?: string;
|
|
@@ -195,7 +208,7 @@ declare abstract class BaseTemplatePlugin extends BasePlugin {
|
|
|
195
208
|
}
|
|
196
209
|
|
|
197
210
|
/**
|
|
198
|
-
* Registry for managing
|
|
211
|
+
* Registry for managing typeweaver plugins
|
|
199
212
|
*/
|
|
200
213
|
declare class PluginRegistry {
|
|
201
214
|
private plugins;
|
|
@@ -203,7 +216,7 @@ declare class PluginRegistry {
|
|
|
203
216
|
/**
|
|
204
217
|
* Register a plugin
|
|
205
218
|
*/
|
|
206
|
-
register(plugin:
|
|
219
|
+
register(plugin: TypeweaverPlugin, config?: unknown): void;
|
|
207
220
|
/**
|
|
208
221
|
* Get a registered plugin
|
|
209
222
|
*/
|
|
@@ -260,4 +273,5 @@ declare class Path {
|
|
|
260
273
|
static relative(from: string, to: string): string;
|
|
261
274
|
}
|
|
262
275
|
|
|
263
|
-
export { BasePlugin, BaseTemplatePlugin,
|
|
276
|
+
export { BasePlugin, BaseTemplatePlugin, Path, PluginContextBuilder, PluginDependencyError, PluginLoadError, PluginRegistry };
|
|
277
|
+
export type { EntityName, EntityResources, EntityResponseResource, ExtendedResponseDefinition, GeneratorContext, GetResourcesResult, OperationResource, PluginConfig, PluginConstructor, PluginContext, PluginMetadata, PluginModule, PluginRegistration, SharedResponseResource, TypeweaverConfig, TypeweaverPlugin };
|