@powerhousedao/vetra-builder-package 0.0.14 → 0.0.16

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.
Files changed (110) hide show
  1. package/dist/document-models/builder-account/gen/schema/types.d.ts +1 -1
  2. package/dist/document-models/builder-account/gen/schema/zod.js +1 -1
  3. package/dist/document-models/index.d.ts +1 -0
  4. package/dist/document-models/index.js +1 -0
  5. package/dist/document-models/renown-profile/gen/actions.d.ts +5 -0
  6. package/dist/document-models/renown-profile/gen/actions.js +2 -0
  7. package/dist/document-models/renown-profile/gen/authorization/actions.d.ts +11 -0
  8. package/dist/document-models/renown-profile/gen/authorization/actions.js +1 -0
  9. package/dist/document-models/renown-profile/gen/authorization/creators.d.ts +4 -0
  10. package/dist/document-models/renown-profile/gen/authorization/creators.js +4 -0
  11. package/dist/document-models/renown-profile/gen/authorization/error.d.ts +1 -0
  12. package/dist/document-models/renown-profile/gen/authorization/error.js +1 -0
  13. package/dist/document-models/renown-profile/gen/authorization/object.d.ts +7 -0
  14. package/dist/document-models/renown-profile/gen/authorization/object.js +10 -0
  15. package/dist/document-models/renown-profile/gen/authorization/operations.d.ts +7 -0
  16. package/dist/document-models/renown-profile/gen/authorization/operations.js +1 -0
  17. package/dist/document-models/renown-profile/gen/creators.d.ts +2 -0
  18. package/dist/document-models/renown-profile/gen/creators.js +2 -0
  19. package/dist/document-models/renown-profile/gen/document-model.d.ts +2 -0
  20. package/dist/document-models/renown-profile/gen/document-model.js +99 -0
  21. package/dist/document-models/renown-profile/gen/index.d.ts +7 -0
  22. package/dist/document-models/renown-profile/gen/index.js +6 -0
  23. package/dist/document-models/renown-profile/gen/object.d.ts +16 -0
  24. package/dist/document-models/renown-profile/gen/object.js +30 -0
  25. package/dist/document-models/renown-profile/gen/ph-factories.d.ts +26 -0
  26. package/dist/document-models/renown-profile/gen/ph-factories.js +53 -0
  27. package/dist/document-models/renown-profile/gen/profile/actions.d.ts +15 -0
  28. package/dist/document-models/renown-profile/gen/profile/actions.js +1 -0
  29. package/dist/document-models/renown-profile/gen/profile/creators.d.ts +5 -0
  30. package/dist/document-models/renown-profile/gen/profile/creators.js +5 -0
  31. package/dist/document-models/renown-profile/gen/profile/error.d.ts +1 -0
  32. package/dist/document-models/renown-profile/gen/profile/error.js +1 -0
  33. package/dist/document-models/renown-profile/gen/profile/object.d.ts +8 -0
  34. package/dist/document-models/renown-profile/gen/profile/object.js +13 -0
  35. package/dist/document-models/renown-profile/gen/profile/operations.d.ts +8 -0
  36. package/dist/document-models/renown-profile/gen/profile/operations.js +1 -0
  37. package/dist/document-models/renown-profile/gen/reducer.d.ts +4 -0
  38. package/dist/document-models/renown-profile/gen/reducer.js +37 -0
  39. package/dist/document-models/renown-profile/gen/schema/index.d.ts +2 -0
  40. package/dist/document-models/renown-profile/gen/schema/index.js +2 -0
  41. package/dist/document-models/renown-profile/gen/schema/types.d.ts +174 -0
  42. package/dist/document-models/renown-profile/gen/schema/types.js +1 -0
  43. package/dist/document-models/renown-profile/gen/schema/zod.d.ts +16 -0
  44. package/dist/document-models/renown-profile/gen/schema/zod.js +62 -0
  45. package/dist/document-models/renown-profile/gen/types.d.ts +9 -0
  46. package/dist/document-models/renown-profile/gen/types.js +1 -0
  47. package/dist/document-models/renown-profile/gen/utils.d.ts +21 -0
  48. package/dist/document-models/renown-profile/gen/utils.js +45 -0
  49. package/dist/document-models/renown-profile/index.d.ts +28 -0
  50. package/dist/document-models/renown-profile/index.js +21 -0
  51. package/dist/document-models/renown-profile/src/reducers/authorization.d.ts +2 -0
  52. package/dist/document-models/renown-profile/src/reducers/authorization.js +8 -0
  53. package/dist/document-models/renown-profile/src/reducers/profile.d.ts +2 -0
  54. package/dist/document-models/renown-profile/src/reducers/profile.js +11 -0
  55. package/dist/document-models/renown-profile/src/tests/authorization.test.d.ts +5 -0
  56. package/dist/document-models/renown-profile/src/tests/authorization.test.js +24 -0
  57. package/dist/document-models/renown-profile/src/tests/document-model.test.d.ts +5 -0
  58. package/dist/document-models/renown-profile/src/tests/document-model.test.js +18 -0
  59. package/dist/document-models/renown-profile/src/tests/profile.test.d.ts +5 -0
  60. package/dist/document-models/renown-profile/src/tests/profile.test.js +24 -0
  61. package/dist/document-models/renown-profile/src/utils.d.ts +1 -0
  62. package/dist/document-models/renown-profile/src/utils.js +1 -0
  63. package/dist/editors/builder-account-editor/editor.js +2 -3
  64. package/dist/editors/hooks/useRenownProfileDocument.d.ts +3 -0
  65. package/dist/editors/hooks/useRenownProfileDocument.js +8 -0
  66. package/dist/editors/index.d.ts +1 -0
  67. package/dist/editors/index.js +1 -0
  68. package/dist/editors/renown-profile-editor/editor.d.ts +3 -0
  69. package/dist/editors/renown-profile-editor/editor.js +33 -0
  70. package/dist/editors/renown-profile-editor/index.d.ts +2 -0
  71. package/dist/editors/renown-profile-editor/index.js +11 -0
  72. package/dist/index.d.ts +1 -1
  73. package/dist/powerhouse.manifest.json +18 -1
  74. package/dist/processors/factory.js +2 -5
  75. package/dist/processors/index.d.ts +2 -0
  76. package/dist/processors/index.js +2 -0
  77. package/dist/processors/renown-profile/factory.d.ts +3 -0
  78. package/dist/processors/renown-profile/factory.js +22 -0
  79. package/dist/processors/renown-profile/index.d.ts +9 -0
  80. package/dist/processors/renown-profile/index.js +81 -0
  81. package/dist/processors/renown-profile/migrations.d.ts +3 -0
  82. package/dist/processors/renown-profile/migrations.js +39 -0
  83. package/dist/processors/renown-profile/schema.d.ts +14 -0
  84. package/dist/processors/renown-profile/schema.js +1 -0
  85. package/dist/processors/renown-read-model/migrations.d.ts +3 -0
  86. package/dist/processors/renown-read-model/migrations.js +55 -0
  87. package/dist/processors/renown-read-model/schema.d.ts +21 -0
  88. package/dist/processors/renown-read-model/schema.js +1 -0
  89. package/dist/style.css +388 -17
  90. package/dist/subgraphs/index.d.ts +2 -1
  91. package/dist/subgraphs/index.js +3 -1
  92. package/dist/subgraphs/renown-profile/index.d.ts +10 -0
  93. package/dist/subgraphs/renown-profile/index.js +11 -0
  94. package/dist/subgraphs/renown-profile/resolvers.d.ts +2 -0
  95. package/dist/subgraphs/renown-profile/resolvers.js +151 -0
  96. package/dist/subgraphs/renown-profile/schema.d.ts +2 -0
  97. package/dist/subgraphs/renown-profile/schema.js +104 -0
  98. package/dist/subgraphs/renown-read-model/index.d.ts +10 -0
  99. package/dist/subgraphs/renown-read-model/index.js +11 -0
  100. package/dist/subgraphs/renown-read-model/resolvers.d.ts +2 -0
  101. package/dist/subgraphs/renown-read-model/resolvers.js +25 -0
  102. package/dist/subgraphs/renown-read-model/schema.d.ts +2 -0
  103. package/dist/subgraphs/renown-read-model/schema.js +16 -0
  104. package/dist/subgraphs/vetra-builder-read-model/index.d.ts +10 -0
  105. package/dist/subgraphs/vetra-builder-read-model/index.js +11 -0
  106. package/dist/subgraphs/vetra-builder-read-model/resolvers.d.ts +2 -0
  107. package/dist/subgraphs/vetra-builder-read-model/resolvers.js +174 -0
  108. package/dist/subgraphs/vetra-builder-read-model/schema.d.ts +2 -0
  109. package/dist/subgraphs/vetra-builder-read-model/schema.js +79 -0
  110. package/package.json +3 -2
