@powerhousedao/vetra-builder-package 0.0.13 → 0.0.15
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/document-models/builder-account/gen/schema/types.d.ts +1 -1
- package/dist/document-models/builder-account/gen/schema/zod.js +1 -1
- package/dist/document-models/index.d.ts +1 -0
- package/dist/document-models/index.js +1 -0
- package/dist/document-models/renown-profile/gen/actions.d.ts +5 -0
- package/dist/document-models/renown-profile/gen/actions.js +2 -0
- package/dist/document-models/renown-profile/gen/authorization/actions.d.ts +11 -0
- package/dist/document-models/renown-profile/gen/authorization/actions.js +1 -0
- package/dist/document-models/renown-profile/gen/authorization/creators.d.ts +4 -0
- package/dist/document-models/renown-profile/gen/authorization/creators.js +4 -0
- package/dist/document-models/renown-profile/gen/authorization/error.d.ts +1 -0
- package/dist/document-models/renown-profile/gen/authorization/error.js +1 -0
- package/dist/document-models/renown-profile/gen/authorization/object.d.ts +7 -0
- package/dist/document-models/renown-profile/gen/authorization/object.js +10 -0
- package/dist/document-models/renown-profile/gen/authorization/operations.d.ts +7 -0
- package/dist/document-models/renown-profile/gen/authorization/operations.js +1 -0
- package/dist/document-models/renown-profile/gen/creators.d.ts +2 -0
- package/dist/document-models/renown-profile/gen/creators.js +2 -0
- package/dist/document-models/renown-profile/gen/document-model.d.ts +2 -0
- package/dist/document-models/renown-profile/gen/document-model.js +99 -0
- package/dist/document-models/renown-profile/gen/index.d.ts +7 -0
- package/dist/document-models/renown-profile/gen/index.js +6 -0
- package/dist/document-models/renown-profile/gen/object.d.ts +16 -0
- package/dist/document-models/renown-profile/gen/object.js +30 -0
- package/dist/document-models/renown-profile/gen/ph-factories.d.ts +26 -0
- package/dist/document-models/renown-profile/gen/ph-factories.js +53 -0
- package/dist/document-models/renown-profile/gen/profile/actions.d.ts +15 -0
- package/dist/document-models/renown-profile/gen/profile/actions.js +1 -0
- package/dist/document-models/renown-profile/gen/profile/creators.d.ts +5 -0
- package/dist/document-models/renown-profile/gen/profile/creators.js +5 -0
- package/dist/document-models/renown-profile/gen/profile/error.d.ts +1 -0
- package/dist/document-models/renown-profile/gen/profile/error.js +1 -0
- package/dist/document-models/renown-profile/gen/profile/object.d.ts +8 -0
- package/dist/document-models/renown-profile/gen/profile/object.js +13 -0
- package/dist/document-models/renown-profile/gen/profile/operations.d.ts +8 -0
- package/dist/document-models/renown-profile/gen/profile/operations.js +1 -0
- package/dist/document-models/renown-profile/gen/reducer.d.ts +4 -0
- package/dist/document-models/renown-profile/gen/reducer.js +37 -0
- package/dist/document-models/renown-profile/gen/schema/index.d.ts +2 -0
- package/dist/document-models/renown-profile/gen/schema/index.js +2 -0
- package/dist/document-models/renown-profile/gen/schema/types.d.ts +174 -0
- package/dist/document-models/renown-profile/gen/schema/types.js +1 -0
- package/dist/document-models/renown-profile/gen/schema/zod.d.ts +16 -0
- package/dist/document-models/renown-profile/gen/schema/zod.js +62 -0
- package/dist/document-models/renown-profile/gen/types.d.ts +9 -0
- package/dist/document-models/renown-profile/gen/types.js +1 -0
- package/dist/document-models/renown-profile/gen/utils.d.ts +21 -0
- package/dist/document-models/renown-profile/gen/utils.js +45 -0
- package/dist/document-models/renown-profile/index.d.ts +28 -0
- package/dist/document-models/renown-profile/index.js +21 -0
- package/dist/document-models/renown-profile/src/reducers/authorization.d.ts +2 -0
- package/dist/document-models/renown-profile/src/reducers/authorization.js +8 -0
- package/dist/document-models/renown-profile/src/reducers/profile.d.ts +2 -0
- package/dist/document-models/renown-profile/src/reducers/profile.js +11 -0
- package/dist/document-models/renown-profile/src/tests/authorization.test.d.ts +5 -0
- package/dist/document-models/renown-profile/src/tests/authorization.test.js +24 -0
- package/dist/document-models/renown-profile/src/tests/document-model.test.d.ts +5 -0
- package/dist/document-models/renown-profile/src/tests/document-model.test.js +18 -0
- package/dist/document-models/renown-profile/src/tests/profile.test.d.ts +5 -0
- package/dist/document-models/renown-profile/src/tests/profile.test.js +24 -0
- package/dist/document-models/renown-profile/src/utils.d.ts +1 -0
- package/dist/document-models/renown-profile/src/utils.js +1 -0
- package/dist/editors/builder-account-editor/editor.js +2 -3
- package/dist/editors/hooks/useRenownProfileDocument.d.ts +3 -0
- package/dist/editors/hooks/useRenownProfileDocument.js +8 -0
- package/dist/editors/index.d.ts +1 -0
- package/dist/editors/index.js +1 -0
- package/dist/editors/renown-profile-editor/editor.d.ts +3 -0
- package/dist/editors/renown-profile-editor/editor.js +33 -0
- package/dist/editors/renown-profile-editor/index.d.ts +2 -0
- package/dist/editors/renown-profile-editor/index.js +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/powerhouse.manifest.json +18 -1
- package/dist/processors/factory.js +2 -5
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.js +2 -0
- package/dist/processors/renown-profile/factory.d.ts +3 -0
- package/dist/processors/renown-profile/factory.js +22 -0
- package/dist/processors/renown-profile/index.d.ts +9 -0
- package/dist/processors/renown-profile/index.js +81 -0
- package/dist/processors/renown-profile/migrations.d.ts +3 -0
- package/dist/processors/renown-profile/migrations.js +39 -0
- package/dist/processors/renown-profile/schema.d.ts +14 -0
- package/dist/processors/renown-profile/schema.js +1 -0
- package/dist/processors/renown-read-model/migrations.d.ts +3 -0
- package/dist/processors/renown-read-model/migrations.js +55 -0
- package/dist/processors/renown-read-model/schema.d.ts +21 -0
- package/dist/processors/renown-read-model/schema.js +1 -0
- package/dist/processors/vetra-read-model/builder-account-handlers.js +7 -7
- package/dist/processors/vetra-read-model/database-helpers.d.ts +6 -1
- package/dist/processors/vetra-read-model/database-helpers.js +24 -1
- package/dist/processors/vetra-read-model/document-drive-handlers.d.ts +21 -0
- package/dist/processors/vetra-read-model/document-drive-handlers.js +77 -0
- package/dist/processors/vetra-read-model/factory.js +4 -1
- package/dist/processors/vetra-read-model/index.d.ts +2 -1
- package/dist/processors/vetra-read-model/index.js +23 -2
- package/dist/processors/vetra-read-model/migrations.js +22 -0
- package/dist/processors/vetra-read-model/schema.d.ts +7 -0
- package/dist/style.css +385 -17
- package/dist/subgraphs/index.d.ts +1 -0
- package/dist/subgraphs/index.js +2 -0
- package/dist/subgraphs/renown-profile/index.d.ts +10 -0
- package/dist/subgraphs/renown-profile/index.js +11 -0
- package/dist/subgraphs/renown-profile/resolvers.d.ts +2 -0
- package/dist/subgraphs/renown-profile/resolvers.js +151 -0
- package/dist/subgraphs/renown-profile/schema.d.ts +2 -0
- package/dist/subgraphs/renown-profile/schema.js +104 -0
- package/dist/subgraphs/renown-read-model/index.d.ts +10 -0
- package/dist/subgraphs/renown-read-model/index.js +11 -0
- package/dist/subgraphs/renown-read-model/resolvers.d.ts +2 -0
- package/dist/subgraphs/renown-read-model/resolvers.js +25 -0
- package/dist/subgraphs/renown-read-model/schema.d.ts +2 -0
- package/dist/subgraphs/renown-read-model/schema.js +16 -0
- package/dist/subgraphs/vetra-read-model/resolvers.js +31 -4
- package/package.json +3 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Subgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import type { DocumentNode } from "graphql";
|
|
3
|
+
export declare class RenownProfileSubgraph 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 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,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,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,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,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
|
+
`;
|
|
@@ -10,7 +10,11 @@ export const getResolvers = (subgraph) => {
|
|
|
10
10
|
const spaces = await VetraReadModelProcessor.query(driveId, db)
|
|
11
11
|
.selectFrom("builder_spaces")
|
|
12
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))
|
|
13
16
|
.where("builder_account_id", "=", parent.id)
|
|
17
|
+
.where("deleted_files.id", "is", null) // Exclude spaces from deleted accounts
|
|
14
18
|
.orderBy("sort_order", "asc")
|
|
15
19
|
.execute();
|
|
16
20
|
return spaces.map((space) => ({
|
|
@@ -30,7 +34,11 @@ export const getResolvers = (subgraph) => {
|
|
|
30
34
|
const members = await VetraReadModelProcessor.query(driveId, db)
|
|
31
35
|
.selectFrom("builder_account_members")
|
|
32
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))
|
|
33
40
|
.where("builder_account_id", "=", parent.id)
|
|
41
|
+
.where("deleted_files.id", "is", null) // Exclude members from deleted accounts
|
|
34
42
|
.execute();
|
|
35
43
|
return members.map((member) => ({
|
|
36
44
|
id: member.id,
|
|
@@ -46,7 +54,12 @@ export const getResolvers = (subgraph) => {
|
|
|
46
54
|
const packages = await VetraReadModelProcessor.query(driveId, db)
|
|
47
55
|
.selectFrom("builder_packages")
|
|
48
56
|
.selectAll()
|
|
49
|
-
.
|
|
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
|
|
50
63
|
.orderBy("sort_order", "asc")
|
|
51
64
|
.execute();
|
|
52
65
|
return packages.map((pkg) => ({
|
|
@@ -74,7 +87,13 @@ export const getResolvers = (subgraph) => {
|
|
|
74
87
|
const keywords = await VetraReadModelProcessor.query(driveId, db)
|
|
75
88
|
.selectFrom("builder_package_keywords")
|
|
76
89
|
.selectAll()
|
|
77
|
-
.
|
|
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
|
|
78
97
|
.execute();
|
|
79
98
|
return keywords.map((keyword) => ({
|
|
80
99
|
id: keyword.id,
|
|
@@ -91,7 +110,11 @@ export const getResolvers = (subgraph) => {
|
|
|
91
110
|
const sortOrder = args.sortOrder || "asc";
|
|
92
111
|
let accounts = VetraReadModelProcessor.query(driveId, db)
|
|
93
112
|
.selectFrom("builder_accounts")
|
|
94
|
-
.selectAll()
|
|
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
|
|
95
118
|
if (search) {
|
|
96
119
|
accounts = accounts.where((eb) => {
|
|
97
120
|
return eb("profile_name", "ilike", `%${search}%`)
|
|
@@ -123,7 +146,11 @@ export const getResolvers = (subgraph) => {
|
|
|
123
146
|
const account = await VetraReadModelProcessor.query(driveId, db)
|
|
124
147
|
.selectFrom("builder_accounts")
|
|
125
148
|
.selectAll()
|
|
126
|
-
.
|
|
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
|
|
127
154
|
.executeTakeFirst();
|
|
128
155
|
if (!account) {
|
|
129
156
|
return null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/vetra-builder-package",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
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": "^
|
|
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",
|