@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.
Files changed (115) 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/processors/vetra-read-model/builder-account-handlers.js +7 -7
  90. package/dist/processors/vetra-read-model/database-helpers.d.ts +6 -1
  91. package/dist/processors/vetra-read-model/database-helpers.js +24 -1
  92. package/dist/processors/vetra-read-model/document-drive-handlers.d.ts +21 -0
  93. package/dist/processors/vetra-read-model/document-drive-handlers.js +77 -0
  94. package/dist/processors/vetra-read-model/factory.js +4 -1
  95. package/dist/processors/vetra-read-model/index.d.ts +2 -1
  96. package/dist/processors/vetra-read-model/index.js +23 -2
  97. package/dist/processors/vetra-read-model/migrations.js +22 -0
  98. package/dist/processors/vetra-read-model/schema.d.ts +7 -0
  99. package/dist/style.css +385 -17
  100. package/dist/subgraphs/index.d.ts +1 -0
  101. package/dist/subgraphs/index.js +2 -0
  102. package/dist/subgraphs/renown-profile/index.d.ts +10 -0
  103. package/dist/subgraphs/renown-profile/index.js +11 -0
  104. package/dist/subgraphs/renown-profile/resolvers.d.ts +2 -0
  105. package/dist/subgraphs/renown-profile/resolvers.js +151 -0
  106. package/dist/subgraphs/renown-profile/schema.d.ts +2 -0
  107. package/dist/subgraphs/renown-profile/schema.js +104 -0
  108. package/dist/subgraphs/renown-read-model/index.d.ts +10 -0
  109. package/dist/subgraphs/renown-read-model/index.js +11 -0
  110. package/dist/subgraphs/renown-read-model/resolvers.d.ts +2 -0
  111. package/dist/subgraphs/renown-read-model/resolvers.js +25 -0
  112. package/dist/subgraphs/renown-read-model/schema.d.ts +2 -0
  113. package/dist/subgraphs/renown-read-model/schema.js +16 -0
  114. package/dist/subgraphs/vetra-read-model/resolvers.js +31 -4
  115. package/package.json +3 -2