@@ -14,15 +14,32 @@
14
14
  {
15
15
  "id": "powerhouse/vetra/package",
16
16
  "name": "VetraPackage"
17
+ },
18
+ {
19
+ "id": "powerhouse/renown-profile",
20
+ "name": "RenownProfile"
21
+ }
22
+ ],
23
+ "editors": [
24
+ {
25
+ "id": "renown-profile-editor",
26
+ "name": "RenownProfileEditor",
27
+ "documentTypes": [
28
+ "powerhouse/renown-profile"
29
+ ]
17
30
  }
18
31
  ],
19
- "editors": [],
20
32
  "apps": [],
21
33
  "subgraphs": [
22
34
  {
23
35
  "id": "vetra",
24
36
  "name": "vetra",
25
37
  "documentTypes": []
38
+ },
39
+ {
40
+ "id": "renown-read-model",
41
+ "name": "RenownReadModel",
42
+ "documentTypes": []
26
43
  }
27
44
  ],
28
45
  "importScripts": []
@@ -1,14 +1,11 @@
1
- /**
2
- * This file aggregates all processor factories
3
- * Auto-generated by codegen - DO NOT EDIT MANUALLY
4
- */
5
- // Import other processor factories here as they are generated
1
+ import { renownProfileProcessorFactory } from "./renown-profile/factory.js";
6
2
  import { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
7
3
  export const processorFactory = (module) => {
8
4
  // Initialize all processor factories once with the module
9
5
  const factories = [];
10
6
  // Add other processors here as they are generated
11
7
  factories.push(vetraReadModelProcessorFactory(module));
8
+ factories.push(renownProfileProcessorFactory(module));
12
9
  // Return the inner function that will be called for each drive
13
10
  return async (driveHeader) => {
14
11
  const processors = [];
@@ -1,3 +1,5 @@
1
1
  export { VetraReadModelProcessor } from "./vetra-read-model/index.js";
2
2
  export { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
3
3
  export { processorFactory } from "./factory.js";
4
+ export * as RenownProfileProcessor from "./renown-profile/index.js";
5
+ export { renownProfileProcessorFactory } from "./renown-profile/factory.js";
@@ -1,3 +1,5 @@
1
1
  export { VetraReadModelProcessor } from "./vetra-read-model/index.js";
2
2
  export { vetraReadModelProcessorFactory } from "./vetra-read-model/factory.js";
3
3
  export { processorFactory } from "./factory.js";
4
+ export * as RenownProfileProcessor from "./renown-profile/index.js";
5
+ export { renownProfileProcessorFactory } from "./renown-profile/factory.js";
@@ -0,0 +1,3 @@
1
+ import { type ProcessorRecord, type IProcessorHostModule } from "document-drive/processors/types";
2
+ import { type PHDocumentHeader } from "document-model";
3
+ export declare const renownProfileProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
@@ -0,0 +1,22 @@
1
+ import { RenownProfileProcessor } from "./index.js";
2
+ export const renownProfileProcessorFactory = (module) => async (driveHeader) => {
3
+ // Create a namespace for the processor and the provided drive id
4
+ const namespace = RenownProfileProcessor.getNamespace(driveHeader.id);
5
+ // Create a namespaced db for the processor
6
+ const store = await module.relationalDb.createNamespace(namespace);
7
+ // Create a filter for the processor
8
+ const filter = {
9
+ branch: ["main"],
10
+ documentId: ["*"],
11
+ documentType: ["powerhouse/renown-profile"],
12
+ scope: ["global"],
13
+ };
14
+ // Create the processor
15
+ const processor = new RenownProfileProcessor(namespace, filter, store);
16
+ return [
17
+ {
18
+ processor,
19
+ filter,
20
+ },
21
+ ];
22
+ };
@@ -0,0 +1,9 @@
1
+ import { RelationalDbProcessor } from "document-drive/processors/relational";
2
+ import { type InternalTransmitterUpdate } from "document-drive/server/listener/transmitter/internal";
3
+ import { type DB } from "./schema.js";
4
+ export declare class RenownProfileProcessor extends RelationalDbProcessor<DB> {
5
+ static getNamespace(driveId: string): string;
6
+ initAndUpgrade(): Promise<void>;
7
+ onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
8
+ onDisconnect(): Promise<void>;
9
+ }
@@ -0,0 +1,81 @@
1
+ import { RelationalDbProcessor } from "document-drive/processors/relational";
2
+ import { up } from "./migrations.js";
3
+ export class RenownProfileProcessor extends RelationalDbProcessor {
4
+ static getNamespace(driveId) {
5
+ // Default namespace: `${this.name}_${driveId.replaceAll("-", "_")}`
6
+ return super.getNamespace(driveId);
7
+ }
8
+ async initAndUpgrade() {
9
+ await up(this.relationalDb);
10
+ }
11
+ async onStrands(strands) {
12
+ if (strands.length === 0) {
13
+ return;
14
+ }
15
+ for (const strand of strands) {
16
+ if (strand.operations.length === 0) {
17
+ continue;
18
+ }
19
+ const documentId = strand.documentId;
20
+ // Ensure the profile exists in the database
21
+ const existingProfile = await this.relationalDb
22
+ .selectFrom("renown_profile")
23
+ .select(["document_id"])
24
+ .where("document_id", "=", documentId)
25
+ .executeTakeFirst();
26
+ if (!existingProfile) {
27
+ // Create a new profile entry
28
+ await this.relationalDb
29
+ .insertInto("renown_profile")
30
+ .values({
31
+ document_id: documentId,
32
+ username: null,
33
+ eth_address: null,
34
+ user_image: null,
35
+ created_at: new Date(),
36
+ updated_at: new Date(),
37
+ })
38
+ .execute();
39
+ }
40
+ // Process each operation
41
+ for (const operation of strand.operations) {
42
+ // Update the profile based on the operation type
43
+ const updateData = {
44
+ updated_at: new Date(),
45
+ };
46
+ switch (operation.action.type) {
47
+ case "SET_USERNAME": {
48
+ const input = operation.action.input;
49
+ if (input?.username) {
50
+ updateData.username = input.username;
51
+ }
52
+ break;
53
+ }
54
+ case "SET_ETH_ADDRESS": {
55
+ const input = operation.action.input;
56
+ if (input?.ethAddress) {
57
+ updateData.eth_address = input.ethAddress;
58
+ }
59
+ break;
60
+ }
61
+ case "SET_USER_IMAGE": {
62
+ const input = operation.action.input;
63
+ if (input?.userImage !== undefined) {
64
+ updateData.user_image = input.userImage || null;
65
+ }
66
+ break;
67
+ }
68
+ }
69
+ // Apply updates if there are any field changes
70
+ if (Object.keys(updateData).length > 1) {
71
+ await this.relationalDb
72
+ .updateTable("renown_profile")
73
+ .set(updateData)
74
+ .where("document_id", "=", documentId)
75
+ .execute();
76
+ }
77
+ }
78
+ }
79
+ }
80
+ async onDisconnect() { }
81
+ }
@@ -0,0 +1,3 @@
1
+ import { type IRelationalDb } from "document-drive/processors/types";
2
+ export declare function up(db: IRelationalDb<any>): Promise<void>;
3
+ export declare function down(db: IRelationalDb<any>): Promise<void>;
@@ -0,0 +1,39 @@
1
+ export async function up(db) {
2
+ await down(db);
3
+ // Create renown_profile table
4
+ await db.schema
5
+ .createTable("renown_profile")
6
+ .addColumn("document_id", "varchar(255)")
7
+ .addColumn("username", "varchar(255)")
8
+ .addColumn("eth_address", "varchar(42)")
9
+ .addColumn("user_image", "text")
10
+ .addColumn("created_at", "timestamp", (col) => col.defaultTo(db.fn("now")))
11
+ .addColumn("updated_at", "timestamp", (col) => col.defaultTo(db.fn("now")))
12
+ .addPrimaryKeyConstraint("renown_profile_pkey", ["document_id"])
13
+ .ifNotExists()
14
+ .execute();
15
+ // Create index on username for faster lookups
16
+ await db.schema
17
+ .createIndex("idx_renown_profile_username")
18
+ .on("renown_profile")
19
+ .column("username")
20
+ .ifNotExists()
21
+ .execute();
22
+ // Create index on eth_address for faster lookups
23
+ await db.schema
24
+ .createIndex("idx_renown_profile_eth_address")
25
+ .on("renown_profile")
26
+ .column("eth_address")
27
+ .ifNotExists()
28
+ .execute();
29
+ }
30
+ export async function down(db) {
31
+ // Drop indexes
32
+ await db.schema
33
+ .dropIndex("idx_renown_profile_eth_address")
34
+ .ifExists()
35
+ .execute();
36
+ await db.schema.dropIndex("idx_renown_profile_username").ifExists().execute();
37
+ // Drop tables
38
+ await db.schema.dropTable("renown_profile").ifExists().execute();
39
+ }
@@ -0,0 +1,14 @@
1
+ import type { ColumnType } from "kysely";
2
+ export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
3
+ export type Timestamp = ColumnType<Date, Date | string, Date | string>;
4
+ export interface RenownProfile {
5
+ created_at: Generated<Timestamp | null>;
6
+ document_id: string;
7
+ eth_address: string | null;
8
+ updated_at: Generated<Timestamp | null>;
9
+ user_image: string | null;
10
+ username: string | null;
11
+ }
12
+ export interface DB {
13
+ renown_profile: RenownProfile;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type IRelationalDb } from "document-drive/processors/types";
2
+ export declare function up(db: IRelationalDb<any>): Promise<void>;
3
+ export declare function down(db: IRelationalDb<any>): Promise<void>;
@@ -0,0 +1,55 @@
1
+ export async function up(db) {
2
+ if (process.env.NODE_ENV !== "production") {
3
+ await down(db);
4
+ }
5
+ // Create renown_profiles table
6
+ await db.schema
7
+ .createTable("renown_profiles")
8
+ .addColumn("id", "varchar(255)", (col) => col.primaryKey())
9
+ .addColumn("username", "varchar(255)")
10
+ .addColumn("eth_address", "varchar(42)") // Ethereum addresses are 42 chars
11
+ .addColumn("user_image", "text")
12
+ .addColumn("created_at", "timestamp", (col) => col.defaultTo("now()").notNull())
13
+ .addColumn("updated_at", "timestamp", (col) => col.defaultTo("now()").notNull())
14
+ .ifNotExists()
15
+ .execute();
16
+ // Create deleted_files table
17
+ await db.schema
18
+ .createTable("deleted_files")
19
+ .addColumn("id", "varchar(255)", (col) => col.primaryKey())
20
+ .addColumn("document_id", "varchar(255)", (col) => col.notNull())
21
+ .addColumn("drive_id", "varchar(255)", (col) => col.notNull())
22
+ .addColumn("deleted_at", "timestamp", (col) => col.defaultTo("now()").notNull())
23
+ .ifNotExists()
24
+ .execute();
25
+ // Create indexes for better performance
26
+ await db.schema
27
+ .createIndex("idx_renown_profiles_username")
28
+ .on("renown_profiles")
29
+ .column("username")
30
+ .ifNotExists()
31
+ .execute();
32
+ await db.schema
33
+ .createIndex("idx_renown_profiles_eth_address")
34
+ .on("renown_profiles")
35
+ .column("eth_address")
36
+ .ifNotExists()
37
+ .execute();
38
+ await db.schema
39
+ .createIndex("idx_deleted_files_document_id")
40
+ .on("deleted_files")
41
+ .column("document_id")
42
+ .ifNotExists()
43
+ .execute();
44
+ await db.schema
45
+ .createIndex("idx_deleted_files_drive_id")
46
+ .on("deleted_files")
47
+ .column("drive_id")
48
+ .ifNotExists()
49
+ .execute();
50
+ }
51
+ export async function down(db) {
52
+ // Drop tables in reverse order due to foreign key constraints
53
+ await db.schema.dropTable("deleted_files").ifExists().execute();
54
+ await db.schema.dropTable("renown_profiles").ifExists().execute();
55
+ }
@@ -0,0 +1,21 @@
1
+ import type { ColumnType } from "kysely";
2
+ export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
3
+ export type Timestamp = ColumnType<Date, Date | string, Date | string>;
4
+ export interface RenownProfiles {
5
+ id: string;
6
+ username: string | null;
7
+ eth_address: string | null;
8
+ user_image: string | null;
9
+ created_at: Generated<Timestamp>;
10
+ updated_at: Generated<Timestamp>;
11
+ }
12
+ export interface DeletedFiles {
13
+ id: string;
14
+ document_id: string;
15
+ drive_id: string;
16
+ deleted_at: Generated<Timestamp>;
17
+ }
18
+ export interface DB {
19
+ renown_profiles: RenownProfiles;
20
+ deleted_files: DeletedFiles;
21
+ }
@@ -0,0 +1 @@
1
+ export {};