@powerhousedao/vetra 4.1.0-dev.101 → 4.1.0-dev.102

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":"app-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/app-generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,qBAAa,YAAa,SAAQ,eAAe;IAC/C,QAAQ,CAAC,sBAAsB,oBAAoB;IAEnD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IA4BnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CA0EjE"}
1
+ {"version":3,"file":"app-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/app-generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,qBAAa,YAAa,SAAQ,eAAe;IAC/C,QAAQ,CAAC,sBAAsB,oBAAoB;IAEnD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IA4BnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CA6EjE"}
@@ -2,6 +2,7 @@ import { generateDriveEditor, generateManifest } from "@powerhousedao/codegen";
2
2
  import { kebabCase } from "change-case";
3
3
  import { logger } from "../../logger.js";
4
4
  import { BaseDocumentGen } from "../base-document-gen.js";
5
+ import { backupDocument } from "./utils.js";
5
6
  /**
6
7
  * Generator for app documents
7
8
  */
@@ -66,6 +67,8 @@ export class AppGenerator extends BaseDocumentGen {
66
67
  logger.error(`⚠️ Failed to update manifest for app ${state.name}:`, manifestError);
67
68
  // Don't throw here - drive editor generation was successful
68
69
  }
70
+ // Backup the document
71
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR);
69
72
  }
70
73
  catch (error) {
71
74
  logger.error(`❌ Error during drive editor generation for app ${state.name}:`, error);
@@ -1 +1 @@
1
- {"version":3,"file":"document-editor-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/document-editor-generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,QAAQ,CAAC,sBAAsB,gCAAgC;IAE/D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAuCnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAiEjE"}
1
+ {"version":3,"file":"document-editor-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/document-editor-generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,QAAQ,CAAC,sBAAsB,gCAAgC;IAE/D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAuCnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAyEjE"}
@@ -2,6 +2,7 @@ import { generateEditor, generateManifest } from "@powerhousedao/codegen";
2
2
  import { kebabCase } from "change-case";
3
3
  import { logger } from "../../logger.js";
4
4
  import { BaseDocumentGen } from "../base-document-gen.js";
5
+ import { backupDocument } from "./utils.js";
5
6
  /**
6
7
  * Generator for document editor documents
7
8
  */
@@ -65,6 +66,8 @@ export class DocumentEditorGenerator extends BaseDocumentGen {
65
66
  logger.error(`⚠️ Failed to update manifest for editor ${state.name}:`, manifestError);
66
67
  // Don't throw here - editor generation was successful
67
68
  }
69
+ // Backup the document
70
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, undefined, state.name);
68
71
  }
69
72
  catch (error) {
70
73
  logger.error(`❌ Error during editor generation for ${state.name}:`, error);
@@ -1 +1 @@
1
- {"version":3,"file":"document-model-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/document-model-generator.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,QAAQ,CAAC,sBAAsB,+BAA+B;IAE9D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IA6BnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAuDjE"}
1
+ {"version":3,"file":"document-model-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/document-model-generator.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,QAAQ,CAAC,sBAAsB,+BAA+B;IAE9D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IA6BnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgEjE"}
@@ -1,6 +1,7 @@
1
1
  import { generateFromDocument, generateManifest, generateSubgraphFromDocumentModel, validateDocumentModelState, } from "@powerhousedao/codegen";
2
2
  import { logger } from "../../logger.js";
3
3
  import { BaseDocumentGen } from "../base-document-gen.js";
4
+ import { backupDocument } from "./utils.js";
4
5
  /**
5
6
  * Generator for document model documents
6
7
  */
@@ -57,6 +58,9 @@ export class DocumentModelGenerator extends BaseDocumentGen {
57
58
  logger.error(`⚠️ Failed to update manifest for document model ${state.name}:`, manifestError);
58
59
  // Don't throw here - code generation was successful
59
60
  }
61
+ // Backup the document
62
+ const extension = state.extension?.replace(/^\.+|\.+$/g, "") || "";
63
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, extension, state.name);
60
64
  }
61
65
  catch (error) {
62
66
  logger.error(`❌ Error during code generation for ${state.name}:`, error);
@@ -1 +1 @@
1
- {"version":3,"file":"package-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/package-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,QAAQ,CAAC,sBAAsB,wBAAwB;IAEvD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAenD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjE"}
1
+ {"version":3,"file":"package-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/package-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,QAAQ,CAAC,sBAAsB,wBAAwB;IAEvD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAenD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BjE"}
@@ -1,6 +1,7 @@
1
1
  import { generateManifest } from "@powerhousedao/codegen";
2
2
  import { logger } from "../../logger.js";
3
3
  import { BaseDocumentGen } from "../base-document-gen.js";
4
+ import { backupDocument } from "./utils.js";
4
5
  /**
5
6
  * Generator for package documents
6
7
  */
@@ -34,5 +35,7 @@ export class PackageGenerator extends BaseDocumentGen {
34
35
  },
35
36
  }, this.config.CURRENT_WORKING_DIR);
