@powerhousedao/builder-profile 0.0.2 → 0.0.4

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 (161) hide show
  1. package/dist/document-models/builder-profile/actions.d.ts +22 -0
  2. package/dist/document-models/builder-profile/actions.d.ts.map +1 -0
  3. package/dist/document-models/builder-profile/actions.js +4 -0
  4. package/dist/document-models/builder-profile/gen/actions.d.ts +3 -3
  5. package/dist/document-models/builder-profile/gen/actions.d.ts.map +1 -1
  6. package/dist/document-models/builder-profile/gen/actions.js +1 -1
  7. package/dist/document-models/builder-profile/gen/builders/actions.d.ts +44 -0
  8. package/dist/document-models/builder-profile/gen/builders/actions.d.ts.map +1 -0
  9. package/dist/document-models/builder-profile/gen/builders/actions.js +1 -0
  10. package/dist/document-models/builder-profile/gen/builders/creators.d.ts +13 -0
  11. package/dist/document-models/builder-profile/gen/builders/creators.d.ts.map +1 -0
  12. package/dist/document-models/builder-profile/gen/builders/creators.js +12 -0
  13. package/dist/document-models/builder-profile/gen/builders/error.d.ts.map +1 -0
  14. package/dist/document-models/builder-profile/gen/builders/operations.d.ts +16 -0
  15. package/dist/document-models/builder-profile/gen/builders/operations.d.ts.map +1 -0
  16. package/dist/document-models/builder-profile/gen/builders/operations.js +3 -0
  17. package/dist/document-models/builder-profile/gen/creators.d.ts +2 -1
  18. package/dist/document-models/builder-profile/gen/creators.d.ts.map +1 -1
  19. package/dist/document-models/builder-profile/gen/creators.js +2 -1
  20. package/dist/document-models/builder-profile/gen/document-model.d.ts +2 -2
  21. package/dist/document-models/builder-profile/gen/document-model.d.ts.map +1 -1
  22. package/dist/document-models/builder-profile/gen/document-model.js +107 -8
  23. package/dist/document-models/builder-profile/gen/document-schema.d.ts +370 -0
  24. package/dist/document-models/builder-profile/gen/document-schema.d.ts.map +1 -0
  25. package/dist/document-models/builder-profile/gen/document-schema.js +33 -0
  26. package/dist/document-models/builder-profile/gen/document-type.d.ts +2 -0
  27. package/dist/document-models/builder-profile/gen/document-type.d.ts.map +1 -0
  28. package/dist/document-models/builder-profile/gen/document-type.js +1 -0
  29. package/dist/document-models/builder-profile/gen/index.d.ts +7 -3
  30. package/dist/document-models/builder-profile/gen/index.d.ts.map +1 -1
  31. package/dist/document-models/builder-profile/gen/index.js +7 -2
  32. package/dist/document-models/builder-profile/gen/ph-factories.d.ts +6 -10
  33. package/dist/document-models/builder-profile/gen/ph-factories.d.ts.map +1 -1
  34. package/dist/document-models/builder-profile/gen/ph-factories.js +9 -4
  35. package/dist/document-models/builder-profile/gen/reducer.d.ts +1 -3
  36. package/dist/document-models/builder-profile/gen/reducer.d.ts.map +1 -1
  37. package/dist/document-models/builder-profile/gen/reducer.js +42 -9
  38. package/dist/document-models/builder-profile/gen/schema/index.d.ts +1 -1
  39. package/dist/document-models/builder-profile/gen/schema/index.d.ts.map +1 -1
  40. package/dist/document-models/builder-profile/gen/schema/index.js +1 -1
  41. package/dist/document-models/builder-profile/gen/schema/types.d.ts +55 -0
  42. package/dist/document-models/builder-profile/gen/schema/types.d.ts.map +1 -1
  43. package/dist/document-models/builder-profile/gen/schema/zod.d.ts +19 -1
  44. package/dist/document-models/builder-profile/gen/schema/zod.d.ts.map +1 -1
  45. package/dist/document-models/builder-profile/gen/schema/zod.js +126 -0
  46. package/dist/document-models/builder-profile/gen/types.d.ts +9 -7
  47. package/dist/document-models/builder-profile/gen/types.d.ts.map +1 -1
  48. package/dist/document-models/builder-profile/gen/types.js +1 -1
  49. package/dist/document-models/builder-profile/gen/utils.d.ts +13 -20
  50. package/dist/document-models/builder-profile/gen/utils.d.ts.map +1 -1
  51. package/dist/document-models/builder-profile/gen/utils.js +54 -37
  52. package/dist/document-models/builder-profile/hooks.d.ts +11 -0
  53. package/dist/document-models/builder-profile/hooks.d.ts.map +1 -0
  54. package/dist/document-models/builder-profile/hooks.js +26 -0
  55. package/dist/document-models/builder-profile/index.d.ts +5 -20
  56. package/dist/document-models/builder-profile/index.d.ts.map +1 -1
  57. package/dist/document-models/builder-profile/index.js +5 -17
  58. package/dist/document-models/builder-profile/module.d.ts +5 -0
  59. package/dist/document-models/builder-profile/module.d.ts.map +1 -0
  60. package/dist/document-models/builder-profile/module.js +10 -0
  61. package/dist/document-models/builder-profile/src/index.d.ts +2 -0
  62. package/dist/document-models/builder-profile/src/index.d.ts.map +1 -0
  63. package/dist/document-models/builder-profile/src/index.js +1 -0
  64. package/dist/document-models/builder-profile/src/reducers/builders.d.ts +3 -0
  65. package/dist/document-models/builder-profile/src/reducers/builders.d.ts.map +1 -0
  66. package/dist/document-models/builder-profile/src/reducers/builders.js +108 -0
  67. package/dist/document-models/builder-profile/src/tests/builders.test.d.ts +6 -0
  68. package/dist/document-models/builder-profile/src/tests/builders.test.d.ts.map +1 -0
  69. package/dist/document-models/builder-profile/src/tests/builders.test.js +19 -0
  70. package/dist/document-models/builder-profile/src/tests/document-model.test.d.ts +4 -0
  71. package/dist/document-models/builder-profile/src/tests/document-model.test.d.ts.map +1 -1
  72. package/dist/document-models/builder-profile/src/tests/document-model.test.js +91 -5
  73. package/dist/document-models/builder-profile/utils.d.ts +14 -0
  74. package/dist/document-models/builder-profile/utils.d.ts.map +1 -0
  75. package/dist/document-models/builder-profile/utils.js +7 -0
  76. package/dist/document-models/document-models.d.ts +3 -0
  77. package/dist/document-models/document-models.d.ts.map +1 -0
  78. package/dist/document-models/document-models.js +4 -0
  79. package/dist/document-models/index.d.ts +1 -2
  80. package/dist/document-models/index.d.ts.map +1 -1
  81. package/dist/document-models/index.js +1 -1
  82. package/dist/editors/builder-profile/components/ContributorsSection.d.ts +8 -0
  83. package/dist/editors/builder-profile/components/ContributorsSection.d.ts.map +1 -0
  84. package/dist/editors/builder-profile/components/ContributorsSection.js +177 -0
  85. package/dist/editors/builder-profile/components/ImageUrlInput.d.ts +9 -0
  86. package/dist/editors/builder-profile/components/ImageUrlInput.d.ts.map +1 -0
  87. package/dist/editors/builder-profile/components/ImageUrlInput.js +57 -0
  88. package/dist/editors/builder-profile/components/LinksSection.d.ts +18 -0
  89. package/dist/editors/builder-profile/components/LinksSection.d.ts.map +1 -0
  90. package/dist/editors/builder-profile/components/LinksSection.js +74 -0
  91. package/dist/editors/builder-profile/components/ProfilePreview.d.ts +7 -0
  92. package/dist/editors/builder-profile/components/ProfilePreview.d.ts.map +1 -0
  93. package/dist/editors/builder-profile/components/ProfilePreview.js +55 -0
  94. package/dist/editors/builder-profile/components/ScopesSection.d.ts +9 -0
  95. package/dist/editors/builder-profile/components/ScopesSection.d.ts.map +1 -0
  96. package/dist/editors/builder-profile/components/ScopesSection.js +58 -0
  97. package/dist/editors/builder-profile/components/SkillsSection.d.ts +9 -0
  98. package/dist/editors/builder-profile/components/SkillsSection.d.ts.map +1 -0
  99. package/dist/editors/builder-profile/components/SkillsSection.js +66 -0
  100. package/dist/editors/builder-profile/editor.d.ts +0 -2
  101. package/dist/editors/builder-profile/editor.d.ts.map +1 -1
  102. package/dist/editors/builder-profile/editor.js +216 -97
  103. package/dist/editors/builder-profile/module.d.ts +4 -0
  104. package/dist/editors/builder-profile/module.d.ts.map +1 -0
  105. package/dist/editors/builder-profile/module.js +10 -0
  106. package/dist/editors/editors.d.ts +3 -0
  107. package/dist/editors/editors.d.ts.map +1 -0
  108. package/dist/editors/editors.js +2 -0
  109. package/dist/editors/index.d.ts +1 -2
  110. package/dist/editors/index.d.ts.map +1 -1
  111. package/dist/editors/index.js +1 -1
  112. package/dist/index.d.ts +2 -2
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +2 -2
  115. package/dist/powerhouse.manifest.json +5 -13
  116. package/dist/processors/index.d.ts.map +1 -1
  117. package/dist/style.css +642 -4847
  118. package/dist/subgraphs/builder-profile/index.d.ts +2 -2
  119. package/dist/subgraphs/builder-profile/index.d.ts.map +1 -1
  120. package/dist/subgraphs/builder-profile/index.js +2 -2
  121. package/dist/subgraphs/builder-profile/resolvers.d.ts +2 -2
  122. package/dist/subgraphs/builder-profile/resolvers.d.ts.map +1 -1
  123. package/dist/subgraphs/builder-profile/resolvers.js +112 -4
  124. package/dist/subgraphs/builder-profile/schema.d.ts.map +1 -1
  125. package/dist/subgraphs/builder-profile/schema.js +119 -13
  126. package/dist/subgraphs/index.d.ts +0 -1
  127. package/dist/subgraphs/index.d.ts.map +1 -1
  128. package/dist/vite.config.d.ts +3 -0
  129. package/dist/vite.config.d.ts.map +1 -0
  130. package/dist/vite.config.js +13 -0
  131. package/package.json +56 -42
  132. package/dist/document-models/builder-profile/gen/builder/actions.d.ts +0 -8
  133. package/dist/document-models/builder-profile/gen/builder/actions.d.ts.map +0 -1
  134. package/dist/document-models/builder-profile/gen/builder/actions.js +0 -1
  135. package/dist/document-models/builder-profile/gen/builder/creators.d.ts +0 -4
  136. package/dist/document-models/builder-profile/gen/builder/creators.d.ts.map +0 -1
  137. package/dist/document-models/builder-profile/gen/builder/creators.js +0 -3
  138. package/dist/document-models/builder-profile/gen/builder/error.d.ts.map +0 -1
  139. package/dist/document-models/builder-profile/gen/builder/object.d.ts +0 -7
  140. package/dist/document-models/builder-profile/gen/builder/object.d.ts.map +0 -1
  141. package/dist/document-models/builder-profile/gen/builder/object.js +0 -7
  142. package/dist/document-models/builder-profile/gen/builder/operations.d.ts +0 -7
  143. package/dist/document-models/builder-profile/gen/builder/operations.d.ts.map +0 -1
  144. package/dist/document-models/builder-profile/gen/builder/operations.js +0 -1
  145. package/dist/document-models/builder-profile/gen/object.d.ts +0 -15
  146. package/dist/document-models/builder-profile/gen/object.d.ts.map +0 -1
  147. package/dist/document-models/builder-profile/gen/object.js +0 -25
  148. package/dist/document-models/builder-profile/src/reducers/builder.d.ts +0 -3
  149. package/dist/document-models/builder-profile/src/reducers/builder.d.ts.map +0 -1
  150. package/dist/document-models/builder-profile/src/reducers/builder.js +0 -9
  151. package/dist/document-models/builder-profile/src/tests/builder.test.d.ts +0 -2
  152. package/dist/document-models/builder-profile/src/tests/builder.test.d.ts.map +0 -1
  153. package/dist/document-models/builder-profile/src/tests/builder.test.js +0 -116
  154. package/dist/editors/builder-profile/index.d.ts +0 -3
  155. package/dist/editors/builder-profile/index.d.ts.map +0 -1
  156. package/dist/editors/builder-profile/index.js +0 -11
  157. package/dist/editors/hooks/useBuilderProfileDocument.d.ts +0 -4
  158. package/dist/editors/hooks/useBuilderProfileDocument.d.ts.map +0 -1
  159. package/dist/editors/hooks/useBuilderProfileDocument.js +0 -8
  160. /package/dist/document-models/builder-profile/gen/{builder → builders}/error.d.ts +0 -0
  161. /package/dist/document-models/builder-profile/gen/{builder → builders}/error.js +0 -0
