@powerhousedao/codegen 4.1.0-dev.2 → 4.1.0-dev.21
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/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts +14 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts.map +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js +12 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js.map +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/resolvers.esm.t +17 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/schema.esm.t +16 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +4 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/actions.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t +6 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +4 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +13 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +59 -50
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +10 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +292 -131
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +20 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderTree.esm.t +43 -25
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +37 -42
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +2 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +1 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.esm.t +0 -32
- package/dist/src/codegen/graphql.d.ts +5 -1
- package/dist/src/codegen/graphql.d.ts.map +1 -1
- package/dist/src/codegen/graphql.js +28 -5
- package/dist/src/codegen/graphql.js.map +1 -1
- package/dist/src/codegen/hygen.d.ts +6 -3
- package/dist/src/codegen/hygen.d.ts.map +1 -1
- package/dist/src/codegen/hygen.js +37 -5
- package/dist/src/codegen/hygen.js.map +1 -1
- package/dist/src/codegen/index.d.ts +6 -5
- package/dist/src/codegen/index.d.ts.map +1 -1
- package/dist/src/codegen/index.js +80 -3
- package/dist/src/codegen/index.js.map +1 -1
- package/dist/src/ts-morph-generator/core/FileGenerator.d.ts +10 -0
- package/dist/src/ts-morph-generator/core/FileGenerator.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/core/FileGenerator.js +9 -0
- package/dist/src/ts-morph-generator/core/FileGenerator.js.map +1 -0
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts +30 -0
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/core/GenerationContext.js +2 -0
- package/dist/src/ts-morph-generator/core/GenerationContext.js.map +1 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts +19 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js +114 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js.map +1 -0
- package/dist/src/ts-morph-generator/core/index.d.ts +4 -0
- package/dist/src/ts-morph-generator/core/index.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/core/index.js +4 -0
- package/dist/src/ts-morph-generator/core/index.js.map +1 -0
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts +12 -0
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js +140 -0
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js.map +1 -0
- package/dist/src/ts-morph-generator/file-generators/index.d.ts +2 -0
- package/dist/src/ts-morph-generator/file-generators/index.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/file-generators/index.js +2 -0
- package/dist/src/ts-morph-generator/file-generators/index.js.map +1 -0
- package/dist/src/ts-morph-generator/index.d.ts +4 -0
- package/dist/src/ts-morph-generator/index.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/index.js +4 -0
- package/dist/src/ts-morph-generator/index.js.map +1 -0
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts +13 -0
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.js +45 -0
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.js.map +1 -0
- package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts +14 -0
- package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/utilities/ImportManager.js +40 -0
- package/dist/src/ts-morph-generator/utilities/ImportManager.js.map +1 -0
- package/dist/src/ts-morph-generator/utilities/index.d.ts +3 -0
- package/dist/src/ts-morph-generator/utilities/index.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/utilities/index.js +3 -0
- package/dist/src/ts-morph-generator/utilities/index.js.map +1 -0
- package/dist/tsconfig.hygen.tsbuildinfo +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customReducers.esm.t +0 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FileItemsGrid.esm.t +0 -44
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderItemsGrid.esm.t +0 -96
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useSelectedFolderChildren.esm.t +0 -35
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useTransformedNodes.esm.t +0 -35
|
@@ -92,7 +92,11 @@ export async function generate(config) {
|
|
|
92
92
|
* @returns A promise that resolves when code generation is complete
|
|
93
93
|
*/
|
|
94
94
|
async function generateFromDocumentModel(documentModel, config, filePath, options = {}) {
|
|
95
|
-
|
|
95
|
+
// Derive verbose from config.logLevel if not explicitly provided
|
|
96
|
+
// Show hygen logs for verbose, debug, and info levels (default behavior before ts-morph)
|
|
97
|
+
const { verbose = config.logLevel === "verbose" ||
|
|
98
|
+
config.logLevel === "debug" ||
|
|
99
|
+
config.logLevel === "info", force = false, } = options;
|
|
96
100
|
const name = paramCase(documentModel.name);
|
|
97
101
|
// create document model folder and spec as json
|
|
98
102
|
fs.mkdirSync(join(config.documentModelsDir, name), { recursive: true });
|
|
@@ -112,6 +116,7 @@ async function generateFromDocumentModel(documentModel, config, filePath, option
|
|
|
112
116
|
await generateDocumentModel(documentModel, config.documentModelsDir, {
|
|
113
117
|
skipFormat: config.skipFormat,
|
|
114
118
|
verbose,
|
|
119
|
+
force,
|
|
115
120
|
});
|
|
116
121
|
await generateSubgraph(name, filePath || null, config, { verbose });
|
|
117
122
|
}
|
|
@@ -138,7 +143,7 @@ export async function generateFromDocument(documentModelState, config, options =
|
|
|
138
143
|
// delegate to shared generation function
|
|
139
144
|
await generateFromDocumentModel(documentModelState, config, null, options);
|
|
140
145
|
}
|
|
141
|
-
export async function generateEditor(name, documentTypes, config) {
|
|
146
|
+
export async function generateEditor(name, documentTypes, config, editorId) {
|
|
142
147
|
const pathOrigin = "../../";
|
|
143
148
|
const { documentModelsDir, skipFormat } = config;
|
|
144
149
|
const documentTypesMap = await getDocumentTypesMap(documentModelsDir, pathOrigin);
|
|
@@ -146,7 +151,13 @@ export async function generateEditor(name, documentTypes, config) {
|
|
|
146
151
|
if (invalidType) {
|
|
147
152
|
throw new Error(`Document model for ${invalidType} not found`);
|
|
148
153
|
}
|
|
149
|
-
return _generateEditor(name, documentTypes, documentTypesMap, config.editorsDir, config.documentModelsDir, { skipFormat });
|
|
154
|
+
return _generateEditor(name, documentTypes, documentTypesMap, config.editorsDir, config.documentModelsDir, { skipFormat }, editorId);
|
|
155
|
+
}
|
|
156
|
+
export async function generateSubgraphFromDocumentModel(name, documentModel, config, options = {}) {
|
|
157
|
+
return _generateSubgraph(name, documentModel, config.subgraphsDir, {
|
|
158
|
+
skipFormat: config.skipFormat,
|
|
159
|
+
verbose: options.verbose,
|
|
160
|
+
});
|
|
150
161
|
}
|
|
151
162
|
export async function generateSubgraph(name, file, config, options = {}) {
|
|
152
163
|
return _generateSubgraph(name, file !== null ? await loadDocumentModel(file) : null, config.subgraphsDir, { skipFormat: config.skipFormat, verbose: options.verbose });
|
|
@@ -170,4 +181,70 @@ export async function generateImportScript(name, config) {
|
|
|
170
181
|
skipFormat: config.skipFormat,
|
|
171
182
|
});
|
|
172
183
|
}
|
|
184
|
+
export function generateManifest(manifestData, projectRoot) {
|
|
185
|
+
const rootDir = projectRoot || process.cwd();
|
|
186
|
+
const manifestPath = join(rootDir, "powerhouse.manifest.json");
|
|
187
|
+
// Create default manifest structure
|
|
188
|
+
const defaultManifest = {
|
|
189
|
+
name: "",
|
|
190
|
+
description: "",
|
|
191
|
+
category: "",
|
|
192
|
+
publisher: {
|
|
193
|
+
name: "",
|
|
194
|
+
url: "",
|
|
195
|
+
},
|
|
196
|
+
documentModels: [],
|
|
197
|
+
editors: [],
|
|
198
|
+
apps: [],
|
|
199
|
+
subgraphs: [],
|
|
200
|
+
importScripts: [],
|
|
201
|
+
};
|
|
202
|
+
// Read existing manifest if it exists
|
|
203
|
+
let existingManifest = defaultManifest;
|
|
204
|
+
if (fs.existsSync(manifestPath)) {
|
|
205
|
+
try {
|
|
206
|
+
const existingData = fs.readFileSync(manifestPath, "utf-8");
|
|
207
|
+
existingManifest = JSON.parse(existingData);
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
console.warn(`Failed to parse existing manifest: ${String(error)}`);
|
|
211
|
+
existingManifest = defaultManifest;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Helper function to merge arrays by ID
|
|
215
|
+
const mergeArrayById = (existingArray, newArray) => {
|
|
216
|
+
if (!newArray)
|
|
217
|
+
return existingArray;
|
|
218
|
+
const result = [...existingArray];
|
|
219
|
+
newArray.forEach((newItem) => {
|
|
220
|
+
const existingIndex = result.findIndex((item) => item.id === newItem.id);
|
|
221
|
+
if (existingIndex !== -1) {
|
|
222
|
+
// Replace existing item
|
|
223
|
+
result[existingIndex] = newItem;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// Add new item
|
|
227
|
+
result.push(newItem);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return result;
|
|
231
|
+
};
|
|
232
|
+
// Merge partial data with existing manifest
|
|
233
|
+
const updatedManifest = {
|
|
234
|
+
...existingManifest,
|
|
235
|
+
...manifestData,
|
|
236
|
+
publisher: {
|
|
237
|
+
...existingManifest.publisher,
|
|
238
|
+
...(manifestData.publisher || {}),
|
|
239
|
+
},
|
|
240
|
+
documentModels: mergeArrayById(existingManifest.documentModels, manifestData.documentModels),
|
|
241
|
+
editors: mergeArrayById(existingManifest.editors, manifestData.editors),
|
|
242
|
+
apps: mergeArrayById(existingManifest.apps, manifestData.apps),
|
|
243
|
+
subgraphs: mergeArrayById(existingManifest.subgraphs, manifestData.subgraphs),
|
|
244
|
+
importScripts: mergeArrayById(existingManifest.importScripts, manifestData.importScripts),
|
|
245
|
+
};
|
|
246
|
+
// Write updated manifest to file
|
|
247
|
+
fs.writeFileSync(manifestPath, JSON.stringify(updatedManifest, null, 4));
|
|
248
|
+
return manifestPath;
|
|
249
|
+
}
|
|
173
250
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKpD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,mBAAmB,IAAI,oBAAoB,EAC3C,cAAc,IAAI,eAAe,EACjC,oBAAoB,IAAI,qBAAqB,EAC7C,iBAAiB,IAAI,kBAAkB,EACvC,gBAAgB,IAAI,iBAAiB,EACrC,WAAW,EACX,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAO/C,SAAS,qBAAqB,CAAC,aAAiC;IAC9D,MAAM,IAAI,GACR,aAAa,CAAC,cAAc,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAA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AC;IAEF,4CAA4C;IAC5C,MAAM,eAAe,GAAuB;QAC1C,GAAG,gBAAgB;QACnB,GAAG,YAAY;QACf,SAAS,EAAE;YACT,GAAG,gBAAgB,CAAC,SAAS;YAC7B,GAAG,CAAC,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC;SAClC;QACD,cAAc,EAAE,cAAc,CAC5B,gBAAgB,CAAC,cAAc,EAC/B,YAAY,CAAC,cAAc,CAC5B;QACD,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC;QACvE,IAAI,EAAE,cAAc,CAAC,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC;QAC9D,SAAS,EAAE,cAAc,CACvB,gBAAgB,CAAC,SAAS,EAC1B,YAAY,CAAC,SAAS,CACvB;QACD,aAAa,EAAE,cAAc,CAC3B,gBAAgB,CAAC,aAAa,EAC9B,YAAY,CAAC,aAAa,CAC3B;KACF,CAAC;IAEF,iCAAiC;IACjC,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzE,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DirectoryManager } from "../utilities/DirectoryManager.js";
|
|
2
|
+
import { type ImportManager } from "../utilities/ImportManager.js";
|
|
3
|
+
import { type GenerationContext } from "./GenerationContext.js";
|
|
4
|
+
export declare abstract class FileGenerator {
|
|
5
|
+
protected importManager: ImportManager;
|
|
6
|
+
protected directoryManager: DirectoryManager;
|
|
7
|
+
constructor(importManager: ImportManager, directoryManager: DirectoryManager);
|
|
8
|
+
abstract generate(context: GenerationContext): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=FileGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileGenerator.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/FileGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,8BAAsB,aAAa;IAE/B,SAAS,CAAC,aAAa,EAAE,aAAa;IACtC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB;gBADlC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB;IAG9C,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAC7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileGenerator.js","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/FileGenerator.ts"],"names":[],"mappings":"AAIA,MAAM,OAAgB,aAAa;IAErB;IACA;IAFZ,YACY,aAA4B,EAC5B,gBAAkC;QADlC,kBAAa,GAAb,aAAa,CAAe;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAkB;IAC3C,CAAC;CAGL"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type DocumentModelState, type Operation as ModuleOperation } from "document-model/document-model/gen/schema/types";
|
|
2
|
+
import { type Project } from "ts-morph";
|
|
3
|
+
export type ModuleSpec = DocumentModelState["specifications"][0]["modules"][0];
|
|
4
|
+
export type OperationError = ModuleOperation["errors"][number];
|
|
5
|
+
export type Operation = ModuleOperation & {
|
|
6
|
+
hasInput: boolean;
|
|
7
|
+
hasAttachment: boolean | undefined;
|
|
8
|
+
scope: string;
|
|
9
|
+
state: string;
|
|
10
|
+
errors?: OperationError[];
|
|
11
|
+
};
|
|
12
|
+
export interface GenerationContext {
|
|
13
|
+
rootDir: string;
|
|
14
|
+
docModel: DocumentModelState;
|
|
15
|
+
module: ModuleSpec;
|
|
16
|
+
project: Project;
|
|
17
|
+
operations: Operation[];
|
|
18
|
+
forceUpdate: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type PHProjectDirectories = {
|
|
21
|
+
documentModelDir?: string;
|
|
22
|
+
editorsDir?: string;
|
|
23
|
+
processorsDir?: string;
|
|
24
|
+
subgraphsDir?: string;
|
|
25
|
+
};
|
|
26
|
+
export type CodeGeneratorOptions = {
|
|
27
|
+
directories?: PHProjectDirectories;
|
|
28
|
+
forceUpdate?: boolean;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=GenerationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerationContext.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/GenerationContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,SAAS,IAAI,eAAe,EAClC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerationContext.js","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/GenerationContext.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type DocumentModelState } from "document-model";
|
|
2
|
+
import { type CodeGeneratorOptions } from "./GenerationContext.js";
|
|
3
|
+
export declare class TSMorphCodeGenerator {
|
|
4
|
+
private rootDir;
|
|
5
|
+
private docModels;
|
|
6
|
+
private project;
|
|
7
|
+
private generators;
|
|
8
|
+
private directories;
|
|
9
|
+
private forceUpdate;
|
|
10
|
+
constructor(rootDir: string, docModels: DocumentModelState[], options?: CodeGeneratorOptions);
|
|
11
|
+
private setupGenerators;
|
|
12
|
+
generateReducers(): Promise<void>;
|
|
13
|
+
generateAll(): Promise<void>;
|
|
14
|
+
private generateFileType;
|
|
15
|
+
private setupProject;
|
|
16
|
+
private createGenerationContext;
|
|
17
|
+
private ensureDirectoryExists;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=TSMorphCodeGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TSMorphCodeGenerator.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/TSMorphCodeGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAOzD,OAAO,EACL,KAAK,oBAAoB,EAK1B,MAAM,wBAAwB,CAAC;AAEhC,qBAAa,oBAAoB;IAY7B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,SAAS;IAZnB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,WAAW,CAKjB;IACF,OAAO,CAAC,WAAW,CAAS;gBAGlB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,kBAAkB,EAAE,EACvC,OAAO,GAAE,oBAA8D;IAYzE,OAAO,CAAC,eAAe;IAYjB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;YAMpB,gBAAgB;YAwBhB,YAAY;IAiC1B,OAAO,CAAC,uBAAuB;YAuBjB,qBAAqB;CAQpC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import { Project } from "ts-morph";
|
|
3
|
+
import { ReducerGenerator } from "../file-generators/ReducerGenerator.js";
|
|
4
|
+
import { DirectoryManager } from "../utilities/DirectoryManager.js";
|
|
5
|
+
import { ImportManager } from "../utilities/ImportManager.js";
|
|
6
|
+
export class TSMorphCodeGenerator {
|
|
7
|
+
rootDir;
|
|
8
|
+
docModels;
|
|
9
|
+
project = new Project();
|
|
10
|
+
generators = new Map();
|
|
11
|
+
directories = {
|
|
12
|
+
documentModelDir: "document-model",
|
|
13
|
+
editorsDir: "editors",
|
|
14
|
+
processorsDir: "processors",
|
|
15
|
+
subgraphsDir: "subgraphs",
|
|
16
|
+
};
|
|
17
|
+
forceUpdate = false;
|
|
18
|
+
constructor(rootDir, docModels, options = { directories: {}, forceUpdate: false }) {
|
|
19
|
+
this.rootDir = rootDir;
|
|
20
|
+
this.docModels = docModels;
|
|
21
|
+
this.directories = {
|
|
22
|
+
...this.directories,
|
|
23
|
+
...options.directories,
|
|
24
|
+
};
|
|
25
|
+
this.forceUpdate = options.forceUpdate ?? false;
|
|
26
|
+
this.setupGenerators();
|
|
27
|
+
}
|
|
28
|
+
setupGenerators() {
|
|
29
|
+
const importManager = new ImportManager();
|
|
30
|
+
const directoryManager = new DirectoryManager(this.directories);
|
|
31
|
+
// Register all generators
|
|
32
|
+
this.generators.set("reducers", new ReducerGenerator(importManager, directoryManager));
|
|
33
|
+
}
|
|
34
|
+
// Generate specific file types
|
|
35
|
+
async generateReducers() {
|
|
36
|
+
await this.generateFileType("reducers");
|
|
37
|
+
}
|
|
38
|
+
// Generate everything
|
|
39
|
+
async generateAll() {
|
|
40
|
+
for (const [type] of this.generators) {
|
|
41
|
+
await this.generateFileType(type);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async generateFileType(type) {
|
|
45
|
+
const generator = this.generators.get(type);
|
|
46
|
+
if (!generator) {
|
|
47
|
+
throw new Error(`No generator registered for type: ${type}`);
|
|
48
|
+
}
|
|
49
|
+
await this.setupProject();
|
|
50
|
+
for (const docModel of this.docModels) {
|
|
51
|
+
const latestSpec = docModel.specifications[docModel.specifications.length - 1];
|
|
52
|
+
for (const module of latestSpec.modules) {
|
|
53
|
+
const context = this.createGenerationContext(docModel, module, this.forceUpdate);
|
|
54
|
+
await generator.generate(context);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async setupProject() {
|
|
59
|
+
// Only load files from configured directories
|
|
60
|
+
const sourcePaths = [];
|
|
61
|
+
if (this.directories.documentModelDir) {
|
|
62
|
+
const dirPath = `${this.rootDir}/${this.directories.documentModelDir}`;
|
|
63
|
+
await this.ensureDirectoryExists(dirPath);
|
|
64
|
+
sourcePaths.push(`${dirPath}/**/*.ts`);
|
|
65
|
+
}
|
|
66
|
+
if (this.directories.editorsDir) {
|
|
67
|
+
const dirPath = `${this.rootDir}/${this.directories.editorsDir}`;
|
|
68
|
+
await this.ensureDirectoryExists(dirPath);
|
|
69
|
+
sourcePaths.push(`${dirPath}/**/*.ts`);
|
|
70
|
+
}
|
|
71
|
+
if (this.directories.processorsDir) {
|
|
72
|
+
const dirPath = `${this.rootDir}/${this.directories.processorsDir}`;
|
|
73
|
+
await this.ensureDirectoryExists(dirPath);
|
|
74
|
+
sourcePaths.push(`${dirPath}/**/*.ts`);
|
|
75
|
+
}
|
|
76
|
+
if (this.directories.subgraphsDir) {
|
|
77
|
+
const dirPath = `${this.rootDir}/${this.directories.subgraphsDir}`;
|
|
78
|
+
await this.ensureDirectoryExists(dirPath);
|
|
79
|
+
sourcePaths.push(`${dirPath}/**/*.ts`);
|
|
80
|
+
}
|
|
81
|
+
// Exclude node_modules from all paths
|
|
82
|
+
sourcePaths.push(`!${this.rootDir}/**/node_modules/**`);
|
|
83
|
+
if (sourcePaths.length > 0) {
|
|
84
|
+
this.project.addSourceFilesAtPaths(sourcePaths);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
createGenerationContext(docModel, module, forceUpdate = false) {
|
|
88
|
+
const operations = module.operations.map((op) => ({
|
|
89
|
+
...op,
|
|
90
|
+
hasInput: op.schema !== null,
|
|
91
|
+
hasAttachment: op.schema?.includes(": Attachment"),
|
|
92
|
+
scope: op.scope || "global",
|
|
93
|
+
state: op.scope === "global" ? "" : op.scope,
|
|
94
|
+
}));
|
|
95
|
+
return {
|
|
96
|
+
rootDir: this.rootDir,
|
|
97
|
+
docModel,
|
|
98
|
+
module,
|
|
99
|
+
project: this.project,
|
|
100
|
+
operations,
|
|
101
|
+
forceUpdate,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async ensureDirectoryExists(dirPath) {
|
|
105
|
+
try {
|
|
106
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
console.error(`Failed to create directory: ${dirPath}`, err);
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=TSMorphCodeGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TSMorphCodeGenerator.js","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/TSMorphCodeGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAU9D,MAAM,OAAO,oBAAoB;IAYrB;IACA;IAZF,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IACxB,UAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC9C,WAAW,GAAyB;QAC1C,gBAAgB,EAAE,gBAAgB;QAClC,UAAU,EAAE,SAAS;QACrB,aAAa,EAAE,YAAY;QAC3B,YAAY,EAAE,WAAW;KAC1B,CAAC;IACM,WAAW,GAAG,KAAK,CAAC;IAE5B,YACU,OAAe,EACf,SAA+B,EACvC,UAAgC,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;QAF/D,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAsB;QAGvC,IAAI,CAAC,WAAW,GAAG;YACjB,GAAG,IAAI,CAAC,WAAW;YACnB,GAAG,OAAO,CAAC,WAAW;SACvB,CAAC;QAEF,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC;QAEhD,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAEO,eAAe;QACrB,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;QAC1C,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEhE,0BAA0B;QAC1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|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ts-morph-generator/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FileGenerator } from "../core/FileGenerator.js";
|
|
2
|
+
import { type GenerationContext } from "../core/GenerationContext.js";
|
|
3
|
+
export declare class ReducerGenerator extends FileGenerator {
|
|
4
|
+
generate(context: GenerationContext): Promise<void>;
|
|
5
|
+
private static getDefaultReducerCode;
|
|
6
|
+
private addErrorImports;
|
|
7
|
+
private getOutputPath;
|
|
8
|
+
private createReducerObject;
|
|
9
|
+
private addReducerMethod;
|
|
10
|
+
private setReducerMethodCode;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ReducerGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReducerGenerator.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-generator/file-generators/ReducerGenerator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,KAAK,iBAAiB,EAGvB,MAAM,8BAA8B,CAAC;AAEtC,qBAAa,gBAAiB,SAAQ,aAAa;IAC3C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCzD,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAOpC,OAAO,CAAC,eAAe;IAyEvB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,mBAAmB;IAsC3B,OAAO,CAAC,gBAAgB;IAiCxB,OAAO,CAAC,oBAAoB;CAK7B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { camelCase, paramCase, pascalCase } from "change-case";
|
|
2
|
+
import { SyntaxKind, VariableDeclarationKind, } from "ts-morph";
|
|
3
|
+
import { FileGenerator } from "../core/FileGenerator.js";
|
|
4
|
+
export class ReducerGenerator extends FileGenerator {
|
|
5
|
+
async generate(context) {
|
|
6
|
+
// Skip if no actions to generate
|
|
7
|
+
if (context.operations.length === 0)
|
|
8
|
+
return;
|
|
9
|
+
const filePath = this.getOutputPath(context);
|
|
10
|
+
const sourceFile = await this.directoryManager.createSourceFile(context.project, filePath);
|
|
11
|
+
// Reducer-specific import logic
|
|
12
|
+
const typeImportName = `${pascalCase(context.docModel.name)}${pascalCase(context.module.name)}Operations`;
|
|
13
|
+
const typeImportPath = `../../gen/${paramCase(context.module.name)}/operations.js`;
|
|
14
|
+
// Import management (shared utility)
|
|
15
|
+
this.importManager.addTypeImport(sourceFile, typeImportName, typeImportPath);
|
|
16
|
+
// AST logic (specific to reducers)
|
|
17
|
+
this.createReducerObject(sourceFile, typeImportName, context.operations, context.forceUpdate);
|
|
18
|
+
// Detect and import error classes used in the actual reducer code (after generation)
|
|
19
|
+
this.addErrorImports(sourceFile, context);
|
|
20
|
+
await sourceFile.save();
|
|
21
|
+
}
|
|
22
|
+
static getDefaultReducerCode(methodName) {
|
|
23
|
+
return [
|
|
24
|
+
`// TODO: Implement "${methodName}" reducer`,
|
|
25
|
+
`throw new Error('Reducer "${methodName}" not yet implemented');`,
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
addErrorImports(sourceFile, context) {
|
|
29
|
+
// Collect all errors from all operations
|
|
30
|
+
const allErrors = [];
|
|
31
|
+
context.operations.forEach((operation) => {
|
|
32
|
+
if (Array.isArray(operation.errors)) {
|
|
33
|
+
operation.errors
|
|
34
|
+
.filter((error) => error.name)
|
|
35
|
+
.forEach((error) => {
|
|
36
|
+
// Deduplicate errors by name
|
|
37
|
+
if (!allErrors.find((e) => e.name === error.name)) {
|
|
38
|
+
allErrors.push(error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (allErrors.length === 0)
|
|
44
|
+
return;
|
|
45
|
+
// Analyze the actual source file content to find which errors are used
|
|
46
|
+
const sourceFileContent = sourceFile.getFullText();
|
|
47
|
+
const usedErrors = new Set();
|
|
48
|
+
allErrors.forEach((error) => {
|
|
49
|
+
// Check if error class name is mentioned anywhere in the source file
|
|
50
|
+
// Look for patterns like "new ErrorName" or "throw ErrorName" or "ErrorName("
|
|
51
|
+
const errorPattern = new RegExp(`\\b${error.name}\\b`, "g");
|
|
52
|
+
if (errorPattern.test(sourceFileContent)) {
|
|
53
|
+
usedErrors.add(error.name);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
// Add imports for used errors (only if they're not already imported)
|
|
57
|
+
if (usedErrors.size > 0) {
|
|
58
|
+
const errorImportPath = `../../gen/${paramCase(context.module.name)}/error.js`;
|
|
59
|
+
const errorClassNames = Array.from(usedErrors);
|
|
60
|
+
// Check if imports already exist to avoid duplicates
|
|
61
|
+
const existingImports = sourceFile.getImportDeclarations();
|
|
62
|
+
const existingErrorImport = existingImports.find((importDecl) => importDecl.getModuleSpecifierValue() === errorImportPath);
|
|
63
|
+
if (existingErrorImport) {
|
|
64
|
+
// Get already imported error names
|
|
65
|
+
const existingNamedImports = existingErrorImport
|
|
66
|
+
.getNamedImports()
|
|
67
|
+
.map((namedImport) => namedImport.getName());
|
|
68
|
+
// Only import errors that aren't already imported
|
|
69
|
+
const newErrorsToImport = errorClassNames.filter((errorName) => !existingNamedImports.includes(errorName));
|
|
70
|
+
if (newErrorsToImport.length > 0) {
|
|
71
|
+
// Add new named imports to existing import declaration
|
|
72
|
+
existingErrorImport.addNamedImports(newErrorsToImport);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Create new import declaration
|
|
77
|
+
this.importManager.addNamedImports(sourceFile, errorClassNames, errorImportPath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
getOutputPath(context) {
|
|
82
|
+
return this.directoryManager.getReducerPath(context.rootDir, context.docModel.name, context.module.name);
|
|
83
|
+
}
|
|
84
|
+
createReducerObject(sourceFile, typeName, operations, forceUpdate = false) {
|
|
85
|
+
let reducerVar = sourceFile.getVariableDeclaration("reducer");
|
|
86
|
+
if (!reducerVar) {
|
|
87
|
+
sourceFile.addVariableStatement({
|
|
88
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
89
|
+
isExported: true,
|
|
90
|
+
declarations: [
|
|
91
|
+
{
|
|
92
|
+
name: "reducer",
|
|
93
|
+
type: typeName,
|
|
94
|
+
initializer: "{}",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
reducerVar = sourceFile.getVariableDeclarationOrThrow("reducer");
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Ensure correct type
|
|
102
|
+
const typeNode = reducerVar.getTypeNode();
|
|
103
|
+
if (!typeNode || typeNode.getText() !== typeName) {
|
|
104
|
+
reducerVar.setType(typeName);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const initializer = reducerVar.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
108
|
+
for (const operation of operations) {
|
|
109
|
+
this.addReducerMethod(initializer, operation, forceUpdate);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
addReducerMethod(objectLiteral, operation, forceUpdate = false) {
|
|
113
|
+
const actionName = camelCase(operation.name ?? "");
|
|
114
|
+
if (!actionName)
|
|
115
|
+
return;
|
|
116
|
+
const methodName = `${actionName}Operation`;
|
|
117
|
+
const reducerCode = operation.reducer?.trim();
|
|
118
|
+
const existingReducer = objectLiteral
|
|
119
|
+
.getProperty(methodName)
|
|
120
|
+
?.asKind(SyntaxKind.MethodDeclaration);
|
|
121
|
+
// if reducer already exists but forceUpdate is true, update it
|
|
122
|
+
if (existingReducer) {
|
|
123
|
+
if (forceUpdate && reducerCode) {
|
|
124
|
+
existingReducer.setBodyText("");
|
|
125
|
+
this.setReducerMethodCode(existingReducer, reducerCode);
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// if reducer doesn't exist, create it and set the code with the default code if no code is provided
|
|
130
|
+
const method = objectLiteral.addMethod({
|
|
131
|
+
name: methodName,
|
|
132
|
+
parameters: [{ name: "state" }, { name: "action" }, { name: "dispatch" }],
|
|
133
|
+
});
|
|
134
|
+
this.setReducerMethodCode(method, reducerCode);
|
|
135
|
+
}
|
|
136
|
+
setReducerMethodCode(reducer, code) {
|
|
137
|
+
reducer.addStatements(code ? [code] : ReducerGenerator.getDefaultReducerCode(reducer.getName()));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=ReducerGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReducerGenerator.js","sourceRoot":"","sources":["../../../../src/ts-morph-generator/file-generators/ReducerGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,uBAAuB,GAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IACjD,KAAK,CAAC,QAAQ,CAAC,OAA0B;QACvC,iCAAiC;QACjC,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAE5C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAC7D,OAAO,CAAC,OAAO,EACf,QAAQ,CACT,CAAC;QAEF,gCAAgC;QAChC,MAAM,cAAc,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,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,CAAC;IACjD,CAAC;IAEO,oBAAoB,CAAC,OAA0B,EAAE,IAAa;QACpE,OAAO,CAAC,aAAa,CACnB,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAC1E,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-generator/file-generators/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ts-morph-generator/file-generators/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts-morph-generator/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ts-morph-generator/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Project, type SourceFile } from "ts-morph";
|
|
2
|
+
import { type PHProjectDirectories } from "../core/GenerationContext.js";
|
|
3
|
+
export declare class DirectoryManager {
|
|
4
|
+
private directories;
|
|
5
|
+
constructor(directories?: PHProjectDirectories);
|
|
6
|
+
ensureExists(dirPath: string): Promise<void>;
|
|
7
|
+
getReducerPath(rootDir: string, docModelName: string, moduleName: string): string;
|
|
8
|
+
getActionsPath(rootDir: string, docModelName: string, moduleName: string): string;
|
|
9
|
+
getComponentPath(rootDir: string, docModelName: string, componentName: string): string;
|
|
10
|
+
getTypesPath(rootDir: string, docModelName: string): string;
|
|
11
|
+
createSourceFile(project: Project, filePath: string): Promise<SourceFile>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DirectoryManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DirectoryManager.d.ts","sourceRoot":"","sources":["../../../../src/ts-morph-generator/utilities/DirectoryManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAKjB;gBAEU,WAAW,GAAE,oBAAyB;IAM5C,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlD,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM;IAWT,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM;IAWT,gBAAgB,CACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,MAAM;IAWT,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAUrD,gBAAgB,CACpB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC;CAOvB"}
|