@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.
- package/dist/processors/codegen/__tests__/codegen-processor-e2e.test.js +3 -3
- package/dist/processors/codegen/document-handlers/generators/document-model-generator.d.ts +4 -0
- package/dist/processors/codegen/document-handlers/generators/document-model-generator.d.ts.map +1 -1
- package/dist/processors/codegen/document-handlers/generators/document-model-generator.js +35 -19
- package/dist/processors/codegen/factory.d.ts +2 -1
- package/dist/processors/codegen/factory.d.ts.map +1 -1
- package/dist/processors/codegen/factory.legacy.d.ts +4 -0
- package/dist/processors/codegen/factory.legacy.d.ts.map +1 -0
- package/dist/processors/codegen/factory.legacy.js +53 -0
- package/dist/processors/codegen/index.d.ts +2 -2
- package/dist/processors/codegen/index.d.ts.map +1 -1
- package/dist/processors/codegen/index.js +22 -21
- package/dist/processors/codegen/index.legacy.d.ts +11 -0
- package/dist/processors/codegen/index.legacy.d.ts.map +1 -0
- package/dist/processors/codegen/index.legacy.js +57 -0
- package/dist/processors/factory.d.ts +4 -4
- package/dist/processors/factory.d.ts.map +1 -1
- package/dist/processors/factory.js +4 -3
- package/dist/processors/factory.legacy.d.ts +7 -0
- package/dist/processors/factory.legacy.d.ts.map +1 -0
- package/dist/processors/factory.legacy.js +20 -0
- package/dist/processors/index.d.ts +8 -2
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +10 -2
- package/dist/processors/vetra-read-model/factory.d.ts +3 -2
- package/dist/processors/vetra-read-model/factory.d.ts.map +1 -1
- package/dist/processors/vetra-read-model/factory.js +13 -16
- package/dist/processors/vetra-read-model/factory.legacy.d.ts +4 -0
- package/dist/processors/vetra-read-model/factory.legacy.d.ts.map +1 -0
- package/dist/processors/vetra-read-model/factory.legacy.js +24 -0
- package/dist/processors/vetra-read-model/index.d.ts +6 -5
- package/dist/processors/vetra-read-model/index.d.ts.map +1 -1
- package/dist/processors/vetra-read-model/index.js +20 -37
- package/dist/processors/vetra-read-model/index.legacy.d.ts +9 -0
- package/dist/processors/vetra-read-model/index.legacy.d.ts.map +1 -0
- package/dist/processors/vetra-read-model/index.legacy.js +75 -0
- package/dist/subgraphs/vetra-read-model/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/vetra-read-model/resolvers.js +2 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -14
|
@@ -1,42 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { up } from "./migrations.js";
|
|
1
|
+
import { logger } from "../codegen/logger.js";
|
|
3
2
|
import {} from "./schema.js";
|
|
4
|
-
export class VetraReadModelProcessor
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return super.getNamespace("vetra-packages");
|
|
3
|
+
export class VetraReadModelProcessor {
|
|
4
|
+
relationalDb;
|
|
5
|
+
constructor(relationalDb) {
|
|
6
|
+
this.relationalDb = relationalDb;
|
|
9
7
|
}
|
|
10
|
-
async
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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(
|
|
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:
|
|
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
|
-
|
|
49
|
-
|
|
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:
|
|
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:
|
|
66
|
-
last_operation_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,
|
|
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 {
|
|
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 =
|
|
9
|
+
let query = VetraReadModelProcessorLegacy.query("vetra-packages", db)
|
|
11
10
|
.selectFrom("vetra_package")
|
|
12
11
|
.selectAll();
|
|
13
12
|
if (search) {
|