@@ -0,0 +1,3 @@
1
+ import type { BuilderProfileBuildersOperations } from "@powerhousedao/builder-profile/document-models/builder-profile";
2
+ export declare const builderProfileBuildersOperations: BuilderProfileBuildersOperations;
3
+ //# sourceMappingURL=builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/reducers/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,gEAAgE,CAAC;AAEvH,eAAO,MAAM,gCAAgC,EAAE,gCAyG5C,CAAC"}
@@ -0,0 +1,108 @@
1
+ export const builderProfileBuildersOperations = {
2
+ updateProfileOperation(state, action) {
3
+ if (action.input.id)
4
+ state.id = action.input.id;
5
+ if (action.input.code)
6
+ state.code = action.input.code;
7
+ if (action.input.slug)
8
+ state.slug = action.input.slug;
9
+ if (action.input.name)
10
+ state.name = action.input.name;
11
+ if (action.input.icon)
12
+ state.icon = action.input.icon;
13
+ if (action.input.description)
14
+ state.description = action.input.description;
15
+ if (action.input.status)
16
+ state.status = action.input.status;
17
+ if (action.input.type)
18
+ state.type = action.input.type;
19
+ // Convert UTC timestamp (ms) to ISO string for storage
20
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
21
+ },
22
+ addSkillOperation(state, action) {
23
+ if (action.input.skill) {
24
+ if (!state.skilss.includes(action.input.skill)) {
25
+ state.skilss.push(action.input.skill);
26
+ }
27
+ }
28
+ // Convert UTC timestamp (ms) to ISO string for storage
29
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
30
+ },
31
+ removeSkillOperation(state, action) {
32
+ if (action.input.skill) {
33
+ const index = state.skilss.indexOf(action.input.skill);
34
+ if (index !== -1) {
35
+ state.skilss.splice(index, 1);
36
+ }
37
+ }
38
+ // Convert UTC timestamp (ms) to ISO string for storage
39
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
40
+ },
41
+ addScopeOperation(state, action) {
42
+ if (action.input.scope) {
43
+ if (!state.scopes.includes(action.input.scope)) {
44
+ state.scopes.push(action.input.scope);
45
+ }
46
+ }
47
+ // Convert UTC timestamp (ms) to ISO string for storage
48
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
49
+ },
50
+ removeScopeOperation(state, action) {
51
+ if (action.input.scope) {
52
+ const index = state.scopes.indexOf(action.input.scope);
53
+ if (index !== -1) {
54
+ state.scopes.splice(index, 1);
55
+ }
56
+ }
57
+ // Convert UTC timestamp (ms) to ISO string for storage
58
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
59
+ },
60
+ addLinkOperation(state, action) {
61
+ const newLink = {
62
+ id: action.input.id,
63
+ url: action.input.url,
64
+ label: action.input.label || null,
65
+ };
66
+ state.links.push(newLink);
67
+ // Convert UTC timestamp (ms) to ISO string for storage
68
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
69
+ },
70
+ editLinkOperation(state, action) {
71
+ const linkIndex = state.links.findIndex((link) => link.id === action.input.id);
72
+ if (linkIndex !== -1) {
73
+ if (action.input.url)
74
+ state.links[linkIndex].url = action.input.url;
75
+ if (action.input.label)
76
+ state.links[linkIndex].label = action.input.label;
77
+ }
78
+ // Convert UTC timestamp (ms) to ISO string for storage
79
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
80
+ },
81
+ removeLinkOperation(state, action) {
82
+ const linkIndex = state.links.findIndex((link) => link.id === action.input.id);
83
+ if (linkIndex !== -1) {
84
+ state.links.splice(linkIndex, 1);
85
+ }
86
+ // Convert UTC timestamp (ms) to ISO string for storage
87
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
88
+ },
89
+ addContributorOperation(state, action) {
90
+ if (action.input.contributorPHID) {
91
+ if (!state.contributors.includes(action.input.contributorPHID)) {
92
+ state.contributors.push(action.input.contributorPHID);
93
+ }
94
+ }
95
+ // Convert UTC timestamp (ms) to ISO string for storage
96
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
97
+ },
98
+ removeContributorOperation(state, action) {
99
+ if (action.input.contributorPHID) {
100
+ const index = state.contributors.indexOf(action.input.contributorPHID);
101
+ if (index !== -1) {
102
+ state.contributors.splice(index, 1);
103
+ }
104
+ }
105
+ // Convert UTC timestamp (ms) to ISO string for storage
106
+ state.lastModified = new Date(action.timestampUtcMs).toISOString();
107
+ },
108
+ };
@@ -0,0 +1,6 @@
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 {};
6
+ //# sourceMappingURL=builders.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/tests/builders.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,19 @@
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 { generateMock } from "@powerhousedao/codegen";
7
+ import { reducer, utils, isBuilderProfileDocument, updateProfile, UpdateProfileInputSchema, } from "@powerhousedao/builder-profile/document-models/builder-profile";
8
+ describe("Builders Operations", () => {
9
+ it("should handle updateProfile operation", () => {
10
+ const document = utils.createDocument();
11
+ const input = generateMock(UpdateProfileInputSchema());
12
+ const updatedDocument = reducer(document, updateProfile(input));
13
+ expect(isBuilderProfileDocument(updatedDocument)).toBe(true);
14
+ expect(updatedDocument.operations.global).toHaveLength(1);
15
+ expect(updatedDocument.operations.global[0].action.type).toBe("UPDATE_PROFILE");
16
+ expect(updatedDocument.operations.global[0].action.input).toStrictEqual(input);
17
+ expect(updatedDocument.operations.global[0].index).toEqual(0);
18
+ });
19
+ });
@@ -1,3 +1,7 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
1
5
  /**
2
6
  * This is a scaffold file meant for customization:
3
7
  * - change it by adding new tests or modifying the existing ones
@@ -1 +1 @@
1
- {"version":3,"file":"document-model.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/tests/document-model.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
1
+ {"version":3,"file":"document-model.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/tests/document-model.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;GAGG"}
@@ -1,18 +1,104 @@
1
+ /**
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
4
+ */
1
5
  /**
2
6
  * This is a scaffold file meant for customization:
3
7
  * - change it by adding new tests or modifying the existing ones
4
8
  */
