@powerhousedao/vetra-builder-package 0.0.14 → 0.0.16

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 (110) hide show
  1. package/dist/document-models/builder-account/gen/schema/types.d.ts +1 -1
  2. package/dist/document-models/builder-account/gen/schema/zod.js +1 -1
  3. package/dist/document-models/index.d.ts +1 -0
  4. package/dist/document-models/index.js +1 -0
  5. package/dist/document-models/renown-profile/gen/actions.d.ts +5 -0
  6. package/dist/document-models/renown-profile/gen/actions.js +2 -0
  7. package/dist/document-models/renown-profile/gen/authorization/actions.d.ts +11 -0
  8. package/dist/document-models/renown-profile/gen/authorization/actions.js +1 -0
  9. package/dist/document-models/renown-profile/gen/authorization/creators.d.ts +4 -0
  10. package/dist/document-models/renown-profile/gen/authorization/creators.js +4 -0
  11. package/dist/document-models/renown-profile/gen/authorization/error.d.ts +1 -0
  12. package/dist/document-models/renown-profile/gen/authorization/error.js +1 -0
  13. package/dist/document-models/renown-profile/gen/authorization/object.d.ts +7 -0
  14. package/dist/document-models/renown-profile/gen/authorization/object.js +10 -0
  15. package/dist/document-models/renown-profile/gen/authorization/operations.d.ts +7 -0
  16. package/dist/document-models/renown-profile/gen/authorization/operations.js +1 -0
  17. package/dist/document-models/renown-profile/gen/creators.d.ts +2 -0
  18. package/dist/document-models/renown-profile/gen/creators.js +2 -0
  19. package/dist/document-models/renown-profile/gen/document-model.d.ts +2 -0
  20. package/dist/document-models/renown-profile/gen/document-model.js +99 -0
  21. package/dist/document-models/renown-profile/gen/index.d.ts +7 -0
  22. package/dist/document-models/renown-profile/gen/index.js +6 -0
  23. package/dist/document-models/renown-profile/gen/object.d.ts +16 -0
  24. package/dist/document-models/renown-profile/gen/object.js +30 -0
  25. package/dist/document-models/renown-profile/gen/ph-factories.d.ts +26 -0
  26. package/dist/document-models/renown-profile/gen/ph-factories.js +53 -0
  27. package/dist/document-models/renown-profile/gen/profile/actions.d.ts +15 -0
  28. package/dist/document-models/renown-profile/gen/profile/actions.js +1 -0
  29. package/dist/document-models/renown-profile/gen/profile/creators.d.ts +5 -0
  30. package/dist/document-models/renown-profile/gen/profile/creators.js +5 -0
  31. package/dist/document-models/renown-profile/gen/profile/error.d.ts +1 -0
  32. package/dist/document-models/renown-profile/gen/profile/error.js +1 -0
  33. package/dist/document-models/renown-profile/gen/profile/object.d.ts +8 -0
  34. package/dist/document-models/renown-profile/gen/profile/object.js +13 -0
  35. package/dist/document-models/renown-profile/gen/profile/operations.d.ts +8 -0
  36. package/dist/document-models/renown-profile/gen/profile/operations.js +1 -0
  37. package/dist/document-models/renown-profile/gen/reducer.d.ts +4 -0
  38. package/dist/document-models/renown-profile/gen/reducer.js +37 -0
  39. package/dist/document-models/renown-profile/gen/schema/index.d.ts +2 -0
  40. package/dist/document-models/renown-profile/gen/schema/index.js +2 -0
  41. package/dist/document-models/renown-profile/gen/schema/types.d.ts +174 -0
  42. package/dist/document-models/renown-profile/gen/schema/types.js +1 -0
  43. package/dist/document-models/renown-profile/gen/schema/zod.d.ts +16 -0
  44. package/dist/document-models/renown-profile/gen/schema/zod.js +62 -0
  45. package/dist/document-models/renown-profile/gen/types.d.ts +9 -0
  46. package/dist/document-models/renown-profile/gen/types.js +1 -0
  47. package/dist/document-models/renown-profile/gen/utils.d.ts +21 -0
  48. package/dist/document-models/renown-profile/gen/utils.js +45 -0
  49. package/dist/document-models/renown-profile/index.d.ts +28 -0
  50. package/dist/document-models/renown-profile/index.js +21 -0
  51. package/dist/document-models/renown-profile/src/reducers/authorization.d.ts +2 -0
  52. package/dist/document-models/renown-profile/src/reducers/authorization.js +8 -0
  53. package/dist/document-models/renown-profile/src/reducers/profile.d.ts +2 -0
  54. package/dist/document-models/renown-profile/src/reducers/profile.js +11 -0
  55. package/dist/document-models/renown-profile/src/tests/authorization.test.d.ts +5 -0
  56. package/dist/document-models/renown-profile/src/tests/authorization.test.js +24 -0
  57. package/dist/document-models/renown-profile/src/tests/document-model.test.d.ts +5 -0
  58. package/dist/document-models/renown-profile/src/tests/document-model.test.js +18 -0
  59. package/dist/document-models/renown-profile/src/tests/profile.test.d.ts +5 -0
  60. package/dist/document-models/renown-profile/src/tests/profile.test.js +24 -0
  61. package/dist/document-models/renown-profile/src/utils.d.ts +1 -0
  62. package/dist/document-models/renown-profile/src/utils.js +1 -0
  63. package/dist/editors/builder-account-editor/editor.js +2 -3
  64. package/dist/editors/hooks/useRenownProfileDocument.d.ts +3 -0
  65. package/dist/editors/hooks/useRenownProfileDocument.js +8 -0
  66. package/dist/editors/index.d.ts +1 -0
  67. package/dist/editors/index.js +1 -0
  68. package/dist/editors/renown-profile-editor/editor.d.ts +3 -0
  69. package/dist/editors/renown-profile-editor/editor.js +33 -0
  70. package/dist/editors/renown-profile-editor/index.d.ts +2 -0
  71. package/dist/editors/renown-profile-editor/index.js +11 -0
  72. package/dist/index.d.ts +1 -1
  73. package/dist/powerhouse.manifest.json +18 -1
  74. package/dist/processors/factory.js +2 -5
  75. package/dist/processors/index.d.ts +2 -0
  76. package/dist/processors/index.js +2 -0
  77. package/dist/processors/renown-profile/factory.d.ts +3 -0
  78. package/dist/processors/renown-profile/factory.js +22 -0
  79. package/dist/processors/renown-profile/index.d.ts +9 -0
  80. package/dist/processors/renown-profile/index.js +81 -0
  81. package/dist/processors/renown-profile/migrations.d.ts +3 -0
  82. package/dist/processors/renown-profile/migrations.js +39 -0
  83. package/dist/processors/renown-profile/schema.d.ts +14 -0
  84. package/dist/processors/renown-profile/schema.js +1 -0
  85. package/dist/processors/renown-read-model/migrations.d.ts +3 -0
  86. package/dist/processors/renown-read-model/migrations.js +55 -0
  87. package/dist/processors/renown-read-model/schema.d.ts +21 -0
  88. package/dist/processors/renown-read-model/schema.js +1 -0
  89. package/dist/style.css +388 -17
  90. package/dist/subgraphs/index.d.ts +2 -1
  91. package/dist/subgraphs/index.js +3 -1
  92. package/dist/subgraphs/renown-profile/index.d.ts +10 -0
  93. package/dist/subgraphs/renown-profile/index.js +11 -0
  94. package/dist/subgraphs/renown-profile/resolvers.d.ts +2 -0
  95. package/dist/subgraphs/renown-profile/resolvers.js +151 -0
  96. package/dist/subgraphs/renown-profile/schema.d.ts +2 -0
  97. package/dist/subgraphs/renown-profile/schema.js +104 -0
  98. package/dist/subgraphs/renown-read-model/index.d.ts +10 -0
  99. package/dist/subgraphs/renown-read-model/index.js +11 -0
  100. package/dist/subgraphs/renown-read-model/resolvers.d.ts +2 -0
  101. package/dist/subgraphs/renown-read-model/resolvers.js +25 -0
  102. package/dist/subgraphs/renown-read-model/schema.d.ts +2 -0
  103. package/dist/subgraphs/renown-read-model/schema.js +16 -0
  104. package/dist/subgraphs/vetra-builder-read-model/index.d.ts +10 -0
  105. package/dist/subgraphs/vetra-builder-read-model/index.js +11 -0
  106. package/dist/subgraphs/vetra-builder-read-model/resolvers.d.ts +2 -0
  107. package/dist/subgraphs/vetra-builder-read-model/resolvers.js +174 -0
  108. package/dist/subgraphs/vetra-builder-read-model/schema.d.ts +2 -0
  109. package/dist/subgraphs/vetra-builder-read-model/schema.js +79 -0
  110. package/package.json +3 -2
