@powerhousedao/codegen 4.1.0-dev.2 → 4.1.0-dev.20

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.
Files changed (83) hide show
  1. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts +14 -0
  2. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.d.ts.map +1 -0
  3. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js +12 -0
  4. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js.map +1 -0
  5. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/resolvers.esm.t +17 -0
  6. package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/schema.esm.t +16 -0
  7. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +4 -1
  8. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +1 -1
  9. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/actions.esm.t +3 -3
  10. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +2 -2
  11. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t +6 -10
  12. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +4 -0
  13. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map +1 -1
  14. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +13 -1
  15. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map +1 -1
  16. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +59 -50
  17. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t +3 -3
  18. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +10 -1
  19. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +292 -131
  20. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +20 -3
  21. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderTree.esm.t +43 -25
  22. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +37 -42
  23. package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.esm.t +0 -32
  24. package/dist/src/codegen/graphql.d.ts +5 -1
  25. package/dist/src/codegen/graphql.d.ts.map +1 -1
  26. package/dist/src/codegen/graphql.js +28 -5
  27. package/dist/src/codegen/graphql.js.map +1 -1
  28. package/dist/src/codegen/hygen.d.ts +5 -2
  29. package/dist/src/codegen/hygen.d.ts.map +1 -1
  30. package/dist/src/codegen/hygen.js +30 -2
  31. package/dist/src/codegen/hygen.js.map +1 -1
  32. package/dist/src/codegen/index.d.ts +5 -4
  33. package/dist/src/codegen/index.d.ts.map +1 -1
  34. package/dist/src/codegen/index.js +60 -1
  35. package/dist/src/codegen/index.js.map +1 -1
  36. package/dist/src/ts-morph-generator/core/FileGenerator.d.ts +10 -0
  37. package/dist/src/ts-morph-generator/core/FileGenerator.d.ts.map +1 -0
  38. package/dist/src/ts-morph-generator/core/FileGenerator.js +9 -0
  39. package/dist/src/ts-morph-generator/core/FileGenerator.js.map +1 -0
  40. package/dist/src/ts-morph-generator/core/GenerationContext.d.ts +30 -0
  41. package/dist/src/ts-morph-generator/core/GenerationContext.d.ts.map +1 -0
  42. package/dist/src/ts-morph-generator/core/GenerationContext.js +2 -0
  43. package/dist/src/ts-morph-generator/core/GenerationContext.js.map +1 -0
  44. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts +19 -0
  45. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts.map +1 -0
  46. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js +114 -0
  47. package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js.map +1 -0
  48. package/dist/src/ts-morph-generator/core/index.d.ts +4 -0
  49. package/dist/src/ts-morph-generator/core/index.d.ts.map +1 -0
  50. package/dist/src/ts-morph-generator/core/index.js +4 -0
  51. package/dist/src/ts-morph-generator/core/index.js.map +1 -0
  52. package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts +12 -0
  53. package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts.map +1 -0
  54. package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js +140 -0
  55. package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js.map +1 -0
  56. package/dist/src/ts-morph-generator/file-generators/index.d.ts +2 -0
  57. package/dist/src/ts-morph-generator/file-generators/index.d.ts.map +1 -0
  58. package/dist/src/ts-morph-generator/file-generators/index.js +2 -0
  59. package/dist/src/ts-morph-generator/file-generators/index.js.map +1 -0
  60. package/dist/src/ts-morph-generator/index.d.ts +4 -0
  61. package/dist/src/ts-morph-generator/index.d.ts.map +1 -0
  62. package/dist/src/ts-morph-generator/index.js +4 -0
  63. package/dist/src/ts-morph-generator/index.js.map +1 -0
  64. package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts +13 -0
  65. package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts.map +1 -0
  66. package/dist/src/ts-morph-generator/utilities/DirectoryManager.js +45 -0
  67. package/dist/src/ts-morph-generator/utilities/DirectoryManager.js.map +1 -0
  68. package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts +14 -0
  69. package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts.map +1 -0
  70. package/dist/src/ts-morph-generator/utilities/ImportManager.js +40 -0
  71. package/dist/src/ts-morph-generator/utilities/ImportManager.js.map +1 -0
  72. package/dist/src/ts-morph-generator/utilities/index.d.ts +3 -0
  73. package/dist/src/ts-morph-generator/utilities/index.d.ts.map +1 -0
  74. package/dist/src/ts-morph-generator/utilities/index.js +3 -0
  75. package/dist/src/ts-morph-generator/utilities/index.js.map +1 -0
  76. package/dist/tsconfig.hygen.tsbuildinfo +1 -1
  77. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  78. package/package.json +8 -6
  79. package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customReducers.esm.t +0 -20
  80. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FileItemsGrid.esm.t +0 -44
  81. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderItemsGrid.esm.t +0 -96
  82. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useSelectedFolderChildren.esm.t +0 -35
  83. package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useTransformedNodes.esm.t +0 -35
