@powerhousedao/renown-package 0.0.2 → 0.0.3

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
@@ -12246,6 +12246,9 @@ input[type="number"] {
12246
12246
  .inline-flex {
12247
12247
  display: inline-flex;
12248
12248
  }
12249
+ .table {
12250
+ display: table;
12251
+ }
12249
12252
  .h-4 {
12250
12253
  height: calc(var(--spacing) * 4);
12251
12254
  }
@@ -1,9 +1,105 @@
1
+ import { RenownUserProcessor } from "../../processors/renown-user/index.js";
2
+ const mapToProfile = (user) => ({
3
+ documentId: user.document_id,
4
+ username: user.username,
5
+ ethAddress: user.eth_address,
6
+ userImage: user.user_image,
7
+ createdAt: user.created_at,
8
+ updatedAt: user.updated_at,
9
+ });
1
10
  export const getResolvers = (subgraph) => {
2
- const reactor = subgraph.reactor;
11
+ const db = subgraph.relationalDb;
3
12
  return {
4
13
  Query: {
5
- example: async (parent, args) => {
6
- return "example";
14
+ getProfile: async (parent, args) => {
15
+ const { driveId, id, username, ethAddress, searchInput } = args.input;
16
+ let query = RenownUserProcessor.query(driveId, db).selectFrom("renown_user");
17
+ // Priority: id > username > ethAddress > searchInput
18
+ if (id) {
19
+ query = query.where("renown_user.document_id", "=", id);
20
+ }
21
+ else if (username) {
22
+ query = query.where("renown_user.username", "=", username);
23
+ }
24
+ else if (ethAddress) {
25
+ query = query.where("renown_user.eth_address", "=", ethAddress);
26
+ }
27
+ else if (searchInput) {
28
+ // Search across username and eth_address
29
+ query = query.where((eb) => eb.or([
30
+ eb("renown_user.username", "like", `%${searchInput}%`),
31
+ eb("renown_user.eth_address", "like", `%${searchInput}%`),
32
+ ]));
33
+ }
34
+ else {
35
+ throw new Error("At least one of id, username, ethAddress, or searchInput must be provided");
36
+ }
37
+ const result = await query.selectAll().executeTakeFirst();
38
+ return result ? mapToProfile(result) : null;
39
+ },
40
+ getProfiles: async (parent, args) => {
41
+ const { driveId, ids, usernames, ethAddresses, searchString } = args.input;
42
+ let query = RenownUserProcessor.query(driveId, db).selectFrom("renown_user");
43
+ // Build OR conditions based on provided inputs
44
+ if (ids && ids.length > 0) {
45
+ query = query.where((eb) => eb.or([
46
+ eb("renown_user.document_id", "in", ids),
47
+ ...(usernames && usernames.length > 0
48
+ ? [eb("renown_user.username", "in", usernames)]
49
+ : []),
50
+ ...(ethAddresses && ethAddresses.length > 0
51
+ ? [eb("renown_user.eth_address", "in", ethAddresses)]
52
+ : []),
53
+ ...(searchString
54
+ ? [
55
+ eb.or([
56
+ eb("renown_user.username", "like", `%${searchString}%`),
57
+ eb("renown_user.eth_address", "like", `%${searchString}%`),
58
+ ]),
59
+ ]
60
+ : []),
61
+ ]));
62
+ }
63
+ else if (usernames && usernames.length > 0) {
64
+ query = query.where((eb) => eb.or([
65
+ eb("renown_user.username", "in", usernames),
66
+ ...(ethAddresses && ethAddresses.length > 0
67
+ ? [eb("renown_user.eth_address", "in", ethAddresses)]
68
+ : []),
69
+ ...(searchString
70
+ ? [
71
+ eb.or([
72
+ eb("renown_user.username", "like", `%${searchString}%`),
73
+ eb("renown_user.eth_address", "like", `%${searchString}%`),
74
+ ]),
75
+ ]
76
+ : []),
77
+ ]));
78
+ }
79
+ else if (ethAddresses && ethAddresses.length > 0) {
80
+ query = query.where((eb) => eb.or([
81
+ eb("renown_user.eth_address", "in", ethAddresses),
82
+ ...(searchString
83
+ ? [
84
+ eb.or([
85
+ eb("renown_user.username", "like", `%${searchString}%`),
86
+ eb("renown_user.eth_address", "like", `%${searchString}%`),
87
+ ]),
88
+ ]
89
+ : []),
90
+ ]));
91
+ }
92
+ else if (searchString) {
93
+ query = query.where((eb) => eb.or([
94
+ eb("renown_user.username", "like", `%${searchString}%`),
95
+ eb("renown_user.eth_address", "like", `%${searchString}%`),
96
+ ]));
97
+ }
98
+ else {
99
+ throw new Error("At least one of ids, usernames, ethAddresses, or searchString must be provided");
100
+ }
101
+ const results = await query.selectAll().execute();
102
+ return results.map(mapToProfile);
7
103
  },
8
104
  },
9
105
  };
@@ -1,9 +1,35 @@
1
1
  import { gql } from "graphql-tag";
2
2
  export const schema = gql `
3
3
  """
4
- Subgraph definition
4
+ Subgraph definition for Renown Read Model
5
5
  """
6
+ type RenownProfile {
7
+ documentId: String!
8
+ username: String
9
+ ethAddress: String
10
+ userImage: String
11
+ createdAt: String
12
+ updatedAt: String
13
+ }
14
+
15
+ input GetProfileInput {
16
+ driveId: String!
17
+ id: String
18
+ username: String
19
+ ethAddress: String
20
+ searchInput: String
21
+ }
22
+
23
+ input GetProfilesInput {
24
+ driveId: String!
25
+ ids: [String!]
26
+ usernames: [String!]
27
+ ethAddresses: [String!]
28
+ searchString: String
29
+ }
30
+
6
31
  type Query {
7
- example(driveId: String!): String
32
+ getProfile(input: GetProfileInput!): RenownProfile
33
+ getProfiles(input: GetProfilesInput!): [RenownProfile!]!
8
34
  }
9
35
  `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/renown-package",
3
3
  "description": "",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [
@@ -44,6 +44,7 @@
44
44
  "graphql": "^16.10.0",
45
45
  "graphql-tag": "^2.12.6",
46
46
  "kysely": "^0.28.7",
47
+ "scalars": "link:../powerhouse/packages/scalars",
47
48
  "uuid": "^11.1.0",
48
49
  "zod": "^3.24.2"
49
50
  },
@@ -56,7 +57,7 @@
56
57
  "@powerhousedao/reactor-api": "staging",
57
58
  "@powerhousedao/reactor-browser": "staging",
58
59
  "@powerhousedao/reactor-local": "staging",
59
- "@powerhousedao/scalars": "2.0.1",
60
+ "@powerhousedao/scalars": "staging",
60
61
  "@powerhousedao/switchboard": "staging",
61
62
  "@tailwindcss/cli": "^4.0.15",
62
63
  "@testing-library/react": "^16.3.0",