@@ -0,0 +1,11 @@
1
+ import { Subgraph } from "@powerhousedao/reactor-api";
2
+ import { schema } from "./schema.js";
3
+ import { getResolvers } from "./resolvers.js";
4
+ export class RenownProfileSubgraph extends Subgraph {
5
+ name = "renown-profile";
6
+ typeDefs = schema;
7
+ resolvers = getResolvers(this);
8
+ additionalContextFields = {};
9
+ async onSetup() { }
10
+ async onDisconnect() { }
11
+ }
@@ -0,0 +1,2 @@
1
+ import { type Subgraph } from "@powerhousedao/reactor-api";
2
+ export declare const getResolvers: (subgraph: Subgraph) => Record<string, unknown>;
@@ -0,0 +1,151 @@
1
+ import { addFile } from "document-drive";
2
+ import { setName } from "document-model";
3
+ import { RenownProfileProcessor } from "../../processors/renown-profile/index.js";
4
+ import { actions, } from "../../document-models/renown-profile/index.js";
5
+ export const getResolvers = (subgraph) => {
6
+ const reactor = subgraph.reactor;
7
+ const db = subgraph.relationalDb;
8
+ return {
9
+ Query: {
10
+ Renown: async () => {
11
+ return {
12
+ getProfile: async (args) => {
13
+ const { ethAddress, driveId } = args;
14
+ const profile = await RenownProfileProcessor.query(driveId, db)
15
+ .selectFrom("renown_profile")
16
+ .selectAll()
17
+ .where("eth_address", "=", ethAddress)
18
+ .executeTakeFirst();
19
+ return {
20
+ ...profile,
21
+ documentId: profile?.document_id,
22
+ ethAddress: profile?.eth_address,
23
+ username: profile?.username,
24
+ userImage: profile?.user_image,
25
+ createdAt: profile?.created_at,
26
+ updatedAt: profile?.updated_at,
27
+ };
28
+ },
29
+ getDocument: async (args) => {
30
+ const { docId, driveId } = args;
31
+ if (!docId) {
32
+ throw new Error("Document id is required");
33
+ }
34
+ if (driveId) {
35
+ const docIds = await reactor.getDocuments(driveId);
36
+ if (!docIds.includes(docId)) {
37
+ throw new Error(`Document with id ${docId} is not part of ${driveId}`);
38
+ }
39
+ }
40
+ const doc = await reactor.getDocument(docId);
41
+ return {
42
+ driveId: driveId,
43
+ ...doc,
44
+ ...doc.header,
45
+ created: doc.header.createdAtUtcIso,
46
+ lastModified: doc.header.lastModifiedAtUtcIso,
47
+ state: doc.state.global,
48
+ stateJSON: doc.state.global,
49
+ revision: doc.header?.revision?.global ?? 0,
50
+ };
51
+ },
52
+ getDocuments: async (args) => {
53
+ const { driveId } = args;
54
+ const docsIds = await reactor.getDocuments(driveId);
55
+ const docs = await Promise.all(docsIds.map(async (docId) => {
56
+ const doc = await reactor.getDocument(docId);
57
+ return {
58
+ driveId: driveId,
59
+ ...doc,
60
+ ...doc.header,
61
+ created: doc.header.createdAtUtcIso,
62
+ lastModified: doc.header.lastModifiedAtUtcIso,
63
+ state: doc.state.global,
64
+ stateJSON: doc.state.global,
65
+ revision: doc.header?.revision?.global ?? 0,
66
+ };
67
+ }));
68
+ return docs.filter((doc) => doc.header.documentType === "powerhouse/renown-profile");
69
+ },
70
+ };
71
+ },
72
+ },
73
+ Mutation: {
74
+ RenownProfile_createDocument: async (_, args) => {
75
+ const { driveId, name } = args;
76
+ const document = await reactor.addDocument("powerhouse/renown-profile");
77
+ if (driveId) {
78
+ await reactor.addAction(driveId, addFile({
79
+ name,
80
+ id: document.header.id,
81
+ documentType: "powerhouse/renown-profile",
82
+ }));
83
+ }
84
+ if (name) {
85
+ await reactor.addAction(document.header.id, setName(name));
86
+ }
87
+ return document.header.id;
88
+ },
89
+ RenownProfile_setUsername: async (_, args) => {
90
+ const { docId, input } = args;
91
+ const doc = await reactor.getDocument(docId);
92
+ if (!doc) {
93
+ throw new Error("Document not found");
94
+ }
95
+ const result = await reactor.addAction(docId, actions.setUsername(input));
96
+ if (result.status !== "SUCCESS") {
97
+ throw new Error(result.error?.message ?? "Failed to setUsername");
98
+ }
99
+ return true;
100
+ },
101
+ RenownProfile_setEthAddress: async (_, args) => {
102
+ const { docId, input } = args;
103
+ const doc = await reactor.getDocument(docId);
104
+ if (!doc) {
105
+ throw new Error("Document not found");
106
+ }
107
+ const result = await reactor.addAction(docId, actions.setEthAddress(input));
108
+ if (result.status !== "SUCCESS") {
109
+ throw new Error(result.error?.message ?? "Failed to setEthAddress");
110
+ }
111
+ return true;
112
+ },
113
+ RenownProfile_setUserImage: async (_, args) => {
114
+ const { docId, input } = args;
115
+ const doc = await reactor.getDocument(docId);
116
+ if (!doc) {
117
+ throw new Error("Document not found");
118
+ }
119
+ const result = await reactor.addAction(docId, actions.setUserImage(input));
120
+ if (result.status !== "SUCCESS") {
121
+ throw new Error(result.error?.message ?? "Failed to setUserImage");
122
+ }
123
+ return true;
124
+ },
125
+ RenownProfile_addAuthorization: async (_, args) => {
126
+ const { docId, input } = args;
127
+ const doc = await reactor.getDocument(docId);
128
+ if (!doc) {
129
+ throw new Error("Document not found");
130
+ }
131
+ const result = await reactor.addAction(docId, actions.addAuthorization(input));
132
+ if (result.status !== "SUCCESS") {
133
+ throw new Error(result.error?.message ?? "Failed to addAuthorization");
134
+ }
135
+ return true;
136
+ },
137
+ RenownProfile_revokeAuthorization: async (_, args) => {
138
+ const { docId, input } = args;
139
+ const doc = await reactor.getDocument(docId);
140
+ if (!doc) {
141
+ throw new Error("Document not found");
142
+ }
143
+ const result = await reactor.addAction(docId, actions.revokeAuthorization(input));
144
+ if (result.status !== "SUCCESS") {
145
+ throw new Error(result.error?.message ?? "Failed to revokeAuthorization");
146
+ }
147
+ return true;
148
+ },
149
+ },
150
+ };
151
+ };
@@ -0,0 +1,2 @@
1
+ import type { DocumentNode } from "graphql";
2
+ export declare const schema: DocumentNode;
@@ -0,0 +1,104 @@
1
+ import { gql } from "graphql-tag";
2
+ export const schema = gql `
3
+ """
4
+ Subgraph definition for RenownProfile (powerhouse/renown-profile)
5
+ """
6
+ type RenownProfileState {
7
+ "Add your global state fields here"
8
+ documentId: String
9
+ username: String
10
+ ethAddress: EthereumAddress
11
+ userImage: String
12
+ authorizations: [RenownAuthorization!]!
13
+ }
14
+
15
+ # Issuer is ETH Address
16
+ # Subject is the DID for Connect
17
+ # Audience is the target ie did:web:staging.vetra.io
18
+ # expiry
19
+ type RenownAuthorization {
20
+ id: OID!
21
+ audience: String
22
+ issuer: String!
23
+ subject: String!
24
+ expiry: Int
25
+ }
26
+
27
+ """
28
+ Queries: RenownProfile
29
+ """
30
+ type RenownProfileQueries {
31
+ getProfile(ethAddress: String!, driveId: String!): RenownProfileState
32
+ getDocument(docId: PHID!, driveId: PHID): RenownProfile
33
+ getDocuments(driveId: String!): [RenownProfile!]
34
+ }
35
+
36
+ type Query {
37
+ Renown: RenownProfileQueries
38
+ }
39
+
40
+ """
41
+ Mutations: RenownProfile
42
+ """
43
+ type Mutation {
44
+ RenownProfile_createDocument(name: String!, driveId: String): String
45
+
46
+ RenownProfile_setUsername(
47
+ driveId: String
48
+ docId: PHID
49
+ input: RenownProfile_SetUsernameInput
50
+ ): Int
51
+ RenownProfile_setEthAddress(
52
+ driveId: String
53
+ docId: PHID
54
+ input: RenownProfile_SetEthAddressInput
55
+ ): Int
56
+ RenownProfile_setUserImage(
57
+ driveId: String
58
+ docId: PHID
59
+ input: RenownProfile_SetUserImageInput
60
+ ): Int
61
+ RenownProfile_addAuthorization(
62
+ driveId: String
63
+ docId: PHID
64
+ input: RenownProfile_AddAuthorizationInput
65
+ ): Int
66
+ RenownProfile_revokeAuthorization(
67
+ driveId: String
68
+ docId: PHID
69
+ input: RenownProfile_RevokeAuthorizationInput
70
+ ): Int
71
+ }
72
+
73
+ """
74
+ Module: Profile
75
+ """
76
+ input RenownProfile_SetUsernameInput {
77
+ "Add your inputs here"
78
+ username: String!
79
+ }
80
+ input RenownProfile_SetEthAddressInput {
81
+ "Add your inputs here"
82
+ ethAddress: EthereumAddress!
83
+ }
84
+ input RenownProfile_SetUserImageInput {
85
+ "Add your inputs here"
86
+ userImage: String
87
+ }
88
+
89
+ """
90
+ Module: Authorization
91
+ """
92
+ input RenownProfile_AddAuthorizationInput {
93
+ "Add your inputs here"
94
+ id: OID!
95
+ audience: String
96
+ issuer: String!
97
+ subject: String!
98
+ expiry: Int
99
+ }
100
+ input RenownProfile_RevokeAuthorizationInput {
101
+ "Add your inputs here"
102
+ authorizationId: OID!
103
+ }
104
+ `;
@@ -0,0 +1,10 @@
1
+ import { Subgraph } from "@powerhousedao/reactor-api";
2
+ import type { DocumentNode } from "graphql";
3
+ export declare class RenownReadModelSubgraph extends Subgraph {
4
+ name: string;
5
+ typeDefs: DocumentNode;
6
+ resolvers: Record<string, unknown>;
7
+ additionalContextFields: {};
8
+ onSetup(): Promise<void>;
9
+ onDisconnect(): Promise<void>;
10
+ }
@@ -0,0 +1,11 @@
1
+ import { Subgraph } from "@powerhousedao/reactor-api";
2
+ import { schema } from "./schema.js";
3
+ import { getResolvers } from "./resolvers.js";
4
+ export class RenownReadModelSubgraph extends Subgraph {
5
+ name = "renown-read-model";
6
+ typeDefs = schema;
7
+ resolvers = getResolvers(this);
8
+ additionalContextFields = {};
9
+ async onSetup() { }
10
+ async onDisconnect() { }
11
+ }
@@ -0,0 +1,2 @@
1
+ import { type Subgraph } from "@powerhousedao/reactor-api";
2
+ export declare const getResolvers: (subgraph: Subgraph) => Record<string, unknown>;
@@ -0,0 +1,25 @@
1
+ import { RenownProfileProcessor } from "processors/renown-profile";
2
+ export const getResolvers = (subgraph) => {
3
+ const reactor = subgraph.reactor;
4
+ const db = subgraph.relationalDb;
5
+ return {
6
+ Query: {
7
+ getUserProfile: async (parent, args) => {
8
+ const profile = await RenownProfileProcessor.query(args.driveId || "renown-profiles", db)
9
+ .selectFrom("renown_profile")
10
+ .selectAll()
11
+ .where("eth_address", "=", args.ethAddress)
12
+ .executeTakeFirst();
13
+ if (!profile) {
14
+ return null;
15
+ }
16
+ return {
17
+ documentId: profile.document_id,
18
+ ethAddress: profile.eth_address,
19
+ username: profile.username,
20
+ userImage: profile.user_image,
21
+ };
22
+ },
23
+ },
24
+ };
25
+ };
@@ -0,0 +1,2 @@
1
+ import type { DocumentNode } from "graphql";
2
+ export declare const schema: DocumentNode;
@@ -0,0 +1,16 @@
1
+ import { gql } from "graphql-tag";
2
+ export const schema = gql `
3
+ """
4
+ Subgraph definition
5
+ """
6
+ type Query {
7
+ getUserProfile(ethAddress: String!, driveId: String!): RenownProfile
8
+ }
9
+
10
+ type RenownProfile {
11
+ documentId: String
12
+ ethAddress: String
13
+ username: String
14
+ userImage: String
15
+ }
16
+ `;
@@ -0,0 +1,10 @@
1
+ import { Subgraph } from "@powerhousedao/reactor-api";
2
+ import type { DocumentNode } from "graphql";
3
+ export declare class VetraReadModelSubgraph extends Subgraph {
4
+ name: string;
5
+ typeDefs: DocumentNode;
6
+ resolvers: Record<string, unknown>;
7
+ additionalContextFields: {};
8
+ onSetup(): Promise<void>;
9
+ onDisconnect(): Promise<void>;
10
+ }
@@ -0,0 +1,11 @@
1
+ import { Subgraph } from "@powerhousedao/reactor-api";
2
+ import { schema } from "./schema.js";
3
+ import { getResolvers } from "./resolvers.js";
4
+ export class VetraReadModelSubgraph extends Subgraph {
5
+ name = "vetra-builder-read-model";
6
+ typeDefs = schema;
7
+ resolvers = getResolvers(this);
8
+ additionalContextFields = {};
9
+ async onSetup() { }
10
+ async onDisconnect() { }
11
+ }
@@ -0,0 +1,2 @@
1
+ import { type Subgraph } from "@powerhousedao/reactor-api";
2
+ export declare const getResolvers: (subgraph: Subgraph) => Record<string, unknown>;
@@ -0,0 +1,174 @@
1
+ import { VetraReadModelProcessor } from "../../processors/vetra-read-model/index.js";
2
+ export const getResolvers = (subgraph) => {
3
+ const reactor = subgraph.reactor;
4
+ const db = subgraph.relationalDb;
5
+ const DEFAULT_DRIVE_ID = process.env.VETRA_BUILDER_DRIVE_ID || "powerhouse";
6
+ return {
7
+ BuilderAccountType: {
8
+ spaces: async (parent, args, context) => {
9
+ const driveId = context.driveId || DEFAULT_DRIVE_ID;
10
+ const spaces = await VetraReadModelProcessor.query(driveId, db)
11
+ .selectFrom("builder_spaces")
12
+ .selectAll()
13
+ .leftJoin("deleted_files", (join) => join
14
+ .onRef("deleted_files.document_id", "=", "builder_spaces.builder_account_id")
15
+ .on("deleted_files.drive_id", "=", driveId))
16
+ .where("builder_account_id", "=", parent.id)
17
+ .where("deleted_files.id", "is", null) // Exclude spaces from deleted accounts
18
+ .orderBy("sort_order", "asc")
19
+ .execute();
20
+ return spaces.map((space) => ({
21
+ id: space.id,
22
+ builderAccountId: space.builder_account_id,
23
+ title: space.title,
24
+ description: space.description,
25
+ sortOrder: space.sort_order,
26
+ createdAt: space.created_at.toISOString(),
27
+ updatedAt: space.updated_at.toISOString(),
28
+ driveId: driveId, // Pass driveId to field resolvers
29
+ packages: [], // Will be resolved by field resolver
30
+ }));
31
+ },
32
+ members: async (parent, args, context) => {
33
+ const driveId = context.driveId || DEFAULT_DRIVE_ID;
34
+ const members = await VetraReadModelProcessor.query(driveId, db)
35
+ .selectFrom("builder_account_members")
36
+ .selectAll()
37
+ .leftJoin("deleted_files", (join) => join
38
+ .onRef("deleted_files.document_id", "=", "builder_account_members.builder_account_id")
39
+ .on("deleted_files.drive_id", "=", driveId))
40
+ .where("builder_account_id", "=", parent.id)
41
+ .where("deleted_files.id", "is", null) // Exclude members from deleted accounts
42
+ .execute();
43
+ return members.map((member) => ({
44
+ id: member.id,
45
+ builderAccountId: member.builder_account_id,
46
+ ethAddress: member.eth_address,
47
+ createdAt: member.created_at.toISOString(),
48
+ }));
49
+ },
50
+ },
51
+ BuilderSpace: {
52
+ packages: async (parent, args, context) => {
53
+ const driveId = parent.driveId || context.driveId || DEFAULT_DRIVE_ID;
54
+ const packages = await VetraReadModelProcessor.query(driveId, db)
55
+ .selectFrom("builder_packages")
56
+ .selectAll()
57
+ .leftJoin("builder_spaces", (join) => join.onRef("builder_spaces.id", "=", "builder_packages.space_id"))
58
+ .leftJoin("deleted_files", (join) => join
59
+ .onRef("deleted_files.document_id", "=", "builder_spaces.builder_account_id")
60
+ .on("deleted_files.drive_id", "=", driveId))
61
+ .where("builder_packages.space_id", "=", parent.id)
62
+ .where("deleted_files.id", "is", null) // Exclude packages from deleted accounts
63
+ .orderBy("sort_order", "asc")
64
+ .execute();
65
+ return packages.map((pkg) => ({
66
+ id: pkg.id,
67
+ spaceId: pkg.space_id,
68
+ name: pkg.name,
69
+ description: pkg.description,
70
+ category: pkg.category,
71
+ authorName: pkg.author_name,
72
+ authorWebsite: pkg.author_website,
73
+ githubUrl: pkg.github_url,
74
+ npmUrl: pkg.npm_url,
75
+ vetraDriveUrl: pkg.vetra_drive_url,
76
+ driveId: pkg.drive_id,
77
+ sortOrder: pkg.sort_order,
78
+ createdAt: pkg.created_at.toISOString(),
79
+ updatedAt: pkg.updated_at.toISOString(),
80
+ keywords: [], // Will be resolved by field resolver
81
+ }));
82
+ },
83
+ },
84
+ BuilderPackage: {
85
+ keywords: async (parent, args, context) => {
86
+ const driveId = context.driveId || DEFAULT_DRIVE_ID;
87
+ const keywords = await VetraReadModelProcessor.query(driveId, db)
88
+ .selectFrom("builder_package_keywords")
89
+ .selectAll()
90
+ .leftJoin("builder_packages", (join) => join.onRef("builder_packages.id", "=", "builder_package_keywords.package_id"))
91
+ .leftJoin("builder_spaces", (join) => join.onRef("builder_spaces.id", "=", "builder_packages.space_id"))
92
+ .leftJoin("deleted_files", (join) => join
93
+ .onRef("deleted_files.document_id", "=", "builder_spaces.builder_account_id")
94
+ .on("deleted_files.drive_id", "=", driveId))
95
+ .where("builder_package_keywords.package_id", "=", parent.id)
96
+ .where("deleted_files.id", "is", null) // Exclude keywords from deleted accounts
97
+ .execute();
98
+ return keywords.map((keyword) => ({
99
+ id: keyword.id,
100
+ packageId: keyword.package_id,
101
+ label: keyword.label,
102
+ createdAt: keyword.created_at.toISOString(),
103
+ }));
104
+ },
105
+ },
106
+ Query: {
107
+ fetchAllBuilderAccounts: async (parent, args) => {
108
+ const driveId = args.driveId || DEFAULT_DRIVE_ID;
109
+ const search = args.search;
110
+ const sortOrder = args.sortOrder || "asc";
111
+ let accounts = VetraReadModelProcessor.query(driveId, db)
112
+ .selectFrom("builder_accounts")
113
+ .selectAll()
114
+ .leftJoin("deleted_files", (join) => join
115
+ .onRef("deleted_files.document_id", "=", "builder_accounts.id")
116
+ .on("deleted_files.drive_id", "=", driveId))
117
+ .where("deleted_files.id", "is", null); // Exclude deleted documents
118
+ if (search) {
119
+ accounts = accounts.where((eb) => {
120
+ return eb("profile_name", "ilike", `%${search}%`)
121
+ .or("profile_slug", "ilike", `%${search}%`)
122
+ .or("profile_description", "ilike", `%${search}%`);
123
+ });
124
+ }
125
+ // Add sorting by profile_name
126
+ accounts = accounts.orderBy("profile_name", sortOrder);
127
+ const results = await accounts.execute();
128
+ return results.map((account) => ({
129
+ id: account.id,
130
+ profileName: account.profile_name,
131
+ profileSlug: account.profile_slug,
132
+ profileLogo: account.profile_logo,
133
+ profileDescription: account.profile_description,
134
+ profileSocialsX: account.profile_socials_x,
135
+ profileSocialsGithub: account.profile_socials_github,
136
+ profileSocialsWebsite: account.profile_socials_website,
137
+ createdAt: account.created_at.toISOString(),
138
+ updatedAt: account.updated_at.toISOString(),
139
+ driveId: driveId, // Pass driveId to field resolvers
140
+ spaces: [], // Will be resolved by field resolver
141
+ members: [], // Will be resolved by field resolver
142
+ }));
143
+ },
144
+ fetchBuilderAccount: async (parent, args) => {
145
+ const driveId = args.driveId || DEFAULT_DRIVE_ID;
146
+ const account = await VetraReadModelProcessor.query(driveId, db)
147
+ .selectFrom("builder_accounts")
148
+ .selectAll()
149
+ .leftJoin("deleted_files", (join) => join
150
+ .onRef("deleted_files.document_id", "=", "builder_accounts.id")
151
+ .on("deleted_files.drive_id", "=", driveId))
152
+ .where("builder_accounts.id", "=", args.id)
153
+ .where("deleted_files.id", "is", null) // Exclude deleted documents
154
+ .executeTakeFirst();
155
+ if (!account) {
156
+ return null;
157
+ }
158
+ return {
159
+ id: account.id,
160
+ profileName: account.profile_name,
161
+ profileSlug: account.profile_slug,
162
+ profileLogo: account.profile_logo,
163
+ profileDescription: account.profile_description,
164
+ profileSocialsX: account.profile_socials_x,
165
+ profileSocialsGithub: account.profile_socials_github,
166
+ profileSocialsWebsite: account.profile_socials_website,
167
+ createdAt: account.created_at.toISOString(),
168
+ updatedAt: account.updated_at.toISOString(),
169
+ driveId: driveId, // Pass driveId to field resolvers
170
+ };
171
+ },
172
+ },
173
+ };
174
+ };
@@ -0,0 +1,2 @@
1
+ import type { DocumentNode } from "graphql";
2
+ export declare const schema: DocumentNode;
@@ -0,0 +1,79 @@
1
+ import { gql } from "graphql-tag";
2
+ export const schema = gql `
3
+ """
4
+ Subgraph definition for Vetra Read Model
5
+ """
6
+ type BuilderAccountType {
7
+ id: String!
8
+ profileName: String!
9
+ profileSlug: String!
10
+ profileLogo: String
11
+ profileDescription: String
12
+ profileSocialsX: String
13
+ profileSocialsGithub: String
14
+ profileSocialsWebsite: String
15
+ createdAt: String!
16
+ updatedAt: String!
17
+ spaces: [BuilderSpace!]!
18
+ members: [BuilderAccountMember!]!
19
+ }
20
+
21
+ type BuilderSpace {
22
+ id: String!
23
+ builderAccountId: String!
24
+ title: String!
25
+ description: String
26
+ sortOrder: Int!
27
+ createdAt: String!
28
+ updatedAt: String!
29
+ packages: [BuilderPackage!]!
30
+ }
31
+
32
+ type BuilderPackage {
33
+ id: String!
34
+ spaceId: String!
35
+ name: String!
36
+ description: String
37
+ category: String
38
+ authorName: String!
39
+ authorWebsite: String
40
+ githubUrl: String
41
+ npmUrl: String
42
+ vetraDriveUrl: String
43
+ driveId: String
44
+ sortOrder: Int!
45
+ createdAt: String!
46
+ updatedAt: String!
47
+ keywords: [BuilderPackageKeyword!]!
48
+ }
49
+
50
+ type BuilderPackageKeyword {
51
+ id: String!
52
+ packageId: String!
53
+ label: String!
54
+ createdAt: String!
55
+ }
56
+
57
+ type BuilderAccountMember {
58
+ id: String!
59
+ builderAccountId: String!
60
+ ethAddress: String!
61
+ createdAt: String!
62
+ }
63
+
64
+ type BuilderAccountFilter {
65
+ profileName: String
66
+ profileSlug: String
67
+ profileLogo: String
68
+ profileDescription: String
69
+ }
70
+
71
+ type Query {
72
+ fetchAllBuilderAccounts(
73
+ driveId: String
74
+ search: String
75
+ sortOrder: String
76
+ ): [BuilderAccountType!]!
77
+ fetchBuilderAccount(driveId: String, id: String!): BuilderAccountType
78
+ }
79
+ `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/vetra-builder-package",
3
3
  "description": "",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [
@@ -66,6 +66,7 @@
66
66
  "@powerhousedao/common": "staging",
67
67
  "@powerhousedao/design-system": "staging",
68
68
  "@powerhousedao/document-engineering": "^1.36.0",
69
+ "@renown/sdk": "staging",
69
70
  "document-model": "staging",
70
71
  "graphql": "^16.10.0",
71
72
  "graphql-tag": "^2.12.6",
@@ -91,7 +92,7 @@
91
92
  "@testing-library/react": "^16.3.0",
92
93
  "@types/node": "^22.13.11",
93
94
  "@types/react": "^18.3.19",
94
- "@vitejs/plugin-react": "^4.3.4",
95
+ "@vitejs/plugin-react": "^5.0.4",
95
96
  "document-drive": "staging",
96
97
  "eslint": "^9.22.0",
97
98
  "eslint-plugin-react": "^7.37.4",