36
37
  logger.info("✅ Manifest generated successfully");
38
+ // Backup the document
39
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, undefined, "vetra-package");
37
40
  }
38
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"processor-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/processor-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,QAAQ,CAAC,sBAAsB,0BAA0B;IAEzD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAsCnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAsEjE"}
1
+ {"version":3,"file":"processor-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/processor-generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,QAAQ,CAAC,sBAAsB,0BAA0B;IAEzD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAsCnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CA8EjE"}
@@ -1,6 +1,7 @@
1
1
  import { generateProcessor } from "@powerhousedao/codegen";
2
2
  import { logger } from "../../logger.js";
3
3
  import { BaseDocumentGen } from "../base-document-gen.js";
4
+ import { backupDocument } from "./utils.js";
4
5
  /**
5
6
  * Generator for processor documents
6
7
  */
@@ -64,6 +65,8 @@ export class ProcessorGenerator extends BaseDocumentGen {
64
65
  // Generate the processor using the codegen function
65
66
  await generateProcessor(state.name, processorType, documentTypes, this.config.PH_CONFIG);
66
67
  logger.info(`✅ Processor generation completed successfully for: ${state.name}`);
68
+ // Backup the document
69
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, undefined, state.name);
67
70
  }
68
71
  catch (error) {
69
72
  logger.error(`❌ Error during processor generation for ${state.name}:`, error);
@@ -1 +1 @@
1
- {"version":3,"file":"subgraph-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/subgraph-generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACpD,QAAQ,CAAC,sBAAsB,yBAAyB;IAExD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IA4BnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgEjE"}
1
+ {"version":3,"file":"subgraph-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/subgraph-generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACpD,QAAQ,CAAC,sBAAsB,yBAAyB;IAExD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IA4BnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAwEjE"}
@@ -2,6 +2,7 @@ import { generateManifest, generateSubgraph } from "@powerhousedao/codegen";
2
2
  import { kebabCase } from "change-case";
3
3
  import { logger } from "../../logger.js";
4
4
  import { BaseDocumentGen } from "../base-document-gen.js";
5
+ import { backupDocument } from "./utils.js";
5
6
  /**
6
7
  * Generator for subgraph documents
7
8
  */
@@ -59,6 +60,8 @@ export class SubgraphGenerator extends BaseDocumentGen {
59
60
  logger.error(`⚠️ Failed to update manifest for subgraph ${state.name}:`, manifestError);
60
61
  // Don't throw here - subgraph generation was successful
61
62
  }
63
+ // Backup the document
64
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, undefined, state.name);
62
65
  }
63
66
  catch (error) {
64
67
  logger.error(`❌ Error during subgraph generation for ${state.name}:`, error);
@@ -0,0 +1,13 @@
1
+ import type { PHDocument } from "document-model";
2
+ /**
3
+ * Exports a document to the backup directory.
4
+ * Creates the backup directory if it doesn't exist.
5
+ *
6
+ * @param document - The document to backup
7
+ * @param workingDir - Current working directory
8
+ * @param extension - File extension for the document type (without dot)
9
+ * @param name - Name of the document to use for the backup file (optional)
10
+ * @returns Promise resolving to the backup file path, or undefined if backup failed
11
+ */
12
+ export declare function backupDocument(document: PHDocument, workingDir: string, extension?: string, name?: string): Promise<string | undefined>;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQjD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAW,EACtB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoB7B"}
@@ -0,0 +1,29 @@
1
+ import { baseSaveToFile } from "document-model/node";
2
+ import { mkdir } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { logger } from "../../logger.js";
5
+ const BACKUP_FOLDER = "backup-documents";
6
+ /**
7
+ * Exports a document to the backup directory.
8
+ * Creates the backup directory if it doesn't exist.
9
+ *
10
+ * @param document - The document to backup
11
+ * @param workingDir - Current working directory
12
+ * @param extension - File extension for the document type (without dot)
13
+ * @param name - Name of the document to use for the backup file (optional)
14
+ * @returns Promise resolving to the backup file path, or undefined if backup failed
15
+ */
16
+ export async function backupDocument(document, workingDir, extension = "", name) {
17
+ const docName = name ?? document.header.name;
18
+ try {
19
+ const backupPath = join(workingDir, BACKUP_FOLDER);
20
+ await mkdir(backupPath, { recursive: true });
21
+ const filePath = await baseSaveToFile(document, backupPath, extension, docName);
22
+ logger.debug(`📁 Document backed up to: ${filePath}`);
23
+ return filePath;
24
+ }
25
+ catch (error) {
26
+ logger.warn(`⚠️ Failed to backup document "${docName}":`, error);
27
+ return undefined;
28
+ }
29
+ }