@powerhousedao/vetra 6.2.3-dev.79 โ†’ 6.2.3-dev.80

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.
@@ -1 +1 @@
1
- {"version":3,"file":"processor-C_zliXhw.js","names":["installFeatureDependencies","installForFeatures","installFeatureDependencies","installFeatureDependencies"],"sources":["../processors/codegen/document-handlers/base-document-gen.ts","../processors/codegen/interactive-manager.ts","../processors/codegen/written-files.ts","../processors/codegen/document-handlers/document-codegen-manager.ts","../processors/codegen/document-handlers/generators/utils.ts","../processors/codegen/document-handlers/generators/app-generator.ts","../processors/codegen/document-handlers/generators/document-editor-generator.ts","../processors/codegen/document-handlers/generators/document-model-generator.ts","../processors/codegen/document-handlers/generators/package-generator.ts","../processors/codegen/document-handlers/generators/processor-generator.ts","../processors/codegen/document-handlers/generators/subgraph-generator.ts","../processors/codegen/document-handlers/document-codegen-factory.ts","../processors/codegen/processor.ts"],"sourcesContent":["import type { Project } from \"ts-morph\";\nimport type {\n CodegenInput,\n CodegenJob,\n Config,\n GenerateResult,\n} from \"./types.js\";\n\n/** The base of the generators, one per document type or set of types. */\nexport abstract class BaseDocumentGen {\n /** The document type or types this generator handles. */\n abstract readonly supportedDocumentTypes: string | string[];\n project: Project;\n\n constructor(\n protected config: Config,\n project: Project,\n ) {\n this.project = project;\n }\n\n /** Generates code for the document; throws when generation fails. */\n abstract generate(\n strand: CodegenInput,\n job?: CodegenJob,\n ): Promise<GenerateResult>;\n\n supportsDocumentType(documentType: string): boolean {\n if (typeof this.supportedDocumentTypes === \"string\") {\n return this.supportedDocumentTypes === documentType;\n }\n return this.supportedDocumentTypes.includes(documentType);\n }\n\n getSupportedDocumentTypes(): string[] {\n if (typeof this.supportedDocumentTypes === \"string\") {\n return [this.supportedDocumentTypes];\n }\n return [...this.supportedDocumentTypes];\n }\n\n /** The module's name in the strand's state, for its codegen status. */\n moduleName(strand: CodegenInput): string | undefined {\n const state = strand.state as { global?: { name?: unknown } } | undefined;\n const name = state?.global?.name;\n return typeof name === \"string\" && name !== \"\" ? name : undefined;\n }\n\n /** Why this strand is not generated from; undefined when it is. */\n skipReason(strand: CodegenInput): string | undefined {\n if (!strand.documentId || !strand.documentType) {\n return \"The operation names no document\";\n }\n if (!this.supportsDocumentType(strand.documentType)) {\n return `No generator for document type ${strand.documentType}`;\n }\n return undefined;\n }\n\n shouldProcess(strand: CodegenInput): boolean {\n return this.skipReason(strand) === undefined;\n }\n}\n","import { createInterface } from \"node:readline\";\nimport type { CodegenInput } from \"./document-handlers/types.js\";\nimport { logger } from \"./logger.js\";\n\nexport interface QueuedStrand {\n strand: CodegenInput;\n timestamp: number;\n}\n\n/**\n * InteractiveManager handles user interaction for code generation confirmation\n * Supports both individual strand processing and queue-based batch processing\n */\nexport class InteractiveManager {\n private isInteractiveMode: boolean;\n private processingConfirmation = false;\n private strandQueue = new Map<string, QueuedStrand>();\n\n constructor(interactiveMode = false) {\n this.isInteractiveMode = interactiveMode;\n }\n\n private getDocumentKey(documentType: string, documentId: string): string {\n return `${documentType}:${documentId}`;\n }\n\n /**\n * Add a strand to the queue, replacing any existing strand for the same document\n */\n public queueStrand(strand: CodegenInput): void {\n const documentKey = this.getDocumentKey(\n strand.documentType,\n strand.documentId,\n );\n\n this.strandQueue.set(documentKey, {\n strand,\n timestamp: Date.now(),\n });\n\n logger.debug(\n `>>> Queued strand for ${documentKey}, queue size: ${this.strandQueue.size}`,\n );\n }\n\n /**\n * Drop the queued strands the predicate matches\n */\n public discardWhere(predicate: (strand: CodegenInput) => boolean): void {\n for (const [key, queued] of this.strandQueue) {\n if (predicate(queued.strand)) this.strandQueue.delete(key);\n }\n }\n\n /**\n * Get all queued strands\n */\n public getQueuedStrands(): QueuedStrand[] {\n return Array.from(this.strandQueue.values());\n }\n\n /**\n * Clear and return all queued strands\n */\n public clearQueue(): QueuedStrand[] {\n const queuedStrands = Array.from(this.strandQueue.values());\n this.strandQueue.clear();\n return queuedStrands;\n }\n\n /**\n * Get the current queue size\n */\n public getQueueSize(): number {\n return this.strandQueue.size;\n }\n\n private async promptUserConfirmation(): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"๐Ÿ”„ Code generation ready to run.\");\n console.log(\"=\".repeat(50));\n\n process.stdout.write(\n \"Do you want to proceed with code generation? (y/n): \\n\\n\",\n );\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n console.log(\"\"); // Add blank line after user input\n resolve(answer.toLowerCase() === \"y\" || answer.toLowerCase() === \"yes\");\n });\n });\n }\n\n /**\n * Process generation with user confirmation (legacy single-strand method)\n * This method assumes interactive mode is already enabled (checked by caller)\n */\n public async processWithConfirmation<T>(\n documentType: string,\n generator: () => Promise<T>,\n ): Promise<T | null> {\n if (this.processingConfirmation) {\n logger.debug(\"Already processing confirmation, skipping\");\n return null;\n }\n\n this.processingConfirmation = true;\n\n try {\n // Always prompt user since this method only called in interactive mode\n const shouldProceed = await this.promptUserConfirmation();\n\n if (!shouldProceed) {\n logger.info(`โŒ Code generation cancelled by user for ${documentType}`);\n return null;\n }\n\n logger.info(`โœ… User approved code generation for ${documentType}`);\n\n const result = await generator();\n return result;\n } catch (error) {\n logger.error(\n `โŒ Error during interactive code generation for ${documentType}:`,\n error,\n );\n throw error;\n } finally {\n this.processingConfirmation = false;\n }\n }\n\n /**\n * Process all queued strands with a single user confirmation\n * This is the main method for queue-based interactive processing\n */\n public async processQueueWithConfirmation(\n processor: (strands: QueuedStrand[]) => Promise<void>,\n onCancel?: (strands: QueuedStrand[]) => void,\n ): Promise<void> {\n if (this.processingConfirmation) {\n logger.debug(\n \"Already processing confirmation, skipping queue processing\",\n );\n return;\n }\n\n // Check if there are any strands to process\n let queuedStrands = this.getQueuedStrands();\n if (queuedStrands.length === 0) {\n logger.debug(\"No strands in queue to process\");\n return;\n }\n\n this.processingConfirmation = true;\n\n try {\n // Prompt user for confirmation\n const shouldProceed = await this.promptUserConfirmation();\n\n if (!shouldProceed) {\n logger.info(\"โŒ Code generation cancelled by user\");\n onCancel?.(this.clearQueue());\n return;\n }\n\n // Get and clear the final queue state right before processing\n // (in case new strands were added while waiting for user input)\n queuedStrands = this.clearQueue();\n if (queuedStrands.length === 0) {\n logger.info(\"โ„น๏ธ No documents to process\");\n return;\n }\n\n logger.info(\n `โœ… User approved code generation for ${queuedStrands.length} document(s)`,\n );\n\n // Process all queued strands\n await processor(queuedStrands);\n logger.info(\"โœ… Code generation completed\");\n } catch (error) {\n logger.error(\n \"โŒ Error during interactive queue processing: @error\",\n error,\n );\n throw error;\n } finally {\n this.processingConfirmation = false;\n }\n }\n\n public setInteractiveMode(enabled: boolean): void {\n this.isInteractiveMode = enabled;\n logger.debug(`Interactive mode set to: ${enabled}`);\n }\n\n public isInteractive(): boolean {\n return this.isInteractiveMode;\n }\n\n public isProcessing(): boolean {\n return this.processingConfirmation;\n }\n}\n","import type { Dirent } from \"node:fs\";\nimport { readdir, stat } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\n\nconst SKIPPED_DIRS = new Set([\"node_modules\", \"dist\", \"backup-documents\"]);\nconst MAX_FILES = 500;\n\n/** The project's files modified at or after `since`, relative and sorted. */\nexport async function filesWrittenSince(\n projectDir: string,\n since: number,\n): Promise<string[]> {\n const written: string[] = [];\n const visit = async (dir: string): Promise<void> => {\n let entries: Dirent[];\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (written.length >= MAX_FILES) return;\n const path = join(dir, entry.name);\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\") || SKIPPED_DIRS.has(entry.name)) {\n continue;\n }\n await visit(path);\n } else if (entry.isFile()) {\n try {\n if ((await stat(path)).mtimeMs >= since) {\n written.push(relative(projectDir, path).replaceAll(\"\\\\\", \"/\"));\n }\n } catch {\n // Removed while listing.\n }\n }\n }\n };\n await visit(projectDir);\n return written.sort();\n}\n","import { afterPendingInstalls, installsPending } from \"@powerhousedao/codegen\";\nimport {\n type CodegenState,\n type CodegenStatusRegistry,\n getCodegenStatusRegistry,\n} from \"@powerhousedao/shared/processors\";\nimport type { Project } from \"ts-morph\";\nimport type { QueuedStrand } from \"../interactive-manager.js\";\nimport { InteractiveManager } from \"../interactive-manager.js\";\nimport { logger } from \"../logger.js\";\nimport { filesWrittenSince } from \"../written-files.js\";\nimport type { BaseDocumentGen } from \"./base-document-gen.js\";\nimport type { CodegenInput, CodegenJob, Config } from \"./types.js\";\n\nconst DEFAULT_DEBOUNCE_TIME = 1000; // wait 1 second between codegen calls\nconst MODULE_NOT_FOUND_CODES = new Set([\n \"ERR_MODULE_NOT_FOUND\",\n \"MODULE_NOT_FOUND\",\n \"ERR_PACKAGE_PATH_NOT_EXPORTED\",\n]);\nconst MODULE_NOT_FOUND_MESSAGE =\n /Cannot find (module|package)|Failed to resolve (import|entry)|Failed to load url/;\n\n/** Whether a document belongs to what this manager generates from. */\nexport type DocumentScope = (documentId: string) => Promise<boolean>;\n\n/**\n * Manager class responsible for routing documents to the correct generator\n * and managing generator registration and instantiation\n */\nexport class DocumentCodegenManager {\n project: Project;\n private generators = new Map<string, BaseDocumentGen>();\n private debounceTimers = new Map<string, NodeJS.Timeout>();\n // One job at a time, so none runs while another job's install relinks node_modules.\n private jobs: Promise<void> = Promise.resolve();\n private queuedJobs = new Map<string, CodegenInput>();\n private runningJobs = 0;\n /** The wait before retrying a module-resolution failure when no install is queued. */\n retryDelayMs = 3000;\n private interactiveManager: InteractiveManager;\n private isInScope: DocumentScope = () => Promise.resolve(true);\n readonly status: CodegenStatusRegistry;\n\n constructor(\n private config: Config,\n project: Project,\n interactiveMode = false,\n status: CodegenStatusRegistry = getCodegenStatusRegistry(),\n ) {\n this.project = project;\n this.interactiveManager = new InteractiveManager(interactiveMode);\n this.status = status;\n }\n\n /**\n * Limit generation to the documents `isInScope` accepts, checked when the\n * debounce fires\n */\n setScope(isInScope: DocumentScope): void {\n this.isInScope = isInScope;\n }\n\n /**\n * Register a generator class for a specific document type\n */\n registerGenerator(\n documentType: string,\n generatorClass: new (config: Config, project: Project) => BaseDocumentGen,\n ): void {\n if (this.generators.has(documentType)) {\n logger.warn(\n `โš ๏ธ Generator for document type \"${documentType}\" is already registered. Overwriting.`,\n );\n }\n\n this.generators.set(\n documentType,\n new generatorClass(this.config, this.project),\n );\n logger.debug(`โœ… Registered generator for document type: ${documentType}`);\n }\n\n /**\n * Register a generator class that supports multiple document types\n */\n registerMultiTypeGenerator(\n generatorClass: new (config: Config, project: Project) => BaseDocumentGen,\n ): void {\n const generator = new generatorClass(this.config, this.project);\n const supportedTypes = generator.getSupportedDocumentTypes();\n\n for (const documentType of supportedTypes) {\n if (this.generators.has(documentType)) {\n logger.warn(\n `โš ๏ธ Generator for document type \"${documentType}\" is already registered. Overwriting.`,\n );\n }\n this.generators.set(documentType, generator);\n }\n\n logger.debug(\n `โœ… Registered multi-type generator for document types: ${supportedTypes.join(\", \")}`,\n );\n }\n\n /**\n * Get a generator instance for the given document type\n * Public method to allow external access for validation\n */\n public getGenerator(documentType: string): BaseDocumentGen | undefined {\n return this.generators.get(documentType);\n }\n\n /**\n * Get all registered document types\n */\n getRegisteredDocumentTypes(): string[] {\n return Array.from(this.generators.keys());\n }\n\n /**\n * Check if a document type is supported\n */\n isDocumentTypeSupported(documentType: string): boolean {\n return this.generators.has(documentType);\n }\n\n /**\n * Route a document to the appropriate generator and handle the generation\n * Handles both interactive and non-interactive modes with queue-based processing\n */\n routeAndGenerate(strand: CodegenInput): Promise<void> {\n const documentType = strand.documentType;\n\n if (!documentType) {\n logger.error(\"โŒ Document type is missing from strand state\");\n throw new Error(\"Document type is missing from strand state\");\n }\n\n const generator = this.getGenerator(documentType);\n\n if (!generator) {\n logger.warn(`โš ๏ธ No generator found for document type: ${documentType}`);\n logger.warn(\n `โ„น๏ธ Supported document types: ${this.getRegisteredDocumentTypes().join(\", \")}`,\n );\n throw new Error(`Unsupported document type: ${documentType}`);\n }\n\n // Scope and validation are checked when the debounce fires, on the\n // document's final state.\n this.status.set({\n documentId: strand.documentId,\n documentType,\n state: \"queued\",\n message: this.interactiveManager.isInteractive()\n ? \"Waiting for confirmation in the terminal running Vetra\"\n : \"Waiting for the document's changes to settle\",\n });\n // Different flow for interactive vs non-interactive mode\n if (this.interactiveManager.isInteractive()) {\n // Interactive mode: queue strands and use debounce timer to trigger batch processing\n logger.debug(\n `>>> Queueing strand for interactive processing: ${documentType}:${strand.documentId}`,\n );\n\n // Add strand to queue (will replace any existing strand for same document)\n this.interactiveManager.queueStrand(strand);\n\n // Clear any existing debounce timer for interactive processing\n const existingTimer = this.debounceTimers.get(\"interactive\");\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n\n // Set up debounce timer for batch interactive processing\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const debounceTimer = setTimeout(async () => {\n try {\n const rejected = new Set<CodegenInput>();\n for (const { strand } of this.interactiveManager.getQueuedStrands()) {\n if (!(await this.accepts(strand))) rejected.add(strand);\n }\n this.interactiveManager.discardWhere((queued) =>\n rejected.has(queued),\n );\n await this.interactiveManager.processQueueWithConfirmation(\n async (queuedStrands: QueuedStrand[]) => {\n await this.processQueuedStrands(queuedStrands);\n },\n (cancelled) => {\n for (const { strand } of cancelled) {\n this.setStatus(strand, \"skipped\", \"Cancelled in the terminal\");\n }\n },\n );\n } catch (error) {\n logger.error(\n \"โŒ Error during interactive batch processing: @error\",\n error,\n );\n } finally {\n // Clean up the timer reference\n this.debounceTimers.delete(\"interactive\");\n }\n }, DEFAULT_DEBOUNCE_TIME);\n\n // Store the timer reference using 'interactive' key\n this.debounceTimers.set(\"interactive\", debounceTimer);\n } else {\n // Non-interactive mode: use debouncing per document instance\n // Create unique key for this specific document instance\n const timerKey = `${documentType}:${strand.documentId}`;\n\n // Clear any existing debounce timer for this document instance\n const existingTimer = this.debounceTimers.get(timerKey);\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n\n // Set up new debounced generation (no interactive confirmation)\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const debounceTimer = setTimeout(async () => {\n try {\n if (!(await this.accepts(strand))) return;\n logger.debug(\n `๐Ÿ”„ Routing document type \"${documentType}\" to generator (debounced)`,\n );\n await this.enqueueJob(strand);\n } finally {\n // Clean up the timer reference\n this.debounceTimers.delete(timerKey);\n }\n }, DEFAULT_DEBOUNCE_TIME);\n\n // Store the timer reference\n this.debounceTimers.set(timerKey, debounceTimer);\n }\n return Promise.resolve();\n }\n\n /** In scope first, so documents out of scope are never validated or logged. */\n private async accepts(strand: CodegenInput): Promise<boolean> {\n const generator = this.getGenerator(strand.documentType);\n if (!generator) return false;\n if (!(await this.isInScope(strand.documentId))) {\n logger.debug(\n `Document ${strand.documentId} is not in the Vetra drive, skipping codegen`,\n );\n this.status.delete(strand.documentId);\n this.queuedJobs.delete(strand.documentId);\n return false;\n }\n const reason = generator.skipReason(strand);\n if (reason !== undefined) {\n this.setStatus(strand, \"skipped\", reason);\n this.queuedJobs.delete(strand.documentId);\n return false;\n }\n return true;\n }\n\n /** Queues a job; one already queued for the document runs the latest strand. */\n private enqueueJob(strand: CodegenInput): Promise<void> {\n const { documentId } = strand;\n const alreadyQueued = this.queuedJobs.has(documentId);\n this.queuedJobs.set(documentId, strand);\n if (this.runningJobs > 0) {\n this.setStatus(\n strand,\n \"queued\",\n \"Waiting for codegen of other documents to finish\",\n );\n }\n if (alreadyQueued) return this.jobs;\n this.jobs = this.jobs.then(async () => {\n const latest = this.queuedJobs.get(documentId);\n this.queuedJobs.delete(documentId);\n const generator = latest && this.getGenerator(latest.documentType);\n if (!latest || !generator) return;\n this.runningJobs++;\n try {\n await this.runJob(latest, generator);\n } finally {\n this.runningJobs--;\n }\n });\n return this.jobs;\n }\n\n /** Runs a job after pending installs, once more after a module-resolution failure. */\n private async runJob(\n strand: CodegenInput,\n generator: BaseDocumentGen,\n ): Promise<void> {\n await this.afterInstalls(\n strand,\n \"Waiting for a dependency install to finish\",\n );\n const error = await this.attempt(strand, generator);\n if (error === undefined) return;\n if (!isModuleResolutionError(error)) {\n this.setStatus(strand, \"failed\", errorMessage(error));\n return;\n }\n logger.warn(\n `Codegen for ${strand.documentType} ${strand.documentId} could not resolve a module; retrying once installs finish: ${errorMessage(error)}`,\n );\n const waited = await this.afterInstalls(\n strand,\n `Retrying once dependency installs finish, after: ${errorMessage(error)}`,\n );\n if (!waited) {\n await new Promise((resolve) => setTimeout(resolve, this.retryDelayMs));\n }\n const retryError = await this.attempt(strand, generator);\n if (retryError !== undefined) {\n this.setStatus(\n strand,\n \"failed\",\n `${errorMessage(retryError)} (also after a retry; if an install is running, run it to the end, then change the document again)`,\n );\n }\n }\n\n /** Waits for queued installs, saying so; resolves to whether any was queued. */\n private async afterInstalls(\n strand: CodegenInput,\n message: string,\n ): Promise<boolean> {\n if (!installsPending()) return false;\n this.setStatus(strand, \"waiting-for-install\", message);\n await afterPendingInstalls();\n return true;\n }\n\n /** Generates once; records done or skipped, or resolves to the error. */\n private async attempt(\n strand: CodegenInput,\n generator: BaseDocumentGen,\n ): Promise<unknown> {\n const startedAt = Date.now();\n const job: CodegenJob = {\n waitingForInstall: (message) =>\n this.setStatus(strand, \"waiting-for-install\", message),\n running: () => this.setStatus(strand, \"running\"),\n };\n job.running();\n try {\n const result = await generator.generate(strand, job);\n if (result) {\n this.setStatus(strand, \"skipped\", result.skipped);\n return;\n }\n const files = await filesWrittenSince(\n this.config.CURRENT_WORKING_DIR,\n startedAt,\n );\n this.setStatus(strand, \"done\", undefined, files);\n logger.debug(\n `โœ… Successfully generated code for document type: ${strand.documentType}`,\n );\n return undefined;\n } catch (error) {\n logger.error(\n `โŒ Error generating code for document type \"${strand.documentType}\":`,\n error,\n );\n return error ?? new Error(\"Codegen failed\");\n }\n }\n\n private setStatus(\n strand: CodegenInput,\n state: CodegenState,\n message?: string,\n files?: string[],\n ): void {\n this.status.set({\n documentId: strand.documentId,\n documentType: strand.documentType,\n name: this.getGenerator(strand.documentType)?.moduleName(strand),\n state,\n message,\n files,\n });\n }\n\n /**\n * Process multiple strands in priority order (document-model types first)\n */\n private async processQueuedStrands(\n queuedStrands: QueuedStrand[],\n ): Promise<void> {\n logger.debug(`๐Ÿ”„ Processing ${queuedStrands.length} queued strand(s)`);\n\n // Sort by priority (document-model first to ensure dependencies exist)\n const documentModelStrands = queuedStrands.filter(\n (qs: QueuedStrand) =>\n qs.strand.documentType === \"powerhouse/document-model\",\n );\n const otherStrands = queuedStrands.filter(\n (qs: QueuedStrand) =>\n qs.strand.documentType !== \"powerhouse/document-model\",\n );\n\n // Process document models first\n for (const queuedStrand of documentModelStrands) {\n await this.processStrand(queuedStrand.strand);\n }\n\n // Then process other document types\n for (const queuedStrand of otherStrands) {\n await this.processStrand(queuedStrand.strand);\n }\n\n logger.debug(\n `โœ… Successfully processed all ${queuedStrands.length} queued strand(s)`,\n );\n }\n\n /**\n * Process a single strand (used internally by processQueuedStrands)\n */\n private async processStrand(strand: CodegenInput): Promise<void> {\n const documentType = strand.documentType;\n const generator = this.getGenerator(documentType);\n\n if (!generator) {\n logger.warn(`โš ๏ธ No generator found for document type: ${documentType}`);\n return;\n }\n\n logger.debug(`๐Ÿ”„ Generating code for document type: ${documentType}`);\n await this.enqueueJob(strand);\n }\n\n /**\n * Clear all registered generators\n */\n clearGenerators(): void {\n this.generators.clear();\n logger.debug(\"๐Ÿงน Cleared all registered generators\");\n }\n\n /**\n * Get statistics about registered generators\n */\n getStats(): { totalGenerators: number; supportedTypes: string[] } {\n return {\n totalGenerators: this.generators.size,\n supportedTypes: this.getRegisteredDocumentTypes(),\n };\n }\n\n /**\n * Set interactive mode for code generation\n */\n setInteractiveMode(enabled: boolean): void {\n this.interactiveManager.setInteractiveMode(enabled);\n }\n\n /**\n * Check if interactive mode is enabled\n */\n isInteractiveMode(): boolean {\n return this.interactiveManager.isInteractive();\n }\n\n /**\n * Check if the manager is currently processing an interactive confirmation\n */\n isProcessingInteractive(): boolean {\n return this.interactiveManager.isProcessing();\n }\n}\n\nfunction isModuleResolutionError(error: unknown): boolean {\n for (let cause = error; cause instanceof Error; cause = cause.cause) {\n const code = (cause as NodeJS.ErrnoException).code;\n if (code && MODULE_NOT_FOUND_CODES.has(code)) return true;\n if (MODULE_NOT_FOUND_MESSAGE.test(cause.message)) return true;\n }\n return false;\n}\n\nfunction errorMessage(error: unknown): string {\n if (!(error instanceof Error)) return String(error);\n const cause = error.cause instanceof Error ? `: ${error.cause.message}` : \"\";\n return `${error.message}${cause}`;\n}\n","import {\n type Feature,\n installFeatureDependencies as installForFeatures,\n} from \"@powerhousedao/codegen\";\nimport type {\n MinimalBackupData,\n PHBaseState,\n PHDocument,\n PHDocumentHeader,\n} from \"@powerhousedao/shared/document-model\";\nimport { baseMinimalSaveToFile, baseSaveToFile } from \"document-model/node\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { lintSubgraphTypes } from \"../../../../codegen/subgraph-type-lint.js\";\nimport { logger } from \"../../logger.js\";\nimport type { CodegenJob } from \"../types.js\";\n\nconst BACKUP_FOLDER = \"backup-documents\";\n\n/**\n * Exports a document to the backup directory.\n * Creates the backup directory if it doesn't exist.\n *\n * @param document - The document to backup\n * @param workingDir - Current working directory\n * @param extension - File extension for the document type (without dot)\n * @param name - Name of the document to use for the backup file (optional)\n * @returns Promise resolving to the backup file path, or undefined if backup failed\n */\nexport async function backupDocument(\n document: PHDocument,\n workingDir: string,\n extension: string = \"\",\n name?: string,\n): Promise<string | undefined> {\n const docName = name ?? document.header.name;\n\n try {\n const backupPath = join(workingDir, BACKUP_FOLDER);\n await mkdir(backupPath, { recursive: true });\n\n const filePath = await baseSaveToFile(\n document,\n backupPath,\n extension,\n docName,\n );\n\n logger.debug(`๐Ÿ“ Document backed up to: ${filePath}`);\n return filePath;\n } catch (error) {\n logger.warn(`โš ๏ธ Failed to backup document \"${docName}\":`, error);\n return undefined;\n }\n}\n\n/**\n * Creates a minimal backup of a document from strand data.\n * Used when the full document is not available (e.g., in onOperations handler).\n */\nexport async function minimalBackupDocument(\n data: MinimalBackupData,\n workingDir: string,\n extension?: string,\n): Promise<string | undefined> {\n // The reactor's resultingState carries the document header alongside the\n // state scopes; lift its protocol versions into the backup header.\n const { header, ...state } = data.state as PHBaseState & {\n header?: PHDocumentHeader;\n };\n\n try {\n const backupPath = join(workingDir, BACKUP_FOLDER);\n await mkdir(backupPath, { recursive: true });\n\n const filePath = await baseMinimalSaveToFile(\n {\n ...data,\n state,\n protocolVersions: data.protocolVersions ?? header?.protocolVersions,\n },\n backupPath,\n extension ?? \"\",\n );\n\n logger.debug(`Document backed up to: ${filePath}`);\n return filePath;\n } catch (error) {\n logger.warn(`Failed to backup document \"${data.name}\":`, error);\n return undefined;\n }\n}\n\nexport async function warnSubgraphTypeConflicts(\n workingDir: string,\n): Promise<void> {\n let warnings: string[];\n try {\n warnings = await lintSubgraphTypes(workingDir);\n } catch (error) {\n logger.warn(\n `Failed to check subgraph type names: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n for (const warning of warnings) logger.warn(`โš ๏ธ ${warning}`);\n}\n\n/** Adds and installs what `features` need before their files are written:\n * the package loader reloads on those files, so their imports must resolve. */\nexport async function installFeatureDependencies(\n features: readonly Feature[],\n projectDir: string,\n waiting?: string,\n job?: CodegenJob,\n): Promise<void> {\n const install = { ran: false };\n try {\n await installForFeatures(features, projectDir, {\n log: (message) => logger.info(message),\n warn: (message) => logger.warn(`โš ๏ธ ${message}`),\n waiting,\n onInstall: (packages, command) => {\n install.ran = true;\n job?.waitingForInstall(\n `Installing ${packages.join(\", \")} with \\`${command}\\``,\n );\n },\n });\n } catch (error) {\n logger.warn(\n `โš ๏ธ Could not add the dependencies of ${features.join(\", \")}: ${(error as Error).message}`,\n );\n } finally {\n if (install.ran) job?.running();\n }\n}\n","import { generateApp } from \"@powerhousedao/codegen\";\nimport type {\n AppModuleGlobalState,\n AppModulePHState,\n} from \"@powerhousedao/vetra/document-models/app-module\";\nimport { kebabCase } from \"change-case\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, GenerateResult } from \"../types.js\";\nimport { minimalBackupDocument } from \"./utils.js\";\n\n/**\n * Generator for app documents\n */\nexport class AppGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/app\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): AppModuleGlobalState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as AppModulePHState;\n return fullState.global;\n }\n\n skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const state = this.extractGlobalState(input);\n let reason: string | undefined;\n if (!state) reason = \"The app has no state\";\n else if (!state.name) reason = \"The app has no name\";\n else if (state.status !== \"CONFIRMED\") {\n reason = `App \"${state.name}\" is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(input: CodegenInput): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n const reason = this.skipReason(input);\n if (!state || reason) {\n return { skipped: reason ?? \"The app has no state\" };\n }\n\n logger.info(`๐Ÿ”„ Starting app generation for app: ${state.name}`);\n try {\n await generateApp(\n {\n ...this.config.PH_CONFIG,\n appName: state.name,\n appId: kebabCase(state.name),\n allowedDocumentTypes: state.allowedDocumentTypes ?? [],\n isDragAndDropEnabled: state.isDragAndDropEnabled,\n },\n this.project,\n );\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during app generation for app ${state.name}:`,\n error,\n );\n throw error;\n }\n\n logger.info(\n `โœ… App generation completed successfully for app: ${state.name}`,\n );\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as AppModulePHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import { generateEditor } from \"@powerhousedao/codegen\";\nimport { kebabCase } from \"change-case\";\nimport type {\n DocumentEditorPHState,\n DocumentEditorState,\n} from \"../../../../document-models/document-editor/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, GenerateResult } from \"../types.js\";\nimport { minimalBackupDocument } from \"./utils.js\";\n\n/**\n * Generator for document editor documents\n */\nexport class DocumentEditorGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/document-editor\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): DocumentEditorState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as DocumentEditorPHState;\n return fullState.global;\n }\n\n skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const state = this.extractGlobalState(input);\n let reason: string | undefined;\n if (!state) reason = \"The editor has no state\";\n else if (!state.name) reason = \"The editor has no name\";\n else if (state.documentTypes.length === 0) {\n reason = `Editor \"${state.name}\" has no document types`;\n } else if (state.status !== \"CONFIRMED\") {\n reason = `Editor \"${state.name}\" is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(input: CodegenInput): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n if (!state) {\n return { skipped: \"The editor has no state\" };\n }\n\n logger.info(`๐Ÿ”„ Starting editor generation for: ${state.name}`);\n try {\n await generateEditor(\n {\n ...this.config.PH_CONFIG,\n editorName: state.name,\n documentTypes: state.documentTypes.map((dt) => dt.documentType),\n editorId: kebabCase(state.name),\n },\n this.project,\n );\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during editor generation for ${state.name}:`,\n error,\n );\n throw error;\n }\n\n logger.info(\n `โœ… Editor generation completed successfully for: ${state.name}`,\n );\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as DocumentEditorPHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import {\n generateDocumentModel,\n validateDocumentModelState,\n} from \"@powerhousedao/codegen\";\nimport type {\n DocumentModelGlobalState,\n DocumentModelPHState,\n} from \"@powerhousedao/shared/document-model\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput } from \"../types.js\";\nimport { minimalBackupDocument, warnSubgraphTypeConflicts } from \"./utils.js\";\n\n/**\n * Generator for document model documents\n */\nexport class DocumentModelGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/document-model\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): DocumentModelGlobalState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as DocumentModelPHState;\n return fullState.global;\n }\n\n skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const globalState = this.extractGlobalState(input);\n if (!globalState) {\n logger.debug(\n `>>> No global state found for document model: ${input.documentId}`,\n );\n return \"The document model has no global state\";\n }\n\n const validationResult = validateDocumentModelState(globalState);\n if (!validationResult.isValid) {\n const errorList = validationResult.errors\n .map((error) => ` - ${error}`)\n .join(\"\\n\");\n logger.info(\n `โš ๏ธ Skipped code generation for '${globalState.name || input.documentId}' due to validation errors:\\n${errorList}`,\n );\n return `The document model is not ready for code generation:\\n${errorList}`;\n }\n\n logger.info(\n `Document model ${globalState.name} is valid, proceeding with code generation`,\n );\n return undefined;\n }\n\n async generate(input: CodegenInput): Promise<void> {\n const globalState = this.extractGlobalState(input);\n if (!globalState) {\n throw new Error(\n `No global state found for document model: ${input.documentId}`,\n );\n }\n logger.debug(\n `๐Ÿ”„ Starting code generation for document model: ${globalState.name}`,\n );\n try {\n await generateDocumentModel(globalState, this.project);\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during code generation for ${globalState.name}:`,\n error,\n );\n throw error;\n }\n logger.info(\n `โœ… Code generation completed successfully for: ${globalState.name}`,\n );\n await warnSubgraphTypeConflicts(this.config.CURRENT_WORKING_DIR);\n\n const fullState = input.state as DocumentModelPHState;\n const extension = globalState.extension?.replace(/^\\.+|\\.+$/g, \"\") || \"\";\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: fullState,\n name: globalState.name,\n },\n this.config.CURRENT_WORKING_DIR,\n extension,\n );\n }\n}\n","import { createOrUpdateManifest } from \"@powerhousedao/codegen/file-builders\";\nimport type {\n VetraPackageGlobalState,\n VetraPackagePHState,\n} from \"../../../../document-models/vetra-package/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput } from \"../types.js\";\nimport { minimalBackupDocument } from \"./utils.js\";\n\n/**\n * Generator for package documents\n */\nexport class PackageGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/package\";\n\n skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n if (!input.state) {\n logger.debug(`>>> No state found for package: ${input.documentId}`);\n return \"The package has no state\";\n }\n return undefined;\n }\n\n async generate(input: CodegenInput): Promise<void> {\n const fullState = input.state as VetraPackagePHState;\n const state = fullState.global as VetraPackageGlobalState;\n\n await createOrUpdateManifest(\n {\n name: state.name ?? \"\",\n category: state.category ?? \"\",\n description: state.description ?? \"\",\n publisher: {\n name: state.author?.name ?? \"\",\n url: state.author?.website ?? \"\",\n },\n },\n this.config.CURRENT_WORKING_DIR,\n );\n\n // Backup the document\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: fullState,\n name: \"vetra-package\",\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import { type Feature, generateProcessor } from \"@powerhousedao/codegen\";\nimport {\n PROCESSOR_APPS,\n type ProcessorApp,\n type ProcessorApps,\n} from \"@powerhousedao/shared/processors\";\nimport type {\n ProcessorModulePHState,\n ProcessorModuleState,\n} from \"../../../../document-models/processor-module/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, CodegenJob, GenerateResult } from \"../types.js\";\nimport { installFeatureDependencies, minimalBackupDocument } from \"./utils.js\";\n\nconst PROCESSOR_TYPES = {\n analytics: \"analytics\",\n relational: \"relationalDb\",\n} as const;\n\n/**\n * Generator for processor documents\n */\nexport class ProcessorGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/processor\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): ProcessorModuleState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as ProcessorModulePHState;\n return fullState.global;\n }\n\n skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const reason = invalidReason(this.extractGlobalState(input));\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(\n input: CodegenInput,\n job?: CodegenJob,\n ): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n const reason = this.skipReason(input);\n if (!state || reason) {\n return { skipped: reason ?? \"The processor has no state\" };\n }\n const processorType =\n PROCESSOR_TYPES[state.type as keyof typeof PROCESSOR_TYPES];\n const processorApps = state.processorApps as ProcessorApps;\n logger.info(`๐Ÿ”„ Starting processor generation for: ${state.name}`);\n try {\n const features: Feature[] =\n processorType === \"analytics\"\n ? [\"analyticsProcessor\"]\n : [\"relationalDbProcessor\"];\n await installFeatureDependencies(\n features,\n this.config.CURRENT_WORKING_DIR,\n `processor \"${state.name}\"`,\n job,\n );\n\n await generateProcessor(\n {\n processorName: state.name,\n processorType,\n documentTypes: state.documentTypes.map((dt) => dt.documentType),\n processorApps,\n },\n this.project,\n );\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during processor generation for ${state.name}:`,\n error,\n );\n throw error;\n }\n\n logger.info(\n `โœ… Processor generation completed successfully for: ${state.name}`,\n );\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as ProcessorModulePHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n\nfunction invalidReason(\n state: ProcessorModuleState | undefined,\n): string | undefined {\n if (!state) return \"The processor has no state\";\n if (!state.name) return \"The processor has no name\";\n const processor = `Processor \"${state.name}\"`;\n if (!state.type) return `${processor} has no type`;\n if (!(state.type in PROCESSOR_TYPES)) {\n return `${processor} has the unsupported type \"${state.type}\"; use ${Object.keys(PROCESSOR_TYPES).join(\" or \")}`;\n }\n if (state.documentTypes.length === 0) {\n return `${processor} has no document types`;\n }\n if (state.processorApps.length === 0) {\n return `${processor} has no processor apps`;\n }\n if (!isProcessorApps(state.processorApps)) {\n return `${processor} has unsupported processor apps (${state.processorApps.join(\", \")}); use ${PROCESSOR_APPS.join(\", \")}, each once`;\n }\n if (state.status !== \"CONFIRMED\") {\n return `${processor} is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n return undefined;\n}\n\nfunction isProcessorApps(input: readonly string[]): input is ProcessorApps {\n if (input.length === 0) return false;\n if (new Set(input).size !== input.length) {\n return false;\n }\n if (!input.every((i) => PROCESSOR_APPS.includes(i as ProcessorApp)))\n return false;\n\n return true;\n}\n","import { generateSubgraph } from \"@powerhousedao/codegen\";\nimport { findSubgraphNameConflict } from \"../../../../codegen/subgraph-type-lint.js\";\nimport type {\n SubgraphModulePHState,\n SubgraphModuleState,\n} from \"../../../../document-models/subgraph-module/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, CodegenJob, GenerateResult } from \"../types.js\";\nimport {\n installFeatureDependencies,\n minimalBackupDocument,\n warnSubgraphTypeConflicts,\n} from \"./utils.js\";\n\n/**\n * Generator for subgraph documents\n */\nexport class SubgraphGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/subgraph\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): SubgraphModuleState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as SubgraphModulePHState;\n return fullState.global;\n }\n\n skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const state = this.extractGlobalState(input);\n let reason: string | undefined;\n if (!state) reason = \"The subgraph has no state\";\n else if (!state.name) reason = \"The subgraph has no name\";\n else if (state.status !== \"CONFIRMED\") {\n reason = `Subgraph \"${state.name}\" is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(\n input: CodegenInput,\n job?: CodegenJob,\n ): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n const reason = this.skipReason(input);\n if (!state || reason) {\n return { skipped: reason ?? \"The subgraph has no state\" };\n }\n\n logger.info(`๐Ÿ”„ Starting subgraph generation for: ${state.name}`);\n try {\n const conflict = await findSubgraphNameConflict(\n this.config.CURRENT_WORKING_DIR,\n state.name,\n );\n if (conflict) {\n logger.error(`โŒ Skipping subgraph generation: ${conflict}`);\n return { skipped: conflict };\n }\n await installFeatureDependencies(\n [\"subgraph\"],\n this.config.CURRENT_WORKING_DIR,\n `subgraph \"${state.name}\"`,\n job,\n );\n await generateSubgraph(state.name, this.project);\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during subgraph generation for ${state.name}:`,\n error,\n );\n throw error;\n }\n logger.info(\n `โœ… Subgraph generation completed successfully for: ${state.name}`,\n );\n await warnSubgraphTypeConflicts(this.config.CURRENT_WORKING_DIR);\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as SubgraphModulePHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import type { CodegenStatusRegistry } from \"@powerhousedao/shared/processors\";\nimport type { Project } from \"ts-morph\";\nimport type { BaseDocumentGen } from \"./base-document-gen.js\";\nimport { DocumentCodegenManager } from \"./document-codegen-manager.js\";\nimport {\n AppGenerator,\n DocumentEditorGenerator,\n DocumentModelGenerator,\n PackageGenerator,\n ProcessorGenerator,\n SubgraphGenerator,\n} from \"./generators/index.js\";\nimport type { Config } from \"./types.js\";\n\n/**\n * Factory class for creating and configuring DocumentCodegenManager instances\n * with all the standard generators pre-registered\n */\nexport class DocumentCodegenFactory {\n /**\n * Create a DocumentCodegenManager with all standard generators registered\n */\n static createManager(\n config: Config,\n project: Project,\n interactiveMode: boolean = false,\n status?: CodegenStatusRegistry,\n ): DocumentCodegenManager {\n const manager = new DocumentCodegenManager(\n config,\n project,\n interactiveMode,\n status,\n );\n\n // Register all the standard generators\n manager.registerGenerator(\n \"powerhouse/document-model\",\n DocumentModelGenerator,\n );\n manager.registerGenerator(\"powerhouse/package\", PackageGenerator);\n manager.registerGenerator(\"powerhouse/app\", AppGenerator);\n manager.registerGenerator(\n \"powerhouse/document-editor\",\n DocumentEditorGenerator,\n );\n manager.registerGenerator(\"powerhouse/subgraph\", SubgraphGenerator);\n manager.registerGenerator(\"powerhouse/processor\", ProcessorGenerator);\n\n return manager;\n }\n\n /**\n * Create a DocumentCodegenManager with only specific generators\n */\n static createManagerWithGenerators(\n config: Config,\n generators: Array<new (config: Config) => any>,\n project: Project,\n interactiveMode: boolean = false,\n status?: CodegenStatusRegistry,\n ): DocumentCodegenManager {\n const manager = new DocumentCodegenManager(\n config,\n project,\n interactiveMode,\n status,\n );\n\n for (const generatorClass of generators) {\n const generator = new generatorClass(config) as BaseDocumentGen;\n const supportedTypes = generator.getSupportedDocumentTypes();\n\n for (const documentType of supportedTypes) {\n manager.registerGenerator(documentType, generatorClass);\n }\n }\n\n return manager;\n }\n\n /**\n * Get all available generator classes\n */\n static getAvailableGenerators() {\n return {\n DocumentModelGenerator,\n PackageGenerator,\n AppGenerator,\n DocumentEditorGenerator,\n SubgraphGenerator,\n ProcessorGenerator,\n };\n }\n}\n","import type {\n IProcessor,\n IReactorClient,\n OperationWithContext,\n} from \"@powerhousedao/reactor-browser\";\nimport type { PowerhouseConfig } from \"@powerhousedao/shared\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport type { Project } from \"ts-morph\";\nimport type { DocumentCodegenManager } from \"./document-handlers/document-codegen-manager.js\";\nimport { DocumentCodegenFactory } from \"./document-handlers/index.js\";\nimport type { CodegenInput } from \"./document-handlers/types.js\";\nimport { logger } from \"./logger.js\";\n\nexport class CodegenProcessor implements IProcessor {\n private manager: DocumentCodegenManager;\n\n constructor(\n project: Project,\n config: PowerhouseConfig,\n cwd: string,\n private readonly driveId: string,\n private readonly client: IReactorClient,\n interactiveMode = false,\n ) {\n this.manager = DocumentCodegenFactory.createManager(\n {\n PH_CONFIG: config,\n CURRENT_WORKING_DIR: cwd,\n },\n project,\n interactiveMode,\n );\n this.manager.setScope((documentId) => this.isInDrive(documentId));\n\n if (interactiveMode) {\n logger.info(`CodegenProcessor initialized with interactive mode enabled`);\n } else {\n logger.debug(\n `CodegenProcessor initialized with interactive mode disabled`,\n );\n }\n }\n\n async onOperations(operations: OperationWithContext[]): Promise<void> {\n logger.debug(\"CodegenProcessor.onOperations()\");\n\n // Only a document's final state in the batch is generated from.\n const latest = new Map<string, OperationWithContext>();\n for (const operation of operations) {\n latest.set(operation.context.documentId, operation);\n }\n\n for (const { context } of latest.values()) {\n const generator = this.manager.getGenerator(context.documentType);\n if (!generator) {\n logger.debug(\n `No generator found for document type: ${context.documentType}`,\n );\n continue;\n }\n\n const input: CodegenInput = {\n documentId: context.documentId,\n documentType: context.documentType,\n scope: context.scope,\n branch: context.branch,\n state: context.resultingState\n ? JSON.parse(context.resultingState)\n : undefined,\n };\n\n await this.manager.routeAndGenerate(input);\n }\n }\n\n async onDisconnect() {}\n\n // Utility methods for external configuration and monitoring\n public setInteractiveMode(enabled: boolean): void {\n this.manager.setInteractiveMode(enabled);\n }\n\n public isInteractive(): boolean {\n return this.manager.isInteractiveMode();\n }\n\n public isProcessingInteractive(): boolean {\n return this.manager.isProcessingInteractive();\n }\n\n /**\n * The reactor delivers every drive's operations, so membership is checked\n * here: a node of the drive (in any folder, and in drives older than\n * relationship edges), or a child edge from it (a document attached by\n * relationship alone).\n */\n private async isInDrive(documentId: string): Promise<boolean> {\n try {\n const drive = await this.client.get<DocumentDriveDocument>(this.driveId);\n if (drive.state.global.nodes.some((node) => node.id === documentId)) {\n return true;\n }\n } catch (error) {\n logger.debug(`Could not read the Vetra drive ${this.driveId}:`, error);\n }\n try {\n const parents = await this.client.getIncomingRelationshipEdges(\n documentId,\n \"child\",\n );\n return parents.results.some((edge) => edge.sourceId === this.driveId);\n } catch (error) {\n logger.debug(`Could not read the parents of ${documentId}:`, error);\n return false;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AASA,IAAsB,kBAAtB,MAAsC;CAMxB;CAHZ;CAEA,YACE,QACA,SACA;EAFU,KAAA,SAAA;EAGV,KAAK,UAAU;CACjB;CAQA,qBAAqB,cAA+B;EAClD,IAAI,OAAO,KAAK,2BAA2B,UACzC,OAAO,KAAK,2BAA2B;EAEzC,OAAO,KAAK,uBAAuB,SAAS,YAAY;CAC1D;CAEA,4BAAsC;EACpC,IAAI,OAAO,KAAK,2BAA2B,UACzC,OAAO,CAAC,KAAK,sBAAsB;EAErC,OAAO,CAAC,GAAG,KAAK,sBAAsB;CACxC;;CAGA,WAAW,QAA0C;EAEnD,MAAM,OADQ,OAAO,OACD,QAAQ;EAC5B,OAAO,OAAO,SAAS,YAAY,SAAS,KAAK,OAAO,KAAA;CAC1D;;CAGA,WAAW,QAA0C;EACnD,IAAI,CAAC,OAAO,cAAc,CAAC,OAAO,cAChC,OAAO;EAET,IAAI,CAAC,KAAK,qBAAqB,OAAO,YAAY,GAChD,OAAO,kCAAkC,OAAO;CAGpD;CAEA,cAAc,QAA+B;EAC3C,OAAO,KAAK,WAAW,MAAM,MAAM,KAAA;CACrC;AACF;;;;;;;ACjDA,IAAa,qBAAb,MAAgC;CAC9B;CACA,yBAAiC;CACjC,8BAAsB,IAAI,IAA0B;CAEpD,YAAY,kBAAkB,OAAO;EACnC,KAAK,oBAAoB;CAC3B;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ACtB,OAAO,IAAI,UAAU,QAAQ,YAAY,SAAS;EAGpD,KAAK,MAAM,EAAE,aAAa,OAAO,OAAO,GAAG;GAEzC,IAAI,CADc,KAAK,QAAQ,aAAa,QAAQ,YACvC,GAAG;IACd,OAAO,MACL,yCAAyC,QAAQ,cACnD;IACA;GACF;GAEA,MAAM,QAAsB;IAC1B,YAAY,QAAQ;IACpB,cAAc,QAAQ;IACtB,OAAO,QAAQ;IACf,QAAQ,QAAQ;IAChB,OAAO,QAAQ,iBACX,KAAK,MAAM,QAAQ,cAAc,IACjC,KAAA;GACN;GAEA,MAAM,KAAK,QAAQ,iBAAiB,KAAK;EAC3C;CACF;CAEA,MAAM,eAAe,CAAC;CAGtB,mBAA0B,SAAwB;EAChD,KAAK,QAAQ,mBAAmB,OAAO;CACzC;CAEA,gBAAgC;EAC9B,OAAO,KAAK,QAAQ,kBAAkB;CACxC;CAEA,0BAA0C;EACxC,OAAO,KAAK,QAAQ,wBAAwB;CAC9C;;;;;;;CAQA,MAAc,UAAU,YAAsC;EAC5D,IAAI;GAEF,KAAI,MADgB,KAAK,OAAO,IAA2B,KAAK,OAAO,EAAA,CAC7D,MAAM,OAAO,MAAM,MAAM,SAAS,KAAK,OAAO,UAAU,GAChE,OAAO;EAEX,SAAS,OAAO;GACd,OAAO,MAAM,kCAAkC,KAAK,QAAQ,IAAI,KAAK;EACvE;EACA,IAAI;GAKF,QAAO,MAJe,KAAK,OAAO,6BAChC,YACA,OACF,EAAA,CACe,QAAQ,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO;EACtE,SAAS,OAAO;GACd,OAAO,MAAM,iCAAiC,WAAW,IAAI,KAAK;GAClE,OAAO;EACT;CACF;AACF"}
1
+ {"version":3,"file":"processor-C_zliXhw.js","names":["installFeatureDependencies","installForFeatures","installFeatureDependencies","installFeatureDependencies"],"sources":["../processors/codegen/document-handlers/base-document-gen.ts","../processors/codegen/interactive-manager.ts","../processors/codegen/written-files.ts","../processors/codegen/document-handlers/document-codegen-manager.ts","../processors/codegen/document-handlers/generators/utils.ts","../processors/codegen/document-handlers/generators/app-generator.ts","../processors/codegen/document-handlers/generators/document-editor-generator.ts","../processors/codegen/document-handlers/generators/document-model-generator.ts","../processors/codegen/document-handlers/generators/package-generator.ts","../processors/codegen/document-handlers/generators/processor-generator.ts","../processors/codegen/document-handlers/generators/subgraph-generator.ts","../processors/codegen/document-handlers/document-codegen-factory.ts","../processors/codegen/processor.ts"],"sourcesContent":["import type { Project } from \"ts-morph\";\nimport type {\n CodegenInput,\n CodegenJob,\n Config,\n GenerateResult,\n} from \"./types.js\";\n\n/** The base of the generators, one per document type or set of types. */\nexport abstract class BaseDocumentGen {\n /** The document type or types this generator handles. */\n abstract readonly supportedDocumentTypes: string | string[];\n project: Project;\n\n constructor(\n protected config: Config,\n project: Project,\n ) {\n this.project = project;\n }\n\n /** Generates code for the document; throws when generation fails. */\n abstract generate(\n strand: CodegenInput,\n job?: CodegenJob,\n ): Promise<GenerateResult>;\n\n supportsDocumentType(documentType: string): boolean {\n if (typeof this.supportedDocumentTypes === \"string\") {\n return this.supportedDocumentTypes === documentType;\n }\n return this.supportedDocumentTypes.includes(documentType);\n }\n\n getSupportedDocumentTypes(): string[] {\n if (typeof this.supportedDocumentTypes === \"string\") {\n return [this.supportedDocumentTypes];\n }\n return [...this.supportedDocumentTypes];\n }\n\n /** The module's name in the strand's state, for its codegen status. */\n moduleName(strand: CodegenInput): string | undefined {\n const state = strand.state as { global?: { name?: unknown } } | undefined;\n const name = state?.global?.name;\n return typeof name === \"string\" && name !== \"\" ? name : undefined;\n }\n\n /** Why this strand is not generated from; undefined when it is. */\n skipReason(strand: CodegenInput): string | undefined {\n if (!strand.documentId || !strand.documentType) {\n return \"The operation names no document\";\n }\n if (!this.supportsDocumentType(strand.documentType)) {\n return `No generator for document type ${strand.documentType}`;\n }\n return undefined;\n }\n\n shouldProcess(strand: CodegenInput): boolean {\n return this.skipReason(strand) === undefined;\n }\n}\n","import { createInterface } from \"node:readline\";\nimport type { CodegenInput } from \"./document-handlers/types.js\";\nimport { logger } from \"./logger.js\";\n\nexport interface QueuedStrand {\n strand: CodegenInput;\n timestamp: number;\n}\n\n/**\n * InteractiveManager handles user interaction for code generation confirmation\n * Supports both individual strand processing and queue-based batch processing\n */\nexport class InteractiveManager {\n private isInteractiveMode: boolean;\n private processingConfirmation = false;\n private strandQueue = new Map<string, QueuedStrand>();\n\n constructor(interactiveMode = false) {\n this.isInteractiveMode = interactiveMode;\n }\n\n private getDocumentKey(documentType: string, documentId: string): string {\n return `${documentType}:${documentId}`;\n }\n\n /**\n * Add a strand to the queue, replacing any existing strand for the same document\n */\n public queueStrand(strand: CodegenInput): void {\n const documentKey = this.getDocumentKey(\n strand.documentType,\n strand.documentId,\n );\n\n this.strandQueue.set(documentKey, {\n strand,\n timestamp: Date.now(),\n });\n\n logger.debug(\n `>>> Queued strand for ${documentKey}, queue size: ${this.strandQueue.size}`,\n );\n }\n\n /**\n * Drop the queued strands the predicate matches\n */\n public discardWhere(predicate: (strand: CodegenInput) => boolean): void {\n for (const [key, queued] of this.strandQueue) {\n if (predicate(queued.strand)) this.strandQueue.delete(key);\n }\n }\n\n /**\n * Get all queued strands\n */\n public getQueuedStrands(): QueuedStrand[] {\n return Array.from(this.strandQueue.values());\n }\n\n /**\n * Clear and return all queued strands\n */\n public clearQueue(): QueuedStrand[] {\n const queuedStrands = Array.from(this.strandQueue.values());\n this.strandQueue.clear();\n return queuedStrands;\n }\n\n /**\n * Get the current queue size\n */\n public getQueueSize(): number {\n return this.strandQueue.size;\n }\n\n private async promptUserConfirmation(): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"๐Ÿ”„ Code generation ready to run.\");\n console.log(\"=\".repeat(50));\n\n process.stdout.write(\n \"Do you want to proceed with code generation? (y/n): \\n\\n\",\n );\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n console.log(\"\"); // Add blank line after user input\n resolve(answer.toLowerCase() === \"y\" || answer.toLowerCase() === \"yes\");\n });\n });\n }\n\n /**\n * Process generation with user confirmation (legacy single-strand method)\n * This method assumes interactive mode is already enabled (checked by caller)\n */\n public async processWithConfirmation<T>(\n documentType: string,\n generator: () => Promise<T>,\n ): Promise<T | null> {\n if (this.processingConfirmation) {\n logger.debug(\"Already processing confirmation, skipping\");\n return null;\n }\n\n this.processingConfirmation = true;\n\n try {\n // Always prompt user since this method only called in interactive mode\n const shouldProceed = await this.promptUserConfirmation();\n\n if (!shouldProceed) {\n logger.info(`โŒ Code generation cancelled by user for ${documentType}`);\n return null;\n }\n\n logger.info(`โœ… User approved code generation for ${documentType}`);\n\n const result = await generator();\n return result;\n } catch (error) {\n logger.error(\n `โŒ Error during interactive code generation for ${documentType}:`,\n error,\n );\n throw error;\n } finally {\n this.processingConfirmation = false;\n }\n }\n\n /**\n * Process all queued strands with a single user confirmation\n * This is the main method for queue-based interactive processing\n */\n public async processQueueWithConfirmation(\n processor: (strands: QueuedStrand[]) => Promise<void>,\n onCancel?: (strands: QueuedStrand[]) => void,\n ): Promise<void> {\n if (this.processingConfirmation) {\n logger.debug(\n \"Already processing confirmation, skipping queue processing\",\n );\n return;\n }\n\n // Check if there are any strands to process\n let queuedStrands = this.getQueuedStrands();\n if (queuedStrands.length === 0) {\n logger.debug(\"No strands in queue to process\");\n return;\n }\n\n this.processingConfirmation = true;\n\n try {\n // Prompt user for confirmation\n const shouldProceed = await this.promptUserConfirmation();\n\n if (!shouldProceed) {\n logger.info(\"โŒ Code generation cancelled by user\");\n onCancel?.(this.clearQueue());\n return;\n }\n\n // Get and clear the final queue state right before processing\n // (in case new strands were added while waiting for user input)\n queuedStrands = this.clearQueue();\n if (queuedStrands.length === 0) {\n logger.info(\"โ„น๏ธ No documents to process\");\n return;\n }\n\n logger.info(\n `โœ… User approved code generation for ${queuedStrands.length} document(s)`,\n );\n\n // Process all queued strands\n await processor(queuedStrands);\n logger.info(\"โœ… Code generation completed\");\n } catch (error) {\n logger.error(\n \"โŒ Error during interactive queue processing: @error\",\n error,\n );\n throw error;\n } finally {\n this.processingConfirmation = false;\n }\n }\n\n public setInteractiveMode(enabled: boolean): void {\n this.isInteractiveMode = enabled;\n logger.debug(`Interactive mode set to: ${enabled}`);\n }\n\n public isInteractive(): boolean {\n return this.isInteractiveMode;\n }\n\n public isProcessing(): boolean {\n return this.processingConfirmation;\n }\n}\n","import type { Dirent } from \"node:fs\";\nimport { readdir, stat } from \"node:fs/promises\";\nimport { join, relative } from \"node:path\";\n\nconst SKIPPED_DIRS = new Set([\"node_modules\", \"dist\", \"backup-documents\"]);\nconst MAX_FILES = 500;\n\n/** The project's files modified at or after `since`, relative and sorted. */\nexport async function filesWrittenSince(\n projectDir: string,\n since: number,\n): Promise<string[]> {\n const written: string[] = [];\n const visit = async (dir: string): Promise<void> => {\n let entries: Dirent[];\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch {\n return;\n }\n for (const entry of entries) {\n if (written.length >= MAX_FILES) return;\n const path = join(dir, entry.name);\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\") || SKIPPED_DIRS.has(entry.name)) {\n continue;\n }\n await visit(path);\n } else if (entry.isFile()) {\n try {\n if ((await stat(path)).mtimeMs >= since) {\n written.push(relative(projectDir, path).replaceAll(\"\\\\\", \"/\"));\n }\n } catch {\n // Removed while listing.\n }\n }\n }\n };\n await visit(projectDir);\n return written.sort();\n}\n","import { afterPendingInstalls, installsPending } from \"@powerhousedao/codegen\";\nimport {\n type CodegenState,\n type CodegenStatusRegistry,\n getCodegenStatusRegistry,\n} from \"@powerhousedao/shared/processors\";\nimport type { Project } from \"ts-morph\";\nimport type { QueuedStrand } from \"../interactive-manager.js\";\nimport { InteractiveManager } from \"../interactive-manager.js\";\nimport { logger } from \"../logger.js\";\nimport { filesWrittenSince } from \"../written-files.js\";\nimport type { BaseDocumentGen } from \"./base-document-gen.js\";\nimport type { CodegenInput, CodegenJob, Config } from \"./types.js\";\n\nconst DEFAULT_DEBOUNCE_TIME = 1000; // wait 1 second between codegen calls\nconst MODULE_NOT_FOUND_CODES = new Set([\n \"ERR_MODULE_NOT_FOUND\",\n \"MODULE_NOT_FOUND\",\n \"ERR_PACKAGE_PATH_NOT_EXPORTED\",\n]);\nconst MODULE_NOT_FOUND_MESSAGE =\n /Cannot find (module|package)|Failed to resolve (import|entry)|Failed to load url/;\n\n/** Whether a document belongs to what this manager generates from. */\nexport type DocumentScope = (documentId: string) => Promise<boolean>;\n\n/**\n * Manager class responsible for routing documents to the correct generator\n * and managing generator registration and instantiation\n */\nexport class DocumentCodegenManager {\n project: Project;\n private generators = new Map<string, BaseDocumentGen>();\n private debounceTimers = new Map<string, NodeJS.Timeout>();\n // One job at a time, so none runs while another job's install relinks node_modules.\n private jobs: Promise<void> = Promise.resolve();\n private queuedJobs = new Map<string, CodegenInput>();\n private runningJobs = 0;\n /** The wait before retrying a module-resolution failure when no install is queued. */\n retryDelayMs = 3000;\n private interactiveManager: InteractiveManager;\n private isInScope: DocumentScope = () => Promise.resolve(true);\n readonly status: CodegenStatusRegistry;\n\n constructor(\n private config: Config,\n project: Project,\n interactiveMode = false,\n status: CodegenStatusRegistry = getCodegenStatusRegistry(),\n ) {\n this.project = project;\n this.interactiveManager = new InteractiveManager(interactiveMode);\n this.status = status;\n }\n\n /**\n * Limit generation to the documents `isInScope` accepts, checked when the\n * debounce fires\n */\n setScope(isInScope: DocumentScope): void {\n this.isInScope = isInScope;\n }\n\n /**\n * Register a generator class for a specific document type\n */\n registerGenerator(\n documentType: string,\n generatorClass: new (config: Config, project: Project) => BaseDocumentGen,\n ): void {\n if (this.generators.has(documentType)) {\n logger.warn(\n `โš ๏ธ Generator for document type \"${documentType}\" is already registered. Overwriting.`,\n );\n }\n\n this.generators.set(\n documentType,\n new generatorClass(this.config, this.project),\n );\n logger.debug(`โœ… Registered generator for document type: ${documentType}`);\n }\n\n /**\n * Register a generator class that supports multiple document types\n */\n registerMultiTypeGenerator(\n generatorClass: new (config: Config, project: Project) => BaseDocumentGen,\n ): void {\n const generator = new generatorClass(this.config, this.project);\n const supportedTypes = generator.getSupportedDocumentTypes();\n\n for (const documentType of supportedTypes) {\n if (this.generators.has(documentType)) {\n logger.warn(\n `โš ๏ธ Generator for document type \"${documentType}\" is already registered. Overwriting.`,\n );\n }\n this.generators.set(documentType, generator);\n }\n\n logger.debug(\n `โœ… Registered multi-type generator for document types: ${supportedTypes.join(\", \")}`,\n );\n }\n\n /**\n * Get a generator instance for the given document type\n * Public method to allow external access for validation\n */\n public getGenerator(documentType: string): BaseDocumentGen | undefined {\n return this.generators.get(documentType);\n }\n\n /**\n * Get all registered document types\n */\n getRegisteredDocumentTypes(): string[] {\n return Array.from(this.generators.keys());\n }\n\n /**\n * Check if a document type is supported\n */\n isDocumentTypeSupported(documentType: string): boolean {\n return this.generators.has(documentType);\n }\n\n /**\n * Route a document to the appropriate generator and handle the generation\n * Handles both interactive and non-interactive modes with queue-based processing\n */\n routeAndGenerate(strand: CodegenInput): Promise<void> {\n const documentType = strand.documentType;\n\n if (!documentType) {\n logger.error(\"โŒ Document type is missing from strand state\");\n throw new Error(\"Document type is missing from strand state\");\n }\n\n const generator = this.getGenerator(documentType);\n\n if (!generator) {\n logger.warn(`โš ๏ธ No generator found for document type: ${documentType}`);\n logger.warn(\n `โ„น๏ธ Supported document types: ${this.getRegisteredDocumentTypes().join(\", \")}`,\n );\n throw new Error(`Unsupported document type: ${documentType}`);\n }\n\n // Scope and validation are checked when the debounce fires, on the\n // document's final state.\n this.status.set({\n documentId: strand.documentId,\n documentType,\n state: \"queued\",\n message: this.interactiveManager.isInteractive()\n ? \"Waiting for confirmation in the terminal running Vetra\"\n : \"Waiting for the document's changes to settle\",\n });\n // Different flow for interactive vs non-interactive mode\n if (this.interactiveManager.isInteractive()) {\n // Interactive mode: queue strands and use debounce timer to trigger batch processing\n logger.debug(\n `>>> Queueing strand for interactive processing: ${documentType}:${strand.documentId}`,\n );\n\n // Add strand to queue (will replace any existing strand for same document)\n this.interactiveManager.queueStrand(strand);\n\n // Clear any existing debounce timer for interactive processing\n const existingTimer = this.debounceTimers.get(\"interactive\");\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n\n // Set up debounce timer for batch interactive processing\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const debounceTimer = setTimeout(async () => {\n try {\n const rejected = new Set<CodegenInput>();\n for (const { strand } of this.interactiveManager.getQueuedStrands()) {\n if (!(await this.accepts(strand))) rejected.add(strand);\n }\n this.interactiveManager.discardWhere((queued) =>\n rejected.has(queued),\n );\n await this.interactiveManager.processQueueWithConfirmation(\n async (queuedStrands: QueuedStrand[]) => {\n await this.processQueuedStrands(queuedStrands);\n },\n (cancelled) => {\n for (const { strand } of cancelled) {\n this.setStatus(strand, \"skipped\", \"Cancelled in the terminal\");\n }\n },\n );\n } catch (error) {\n logger.error(\n \"โŒ Error during interactive batch processing: @error\",\n error,\n );\n } finally {\n // Clean up the timer reference\n this.debounceTimers.delete(\"interactive\");\n }\n }, DEFAULT_DEBOUNCE_TIME);\n\n // Store the timer reference using 'interactive' key\n this.debounceTimers.set(\"interactive\", debounceTimer);\n } else {\n // Non-interactive mode: use debouncing per document instance\n // Create unique key for this specific document instance\n const timerKey = `${documentType}:${strand.documentId}`;\n\n // Clear any existing debounce timer for this document instance\n const existingTimer = this.debounceTimers.get(timerKey);\n if (existingTimer) {\n clearTimeout(existingTimer);\n }\n\n // Set up new debounced generation (no interactive confirmation)\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n const debounceTimer = setTimeout(async () => {\n try {\n if (!(await this.accepts(strand))) return;\n logger.debug(\n `๐Ÿ”„ Routing document type \"${documentType}\" to generator (debounced)`,\n );\n await this.enqueueJob(strand);\n } finally {\n // Clean up the timer reference\n this.debounceTimers.delete(timerKey);\n }\n }, DEFAULT_DEBOUNCE_TIME);\n\n // Store the timer reference\n this.debounceTimers.set(timerKey, debounceTimer);\n }\n return Promise.resolve();\n }\n\n /** In scope first, so documents out of scope are never validated or logged. */\n private async accepts(strand: CodegenInput): Promise<boolean> {\n const generator = this.getGenerator(strand.documentType);\n if (!generator) return false;\n if (!(await this.isInScope(strand.documentId))) {\n logger.debug(\n `Document ${strand.documentId} is not in the Vetra drive, skipping codegen`,\n );\n this.status.delete(strand.documentId);\n this.queuedJobs.delete(strand.documentId);\n return false;\n }\n const reason = generator.skipReason(strand);\n if (reason !== undefined) {\n this.setStatus(strand, \"skipped\", reason);\n this.queuedJobs.delete(strand.documentId);\n return false;\n }\n return true;\n }\n\n /** Queues a job; one already queued for the document runs the latest strand. */\n private enqueueJob(strand: CodegenInput): Promise<void> {\n const { documentId } = strand;\n const alreadyQueued = this.queuedJobs.has(documentId);\n this.queuedJobs.set(documentId, strand);\n if (this.runningJobs > 0) {\n this.setStatus(\n strand,\n \"queued\",\n \"Waiting for codegen of other documents to finish\",\n );\n }\n if (alreadyQueued) return this.jobs;\n this.jobs = this.jobs.then(async () => {\n const latest = this.queuedJobs.get(documentId);\n this.queuedJobs.delete(documentId);\n const generator = latest && this.getGenerator(latest.documentType);\n if (!latest || !generator) return;\n this.runningJobs++;\n try {\n await this.runJob(latest, generator);\n } finally {\n this.runningJobs--;\n }\n });\n return this.jobs;\n }\n\n /** Runs a job after pending installs, once more after a module-resolution failure. */\n private async runJob(\n strand: CodegenInput,\n generator: BaseDocumentGen,\n ): Promise<void> {\n await this.afterInstalls(\n strand,\n \"Waiting for a dependency install to finish\",\n );\n const error = await this.attempt(strand, generator);\n if (error === undefined) return;\n if (!isModuleResolutionError(error)) {\n this.setStatus(strand, \"failed\", errorMessage(error));\n return;\n }\n logger.warn(\n `Codegen for ${strand.documentType} ${strand.documentId} could not resolve a module; retrying once installs finish: ${errorMessage(error)}`,\n );\n const waited = await this.afterInstalls(\n strand,\n `Retrying once dependency installs finish, after: ${errorMessage(error)}`,\n );\n if (!waited) {\n await new Promise((resolve) => setTimeout(resolve, this.retryDelayMs));\n }\n const retryError = await this.attempt(strand, generator);\n if (retryError !== undefined) {\n this.setStatus(\n strand,\n \"failed\",\n `${errorMessage(retryError)} (also after a retry; if an install is running, run it to the end, then change the document again)`,\n );\n }\n }\n\n /** Waits for queued installs, saying so; resolves to whether any was queued. */\n private async afterInstalls(\n strand: CodegenInput,\n message: string,\n ): Promise<boolean> {\n if (!installsPending()) return false;\n this.setStatus(strand, \"waiting-for-install\", message);\n await afterPendingInstalls();\n return true;\n }\n\n /** Generates once; records done or skipped, or resolves to the error. */\n private async attempt(\n strand: CodegenInput,\n generator: BaseDocumentGen,\n ): Promise<unknown> {\n const startedAt = Date.now();\n const job: CodegenJob = {\n waitingForInstall: (message) =>\n this.setStatus(strand, \"waiting-for-install\", message),\n running: () => this.setStatus(strand, \"running\"),\n };\n job.running();\n try {\n const result = await generator.generate(strand, job);\n if (result) {\n this.setStatus(strand, \"skipped\", result.skipped);\n return;\n }\n const files = await filesWrittenSince(\n this.config.CURRENT_WORKING_DIR,\n startedAt,\n );\n this.setStatus(strand, \"done\", undefined, files);\n logger.debug(\n `โœ… Successfully generated code for document type: ${strand.documentType}`,\n );\n return undefined;\n } catch (error) {\n logger.error(\n `โŒ Error generating code for document type \"${strand.documentType}\":`,\n error,\n );\n return error ?? new Error(\"Codegen failed\");\n }\n }\n\n private setStatus(\n strand: CodegenInput,\n state: CodegenState,\n message?: string,\n files?: string[],\n ): void {\n this.status.set({\n documentId: strand.documentId,\n documentType: strand.documentType,\n name: this.getGenerator(strand.documentType)?.moduleName(strand),\n state,\n message,\n files,\n });\n }\n\n /**\n * Process multiple strands in priority order (document-model types first)\n */\n private async processQueuedStrands(\n queuedStrands: QueuedStrand[],\n ): Promise<void> {\n logger.debug(`๐Ÿ”„ Processing ${queuedStrands.length} queued strand(s)`);\n\n // Sort by priority (document-model first to ensure dependencies exist)\n const documentModelStrands = queuedStrands.filter(\n (qs: QueuedStrand) =>\n qs.strand.documentType === \"powerhouse/document-model\",\n );\n const otherStrands = queuedStrands.filter(\n (qs: QueuedStrand) =>\n qs.strand.documentType !== \"powerhouse/document-model\",\n );\n\n // Process document models first\n for (const queuedStrand of documentModelStrands) {\n await this.processStrand(queuedStrand.strand);\n }\n\n // Then process other document types\n for (const queuedStrand of otherStrands) {\n await this.processStrand(queuedStrand.strand);\n }\n\n logger.debug(\n `โœ… Successfully processed all ${queuedStrands.length} queued strand(s)`,\n );\n }\n\n /**\n * Process a single strand (used internally by processQueuedStrands)\n */\n private async processStrand(strand: CodegenInput): Promise<void> {\n const documentType = strand.documentType;\n const generator = this.getGenerator(documentType);\n\n if (!generator) {\n logger.warn(`โš ๏ธ No generator found for document type: ${documentType}`);\n return;\n }\n\n logger.debug(`๐Ÿ”„ Generating code for document type: ${documentType}`);\n await this.enqueueJob(strand);\n }\n\n /**\n * Clear all registered generators\n */\n clearGenerators(): void {\n this.generators.clear();\n logger.debug(\"๐Ÿงน Cleared all registered generators\");\n }\n\n /**\n * Get statistics about registered generators\n */\n getStats(): { totalGenerators: number; supportedTypes: string[] } {\n return {\n totalGenerators: this.generators.size,\n supportedTypes: this.getRegisteredDocumentTypes(),\n };\n }\n\n /**\n * Set interactive mode for code generation\n */\n setInteractiveMode(enabled: boolean): void {\n this.interactiveManager.setInteractiveMode(enabled);\n }\n\n /**\n * Check if interactive mode is enabled\n */\n isInteractiveMode(): boolean {\n return this.interactiveManager.isInteractive();\n }\n\n /**\n * Check if the manager is currently processing an interactive confirmation\n */\n isProcessingInteractive(): boolean {\n return this.interactiveManager.isProcessing();\n }\n}\n\nfunction isModuleResolutionError(error: unknown): boolean {\n for (let cause = error; cause instanceof Error; cause = cause.cause) {\n const code = (cause as NodeJS.ErrnoException).code;\n if (code && MODULE_NOT_FOUND_CODES.has(code)) return true;\n if (MODULE_NOT_FOUND_MESSAGE.test(cause.message)) return true;\n }\n return false;\n}\n\nfunction errorMessage(error: unknown): string {\n if (!(error instanceof Error)) return String(error);\n const cause = error.cause instanceof Error ? `: ${error.cause.message}` : \"\";\n return `${error.message}${cause}`;\n}\n","import {\n type Feature,\n installFeatureDependencies as installForFeatures,\n} from \"@powerhousedao/codegen\";\nimport type {\n MinimalBackupData,\n PHBaseState,\n PHDocument,\n PHDocumentHeader,\n} from \"@powerhousedao/shared/document-model\";\nimport { baseMinimalSaveToFile, baseSaveToFile } from \"document-model/node\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { lintSubgraphTypes } from \"../../../../codegen/subgraph-type-lint.js\";\nimport { logger } from \"../../logger.js\";\nimport type { CodegenJob } from \"../types.js\";\n\nconst BACKUP_FOLDER = \"backup-documents\";\n\n/**\n * Exports a document to the backup directory.\n * Creates the backup directory if it doesn't exist.\n *\n * @param document - The document to backup\n * @param workingDir - Current working directory\n * @param extension - File extension for the document type (without dot)\n * @param name - Name of the document to use for the backup file (optional)\n * @returns Promise resolving to the backup file path, or undefined if backup failed\n */\nexport async function backupDocument(\n document: PHDocument,\n workingDir: string,\n extension: string = \"\",\n name?: string,\n): Promise<string | undefined> {\n const docName = name ?? document.header.name;\n\n try {\n const backupPath = join(workingDir, BACKUP_FOLDER);\n await mkdir(backupPath, { recursive: true });\n\n const filePath = await baseSaveToFile(\n document,\n backupPath,\n extension,\n docName,\n );\n\n logger.debug(`๐Ÿ“ Document backed up to: ${filePath}`);\n return filePath;\n } catch (error) {\n logger.warn(`โš ๏ธ Failed to backup document \"${docName}\":`, error);\n return undefined;\n }\n}\n\n/**\n * Creates a minimal backup of a document from strand data.\n * Used when the full document is not available (e.g., in onOperations handler).\n */\nexport async function minimalBackupDocument(\n data: MinimalBackupData,\n workingDir: string,\n extension?: string,\n): Promise<string | undefined> {\n // The reactor's resultingState carries the document header alongside the\n // state scopes; lift its protocol versions into the backup header.\n const { header, ...state } = data.state as PHBaseState & {\n header?: PHDocumentHeader;\n };\n\n try {\n const backupPath = join(workingDir, BACKUP_FOLDER);\n await mkdir(backupPath, { recursive: true });\n\n const filePath = await baseMinimalSaveToFile(\n {\n ...data,\n state,\n protocolVersions: data.protocolVersions ?? header?.protocolVersions,\n },\n backupPath,\n extension ?? \"\",\n );\n\n logger.debug(`Document backed up to: ${filePath}`);\n return filePath;\n } catch (error) {\n logger.warn(`Failed to backup document \"${data.name}\":`, error);\n return undefined;\n }\n}\n\nexport async function warnSubgraphTypeConflicts(\n workingDir: string,\n): Promise<void> {\n let warnings: string[];\n try {\n warnings = await lintSubgraphTypes(workingDir);\n } catch (error) {\n logger.warn(\n `Failed to check subgraph type names: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n for (const warning of warnings) logger.warn(`โš ๏ธ ${warning}`);\n}\n\n/** Adds and installs what `features` need before their files are written:\n * the package loader reloads on those files, so their imports must resolve. */\nexport async function installFeatureDependencies(\n features: readonly Feature[],\n projectDir: string,\n waiting?: string,\n job?: CodegenJob,\n): Promise<void> {\n const install = { ran: false };\n try {\n await installForFeatures(features, projectDir, {\n log: (message) => logger.info(message),\n warn: (message) => logger.warn(`โš ๏ธ ${message}`),\n waiting,\n onInstall: (packages, command) => {\n install.ran = true;\n job?.waitingForInstall(\n `Installing ${packages.join(\", \")} with \\`${command}\\``,\n );\n },\n });\n } catch (error) {\n logger.warn(\n `โš ๏ธ Could not add the dependencies of ${features.join(\", \")}: ${(error as Error).message}`,\n );\n } finally {\n if (install.ran) job?.running();\n }\n}\n","import { generateApp } from \"@powerhousedao/codegen\";\nimport type {\n AppModuleGlobalState,\n AppModulePHState,\n} from \"@powerhousedao/vetra/document-models/app-module\";\nimport { kebabCase } from \"change-case\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, GenerateResult } from \"../types.js\";\nimport { minimalBackupDocument } from \"./utils.js\";\n\n/**\n * Generator for app documents\n */\nexport class AppGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/app\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): AppModuleGlobalState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as AppModulePHState;\n return fullState.global;\n }\n\n override skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const state = this.extractGlobalState(input);\n let reason: string | undefined;\n if (!state) reason = \"The app has no state\";\n else if (!state.name) reason = \"The app has no name\";\n else if (state.status !== \"CONFIRMED\") {\n reason = `App \"${state.name}\" is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(input: CodegenInput): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n const reason = this.skipReason(input);\n if (!state || reason) {\n return { skipped: reason ?? \"The app has no state\" };\n }\n\n logger.info(`๐Ÿ”„ Starting app generation for app: ${state.name}`);\n try {\n await generateApp(\n {\n ...this.config.PH_CONFIG,\n appName: state.name,\n appId: kebabCase(state.name),\n allowedDocumentTypes: state.allowedDocumentTypes ?? [],\n isDragAndDropEnabled: state.isDragAndDropEnabled,\n },\n this.project,\n );\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during app generation for app ${state.name}:`,\n error,\n );\n throw error;\n }\n\n logger.info(\n `โœ… App generation completed successfully for app: ${state.name}`,\n );\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as AppModulePHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import { generateEditor } from \"@powerhousedao/codegen\";\nimport { kebabCase } from \"change-case\";\nimport type {\n DocumentEditorPHState,\n DocumentEditorState,\n} from \"../../../../document-models/document-editor/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, GenerateResult } from \"../types.js\";\nimport { minimalBackupDocument } from \"./utils.js\";\n\n/**\n * Generator for document editor documents\n */\nexport class DocumentEditorGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/document-editor\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): DocumentEditorState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as DocumentEditorPHState;\n return fullState.global;\n }\n\n override skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const state = this.extractGlobalState(input);\n let reason: string | undefined;\n if (!state) reason = \"The editor has no state\";\n else if (!state.name) reason = \"The editor has no name\";\n else if (state.documentTypes.length === 0) {\n reason = `Editor \"${state.name}\" has no document types`;\n } else if (state.status !== \"CONFIRMED\") {\n reason = `Editor \"${state.name}\" is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(input: CodegenInput): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n if (!state) {\n return { skipped: \"The editor has no state\" };\n }\n\n logger.info(`๐Ÿ”„ Starting editor generation for: ${state.name}`);\n try {\n await generateEditor(\n {\n ...this.config.PH_CONFIG,\n editorName: state.name,\n documentTypes: state.documentTypes.map((dt) => dt.documentType),\n editorId: kebabCase(state.name),\n },\n this.project,\n );\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during editor generation for ${state.name}:`,\n error,\n );\n throw error;\n }\n\n logger.info(\n `โœ… Editor generation completed successfully for: ${state.name}`,\n );\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as DocumentEditorPHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import {\n generateDocumentModel,\n validateDocumentModelState,\n} from \"@powerhousedao/codegen\";\nimport type {\n DocumentModelGlobalState,\n DocumentModelPHState,\n} from \"@powerhousedao/shared/document-model\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput } from \"../types.js\";\nimport { minimalBackupDocument, warnSubgraphTypeConflicts } from \"./utils.js\";\n\n/**\n * Generator for document model documents\n */\nexport class DocumentModelGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/document-model\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): DocumentModelGlobalState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as DocumentModelPHState;\n return fullState.global;\n }\n\n override skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const globalState = this.extractGlobalState(input);\n if (!globalState) {\n logger.debug(\n `>>> No global state found for document model: ${input.documentId}`,\n );\n return \"The document model has no global state\";\n }\n\n const validationResult = validateDocumentModelState(globalState);\n if (!validationResult.isValid) {\n const errorList = validationResult.errors\n .map((error) => ` - ${error}`)\n .join(\"\\n\");\n logger.info(\n `โš ๏ธ Skipped code generation for '${globalState.name || input.documentId}' due to validation errors:\\n${errorList}`,\n );\n return `The document model is not ready for code generation:\\n${errorList}`;\n }\n\n logger.info(\n `Document model ${globalState.name} is valid, proceeding with code generation`,\n );\n return undefined;\n }\n\n async generate(input: CodegenInput): Promise<void> {\n const globalState = this.extractGlobalState(input);\n if (!globalState) {\n throw new Error(\n `No global state found for document model: ${input.documentId}`,\n );\n }\n logger.debug(\n `๐Ÿ”„ Starting code generation for document model: ${globalState.name}`,\n );\n try {\n await generateDocumentModel(globalState, this.project);\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during code generation for ${globalState.name}:`,\n error,\n );\n throw error;\n }\n logger.info(\n `โœ… Code generation completed successfully for: ${globalState.name}`,\n );\n await warnSubgraphTypeConflicts(this.config.CURRENT_WORKING_DIR);\n\n const fullState = input.state as DocumentModelPHState;\n const extension = globalState.extension?.replace(/^\\.+|\\.+$/g, \"\") || \"\";\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: fullState,\n name: globalState.name,\n },\n this.config.CURRENT_WORKING_DIR,\n extension,\n );\n }\n}\n","import { createOrUpdateManifest } from \"@powerhousedao/codegen/file-builders\";\nimport type {\n VetraPackageGlobalState,\n VetraPackagePHState,\n} from \"../../../../document-models/vetra-package/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput } from \"../types.js\";\nimport { minimalBackupDocument } from \"./utils.js\";\n\n/**\n * Generator for package documents\n */\nexport class PackageGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/package\";\n\n override skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n if (!input.state) {\n logger.debug(`>>> No state found for package: ${input.documentId}`);\n return \"The package has no state\";\n }\n return undefined;\n }\n\n async generate(input: CodegenInput): Promise<void> {\n const fullState = input.state as VetraPackagePHState;\n const state = fullState.global as VetraPackageGlobalState;\n\n await createOrUpdateManifest(\n {\n name: state.name ?? \"\",\n category: state.category ?? \"\",\n description: state.description ?? \"\",\n publisher: {\n name: state.author?.name ?? \"\",\n url: state.author?.website ?? \"\",\n },\n },\n this.config.CURRENT_WORKING_DIR,\n );\n\n // Backup the document\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: fullState,\n name: \"vetra-package\",\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import { type Feature, generateProcessor } from \"@powerhousedao/codegen\";\nimport {\n PROCESSOR_APPS,\n type ProcessorApp,\n type ProcessorApps,\n} from \"@powerhousedao/shared/processors\";\nimport type {\n ProcessorModulePHState,\n ProcessorModuleState,\n} from \"../../../../document-models/processor-module/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, CodegenJob, GenerateResult } from \"../types.js\";\nimport { installFeatureDependencies, minimalBackupDocument } from \"./utils.js\";\n\nconst PROCESSOR_TYPES = {\n analytics: \"analytics\",\n relational: \"relationalDb\",\n} as const;\n\n/**\n * Generator for processor documents\n */\nexport class ProcessorGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/processor\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): ProcessorModuleState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as ProcessorModulePHState;\n return fullState.global;\n }\n\n override skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const reason = invalidReason(this.extractGlobalState(input));\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(\n input: CodegenInput,\n job?: CodegenJob,\n ): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n const reason = this.skipReason(input);\n if (!state || reason) {\n return { skipped: reason ?? \"The processor has no state\" };\n }\n const processorType =\n PROCESSOR_TYPES[state.type as keyof typeof PROCESSOR_TYPES];\n const processorApps = state.processorApps as ProcessorApps;\n logger.info(`๐Ÿ”„ Starting processor generation for: ${state.name}`);\n try {\n const features: Feature[] =\n processorType === \"analytics\"\n ? [\"analyticsProcessor\"]\n : [\"relationalDbProcessor\"];\n await installFeatureDependencies(\n features,\n this.config.CURRENT_WORKING_DIR,\n `processor \"${state.name}\"`,\n job,\n );\n\n await generateProcessor(\n {\n processorName: state.name,\n processorType,\n documentTypes: state.documentTypes.map((dt) => dt.documentType),\n processorApps,\n },\n this.project,\n );\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during processor generation for ${state.name}:`,\n error,\n );\n throw error;\n }\n\n logger.info(\n `โœ… Processor generation completed successfully for: ${state.name}`,\n );\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as ProcessorModulePHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n\nfunction invalidReason(\n state: ProcessorModuleState | undefined,\n): string | undefined {\n if (!state) return \"The processor has no state\";\n if (!state.name) return \"The processor has no name\";\n const processor = `Processor \"${state.name}\"`;\n if (!state.type) return `${processor} has no type`;\n if (!(state.type in PROCESSOR_TYPES)) {\n return `${processor} has the unsupported type \"${state.type}\"; use ${Object.keys(PROCESSOR_TYPES).join(\" or \")}`;\n }\n if (state.documentTypes.length === 0) {\n return `${processor} has no document types`;\n }\n if (state.processorApps.length === 0) {\n return `${processor} has no processor apps`;\n }\n if (!isProcessorApps(state.processorApps)) {\n return `${processor} has unsupported processor apps (${state.processorApps.join(\", \")}); use ${PROCESSOR_APPS.join(\", \")}, each once`;\n }\n if (state.status !== \"CONFIRMED\") {\n return `${processor} is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n return undefined;\n}\n\nfunction isProcessorApps(input: readonly string[]): input is ProcessorApps {\n if (input.length === 0) return false;\n if (new Set(input).size !== input.length) {\n return false;\n }\n if (!input.every((i) => PROCESSOR_APPS.includes(i as ProcessorApp)))\n return false;\n\n return true;\n}\n","import { generateSubgraph } from \"@powerhousedao/codegen\";\nimport { findSubgraphNameConflict } from \"../../../../codegen/subgraph-type-lint.js\";\nimport type {\n SubgraphModulePHState,\n SubgraphModuleState,\n} from \"../../../../document-models/subgraph-module/index.js\";\nimport { logger } from \"../../logger.js\";\nimport { BaseDocumentGen } from \"../base-document-gen.js\";\nimport type { CodegenInput, CodegenJob, GenerateResult } from \"../types.js\";\nimport {\n installFeatureDependencies,\n minimalBackupDocument,\n warnSubgraphTypeConflicts,\n} from \"./utils.js\";\n\n/**\n * Generator for subgraph documents\n */\nexport class SubgraphGenerator extends BaseDocumentGen {\n readonly supportedDocumentTypes = \"powerhouse/subgraph\";\n\n private extractGlobalState(\n input: CodegenInput,\n ): SubgraphModuleState | undefined {\n if (!input.state) {\n return undefined;\n }\n const fullState = input.state as SubgraphModulePHState;\n return fullState.global;\n }\n\n override skipReason(input: CodegenInput): string | undefined {\n const base = super.skipReason(input);\n if (base) return base;\n\n const state = this.extractGlobalState(input);\n let reason: string | undefined;\n if (!state) reason = \"The subgraph has no state\";\n else if (!state.name) reason = \"The subgraph has no name\";\n else if (state.status !== \"CONFIRMED\") {\n reason = `Subgraph \"${state.name}\" is not confirmed (status: ${state.status}); codegen runs once it is CONFIRMED`;\n }\n if (reason) logger.debug(reason);\n return reason;\n }\n\n async generate(\n input: CodegenInput,\n job?: CodegenJob,\n ): Promise<GenerateResult> {\n const state = this.extractGlobalState(input);\n const reason = this.skipReason(input);\n if (!state || reason) {\n return { skipped: reason ?? \"The subgraph has no state\" };\n }\n\n logger.info(`๐Ÿ”„ Starting subgraph generation for: ${state.name}`);\n try {\n const conflict = await findSubgraphNameConflict(\n this.config.CURRENT_WORKING_DIR,\n state.name,\n );\n if (conflict) {\n logger.error(`โŒ Skipping subgraph generation: ${conflict}`);\n return { skipped: conflict };\n }\n await installFeatureDependencies(\n [\"subgraph\"],\n this.config.CURRENT_WORKING_DIR,\n `subgraph \"${state.name}\"`,\n job,\n );\n await generateSubgraph(state.name, this.project);\n await this.project.save();\n } catch (error) {\n logger.error(\n `โŒ Error during subgraph generation for ${state.name}:`,\n error,\n );\n throw error;\n }\n logger.info(\n `โœ… Subgraph generation completed successfully for: ${state.name}`,\n );\n await warnSubgraphTypeConflicts(this.config.CURRENT_WORKING_DIR);\n\n await minimalBackupDocument(\n {\n documentId: input.documentId,\n documentType: input.documentType,\n branch: input.branch,\n state: input.state as SubgraphModulePHState,\n name: state.name,\n },\n this.config.CURRENT_WORKING_DIR,\n );\n }\n}\n","import type { CodegenStatusRegistry } from \"@powerhousedao/shared/processors\";\nimport type { Project } from \"ts-morph\";\nimport type { BaseDocumentGen } from \"./base-document-gen.js\";\nimport { DocumentCodegenManager } from \"./document-codegen-manager.js\";\nimport {\n AppGenerator,\n DocumentEditorGenerator,\n DocumentModelGenerator,\n PackageGenerator,\n ProcessorGenerator,\n SubgraphGenerator,\n} from \"./generators/index.js\";\nimport type { Config } from \"./types.js\";\n\n/**\n * Factory class for creating and configuring DocumentCodegenManager instances\n * with all the standard generators pre-registered\n */\nexport class DocumentCodegenFactory {\n /**\n * Create a DocumentCodegenManager with all standard generators registered\n */\n static createManager(\n config: Config,\n project: Project,\n interactiveMode: boolean = false,\n status?: CodegenStatusRegistry,\n ): DocumentCodegenManager {\n const manager = new DocumentCodegenManager(\n config,\n project,\n interactiveMode,\n status,\n );\n\n // Register all the standard generators\n manager.registerGenerator(\n \"powerhouse/document-model\",\n DocumentModelGenerator,\n );\n manager.registerGenerator(\"powerhouse/package\", PackageGenerator);\n manager.registerGenerator(\"powerhouse/app\", AppGenerator);\n manager.registerGenerator(\n \"powerhouse/document-editor\",\n DocumentEditorGenerator,\n );\n manager.registerGenerator(\"powerhouse/subgraph\", SubgraphGenerator);\n manager.registerGenerator(\"powerhouse/processor\", ProcessorGenerator);\n\n return manager;\n }\n\n /**\n * Create a DocumentCodegenManager with only specific generators\n */\n static createManagerWithGenerators(\n config: Config,\n generators: Array<new (config: Config) => any>,\n project: Project,\n interactiveMode: boolean = false,\n status?: CodegenStatusRegistry,\n ): DocumentCodegenManager {\n const manager = new DocumentCodegenManager(\n config,\n project,\n interactiveMode,\n status,\n );\n\n for (const generatorClass of generators) {\n const generator = new generatorClass(config) as BaseDocumentGen;\n const supportedTypes = generator.getSupportedDocumentTypes();\n\n for (const documentType of supportedTypes) {\n manager.registerGenerator(documentType, generatorClass);\n }\n }\n\n return manager;\n }\n\n /**\n * Get all available generator classes\n */\n static getAvailableGenerators() {\n return {\n DocumentModelGenerator,\n PackageGenerator,\n AppGenerator,\n DocumentEditorGenerator,\n SubgraphGenerator,\n ProcessorGenerator,\n };\n }\n}\n","import type {\n IProcessor,\n IReactorClient,\n OperationWithContext,\n} from \"@powerhousedao/reactor-browser\";\nimport type { PowerhouseConfig } from \"@powerhousedao/shared\";\nimport type { DocumentDriveDocument } from \"@powerhousedao/shared/document-drive\";\nimport type { Project } from \"ts-morph\";\nimport type { DocumentCodegenManager } from \"./document-handlers/document-codegen-manager.js\";\nimport { DocumentCodegenFactory } from \"./document-handlers/index.js\";\nimport type { CodegenInput } from \"./document-handlers/types.js\";\nimport { logger } from \"./logger.js\";\n\nexport class CodegenProcessor implements IProcessor {\n private manager: DocumentCodegenManager;\n\n constructor(\n project: Project,\n config: PowerhouseConfig,\n cwd: string,\n private readonly driveId: string,\n private readonly client: IReactorClient,\n interactiveMode = false,\n ) {\n this.manager = DocumentCodegenFactory.createManager(\n {\n PH_CONFIG: config,\n CURRENT_WORKING_DIR: cwd,\n },\n project,\n interactiveMode,\n );\n this.manager.setScope((documentId) => this.isInDrive(documentId));\n\n if (interactiveMode) {\n logger.info(`CodegenProcessor initialized with interactive mode enabled`);\n } else {\n logger.debug(\n `CodegenProcessor initialized with interactive mode disabled`,\n );\n }\n }\n\n async onOperations(operations: OperationWithContext[]): Promise<void> {\n logger.debug(\"CodegenProcessor.onOperations()\");\n\n // Only a document's final state in the batch is generated from.\n const latest = new Map<string, OperationWithContext>();\n for (const operation of operations) {\n latest.set(operation.context.documentId, operation);\n }\n\n for (const { context } of latest.values()) {\n const generator = this.manager.getGenerator(context.documentType);\n if (!generator) {\n logger.debug(\n `No generator found for document type: ${context.documentType}`,\n );\n continue;\n }\n\n const input: CodegenInput = {\n documentId: context.documentId,\n documentType: context.documentType,\n scope: context.scope,\n branch: context.branch,\n state: context.resultingState\n ? JSON.parse(context.resultingState)\n : undefined,\n };\n\n await this.manager.routeAndGenerate(input);\n }\n }\n\n async onDisconnect() {}\n\n // Utility methods for external configuration and monitoring\n public setInteractiveMode(enabled: boolean): void {\n this.manager.setInteractiveMode(enabled);\n }\n\n public isInteractive(): boolean {\n return this.manager.isInteractiveMode();\n }\n\n public isProcessingInteractive(): boolean {\n return this.manager.isProcessingInteractive();\n }\n\n /**\n * The reactor delivers every drive's operations, so membership is checked\n * here: a node of the drive (in any folder, and in drives older than\n * relationship edges), or a child edge from it (a document attached by\n * relationship alone).\n */\n private async isInDrive(documentId: string): Promise<boolean> {\n try {\n const drive = await this.client.get<DocumentDriveDocument>(this.driveId);\n if (drive.state.global.nodes.some((node) => node.id === documentId)) {\n return true;\n }\n } catch (error) {\n logger.debug(`Could not read the Vetra drive ${this.driveId}:`, error);\n }\n try {\n const parents = await this.client.getIncomingRelationshipEdges(\n documentId,\n \"child\",\n );\n return parents.results.some((edge) => edge.sourceId === this.driveId);\n } catch (error) {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AO,QAAQ,iBACX,KAAK,MAAM,QAAQ,cAAc,IACjC,KAAA;GACN;GAEA,MAAM,KAAK,QAAQ,iBAAiB,KAAK;EAC3C;CACF;CAEA,MAAM,eAAe,CAAC;CAGtB,mBAA0B,SAAwB;EAChD,KAAK,QAAQ,mBAAmB,OAAO;CACzC;CAEA,gBAAgC;EAC9B,OAAO,KAAK,QAAQ,kBAAkB;CACxC;CAEA,0BAA0C;EACxC,OAAO,KAAK,QAAQ,wBAAwB;CAC9C;;;;;;;CAQA,MAAc,UAAU,YAAsC;EAC5D,IAAI;GAEF,KAAI,MADgB,KAAK,OAAO,IAA2B,KAAK,OAAO,EAAA,CAC7D,MAAM,OAAO,MAAM,MAAM,SAAS,KAAK,OAAO,UAAU,GAChE,OAAO;EAEX,SAAS,OAAO;GACd,OAAO,MAAM,kCAAkC,KAAK,QAAQ,IAAI,KAAK;EACvE;EACA,IAAI;GAKF,QAAO,MAJe,KAAK,OAAO,6BAChC,YACA,OACF,EAAA,CACe,QAAQ,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO;EACtE,SAAS,OAAO;GACd,OAAO,MAAM,iCAAiC,WAAW,IAAI,KAAK;GAClE,OAAO;EACT;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/vetra",
3
- "version": "6.2.3-dev.79",
3
+ "version": "6.2.3-dev.80",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -61,21 +61,21 @@
61
61
  "./package.json": "./package.json"
62
62
  },
63
63
  "dependencies": {
64
- "@powerhousedao/codegen": "6.2.3-dev.79",
65
- "@powerhousedao/config": "6.2.3-dev.79",
66
- "@powerhousedao/design-system": "6.2.3-dev.79",
67
- "@powerhousedao/reactor-api": "6.2.3-dev.79",
68
- "@powerhousedao/reactor-browser": "6.2.3-dev.79",
69
- "@powerhousedao/shared": "6.2.3-dev.79",
64
+ "@powerhousedao/codegen": "6.2.3-dev.80",
65
+ "@powerhousedao/config": "6.2.3-dev.80",
66
+ "@powerhousedao/design-system": "6.2.3-dev.80",
67
+ "@powerhousedao/reactor-api": "6.2.3-dev.80",
68
+ "@powerhousedao/reactor-browser": "6.2.3-dev.80",
69
+ "@powerhousedao/shared": "6.2.3-dev.80",
70
70
  "change-case": "5.4.4",
71
- "document-model": "6.2.3-dev.79",
71
+ "document-model": "6.2.3-dev.80",
72
72
  "graphql": "^16",
73
73
  "react": "19.2.6",
74
74
  "zod": "^4.5.4",
75
75
  "tailwind-merge": "3.4.0"
76
76
  },
77
77
  "devDependencies": {
78
- "@powerhousedao/builder-tools": "6.2.3-dev.79",
78
+ "@powerhousedao/builder-tools": "6.2.3-dev.80",
79
79
  "@tailwindcss/cli": "4.2.2",
80
80
  "@testing-library/jest-dom": "^6.9.1",
81
81
  "@testing-library/react": "^16.3.0",