@powerhousedao/renown-package 0.0.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/LICENSE +661 -0
- package/README.md +179 -0
- package/dist/document-models/index.d.ts +2 -0
- package/dist/document-models/index.js +1 -0
- package/dist/document-models/renown-user/gen/actions.d.ts +3 -0
- package/dist/document-models/renown-user/gen/actions.js +1 -0
- package/dist/document-models/renown-user/gen/creators.d.ts +1 -0
- package/dist/document-models/renown-user/gen/creators.js +1 -0
- package/dist/document-models/renown-user/gen/document-model.d.ts +2 -0
- package/dist/document-models/renown-user/gen/document-model.js +70 -0
- package/dist/document-models/renown-user/gen/index.d.ts +7 -0
- package/dist/document-models/renown-user/gen/index.js +6 -0
- package/dist/document-models/renown-user/gen/object.d.ts +14 -0
- package/dist/document-models/renown-user/gen/object.js +25 -0
- package/dist/document-models/renown-user/gen/ph-factories.d.ts +26 -0
- package/dist/document-models/renown-user/gen/ph-factories.js +52 -0
- package/dist/document-models/renown-user/gen/profile/actions.d.ts +15 -0
- package/dist/document-models/renown-user/gen/profile/actions.js +1 -0
- package/dist/document-models/renown-user/gen/profile/creators.d.ts +5 -0
- package/dist/document-models/renown-user/gen/profile/creators.js +5 -0
- package/dist/document-models/renown-user/gen/profile/error.d.ts +1 -0
- package/dist/document-models/renown-user/gen/profile/error.js +1 -0
- package/dist/document-models/renown-user/gen/profile/object.d.ts +8 -0
- package/dist/document-models/renown-user/gen/profile/object.js +13 -0
- package/dist/document-models/renown-user/gen/profile/operations.d.ts +8 -0
- package/dist/document-models/renown-user/gen/profile/operations.js +1 -0
- package/dist/document-models/renown-user/gen/reducer.d.ts +4 -0
- package/dist/document-models/renown-user/gen/reducer.js +28 -0
- package/dist/document-models/renown-user/gen/schema/index.d.ts +2 -0
- package/dist/document-models/renown-user/gen/schema/index.js +2 -0
- package/dist/document-models/renown-user/gen/schema/types.d.ts +154 -0
- package/dist/document-models/renown-user/gen/schema/types.js +1 -0
- package/dist/document-models/renown-user/gen/schema/zod.d.ts +13 -0
- package/dist/document-models/renown-user/gen/schema/zod.js +37 -0
- package/dist/document-models/renown-user/gen/types.d.ts +9 -0
- package/dist/document-models/renown-user/gen/types.js +1 -0
- package/dist/document-models/renown-user/gen/utils.d.ts +21 -0
- package/dist/document-models/renown-user/gen/utils.js +44 -0
- package/dist/document-models/renown-user/index.d.ts +26 -0
- package/dist/document-models/renown-user/index.js +21 -0
- package/dist/document-models/renown-user/src/reducers/profile.d.ts +2 -0
- package/dist/document-models/renown-user/src/reducers/profile.js +11 -0
- package/dist/document-models/renown-user/src/tests/document-model.test.d.ts +5 -0
- package/dist/document-models/renown-user/src/tests/document-model.test.js +18 -0
- package/dist/document-models/renown-user/src/tests/profile.test.d.ts +5 -0
- package/dist/document-models/renown-user/src/tests/profile.test.js +24 -0
- package/dist/document-models/renown-user/src/utils.d.ts +1 -0
- package/dist/document-models/renown-user/src/utils.js +1 -0
- package/dist/editors/hooks/useRenownUserDocument.d.ts +3 -0
- package/dist/editors/hooks/useRenownUserDocument.js +8 -0
- package/dist/editors/index.d.ts +2 -0
- package/dist/editors/index.js +1 -0
- package/dist/editors/renown-user-editor/editor.d.ts +3 -0
- package/dist/editors/renown-user-editor/editor.js +33 -0
- package/dist/editors/renown-user-editor/index.d.ts +2 -0
- package/dist/editors/renown-user-editor/index.js +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/powerhouse.manifest.json +33 -0
- package/dist/processors/factory.d.ts +7 -0
- package/dist/processors/factory.js +22 -0
- package/dist/processors/index.d.ts +4 -0
- package/dist/processors/index.js +3 -0
- package/dist/processors/renown-user/factory.d.ts +3 -0
- package/dist/processors/renown-user/factory.js +22 -0
- package/dist/processors/renown-user/index.d.ts +9 -0
- package/dist/processors/renown-user/index.js +81 -0
- package/dist/processors/renown-user/migrations.d.ts +3 -0
- package/dist/processors/renown-user/migrations.js +36 -0
- package/dist/processors/renown-user/schema.d.ts +14 -0
- package/dist/processors/renown-user/schema.js +1 -0
- package/dist/style.css +17667 -0
- package/dist/subgraphs/index.d.ts +3 -0
- package/dist/subgraphs/index.js +2 -0
- package/dist/subgraphs/renown-read-model/index.d.ts +10 -0
- package/dist/subgraphs/renown-read-model/index.js +11 -0
- package/dist/subgraphs/renown-read-model/resolvers.d.ts +2 -0
- package/dist/subgraphs/renown-read-model/resolvers.js +106 -0
- package/dist/subgraphs/renown-read-model/schema.d.ts +2 -0
- package/dist/subgraphs/renown-read-model/schema.js +35 -0
- package/dist/subgraphs/renown-user/index.d.ts +10 -0
- package/dist/subgraphs/renown-user/index.js +11 -0
- package/dist/subgraphs/renown-user/resolvers.d.ts +2 -0
- package/dist/subgraphs/renown-user/resolvers.js +108 -0
- package/dist/subgraphs/renown-user/schema.d.ts +2 -0
- package/dist/subgraphs/renown-user/schema.js +63 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +8 -0
- package/package.json +103 -0
|
@@ -0,0 +1,154 @@
|
|
|
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 RenownUserState = {
|
|
138
|
+
ethAddress: Maybe<Scalars["EthereumAddress"]["output"]>;
|
|
139
|
+
userImage: Maybe<Scalars["String"]["output"]>;
|
|
140
|
+
/** Add your global state fields here */
|
|
141
|
+
username: Maybe<Scalars["String"]["output"]>;
|
|
142
|
+
};
|
|
143
|
+
export type SetEthAddressInput = {
|
|
144
|
+
/** Add your inputs here */
|
|
145
|
+
ethAddress: Scalars["EthereumAddress"]["input"];
|
|
146
|
+
};
|
|
147
|
+
export type SetUserImageInput = {
|
|
148
|
+
/** Add your inputs here */
|
|
149
|
+
userImage: Scalars["String"]["input"];
|
|
150
|
+
};
|
|
151
|
+
export type SetUsernameInput = {
|
|
152
|
+
/** Add your inputs here */
|
|
153
|
+
username: Scalars["String"]["input"];
|
|
154
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RenownUserState, 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 RenownUserStateSchema(): z.ZodObject<Properties<RenownUserState>>;
|
|
10
|
+
export declare function SetEthAddressInputSchema(): z.ZodObject<Properties<SetEthAddressInput>>;
|
|
11
|
+
export declare function SetUserImageInputSchema(): z.ZodObject<Properties<SetUserImageInput>>;
|
|
12
|
+
export declare function SetUsernameInputSchema(): z.ZodObject<Properties<SetUsernameInput>>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
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 RenownUserStateSchema() {
|
|
7
|
+
return z.object({
|
|
8
|
+
__typename: z.literal("RenownUserState").optional(),
|
|
9
|
+
ethAddress: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, {
|
|
12
|
+
message: "Invalid Ethereum address format",
|
|
13
|
+
})
|
|
14
|
+
.nullable(),
|
|
15
|
+
userImage: z.string().nullable(),
|
|
16
|
+
username: z.string().nullable(),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function SetEthAddressInputSchema() {
|
|
20
|
+
return z.object({
|
|
21
|
+
ethAddress: z
|
|
22
|
+
.string()
|
|
23
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, {
|
|
24
|
+
message: "Invalid Ethereum address format",
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function SetUserImageInputSchema() {
|
|
29
|
+
return z.object({
|
|
30
|
+
userImage: z.string(),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function SetUsernameInputSchema() {
|
|
34
|
+
return z.object({
|
|
35
|
+
username: z.string(),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PHDocument } from "document-model";
|
|
2
|
+
import type { RenownUserAction } from "./actions.js";
|
|
3
|
+
import type { RenownUserPHState } from "./ph-factories.js";
|
|
4
|
+
import type { RenownUserState } from "./schema/types.js";
|
|
5
|
+
export { z } from "./schema/index.js";
|
|
6
|
+
export type * from "./schema/types.js";
|
|
7
|
+
type RenownUserLocalState = Record<PropertyKey, never>;
|
|
8
|
+
export type RenownUserDocument = PHDocument<RenownUserPHState>;
|
|
9
|
+
export type { RenownUserState, RenownUserLocalState, RenownUserAction };
|
|
@@ -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 RenownUserState, type RenownUserLocalState } from "./types.js";
|
|
3
|
+
import { RenownUserPHState } from "./ph-factories.js";
|
|
4
|
+
export declare const initialGlobalState: RenownUserState;
|
|
5
|
+
export declare const initialLocalState: RenownUserLocalState;
|
|
6
|
+
export declare const createState: CreateState<RenownUserPHState>;
|
|
7
|
+
export declare const createDocument: CreateDocument<RenownUserPHState>;
|
|
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<RenownUserPHState>;
|
|
11
|
+
export declare const loadFromInput: LoadFromInput<RenownUserPHState>;
|
|
12
|
+
declare const utils: {
|
|
13
|
+
fileExtension: string;
|
|
14
|
+
createState: CreateState<RenownUserPHState>;
|
|
15
|
+
createDocument: CreateDocument<RenownUserPHState>;
|
|
16
|
+
saveToFile: (document: any, path: string, name?: string) => Promise<string>;
|
|
17
|
+
saveToFileHandle: (document: any, input: any) => Promise<void>;
|
|
18
|
+
loadFromFile: LoadFromFile<RenownUserPHState>;
|
|
19
|
+
loadFromInput: LoadFromInput<RenownUserPHState>;
|
|
20
|
+
};
|
|
21
|
+
export default utils;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
};
|
|
8
|
+
export const initialLocalState = {};
|
|
9
|
+
export const createState = (state) => {
|
|
10
|
+
return {
|
|
11
|
+
...defaultBaseState(),
|
|
12
|
+
global: { ...initialGlobalState, ...(state?.global ?? {}) },
|
|
13
|
+
local: { ...initialLocalState, ...(state?.local ?? {}) },
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export const createDocument = (state) => {
|
|
17
|
+
const document = baseCreateDocument(createState, state);
|
|
18
|
+
document.header.documentType = "powerhouse/renown-user";
|
|
19
|
+
// for backwards compatibility, but this is NOT a valid signed document id
|
|
20
|
+
document.header.id = generateId();
|
|
21
|
+
return document;
|
|
22
|
+
};
|
|
23
|
+
export const saveToFile = (document, path, name) => {
|
|
24
|
+
return baseSaveToFile(document, path, "phru", name);
|
|
25
|
+
};
|
|
26
|
+
export const saveToFileHandle = (document, input) => {
|
|
27
|
+
return baseSaveToFileHandle(document, input);
|
|
28
|
+
};
|
|
29
|
+
export const loadFromFile = (path) => {
|
|
30
|
+
return baseLoadFromFile(path, reducer);
|
|
31
|
+
};
|
|
32
|
+
export const loadFromInput = (input) => {
|
|
33
|
+
return baseLoadFromInput(input, reducer);
|
|
34
|
+
};
|
|
35
|
+
const utils = {
|
|
36
|
+
fileExtension: "phru",
|
|
37
|
+
createState,
|
|
38
|
+
createDocument,
|
|
39
|
+
saveToFile,
|
|
40
|
+
saveToFileHandle,
|
|
41
|
+
loadFromFile,
|
|
42
|
+
loadFromInput,
|
|
43
|
+
};
|
|
44
|
+
export default utils;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { RenownUserPHState } from "./gen/ph-factories.js";
|
|
9
|
+
declare const utils: {
|
|
10
|
+
fileExtension: string;
|
|
11
|
+
createState: import("document-model").CreateState<RenownUserPHState>;
|
|
12
|
+
createDocument: import("document-model").CreateDocument<RenownUserPHState>;
|
|
13
|
+
saveToFile: (document: any, path: string, name?: string) => Promise<string>;
|
|
14
|
+
saveToFileHandle: (document: any, input: any) => Promise<void>;
|
|
15
|
+
loadFromFile: import("document-model").LoadFromFile<RenownUserPHState>;
|
|
16
|
+
loadFromInput: import("document-model").LoadFromInput<RenownUserPHState>;
|
|
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
|
+
};
|
|
23
|
+
export declare const module: DocumentModelModule<RenownUserPHState>;
|
|
24
|
+
export { reducer, actions, utils, documentModel };
|
|
25
|
+
export * from "./gen/types.js";
|
|
26
|
+
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 RenownUserActions } 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, ...RenownUserActions };
|
|
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,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;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -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 User Document Model", () => {
|
|
8
|
+
it("should create a new Renown User document", () => {
|
|
9
|
+
const document = utils.createDocument();
|
|
10
|
+
expect(document).toBeDefined();
|
|
11
|
+
expect(document.header.documentType).toBe("powerhouse/renown-user");
|
|
12
|
+
});
|
|
13
|
+
it("should create a new Renown User 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,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 {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RenownUserDocument } from "../../document-models/renown-user/index.js";
|
|
2
|
+
export declare function useRenownUserDocument(documentId: string | null | undefined): never[] | [RenownUserDocument, import("@powerhousedao/reactor-browser").DocumentDispatch<import("../../document-models/renown-user/gen/actions.js").RenownUserProfileAction>];
|
|
3
|
+
export declare function useSelectedRenownUserDocument(): never[] | [RenownUserDocument, import("@powerhousedao/reactor-browser").DocumentDispatch<import("../../document-models/renown-user/gen/actions.js").RenownUserProfileAction>];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useDocumentOfType, useSelectedDocumentId, } from "@powerhousedao/reactor-browser";
|
|
2
|
+
export function useRenownUserDocument(documentId) {
|
|
3
|
+
return useDocumentOfType(documentId, "powerhouse/renown-user");
|
|
4
|
+
}
|
|
5
|
+
export function useSelectedRenownUserDocument() {
|
|
6
|
+
const selectedDocumentId = useSelectedDocumentId();
|
|
7
|
+
return useRenownUserDocument(selectedDocumentId);
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { module as RenownUserEditor } from "./renown-user-editor/index.js";
|
|
@@ -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-user/index.js";
|
|
5
|
+
import { Form, StringField, UrlField, Button } from "@powerhousedao/document-engineering";
|
|
6
|
+
export 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 [isEditingUser, setIsEditingUser] = useState(false);
|
|
14
|
+
const { state: { global } } = typedDocument;
|
|
15
|
+
const { username, ethAddress, userImage } = global;
|
|
16
|
+
// User 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() }));
|
|
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 User" }), _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: () => setIsEditingUser(!isEditingUser), children: isEditingUser ? "Cancel" : "Edit User" }) })] }) }) }) }), _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: "User Information" }), _jsx("p", { className: "text-sm text-gray-500", children: "Manage your renown User details" })] }), _jsx("div", { className: "p-6", children: isEditingUser ? (_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: "User Image URL", value: userImage || "", onChange: (e) => handleSetUserImage(e.target.value), placeholder: "https://example.com/avatar.png", description: "URL to your User image" }), _jsxs("div", { className: "flex justify-end space-x-3 pt-4 border-t", children: [_jsx(Button, { color: "light", onClick: () => setIsEditingUser(false), children: "Cancel" }), _jsx(Button, { onClick: () => setIsEditingUser(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: "User Image" }), userImage ? (_jsxs("div", { className: "flex items-center space-x-4", children: [_jsx("img", { src: userImage, alt: "User", 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: () => setIsEditingUser(true), children: "Edit User" }) })] })) })] }), _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: "User 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 User information available. Click \"Edit User\" to get started." }))] })] }) })] })] }) })] }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Editor } from "./editor.js";
|
|
2
|
+
export const module = {
|
|
3
|
+
Component: Editor,
|
|
4
|
+
documentTypes: ["powerhouse/renown-user"],
|
|
5
|
+
config: {
|
|
6
|
+
id: "renown-user-editor",
|
|
7
|
+
disableExternalControls: true,
|
|
8
|
+
documentToolbarEnabled: true,
|
|
9
|
+
showSwitchboardLink: true,
|
|
10
|
+
},
|
|
11
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Manifest } from "document-model";
|
|
2
|
+
export declare const manifest: Manifest;
|
|
3
|
+
export declare const documentModels: import("document-model").DocumentModelModule<import("./document-models/renown-user/gen").RenownUserPHState>[];
|
|
4
|
+
export declare const editors: import("document-model").EditorModule[];
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import manifestJson from "./powerhouse.manifest.json" with { type: "json" };
|
|
2
|
+
import * as documentModelsExports from './document-models/index.js';
|
|
3
|
+
import * as editorsExports from './editors/index.js';
|
|
4
|
+
export const manifest = manifestJson;
|
|
5
|
+
export const documentModels = Object.values(documentModelsExports);
|
|
6
|
+
export const editors = Object.values(editorsExports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Renown",
|
|
3
|
+
"description": "All document models, editors, processors and subgraphs related to renown.",
|
|
4
|
+
"category": "People & Culture",
|
|
5
|
+
"publisher": {
|
|
6
|
+
"name": "Powerhouse Inc.",
|
|
7
|
+
"url": "https://www.powerhouse.inc"
|
|
8
|
+
},
|
|
9
|
+
"documentModels": [
|
|
10
|
+
{
|
|
11
|
+
"id": "powerhouse/renown-user",
|
|
12
|
+
"name": "RenownUser"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"editors": [
|
|
16
|
+
{
|
|
17
|
+
"id": "renown-user-editor",
|
|
18
|
+
"name": "Renown User Editor",
|
|
19
|
+
"documentTypes": [
|
|
20
|
+
"powerhouse/renown-user"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"apps": [],
|
|
25
|
+
"subgraphs": [
|
|
26
|
+
{
|
|
27
|
+
"id": "renown-read-model",
|
|
28
|
+
"name": "Renown Read Model",
|
|
29
|
+
"documentTypes": []
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"importScripts": []
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file aggregates all processor factories
|
|
3
|
+
* Auto-generated by codegen - DO NOT EDIT MANUALLY
|
|
4
|
+
*/
|
|
5
|
+
import { type ProcessorRecord, type IProcessorHostModule } from "document-drive/processors/types";
|
|
6
|
+
import { type PHDocumentHeader } from "document-model";
|
|
7
|
+
export declare const processorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file aggregates all processor factories
|
|
3
|
+
* Auto-generated by codegen - DO NOT EDIT MANUALLY
|
|
4
|
+
*/
|
|
5
|
+
// Import processor factories here as they are generated
|
|
6
|
+
import { renownUserProcessorFactory } from "./renown-user/factory.js";
|
|
7
|
+
export const processorFactory = (module) => {
|
|
8
|
+
// Initialize all processor factories once with the module
|
|
9
|
+
const factories = [];
|
|
10
|
+
// Add processors here as they are generated
|
|
11
|
+
factories.push(renownUserProcessorFactory(module));
|
|
12
|
+
// Return the inner function that will be called for each drive
|
|
13
|
+
return async (driveHeader) => {
|
|
14
|
+
const processors = [];
|
|
15
|
+
// Call each cached factory with the driveId
|
|
16
|
+
for (const factory of factories) {
|
|
17
|
+
const factoryProcessors = await factory(driveHeader);
|
|
18
|
+
processors.push(...factoryProcessors);
|
|
19
|
+
}
|
|
20
|
+
return processors;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -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 renownUserProcessorFactory: (module: IProcessorHostModule) => (driveHeader: PHDocumentHeader) => Promise<ProcessorRecord[]>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RenownUserProcessor } from "./index.js";
|
|
2
|
+
export const renownUserProcessorFactory = (module) => async (driveHeader) => {
|
|
3
|
+
// Create a namespace for the processor and the provided drive id
|
|
4
|
+
const namespace = RenownUserProcessor.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-user"],
|
|
12
|
+
scope: ["global"],
|
|
13
|
+
};
|
|
14
|
+
// Create the processor
|
|
15
|
+
const processor = new RenownUserProcessor(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 RenownUserProcessor extends RelationalDbProcessor<DB> {
|
|
5
|
+
static getNamespace(driveId: string): string;
|
|
6
|
+
initAndUpgrade(): Promise<void>;
|
|
7
|
+
onStrands(strands: InternalTransmitterUpdate[]): Promise<void>;
|
|
8
|
+
onDisconnect(): Promise<void>;
|
|
9
|
+
}
|