@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
@@ -235,7 +235,7 @@ export type VetraBuilderPackage = {
235
235
  category: Maybe<Scalars["String"]["output"]>;
236
236
  description: Maybe<Scalars["String"]["output"]>;
237
237
  github: Maybe<Scalars["URL"]["output"]>;
238
- id: Scalars["OID"]["output"];
238
+ id: Maybe<Scalars["PHID"]["output"]>;
239
239
  keywords: Array<VetraBuilderPackageKeyword>;
240
240
  name: Scalars["String"]["output"];
241
241
  npm: Maybe<Scalars["URL"]["output"]>;
@@ -142,7 +142,7 @@ export function VetraBuilderPackageSchema() {
142
142
  category: z.string().nullable(),
143
143
  description: z.string().nullable(),
144
144
  github: z.string().url().nullable(),
145
- id: z.string(),
145
+ id: z.string().nullable(),
146
146
  keywords: z.array(VetraBuilderPackageKeywordSchema()),
147
147
  name: z.string(),
148
148
  npm: z.string().url().nullable(),
@@ -1,2 +1,3 @@
1
1
  export {};
2
2
  export { module as BuilderAccount } from "./builder-account/index.js";
3
+ export { module as RenownProfile } from "./renown-profile/index.js";
@@ -1 +1,2 @@
1
1
  export { module as BuilderAccount } from "./builder-account/index.js";
2
+ export { module as RenownProfile } from "./renown-profile/index.js";
@@ -0,0 +1,5 @@
1
+ import type { RenownProfileProfileAction } from "./profile/actions.js";
2
+ import type { RenownProfileAuthorizationAction } from "./authorization/actions.js";
3
+ export * from "./profile/actions.js";
4
+ export * from "./authorization/actions.js";
5
+ export type RenownProfileAction = RenownProfileProfileAction | RenownProfileAuthorizationAction;
@@ -0,0 +1,2 @@
1
+ export * from "./profile/actions.js";
2
+ export * from "./authorization/actions.js";
@@ -0,0 +1,11 @@
1
+ import { type Action } from "document-model";
2
+ import type { AddAuthorizationInput, RevokeAuthorizationInput } from "../types.js";
3
+ export type AddAuthorizationAction = Action & {
4
+ type: "ADD_AUTHORIZATION";
5
+ input: AddAuthorizationInput;
6
+ };
7
+ export type RevokeAuthorizationAction = Action & {
8
+ type: "REVOKE_AUTHORIZATION";
9
+ input: RevokeAuthorizationInput;
10
+ };
11
+ export type RenownProfileAuthorizationAction = AddAuthorizationAction | RevokeAuthorizationAction;
@@ -0,0 +1,4 @@
1
+ import { type AddAuthorizationInput, type RevokeAuthorizationInput } from "../types.js";
2
+ import { type AddAuthorizationAction, type RevokeAuthorizationAction } from "./actions.js";
3
+ export declare const addAuthorization: (input: AddAuthorizationInput) => AddAuthorizationAction;
4
+ export declare const revokeAuthorization: (input: RevokeAuthorizationInput) => RevokeAuthorizationAction;
@@ -0,0 +1,4 @@
1
+ import { createAction } from "document-model";
2
+ import { z, } from "../types.js";
3
+ export const addAuthorization = (input) => createAction("ADD_AUTHORIZATION", { ...input }, undefined, z.AddAuthorizationInputSchema, "global");
4
+ export const revokeAuthorization = (input) => createAction("REVOKE_AUTHORIZATION", { ...input }, undefined, z.RevokeAuthorizationInputSchema, "global");
@@ -0,0 +1 @@
1
+ export declare const errors: {};
@@ -0,0 +1 @@
1
+ export const errors = {};
@@ -0,0 +1,7 @@
1
+ import { BaseDocumentClass } from "document-model";
2
+ import { RenownProfilePHState } from "../ph-factories.js";
3
+ import { type AddAuthorizationInput, type RevokeAuthorizationInput } from "../types.js";
4
+ export default class RenownProfile_Authorization extends BaseDocumentClass<RenownProfilePHState> {
5
+ addAuthorization(input: AddAuthorizationInput): this;
6
+ revokeAuthorization(input: RevokeAuthorizationInput): this;
7
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseDocumentClass } from "document-model";
2
+ import { addAuthorization, revokeAuthorization } from "./creators.js";
3
+ export default class RenownProfile_Authorization extends BaseDocumentClass {
4
+ addAuthorization(input) {
5
+ return this.dispatch(addAuthorization(input));
6
+ }
7
+ revokeAuthorization(input) {
8
+ return this.dispatch(revokeAuthorization(input));
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ import { type SignalDispatch } from "document-model";
2
+ import { type AddAuthorizationAction, type RevokeAuthorizationAction } from "./actions.js";
3
+ import { type RenownProfileState } from "../types.js";
4
+ export interface RenownProfileAuthorizationOperations {
5
+ addAuthorizationOperation: (state: RenownProfileState, action: AddAuthorizationAction, dispatch?: SignalDispatch) => void;
6
+ revokeAuthorizationOperation: (state: RenownProfileState, action: RevokeAuthorizationAction, dispatch?: SignalDispatch) => void;
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./profile/creators.js";
2
+ export * from "./authorization/creators.js";
@@ -0,0 +1,2 @@
1
+ export * from "./profile/creators.js";
2
+ export * from "./authorization/creators.js";
@@ -0,0 +1,2 @@
1
+ import type { DocumentModelState } from "document-model";
2
+ export declare const documentModel: DocumentModelState;
@@ -0,0 +1,99 @@
1
+ export const documentModel = {
2
+ author: {
3
+ name: "Powerhouse Inc.",
4
+ website: "https://powerhouse.inc",
5
+ },
6
+ description: "A renown profile which contains a name, description of a renown user",
7
+ extension: "renown-profile",
8
+ id: "powerhouse/renown-profile",
9
+ name: "RenownProfile",
10
+ specifications: [
11
+ {
12
+ changeLog: [],
13
+ modules: [
14
+ {
15
+ description: "",
16
+ id: "cdd8d6b6-2cbf-46a2-bb81-7b5f12c177ab",
17
+ name: "profile",
18
+ operations: [
19
+ {
20
+ description: "sets the username of the profile",
21
+ errors: [],
22
+ examples: [],
23
+ id: "481a4057-e061-4cea-9a8b-223465b09ab3",
24
+ name: "SET_USERNAME",
25
+ reducer: "",
26
+ schema: 'input SetUsernameInput {\n "Add your inputs here"\n username: String!\n}',
27
+ scope: "global",
28
+ template: "",
29
+ },
30
+ {
31
+ description: "sets the eth address",
32
+ errors: [],
33
+ examples: [],
34
+ id: "0e6ddb86-f9a0-4302-be8f-78f720b752e0",
35
+ name: "SET_ETH_ADDRESS",
36
+ reducer: "",
37
+ schema: 'input SetEthAddressInput {\n "Add your inputs here"\n ethAddress: EthereumAddress!\n}',
38
+ scope: "global",
39
+ template: "",
40
+ },
41
+ {
42
+ description: "sets the user image. provide an empty object for removing the existing",
43
+ errors: [],
44
+ examples: [],
45
+ id: "7d2ac96b-7229-4665-9fda-6b83fd68dcf9",
46
+ name: "SET_USER_IMAGE",
47
+ reducer: "",
48
+ schema: 'input SetUserImageInput {\n "Add your inputs here"\n userImage: String\n}',
49
+ scope: "global",
50
+ template: "",
51
+ },
52
+ ],
53
+ },
54
+ {
55
+ description: "",
56
+ id: "fced3cb9-20d5-47de-939b-6d38c9816404",
57
+ name: "authorization",
58
+ operations: [
59
+ {
60
+ description: "",
61
+ errors: [],
62
+ examples: [],
63
+ id: "93f92fb8-e686-46ea-9c9e-6dac9290ee54",
64
+ name: "ADD_AUTHORIZATION",
65
+ reducer: "",
66
+ schema: 'input AddAuthorizationInput {\n "Add your inputs here"\n id: OID!\n audience: String\n issuer: String!\n subject: String!\n expiry: Int\n}',
67
+ scope: "global",
68
+ template: "",
69
+ },
70
+ {
71
+ description: "",
72
+ errors: [],
73
+ examples: [],
74
+ id: "e68a806b-45f7-469c-b1aa-43743eac623c",
75
+ name: "REVOKE_AUTHORIZATION",
76
+ reducer: "",
77
+ schema: 'input RevokeAuthorizationInput {\n "Add your inputs here"\n authorizationId: OID!\n}',
78
+ scope: "global",
79
+ template: "",
80
+ },
81
+ ],
82
+ },
83
+ ],
84
+ state: {
85
+ global: {
86
+ examples: [],
87
+ initialValue: '"{\\n \\"username\\": null,\\n \\"ethAddress\\": null,\\n \\"userImage\\": null,\\n \\"authorizations\\": []\\n}"',
88
+ schema: 'type RenownProfileState {\n "Add your global state fields here"\n username: String\n ethAddress: EthereumAddress\n userImage: String\n authorizations: [RenownAuthorization!]!\n}\n\n# Issuer is ETH Address\n# Subject is the DID for Connect \n# Audience is the target ie did:web:staging.vetra.io\n# expiry \ntype RenownAuthorization {\n id: OID!\n audience: String\n issuer: String!\n subject: String!\n expiry: Int\n}',
89
+ },
90
+ local: {
91
+ examples: [],
92
+ initialValue: '""',
93
+ schema: "",
94
+ },
95
+ },
96
+ version: 1,
97
+ },
98
+ ],
99
+ };
@@ -0,0 +1,7 @@
1
+ export * from "./actions.js";
2
+ export * from "./document-model.js";
3
+ export * from "./object.js";
4
+ export * from "./types.js";
5
+ export * as actions from "./creators.js";
6
+ export type { RenownProfilePHState } from "./ph-factories.js";
7
+ export { createRenownProfileDocument, createState, defaultPHState, defaultGlobalState, defaultLocalState, } from "./ph-factories.js";
@@ -0,0 +1,6 @@
1
+ export * from "./actions.js";
2
+ export * from "./document-model.js";
3
+ export * from "./object.js";
4
+ export * from "./types.js";
5
+ export * as actions from "./creators.js";
6
+ export { createRenownProfileDocument, createState, defaultPHState, defaultGlobalState, defaultLocalState, } from "./ph-factories.js";
@@ -0,0 +1,16 @@
1
+ import { BaseDocumentClass, type SignalDispatch } from "document-model";
2
+ import { RenownProfilePHState } from "./ph-factories.js";
3
+ import RenownProfile_Profile from "./profile/object.js";
4
+ import RenownProfile_Authorization from "./authorization/object.js";
5
+ export * from "./profile/object.js";
6
+ export * from "./authorization/object.js";
7
+ interface RenownProfile extends RenownProfile_Profile, RenownProfile_Authorization {
8
+ }
9
+ declare class RenownProfile extends BaseDocumentClass<RenownProfilePHState> {
10
+ static fileExtension: string;
11
+ constructor(initialState?: Partial<RenownProfilePHState>, dispatch?: SignalDispatch);
12
+ saveToFile(path: string, name?: string): Promise<string>;
13
+ loadFromFile(path: string): Promise<void>;
14
+ static fromFile(path: string): Promise<RenownProfile>;
15
+ }
16
+ export { RenownProfile };
@@ -0,0 +1,30 @@
1
+ import { BaseDocumentClass, applyMixins, } from "document-model";
2
+ import { reducer } from "./reducer.js";
3
+ import { createDocument } from "./utils.js";
4
+ import RenownProfile_Profile from "./profile/object.js";
5
+ import RenownProfile_Authorization from "./authorization/object.js";
6
+ export * from "./profile/object.js";
7
+ export * from "./authorization/object.js";
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
9
+ class RenownProfile extends BaseDocumentClass {
10
+ static fileExtension = "renown-profile";
11
+ constructor(initialState, dispatch) {
12
+ super(reducer, createDocument(initialState), dispatch);
13
+ }
14
+ saveToFile(path, name) {
15
+ return super.saveToFile(path, RenownProfile.fileExtension, name);
16
+ }
17
+ loadFromFile(path) {
18
+ return super.loadFromFile(path);
19
+ }
20
+ static async fromFile(path) {
21
+ const document = new this();
22
+ await document.loadFromFile(path);
23
+ return document;
24
+ }
25
+ }
26
+ applyMixins(RenownProfile, [
27
+ RenownProfile_Profile,
28
+ RenownProfile_Authorization,
29
+ ]);
30
+ export { RenownProfile };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Factory methods for creating RenownProfileDocument instances
3
+ */
4
+ import { type PHAuthState, type PHDocumentState, type PHBaseState } from "document-model";
5
+ import type { RenownProfileDocument, RenownProfileLocalState, RenownProfileState } from "./types.js";
6
+ export type RenownProfilePHState = PHBaseState & {
7
+ global: RenownProfileState;
8
+ local: RenownProfileLocalState;
9
+ };
10
+ export declare function defaultGlobalState(): RenownProfileState;
11
+ export declare function defaultLocalState(): RenownProfileLocalState;
12
+ export declare function defaultPHState(): RenownProfilePHState;
13
+ export declare function createGlobalState(state?: Partial<RenownProfileState>): RenownProfileState;
14
+ export declare function createLocalState(state?: Partial<RenownProfileLocalState>): RenownProfileLocalState;
15
+ export declare function createState(baseState?: Partial<PHBaseState>, globalState?: Partial<RenownProfileState>, localState?: Partial<RenownProfileLocalState>): RenownProfilePHState;
16
+ /**
17
+ * Creates a RenownProfileDocument with custom global and local state
18
+ * This properly handles the PHBaseState requirements while allowing
19
+ * document-specific state to be set.
20
+ */
21
+ export declare function createRenownProfileDocument(state?: Partial<{
22
+ auth?: Partial<PHAuthState>;
23
+ document?: Partial<PHDocumentState>;
24
+ global?: Partial<RenownProfileState>;
25
+ local?: Partial<RenownProfileLocalState>;
26
+ }>): RenownProfileDocument;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Factory methods for creating RenownProfileDocument instances
3
+ */
4
+ import { createBaseState, defaultBaseState, } from "document-model";
5
+ import { createDocument } from "./utils.js";
6
+ export function defaultGlobalState() {
7
+ return {
8
+ username: null,
9
+ ethAddress: null,
10
+ userImage: null,
11
+ authorizations: [],
12
+ };
13
+ }
14
+ export function defaultLocalState() {
15
+ return {};
16
+ }
17
+ export function defaultPHState() {
18
+ return {
19
+ ...defaultBaseState(),
20
+ global: defaultGlobalState(),
21
+ local: defaultLocalState(),
22
+ };
23
+ }
24
+ export function createGlobalState(state) {
25
+ return {
26
+ ...defaultGlobalState(),
27
+ ...(state || {}),
28
+ };
29
+ }
30
+ export function createLocalState(state) {
31
+ return {
32
+ ...defaultLocalState(),
33
+ ...(state || {}),
34
+ };
35
+ }
36
+ export function createState(baseState, globalState, localState) {
37
+ return {
38
+ ...createBaseState(baseState?.auth, baseState?.document),
39
+ global: createGlobalState(globalState),
40
+ local: createLocalState(localState),
41
+ };
42
+ }
43
+ /**
44
+ * Creates a RenownProfileDocument with custom global and local state
45
+ * This properly handles the PHBaseState requirements while allowing
46
+ * document-specific state to be set.
47
+ */
48
+ export function createRenownProfileDocument(state) {
49
+ const document = createDocument(state
50
+ ? createState(createBaseState(state.auth, state.document), state.global, state.local)
51
+ : undefined);
52
+ return document;
53
+ }
@@ -0,0 +1,15 @@
1
+ import { type Action } from "document-model";
2
+ import type { SetUsernameInput, SetEthAddressInput, SetUserImageInput } from "../types.js";
3
+ export type SetUsernameAction = Action & {
4
+ type: "SET_USERNAME";
5
+ input: SetUsernameInput;
6
+ };
7
+ export type SetEthAddressAction = Action & {
8
+ type: "SET_ETH_ADDRESS";
9
+ input: SetEthAddressInput;
10
+ };
11
+ export type SetUserImageAction = Action & {
12
+ type: "SET_USER_IMAGE";
13
+ input: SetUserImageInput;
14
+ };
15
+ export type RenownProfileProfileAction = SetUsernameAction | SetEthAddressAction | SetUserImageAction;
@@ -0,0 +1,5 @@
1
+ import { type SetUsernameInput, type SetEthAddressInput, type SetUserImageInput } from "../types.js";
2
+ import { type SetUsernameAction, type SetEthAddressAction, type SetUserImageAction } from "./actions.js";
3
+ export declare const setUsername: (input: SetUsernameInput) => SetUsernameAction;
4
+ export declare const setEthAddress: (input: SetEthAddressInput) => SetEthAddressAction;
5
+ export declare const setUserImage: (input: SetUserImageInput) => SetUserImageAction;
@@ -0,0 +1,5 @@
1
+ import { createAction } from "document-model";
2
+ import { z, } from "../types.js";
3
+ export const setUsername = (input) => createAction("SET_USERNAME", { ...input }, undefined, z.SetUsernameInputSchema, "global");
4
+ export const setEthAddress = (input) => createAction("SET_ETH_ADDRESS", { ...input }, undefined, z.SetEthAddressInputSchema, "global");
5
+ export const setUserImage = (input) => createAction("SET_USER_IMAGE", { ...input }, undefined, z.SetUserImageInputSchema, "global");
@@ -0,0 +1 @@
1
+ export declare const errors: {};
@@ -0,0 +1 @@
1
+ export const errors = {};
@@ -0,0 +1,8 @@
1
+ import { BaseDocumentClass } from "document-model";
2
+ import { RenownProfilePHState } from "../ph-factories.js";
3
+ import { type SetUsernameInput, type SetEthAddressInput, type SetUserImageInput } from "../types.js";
4
+ export default class RenownProfile_Profile extends BaseDocumentClass<RenownProfilePHState> {
5
+ setUsername(input: SetUsernameInput): this;
6
+ setEthAddress(input: SetEthAddressInput): this;
7
+ setUserImage(input: SetUserImageInput): this;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseDocumentClass } from "document-model";
2
+ import { setUsername, setEthAddress, setUserImage } from "./creators.js";
3
+ export default class RenownProfile_Profile extends BaseDocumentClass {
4
+ setUsername(input) {
5
+ return this.dispatch(setUsername(input));
6
+ }
7
+ setEthAddress(input) {
8
+ return this.dispatch(setEthAddress(input));
9
+ }
10
+ setUserImage(input) {
11
+ return this.dispatch(setUserImage(input));
12
+ }
13
+ }
@@ -0,0 +1,8 @@
1
+ import { type SignalDispatch } from "document-model";
2
+ import { type SetUsernameAction, type SetEthAddressAction, type SetUserImageAction } from "./actions.js";
3
+ import { type RenownProfileState } from "../types.js";
4
+ export interface RenownProfileProfileOperations {
5
+ setUsernameOperation: (state: RenownProfileState, action: SetUsernameAction, dispatch?: SignalDispatch) => void;
6
+ setEthAddressOperation: (state: RenownProfileState, action: SetEthAddressAction, dispatch?: SignalDispatch) => void;
7
+ setUserImageOperation: (state: RenownProfileState, action: SetUserImageAction, dispatch?: SignalDispatch) => void;
8
+ }
@@ -0,0 +1,4 @@
1
+ import { type StateReducer } from "document-model";
2
+ import { RenownProfilePHState } from "./ph-factories.js";
3
+ export declare const stateReducer: StateReducer<RenownProfilePHState>;
4
+ export declare const reducer: import("document-model").Reducer<RenownProfilePHState>;
@@ -0,0 +1,37 @@
1
+ // TODO: remove eslint-disable rules once refactor is done
2
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
4
+ import { isDocumentAction, createReducer, } from "document-model";
5
+ import { z } from "./types.js";
6
+ import { reducer as ProfileReducer } from "../src/reducers/profile.js";
7
+ import { reducer as AuthorizationReducer } from "../src/reducers/authorization.js";
8
+ export const stateReducer = (state, action, dispatch) => {
9
+ if (isDocumentAction(action)) {
10
+ return state;
11
+ }
12
+ switch (action.type) {
13
+ case "SET_USERNAME":
14
+ z.SetUsernameInputSchema().parse(action.input);
15
+ ProfileReducer.setUsernameOperation(state[action.scope], action, dispatch);
16
+ break;
17
+ case "SET_ETH_ADDRESS":
18
+ z.SetEthAddressInputSchema().parse(action.input);
19
+ ProfileReducer.setEthAddressOperation(state[action.scope], action, dispatch);
20
+ break;
21
+ case "SET_USER_IMAGE":
22
+ z.SetUserImageInputSchema().parse(action.input);
23
+ ProfileReducer.setUserImageOperation(state[action.scope], action, dispatch);
24
+ break;
25
+ case "ADD_AUTHORIZATION":
26
+ z.AddAuthorizationInputSchema().parse(action.input);
27
+ AuthorizationReducer.addAuthorizationOperation(state[action.scope], action, dispatch);
28
+ break;
29
+ case "REVOKE_AUTHORIZATION":
30
+ z.RevokeAuthorizationInputSchema().parse(action.input);
31
+ AuthorizationReducer.revokeAuthorizationOperation(state[action.scope], action, dispatch);
32
+ break;
33
+ default:
34
+ return state;
35
+ }
36
+ };
37
+ export const reducer = createReducer(stateReducer);
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * as z from "./zod.js";
@@ -0,0 +1,2 @@
1
+ export * from "./types.js";
2
+ export * as z from "./zod.js";