@powerhousedao/vetra 6.0.0-dev.2 → 6.0.0-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/editors/app-editor/components/AppEditorForm.js +1 -1
  2. package/dist/editors/app-editor/editor.js +1 -1
  3. package/dist/editors/app-editor/editor.test.js +8 -1
  4. package/dist/editors/document-editor/components/DocumentEditorForm.js +1 -1
  5. package/dist/editors/document-editor/editor.js +1 -1
  6. package/dist/editors/processor-editor/components/ProcessorEditorForm.js +1 -1
  7. package/dist/editors/processor-editor/editor.js +1 -1
  8. package/dist/editors/subgraph-editor/components/SubgraphEditorForm.js +1 -1
  9. package/dist/editors/subgraph-editor/editor.js +1 -1
  10. package/dist/editors/vetra-drive-app/DriveExplorer.js +1 -1
  11. package/dist/editors/vetra-drive-app/components/DriveHeader.js +1 -1
  12. package/dist/editors/vetra-drive-app/editor.js +1 -1
  13. package/dist/editors/vetra-package/components/MetaForm.js +1 -1
  14. package/dist/editors/vetra-package/editor.js +1 -1
  15. package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.js +25 -22
  16. package/dist/processors/codegen/document-handlers/generators/app-generator.js +4 -4
  17. package/dist/processors/codegen/document-handlers/generators/document-editor-generator.js +2 -2
  18. package/dist/processors/codegen/document-handlers/generators/document-model-generator.d.ts +4 -0
  19. package/dist/processors/codegen/document-handlers/generators/document-model-generator.d.ts.map +1 -1
  20. package/dist/processors/codegen/document-handlers/generators/document-model-generator.js +35 -19
  21. package/dist/processors/codegen/document-handlers/generators/processor-generator.js +1 -1
  22. package/dist/processors/codegen/factory.d.ts +2 -1
  23. package/dist/processors/codegen/factory.d.ts.map +1 -1
  24. package/dist/processors/codegen/factory.legacy.d.ts +4 -0
  25. package/dist/processors/codegen/factory.legacy.d.ts.map +1 -0
  26. package/dist/processors/codegen/factory.legacy.js +53 -0
  27. package/dist/processors/codegen/index.d.ts +2 -2
  28. package/dist/processors/codegen/index.d.ts.map +1 -1
  29. package/dist/processors/codegen/index.js +22 -21
  30. package/dist/processors/codegen/index.legacy.d.ts +11 -0
  31. package/dist/processors/codegen/index.legacy.d.ts.map +1 -0
  32. package/dist/processors/codegen/index.legacy.js +57 -0
  33. package/dist/processors/factory.d.ts +4 -4
  34. package/dist/processors/factory.d.ts.map +1 -1
  35. package/dist/processors/factory.js +4 -3
  36. package/dist/processors/factory.legacy.d.ts +7 -0
  37. package/dist/processors/factory.legacy.d.ts.map +1 -0
  38. package/dist/processors/factory.legacy.js +20 -0
  39. package/dist/processors/index.d.ts +8 -2
  40. package/dist/processors/index.d.ts.map +1 -1
  41. package/dist/processors/index.js +10 -2
  42. package/dist/processors/vetra-read-model/factory.d.ts +3 -2
  43. package/dist/processors/vetra-read-model/factory.d.ts.map +1 -1
  44. package/dist/processors/vetra-read-model/factory.js +13 -16
  45. package/dist/processors/vetra-read-model/factory.legacy.d.ts +4 -0
  46. package/dist/processors/vetra-read-model/factory.legacy.d.ts.map +1 -0
  47. package/dist/processors/vetra-read-model/factory.legacy.js +24 -0
  48. package/dist/processors/vetra-read-model/index.d.ts +6 -5
  49. package/dist/processors/vetra-read-model/index.d.ts.map +1 -1
  50. package/dist/processors/vetra-read-model/index.js +20 -37
  51. package/dist/processors/vetra-read-model/index.legacy.d.ts +9 -0
  52. package/dist/processors/vetra-read-model/index.legacy.d.ts.map +1 -0
  53. package/dist/processors/vetra-read-model/index.legacy.js +75 -0
  54. package/dist/subgraphs/vetra-read-model/resolvers.d.ts.map +1 -1
  55. package/dist/subgraphs/vetra-read-model/resolvers.js +2 -3
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +15 -14
@@ -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"}
@@ -1,42 +1,27 @@
1
- import { RelationalDbProcessor, } from "document-drive";
2
- import { up } from "./migrations.js";
1
+ import { logger } from "../codegen/logger.js";
3
2
  import {} from "./schema.js";