@@ -2,20 +2,32 @@
2
2
  to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/components/FolderTree.tsx"
3
3
  unless_exists: true
4
4
  ---
5
- import { useState } from 'react';
6
- import type { UiFolderNode } from "@powerhousedao/design-system";
5
+ import { useState } from "react";
6
+ import type { FolderNode } from "document-drive";
7
7
 
8
8
  interface FolderTreeProps {
9
- folders: UiFolderNode[];
9
+ folders: FolderNode[];
10
10
  selectedNodeId?: string;
11
- onSelectNode: (node: UiFolderNode) => void;
11
+ onSelectNode: (nodeId: string | undefined) => void;
12
12
  }
13
13
 
14
- export function FolderTree({ folders, selectedNodeId, onSelectNode }: FolderTreeProps) {
15
- const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set());
14
+ /**
15
+ * Hierarchical folder tree navigation component.
16
+ * Displays folders in a tree structure with expand/collapse functionality.
17
+ */
18
+ export function FolderTree({
19
+ folders,
20
+ selectedNodeId,
21
+ onSelectNode,
22
+ }: FolderTreeProps) {
23
+ // Track which folders are expanded
24
+ const [expandedFolders, setExpandedFolders] = useState<Set<string>>(
25
+ new Set(),
26
+ );
16
27
 
28
+ // Toggle folder expansion state
17
29
  const toggleFolder = (folderId: string) => {
18
- setExpandedFolders(prev => {
30
+ setExpandedFolders((prev) => {
19
31
  const next = new Set(prev);
20
32
  if (next.has(folderId)) {
21
33
  next.delete(folderId);
@@ -26,20 +38,22 @@ export function FolderTree({ folders, selectedNodeId, onSelectNode }: FolderTree
26
38
  });
27
39
  };
28
40
 
29
- const renderFolder = (folder: UiFolderNode, level: number = 0) => {
30
- const hasChildren = folders.some(f => f.parentFolder === folder.id);
41
+ // Recursive function to render folder tree structure
42
+ const renderFolder = (folder: FolderNode, level: number = 0) => {
43
+ const hasChildren = folders.some((f) => f.parentFolder === folder.id);
31
44
  const isExpanded = expandedFolders.has(folder.id);
32
45
  const isSelected = selectedNodeId === folder.id;
33
46
 
34
47
  return (
35
48
  <div key={folder.id}>
36
49
  <div
37
- className={`flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded ${
38
- isSelected ? 'bg-gray-100' : ''
50
+ className={`flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded text-sm ${
51
+ isSelected ? "bg-blue-100 text-blue-800" : ""
39
52
  }`}
40
- style={{ paddingLeft: `${level * 16 + 8}px` }}
41
- onClick={() => onSelectNode(folder)}
53
+ style={{ paddingLeft: `${level * 16 + 8}px` }} // Customize indentation here
54
+ onClick={() => onSelectNode(folder.id)}
42
55
  >
56
+ {/* Expand/collapse button for folders with children */}
43
57
  {hasChildren && (
44
58
  <button
45
59
  className="w-4 h-4 mr-1 flex items-center justify-center"
@@ -48,16 +62,19 @@ export function FolderTree({ folders, selectedNodeId, onSelectNode }: FolderTree
48
62
  toggleFolder(folder.id);
49
63
  }}
50
64
  >
51
- {isExpanded ? '' : ''}
65
+ {isExpanded ? "" : ""} {/* Customize expand icons here */}
52
66
  </button>
53
67
  )}
54
- <span className="text-sm">{folder.name}</span>
68
+ {!hasChildren && <div className="w-5 mr-1" />}
69
+ {/* Customize folder icon and styling here */}
70
+ <span>📁 {folder.name}</span>
55
71
  </div>
72
+ {/* Recursively render child folders when expanded */}
56
73
  {isExpanded && hasChildren && (
57
74
  <div>
58
75
  {folders
59
- .filter(f => f.parentFolder === folder.id)
60
- .map(child => renderFolder(child, level + 1))}
76
+ .filter((f) => f.parentFolder === folder.id)
77
+ .map((child) => renderFolder(child, level + 1))}
61
78
  </div>
62
79
  )}
63
80
  </div>
@@ -67,19 +84,20 @@ export function FolderTree({ folders, selectedNodeId, onSelectNode }: FolderTree
67
84
  return (
68
85
  <div className="space-y-1">
69
86
  {/* Root Directory Option */}
87
+ {/* Customize root folder appearance here */}
70
88
  <div
71
- className={`flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded ${
72
- !selectedNodeId ? 'bg-gray-100' : ''
89
+ className={`flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded text-sm ${
90
+ !selectedNodeId ? "bg-blue-100 text-blue-800" : ""
73
91
  }`}
74
- onClick={() => onSelectNode({ id: '', name: 'Root', kind: 'FOLDER' } as UiFolderNode)}
92
+ onClick={() => onSelectNode(undefined)}
75
93
  >
76
- <span className="text-sm font-medium">Root</span>
94
+ <span>🏠 Root</span>
77
95
  </div>
78
96
 
79
- {/* Folder Tree */}
97
+ {/* Render top-level folders (no parent) */}
80
98
  {folders
81
- .filter(folder => !folder.parentFolder)
82
- .map(folder => renderFolder(folder))}
99
+ .filter((folder) => !folder.parentFolder)
100
+ .map((folder) => renderFolder(folder))}
83
101
  </div>
84
102
  );
85
- }
103
+ }
@@ -3,71 +3,66 @@ to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/editor.tsx"
3
3
  unless_exists: true
4
4
  ---
5
5
  import { type DriveEditorProps } from "@powerhousedao/reactor-browser";
6
- import { AnalyticsProvider } from '@powerhousedao/reactor-browser/analytics/context';
7
- import { DriveContextProvider } from "@powerhousedao/reactor-browser/hooks/useDriveContext";
8
- import { type DocumentDriveDocument, addFolder, deleteNode, updateNode, generateNodesCopy, copyNode } from "document-drive";
6
+ import { AnalyticsProvider } from "@powerhousedao/reactor-browser/analytics/context";
7
+ import { DriveContextProvider, useDriveContext } from "@powerhousedao/reactor-browser/hooks/useDriveContext";
8
+ import { useInitializePHApp, useSetSelectedNode } from '@powerhousedao/state';
9
+ import { type DocumentDriveDocument, type FileNode } from "document-drive";
9
10
  import { WagmiContext } from "@powerhousedao/design-system";
10
11
  import { DriveExplorer } from "./components/DriveExplorer.js";
11
12
  import { useCallback } from "react";
12
- import { generateId } from "document-model";
13
13
 
14
14
  export type IProps = DriveEditorProps<DocumentDriveDocument>;
15
15
 
16
+ /**
17
+ * Base editor component that renders the drive explorer interface.
18
+ * Customize document opening behavior and drive-level actions here.
19
+ */
16
20
  export function BaseEditor(props: IProps) {
17
- const { dispatch, context } = props;
18
-
19
- const onAddFolder = useCallback((name: string, parentFolder?: string) => {
20
- dispatch(addFolder({
21
- id: generateId(),
22
- name,
23
- parentFolder,
24
- }));
25
- }, [dispatch]);
21
+ const { context, document } = props;
26
22
 
27
- const onDeleteNode = useCallback((nodeId: string) => {
28
- dispatch(deleteNode({ id: nodeId }));
29
- }, [dispatch]);
23
+ // Get drive operations from context
24
+ const {
25
+ onAddFolder,
26
+ onRenameNode,
27
+ onCopyNode,
28
+ showDeleteNodeModal,
29
+ } = useDriveContext();
30
30
 
31
- const renameNode = useCallback((nodeId: string, name: string) => {
32
- dispatch(updateNode({ id: nodeId, name }));
33
- }, [dispatch]);
31
+ const setSelectedNode = useSetSelectedNode();
34
32
 
35
- const onCopyNode = useCallback((nodeId: string, targetName: string, parentId?: string) => {
36
- const copyNodesInput = generateNodesCopy({
37
- srcId: nodeId,
38
- targetParentFolder: parentId,
39
- targetName,
40
- }, () => generateId(), props.document.state.global.nodes);
41
-
42
- const copyNodesAction = copyNodesInput.map(input => {
43
- return copyNode(input);
44
- });
45
-
46
- for (const copyNodeAction of copyNodesAction) {
47
- dispatch(copyNodeAction);
48
- }
49
- }, [dispatch, props.document.state.global.nodes]);
33
+ // Handle document opening - customize this to modify document open behavior
34
+ const onOpenDocument = useCallback(
35
+ (node: FileNode) => {
36
+ setSelectedNode(node.id);
37
+ },
38
+ [setSelectedNode],
39
+ );
50
40
 
51
41
  return (
52
- <div
53
- className="new-drive-explorer"
54
- style={{ height: "100%" }}
55
- >
42
+ <div className="new-drive-explorer" style={{ height: "100%" }}>
56
43
  <DriveExplorer
57
- driveId={props.document.header.id}
58
- nodes={props.document.state.global.nodes}
44
+ driveId={document.header.id}
59
45
  onAddFolder={onAddFolder}
60
- onDeleteNode={onDeleteNode}
61
- renameNode={renameNode}
46
+ onRenameNode={onRenameNode}
62
47
  onCopyNode={onCopyNode}
48
+ onOpenDocument={onOpenDocument}
49
+ showDeleteNodeModal={showDeleteNodeModal}
63
50
  context={context}
64
51
  />
65
52
  </div>
66
53
  );
67
54
  }
68
55
 
56
+ /**
57
+ * Main editor entry point with required providers.
58
+ * useInitializePHApp() is required for state management to work properly.
59
+ */
69
60
  export default function Editor(props: IProps) {
61
+ // Required: Initialize Powerhouse app state
62
+ useInitializePHApp();
63
+
70
64
  return (
65
+ // Required context providers for drive functionality
71
66
  <DriveContextProvider value={props.context}>
72
67
  <WagmiContext>
73
68
  <AnalyticsProvider databaseName={props.context.analyticsDatabaseName}>
@@ -3,46 +3,14 @@ to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/index.ts"
3
3
  force: true
4
4
  ---
5
5
  import { Subgraph } from "@powerhousedao/reactor-api";
6
- <% if (loadFromFile) { %>
7
6
  import { schema } from "./schema.js";
8
7
  import { getResolvers } from "./resolvers.js";
9
- <% } else { %>
10
- import { gql } from "graphql-tag";
11
- <% } %>
12
8
 
13
9
  export class <%= pascalName %>Subgraph extends Subgraph {
14
10
  name = "<%= h.changeCase.param(name) %>";
15
- <% if (loadFromFile) { %>
16
11
  typeDefs = schema;
17
12
  resolvers = getResolvers(this);
18
13
  additionalContextFields = {};
19
14
  async onSetup() {}
20
15
  async onDisconnect() {}
21
-
22
- <% } else { %>
23
-
24
- resolvers = {
25
- Query: {
26
- example: {
27
- resolve: async (parent, args, context, info) => {
28
- return "example";
29
- }
30
- }
31
- }
32
- }
33
-
34
- typeDefs = gql`
35
- type Query {
36
- example(id: ID!): String
37
- }
38
- `;
39
-
40
- additionalContextFields = {
41
- example: "test"
42
- }
43
-
44
- async onSetup() {}
45
-
46
- async onDisconnect() {}
47
- <% } %>
48
16
  }
@@ -20,7 +20,11 @@ export declare const generateSchema: (model: string, inDir: string, { watch, ski
20
20
  skipFormat?: boolean | undefined;
21
21
  outDir?: string | undefined;
22
22
  verbose?: boolean | undefined;
23
- }) => Promise<any>;
23
+ }) => Promise<{
24
+ filename: string;
25
+ content: string;
26
+ hooks: Record<string, unknown>;
27
+ }[]>;
24
28
  export declare const generateSchemas: (inDir: string, { watch, skipFormat, outDir }?: {
25
29
  watch?: boolean | undefined;
26
30
  skipFormat?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/codegen/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAa1E,eAAO,MAAM,OAAO;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;CAO7B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,sBAWtB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAYpC,CAAC;AAEX,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,aAAa,CAAC,WAAW,CAAC,CAmB5B;AAED,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,OAAO,MAAM,EACb;;;;;CAA0E,iBAc3E,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb;;;;CAA0D,iBAoB3D,CAAC"}
1
+ {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/codegen/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAa1E,eAAO,MAAM,OAAO;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;CAO7B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,sBAWtB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAYpC,CAAC;AAEX,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,aAAa,CAAC,WAAW,CAAC,CAmB5B;AAED,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,OAAO,MAAM,EACb;;;;;CAA0E;cAgB9D,MAAM;aACP,MAAM;WACR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA8BjC,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb;;;;CAA0D,iBAqB3D,CAAC"}
@@ -64,18 +64,41 @@ export function schemaConfig(name, inDir, outDir) {
64
64
  },
65
65
  };
66
66
  }
67
- export const generateSchema = (model, inDir, { watch = false, skipFormat = false, outDir = inDir, verbose = true } = {}) => {
67
+ export const generateSchema = async (model, inDir, { watch = false, skipFormat = false, outDir = inDir, verbose = true } = {}) => {
68
68
  const documentModelConfig = schemaConfig(model, inDir, outDir);
69
69
  const config = {
70
70
  overwrite: true,
71
71
  generates: documentModelConfig,
72
72
  watch,
73
73
  silent: !verbose,
74
- hooks: {
75
- beforeOneFileWrite: skipFormat ? [] : [formatWithPrettierBeforeWrite],
76
- },
77
74
  };
78
- return generate(config, !verbose);
75
+ // GraphQL Codegen hooks are not working reliably - write files manually
76
+ const fs = await import("node:fs");
77
+ const path = await import("node:path");
78
+ const result = (await generate(config, !verbose));
79
+ for (const fileResult of result) {
80
+ const { filename, content } = fileResult;
81
+ const fullPath = path.resolve(filename);
82
+ const dir = path.dirname(fullPath);
83
+ // Ensure directory exists
84
+ fs.mkdirSync(dir, { recursive: true });
85
+ // Write content (content is already typed as string)
86
+ let finalContent = content;
87
+ // Format if not skipped
88
+ if (!skipFormat) {
89
+ try {
90
+ const { format } = await import("prettier");
91
+ finalContent = await format(content, { parser: "typescript" });
92
+ }
93
+ catch (error) {
94
+ if (verbose) {
95
+ console.warn(`Failed to format ${filename}:`, error);
96
+ }
97
+ }
98
+ }
99
+ fs.writeFileSync(fullPath, finalContent);
100
+ }
101
+ return result;
79
102
  };
80
103
  export const generateSchemas = (inDir, { watch = false, skipFormat = false, outDir = inDir } = {}) => {
81
104
  const documentModels = getDirectories(inDir);
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../src/codegen/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE,CACxC,WAAW,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;KACzC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;KACxC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,yBAAyB;IAClC,GAAI,iBAA4C;CACjD,CAAC;AAEF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AK,EAAE,GAAG,EAAE,EAC1D,EAAE;IACF,MAAM,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,oBAAoB,GAAG,cAAc,CAAC,MAAM,CAChD,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACf,GAAG,GAAG;QACN,GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;KACtC,CAAC,EACF,EAAE,CACH,CAAC;IAEF,MAAM,MAAM,GAAkB;QAC5B,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,oBAAoB;QAC/B,KAAK;QACL,KAAK,EAAE;YACL,kBAAkB,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,6BAA6B,CAAC;SACtE;KACF,CAAC;IAEF,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC"}
@@ -5,15 +5,18 @@ export declare function run(args: string[], { watch, skipFormat, verbose }?: {
5
5
  skipFormat?: boolean | undefined;
6
6
  verbose?: boolean | undefined;
7
7
  }): Promise<import("hygen/dist/types.js").RunnerResult>;
8
- export declare function generateAll(dir: string, { watch, skipFormat, verbose }?: {
8
+ export declare function generateAll(dir: string, { watch, skipFormat, verbose, force }?: {
9
9
  watch?: boolean | undefined;
10
10
  skipFormat?: boolean | undefined;
11
11
  verbose?: boolean | undefined;
12
+ force?: boolean | undefined;
12
13
  }): Promise<void>;
13
- export declare function generateDocumentModel(documentModelState: DocumentModelState, dir: string, { watch, skipFormat, verbose }?: {
14
+ export declare function generateDocumentModel(documentModelState: DocumentModelState, dir: string, { watch, skipFormat, verbose, generateReducers, force, }?: {
14
15
  watch?: boolean | undefined;
15
16
  skipFormat?: boolean | undefined;
16
17
  verbose?: boolean | undefined;
18
+ generateReducers?: boolean | undefined;
19
+ force?: boolean | undefined;
17
20
  }): Promise<void>;
18
21
  export declare function generateEditor(name: string, documentTypes: string[], documentTypesMap: DocumentTypesMap, dir: string, documentModelsDir: string, { skipFormat, verbose }?: {
19
22
  skipFormat?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"hygen.d.ts","sourceRoot":"","sources":["../../../src/codegen/hygen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMzD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AASnD,wBAAsB,GAAG,CACvB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,KAAa,EAAE,UAAkB,EAAE,OAAc,EAAE;;;;CAAK,uDAuC3D;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,EAAE,KAAa,EAAE,UAAkB,EAAE,OAAc,EAAE;;;;CAAK,iBA0B3D;AAED,wBAAsB,qBAAqB,CACzC,kBAAkB,EAAE,kBAAkB,EACtC,GAAG,EAAE,MAAM,EACX,EAAE,KAAa,EAAE,UAAkB,EAAE,OAAc,EAAE;;;;CAAK,iBAoC3D;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EAAE,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,MAAM,EACzB,EAAE,UAAkB,EAAE,OAAc,EAAE;;;CAAK,iBAoB5C;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EAAE,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,WAAW,GAAG,cAAc,EAClC,EAAE,UAAkB,EAAE,OAAc,EAAE;;;CAAK,iBAuB5C;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,kBAAkB,GAAG,IAAI,EACxC,GAAG,EAAE,MAAM,EACX,EAAE,UAAkB,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,EACzB,IAAI,EAAE,WAAW,GAAG,cAAc,EAClC,EAAE,UAAkB,EAAE,OAAc,EAAE;;;CAAK,iBAuB5C;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,kBAAkB,GAAG,IAAI,EACxC,GAAG,EAAE,MAAM,EACX,EAAE,UAAkB,EAAE,OAAc,EAAE;;;CAAK,iBAgD5C;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,EAAE,UAAkB,EAAE,OAAc,EAAE;;;CAAK,iBAgB5C;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,EAAE,UAAkB,EAAE;;CAAK,iBAO5B"}
@@ -4,6 +4,7 @@ import fs from "node:fs";
4
4
  import { createRequire } from "node:module";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
+ import { TSMorphCodeGenerator } from "../ts-morph-generator/core/TSMorphCodeGenerator.js";
7
8
  import { loadDocumentModel } from "./utils.js";
8
9
  const require = createRequire(import.meta.url);
9
10
  const __dirname = import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));
@@ -42,8 +43,9 @@ export async function run(args, { watch = false, skipFormat = false, verbose = t
42
43
  }
43
44
  return result;
44
45
  }
45
- export async function generateAll(dir, { watch = false, skipFormat = false, verbose = true } = {}) {
46
+ export async function generateAll(dir, { watch = false, skipFormat = false, verbose = true, force = true } = {}) {
46
47
  const files = fs.readdirSync(dir, { withFileTypes: true });
48
+ const documentModelStates = [];
47
49
  for (const directory of files.filter((f) => f.isDirectory())) {
48
50
  const documentModelPath = path.join(dir, directory.name, `${directory.name}.json`);
49
51
  if (!fs.existsSync(documentModelPath)) {
@@ -51,10 +53,13 @@ export async function generateAll(dir, { watch = false, skipFormat = false, verb
51
53
  }
52
54
  try {
53
55
  const documentModel = await loadDocumentModel(documentModelPath);
56
+ documentModelStates.push(documentModel);
54
57
  await generateDocumentModel(documentModel, dir, {
55
58
  watch,
56
59
  skipFormat,
57
60
  verbose,
61
+ generateReducers: false,
62
+ force,
58
63
  });
59
64
  }
60
65
  catch (error) {
@@ -63,8 +68,17 @@ export async function generateAll(dir, { watch = false, skipFormat = false, verb
63
68
  }
64
69
  }
65
70
  }
71
+ const projectDir = path.dirname(dir);
72
+ const documentModelDir = path.basename(dir);
73
+ const generator = new TSMorphCodeGenerator(projectDir, documentModelStates, {
74
+ directories: { documentModelDir },
75
+ forceUpdate: force,
76
+ });
77
+ await generator.generateReducers();
66
78
  }
67
- export async function generateDocumentModel(documentModelState, dir, { watch = false, skipFormat = false, verbose = true } = {}) {
79
+ export async function generateDocumentModel(documentModelState, dir, { watch = false, skipFormat = false, verbose = true, generateReducers = true, force = true, } = {}) {
80
+ const projectDir = path.dirname(dir);
81
+ const documentModelDir = path.basename(dir);
68
82
  // Generate the singular files for the document model logic
69
83
  await run([
70
84
  "powerhouse",
@@ -88,6 +102,10 @@ export async function generateDocumentModel(documentModelState, dir, { watch = f
88
102
  module.name,
89
103
  ], { watch, skipFormat, verbose });
90
104
  }
105
+ if (generateReducers) {
106
+ const generator = new TSMorphCodeGenerator(projectDir, [documentModelState], { directories: { documentModelDir }, forceUpdate: force });
107
+ await generator.generateReducers();
108
+ }
91
109
  }
92
110
  export async function generateEditor(name, documentTypes, documentTypesMap, dir, documentModelsDir, { skipFormat = false, verbose = true } = {}) {
93
111
  // Generate the singular files for the document model logic
@@ -155,6 +173,16 @@ export async function generateSubgraph(name, documentModel, dir, { skipFormat =
155
173
  dir,
156
174
  ], { skipFormat, verbose });
157
175
  }
176
+ else {
177
+ await run([
178
+ "powerhouse",
179
+ "generate-custom-subgraph",
180
+ "--subgraph",
181
+ name,
182
+ "--root-dir",
183
+ dir,
184
+ ], { skipFormat, verbose });
185
+ }
158
186
  }
159
187
  export async function generateImportScript(name, dir, { skipFormat = false, verbose = true } = {}) {
160
188
  // Generate the singular files for the document model logic
@@ -1 +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,wCAAwC;QACxC,MAAM,GAAG,CACP;YACE,YAAY;YACZ,kCAAkC;YAClC,YAAY;YACZ,IAAI;YACJ,kBAAkB;YAClB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;YAC7B,YAAY;YACZ,GAAG;SACJ,EACD,EAAE,UAAU,EAAE,OAAO,EAAE,CACxB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CACP;YACE,YAAY;YACZ,0BAA0B;YAC1B,YAAY;YACZ,IAAI;YACJ,YAAY;YACZ,GAAG;SACJ,EACD,EAAE,UAAU,EAAE,OAAO,EAAE,CACxB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAY,EACZ,GAAW,EACX,EAAE,UAAU,GAAG,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,EAAE;IAE3C,2DAA2D;IAC3D,MAAM,GAAG,CACP;QACE,YAAY;QACZ,wBAAwB;QACxB,QAAQ;QACR,IAAI;QACJ,cAAc;QACd,UAAU,CAAC,IAAI,CAAC;QAChB,YAAY;QACZ,GAAG;KACJ,EACD,EAAE,UAAU,EAAE,OAAO,EAAE,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAY,EACZ,GAAW,EACX,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,EAAE;IAE3B,kCAAkC;IAClC,MAAM,GAAG,CACP,CAAC,YAAY,EAAE,uBAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,CAAC,EAC1E,EAAE,UAAU,EAAE,CACf,CAAC;AACJ,CAAC"}
@@ -1,8 +1,9 @@
1
- import { type PowerhouseConfig } from "@powerhousedao/config/powerhouse";
1
+ import { type PartialPowerhouseManifest, type PowerhouseConfig } from "@powerhousedao/config/powerhouse";
2
2
  import { type DocumentModelState } from "document-model";
3
3
  export { generateDBSchema } from "./kysely.js";
4
4
  export type CodegenOptions = {
5
5
  verbose?: boolean;
6
+ force?: boolean;
6
7
  };
7
8
  export declare function generate(config: PowerhouseConfig): Promise<void>;
8
9
  export declare function generateFromFile(path: string, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
@@ -21,9 +22,8 @@ export declare function generateFromFile(path: string, config: PowerhouseConfig,
21
22
  */
22
23
  export declare function generateFromDocument(documentModelState: DocumentModelState, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
23
24
  export declare function generateEditor(name: string, documentTypes: string[], config: PowerhouseConfig): Promise<void>;
24
- export declare function generateSubgraph(name: string, file: string | null, config: PowerhouseConfig, options?: {
25
- verbose?: boolean;
26
- }): Promise<void>;
25
+ export declare function generateSubgraphFromDocumentModel(name: string, documentModel: DocumentModelState, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
26
+ export declare function generateSubgraph(name: string, file: string | null, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
27
27
  export declare function generateProcessor(name: string, type: "analytics" | "relationalDb", documentTypes: string[], config: PowerhouseConfig): Promise<void>;
28
28
  export type DocumentTypesMap = Record<string, {
29
29
  name: string;
@@ -31,4 +31,5 @@ export type DocumentTypesMap = Record<string, {
31
31
  }>;
32
32
  export declare function generateDriveEditor(name: string, config: PowerhouseConfig): Promise<void>;
33
33
  export declare function generateImportScript(name: string, config: PowerhouseConfig): Promise<void>;
34
+ export declare function generateManifest(manifestData: PartialPowerhouseManifest, projectRoot?: string): string;
34
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAexB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAA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Z,MAAM,EAAE,gBAAgB,iBAKzB;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,gBAAgB,iBAKzB;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,yBAAyB,EACvC,WAAW,CAAC,EAAE,MAAM,UAqDrB"}
@@ -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
- const { verbose = false } = options;
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
  }
@@ -148,6 +153,12 @@ export async function generateEditor(name, documentTypes, config) {
148
153
  }
149
154
  return _generateEditor(name, documentTypes, documentTypesMap, config.editorsDir, config.documentModelsDir, { skipFormat });
150
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
+ });
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 });
153
164
  }
@@ -170,4 +181,52 @@ 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
+ // Merge partial data with existing manifest
215
+ const updatedManifest = {
216
+ ...existingManifest,
217
+ ...manifestData,
218
+ publisher: {
219
+ ...existingManifest.publisher,
220
+ ...(manifestData.publisher || {}),
221
+ },
222
+ documentModels: manifestData.documentModels || existingManifest.documentModels,
223
+ editors: manifestData.editors || existingManifest.editors,
224
+ apps: manifestData.apps || existingManifest.apps,
225
+ subgraphs: manifestData.subgraphs || existingManifest.subgraphs,
226
+ importScripts: manifestData.importScripts || existingManifest.importScripts,
227
+ };
228
+ // Write updated manifest to file
229
+ fs.writeFileSync(manifestPath, JSON.stringify(updatedManifest, null, 4));
230
+ return manifestPath;
231
+ }
173
232
  //# sourceMappingURL=index.js.map