@powerhousedao/renown-package 1.2.1 → 1.3.0
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/processors/factory.d.ts +3 -7
- package/dist/processors/factory.d.ts.map +1 -1
- package/dist/processors/factory.js +1 -12
- package/dist/processors/renown-credential/factory.d.ts +4 -4
- package/dist/processors/renown-credential/factory.d.ts.map +1 -1
- package/dist/processors/renown-credential/factory.js +1 -13
- package/dist/processors/renown-credential/index.d.ts +4 -5
- package/dist/processors/renown-credential/index.d.ts.map +1 -1
- package/dist/processors/renown-credential/index.js +78 -118
- package/dist/processors/renown-credential/migrations.d.ts +3 -3
- package/dist/processors/renown-credential/migrations.d.ts.map +1 -1
- package/dist/processors/renown-credential/migrations.js +0 -1
- package/dist/processors/renown-user/factory.d.ts +3 -3
- package/dist/processors/renown-user/factory.d.ts.map +1 -1
- package/dist/processors/renown-user/factory.js +1 -13
- package/dist/processors/renown-user/index.d.ts +3 -4
- package/dist/processors/renown-user/index.d.ts.map +1 -1
- package/dist/processors/renown-user/index.js +34 -45
- package/dist/processors/renown-user/migrations.d.ts +3 -3
- package/dist/processors/renown-user/migrations.d.ts.map +1 -1
- package/dist/processors/renown-user/migrations.js +0 -1
- package/dist/subgraphs/renown-read-model/resolvers.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Auto-generated by codegen - DO NOT EDIT MANUALLY
|
|
4
|
-
*/
|
|
5
|
-
import { type ProcessorRecordLegacy, type IProcessorHostModuleLegacy } from "document-drive";
|
|
6
|
-
import { type PHDocumentHeader } from "document-model";
|
|
1
|
+
import type { ProcessorRecord, IProcessorHostModule } from "@powerhousedao/reactor-browser";
|
|
2
|
+
import type { PHDocumentHeader } from "document-model";
|
|
7
3
|
import { type IProcessorHostModuleWithReactor } from "./renown-credential/factory.js";
|
|
8
|
-
export declare const processorFactory: (module:
|
|
4
|
+
export declare const processorFactory: (module: IProcessorHostModule | IProcessorHostModuleWithReactor) => Promise<(driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>>;
|
|
9
5
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../processors/factory.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../processors/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,oBAAoB,GAAG,+BAA+B,2BAanC,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAQzE,CAAC"}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file aggregates all processor factories
|
|
3
|
-
* Auto-generated by codegen - DO NOT EDIT MANUALLY
|
|
4
|
-
*/
|
|
5
|
-
import {} from "document-drive";
|
|
6
|
-
import {} from "document-model";
|
|
7
|
-
// Import processor factories here as they are generated
|
|
8
1
|
import { renownUserProcessorFactory } from "./renown-user/factory.js";
|
|
9
2
|
import { renownCredentialProcessorFactory, } from "./renown-credential/factory.js";
|
|
10
|
-
export const processorFactory = (module) => {
|
|
11
|
-
// Initialize all processor factories once with the module
|
|
3
|
+
export const processorFactory = async (module) => {
|
|
12
4
|
const factories = [];
|
|
13
|
-
// Add processors here as they are generated
|
|
14
5
|
factories.push(renownUserProcessorFactory(module));
|
|
15
6
|
factories.push(renownCredentialProcessorFactory(module));
|
|
16
|
-
// Return the inner function that will be called for each drive
|
|
17
7
|
return async (driveHeader) => {
|
|
18
8
|
const processors = [];
|
|
19
|
-
// Call each cached factory with the driveId
|
|
20
9
|
for (const factory of factories) {
|
|
21
10
|
const factoryProcessors = await factory(driveHeader);
|
|
22
11
|
processors.push(...factoryProcessors);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ProcessorRecord, IProcessorHostModule } from "@powerhousedao/reactor-browser";
|
|
2
|
+
import type { PHDocumentHeader } from "document-model";
|
|
3
3
|
import { type IReactor } from "./index.js";
|
|
4
|
-
export interface IProcessorHostModuleWithReactor extends
|
|
4
|
+
export interface IProcessorHostModuleWithReactor extends IProcessorHostModule {
|
|
5
5
|
reactor?: IReactor;
|
|
6
6
|
}
|
|
7
|
-
export declare const renownCredentialProcessorFactory: (module: IProcessorHostModuleWithReactor) => (driveHeader: PHDocumentHeader) => Promise<
|
|
7
|
+
export declare const renownCredentialProcessorFactory: (module: IProcessorHostModuleWithReactor) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
|
|
8
8
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/renown-credential/factory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/renown-credential/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,+BAAgC,SAAQ,oBAAoB;IAC3E,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,eAAO,MAAM,gCAAgC,GAC1C,QAAQ,+BAA+B,MACjC,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAsB/D,CAAC"}
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import {} from "document-drive";
|
|
2
|
-
import {} from "document-drive";
|
|
3
|
-
import {} from "document-model";
|
|
4
1
|
import { RenownCredentialProcessor } from "./index.js";
|
|
5
2
|
export const renownCredentialProcessorFactory = (module) => async (driveHeader) => {
|
|
6
|
-
// Create a namespace for the processor and the provided drive id
|
|
7
3
|
const namespace = RenownCredentialProcessor.getNamespace("renown-credential");
|
|
8
|
-
// Create a namespaced db for the processor
|
|
9
4
|
const store = await module.relationalDb.createNamespace(namespace);
|
|
10
|
-
// Create a filter for the processor
|
|
11
5
|
const filter = {
|
|
12
6
|
branch: ["main"],
|
|
13
7
|
documentId: ["*"],
|
|
14
8
|
documentType: ["powerhouse/renown-credential"],
|
|
15
9
|
scope: ["global"],
|
|
16
10
|
};
|
|
17
|
-
// Create the processor with reactor support
|
|
18
11
|
const processor = new RenownCredentialProcessor(namespace, filter, store, module.reactor);
|
|
19
|
-
return [
|
|
20
|
-
{
|
|
21
|
-
processor,
|
|
22
|
-
filter,
|
|
23
|
-
},
|
|
24
|
-
];
|
|
12
|
+
return [{ processor, filter }];
|
|
25
13
|
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type InternalTransmitterUpdate } from "document-drive";
|
|
1
|
+
import { RelationalDbProcessor, type OperationWithContext, type ProcessorFilter, type IRelationalDb } from "@powerhousedao/reactor-browser";
|
|
3
2
|
import { type DB } from "./schema.js";
|
|
4
3
|
export interface IReactor {
|
|
5
4
|
deleteDocument(documentId: string): Promise<boolean>;
|
|
6
5
|
}
|
|
7
|
-
export declare class RenownCredentialProcessor extends
|
|
6
|
+
export declare class RenownCredentialProcessor extends RelationalDbProcessor<DB> {
|
|
8
7
|
private reactor?;
|
|
9
|
-
constructor(namespace: string, filter:
|
|
8
|
+
constructor(namespace: string, filter: ProcessorFilter, relationalDb: IRelationalDb<DB>, reactor?: IReactor);
|
|
10
9
|
static getNamespace(driveId: string): string;
|
|
11
10
|
initAndUpgrade(): Promise<void>;
|
|
12
|
-
|
|
11
|
+
onOperations(operations: OperationWithContext[]): Promise<void>;
|
|
13
12
|
onDisconnect(): Promise<void>;
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/renown-credential/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/renown-credential/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAMtC,MAAM,WAAW,QAAQ;IACvB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD;AAED,qBAAa,yBAA0B,SAAQ,qBAAqB,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,OAAO,CAAC,CAAW;gBAGzB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,aAAa,CAAC,EAAE,CAAC,EAC/B,OAAO,CAAC,EAAE,QAAQ;WAMJ,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY,CACzB,UAAU,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IAqGV,YAAY;CACnB"}
|
|
@@ -1,145 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {} from "document-drive";
|
|
1
|
+
import { RelationalDbProcessor, } from "@powerhousedao/reactor-browser";
|
|
3
2
|
import { up } from "./migrations.js";
|
|
4
3
|
import {} from "./schema.js";
|
|
5
|
-
export class RenownCredentialProcessor extends
|
|
4
|
+
export class RenownCredentialProcessor extends RelationalDbProcessor {
|
|
6
5
|
reactor;
|
|
7
6
|
constructor(namespace, filter, relationalDb, reactor) {
|
|
8
7
|
super(namespace, filter, relationalDb);
|
|
9
8
|
this.reactor = reactor;
|
|
10
|
-
console.log(`[RenownCredentialProcessor] Constructor called - namespace: ${namespace}, has reactor: ${!!reactor}`);
|
|
11
9
|
}
|
|
12
10
|
static getNamespace(driveId) {
|
|
13
|
-
|
|
14
|
-
const namespace = super.getNamespace(driveId);
|
|
15
|
-
console.log(`[RenownCredentialProcessor] getNamespace called - driveId: ${driveId}, namespace: ${namespace}`);
|
|
16
|
-
return namespace;
|
|
11
|
+
return super.getNamespace(driveId);
|
|
17
12
|
}
|
|
18
13
|
async initAndUpgrade() {
|
|
19
|
-
console.log(`[RenownCredentialProcessor] initAndUpgrade called - running migrations`);
|
|
20
14
|
await up(this.relationalDb);
|
|
21
|
-
console.log(`[RenownCredentialProcessor] initAndUpgrade completed`);
|
|
22
15
|
}
|
|
23
|
-
async
|
|
24
|
-
|
|
25
|
-
if (strands.length === 0) {
|
|
16
|
+
async onOperations(operations) {
|
|
17
|
+
if (operations.length === 0) {
|
|
26
18
|
return;
|
|
27
19
|
}
|
|
28
|
-
for (const
|
|
29
|
-
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const documentId = strand.documentId;
|
|
33
|
-
console.log(`[RenownCredentialProcessor] Processing document ${documentId} with ${strand.operations.length} operations`);
|
|
34
|
-
console.log(`[RenownCredentialProcessor] Strand keys:`, Object.keys(strand));
|
|
35
|
-
console.log(`[RenownCredentialProcessor] Has state:`, !!strand.state);
|
|
36
|
-
console.log(`[RenownCredentialProcessor] State type:`, typeof strand.state, strand.state);
|
|
37
|
-
// Ensure the Credential exists in the database
|
|
20
|
+
for (const { operation, context } of operations) {
|
|
21
|
+
const documentId = context.documentId;
|
|
38
22
|
const existingCredential = await this.relationalDb
|
|
39
23
|
.selectFrom("renown_credential")
|
|
40
24
|
.select(["document_id"])
|
|
41
25
|
.where("document_id", "=", documentId)
|
|
42
26
|
.executeTakeFirst();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
: null,
|
|
94
|
-
revocation_reason: state.revocationReason || null,
|
|
95
|
-
created_at: new Date(),
|
|
96
|
-
updated_at: new Date(),
|
|
97
|
-
})
|
|
98
|
-
.execute();
|
|
99
|
-
console.log(`[RenownCredentialProcessor] INIT - Credential inserted successfully`);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
console.log(`[RenownCredentialProcessor] INIT - Skipped: state=${!!state}, existingCredential=${!!existingCredential}`);
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
27
|
+
switch (operation.action.type) {
|
|
28
|
+
case "INIT": {
|
|
29
|
+
// resultingState contains the full document state after this operation
|
|
30
|
+
const stateStr = operation.resultingState ?? context.resultingState;
|
|
31
|
+
const state = stateStr
|
|
32
|
+
? JSON.parse(stateStr)
|
|
33
|
+
: undefined;
|
|
34
|
+
if (state && !existingCredential) {
|
|
35
|
+
await this.relationalDb
|
|
36
|
+
.insertInto("renown_credential")
|
|
37
|
+
.values({
|
|
38
|
+
document_id: documentId,
|
|
39
|
+
context: state.context ? JSON.stringify(state.context) : "[]",
|
|
40
|
+
credential_id: state.id || "",
|
|
41
|
+
type: state.type ? JSON.stringify(state.type) : "[]",
|
|
42
|
+
issuer_id: state.issuer?.id || "",
|
|
43
|
+
issuer_ethereum_address: state.issuer?.ethereumAddress || "",
|
|
44
|
+
issuance_date: state.issuanceDate
|
|
45
|
+
? new Date(state.issuanceDate)
|
|
46
|
+
: new Date(),
|
|
47
|
+
expiration_date: state.expirationDate
|
|
48
|
+
? new Date(state.expirationDate)
|
|
49
|
+
: null,
|
|
50
|
+
credential_subject_id: state.credentialSubject?.id || null,
|
|
51
|
+
credential_subject_app: state.credentialSubject?.app || "",
|
|
52
|
+
credential_status_id: state.credentialStatus?.id || null,
|
|
53
|
+
credential_status_type: state.credentialStatus?.type || null,
|
|
54
|
+
credential_schema_id: state.credentialSchema?.id || "",
|
|
55
|
+
credential_schema_type: state.credentialSchema?.type || "",
|
|
56
|
+
proof_verification_method: state.proof?.verificationMethod || "",
|
|
57
|
+
proof_ethereum_address: state.proof?.ethereumAddress || "",
|
|
58
|
+
proof_created: state.proof?.created
|
|
59
|
+
? new Date(state.proof.created)
|
|
60
|
+
: new Date(),
|
|
61
|
+
proof_purpose: state.proof?.proofPurpose || "",
|
|
62
|
+
proof_type: state.proof?.type || "",
|
|
63
|
+
proof_value: state.proof?.proofValue || "",
|
|
64
|
+
proof_eip712_domain: state.proof?.eip712?.domain
|
|
65
|
+
? JSON.stringify(state.proof.eip712.domain)
|
|
66
|
+
: "{}",
|
|
67
|
+
proof_eip712_primary_type: state.proof?.eip712?.primaryType || "",
|
|
68
|
+
revoked: state.revoked || false,
|
|
69
|
+
revoked_at: state.revokedAt
|
|
70
|
+
? new Date(state.revokedAt)
|
|
71
|
+
: null,
|
|
72
|
+
revocation_reason: state.revocationReason || null,
|
|
73
|
+
created_at: new Date(),
|
|
74
|
+
updated_at: new Date(),
|
|
75
|
+
})
|
|
76
|
+
.execute();
|
|
105
77
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
console.log(`[RenownCredentialProcessor] REVOKE - Calling reactor.deleteDocument`);
|
|
126
|
-
await this.reactor.deleteDocument(documentId);
|
|
127
|
-
console.log(`[RenownCredentialProcessor] REVOKE - Document deleted successfully`);
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
// Log error but don't throw - database already updated
|
|
131
|
-
console.error(`[RenownCredentialProcessor] REVOKE - Failed to delete revoked credential document ${documentId}:`, error);
|
|
132
|
-
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "REVOKE": {
|
|
81
|
+
const input = operation.action.input;
|
|
82
|
+
if (input && existingCredential) {
|
|
83
|
+
await this.relationalDb
|
|
84
|
+
.updateTable("renown_credential")
|
|
85
|
+
.set({
|
|
86
|
+
revoked: true,
|
|
87
|
+
revoked_at: new Date(input.revokedAt),
|
|
88
|
+
revocation_reason: input.reason || null,
|
|
89
|
+
updated_at: new Date(),
|
|
90
|
+
})
|
|
91
|
+
.where("document_id", "=", documentId)
|
|
92
|
+
.execute();
|
|
93
|
+
if (this.reactor) {
|
|
94
|
+
try {
|
|
95
|
+
await this.reactor.deleteDocument(documentId);
|
|
133
96
|
}
|
|
134
|
-
|
|
135
|
-
console.
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error(`[RenownCredentialProcessor] Failed to delete revoked credential document ${documentId}:`, error);
|
|
136
99
|
}
|
|
137
100
|
}
|
|
138
|
-
else {
|
|
139
|
-
console.log(`[RenownCredentialProcessor] REVOKE - Skipped: input=${!!input}, existingCredential=${!!existingCredential}`);
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
101
|
}
|
|
102
|
+
break;
|
|
143
103
|
}
|
|
144
104
|
}
|
|
145
105
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function up(db:
|
|
3
|
-
export declare function down(db:
|
|
1
|
+
import type { IRelationalDb } from "@powerhousedao/reactor-browser";
|
|
2
|
+
export declare function up(db: IRelationalDb<any>): Promise<void>;
|
|
3
|
+
export declare function down(db: IRelationalDb<any>): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/renown-credential/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/renown-credential/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,wBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsF9D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BhE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const renownUserProcessorFactory: (module:
|
|
1
|
+
import type { ProcessorRecord, IProcessorHostModule } from "@powerhousedao/reactor-browser";
|
|
2
|
+
import type { PHDocumentHeader } from "document-model";
|
|
3
|
+
export declare const renownUserProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
|
|
4
4
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/renown-user/factory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../processors/renown-user/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,0BAA0B,GACpC,QAAQ,oBAAoB,MACtB,aAAa,gBAAgB,KAAG,OAAO,CAAC,eAAe,EAAE,CAc/D,CAAC"}
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import {} from "document-drive";
|
|
2
|
-
import {} from "document-drive";
|
|
3
|
-
import {} from "document-model";
|
|
4
1
|
import { RenownUserProcessor } from "./index.js";
|
|
5
2
|
export const renownUserProcessorFactory = (module) => async (driveHeader) => {
|
|
6
|
-
// Create a namespace for the processor and the provided drive id
|
|
7
3
|
const namespace = RenownUserProcessor.getNamespace("renown-user");
|
|
8
|
-
// Create a namespaced db for the processor
|
|
9
4
|
const store = await module.relationalDb.createNamespace(namespace);
|
|
10
|
-
// Create a filter for the processor
|
|
11
5
|
const filter = {
|
|
12
6
|
branch: ["main"],
|
|
13
7
|
documentId: ["*"],
|
|
14
8
|
documentType: ["powerhouse/renown-user"],
|
|
15
9
|
scope: ["global"],
|
|
16
10
|
};
|
|
17
|
-
// Create the processor
|
|
18
11
|
const processor = new RenownUserProcessor(namespace, filter, store);
|
|
19
|
-
return [
|
|
20
|
-
{
|
|
21
|
-
processor,
|
|
22
|
-
filter,
|
|
23
|
-
},
|
|
24
|
-
];
|
|
12
|
+
return [{ processor, filter }];
|
|
25
13
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type InternalTransmitterUpdate } from "document-drive";
|
|
1
|
+
import { RelationalDbProcessor, type OperationWithContext } from "@powerhousedao/reactor-browser";
|
|
3
2
|
import { type DB } from "./schema.js";
|
|
4
|
-
export declare class RenownUserProcessor extends
|
|
3
|
+
export declare class RenownUserProcessor extends RelationalDbProcessor<DB> {
|
|
5
4
|
static getNamespace(driveId: string): string;
|
|
6
5
|
initAndUpgrade(): Promise<void>;
|
|
7
|
-
|
|
6
|
+
onOperations(operations: OperationWithContext[]): Promise<void>;
|
|
8
7
|
onDisconnect(): Promise<void>;
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/renown-user/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../processors/renown-user/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,qBAAa,mBAAoB,SAAQ,qBAAqB,CAAC,EAAE,CAAC;WAChD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY,CACzB,UAAU,EAAE,oBAAoB,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC;IA8EV,YAAY;CACnB"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {} from "document-drive";
|
|
1
|
+
import { RelationalDbProcessor, } from "@powerhousedao/reactor-browser";
|
|
3
2
|
import { up } from "./migrations.js";
|
|
4
3
|
import {} from "./schema.js";
|
|
5
|
-
export class RenownUserProcessor extends
|
|
4
|
+
export class RenownUserProcessor extends RelationalDbProcessor {
|
|
6
5
|
static getNamespace(driveId) {
|
|
7
|
-
// Default namespace: `${this.name}_${driveId.replaceAll("-", "_")}`
|
|
8
6
|
return super.getNamespace(driveId);
|
|
9
7
|
}
|
|
10
8
|
async initAndUpgrade() {
|
|
11
9
|
await up(this.relationalDb);
|
|
12
10
|
}
|
|
13
|
-
async
|
|
14
|
-
if (
|
|
11
|
+
async onOperations(operations) {
|
|
12
|
+
if (operations.length === 0) {
|
|
15
13
|
return;
|
|
16
14
|
}
|
|
17
|
-
for (const
|
|
18
|
-
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const documentId = strand.documentId;
|
|
15
|
+
for (const { operation, context } of operations) {
|
|
16
|
+
const documentId = context.documentId;
|
|
22
17
|
// Ensure the User exists in the database
|
|
23
18
|
const existingUser = await this.relationalDb
|
|
24
19
|
.selectFrom("renown_user")
|
|
@@ -26,7 +21,6 @@ export class RenownUserProcessor extends RelationalDbProcessorLegacy {
|
|
|
26
21
|
.where("document_id", "=", documentId)
|
|
27
22
|
.executeTakeFirst();
|
|
28
23
|
if (!existingUser) {
|
|
29
|
-
// Create a new User entry
|
|
30
24
|
await this.relationalDb
|
|
31
25
|
.insertInto("renown_user")
|
|
32
26
|
.values({
|
|
@@ -39,44 +33,39 @@ export class RenownUserProcessor extends RelationalDbProcessorLegacy {
|
|
|
39
33
|
})
|
|
40
34
|
.execute();
|
|
41
35
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const input = operation.action.input;
|
|
51
|
-
if (input?.username) {
|
|
52
|
-
updateData.username = input.username;
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
36
|
+
const updateData = {
|
|
37
|
+
updated_at: new Date(),
|
|
38
|
+
};
|
|
39
|
+
switch (operation.action.type) {
|
|
40
|
+
case "SET_USERNAME": {
|
|
41
|
+
const input = operation.action.input;
|
|
42
|
+
if (input?.username) {
|
|
43
|
+
updateData.username = input.username;
|
|
55
44
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
case "SET_USER_IMAGE": {
|
|
64
|
-
const input = operation.action.input;
|
|
65
|
-
if (input?.userImage !== undefined) {
|
|
66
|
-
updateData.user_image = input.userImage || null;
|
|
67
|
-
}
|
|
68
|
-
break;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "SET_ETH_ADDRESS": {
|
|
48
|
+
const input = operation.action.input;
|
|
49
|
+
if (input?.ethAddress) {
|
|
50
|
+
updateData.eth_address = input.ethAddress;
|
|
69
51
|
}
|
|
52
|
+
break;
|
|
70
53
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.execute();
|
|
54
|
+
case "SET_USER_IMAGE": {
|
|
55
|
+
const input = operation.action.input;
|
|
56
|
+
if (input?.userImage !== undefined) {
|
|
57
|
+
updateData.user_image = input.userImage || null;
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
78
60
|
}
|
|
79
61
|
}
|
|
62
|
+
if (Object.keys(updateData).length > 1) {
|
|
63
|
+
await this.relationalDb
|
|
64
|
+
.updateTable("renown_user")
|
|
65
|
+
.set(updateData)
|
|
66
|
+
.where("document_id", "=", documentId)
|
|
67
|
+
.execute();
|
|
68
|
+
}
|
|
80
69
|
}
|
|
81
70
|
}
|
|
82
71
|
async onDisconnect() { }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function up(db:
|
|
3
|
-
export declare function down(db:
|
|
1
|
+
import type { IRelationalDb } from "@powerhousedao/reactor-browser";
|
|
2
|
+
export declare function up(db: IRelationalDb<any>): Promise<void>;
|
|
3
|
+
export declare function down(db: IRelationalDb<any>): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/renown-user/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../processors/renown-user/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,wBAAsB,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B9D;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/renown-read-model/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/renown-read-model/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAyJ5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAmJxE,CAAC"}
|
package/package.json
CHANGED