5
9
  import { describe, it, expect } from "vitest";
6
- import utils, { initialGlobalState, initialLocalState, } from "../../gen/utils.js";
7
- describe("Builder Profile Document Model", () => {
8
- it("should create a new Builder Profile document", () => {
10
+ import { utils, initialGlobalState, initialLocalState, builderProfileDocumentType, isBuilderProfileDocument, assertIsBuilderProfileDocument, isBuilderProfileState, assertIsBuilderProfileState, } from "@powerhousedao/builder-profile/document-models/builder-profile";
11
+ import { ZodError } from "zod";
12
+ describe("BuilderProfile Document Model", () => {
13
+ it("should create a new BuilderProfile document", () => {
9
14
  const document = utils.createDocument();
10
15
  expect(document).toBeDefined();
11
- expect(document.header.documentType).toBe("powerhouse/builder-profile");
16
+ expect(document.header.documentType).toBe(builderProfileDocumentType);
12
17
  });
13
- it("should create a new Builder Profile document with a valid initial state", () => {
18
+ it("should create a new BuilderProfile document with a valid initial state", () => {
14
19
  const document = utils.createDocument();
15
20
  expect(document.state.global).toStrictEqual(initialGlobalState);
16
21
  expect(document.state.local).toStrictEqual(initialLocalState);
22
+ expect(isBuilderProfileDocument(document)).toBe(true);
23
+ expect(isBuilderProfileState(document.state)).toBe(true);
24
+ });
25
+ it("should reject a document that is not a BuilderProfile document", () => {
26
+ const wrongDocumentType = utils.createDocument();
27
+ wrongDocumentType.header.documentType = "the-wrong-thing-1234";
28
+ try {
29
+ expect(assertIsBuilderProfileDocument(wrongDocumentType)).toThrow();
30
+ expect(isBuilderProfileDocument(wrongDocumentType)).toBe(false);
31
+ }
32
+ catch (error) {
33
+ expect(error).toBeInstanceOf(ZodError);
34
+ }
17
35
  });
36
+ const wrongState = utils.createDocument();
37
+ // @ts-expect-error - we are testing the error case
38
+ wrongState.state.global = {
39
+ ...{ notWhat: "you want" },
40
+ };
41
+ try {
42
+ expect(isBuilderProfileState(wrongState.state)).toBe(false);
43
+ expect(assertIsBuilderProfileState(wrongState.state)).toThrow();
44
+ expect(isBuilderProfileDocument(wrongState)).toBe(false);
45
+ expect(assertIsBuilderProfileDocument(wrongState)).toThrow();
46
+ }
47
+ catch (error) {
48
+ expect(error).toBeInstanceOf(ZodError);
49
+ }
50
+ const wrongInitialState = utils.createDocument();
51
+ // @ts-expect-error - we are testing the error case
52
+ wrongInitialState.initialState.global = {
53
+ ...{ notWhat: "you want" },
54
+ };
55
+ try {
56
+ expect(isBuilderProfileState(wrongInitialState.state)).toBe(false);
57
+ expect(assertIsBuilderProfileState(wrongInitialState.state)).toThrow();
58
+ expect(isBuilderProfileDocument(wrongInitialState)).toBe(false);
59
+ expect(assertIsBuilderProfileDocument(wrongInitialState)).toThrow();
60
+ }
61
+ catch (error) {
62
+ expect(error).toBeInstanceOf(ZodError);
63
+ }
64
+ const missingIdInHeader = utils.createDocument();
65
+ // @ts-expect-error - we are testing the error case
66
+ delete missingIdInHeader.header.id;
67
+ try {
68
+ expect(isBuilderProfileDocument(missingIdInHeader)).toBe(false);
69
+ expect(assertIsBuilderProfileDocument(missingIdInHeader)).toThrow();
70
+ }
71
+ catch (error) {
72
+ expect(error).toBeInstanceOf(ZodError);
73
+ }
74
+ const missingNameInHeader = utils.createDocument();
75
+ // @ts-expect-error - we are testing the error case
76
+ delete missingNameInHeader.header.name;
77
+ try {
78
+ expect(isBuilderProfileDocument(missingNameInHeader)).toBe(false);
79
+ expect(assertIsBuilderProfileDocument(missingNameInHeader)).toThrow();
80
+ }
81
+ catch (error) {
82
+ expect(error).toBeInstanceOf(ZodError);
83
+ }
84
+ const missingCreatedAtUtcIsoInHeader = utils.createDocument();
85
+ // @ts-expect-error - we are testing the error case
86
+ delete missingCreatedAtUtcIsoInHeader.header.createdAtUtcIso;
87
+ try {
88
+ expect(isBuilderProfileDocument(missingCreatedAtUtcIsoInHeader)).toBe(false);
89
+ expect(assertIsBuilderProfileDocument(missingCreatedAtUtcIsoInHeader)).toThrow();
90
+ }
91
+ catch (error) {
92
+ expect(error).toBeInstanceOf(ZodError);
93
+ }
94
+ const missingLastModifiedAtUtcIsoInHeader = utils.createDocument();
95
+ // @ts-expect-error - we are testing the error case
96
+ delete missingLastModifiedAtUtcIsoInHeader.header.lastModifiedAtUtcIso;
97
+ try {
98
+ expect(isBuilderProfileDocument(missingLastModifiedAtUtcIsoInHeader)).toBe(false);
99
+ expect(assertIsBuilderProfileDocument(missingLastModifiedAtUtcIsoInHeader)).toThrow();
100
+ }
101
+ catch (error) {
102
+ expect(error).toBeInstanceOf(ZodError);
103
+ }
18
104
  });
@@ -0,0 +1,14 @@
1
+ import type { BuilderProfilePHState } from "./gen/types.js";
2
+ /** Utils for the BuilderProfile document model */
3
+ export declare const utils: {
4
+ fileExtension: string;
5
+ createState: import("document-model").CreateState<BuilderProfilePHState>;
6
+ createDocument: import("document-model").CreateDocument<BuilderProfilePHState>;
7
+ loadFromInput: import("document-model").LoadFromInput<BuilderProfilePHState>;
8
+ saveToFileHandle: import("document-model").SaveToFileHandle;
9
+ isStateOfType: import("document-model").IsStateOfType<BuilderProfilePHState>;
10
+ assertIsStateOfType: import("document-model").AssertIsStateOfType<BuilderProfilePHState>;
11
+ isDocumentOfType: import("document-model").IsDocumentOfType<BuilderProfilePHState>;
12
+ assertIsDocumentOfType: import("document-model").AssertIsDocumentOfType<BuilderProfilePHState>;
13
+ };
14
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../document-models/builder-profile/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAI5D,kDAAkD;AAClD,eAAO,MAAM,KAAK;;;;;;;;;;CAGmC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { utils as genUtils } from "./gen/utils.js";
2
+ import * as customUtils from "./src/utils.js";
3
+ /** Utils for the BuilderProfile document model */
4
+ export const utils = {
5
+ ...genUtils,
6
+ ...customUtils,
7
+ };
@@ -0,0 +1,3 @@
1
+ import type { DocumentModelModule } from "document-model";
2
+ export declare const documentModels: DocumentModelModule<any>[];
3
+ //# sourceMappingURL=document-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-models.d.ts","sourceRoot":"","sources":["../../document-models/document-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,eAAO,MAAM,cAAc,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAEpD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { BuilderProfile } from "./builder-profile/module.js";
2
+ export const documentModels = [
3
+ BuilderProfile,
4
+ ];
@@ -1,3 +1,2 @@
1
- export {};
2
- export { module as BuilderProfile } from "./builder-profile/index.js";
1
+ export { BuilderProfile } from "./builder-profile/module.js";
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../document-models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AACV,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../document-models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
@@ -1 +1 @@
1
- export { module as BuilderProfile } from "./builder-profile/index.js";
1
+ export { BuilderProfile } from "./builder-profile/module.js";
@@ -0,0 +1,8 @@
1
+ interface ContributorsSectionProps {
2
+ contributors: string[];
3
+ onAddContributor: (contributorPHID: string) => void;
4
+ onRemoveContributor: (contributorPHID: string) => void;
5
+ }
6
+ export declare function ContributorsSection({ contributors, onAddContributor, onRemoveContributor, }: ContributorsSectionProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=ContributorsSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContributorsSection.d.ts","sourceRoot":"","sources":["../../../../editors/builder-profile/components/ContributorsSection.tsx"],"names":[],"mappings":"AAyBA,UAAU,wBAAwB;IAChC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,mBAAmB,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,GACpB,EAAE,wBAAwB,2CA+O1B"}
@@ -0,0 +1,177 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useCallback } from "react";
3
+ import { useDrives, useGetDocuments } from "@powerhousedao/reactor-browser";
4
+ import { ObjectSetTable, PHIDInput, } from "@powerhousedao/document-engineering";
5
+ export function ContributorsSection({ contributors, onAddContributor, onRemoveContributor, }) {
6
+ const drives = useDrives();
7
+ // Map all builder profile FileNodes from all drives with their driveId
8
+ const builderProfileNodesWithDriveId = useMemo(() => {
9
+ if (!drives)
10
+ return [];
11
+ return drives.flatMap((drive) => {
12
+ const builderProfileNodes = drive.state.global.nodes.filter((node) => node.kind === "file" &&
13
+ "documentType" in node &&
14
+ node.documentType === "powerhouse/builder-profile");
15
+ return builderProfileNodes.map((node) => ({
16
+ node,
17
+ driveId: drive.header.id,
18
+ }));
19
+ });
20
+ }, [drives]);
21
+ // Get all unique builder PHIDs from the nodes
22
+ const builderPhids = useMemo(() => {
23
+ return builderProfileNodesWithDriveId.map(({ node }) => node.id);
24
+ }, [builderProfileNodesWithDriveId]);
25
+ // Fetch all builder profile documents from all drives
26
+ const builderProfileDocuments = useGetDocuments(builderPhids);
27
+ // Create a map of PHID to document for quick lookup
28
+ const builderProfileMap = useMemo(() => {
29
+ const map = new Map();
30
+ if (!builderProfileDocuments)
31
+ return map;
32
+ builderProfileDocuments.forEach((doc) => {
33
+ if (doc.header.documentType === "powerhouse/builder-profile") {
34
+ map.set(doc.header.id, doc);
35
+ }
36
+ });
37
+ return map;
38
+ }, [builderProfileDocuments]);
39
+ // Helper function to get builder profile documents from all drives
40
+ const getBuilderProfiles = useCallback(() => {
41
+ return builderProfileNodesWithDriveId.map(({ node }) => {
42
+ const doc = builderProfileMap.get(node.id);
43
+ const name = doc?.state?.global?.name || node.name || node.id;
44
+ return {
45
+ id: node.id,
46
+ label: name,
47
+ value: node.id,
48
+ title: name,
49
+ };
50
+ });
51
+ }, [builderProfileNodesWithDriveId, builderProfileMap]);
52
+ // Helper function to get builder profile data by PHID from all drives
53
+ const getBuilderProfileByPhid = useCallback((phid) => {
54
+ const doc = builderProfileMap.get(phid);
55
+ if (!doc)
56
+ return null;
57
+ return {
58
+ name: doc.state.global?.name || doc.header.id,
59
+ slug: doc.state.global?.slug || doc.header.id,
60
+ icon: doc.state.global?.icon || null,
61
+ };
62
+ }, [builderProfileMap]);
63
+ const contributorData = useMemo(() => {
64
+ return contributors.map((phid) => {
65
+ const profile = getBuilderProfileByPhid(phid);
66
+ return {
67
+ phid: phid,
68
+ name: profile?.name || "",
69
+ slug: profile?.slug || "",
70
+ icon: profile?.icon || null,
71
+ };
72
+ });
73
+ }, [contributors, getBuilderProfileByPhid]);
74
+ const columns = useMemo(() => [
75
+ {
76
+ field: "phid",
77
+ title: "PHID",
78
+ editable: true,
79
+ align: "center",
80
+ width: 200,
81
+ onSave: (newValue, context) => {
82
+ const currentId = context.row.phid || "";
83
+ if (newValue !== currentId && newValue && currentId) {
84
+ // First remove the old contributor
85
+ onRemoveContributor(currentId);
86
+ // Then add the new contributor with the new PHID
87
+ onAddContributor(newValue);
88
+ return true;
89
+ }
90
+ return false;
91
+ },
92
+ renderCellEditor: (value, onChange, context) => (_jsx(PHIDInput, { value: value || "", onChange: (newValue) => {
93
+ onChange(newValue);
94
+ }, onBlur: (e) => {
95
+ const newValue = e.target.value;
96
+ const currentValue = value || "";
97
+ // If a PHID is entered and it's different from current value
98
+ if (newValue && newValue !== currentValue) {
99
+ const existingContributor = contributors.find((contributor) => contributor === newValue);
100
+ if (!existingContributor) {
101
+ // If we're editing an existing row (has an ID), remove the old one first
102
+ if (context.row.phid && context.row.phid !== newValue) {
103
+ onRemoveContributor(context.row.phid);
104
+ }
105
+ // Add the new contributor
106
+ onAddContributor(newValue);
107
+ }
108
+ }
109
+ }, placeholder: "Enter PHID", className: "w-full", variant: "withValueAndTitle", initialOptions: getBuilderProfiles(), fetchOptionsCallback: (userInput) => {
110
+ const builderProfiles = getBuilderProfiles();
111
+ // Filter profiles based on user input
112
+ if (!userInput.trim()) {
113
+ return Promise.resolve(builderProfiles);
114
+ }
115
+ const filteredProfiles = builderProfiles.filter((profile) => profile.label
116
+ .toLowerCase()
117
+ .includes(userInput.toLowerCase()) ||
118
+ profile.id.toLowerCase().includes(userInput.toLowerCase()));
119
+ return Promise.resolve(filteredProfiles);
120
+ } })),
121
+ renderCell: (value) => {
122
+ if (value === "" || !value) {
123
+ return (_jsx("div", { className: "font-light italic text-gray-500 text-center", children: "+ Double-click to add new contributor (enter or click outside to save)" }));
124
+ }
125
+ return _jsx("div", { className: "text-center font-mono text-sm", children: value });
126
+ },
127
+ },
128
+ {
129
+ field: "name",
130
+ title: "Name",
131
+ editable: false,
132
+ align: "center",
133
+ width: 200,
134
+ renderCell: (value) => {
135
+ return _jsx("div", { className: "text-center", children: value });
136
+ },
137
+ },
138
+ {
139
+ field: "slug",
140
+ title: "Slug",
141
+ editable: false,
142
+ align: "center",
143
+ width: 200,
144
+ renderCell: (value) => {
145
+ return _jsx("div", { className: "text-center", children: value });
146
+ },
147
+ },
148
+ {
149
+ field: "icon",
150
+ title: "Icon",
151
+ editable: false,
152
+ align: "center",
153
+ width: 150,
154
+ renderCell: (_value, context) => {
155
+ if (!context.row.icon) {
156
+ return null;
157
+ }
158
+ return (_jsx("div", { className: "text-center", children: _jsx("img", { src: context.row.icon, alt: "Contributor icon", className: "w-10 h-10 rounded-sm mx-auto object-cover", onError: (e) => {
159
+ e.currentTarget.style.display = "none";
160
+ } }) }));
161
+ },
162
+ },
163
+ ], [contributors, getBuilderProfiles, onAddContributor, onRemoveContributor]);
164
+ return (_jsxs("div", { className: "bg-white rounded-lg p-6 shadow-sm", children: [_jsx("h3", { className: "text-lg font-medium text-gray-900 mb-4", children: "Contributors" }), _jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Add team members to your builder profile. Search for existing builder profiles by name or PHID." }), _jsx(ObjectSetTable, { columns: columns, data: contributorData, allowRowSelection: true, onDelete: (data) => {
165
+ if (data.length > 0) {
166
+ data.forEach((d) => {
167
+ onRemoveContributor(d.phid);
168
+ });
169
+ }
170
+ }, onAdd: (data) => {
171
+ // Only add if we have a PHID
172
+ const phid = data.id;
173
+ if (phid) {
174
+ onAddContributor(phid);
175
+ }
176
+ } })] }));
177
+ }
@@ -0,0 +1,9 @@
1
+ interface ImageUrlInputProps {
2
+ label: string;
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ placeholder?: string;
6
+ }
7
+ export declare function ImageUrlInput({ label, value, onChange, placeholder, }: ImageUrlInputProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=ImageUrlInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageUrlInput.d.ts","sourceRoot":"","sources":["../../../../editors/builder-profile/components/ImageUrlInput.tsx"],"names":[],"mappings":"AA0EA,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,GACZ,EAAE,kBAAkB,2CA4FpB"}
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { TextInput, Icon } from "@powerhousedao/document-engineering";
4
+ function ImageModal({ isOpen, onClose, imageUrl, imageAlt }) {
5
+ const [imageLoaded, setImageLoaded] = useState(false);
6
+ const [imageDimensions, setImageDimensions] = useState({
7
+ width: 0,
8
+ height: 0,
9
+ });
10
+ if (!isOpen)
11
+ return null;
12
+ const handleImageLoad = (e) => {
13
+ const img = e.target;
14
+ setImageDimensions({ width: img.naturalWidth, height: img.naturalHeight });
15
+ setImageLoaded(true);
16
+ };
17
+ const getModalSize = () => {
18
+ if (!imageLoaded)
19
+ return { width: "auto", height: "auto" };
20
+ const maxWidth = Math.min(imageDimensions.width + 100, window.innerWidth * 0.8);
21
+ const maxHeight = Math.min(imageDimensions.height + 100, window.innerHeight * 0.8);
22
+ return {
23
+ width: `${maxWidth}px`,
24
+ height: `${maxHeight}px`,
25
+ };
26
+ };
27
+ return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center backdrop-blur-sm", onClick: onClose, children: _jsxs("div", { className: "relative bg-gray-900 rounded-lg shadow-2xl border-2 border-gray-700", style: getModalSize(), children: [_jsx("button", { onClick: onClose, className: "absolute -top-3 -right-3 z-10 w-8 h-8 bg-gray-800 hover:bg-gray-900 rounded-full flex items-center justify-center text-white transition-all duration-200 shadow-lg", children: _jsx(Icon, { name: "Xmark", size: 16 }) }), _jsx("div", { className: "w-full h-full flex items-center justify-center p-8", children: _jsx("img", { src: imageUrl, alt: imageAlt, className: `max-w-full max-h-full object-contain rounded-lg ${imageLoaded ? "opacity-100" : "opacity-0"} transition-opacity duration-200`, onClick: (e) => e.stopPropagation(), onLoad: handleImageLoad }) })] }) }));
28
+ }
29
+ export function ImageUrlInput({ label, value, onChange, placeholder, }) {
30
+ const [imageError, setImageError] = useState(false);
31
+ const [isModalOpen, setIsModalOpen] = useState(false);
32
+ useEffect(() => {
33
+ setImageError(false);
34
+ }, [value]);
35
+ const handleImageClick = () => {
36
+ if (value &&
37
+ !imageError &&
38
+ (value.startsWith("http://") || value.startsWith("https://"))) {
39
+ setIsModalOpen(true);
40
+ }
41
+ };
42
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-2", children: [_jsx("label", { className: "block text-sm font-medium text-gray-700", children: label }), _jsxs("div", { className: "border border-gray-300 rounded-lg p-4", children: [_jsx("div", { className: "flex items-center justify-between", children: _jsxs("div", { className: "flex items-center space-x-3", children: [_jsx("div", { className: `flex-shrink-0 w-12 h-12 bg-gray-100 rounded border flex items-center justify-center overflow-hidden ${value &&
43
+ !imageError &&
44
+ (value.startsWith("http://") || value.startsWith("https://"))
45
+ ? "cursor-pointer hover:opacity-80 transition-opacity duration-200"
46
+ : ""}`, onClick: handleImageClick, children: value &&
47
+ !imageError &&
48
+ (value.startsWith("http://") ||
49
+ value.startsWith("https://")) ? (_jsx("img", { src: value, alt: `${label} preview`, className: "w-full h-full object-cover", onError: () => setImageError(true), onLoad: () => setImageError(false) })) : (_jsx(Icon, { name: "Image", size: 24, className: "text-gray-400" })) }), _jsx("div", { className: "flex-1 min-w-0", children: _jsxs("div", { className: "text-xs text-gray-500", children: [imageError && value && (_jsx("div", { className: "text-red-500", children: "Failed to load image" })), value &&
50
+ !imageError &&
51
+ (value.startsWith("http://") ||
52
+ value.startsWith("https://")) && (_jsx("div", { className: "text-blue-600", children: "Click image to view full size" }))] }) })] }) }), _jsx("div", { className: "mt-3", children: _jsx(TextInput, { className: "w-full", defaultValue: value || "", onBlur: (e) => {
53
+ if (e.target.value !== value) {
54
+ onChange(e.target.value);
55
+ }
56
+ }, placeholder: placeholder || "Enter image URL" }) })] })] }), _jsx(ImageModal, { isOpen: isModalOpen, onClose: () => setIsModalOpen(false), imageUrl: value, imageAlt: `${label} full size` })] }));
57
+ }
@@ -0,0 +1,18 @@
1
+ import type { BuilderLink } from "../../../document-models/builder-profile/gen/types.js";
2
+ interface LinksSectionProps {
3
+ links: BuilderLink[];
4
+ onAddLink: (link: {
5
+ id: string;
6
+ url: string;
7
+ label?: string;
8
+ }) => void;
9
+ onEditLink: (link: {
10
+ id: string;
11
+ url: string;
12
+ label?: string;
13
+ }) => void;
14
+ onRemoveLink: (id: string) => void;
15
+ }
16
+ export declare function LinksSection({ links, onAddLink, onEditLink, onRemoveLink, }: LinksSectionProps): import("react/jsx-runtime").JSX.Element;
17
+ export {};
18
+ //# sourceMappingURL=LinksSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinksSection.d.ts","sourceRoot":"","sources":["../../../../editors/builder-profile/components/LinksSection.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uDAAuD,CAAC;AAEzF,UAAU,iBAAiB;IACzB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,SAAS,EAAE,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACvE,UAAU,EAAE,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAYD,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,SAAS,EACT,UAAU,EACV,YAAY,GACb,EAAE,iBAAiB,2CAgOnB"}