@powerhousedao/renown-package 1.2.2 → 1.3.1

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.
@@ -1,9 +1,5 @@
1
- /**
2
- * This file aggregates all processor factories
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: IProcessorHostModuleLegacy | IProcessorHostModuleWithReactor) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecordLegacy[]>;
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;;;GAGG;AAEH,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAEhC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,0BAA0B,GAAG,+BAA+B,MAgBtD,aAAa,gBAAgB,KAAG,OAAO,CAAC,qBAAqB,EAAE,CAU9E,CAAC"}
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 { type ProcessorRecordLegacy, type IProcessorHostModuleLegacy } from "document-drive";
2
- import { type PHDocumentHeader } from "document-model";
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 IProcessorHostModuleLegacy {
4
+ export interface IProcessorHostModuleWithReactor extends IProcessorHostModule {
5
5
  reactor?: IReactor;
6
6
  }
7
- export declare const renownCredentialProcessorFactory: (module: IProcessorHostModuleWithReactor) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecordLegacy[]>;
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,EACL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAChC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA6B,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,+BAAgC,SAAQ,0BAA0B;IACjF,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,eAAO,MAAM,gCAAgC,GAC1C,QAAQ,+BAA+B,MACjC,aAAa,gBAAgB,KAAG,OAAO,CAAC,qBAAqB,EAAE,CAgCrE,CAAC"}
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 { RelationalDbProcessorLegacy, type RelationalDbProcessorFilterLegacy, type IRelationalDbLegacy } from "document-drive";
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 RelationalDbProcessorLegacy<DB> {
6
+ export declare class RenownCredentialProcessor extends RelationalDbProcessor<DB> {
8
7
  private reactor?;
9
- constructor(namespace: string, filter: RelationalDbProcessorFilterLegacy, relationalDb: IRelationalDbLegacy<DB>, reactor?: IReactor);
8
+ constructor(namespace: string, filter: ProcessorFilter, relationalDb: IRelationalDb<DB>, reactor?: IReactor);
10
9
  static getNamespace(driveId: string): string;
11
10
  initAndUpgrade(): Promise<void>;
12
- onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
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,2BAA2B,EAC3B,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,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,2BAA2B,CAAC,EAAE,CAAC;IAC5E,OAAO,CAAC,OAAO,CAAC,CAAW;gBAGzB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,iCAAiC,EACzC,YAAY,EAAE,mBAAmB,CAAC,EAAE,CAAC,EACrC,OAAO,CAAC,EAAE,QAAQ;WASJ,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAStC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ/B,SAAS,CACtB,OAAO,EAAE,yBAAyB,EAAE,GACnC,OAAO,CAAC,IAAI,CAAC;IA8KV,YAAY;CACnB"}
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 { RelationalDbProcessorLegacy, } from "document-drive";
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 RelationalDbProcessorLegacy {
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
- // Default namespace: `${this.name}_${driveId.replaceAll("-", "_")}`
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 onStrands(strands) {
24
- console.log(`[RenownCredentialProcessor] onStrands called with ${strands.length} strands`);
25
- if (strands.length === 0) {
16
+ async onOperations(operations) {
17
+ if (operations.length === 0) {
26
18
  return;
27
19
  }
28
- for (const strand of strands) {
29
- if (strand.operations.length === 0) {
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
- // Process each operation
44
- for (const operation of strand.operations) {
45
- console.log(`[RenownCredentialProcessor] Processing operation: ${operation.action.type}`);
46
- switch (operation.action.type) {
47
- case "INIT": {
48
- console.log(`[RenownCredentialProcessor] INIT - documentId: ${documentId}, existingCredential: ${!!existingCredential}`);
49
- // INIT operation receives full EIP-712 credential structure
50
- console.log(`[RenownCredentialProcessor] INIT - Processing state`);
51
- // State is directly the global state, not wrapped in a .global property
52
- const state = strand.state;
53
- console.log(`[RenownCredentialProcessor] INIT - Credential ID:`, state?.id);
54
- console.log(`[RenownCredentialProcessor] INIT - Issuer:`, state?.issuer?.id);
55
- if (state && !existingCredential) {
56
- console.log(`[RenownCredentialProcessor] INIT - Inserting credential: issuer=${state.issuer?.id}, credentialId=${state.id}`);
57
- await this.relationalDb
58
- .insertInto("renown_credential")
59
- .values({
60
- document_id: documentId,
61
- context: state.context ? JSON.stringify(state.context) : "[]",
62
- credential_id: state.id || "",
63
- type: state.type ? JSON.stringify(state.type) : "[]",
64
- issuer_id: state.issuer?.id || "",
65
- issuer_ethereum_address: state.issuer?.ethereumAddress || "",
66
- issuance_date: state.issuanceDate
67
- ? new Date(state.issuanceDate)
68
- : new Date(),
69
- expiration_date: state.expirationDate
70
- ? new Date(state.expirationDate)
71
- : null,
72
- credential_subject_id: state.credentialSubject?.id || null,
73
- credential_subject_app: state.credentialSubject?.app || "",
74
- credential_status_id: state.credentialStatus?.id || null,
75
- credential_status_type: state.credentialStatus?.type || null,
76
- credential_schema_id: state.credentialSchema?.id || "",
77
- credential_schema_type: state.credentialSchema?.type || "",
78
- proof_verification_method: state.proof?.verificationMethod || "",
79
- proof_ethereum_address: state.proof?.ethereumAddress || "",
80
- proof_created: state.proof?.created
81
- ? new Date(state.proof.created)
82
- : new Date(),
83
- proof_purpose: state.proof?.proofPurpose || "",
84
- proof_type: state.proof?.type || "",
85
- proof_value: state.proof?.proofValue || "",
86
- proof_eip712_domain: state.proof?.eip712?.domain
87
- ? JSON.stringify(state.proof.eip712.domain)
88
- : "{}",
89
- proof_eip712_primary_type: state.proof?.eip712?.primaryType || "",
90
- revoked: state.revoked || false,
91
- revoked_at: state.revokedAt
92
- ? new Date(state.revokedAt)
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
- case "REVOKE": {
107
- console.log(`[RenownCredentialProcessor] REVOKE - documentId: ${documentId}`);
108
- const input = operation.action.input;
109
- if (input && existingCredential) {
110
- console.log(`[RenownCredentialProcessor] REVOKE - Marking as revoked and deleting document`);
111
- // Update the database to mark as revoked
112
- await this.relationalDb
113
- .updateTable("renown_credential")
114
- .set({
115
- revoked: true,
116
- revoked_at: new Date(input.revokedAt),
117
- revocation_reason: input.reason || null,
118
- updated_at: new Date(),
119
- })
120
- .where("document_id", "=", documentId)
121
- .execute();
122
- // Delete the credential document using the reactor
123
- if (this.reactor) {
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
- else {
135
- console.log(`[RenownCredentialProcessor] REVOKE - No reactor available, skipping document deletion`);
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 { type IRelationalDbLegacy } from "document-drive";
2
- export declare function up(db: IRelationalDbLegacy<any>): Promise<void>;
3
- export declare function down(db: IRelationalDbLegacy<any>): Promise<void>;
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,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,wBAAsB,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsFpE;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BtE"}
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,3 @@
1
- import {} from "document-drive";
2
1
  export async function up(db) {
3
2
  await down(db);
4
3
  // Create renown_credential table with EIP-712 signed credential schema
@@ -1,4 +1,4 @@
1
- import { type ProcessorRecordLegacy, type IProcessorHostModuleLegacy } from "document-drive";
2
- import { type PHDocumentHeader } from "document-model";
3
- export declare const renownUserProcessorFactory: (module: IProcessorHostModuleLegacy) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecordLegacy[]>;
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,EACL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAChC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,eAAO,MAAM,0BAA0B,GACpC,QAAQ,0BAA0B,MAC5B,aAAa,gBAAgB,KAAG,OAAO,CAAC,qBAAqB,EAAE,CAwBrE,CAAC"}
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 { RelationalDbProcessorLegacy } from "document-drive";
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 RelationalDbProcessorLegacy<DB> {
3
+ export declare class RenownUserProcessor extends RelationalDbProcessor<DB> {
5
4
  static getNamespace(driveId: string): string;
6
5
  initAndUpgrade(): Promise<void>;
7
- onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
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,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,qBAAa,mBAAoB,SAAQ,2BAA2B,CAAC,EAAE,CAAC;WACtD,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAKtC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,SAAS,CACtB,OAAO,EAAE,yBAAyB,EAAE,GACnC,OAAO,CAAC,IAAI,CAAC;IAwFV,YAAY;CACnB"}
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 { RelationalDbProcessorLegacy } from "document-drive";
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 RelationalDbProcessorLegacy {
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 onStrands(strands) {
14
- if (strands.length === 0) {
11
+ async onOperations(operations) {
12
+ if (operations.length === 0) {
15
13
  return;
16
14
  }
17
- for (const strand of strands) {
18
- if (strand.operations.length === 0) {
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
- // Process each operation
43
- for (const operation of strand.operations) {
44
- // Update the User based on the operation type
45
- const updateData = {
46
- updated_at: new Date(),
47
- };
48
- switch (operation.action.type) {
49
- case "SET_USERNAME": {
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
- case "SET_ETH_ADDRESS": {
57
- const input = operation.action.input;
58
- if (input?.ethAddress) {
59
- updateData.eth_address = input.ethAddress;
60
- }
61
- break;
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
- // Apply updates if there are any field changes
72
- if (Object.keys(updateData).length > 1) {
73
- await this.relationalDb
74
- .updateTable("renown_user")
75
- .set(updateData)
76
- .where("document_id", "=", documentId)
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 { type IRelationalDbLegacy } from "document-drive";
2
- export declare function up(db: IRelationalDbLegacy<any>): Promise<void>;
3
- export declare function down(db: IRelationalDbLegacy<any>): Promise<void>;
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,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,wBAAsB,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BpE;AAED,wBAAsB,IAAI,CAAC,EAAE,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAOtE"}
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,4 +1,3 @@
1
- import {} from "document-drive";
2
1
  export async function up(db) {
3
2
  await down(db);
4
3
  // Create renown_user table
@@ -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;AAwJ5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAmJxE,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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/renown-package",
3
3
  "description": "Renown document models, editors, and processors for the Powerhouse ecosystem",
4
- "version": "1.2.2",
4
+ "version": "1.3.1",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
7
7
  "type": "git",