@powerhousedao/vetra-builder-package 0.0.15 → 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.
package/dist/style.css CHANGED
@@ -5789,6 +5789,9 @@ input[type="number"] {
5789
5789
  .inline-flex {
5790
5790
  display: inline-flex;
5791
5791
  }
5792
+ .table {
5793
+ display: table;
5794
+ }
5792
5795
  .h-4 {
5793
5796
  height: calc(var(--spacing) * 4);
5794
5797
  }
@@ -1,4 +1,4 @@
1
1
  export {};
2
2
  export * as BuilderAccountSubgraph from "./builder-account/index.js";
3
- export * as VetraReadModelSubgraph from "./vetra-read-model/index.js";
3
+ export * as VetraBuilderReadModelSubgraph from "./vetra-builder-read-model/index.js";
4
4
  export * as RenownProfileSubgraph from "./renown-profile/index.js";
@@ -1,4 +1,4 @@
1
1
  export * as BuilderAccountSubgraph from "./builder-account/index.js";
2
- export * as VetraReadModelSubgraph from "./vetra-read-model/index.js";
2
+ export * as VetraBuilderReadModelSubgraph from "./vetra-builder-read-model/index.js";
3
3
  export * as RenownProfileSubgraph from "./renown-profile/index.js";
4
4
  // export * as RenownReadModelSubgraph from "./renown-read-model/index.js";
@@ -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.15",
4
+ "version": "0.0.16",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [