@powerhousedao/builder-profile 0.0.2 → 0.0.3

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 (111) hide show
  1. package/dist/document-models/builder-profile/actions.d.ts +13 -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/builder/actions.js +1 -1
  5. package/dist/document-models/builder-profile/gen/builder/creators.d.ts +2 -2
  6. package/dist/document-models/builder-profile/gen/builder/creators.d.ts.map +1 -1
  7. package/dist/document-models/builder-profile/gen/builder/creators.js +3 -3
  8. package/dist/document-models/builder-profile/gen/builder/operations.js +3 -1
  9. package/dist/document-models/builder-profile/gen/creators.d.ts +1 -0
  10. package/dist/document-models/builder-profile/gen/creators.d.ts.map +1 -1
  11. package/dist/document-models/builder-profile/gen/creators.js +1 -0
  12. package/dist/document-models/builder-profile/gen/document-model.d.ts +2 -2
  13. package/dist/document-models/builder-profile/gen/document-model.d.ts.map +1 -1
  14. package/dist/document-models/builder-profile/gen/document-model.js +23 -23
  15. package/dist/document-models/builder-profile/gen/document-schema.d.ts +218 -0
  16. package/dist/document-models/builder-profile/gen/document-schema.d.ts.map +1 -0
  17. package/dist/document-models/builder-profile/gen/document-schema.js +33 -0
  18. package/dist/document-models/builder-profile/gen/document-type.d.ts +2 -0
  19. package/dist/document-models/builder-profile/gen/document-type.d.ts.map +1 -0
  20. package/dist/document-models/builder-profile/gen/document-type.js +1 -0
  21. package/dist/document-models/builder-profile/gen/index.d.ts +7 -3
  22. package/dist/document-models/builder-profile/gen/index.d.ts.map +1 -1
  23. package/dist/document-models/builder-profile/gen/index.js +7 -2
  24. package/dist/document-models/builder-profile/gen/ph-factories.d.ts +6 -10
  25. package/dist/document-models/builder-profile/gen/ph-factories.d.ts.map +1 -1
  26. package/dist/document-models/builder-profile/gen/ph-factories.js +1 -4
  27. package/dist/document-models/builder-profile/gen/reducer.d.ts +1 -3
  28. package/dist/document-models/builder-profile/gen/reducer.d.ts.map +1 -1
  29. package/dist/document-models/builder-profile/gen/reducer.js +6 -9
  30. package/dist/document-models/builder-profile/gen/schema/index.d.ts +1 -1
  31. package/dist/document-models/builder-profile/gen/schema/index.d.ts.map +1 -1
  32. package/dist/document-models/builder-profile/gen/schema/index.js +1 -1
  33. package/dist/document-models/builder-profile/gen/types.d.ts +9 -7
  34. package/dist/document-models/builder-profile/gen/types.d.ts.map +1 -1
  35. package/dist/document-models/builder-profile/gen/types.js +1 -1
  36. package/dist/document-models/builder-profile/gen/utils.d.ts +13 -20
  37. package/dist/document-models/builder-profile/gen/utils.d.ts.map +1 -1
  38. package/dist/document-models/builder-profile/gen/utils.js +45 -36
  39. package/dist/document-models/builder-profile/hooks.d.ts +11 -0
  40. package/dist/document-models/builder-profile/hooks.d.ts.map +1 -0
  41. package/dist/document-models/builder-profile/hooks.js +26 -0
  42. package/dist/document-models/builder-profile/index.d.ts +5 -20
  43. package/dist/document-models/builder-profile/index.d.ts.map +1 -1
  44. package/dist/document-models/builder-profile/index.js +5 -17
  45. package/dist/document-models/builder-profile/module.d.ts +5 -0
  46. package/dist/document-models/builder-profile/module.d.ts.map +1 -0
  47. package/dist/document-models/builder-profile/module.js +10 -0
  48. package/dist/document-models/builder-profile/src/index.d.ts +2 -0
  49. package/dist/document-models/builder-profile/src/index.d.ts.map +1 -0
  50. package/dist/document-models/builder-profile/src/index.js +1 -0
  51. package/dist/document-models/builder-profile/src/reducers/builder.d.ts +2 -2
  52. package/dist/document-models/builder-profile/src/reducers/builder.d.ts.map +1 -1
  53. package/dist/document-models/builder-profile/src/reducers/builder.js +2 -2
  54. package/dist/document-models/builder-profile/src/tests/builder.test.d.ts +4 -0
  55. package/dist/document-models/builder-profile/src/tests/builder.test.d.ts.map +1 -1
  56. package/dist/document-models/builder-profile/src/tests/builder.test.js +14 -111
  57. package/dist/document-models/builder-profile/src/tests/document-model.test.d.ts +4 -0
  58. package/dist/document-models/builder-profile/src/tests/document-model.test.d.ts.map +1 -1
  59. package/dist/document-models/builder-profile/src/tests/document-model.test.js +91 -5
  60. package/dist/document-models/builder-profile/utils.d.ts +14 -0
  61. package/dist/document-models/builder-profile/utils.d.ts.map +1 -0
  62. package/dist/document-models/builder-profile/utils.js +7 -0
  63. package/dist/document-models/document-models.d.ts +3 -0
  64. package/dist/document-models/document-models.d.ts.map +1 -0
  65. package/dist/document-models/document-models.js +2 -0
  66. package/dist/document-models/index.d.ts +5 -2
  67. package/dist/document-models/index.d.ts.map +1 -1
  68. package/dist/document-models/index.js +5 -1
  69. package/dist/editors/builder-profile/editor.d.ts +0 -2
  70. package/dist/editors/builder-profile/editor.d.ts.map +1 -1
  71. package/dist/editors/builder-profile/editor.js +26 -19
  72. package/dist/editors/builder-profile/module.d.ts +4 -0
  73. package/dist/editors/builder-profile/module.d.ts.map +1 -0
  74. package/dist/editors/builder-profile/module.js +10 -0
  75. package/dist/editors/editors.d.ts +3 -0
  76. package/dist/editors/editors.d.ts.map +1 -0
  77. package/dist/editors/editors.js +2 -0
  78. package/dist/editors/index.d.ts +5 -2
  79. package/dist/editors/index.d.ts.map +1 -1
  80. package/dist/editors/index.js +5 -1
  81. package/dist/index.d.ts +2 -2
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/powerhouse.manifest.json +7 -20
  84. package/dist/processors/index.d.ts.map +1 -1
  85. package/dist/style.css +108 -5029
  86. package/dist/subgraphs/builder-profile/index.d.ts +2 -2
  87. package/dist/subgraphs/builder-profile/index.d.ts.map +1 -1
  88. package/dist/subgraphs/builder-profile/index.js +2 -2
  89. package/dist/subgraphs/builder-profile/resolvers.d.ts +2 -2
  90. package/dist/subgraphs/builder-profile/resolvers.d.ts.map +1 -1
  91. package/dist/subgraphs/builder-profile/resolvers.js +4 -4
  92. package/dist/subgraphs/builder-profile/schema.d.ts.map +1 -1
  93. package/dist/subgraphs/builder-profile/schema.js +1 -12
  94. package/dist/subgraphs/index.d.ts +0 -1
  95. package/dist/subgraphs/index.d.ts.map +1 -1
  96. package/dist/vite.config.d.ts +3 -0
  97. package/dist/vite.config.d.ts.map +1 -0
  98. package/dist/vite.config.js +13 -0
  99. package/package.json +55 -45
  100. package/dist/document-models/builder-profile/gen/builder/object.d.ts +0 -7
  101. package/dist/document-models/builder-profile/gen/builder/object.d.ts.map +0 -1
  102. package/dist/document-models/builder-profile/gen/builder/object.js +0 -7
  103. package/dist/document-models/builder-profile/gen/object.d.ts +0 -15
  104. package/dist/document-models/builder-profile/gen/object.d.ts.map +0 -1
  105. package/dist/document-models/builder-profile/gen/object.js +0 -25
  106. package/dist/editors/builder-profile/index.d.ts +0 -3
  107. package/dist/editors/builder-profile/index.d.ts.map +0 -1
  108. package/dist/editors/builder-profile/index.js +0 -11
  109. package/dist/editors/hooks/useBuilderProfileDocument.d.ts +0 -4
  110. package/dist/editors/hooks/useBuilderProfileDocument.d.ts.map +0 -1
  111. package/dist/editors/hooks/useBuilderProfileDocument.js +0 -8
@@ -1,22 +1,15 @@
1
- import { type CreateDocument, type CreateState, type LoadFromFile, type LoadFromInput } from "document-model";
2
- import { type BuilderProfileState, type BuilderProfileLocalState } from "./types.js";
3
- import { BuilderProfilePHState } from "./ph-factories.js";
4
- export declare const initialGlobalState: BuilderProfileState;
1
+ import type { DocumentModelUtils } from "document-model";
2
+ import type { BuilderProfileGlobalState, BuilderProfileLocalState } from "./types.js";
3
+ import type { BuilderProfilePHState } from "./types.js";
4
+ export declare const initialGlobalState: BuilderProfileGlobalState;
5
5
  export declare const initialLocalState: BuilderProfileLocalState;
6
- export declare const createState: CreateState<BuilderProfilePHState>;
7
- export declare const createDocument: CreateDocument<BuilderProfilePHState>;
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<BuilderProfilePHState>;
11
- export declare const loadFromInput: LoadFromInput<BuilderProfilePHState>;
12
- declare const utils: {
13
- fileExtension: string;
14
- createState: CreateState<BuilderProfilePHState>;
15
- createDocument: CreateDocument<BuilderProfilePHState>;
16
- saveToFile: (document: any, path: string, name?: string) => Promise<string>;
17
- saveToFileHandle: (document: any, input: any) => Promise<void>;
18
- loadFromFile: LoadFromFile<BuilderProfilePHState>;
19
- loadFromInput: LoadFromInput<BuilderProfilePHState>;
20
- };
21
- export default utils;
6
+ export declare const utils: DocumentModelUtils<BuilderProfilePHState>;
7
+ export declare const createDocument: import("document-model").CreateDocument<BuilderProfilePHState>;
8
+ export declare const createState: import("document-model").CreateState<BuilderProfilePHState>;
9
+ export declare const saveToFileHandle: import("document-model").SaveToFileHandle;
10
+ export declare const loadFromInput: import("document-model").LoadFromInput<BuilderProfilePHState>;
11
+ export declare const isStateOfType: import("document-model").IsStateOfType<BuilderProfilePHState>;
12
+ export declare const assertIsStateOfType: import("document-model").AssertIsStateOfType<BuilderProfilePHState>;
13
+ export declare const isDocumentOfType: import("document-model").IsDocumentOfType<BuilderProfilePHState>;
14
+ export declare const assertIsDocumentOfType: import("document-model").AssertIsDocumentOfType<BuilderProfilePHState>;
22
15
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../document-models/builder-profile/gen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAQnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,kBAAkB,EAAE,mBAMhC,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,wBAA6B,CAAC;AAE9D,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,qBAAqB,CAM1D,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,qBAAqB,CAQhE,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,GAAG,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,oBAEpE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,GAAG,EAAE,OAAO,GAAG,kBAEzD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,qBAAqB,CAE5D,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,qBAAqB,CAE9D,CAAC;AAEF,QAAA,MAAM,KAAK;;;;2BAhB0B,GAAG,QAAQ,MAAM,SAAS,MAAM;iCAI1B,GAAG,SAAS,GAAG;;;CAoBzD,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../document-models/builder-profile/gen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQzD,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAUxD,eAAO,MAAM,kBAAkB,EAAE,yBAMhC,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,wBAA6B,CAAC;AAE9D,eAAO,MAAM,KAAK,EAAE,kBAAkB,CAAC,qBAAqB,CAqC3D,CAAC;AAEF,eAAO,MAAM,cAAc,gEAAuB,CAAC;AACnD,eAAO,MAAM,WAAW,6DAAoB,CAAC;AAC7C,eAAO,MAAM,gBAAgB,2CAAyB,CAAC;AACvD,eAAO,MAAM,aAAa,+DAAsB,CAAC;AACjD,eAAO,MAAM,aAAa,+DAAsB,CAAC;AACjD,eAAO,MAAM,mBAAmB,qEAA4B,CAAC;AAC7D,eAAO,MAAM,gBAAgB,kEAAyB,CAAC;AACvD,eAAO,MAAM,sBAAsB,wEAA+B,CAAC"}
@@ -1,5 +1,7 @@
1
- import { baseCreateDocument, baseSaveToFile, baseSaveToFileHandle, baseLoadFromFile, baseLoadFromInput, defaultBaseState, generateId, } from "document-model";
1
+ import { baseCreateDocument, baseSaveToFileHandle, baseLoadFromInput, defaultBaseState, generateId, } from "document-model/core";
2
2
  import { reducer } from "./reducer.js";
3
+ import { builderProfileDocumentType } from "./document-type.js";
4
+ import { isBuilderProfileDocument, assertIsBuilderProfileDocument, isBuilderProfileState, assertIsBuilderProfileState, } from "./document-schema.js";
3
5
  export const initialGlobalState = {
4
6
  id: null,
5
7
  slug: null,
@@ -8,39 +10,46 @@ export const initialGlobalState = {
8
10
  description: null,
9
11
  };
10
12
  export const initialLocalState = {};
11
- export const createState = (state) => {
12
- return {
13
- ...defaultBaseState(),
14
- global: { ...initialGlobalState, ...(state?.global ?? {}) },
15
- local: { ...initialLocalState, ...(state?.local ?? {}) },
16
- };
17
- };
18
- export const createDocument = (state) => {
19
- const document = baseCreateDocument(createState, state);
20
- document.header.documentType = "powerhouse/builder-profile";
21
- // for backwards compatibility, but this is NOT a valid signed document id
22
- document.header.id = generateId();
23
- return document;
24
- };
25
- export const saveToFile = (document, path, name) => {
26
- return baseSaveToFile(document, path, ".phdm", name);
27
- };
28
- export const saveToFileHandle = (document, input) => {
29
- return baseSaveToFileHandle(document, input);
30
- };
31
- export const loadFromFile = (path) => {
32
- return baseLoadFromFile(path, reducer);
33
- };
34
- export const loadFromInput = (input) => {
35
- return baseLoadFromInput(input, reducer);
36
- };
37
- const utils = {
13
+ export const utils = {
38
14
  fileExtension: ".phdm",
39
- createState,
40
- createDocument,
41
- saveToFile,
42
- saveToFileHandle,
43
- loadFromFile,
44
- loadFromInput,
45
- };
46
- export default utils;
15
+ createState(state) {
16
+ return {
17
+ ...defaultBaseState(),
18
+ global: { ...initialGlobalState, ...state?.global },
19
+ local: { ...initialLocalState, ...state?.local },
20
+ };
21
+ },
22
+ createDocument(state) {
23
+ const document = baseCreateDocument(utils.createState, state);
24
+ document.header.documentType = builderProfileDocumentType;
25
+ // for backwards compatibility, but this is NOT a valid signed document id
26
+ document.header.id = generateId();
27
+ return document;
28
+ },
29
+ saveToFileHandle(document, input) {
30
+ return baseSaveToFileHandle(document, input);
31
+ },
32
+ loadFromInput(input) {
33
+ return baseLoadFromInput(input, reducer);
34
+ },
35
+ isStateOfType(state) {
36
+ return isBuilderProfileState(state);
37
+ },
38
+ assertIsStateOfType(state) {
39
+ return assertIsBuilderProfileState(state);
40
+ },
41
+ isDocumentOfType(document) {
42
+ return isBuilderProfileDocument(document);
43
+ },
44
+ assertIsDocumentOfType(document) {
45
+ return assertIsBuilderProfileDocument(document);
46
+ },
47
+ };
48
+ export const createDocument = utils.createDocument;
49
+ export const createState = utils.createState;
50
+ export const saveToFileHandle = utils.saveToFileHandle;
51
+ export const loadFromInput = utils.loadFromInput;
52
+ export const isStateOfType = utils.isStateOfType;
53
+ export const assertIsStateOfType = utils.assertIsStateOfType;
54
+ export const isDocumentOfType = utils.isDocumentOfType;
55
+ export const assertIsDocumentOfType = utils.assertIsDocumentOfType;
@@ -0,0 +1,11 @@
1
+ import type { DocumentDispatch } from "@powerhousedao/reactor-browser";
2
+ import type { BuilderProfileDocument, BuilderProfileAction } from "@powerhousedao/builder-profile/document-models/builder-profile";
3
+ /** Hook to get a BuilderProfile document by its id */
4
+ export declare function useBuilderProfileDocumentById(documentId: string | null | undefined): [BuilderProfileDocument, DocumentDispatch<BuilderProfileAction>] | [undefined, undefined];
5
+ /** Hook to get the selected BuilderProfile document */
6
+ export declare function useSelectedBuilderProfileDocument(): [BuilderProfileDocument, DocumentDispatch<BuilderProfileAction>] | [undefined, undefined];
7
+ /** Hook to get all BuilderProfile documents in the selected drive */
8
+ export declare function useBuilderProfileDocumentsInSelectedDrive(): BuilderProfileDocument[] | undefined;
9
+ /** Hook to get all BuilderProfile documents in the selected folder */
10
+ export declare function useBuilderProfileDocumentsInSelectedFolder(): BuilderProfileDocument[] | undefined;
11
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../document-models/builder-profile/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAOvE,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,gEAAgE,CAAC;AAGxE,sDAAsD;AACtD,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAEnC,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,SAAS,CAAC,CAIzB;AAED,uDAAuD;AACvD,wBAAgB,iCAAiC,IAC7C,CAAC,sBAAsB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,GAChE,CAAC,SAAS,EAAE,SAAS,CAAC,CAIzB;AAED,qEAAqE;AACrE,wBAAgB,yCAAyC,yCAGxD;AAED,sEAAsE;AACtE,wBAAgB,0CAA0C,yCAGzD"}
@@ -0,0 +1,26 @@
1
+ import { useDocumentsInSelectedDrive, useDocumentsInSelectedFolder, useDocumentById, useSelectedDocument, } from "@powerhousedao/reactor-browser";
2
+ import { isBuilderProfileDocument } from "./gen/document-schema.js";
3
+ /** Hook to get a BuilderProfile document by its id */
4
+ export function useBuilderProfileDocumentById(documentId) {
5
+ const [document, dispatch] = useDocumentById(documentId);
6
+ if (!isBuilderProfileDocument(document))
7
+ return [undefined, undefined];
8
+ return [document, dispatch];
9
+ }
10
+ /** Hook to get the selected BuilderProfile document */
11
+ export function useSelectedBuilderProfileDocument() {
12
+ const [document, dispatch] = useSelectedDocument();
13
+ if (!isBuilderProfileDocument(document))
14
+ return [undefined, undefined];
15
+ return [document, dispatch];
16
+ }
17
+ /** Hook to get all BuilderProfile documents in the selected drive */
18
+ export function useBuilderProfileDocumentsInSelectedDrive() {
19
+ const documentsInSelectedDrive = useDocumentsInSelectedDrive();
20
+ return documentsInSelectedDrive?.filter(isBuilderProfileDocument);
21
+ }
22
+ /** Hook to get all BuilderProfile documents in the selected folder */
23
+ export function useBuilderProfileDocumentsInSelectedFolder() {
24
+ const documentsInSelectedFolder = useDocumentsInSelectedFolder();
25
+ return documentsInSelectedFolder?.filter(isBuilderProfileDocument);
26
+ }
@@ -2,24 +2,9 @@
2
2
  * This is a scaffold file meant for customization.
3
3
  * Delete the file and run the code generator again to have it reset
4
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 { BuilderProfilePHState } from "./gen/ph-factories.js";
9
- declare const utils: {
10
- fileExtension: string;
11
- createState: import("document-model").CreateState<BuilderProfilePHState>;
12
- createDocument: import("document-model").CreateDocument<BuilderProfilePHState>;
13
- saveToFile: (document: any, path: string, name?: string) => Promise<string>;
14
- saveToFileHandle: (document: any, input: any) => Promise<void>;
15
- loadFromFile: import("document-model").LoadFromFile<BuilderProfilePHState>;
16
- loadFromInput: import("document-model").LoadFromInput<BuilderProfilePHState>;
17
- };
18
- declare const actions: {
19
- updateProfile: (input: import("./gen/index.js").UpdateProfileInput) => import("./gen/index.js").UpdateProfileAction;
20
- };
21
- export declare const module: DocumentModelModule<BuilderProfilePHState>;
22
- export { reducer, actions, utils, documentModel };
23
- export * from "./gen/types.js";
24
- export * from "./src/utils.js";
5
+ export * from "./gen/index.js";
6
+ export * from "./src/index.js";
7
+ export * from "./hooks.js";
8
+ export { actions } from "./actions.js";
9
+ export { utils } from "./utils.js";
25
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../document-models/builder-profile/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,QAAA,MAAM,KAAK;;;;;;;;CAAkC,CAAC;AAC9C,QAAA,MAAM,OAAO;oBATb,kDACA;CAQ4D,CAAC;AAE7D,eAAO,MAAM,MAAM,EAAE,mBAAmB,CAAC,qBAAqB,CAK7D,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAElD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../document-models/builder-profile/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -2,20 +2,8 @@
2
2
  * This is a scaffold file meant for customization.
3
3
  * Delete the file and run the code generator again to have it reset
4
4
  */
5
- import { actions as BaseActions, } from "document-model";
6
- import { actions as BuilderProfileActions } 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, ...BuilderProfileActions };
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";
5
+ export * from "./gen/index.js";
6
+ export * from "./src/index.js";
7
+ export * from "./hooks.js";
8
+ export { actions } from "./actions.js";
9
+ export { utils } from "./utils.js";
@@ -0,0 +1,5 @@
1
+ import type { DocumentModelModule } from "document-model";
2
+ import type { BuilderProfilePHState } from "@powerhousedao/builder-profile/document-models/builder-profile";
3
+ /** Document model module for the Todo List document type */
4
+ export declare const BuilderProfile: DocumentModelModule<BuilderProfilePHState>;
5
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../document-models/builder-profile/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AAQ5G,4DAA4D;AAC5D,eAAO,MAAM,cAAc,EAAE,mBAAmB,CAAC,qBAAqB,CAKrE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { createState } from "document-model";
2
+ import { defaultBaseState } from "document-model/core";
3
+ import { actions, documentModel, reducer, utils, } from "@powerhousedao/builder-profile/document-models/builder-profile";
4
+ /** Document model module for the Todo List document type */
5
+ export const BuilderProfile = {
6
+ reducer,
7
+ actions,
8
+ utils,
9
+ documentModel: createState(defaultBaseState(), documentModel),
10
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./utils.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../document-models/builder-profile/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./utils.js";
@@ -1,3 +1,3 @@
1
- import type { BuilderProfileBuilderOperations } from "../../gen/builder/operations.js";
2
- export declare const reducer: BuilderProfileBuilderOperations;
1
+ import type { BuilderProfileBuilderOperations } from "@powerhousedao/builder-profile/document-models/builder-profile";
2
+ export declare const builderProfileBuilderOperations: BuilderProfileBuilderOperations;
3
3
  //# sourceMappingURL=builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/reducers/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AAEvF,eAAO,MAAM,OAAO,EAAE,+BAQrB,CAAC"}
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/reducers/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gEAAgE,CAAC;AAEtH,eAAO,MAAM,+BAA+B,EAAE,+BAQ7C,CAAC"}
@@ -1,5 +1,5 @@
1
- export const reducer = {
2
- updateProfileOperation(state, action, dispatch) {
1
+ export const builderProfileBuilderOperations = {
2
+ updateProfileOperation(state, action) {
3
3
  state.id = action.input.id ?? state.id;
4
4
  state.slug = action.input.slug ?? state.slug;
5
5
  state.name = action.input.name ?? state.name;
@@ -1,2 +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
+ */
1
5
  export {};
2
6
  //# sourceMappingURL=builder.test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/tests/builder.test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"builder.test.d.ts","sourceRoot":"","sources":["../../../../../document-models/builder-profile/src/tests/builder.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,116 +1,19 @@
1
- import { describe, it, expect, beforeEach } from "vitest";
2
- import utils from "../../gen/utils.js";
3
- import { reducer } from "../../gen/reducer.js";
4
- import * as creators from "../../gen/builder/creators.js";
5
- import { z } from "../../gen/schema/index.js";
6
1
  /**
7
- * BuilderProfile Document Model: Comprehensive Tests
8
- * Focus: PHID and URL field validation, update, and expected behaviors
2
+ * This is a scaffold file meant for customization:
3
+ * - change it by adding new tests or modifying the existing ones
9
4
  */
10
- const VALID_PHID = "phd:baefc2a4-f9a0-4950-8161-fd8d8cc7dea7";
11
- const VALID_URL = "https://powerhouse.inc/icon.png";
12
- const INVALID_PHID = "invalid:format:phid";
13
- const INVALID_URL = "not-a-url";
14
- describe("BuilderProfile Document Model", () => {
15
- let document;
16
- beforeEach(() => {
17
- document = utils.createDocument();
18
- });
19
- it("should accept a valid PHID and URL in updateProfile", () => {
20
- const input = {
21
- id: VALID_PHID,
22
- slug: "builder-slug",
23
- name: "Builder Name",
24
- icon: VALID_URL,
25
- description: "A valid builder description"
26
- };
27
- // Should not throw during reducer/update
28
- const updatedDocument = reducer(document, creators.updateProfile(input));
29
- // Check operation appended with strict equality
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("Builder 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);
30
14
  expect(updatedDocument.operations.global).toHaveLength(1);
31
- const op = updatedDocument.operations.global[0];
32
- expect(op.action.type).toBe("UPDATE_PROFILE");
33
- expect(op.action.input).toStrictEqual(input);
34
- // Ensure the PHID and URL fields persisted in state
35
- expect(updatedDocument.state.global.id).toBe(VALID_PHID);
36
- expect(updatedDocument.state.global.icon).toBe(VALID_URL);
37
- });
38
- it("should reject an invalid PHID using Zod validation", () => {
39
- const input = {
40
- id: INVALID_PHID,
41
- slug: "builder-slug",
42
- name: "Builder Name",
43
- icon: VALID_URL,
44
- description: "should fail phid"
45
- };
46
- // Zod parsing should throw
47
- expect(() => z.UpdateProfileInputSchema().parse(input)).toThrow();
48
- });
49
- it("should reject an invalid URL using Zod validation", () => {
50
- const input = {
51
- id: VALID_PHID,
52
- slug: "builder-slug",
53
- name: "Builder Name",
54
- icon: INVALID_URL,
55
- description: "should fail url"
56
- };
57
- // Zod parsing should throw
58
- expect(() => z.UpdateProfileInputSchema().parse(input)).toThrow();
59
- });
60
- it("should update only the URL and PHID fields if only they are provided", () => {
61
- // The rest of the state is initialized to undefined by utils.createDocument()
62
- // Set initial values
63
- const initialInput = {
64
- id: VALID_PHID,
65
- slug: "slug-main",
66
- name: "Initial Name",
67
- icon: VALID_URL,
68
- description: "Initial desc"
69
- };
70
- let currDoc = reducer(document, creators.updateProfile(initialInput));
71
- // Now, update only id and icon
72
- const updateInput = {
73
- id: "phd:12345678-1111-2222-3333-abcdefabcdef:main:public",
74
- icon: "https://updated-url.com/icon.svg"
75
- };
76
- currDoc = reducer(currDoc, creators.updateProfile(updateInput));
77
- // id & icon changed, others remain
78
- expect(currDoc.state.global.id).toBe(updateInput.id);
79
- expect(currDoc.state.global.icon).toBe(updateInput.icon);
80
- expect(currDoc.state.global.slug).toBe(initialInput.slug);
81
- expect(currDoc.state.global.name).toBe(initialInput.name);
82
- expect(currDoc.state.global.description).toBe(initialInput.description);
83
- });
84
- it("should allow updateProfile with partial inputs, always keeping PHID format valid", () => {
85
- // Start with valid state
86
- const initialState = {
87
- id: VALID_PHID,
88
- slug: "val-slug",
89
- name: "val-name",
90
- icon: VALID_URL,
91
- description: "val desc"
92
- };
93
- let doc = reducer(document, creators.updateProfile(initialState));
94
- // Now update only slug
95
- const partialInput = {
96
- slug: "new-slug"
97
- };
98
- doc = reducer(doc, creators.updateProfile(partialInput));
99
- // id is preserved and still valid PHID
100
- expect(doc.state.global.id).toBe(VALID_PHID);
101
- // slug should update
102
- expect(doc.state.global.slug).toBe("new-slug");
103
- });
104
- it("should throw if after a partial update the PHID is not valid", () => {
105
- // Start with bad PHID in state
106
- document.state.global.id = INVALID_PHID;
107
- const input = {
108
- slug: "doesnt-matter"
109
- };
110
- // Can't validate via reducer, so check with zod directly
111
- expect(() => z.BuilderProfileStateSchema().parse({
112
- ...document.state,
113
- ...input
114
- })).toThrow();
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);
115
18
  });
116
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,EAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { BuilderProfile } from "./builder-profile/module.js";
2
+ export const documentModels = [BuilderProfile];
@@ -1,3 +1,6 @@
1
- export {};
2
- export { module as BuilderProfile } from "./builder-profile/index.js";
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
+ export { BuilderProfile } from "./builder-profile/module.js";
3
6
  //# 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;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}