@powerhousedao/vetra-builder-package 0.0.23 → 0.0.25

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.
@@ -97,6 +97,8 @@ export class BuilderTeamHandlers {
97
97
  await this.dbHelpers.ensureBuilderAccountExistsAndIsNotdeleted(documentId);
98
98
  if (!action.input.id)
99
99
  return;
100
+ // Find member in state to get full details
101
+ const member = state.members.find((m) => m.id === action.input.id);
100
102
  const memberExists = await this.dbHelpers.memberExists(documentId, action.input.id);
101
103
  if (!memberExists) {
102
104
  await this.db
@@ -104,11 +106,28 @@ export class BuilderTeamHandlers {
104
106
  .values({
105
107
  id: action.input.id,
106
108
  builder_team_id: documentId,
107
- eth_address: "",
109
+ eth_address: member?.ethAddress || action.input.id,
110
+ phid: member?.phid || null,
111
+ name: member?.name || null,
112
+ profile_image: member?.profileImage || null,
108
113
  created_at: new Date(),
109
114
  })
110
115
  .execute();
111
116
  }
117
+ else {
118
+ // Update existing member with new information
119
+ await this.db
120
+ .updateTable("builder_team_members")
121
+ .set({
122
+ eth_address: member?.ethAddress || action.input.id,
123
+ phid: member?.phid || null,
124
+ name: member?.name || null,
125
+ profile_image: member?.profileImage || null,
126
+ })
127
+ .where("id", "=", action.input.id)
128
+ .where("builder_team_id", "=", documentId)
129
+ .execute();
130
+ }
112
131
  }
113
132
  async handleRemoveMember(documentId, action, state) {
114
133
  if (!action.input.id)
@@ -23,6 +23,9 @@ export async function up(db) {
23
23
  .addColumn("id", "varchar(255)", (col) => col.primaryKey())
24
24
  .addColumn("builder_team_id", "varchar(255)", (col) => col.notNull())
25
25
  .addColumn("eth_address", "varchar(42)", (col) => col.notNull()) // Ethereum addresses are 42 chars
26
+ .addColumn("phid", "varchar(255)") // Powerhouse ID for Renown integration
27
+ .addColumn("name", "varchar(255)") // Member name
28
+ .addColumn("profile_image", "text") // Profile image URL
26
29
  .addColumn("created_at", "timestamp", (col) => col.defaultTo("now()").notNull())
27
30
  .addForeignKeyConstraint("builder_team_members_account_fk", ["builder_team_id"], "builder_teams", ["id"], (cb) => cb.onDelete("cascade"))
28
31
  .ifNotExists()
@@ -98,6 +101,12 @@ export async function up(db) {
98
101
  .column("eth_address")
99
102
  .ifNotExists()
100
103
  .execute();
104
+ await db.schema
105
+ .createIndex("idx_builder_team_members_phid")
106
+ .on("builder_team_members")
107
+ .column("phid")
108
+ .ifNotExists()
109
+ .execute();
101
110
  await db.schema
102
111
  .createIndex("idx_builder_team_spaces_account")
103
112
  .on("builder_team_spaces")
@@ -6,6 +6,9 @@ export interface BuilderTeamMembers {
6
6
  created_at: Generated<Timestamp>;
7
7
  eth_address: string;
8
8
  id: string;
9
+ name: string | null;
10
+ phid: string | null;
11
+ profile_image: string | null;
9
12
  }
10
13
  export interface BuilderTeamPackageKeywords {
11
14
  created_at: Generated<Timestamp>;
@@ -43,6 +43,9 @@ export const getResolvers = (subgraph) => {
43
43
  .select([
44
44
  "builder_team_members.id",
45
45
  "builder_team_members.builder_team_id",
46
+ "builder_team_members.phid",
47
+ "builder_team_members.name",
48
+ "builder_team_members.profile_image",
46
49
  "builder_team_members.eth_address",
47
50
  "builder_team_members.created_at",
48
51
  ])
@@ -55,6 +58,9 @@ export const getResolvers = (subgraph) => {
55
58
  return members.map((member) => ({
56
59
  id: member.id,
57
60
  builderAccountId: member.builder_team_id,
61
+ phid: member.phid,
62
+ name: member.name,
63
+ profileImage: member.profile_image,
58
64
  ethAddress: member.eth_address,
59
65
  createdAt: member.created_at.toISOString(),
60
66
  }));
@@ -138,13 +144,35 @@ export const getResolvers = (subgraph) => {
138
144
  fetchBuilderTeam: async (parent, args, context) => {
139
145
  const driveId = args.driveId || DEFAULT_DRIVE_ID;
140
146
  context.driveId = driveId;
141
- const account = await VetraBuilderRelationalDbProcessor.query(driveId, db)
147
+ // Require either id or slug
148
+ if (!args.id && !args.slug) {
149
+ throw new Error("Either id or slug parameter is required");
150
+ }
151
+ let query = VetraBuilderRelationalDbProcessor.query(driveId, db)
142
152
  .selectFrom("builder_teams")
143
- .selectAll()
153
+ .select([
154
+ "builder_teams.id",
155
+ "builder_teams.profile_name",
156
+ "builder_teams.profile_slug",
157
+ "builder_teams.profile_logo",
158
+ "builder_teams.profile_description",
159
+ "builder_teams.profile_socials_x",
160
+ "builder_teams.profile_socials_github",
161
+ "builder_teams.profile_socials_website",
162
+ "builder_teams.created_at",
163
+ "builder_teams.updated_at",
164
+ ])
144
165
  .leftJoin("deleted_files", (join) => join
145
166
  .onRef("deleted_files.document_id", "=", "builder_teams.id")
146
- .on("deleted_files.drive_id", "=", driveId))
147
- .where("builder_teams.id", "=", args.id)
167
+ .on("deleted_files.drive_id", "=", driveId));
168
+ // Query by id or slug
169
+ if (args.id) {
170
+ query = query.where("builder_teams.id", "=", args.id);
171
+ }
172
+ else if (args.slug) {
173
+ query = query.where("builder_teams.profile_slug", "=", args.slug);
174
+ }
175
+ const account = await query
148
176
  .where("deleted_files.id", "is", null) // Exclude deleted documents
149
177
  .executeTakeFirst();
150
178
  if (!account) {
@@ -45,6 +45,9 @@ export const schema = gql `
45
45
  type BuilderTeamMember {
46
46
  id: String!
47
47
  builderAccountId: String!
48
+ phid: String
49
+ name: String
50
+ profileImage: String
48
51
  ethAddress: String!
49
52
  createdAt: String!
50
53
  }
@@ -62,6 +65,6 @@ export const schema = gql `
62
65
  search: String
63
66
  sortOrder: String
64
67
  ): [BuilderTeamType!]!
65
- fetchBuilderTeam(driveId: String, id: String!): BuilderTeamType
68
+ fetchBuilderTeam(driveId: String, id: String, slug: String): BuilderTeamType
66
69
  }
67
70
  `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/vetra-builder-package",
3
3
  "description": "",
4
- "version": "0.0.23",
4
+ "version": "0.0.25",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [