@powerhousedao/vetra 6.0.0-dev.12 → 6.0.0-dev.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.js +3 -3
  2. package/dist/processors/codegen/document-handlers/generators/document-model-generator.d.ts +4 -0
  3. package/dist/processors/codegen/document-handlers/generators/document-model-generator.d.ts.map +1 -1
  4. package/dist/processors/codegen/document-handlers/generators/document-model-generator.js +35 -19
  5. package/dist/processors/codegen/factory.d.ts +2 -1
  6. package/dist/processors/codegen/factory.d.ts.map +1 -1
  7. package/dist/processors/codegen/factory.legacy.d.ts +4 -0
  8. package/dist/processors/codegen/factory.legacy.d.ts.map +1 -0
  9. package/dist/processors/codegen/factory.legacy.js +53 -0
  10. package/dist/processors/codegen/index.d.ts +2 -2
  11. package/dist/processors/codegen/index.d.ts.map +1 -1
  12. package/dist/processors/codegen/index.js +22 -21
  13. package/dist/processors/codegen/index.legacy.d.ts +11 -0
  14. package/dist/processors/codegen/index.legacy.d.ts.map +1 -0
  15. package/dist/processors/codegen/index.legacy.js +57 -0
  16. package/dist/processors/factory.d.ts +4 -4
  17. package/dist/processors/factory.d.ts.map +1 -1
  18. package/dist/processors/factory.js +4 -3
  19. package/dist/processors/factory.legacy.d.ts +7 -0
  20. package/dist/processors/factory.legacy.d.ts.map +1 -0
  21. package/dist/processors/factory.legacy.js +20 -0
  22. package/dist/processors/index.d.ts +8 -2
  23. package/dist/processors/index.d.ts.map +1 -1
  24. package/dist/processors/index.js +10 -2
  25. package/dist/processors/vetra-read-model/factory.d.ts +3 -2
  26. package/dist/processors/vetra-read-model/factory.d.ts.map +1 -1
  27. package/dist/processors/vetra-read-model/factory.js +13 -16
  28. package/dist/processors/vetra-read-model/factory.legacy.d.ts +4 -0
  29. package/dist/processors/vetra-read-model/factory.legacy.d.ts.map +1 -0
  30. package/dist/processors/vetra-read-model/factory.legacy.js +24 -0
  31. package/dist/processors/vetra-read-model/index.d.ts +6 -5
  32. package/dist/processors/vetra-read-model/index.d.ts.map +1 -1
  33. package/dist/processors/vetra-read-model/index.js +20 -37
  34. package/dist/processors/vetra-read-model/index.legacy.d.ts +9 -0
  35. package/dist/processors/vetra-read-model/index.legacy.d.ts.map +1 -0
  36. package/dist/processors/vetra-read-model/index.legacy.js +75 -0
  37. package/dist/subgraphs/vetra-read-model/resolvers.d.ts.map +1 -1
  38. package/dist/subgraphs/vetra-read-model/resolvers.js +2 -3
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +15 -14
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { USE_TS_MORPH, USE_VERSIONING, } from "../document-handlers/generators/constants.js";
4
- import { CodegenProcessor } from "../index.js";
4
+ import { CodegenProcessorLegacy } from "../index.legacy.js";
5
5
  const defaultManifest = {
6
6
  name: "",
7
7
  description: "",
@@ -55,7 +55,7 @@ vi.mock("../logger.js", () => ({
55
55
  error: vi.fn(),
56
56
  },
57
57
  }));
58
- describe("CodegenProcessor E2E Tests", () => {
58
+ describe("CodegenProcessorLegacy E2E Tests", () => {
59
59
  let processor;
60
60
  let mockConfig;
61
61
  beforeEach(async () => {
@@ -68,7 +68,7 @@ describe("CodegenProcessor E2E Tests", () => {
68
68
  CURRENT_WORKING_DIR: process.cwd(),
69
69
  };
70
70
  // Create a REAL processor instance (not mocked)
71
- processor = new CodegenProcessor();
71
+ processor = new CodegenProcessorLegacy();
72
72
  // Reset all codegen function mocks to resolve successfully
73
73
  const codegen = await import("@powerhousedao/codegen");
74
74
  vi.mocked(codegen.generateEditor).mockResolvedValue();
@@ -5,6 +5,10 @@ import { BaseDocumentGen } from "../base-document-gen.js";
5
5
  */
6
6
  export declare class DocumentModelGenerator extends BaseDocumentGen {
7
7
  readonly supportedDocumentTypes = "powerhouse/document-model";
8
+ /**
9
+ * Extract the global state from the full document state
10
+ */
11
+ private extractGlobalState;
8
12
  /**
9
13
  * Validate if this document model strand should be processed
10
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"document-model-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/document-model-generator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI1D;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,QAAQ,CAAC,sBAAsB,+BAA+B;IAE9D;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAiCnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CA4DjE"}
1
+ {"version":3,"file":"document-model-generator.d.ts","sourceRoot":"","sources":["../../../../../processors/codegen/document-handlers/generators/document-model-generator.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAMhE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI1D;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,QAAQ,CAAC,sBAAsB,+BAA+B;IAE9D;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO;IAiCnD,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAqEjE"}
@@ -8,6 +8,18 @@ import { backupDocument } from "./utils.js";
8
8
  */
9
9
  export class DocumentModelGenerator extends BaseDocumentGen {
10
10
  supportedDocumentTypes = "powerhouse/document-model";
11
+ /**
12
+ * Extract the global state from the full document state
13
+ */
14
+ extractGlobalState(strand) {
15
+ const fullState = strand.state;
16
+ if (!fullState) {
17
+ return undefined;
18
+ }
19
+ // The state is the full document state with {auth, document, local, global, header}
20
+ // We need the global property which contains the DocumentModelGlobalState
21
+ return fullState.global;
22
+ }
11
23
  /**
12
24
  * Validate if this document model strand should be processed
13
25
  */
@@ -16,58 +28,62 @@ export class DocumentModelGenerator extends BaseDocumentGen {
16
28
  if (!super.shouldProcess(strand)) {
17
29
  return false;
18
30
  }
19
- // Validate document model state
20
- const state = strand.state;
21
- if (!state) {
22
- logger.debug(`>>> No state found for document model: ${strand.documentId}`);
31
+ // Extract the global state from the full document state
32
+ const globalState = this.extractGlobalState(strand);
33
+ if (!globalState) {
34
+ logger.debug(`>>> No global state found for document model: ${strand.documentId}`);
23
35
  return false;
24
36
  }
25
- const validationResult = validateDocumentModelState(state);
37
+ const validationResult = validateDocumentModelState(globalState);
26
38
  if (!validationResult.isValid) {
27
39
  const errorList = validationResult.errors
28
40
  .map((error) => ` - ${error}`)
29
41
  .join("\n");
30
- logger.info(`⚠️ Skipped code generation for '${state.name || strand.documentId}' due to validation errors:\n${errorList}`);
42
+ logger.info(`⚠️ Skipped code generation for '${globalState.name || strand.documentId}' due to validation errors:\n${errorList}`);
31
43
  return false;
32
44
  }
33
- logger.info(`Document model ${state.name} is valid, proceeding with code generation`);
45
+ logger.info(`Document model ${globalState.name} is valid, proceeding with code generation`);
34
46
  return true;
35
47
  }
36
48
  async generate(strand) {
37
- const state = strand.state;
49
+ const globalState = this.extractGlobalState(strand);
50
+ if (!globalState) {
51
+ logger.error(`❌ No global state found for document model: ${strand.documentId}`);
52
+ return;
53
+ }
38
54
  // Validation is already done in shouldProcess, so we can proceed directly
39
- logger.debug(`🔄 Starting code generation for document model: ${state.name}`);
55
+ logger.debug(`🔄 Starting code generation for document model: ${globalState.name}`);
40
56
  try {
41
57
  await generateFromDocument({
42
- documentModelState: state,
58
+ documentModelState: globalState,
43
59
  config: this.config.PH_CONFIG,
44
60
  useTsMorph: USE_TS_MORPH,
45
61
  useVersioning: USE_VERSIONING,
46
62
  });
47
- logger.info(`✅ Code generation completed successfully for: ${state.name}`);
63
+ logger.info(`✅ Code generation completed successfully for: ${globalState.name}`);
48
64
  // Update the manifest with the new document model
49
65
  try {
50
- logger.debug(`🔄 Updating manifest with document model: ${state.name} (ID: ${state.id})`);
66
+ logger.debug(`🔄 Updating manifest with document model: ${globalState.name} (ID: ${globalState.id})`);
51
67
  generateManifest({
52
68
  documentModels: [
53
69
  {
54
- id: state.id,
55
- name: state.name,
70
+ id: globalState.id,
71
+ name: globalState.name,
56
72
  },
57
73
  ],
58
74
  }, this.config.CURRENT_WORKING_DIR);
59
- logger.debug(`✅ Manifest updated successfully for document model: ${state.name}`);
75
+ logger.debug(`✅ Manifest updated successfully for document model: ${globalState.name}`);
60
76
  }
61
77
  catch (manifestError) {
62
- logger.error(`⚠️ Failed to update manifest for document model ${state.name}:`, manifestError);
78
+ logger.error(`⚠️ Failed to update manifest for document model ${globalState.name}:`, manifestError);
63
79
  // Don't throw here - code generation was successful
64
80
  }
65
81
  // Backup the document
66
- const extension = state.extension?.replace(/^\.+|\.+$/g, "") || "";
67
- await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, extension, state.name);
82
+ const extension = globalState.extension?.replace(/^\.+|\.+$/g, "") || "";
83
+ await backupDocument(strand.document, this.config.CURRENT_WORKING_DIR, extension, globalState.name);
68
84
  }
69
85
  catch (error) {
70
- logger.error(`❌ Error during code generation for ${state.name}:`, error);
86
+ logger.error(`❌ Error during code generation for ${globalState.name}:`, error);
71
87
  // Don't throw - let codegen continue with other documents
72
88
  return;
73
89
  }
@@ -1,4 +1,5 @@
1
- import type { IProcessorHostModule, ProcessorRecord } from "document-drive";
1
+ import type { ProcessorRecord } from "@powerhousedao/reactor";
2
+ import type { IProcessorHostModule } from "document-drive";
2
3
  import type { PHDocumentHeader } from "document-model";
3
4
  export declare const codegenProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => ProcessorRecord[];
4
5
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/codegen/factory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgCvD,eAAO,MAAM,uBAAuB,GACjC,QAAQ,oBAAoB,MAC5B,aAAa,gBAAgB,KAAG,eAAe,EAsC/C,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/codegen/factory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgCvD,eAAO,MAAM,uBAAuB,GACjC,QAAQ,oBAAoB,MAC5B,aAAa,gBAAgB,KAAG,eAAe,EAsC/C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IProcessorHostModule, ProcessorRecord } from "document-drive";
2
+ import type { PHDocumentHeader } from "document-model";
3
+ export declare const codegenProcessorFactoryLegacy: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => ProcessorRecord[];
4
+ //# sourceMappingURL=factory.legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.legacy.d.ts","sourceRoot":"","sources":["../../../processors/codegen/factory.legacy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgCvD,eAAO,MAAM,6BAA6B,GACvC,QAAQ,oBAAoB,MAC5B,aAAa,gBAAgB,KAAG,eAAe,EAsC/C,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { VETRA_PROCESSOR_CONFIG_KEY } from "@powerhousedao/config";
2
+ import { CodegenProcessorLegacy } from "./index.legacy.js";
3
+ import { logger } from "./logger.js";
4
+ /**
5
+ * Determines if a drive header matches the Vetra drive criteria.
6
+ * @param driveHeader - The drive header to check
7
+ * @param explicitDriveId - Optional explicit drive ID from config (if set, uses exact match)
8
+ * @returns true if the drive is a Vetra drive, false otherwise
9
+ */
10
+ function isDriveVetra(driveHeader, driveIdFromConfig) {
11
+ // If explicit drive ID is configured, use exact match
12
+ if (driveIdFromConfig) {
13
+ return (driveHeader.slug === driveIdFromConfig ||
14
+ driveHeader.id === driveIdFromConfig);
15
+ }
16
+ // Otherwise, check if slug/id matches Vetra pattern
17
+ // Matches "vetra" exactly or IDs starting with "vetra-" (case-insensitive)
18
+ const matchesPattern = (identifier) => {
19
+ const lower = identifier.toLowerCase();
20
+ return lower === "vetra" || lower.startsWith("vetra-");
21
+ };
22
+ return matchesPattern(driveHeader.slug) || matchesPattern(driveHeader.id);
23
+ }
24
+ export const codegenProcessorFactoryLegacy = (module) => (driveHeader) => {
25
+ // Create the processor
26
+ const processorsConfig = module.config ?? new Map();
27
+ const vetraConfig = processorsConfig.get(VETRA_PROCESSOR_CONFIG_KEY);
28
+ // Check if this drive should use the Vetra processor
29
+ if (!isDriveVetra(driveHeader, vetraConfig?.driveId)) {
30
+ logger.info(`Drive ${driveHeader.slug} is not a Vetra drive, skipping codegen processor`);
31
+ return [];
32
+ }
33
+ logger.info(`Drive ${driveHeader.slug} is a Vetra drive, using codegen processor (legacy)`);
34
+ const processor = new CodegenProcessorLegacy(vetraConfig?.interactive);
35
+ return [
36
+ {
37
+ processor,
38
+ filter: {
39
+ branch: ["main"],
40
+ documentId: ["*"],
41
+ documentType: [
42
+ "powerhouse/document-model",
43
+ "powerhouse/package",
44
+ "powerhouse/document-editor",
45
+ "powerhouse/subgraph",
46
+ "powerhouse/processor",
47
+ "powerhouse/app",
48
+ ],
49
+ scope: ["global"],
50
+ },
51
+ },
52
+ ];
53
+ };
@@ -1,8 +1,8 @@
1
- import type { InternalTransmitterUpdate, IProcessor } from "document-drive";
1
+ import type { IProcessor, OperationWithContext } from "@powerhousedao/reactor";
2
2
  export declare class CodegenProcessor implements IProcessor {
3
3
  private manager;
4
4
  constructor(interactiveMode?: boolean);
5
- onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
5
+ onOperations(operations: OperationWithContext[]): Promise<void>;
6
6
  onDisconnect(): Promise<void>;
7
7
  setInteractiveMode(enabled: boolean): void;
8
8
  isInteractive(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/codegen/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQ5E,qBAAa,gBAAiB,YAAW,UAAU;IACjD,OAAO,CAAC,OAAO,CAAyB;gBAE5B,eAAe,UAAQ;IAoB7B,SAAS,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC9D,YAAY;IAGX,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI1C,aAAa,IAAI,OAAO;IAIxB,uBAAuB,IAAI,OAAO;CAG1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/codegen/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAS/E,qBAAa,gBAAiB,YAAW,UAAU;IACjD,OAAO,CAAC,OAAO,CAAyB;gBAE5B,eAAe,UAAQ;IAkB7B,YAAY,CAAC,UAAU,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiC/D,YAAY;IAGX,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI1C,aAAa,IAAI,OAAO;IAIxB,uBAAuB,IAAI,OAAO;CAG1C"}
@@ -11,37 +11,38 @@ export class CodegenProcessor {
11
11
  CURRENT_WORKING_DIR,
12
12
  }, interactiveMode);
13
13
  if (interactiveMode) {
14
- logger.info(`🔔 CodegenProcessor initialized with interactive mode enabled`);
14
+ logger.info(`CodegenProcessor initialized with interactive mode enabled`);
15
15
  }
16
16
  else {
17
17
  logger.debug(`CodegenProcessor initialized with interactive mode disabled`);
18
18
  }
19
19
  }
20
- async onStrands(strands) {
21
- logger.info(">>> onStrands()");
22
- // Filter strands to only include those that should be processed
23
- const validStrands = strands.filter((strand) => {
24
- const generator = this.manager.getGenerator(strand.documentType);
20
+ async onOperations(operations) {
21
+ logger.info(">>> CodegenProcessor.onOperations()");
22
+ for (const { operation, context } of operations) {
23
+ const generator = this.manager.getGenerator(context.documentType);
25
24
  if (!generator) {
26
- logger.debug(`>>> No generator found for document type: ${strand.documentType}`);
27
- return false;
25
+ logger.debug(`>>> No generator found for document type: ${context.documentType}`);
26
+ continue;
28
27
  }
29
- // Use the required shouldProcess method for validation
30
- const shouldProcessResult = generator.shouldProcess(strand);
31
- if (!shouldProcessResult) {
32
- logger.debug(`>>> Generator validation failed for ${strand.documentType}:${strand.documentId}, skipping processing`);
33
- }
34
- return shouldProcessResult;
35
- });
36
- if (validStrands.length > 0) {
37
- logger.debug(`>>> Processing ${validStrands.length} valid strands (out of ${strands.length} total)`);
38
- for (const strand of validStrands) {
28
+ // Create strand-like object for generator (using existing generator interface)
29
+ // Cast to InternalTransmitterUpdate since generators only use a subset of fields
30
+ const strand = {
31
+ documentId: context.documentId,
32
+ documentType: context.documentType,
33
+ scope: context.scope,
34
+ branch: context.branch,
35
+ driveId: "", // Not available in new format
36
+ operations: [operation],
37
+ state: context.resultingState
38
+ ? JSON.parse(context.resultingState)
39
+ : undefined,
40
+ };
41
+ const shouldProcess = generator.shouldProcess(strand);
42
+ if (shouldProcess) {
39
43
  await this.manager.routeAndGenerate(strand);
40
44
  }
41
45
  }
42
- else {
43
- logger.debug(`>>> No valid strands to process (${strands.length} strands received)`);
44
- }
45
46
  }
46
47
  async onDisconnect() { }
47
48
  // Utility methods for external configuration and monitoring
@@ -0,0 +1,11 @@
1
+ import type { InternalTransmitterUpdate, IProcessor } from "document-drive";
2
+ export declare class CodegenProcessorLegacy implements IProcessor {
3
+ private manager;
4
+ constructor(interactiveMode?: boolean);
5
+ onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
6
+ onDisconnect(): Promise<void>;
7
+ setInteractiveMode(enabled: boolean): void;
8
+ isInteractive(): boolean;
9
+ isProcessingInteractive(): boolean;
10
+ }
11
+ //# sourceMappingURL=index.legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.legacy.d.ts","sourceRoot":"","sources":["../../../processors/codegen/index.legacy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQ5E,qBAAa,sBAAuB,YAAW,UAAU;IACvD,OAAO,CAAC,OAAO,CAAyB;gBAE5B,eAAe,UAAQ;IAoB7B,SAAS,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC9D,YAAY;IAGX,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI1C,aAAa,IAAI,OAAO;IAIxB,uBAAuB,IAAI,OAAO;CAG1C"}
@@ -0,0 +1,57 @@
1
+ import { getConfig } from "@powerhousedao/config/node";
2
+ import { DocumentCodegenFactory } from "./document-handlers/index.js";
3
+ import { logger } from "./logger.js";
4
+ const PH_CONFIG = getConfig();
5
+ const CURRENT_WORKING_DIR = process.cwd();
6
+ export class CodegenProcessorLegacy {
7
+ manager;
8
+ constructor(interactiveMode = false) {
9
+ this.manager = DocumentCodegenFactory.createManager({
10
+ PH_CONFIG,
11
+ CURRENT_WORKING_DIR,
12
+ }, interactiveMode);
13
+ if (interactiveMode) {
14
+ logger.info(`CodegenProcessorLegacy initialized with interactive mode enabled`);
15
+ }
16
+ else {
17
+ logger.debug(`CodegenProcessorLegacy initialized with interactive mode disabled`);
18
+ }
19
+ }
20
+ async onStrands(strands) {
21
+ logger.info(">>> CodegenProcessorLegacy.onStrands()");
22
+ // Filter strands to only include those that should be processed
23
+ const validStrands = strands.filter((strand) => {
24
+ const generator = this.manager.getGenerator(strand.documentType);
25
+ if (!generator) {
26
+ logger.debug(`>>> No generator found for document type: ${strand.documentType}`);
27
+ return false;
28
+ }
29
+ // Use the required shouldProcess method for validation
30
+ const shouldProcessResult = generator.shouldProcess(strand);
31
+ if (!shouldProcessResult) {
32
+ logger.debug(`>>> Generator validation failed for ${strand.documentType}:${strand.documentId}, skipping processing`);
33
+ }
34
+ return shouldProcessResult;
35
+ });
36
+ if (validStrands.length > 0) {
37
+ logger.debug(`>>> Processing ${validStrands.length} valid strands (out of ${strands.length} total)`);
38
+ for (const strand of validStrands) {
39
+ await this.manager.routeAndGenerate(strand);
40
+ }
41
+ }
42
+ else {
43
+ logger.debug(`>>> No valid strands to process (${strands.length} strands received)`);
44
+ }
45
+ }
46
+ async onDisconnect() { }
47
+ // Utility methods for external configuration and monitoring
48
+ setInteractiveMode(enabled) {
49
+ this.manager.setInteractiveMode(enabled);
50
+ }
51
+ isInteractive() {
52
+ return this.manager.isInteractiveMode();
53
+ }
54
+ isProcessingInteractive() {
55
+ return this.manager.isProcessingInteractive();
56
+ }
57
+ }
@@ -1,8 +1,8 @@
1
+ import type { ProcessorRecord } from "@powerhousedao/reactor";
2
+ import type { IProcessorHostModule } from "document-drive";
3
+ import type { PHDocumentHeader } from "document-model";
1
4
  /**
2
- * This file aggregates all processor factories
3
- * Auto-generated by codegen - DO NOT EDIT MANUALLY
5
+ * This file aggregates all processor factories for the new reactor
4
6
  */
5
- import type { IProcessorHostModule, ProcessorRecord } from "document-drive";
6
- import type { PHDocumentHeader } from "document-model";
7
7
  export declare const processorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
8
8
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../processors/factory.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAEpB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,MAW7C,aAAa,gBAAgB,+BAU5C,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../processors/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD;;GAEG;AAEH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,MAS7C,aAAa,gBAAgB,+BAU5C,CAAC"}
@@ -1,12 +1,13 @@
1
- import { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
2
- // Import other processor factories here as they are generated
3
1
  import { codegenProcessorFactory } from "./codegen/factory.js";
2
+ import { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
3
+ /**
4
+ * This file aggregates all processor factories for the new reactor
5
+ */
4
6
  export const processorFactory = (module) => {
5
7
  // Initialize all processor factories once with the module
6
8
  const factories = [];
7
9
  // Add all processor factories
8
10
  factories.push(vetraReadModelProcessorFactory(module));
9
- // Add other processors here as they are generated
10
11
  factories.push(codegenProcessorFactory(module));
11
12
  // Return the inner function that will be called for each drive
12
13
  return async (driveHeader) => {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file aggregates all legacy processor factories
3
+ */
4
+ import type { IProcessorHostModule, ProcessorRecord } from "document-drive";
5
+ import type { PHDocumentHeader } from "document-model";
6
+ export declare const processorFactoryLegacy: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
7
+ //# sourceMappingURL=factory.legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.legacy.d.ts","sourceRoot":"","sources":["../../processors/factory.legacy.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAEpB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD,eAAO,MAAM,sBAAsB,GAAI,QAAQ,oBAAoB,MAWnD,aAAa,gBAAgB,+BAU5C,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { vetraReadModelProcessorFactoryLegacy } from "./vetra-read-model/factory.legacy.js";
2
+ // Import other processor factories here as they are generated
3
+ import { codegenProcessorFactoryLegacy } from "./codegen/factory.legacy.js";
4
+ export const processorFactoryLegacy = (module) => {
5
+ // Initialize all processor factories once with the module
6
+ const factories = [];
7
+ // Add all processor factories
8
+ factories.push(vetraReadModelProcessorFactoryLegacy(module));
9
+ // Add other processors here as they are generated
10
+ factories.push(codegenProcessorFactoryLegacy(module));
11
+ // Return the inner function that will be called for each drive
12
+ return async (driveHeader) => {
13
+ const processors = [];
14
+ // Call each cached factory with the driveHeader
15
+ for (const factory of factories) {
16
+ processors.push(...(await factory(driveHeader)));
17
+ }
18
+ return processors;
19
+ };
20
+ };
@@ -1,5 +1,11 @@
1
- export * as CodegenProcessor from "./codegen/index.js";
1
+ export { CodegenProcessor } from "./codegen/index.js";
2
2
  export { codegenProcessorFactory } from "./codegen/factory.js";
3
- export { processorFactory } from "./factory.js";
4
3
  export { VetraReadModelProcessor } from "./vetra-read-model/index.js";
4
+ export { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
5
+ export { processorFactory } from "./factory.js";
6
+ export { CodegenProcessorLegacy } from "./codegen/index.legacy.js";
7
+ export { codegenProcessorFactoryLegacy } from "./codegen/factory.legacy.js";
8
+ export { VetraReadModelProcessorLegacy } from "./vetra-read-model/index.legacy.js";
9
+ export { vetraReadModelProcessorFactoryLegacy } from "./vetra-read-model/factory.legacy.js";
10
+ export { processorFactoryLegacy } from "./factory.legacy.js";
5
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../processors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../processors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,oCAAoC,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,4 +1,12 @@
1
- export * as CodegenProcessor from "./codegen/index.js";
1
+ // Default exports (new reactor)
2
+ export { CodegenProcessor } from "./codegen/index.js";
2
3
  export { codegenProcessorFactory } from "./codegen/factory.js";
3
- export { processorFactory } from "./factory.js";
4
4
  export { VetraReadModelProcessor } from "./vetra-read-model/index.js";
5
+ export { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
6
+ export { processorFactory } from "./factory.js";
7
+ // Legacy exports
8
+ export { CodegenProcessorLegacy } from "./codegen/index.legacy.js";
9
+ export { codegenProcessorFactoryLegacy } from "./codegen/factory.legacy.js";
10
+ export { VetraReadModelProcessorLegacy } from "./vetra-read-model/index.legacy.js";
11
+ export { vetraReadModelProcessorFactoryLegacy } from "./vetra-read-model/factory.legacy.js";
12
+ export { processorFactoryLegacy } from "./factory.legacy.js";
@@ -1,4 +1,5 @@
1
- import { type IProcessorHostModule, type ProcessorRecord } from "document-drive";
2
- import { type PHDocumentHeader } from "document-model";
1
+ import type { ProcessorRecord } from "@powerhousedao/reactor";
2
+ import type { IProcessorHostModule } from "document-drive";
3
+ import type { PHDocumentHeader } from "document-model";
3
4
  export declare const vetraReadModelProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
4
5
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/vetra-read-model/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,8BAA8B,GACxC,QAAQ,oBAAoB,MACtB,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CA0B/D,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/vetra-read-model/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD,eAAO,MAAM,8BAA8B,GACxC,QAAQ,oBAAoB,MACtB,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAoB/D,CAAC"}
@@ -1,24 +1,21 @@
1
- import {} from "document-drive";
2
- import {} from "document-model";
3
1
  import { VetraReadModelProcessor } from "./index.js";
2
+ import { up } from "./migrations.js";
4
3
  export const vetraReadModelProcessorFactory = (module) => async (driveHeader) => {
5
- // Create a namespace for the processor and the provided drive id
6
- const namespace = VetraReadModelProcessor.getNamespace(driveHeader.id);
7
- // Create a namespaced db for the processor
8
- const store = await module.relationalDb.createNamespace(namespace);
9
- // Create a filter for the processor
10
- const filter = {
11
- branch: ["main"],
12
- documentId: ["*"],
13
- documentType: ["powerhouse/package"],
14
- scope: ["global"],
15
- };
16
- // Create the processor
17
- const processor = new VetraReadModelProcessor(namespace, filter, store);
4
+ // Create namespace (same as legacy - all vetra packages share one namespace)
5
+ const db = await module.relationalDb.createNamespace("vetra-packages");
6
+ // Run migrations (idempotent - uses ifNotExists)
7
+ await up(db);
8
+ // Create the processor with the relational database
9
+ const processor = new VetraReadModelProcessor(db);
18
10
  return [
19
11
  {
20
12
  processor,
21
- filter,
13
+ filter: {
14
+ branch: ["main"],
15
+ documentId: ["*"],
16
+ documentType: ["powerhouse/package"],
17
+ scope: ["global"],
18
+ },
22
19
  },
23
20
  ];
24
21
  };
@@ -0,0 +1,4 @@
1
+ import { type IProcessorHostModule, type ProcessorRecord } from "document-drive";
2
+ import { type PHDocumentHeader } from "document-model";
3
+ export declare const vetraReadModelProcessorFactoryLegacy: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
4
+ //# sourceMappingURL=factory.legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.legacy.d.ts","sourceRoot":"","sources":["../../../processors/vetra-read-model/factory.legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,oCAAoC,GAC9C,QAAQ,oBAAoB,MACtB,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAgC/D,CAAC"}
@@ -0,0 +1,24 @@
1
+ import {} from "document-drive";
2
+ import {} from "document-model";
3
+ import { VetraReadModelProcessorLegacy } from "./index.legacy.js";
4
+ export const vetraReadModelProcessorFactoryLegacy = (module) => async (driveHeader) => {
5
+ // Create a namespace for the processor and the provided drive id
6
+ const namespace = VetraReadModelProcessorLegacy.getNamespace(driveHeader.id);
7
+ // Create a namespaced db for the processor
8
+ const store = await module.relationalDb.createNamespace(namespace);
9
+ // Create a filter for the processor
10
+ const filter = {
11
+ branch: ["main"],
12
+ documentId: ["*"],
13
+ documentType: ["powerhouse/package"],
14
+ scope: ["global"],
15
+ };
16
+ // Create the processor
17
+ const processor = new VetraReadModelProcessorLegacy(namespace, filter, store);
18
+ return [
19
+ {
20
+ processor,
21
+ filter,
22
+ },
23
+ ];
24
+ };
@@ -1,9 +1,10 @@
1
- import { RelationalDbProcessor, type InternalTransmitterUpdate } from "document-drive";
1
+ import type { IProcessor, OperationWithContext } from "@powerhousedao/reactor";
2
+ import type { Kysely } from "kysely";
2
3
  import { type DB } from "./schema.js";
3
- export declare class VetraReadModelProcessor extends RelationalDbProcessor<DB> {
4
- static getNamespace(driveId: string): string;
5
- initAndUpgrade(): Promise<void>;
6
- onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
4
+ export declare class VetraReadModelProcessor implements IProcessor {
5
+ private relationalDb;
6
+ constructor(relationalDb: Kysely<DB>);
7
+ onOperations(operations: OperationWithContext[]): Promise<void>;
7
8
  onDisconnect(): Promise<void>;
8
9
  }
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/vetra-read-model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,yBAAyB,EAC/B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAItC,qBAAa,uBAAwB,SAAQ,qBAAqB,CAAC,EAAE,CAAC;WACpD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAMtC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,SAAS,CACtB,OAAO,EAAE,yBAAyB,EAAE,GACnC,OAAO,CAAC,IAAI,CAAC;IAyEV,YAAY;CACnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/vetra-read-model/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAItC,qBAAa,uBAAwB,YAAW,UAAU;IACxD,OAAO,CAAC,YAAY,CAAa;gBAErB,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC;IAI9B,YAAY,CAAC,UAAU,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0D/D,YAAY;CACnB"}