@@ -0,0 +1,174 @@
1
+ export type Maybe<T> = T | null;
2
+ export type InputMaybe<T> = T | null | undefined;
3
+ export type Exact<T extends {
4
+ [key: string]: unknown;
5
+ }> = {
6
+ [K in keyof T]: T[K];
7
+ };
8
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
9
+ [SubKey in K]?: Maybe<T[SubKey]>;
10
+ };
11
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
12
+ [SubKey in K]: Maybe<T[SubKey]>;
13
+ };
14
+ export type MakeEmpty<T extends {
15
+ [key: string]: unknown;
16
+ }, K extends keyof T> = {
17
+ [_ in K]?: never;
18
+ };
19
+ export type Incremental<T> = T | {
20
+ [P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never;
21
+ };
22
+ /** All built-in and custom scalars, mapped to their actual values */
23
+ export type Scalars = {
24
+ ID: {
25
+ input: string;
26
+ output: string;
27
+ };
28
+ String: {
29
+ input: string;
30
+ output: string;
31
+ };
32
+ Boolean: {
33
+ input: boolean;
34
+ output: boolean;
35
+ };
36
+ Int: {
37
+ input: number;
38
+ output: number;
39
+ };
40
+ Float: {
41
+ input: number;
42
+ output: number;
43
+ };
44
+ Amount: {
45
+ input: {
46
+ unit?: string;
47
+ value?: number;
48
+ };
49
+ output: {
50
+ unit?: string;
51
+ value?: number;
52
+ };
53
+ };
54
+ Amount_Crypto: {
55
+ input: {
56
+ unit: string;
57
+ value: string;
58
+ };
59
+ output: {
60
+ unit: string;
61
+ value: string;
62
+ };
63
+ };
64
+ Amount_Currency: {
65
+ input: {
66
+ unit: string;
67
+ value: string;
68
+ };
69
+ output: {
70
+ unit: string;
71
+ value: string;
72
+ };
73
+ };
74
+ Amount_Fiat: {
75
+ input: {
76
+ unit: string;
77
+ value: number;
78
+ };
79
+ output: {
80
+ unit: string;
81
+ value: number;
82
+ };
83
+ };
84
+ Amount_Money: {
85
+ input: number;
86
+ output: number;
87
+ };
88
+ Amount_Percentage: {
89
+ input: number;
90
+ output: number;
91
+ };
92
+ Amount_Tokens: {
93
+ input: number;
94
+ output: number;
95
+ };
96
+ Currency: {
97
+ input: string;
98
+ output: string;
99
+ };
100
+ Date: {
101
+ input: string;
102
+ output: string;
103
+ };
104
+ DateTime: {
105
+ input: string;
106
+ output: string;
107
+ };
108
+ EmailAddress: {
109
+ input: string;
110
+ output: string;
111
+ };
112
+ EthereumAddress: {
113
+ input: string;
114
+ output: string;
115
+ };
116
+ OID: {
117
+ input: string;
118
+ output: string;
119
+ };
120
+ OLabel: {
121
+ input: string;
122
+ output: string;
123
+ };
124
+ PHID: {
125
+ input: string;
126
+ output: string;
127
+ };
128
+ URL: {
129
+ input: string;
130
+ output: string;
131
+ };
132
+ Upload: {
133
+ input: File;
134
+ output: File;
135
+ };
136
+ };
137
+ export type AddAuthorizationInput = {
138
+ audience?: InputMaybe<Scalars["String"]["input"]>;
139
+ expiry?: InputMaybe<Scalars["Int"]["input"]>;
140
+ /** Add your inputs here */
141
+ id: Scalars["OID"]["input"];
142
+ issuer: Scalars["String"]["input"];
143
+ subject: Scalars["String"]["input"];
144
+ };
145
+ export type RenownAuthorization = {
146
+ audience: Maybe<Scalars["String"]["output"]>;
147
+ expiry: Maybe<Scalars["Int"]["output"]>;
148
+ id: Scalars["OID"]["output"];
149
+ issuer: Scalars["String"]["output"];
150
+ subject: Scalars["String"]["output"];
151
+ };
152
+ export type RenownProfileState = {
153
+ authorizations: Array<RenownAuthorization>;
154
+ ethAddress: Maybe<Scalars["EthereumAddress"]["output"]>;
155
+ userImage: Maybe<Scalars["String"]["output"]>;
156
+ /** Add your global state fields here */
157
+ username: Maybe<Scalars["String"]["output"]>;
158
+ };
159
+ export type RevokeAuthorizationInput = {
160
+ /** Add your inputs here */
161
+ authorizationId: Scalars["OID"]["input"];
162
+ };
163
+ export type SetEthAddressInput = {
164
+ /** Add your inputs here */
165
+ ethAddress: Scalars["EthereumAddress"]["input"];
166
+ };
167
+ export type SetUserImageInput = {
168
+ /** Add your inputs here */
169
+ userImage?: InputMaybe<Scalars["String"]["input"]>;
170
+ };
171
+ export type SetUsernameInput = {
172
+ /** Add your inputs here */
173
+ username: Scalars["String"]["input"];
174
+ };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import type { AddAuthorizationInput, RenownAuthorization, RenownProfileState, RevokeAuthorizationInput, SetEthAddressInput, SetUserImageInput, SetUsernameInput } from "./types.js";
3
+ type Properties<T> = Required<{
4
+ [K in keyof T]: z.ZodType<T[K], any, T[K]>;
5
+ }>;
6
+ type definedNonNullAny = {};
7
+ export declare const isDefinedNonNullAny: (v: any) => v is definedNonNullAny;
8
+ export declare const definedNonNullAnySchema: z.ZodEffects<z.ZodAny, definedNonNullAny, any>;
9
+ export declare function AddAuthorizationInputSchema(): z.ZodObject<Properties<AddAuthorizationInput>>;
10
+ export declare function RenownAuthorizationSchema(): z.ZodObject<Properties<RenownAuthorization>>;
11
+ export declare function RenownProfileStateSchema(): z.ZodObject<Properties<RenownProfileState>>;
12
+ export declare function RevokeAuthorizationInputSchema(): z.ZodObject<Properties<RevokeAuthorizationInput>>;
13
+ export declare function SetEthAddressInputSchema(): z.ZodObject<Properties<SetEthAddressInput>>;
14
+ export declare function SetUserImageInputSchema(): z.ZodObject<Properties<SetUserImageInput>>;
15
+ export declare function SetUsernameInputSchema(): z.ZodObject<Properties<SetUsernameInput>>;
16
+ export {};
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ export const isDefinedNonNullAny = (v) => v !== undefined && v !== null;
3
+ export const definedNonNullAnySchema = z
4
+ .any()
5
+ .refine((v) => isDefinedNonNullAny(v));
6
+ export function AddAuthorizationInputSchema() {
7
+ return z.object({
8
+ audience: z.string().nullish(),
9
+ expiry: z.number().nullish(),
10
+ id: z.string(),
11
+ issuer: z.string(),
12
+ subject: z.string(),
13
+ });
14
+ }
15
+ export function RenownAuthorizationSchema() {
16
+ return z.object({
17
+ __typename: z.literal("RenownAuthorization").optional(),
18
+ audience: z.string().nullable(),
19
+ expiry: z.number().nullable(),
20
+ id: z.string(),
21
+ issuer: z.string(),
22
+ subject: z.string(),
23
+ });
24
+ }
25
+ export function RenownProfileStateSchema() {
26
+ return z.object({
27
+ __typename: z.literal("RenownProfileState").optional(),
28
+ authorizations: z.array(RenownAuthorizationSchema()),
29
+ ethAddress: z
30
+ .string()
31
+ .regex(/^0x[a-fA-F0-9]{40}$/, {
32
+ message: "Invalid Ethereum address format",
33
+ })
34
+ .nullable(),
35
+ userImage: z.string().nullable(),
36
+ username: z.string().nullable(),
37
+ });
38
+ }
39
+ export function RevokeAuthorizationInputSchema() {
40
+ return z.object({
41
+ authorizationId: z.string(),
42
+ });
43
+ }
44
+ export function SetEthAddressInputSchema() {
45
+ return z.object({
46
+ ethAddress: z
47
+ .string()
48
+ .regex(/^0x[a-fA-F0-9]{40}$/, {
49
+ message: "Invalid Ethereum address format",
50
+ }),
51
+ });
52
+ }
53
+ export function SetUserImageInputSchema() {
54
+ return z.object({
55
+ userImage: z.string().nullish(),
56
+ });
57
+ }
58
+ export function SetUsernameInputSchema() {
59
+ return z.object({
60
+ username: z.string(),
61
+ });
62
+ }
@@ -0,0 +1,9 @@
1
+ import type { PHDocument } from "document-model";
2
+ import type { RenownProfileAction } from "./actions.js";
3
+ import type { RenownProfilePHState } from "./ph-factories.js";
4
+ import type { RenownProfileState } from "./schema/types.js";
5
+ export { z } from "./schema/index.js";
6
+ export type * from "./schema/types.js";
7
+ type RenownProfileLocalState = Record<PropertyKey, never>;
8
+ export type RenownProfileDocument = PHDocument<RenownProfilePHState>;
9
+ export type { RenownProfileState, RenownProfileLocalState, RenownProfileAction, };
@@ -0,0 +1 @@
1
+ export { z } from "./schema/index.js";
@@ -0,0 +1,21 @@
1
+ import { type CreateDocument, type CreateState, type LoadFromFile, type LoadFromInput } from "document-model";
2
+ import { type RenownProfileState, type RenownProfileLocalState } from "./types.js";
3
+ import { RenownProfilePHState } from "./ph-factories.js";
4
+ export declare const initialGlobalState: RenownProfileState;
5
+ export declare const initialLocalState: RenownProfileLocalState;
6
+ export declare const createState: CreateState<RenownProfilePHState>;
7
+ export declare const createDocument: CreateDocument<RenownProfilePHState>;
8
+ export declare const saveToFile: (document: any, path: string, name?: string) => Promise<string>;
9
+ export declare const saveToFileHandle: (document: any, input: any) => Promise<void>;
10
+ export declare const loadFromFile: LoadFromFile<RenownProfilePHState>;
11
+ export declare const loadFromInput: LoadFromInput<RenownProfilePHState>;
12
+ declare const utils: {
13
+ fileExtension: string;
14
+ createState: CreateState<RenownProfilePHState>;
15
+ createDocument: CreateDocument<RenownProfilePHState>;
16
+ saveToFile: (document: any, path: string, name?: string) => Promise<string>;
17
+ saveToFileHandle: (document: any, input: any) => Promise<void>;
18
+ loadFromFile: LoadFromFile<RenownProfilePHState>;
19
+ loadFromInput: LoadFromInput<RenownProfilePHState>;
20
+ };
21
+ export default utils;
@@ -0,0 +1,45 @@
1
+ import { baseCreateDocument, baseSaveToFile, baseSaveToFileHandle, baseLoadFromFile, baseLoadFromInput, defaultBaseState, generateId, } from "document-model";
2
+ import { reducer } from "./reducer.js";
3
+ export const initialGlobalState = {
4
+ username: null,
5
+ ethAddress: null,
6
+ userImage: null,
7
+ authorizations: [],
8
+ };
9
+ export const initialLocalState = {};
10
+ export const createState = (state) => {
11
+ return {
12
+ ...defaultBaseState(),
13
+ global: { ...initialGlobalState, ...(state?.global ?? {}) },
14
+ local: { ...initialLocalState, ...(state?.local ?? {}) },
15
+ };
16
+ };
17
+ export const createDocument = (state) => {
18
+ const document = baseCreateDocument(createState, state);
19
+ document.header.documentType = "powerhouse/renown-profile";
20
+ // for backwards compatibility, but this is NOT a valid signed document id
21
+ document.header.id = generateId();
22
+ return document;
23
+ };
24
+ export const saveToFile = (document, path, name) => {
25
+ return baseSaveToFile(document, path, "renown-profile", name);
26
+ };
27
+ export const saveToFileHandle = (document, input) => {
28
+ return baseSaveToFileHandle(document, input);
29
+ };
30
+ export const loadFromFile = (path) => {
31
+ return baseLoadFromFile(path, reducer);
32
+ };
33
+ export const loadFromInput = (input) => {
34
+ return baseLoadFromInput(input, reducer);
35
+ };
36
+ const utils = {
37
+ fileExtension: "renown-profile",
38
+ createState,
39
+ createDocument,
40
+ saveToFile,
41
+ saveToFileHandle,
42
+ loadFromFile,
43
+ loadFromInput,
44
+ };
45
+ export default utils;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This is a scaffold file meant for customization.
3
+ * Delete the file and run the code generator again to have it reset
4
+ */
5
+ import { type DocumentModelModule } from "document-model";
6
+ import { reducer } from "./gen/reducer.js";
7
+ import { documentModel } from "./gen/document-model.js";
8
+ import type { RenownProfilePHState } from "./gen/ph-factories.js";
9
+ declare const utils: {
10
+ fileExtension: string;
11
+ createState: import("document-model").CreateState<RenownProfilePHState>;
12
+ createDocument: import("document-model").CreateDocument<RenownProfilePHState>;
13
+ saveToFile: (document: any, path: string, name?: string) => Promise<string>;
14
+ saveToFileHandle: (document: any, input: any) => Promise<void>;
15
+ loadFromFile: import("document-model").LoadFromFile<RenownProfilePHState>;
16
+ loadFromInput: import("document-model").LoadFromInput<RenownProfilePHState>;
17
+ };
18
+ declare const actions: {
19
+ setUsername: (input: import("./index.js").SetUsernameInput) => import("./gen/actions.js").SetUsernameAction;
20
+ setEthAddress: (input: import("./index.js").SetEthAddressInput) => import("./gen/actions.js").SetEthAddressAction;
21
+ setUserImage: (input: import("./index.js").SetUserImageInput) => import("./gen/actions.js").SetUserImageAction;
22
+ addAuthorization: (input: import("./index.js").AddAuthorizationInput) => import("./gen/actions.js").AddAuthorizationAction;
23
+ revokeAuthorization: (input: import("./index.js").RevokeAuthorizationInput) => import("./gen/actions.js").RevokeAuthorizationAction;
24
+ };
25
+ export declare const module: DocumentModelModule<RenownProfilePHState>;
26
+ export { reducer, actions, utils, documentModel };
27
+ export * from "./gen/types.js";
28
+ export * from "./src/utils.js";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This is a scaffold file meant for customization.
3
+ * Delete the file and run the code generator again to have it reset
4
+ */
5
+ import { actions as BaseActions, } from "document-model";
6
+ import { actions as RenownProfileActions } from "./gen/index.js";
7
+ import { reducer } from "./gen/reducer.js";
8
+ import { documentModel } from "./gen/document-model.js";
9
+ import genUtils from "./gen/utils.js";
10
+ import * as customUtils from "./src/utils.js";
11
+ const utils = { ...genUtils, ...customUtils };
12
+ const actions = { ...BaseActions, ...RenownProfileActions };
13
+ export const module = {
14
+ reducer,
15
+ actions,
16
+ utils,
17
+ documentModel,
18
+ };
19
+ export { reducer, actions, utils, documentModel };
20
+ export * from "./gen/types.js";
21
+ export * from "./src/utils.js";
@@ -0,0 +1,2 @@
1
+ import type { RenownProfileAuthorizationOperations } from "../../gen/authorization/operations.js";
2
+ export declare const reducer: RenownProfileAuthorizationOperations;
@@ -0,0 +1,8 @@
1
+ export const reducer = {
2
+ addAuthorizationOperation(state, action, dispatch) {
3
+ state.authorizations.push(action.input);
4
+ },
5
+ revokeAuthorizationOperation(state, action, dispatch) {
6
+ state.authorizations = state.authorizations.filter((authorization) => authorization.id !== action.input.authorizationId);
7
+ },
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { RenownProfileProfileOperations } from "../../gen/profile/operations.js";
2
+ export declare const reducer: RenownProfileProfileOperations;
@@ -0,0 +1,11 @@
1
+ export const reducer = {
2
+ setUsernameOperation(state, action, dispatch) {
3
+ state.username = action.input.username;
4
+ },
5
+ setEthAddressOperation(state, action, dispatch) {
6
+ state.ethAddress = action.input.ethAddress;
7
+ },
8
+ setUserImageOperation(state, action, dispatch) {
9
+ state.userImage = action.input.userImage ?? null;
10
+ },
11
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ import { describe, it, expect, beforeEach } from "vitest";
6
+ import { generateMock } from "@powerhousedao/codegen";
7
+ import utils from "../../gen/utils.js";
8
+ import { z } from "../../gen/schema/index.js";
9
+ import { reducer } from "../../gen/reducer.js";
10
+ import * as creators from "../../gen/authorization/creators.js";
11
+ describe("Authorization Operations", () => {
12
+ let document;
13
+ beforeEach(() => {
14
+ document = utils.createDocument();
15
+ });
16
+ it("should handle addAuthorization operation", () => {
17
+ const input = generateMock(z.AddAuthorizationInputSchema());
18
+ const updatedDocument = reducer(document, creators.addAuthorization(input));
19
+ expect(updatedDocument.operations.global).toHaveLength(1);
20
+ expect(updatedDocument.operations.global[0].action.type).toBe("ADD_AUTHORIZATION");
21
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
22
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
23
+ });
24
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ import { describe, it, expect } from "vitest";
6
+ import utils, { initialGlobalState, initialLocalState, } from "../../gen/utils.js";
7
+ describe("Renown Profile Document Model", () => {
8
+ it("should create a new Renown Profile document", () => {
9
+ const document = utils.createDocument();
10
+ expect(document).toBeDefined();
11
+ expect(document.header.documentType).toBe("powerhouse/renown-profile");
12
+ });
13
+ it("should create a new Renown Profile document with a valid initial state", () => {
14
+ const document = utils.createDocument();
15
+ expect(document.state.global).toStrictEqual(initialGlobalState);
16
+ expect(document.state.local).toStrictEqual(initialLocalState);
17
+ });
18
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
5
+ import { describe, it, expect, beforeEach } from "vitest";
6
+ import { generateMock } from "@powerhousedao/codegen";
7
+ import utils from "../../gen/utils.js";
8
+ import { z } from "../../gen/schema/index.js";
9
+ import { reducer } from "../../gen/reducer.js";
10
+ import * as creators from "../../gen/profile/creators.js";
11
+ describe("Profile Operations", () => {
12
+ let document;
13
+ beforeEach(() => {
14
+ document = utils.createDocument();
15
+ });
16
+ it("should handle setUsername operation", () => {
17
+ const input = generateMock(z.SetUsernameInputSchema());
18
+ const updatedDocument = reducer(document, creators.setUsername(input));
19
+ expect(updatedDocument.operations.global).toHaveLength(1);
20
+ expect(updatedDocument.operations.global[0].action.type).toBe("SET_USERNAME");
21
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
22
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
23
+ });
24
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useDocumentById } from "@powerhousedao/reactor-browser";
2
+ import { useSelectedDocument } from "@powerhousedao/reactor-browser";
3
3
  import { useCallback, useState } from "react";
4
4
  import { actions, } from "../../document-models/builder-account/index.js";
5
5
  import { Form, StringField, UrlField, Button } from "@powerhousedao/document-engineering";
6
6
  export default function Editor(props) {
7
- const { document: initialDocument } = props;
8
- const [document, dispatch] = useDocumentById(initialDocument.header.id);
7
+ const [document, dispatch] = useSelectedDocument();
9
8
  const typedDocument = document;
10
9
  // Local form state
11
10
  const [isEditingProfile, setIsEditingProfile] = useState(false);
@@ -0,0 +1,3 @@
1
+ import type { RenownProfileAction, RenownProfileDocument } from "../../document-models/renown-profile/index.js";
2
+ export declare function useRenownProfileDocument(documentId: string | null | undefined): never[] | [RenownProfileDocument, import("@powerhousedao/reactor-browser").DocumentDispatch<RenownProfileAction>];
3
+ export declare function useSelectedRenownProfileDocument(): never[] | [RenownProfileDocument, import("@powerhousedao/reactor-browser").DocumentDispatch<RenownProfileAction>];
@@ -0,0 +1,8 @@
1
+ import { useDocumentOfType, useSelectedDocumentId, } from "@powerhousedao/reactor-browser";
2
+ export function useRenownProfileDocument(documentId) {
3
+ return useDocumentOfType(documentId, "powerhouse/renown-profile");
4
+ }
5
+ export function useSelectedRenownProfileDocument() {
6
+ const selectedDocumentId = useSelectedDocumentId();
7
+ return useRenownProfileDocument(selectedDocumentId);
8
+ }
@@ -1,2 +1,3 @@
1
1
  export {};
2
2
  export { module as BuilderAccountEditor } from "./builder-account-editor/index.js";
3
+ export { module as RenownProfileEditor } from "./renown-profile-editor/index.js";
@@ -1 +1,2 @@
1
1
  export { module as BuilderAccountEditor } from "./builder-account-editor/index.js";
2
+ export { module as RenownProfileEditor } from "./renown-profile-editor/index.js";
@@ -0,0 +1,3 @@
1
+ import type { EditorProps } from "document-model";
2
+ export type IProps = EditorProps;
3
+ export default function Editor(props: IProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSelectedDocument } from "@powerhousedao/reactor-browser";
3
+ import { useCallback, useState } from "react";
4
+ import { actions, } from "../../document-models/renown-profile/index.js";
5
+ import { Form, StringField, UrlField, Button } from "@powerhousedao/document-engineering";
6
+ export default function Editor(props) {
7
+ const [document, dispatch] = useSelectedDocument();
8
+ if (!document) {
9
+ return _jsx("div", { children: "Loading..." });
10
+ }
11
+ const typedDocument = document;
12
+ // Local form state
13
+ const [isEditingProfile, setIsEditingProfile] = useState(false);
14
+ const { state: { global } } = typedDocument;
15
+ const { username, ethAddress, userImage } = global;
16
+ // Profile handlers
17
+ const handleSetUsername = useCallback((newUsername) => {
18
+ if (newUsername.trim() && newUsername !== username) {
19
+ dispatch(actions.setUsername({ username: newUsername.trim() }));
20
+ }
21
+ }, [username, dispatch]);
22
+ const handleSetEthAddress = useCallback((address) => {
23
+ if (address.trim() && address !== ethAddress) {
24
+ dispatch(actions.setEthAddress({ ethAddress: address.trim() }));
25
+ }
26
+ }, [ethAddress, dispatch]);
27
+ const handleSetUserImage = useCallback((imageUrl) => {
28
+ if (imageUrl !== userImage) {
29
+ dispatch(actions.setUserImage({ userImage: imageUrl.trim() || null }));
30
+ }
31
+ }, [userImage, dispatch]);
32
+ return (_jsxs("div", { className: "html-defaults-container min-h-screen bg-gray-50", children: [_jsx("div", { className: "bg-white shadow-sm border-b", children: _jsx("div", { className: "max-w-5xl mx-auto px-4 sm:px-6 lg:px-8", children: _jsx("div", { className: "py-6", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center space-x-4", children: [_jsx("div", { className: "flex-shrink-0", children: userImage ? (_jsx("img", { className: "w-16 h-16 rounded-full object-cover border-2 border-blue-500", src: userImage, alt: username || "User" })) : (_jsx("div", { className: "w-16 h-16 bg-gradient-to-br from-blue-500 to-purple-600 rounded-full flex items-center justify-center", children: _jsx("svg", { className: "w-8 h-8 text-white", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) }) })) }), _jsxs("div", { children: [_jsx("h1", { className: "text-3xl font-bold text-gray-900", children: username || "Renown Profile" }), _jsx("p", { className: "text-sm text-gray-500 font-mono", children: ethAddress || "No Ethereum address set" })] })] }), _jsx("div", { className: "flex items-center space-x-3", children: _jsx(Button, { color: "light", onClick: () => setIsEditingProfile(!isEditingProfile), children: isEditingProfile ? "Cancel" : "Edit Profile" }) })] }) }) }) }), _jsx("div", { className: "max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8", children: _jsxs("div", { className: "grid grid-cols-1 gap-8", children: [_jsxs("div", { className: "bg-white rounded-lg shadow-sm border", children: [_jsxs("div", { className: "px-6 py-4 border-b border-gray-200", children: [_jsx("h2", { className: "text-lg font-semibold text-gray-900", children: "Profile Information" }), _jsx("p", { className: "text-sm text-gray-500", children: "Manage your renown profile details" })] }), _jsx("div", { className: "p-6", children: isEditingProfile ? (_jsx(Form, { onSubmit: (e) => e.preventDefault(), children: _jsxs("div", { className: "space-y-6", children: [_jsx(StringField, { name: "username", label: "Username", value: username || "", onChange: (e) => handleSetUsername(e.target.value), placeholder: "Enter your username", description: "Your display name on the platform" }), _jsx(StringField, { name: "ethAddress", label: "Ethereum Address", value: ethAddress || "", onChange: (e) => handleSetEthAddress(e.target.value), placeholder: "0x...", description: "Your Ethereum wallet address" }), _jsx(UrlField, { name: "userImage", label: "Profile Image URL", value: userImage || "", onChange: (e) => handleSetUserImage(e.target.value), placeholder: "https://example.com/avatar.png", description: "URL to your profile image" }), _jsxs("div", { className: "flex justify-end space-x-3 pt-4 border-t", children: [_jsx(Button, { color: "light", onClick: () => setIsEditingProfile(false), children: "Cancel" }), _jsx(Button, { onClick: () => setIsEditingProfile(false), children: "Save Changes" })] })] }) })) : (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Username" }), _jsx("div", { className: "flex items-center", children: _jsx("p", { className: "text-base text-gray-900", children: username || _jsx("span", { className: "text-gray-400 italic", children: "Not set" }) }) })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Ethereum Address" }), _jsx("div", { className: "flex items-center", children: _jsx("p", { className: "text-sm font-mono text-gray-900 break-all", children: ethAddress || _jsx("span", { className: "text-gray-400 italic", children: "Not set" }) }) })] })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Profile Image" }), userImage ? (_jsxs("div", { className: "flex items-center space-x-4", children: [_jsx("img", { src: userImage, alt: "Profile", className: "w-20 h-20 rounded-lg object-cover border border-gray-200" }), _jsx("div", { className: "flex-1", children: _jsx("a", { href: userImage, target: "_blank", rel: "noopener noreferrer", className: "text-sm text-blue-600 hover:text-blue-800 hover:underline break-all", children: userImage }) })] })) : (_jsx("p", { className: "text-gray-400 italic", children: "No image set" }))] }), _jsx("div", { className: "pt-4 border-t", children: _jsx(Button, { onClick: () => setIsEditingProfile(true), children: "Edit Profile" }) })] })) })] }), _jsxs("div", { className: "bg-gradient-to-br from-blue-50 to-purple-50 rounded-lg shadow-sm border border-blue-100", children: [_jsx("div", { className: "px-6 py-4 border-b border-blue-100", children: _jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "Profile Summary" }) }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "flex items-center space-x-6", children: [_jsx("div", { className: "flex-shrink-0", children: userImage ? (_jsx("img", { src: userImage, alt: username || "User", className: "w-24 h-24 rounded-full object-cover border-4 border-white shadow-lg" })) : (_jsx("div", { className: "w-24 h-24 bg-gradient-to-br from-blue-400 to-purple-500 rounded-full flex items-center justify-center shadow-lg", children: _jsx("span", { className: "text-3xl text-white font-bold", children: username ? username.charAt(0).toUpperCase() : "?" }) })) }), _jsxs("div", { className: "flex-1", children: [_jsx("h3", { className: "text-2xl font-bold text-gray-900 mb-2", children: username || "Anonymous User" }), ethAddress && (_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx("svg", { className: "w-5 h-5 text-gray-500", fill: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { d: "M11.944 17.97L4.58 13.62 11.943 24l7.37-10.38-7.372 4.35h.003zM12.056 0L4.69 12.223l7.365 4.354 7.365-4.35L12.056 0z" }) }), _jsx("span", { className: "text-sm font-mono text-gray-600", children: ethAddress })] })), !username && !ethAddress && (_jsx("p", { className: "text-gray-500 italic", children: "No profile information available. Click \"Edit Profile\" to get started." }))] })] }) })] })] }) })] }));
33
+ }
@@ -0,0 +1,2 @@
1
+ import type { EditorModule } from "document-model";
2
+ export declare const module: EditorModule;
@@ -0,0 +1,11 @@
1
+ import Editor from "./editor.js";
2
+ export const module = {
3
+ Component: Editor,
4
+ documentTypes: ["powerhouse/renown-profile"],
5
+ config: {
6
+ id: "renown-profile-editor",
7
+ disableExternalControls: true,
8
+ documentToolbarEnabled: true,
9
+ showSwitchboardLink: true,
10
+ },
11
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { Manifest } from "document-model";
2
2
  export declare const manifest: Manifest;
3
- export declare const documentModels: import("document-model").DocumentModelModule<import("./document-models/builder-account/gen").BuilderAccountPHState>[];
3
+ export declare const documentModels: (import("document-model").DocumentModelModule<import("./document-models/builder-account/gen").BuilderAccountPHState> | import("document-model").DocumentModelModule<import("./document-models/renown-profile/gen").RenownProfilePHState>)[];
4
4
  export declare const editors: import("document-model").EditorModule[];