4
- export class VetraReadModelProcessor extends RelationalDbProcessor {
5
- static getNamespace(driveId) {
6
- // Default namespace: `${this.name}_${driveId.replaceAll("-", "_")}`
7
- // we keep all vetra packages in the same namespace even if they are stored in different drives
8
- return super.getNamespace("vetra-packages");
3
+ export class VetraReadModelProcessor {
4
+ relationalDb;
5
+ constructor(relationalDb) {
6
+ this.relationalDb = relationalDb;
9
7
  }
10
- async initAndUpgrade() {
11
- await up(this.relationalDb);
12
- }
13
- async onStrands(strands) {
14
- if (strands.length === 0) {
8
+ async onOperations(operations) {
9
+ logger.info(">>> VetraReadModelProcessor.onOperations()");
10
+ if (operations.length === 0)
15
11
  return;
16
- }
17
- for (const strand of strands) {
18
- if (strand.operations.length === 0) {
19
- continue;
20
- }
21
- // Only process VetraPackage documents
22
- if (strand.documentType !== "powerhouse/package") {
23
- continue;
24
- }
25
- // Get the last operation to extract the most recent state
26
- const lastOperation = strand.operations[strand.operations.length - 1];
27
- if (!lastOperation)
12
+ for (const { operation, context } of operations) {
13
+ if (context.documentType !== "powerhouse/package")
28
14
  continue;
29
- // Extract VetraPackage state fields with proper typing
30
- const state = strand.state;
31
- // Helper to safely get string values
15
+ const state = context.resultingState
16
+ ? JSON.parse(context.resultingState)
17
+ : undefined;
32
18
  const getString = (val) => typeof val === "string" ? val : null;
33
19
  const now = new Date();
34
- const operationTimestamp = new Date(parseInt(lastOperation.timestampUtcMs, 10));
20
+ const operationTimestamp = new Date(parseInt(operation.timestampUtcMs, 10));
35
21
  await this.relationalDb
36
22
  .insertInto("vetra_package")
37
23
  .values({
38
- document_id: strand.documentId,
39
- // VetraPackage state fields
24
+ document_id: context.documentId,
40
25
  name: getString(state?.name),
41
26
  description: getString(state?.description),
42
27
  category: getString(state?.category),
@@ -45,11 +30,10 @@ export class VetraReadModelProcessor extends RelationalDbProcessor {
45
30
  keywords: state?.keywords ? JSON.stringify(state.keywords) : null,
46
31
  github_url: getString(state?.githubUrl),
47
32
  npm_url: getString(state?.npmUrl),
48
- // Document metadata
49
- last_operation_index: lastOperation.index,
50
- last_operation_hash: lastOperation.hash,
33
+ last_operation_index: operation.index,
34
+ last_operation_hash: operation.hash,
51
35
  last_operation_timestamp: operationTimestamp,
52
- drive_id: strand.driveId,
36
+ drive_id: "", // Not available in new format
53
37
  created_at: now,
54
38
  updated_at: now,
55
39
  })
@@ -62,10 +46,9 @@ export class VetraReadModelProcessor extends RelationalDbProcessor {
62
46
  keywords: state?.keywords ? JSON.stringify(state.keywords) : null,
63
47
  github_url: getString(state?.githubUrl),
64
48
  npm_url: getString(state?.npmUrl),
65
- last_operation_index: lastOperation.index,
66
- last_operation_hash: lastOperation.hash,
49
+ last_operation_index: operation.index,
50
+ last_operation_hash: operation.hash,
67
51
  last_operation_timestamp: operationTimestamp,
68
- drive_id: strand.driveId,
69
52
  updated_at: now,
70
53
  }))
71
54
  .execute();
@@ -0,0 +1,9 @@
1
+ import { RelationalDbProcessor, type InternalTransmitterUpdate } from "document-drive";
2
+ import { type DB } from "./schema.js";
3
+ export declare class VetraReadModelProcessorLegacy extends RelationalDbProcessor<DB> {
4
+ static getNamespace(driveId: string): string;
5
+ initAndUpgrade(): Promise<void>;
6
+ onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
7
+ onDisconnect(): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=index.legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.legacy.d.ts","sourceRoot":"","sources":["../../../processors/vetra-read-model/index.legacy.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,6BAA8B,SAAQ,qBAAqB,CAAC,EAAE,CAAC;WAC1D,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"}
@@ -0,0 +1,75 @@
1
+ import { RelationalDbProcessor, } from "document-drive";
2
+ import { up } from "./migrations.js";
3
+ import {} from "./schema.js";
4
+ export class VetraReadModelProcessorLegacy extends RelationalDbProcessor {
5
+ static getNamespace(driveId) {
6
+ // Default namespace: `${this.name}_${driveId.replaceAll("-", "_")}`
7
+ // we keep all vetra packages in the same namespace even if they are stored in different drives
8
+ return super.getNamespace("vetra-packages");
9
+ }
10
+ async initAndUpgrade() {
11
+ await up(this.relationalDb);
12
+ }
13
+ async onStrands(strands) {
14
+ if (strands.length === 0) {
15
+ return;
16
+ }
17
+ for (const strand of strands) {
18
+ if (strand.operations.length === 0) {
19
+ continue;
20
+ }
21
+ // Only process VetraPackage documents
22
+ if (strand.documentType !== "powerhouse/package") {
23
+ continue;
24
+ }
25
+ // Get the last operation to extract the most recent state
26
+ const lastOperation = strand.operations[strand.operations.length - 1];
27
+ if (!lastOperation)
28
+ continue;
29
+ // Extract VetraPackage state fields with proper typing
30
+ const state = strand.state;
31
+ // Helper to safely get string values
32
+ const getString = (val) => typeof val === "string" ? val : null;
33
+ const now = new Date();
34
+ const operationTimestamp = new Date(parseInt(lastOperation.timestampUtcMs, 10));
35
+ await this.relationalDb
36
+ .insertInto("vetra_package")
37
+ .values({
38
+ document_id: strand.documentId,
39
+ // VetraPackage state fields
40
+ name: getString(state?.name),
41
+ description: getString(state?.description),
42
+ category: getString(state?.category),
43
+ author_name: getString(state?.author?.name),
44
+ author_website: getString(state?.author?.website),
45
+ keywords: state?.keywords ? JSON.stringify(state.keywords) : null,
46
+ github_url: getString(state?.githubUrl),
47
+ npm_url: getString(state?.npmUrl),
48
+ // Document metadata
49
+ last_operation_index: lastOperation.index,
50
+ last_operation_hash: lastOperation.hash,
51
+ last_operation_timestamp: operationTimestamp,
52
+ drive_id: strand.driveId,
53
+ created_at: now,
54
+ updated_at: now,
55
+ })
56
+ .onConflict((oc) => oc.column("document_id").doUpdateSet({
57
+ name: getString(state?.name),
58
+ description: getString(state?.description),
59
+ category: getString(state?.category),
60
+ author_name: getString(state?.author?.name),
61
+ author_website: getString(state?.author?.website),
62
+ keywords: state?.keywords ? JSON.stringify(state.keywords) : null,
63
+ github_url: getString(state?.githubUrl),
64
+ npm_url: getString(state?.npmUrl),
65
+ last_operation_index: lastOperation.index,
66
+ last_operation_hash: lastOperation.hash,
67
+ last_operation_timestamp: operationTimestamp,
68
+ drive_id: strand.driveId,
69
+ updated_at: now,
70
+ }))
71
+ .execute();
72
+ }
73
+ }
74
+ async onDisconnect() { }
75
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/vetra-read-model/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA+CxE,CAAC"}
1
+ {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/vetra-read-model/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAiDxE,CAAC"}
@@ -1,13 +1,12 @@
1
- import { VetraReadModelProcessor } from "../../processors/vetra-read-model/index.js";
1
+ import { VetraReadModelProcessorLegacy } from "../../processors/vetra-read-model/index.legacy.js";
2
2
  export const getResolvers = (subgraph) => {
3
- const reactor = subgraph.reactor;
4
3
  const db = subgraph.relationalDb;
5
4
  return {
6
5
  Query: {
7
6
  vetraPackages: async (parent, args) => {
8
7
  const { search, documentId_in } = args;
9
8
  const sortOrder = args.sortOrder || "asc";
10
- let query = VetraReadModelProcessor.query("vetra-packages", db)
9
+ let query = VetraReadModelProcessorLegacy.query("vetra-packages", db)
11
10
  .selectFrom("vetra_package")
12
11
  .selectAll();
13
12
  if (search) {