@powerhousedao/notes-demo-package 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +179 -0
- package/dist/document-models/index.d.ts +3 -0
- package/dist/document-models/index.d.ts.map +1 -0
- package/dist/document-models/index.js +2 -0
- package/dist/document-models/notes/gen/actions.d.ts +4 -0
- package/dist/document-models/notes/gen/actions.d.ts.map +1 -0
- package/dist/document-models/notes/gen/actions.js +1 -0
- package/dist/document-models/notes/gen/creators.d.ts +2 -0
- package/dist/document-models/notes/gen/creators.d.ts.map +1 -0
- package/dist/document-models/notes/gen/creators.js +1 -0
- package/dist/document-models/notes/gen/document-model.d.ts +3 -0
- package/dist/document-models/notes/gen/document-model.d.ts.map +1 -0
- package/dist/document-models/notes/gen/document-model.js +103 -0
- package/dist/document-models/notes/gen/index.d.ts +6 -0
- package/dist/document-models/notes/gen/index.d.ts.map +1 -0
- package/dist/document-models/notes/gen/index.js +5 -0
- package/dist/document-models/notes/gen/notes/actions.d.ts +28 -0
- package/dist/document-models/notes/gen/notes/actions.d.ts.map +1 -0
- package/dist/document-models/notes/gen/notes/actions.js +1 -0
- package/dist/document-models/notes/gen/notes/creators.d.ts +9 -0
- package/dist/document-models/notes/gen/notes/creators.d.ts.map +1 -0
- package/dist/document-models/notes/gen/notes/creators.js +9 -0
- package/dist/document-models/notes/gen/notes/error.d.ts +2 -0
- package/dist/document-models/notes/gen/notes/error.d.ts.map +1 -0
- package/dist/document-models/notes/gen/notes/error.js +1 -0
- package/dist/document-models/notes/gen/notes/operations.d.ts +12 -0
- package/dist/document-models/notes/gen/notes/operations.d.ts.map +1 -0
- package/dist/document-models/notes/gen/notes/operations.js +3 -0
- package/dist/document-models/notes/gen/ph-factories.d.ts +23 -0
- package/dist/document-models/notes/gen/ph-factories.d.ts.map +1 -0
- package/dist/document-models/notes/gen/ph-factories.js +47 -0
- package/dist/document-models/notes/gen/reducer.d.ts +5 -0
- package/dist/document-models/notes/gen/reducer.d.ts.map +1 -0
- package/dist/document-models/notes/gen/reducer.js +37 -0
- package/dist/document-models/notes/gen/schema/index.d.ts +3 -0
- package/dist/document-models/notes/gen/schema/index.d.ts.map +1 -0
- package/dist/document-models/notes/gen/schema/index.js +2 -0
- package/dist/document-models/notes/gen/schema/types.d.ts +190 -0
- package/dist/document-models/notes/gen/schema/types.d.ts.map +1 -0
- package/dist/document-models/notes/gen/schema/types.js +1 -0
- package/dist/document-models/notes/gen/schema/zod.d.ts +50 -0
- package/dist/document-models/notes/gen/schema/zod.d.ts.map +1 -0
- package/dist/document-models/notes/gen/schema/zod.js +76 -0
- package/dist/document-models/notes/gen/types.d.ts +13 -0
- package/dist/document-models/notes/gen/types.d.ts.map +1 -0
- package/dist/document-models/notes/gen/types.js +2 -0
- package/dist/document-models/notes/gen/utils.d.ts +12 -0
- package/dist/document-models/notes/gen/utils.d.ts.map +1 -0
- package/dist/document-models/notes/gen/utils.js +34 -0
- package/dist/document-models/notes/index.d.ts +36 -0
- package/dist/document-models/notes/index.d.ts.map +1 -0
- package/dist/document-models/notes/index.js +22 -0
- package/dist/document-models/notes/src/reducers/notes.d.ts +3 -0
- package/dist/document-models/notes/src/reducers/notes.d.ts.map +1 -0
- package/dist/document-models/notes/src/reducers/notes.js +69 -0
- package/dist/document-models/notes/src/tests/document-model.test.d.ts +6 -0
- package/dist/document-models/notes/src/tests/document-model.test.d.ts.map +1 -0
- package/dist/document-models/notes/src/tests/document-model.test.js +18 -0
- package/dist/document-models/notes/src/tests/notes.test.d.ts +6 -0
- package/dist/document-models/notes/src/tests/notes.test.d.ts.map +1 -0
- package/dist/document-models/notes/src/tests/notes.test.js +32 -0
- package/dist/document-models/notes/src/utils.d.ts +2 -0
- package/dist/document-models/notes/src/utils.d.ts.map +1 -0
- package/dist/document-models/notes/src/utils.js +1 -0
- package/dist/editors/hooks/useNotesDocument.d.ts +4 -0
- package/dist/editors/hooks/useNotesDocument.d.ts.map +1 -0
- package/dist/editors/hooks/useNotesDocument.js +7 -0
- package/dist/editors/index.d.ts +3 -0
- package/dist/editors/index.d.ts.map +1 -0
- package/dist/editors/index.js +2 -0
- package/dist/editors/notes-editor/components/NoteList.d.ts +11 -0
- package/dist/editors/notes-editor/components/NoteList.d.ts.map +1 -0
- package/dist/editors/notes-editor/components/NoteList.js +5 -0
- package/dist/editors/notes-editor/components/NoteListItem.d.ts +9 -0
- package/dist/editors/notes-editor/components/NoteListItem.d.ts.map +1 -0
- package/dist/editors/notes-editor/components/NoteListItem.js +5 -0
- package/dist/editors/notes-editor/components/TextNoteEditor.d.ts +13 -0
- package/dist/editors/notes-editor/components/TextNoteEditor.d.ts.map +1 -0
- package/dist/editors/notes-editor/components/TextNoteEditor.js +29 -0
- package/dist/editors/notes-editor/components/TodoNoteEditor.d.ts +13 -0
- package/dist/editors/notes-editor/components/TodoNoteEditor.d.ts.map +1 -0
- package/dist/editors/notes-editor/components/TodoNoteEditor.js +34 -0
- package/dist/editors/notes-editor/editor.d.ts +2 -0
- package/dist/editors/notes-editor/editor.d.ts.map +1 -0
- package/dist/editors/notes-editor/editor.js +61 -0
- package/dist/editors/notes-editor/index.d.ts +3 -0
- package/dist/editors/notes-editor/index.d.ts.map +1 -0
- package/dist/editors/notes-editor/index.js +9 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/powerhouse.manifest.json +27 -0
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.d.ts.map +1 -0
- package/dist/processors/index.js +1 -0
- package/dist/style.css +656 -0
- package/dist/subgraphs/index.d.ts +3 -0
- package/dist/subgraphs/index.d.ts.map +1 -0
- package/dist/subgraphs/index.js +2 -0
- package/dist/subgraphs/notes/index.d.ts +11 -0
- package/dist/subgraphs/notes/index.d.ts.map +1 -0
- package/dist/subgraphs/notes/index.js +11 -0
- package/dist/subgraphs/notes/resolvers.d.ts +3 -0
- package/dist/subgraphs/notes/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/notes/resolvers.js +144 -0
- package/dist/subgraphs/notes/schema.d.ts +3 -0
- package/dist/subgraphs/notes/schema.d.ts.map +1 -0
- package/dist/subgraphs/notes/schema.js +80 -0
- package/dist/subgraphs/notes copy/index.d.ts +11 -0
- package/dist/subgraphs/notes copy/index.d.ts.map +1 -0
- package/dist/subgraphs/notes copy/index.js +11 -0
- package/dist/subgraphs/notes copy/resolvers.d.ts +3 -0
- package/dist/subgraphs/notes copy/resolvers.d.ts.map +1 -0
- package/dist/subgraphs/notes copy/resolvers.js +156 -0
- package/dist/subgraphs/notes copy/schema.d.ts +3 -0
- package/dist/subgraphs/notes copy/schema.d.ts.map +1 -0
- package/dist/subgraphs/notes copy/schema.js +80 -0
- package/dist/vite.config.d.ts +3 -0
- package/dist/vite.config.d.ts.map +1 -0
- package/dist/vite.config.js +13 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +8 -0
- package/package.json +118 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { addFile } from "document-drive";
|
|
2
|
+
import { actions, } from "../../document-models/notes/index.js";
|
|
3
|
+
import { setName } from "document-model";
|
|
4
|
+
export const getResolvers = (subgraph) => {
|
|
5
|
+
const reactor = subgraph.reactor;
|
|
6
|
+
return {
|
|
7
|
+
Query: {
|
|
8
|
+
Notes: async () => {
|
|
9
|
+
return {
|
|
10
|
+
getDocument: async (args) => {
|
|
11
|
+
const { docId, driveId } = args;
|
|
12
|
+
if (!docId) {
|
|
13
|
+
throw new Error("Document id is required");
|
|
14
|
+
}
|
|
15
|
+
if (driveId) {
|
|
16
|
+
const docIds = await reactor.getDocuments(driveId);
|
|
17
|
+
if (!docIds.includes(docId)) {
|
|
18
|
+
throw new Error(`Document with id ${docId} is not part of ${driveId}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const doc = await reactor.getDocument(docId);
|
|
22
|
+
return {
|
|
23
|
+
driveId: driveId,
|
|
24
|
+
...doc,
|
|
25
|
+
...doc.header,
|
|
26
|
+
created: doc.header.createdAtUtcIso,
|
|
27
|
+
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
28
|
+
state: doc.state.global,
|
|
29
|
+
stateJSON: doc.state.global,
|
|
30
|
+
revision: doc.header?.revision?.global ?? 0,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
getDocuments: async (args) => {
|
|
34
|
+
const { driveId } = args;
|
|
35
|
+
const docsIds = await reactor.getDocuments(driveId);
|
|
36
|
+
const docs = await Promise.all(docsIds.map(async (docId) => {
|
|
37
|
+
const doc = await reactor.getDocument(docId);
|
|
38
|
+
return {
|
|
39
|
+
driveId: driveId,
|
|
40
|
+
...doc,
|
|
41
|
+
...doc.header,
|
|
42
|
+
created: doc.header.createdAtUtcIso,
|
|
43
|
+
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
44
|
+
state: doc.state.global,
|
|
45
|
+
stateJSON: doc.state.global,
|
|
46
|
+
revision: doc.header?.revision?.global ?? 0,
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
return docs.filter((doc) => doc.header.documentType === "powerhouse/notes");
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
Mutation: {
|
|
55
|
+
Notes_createDocument: async (_, args) => {
|
|
56
|
+
const { driveId, name } = args;
|
|
57
|
+
const document = await reactor.addDocument("powerhouse/notes");
|
|
58
|
+
if (driveId) {
|
|
59
|
+
await reactor.addAction(driveId, addFile({
|
|
60
|
+
name,
|
|
61
|
+
id: document.header.id,
|
|
62
|
+
documentType: "powerhouse/notes",
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
if (name) {
|
|
66
|
+
await reactor.addAction(document.header.id, setName(name));
|
|
67
|
+
}
|
|
68
|
+
return document.header.id;
|
|
69
|
+
},
|
|
70
|
+
Notes_addText: async (_, args) => {
|
|
71
|
+
const { docId, input } = args;
|
|
72
|
+
const doc = await reactor.getDocument(docId);
|
|
73
|
+
if (!doc) {
|
|
74
|
+
throw new Error("Document not found");
|
|
75
|
+
}
|
|
76
|
+
const result = await reactor.addAction(docId, actions.addText(input));
|
|
77
|
+
if (result.status !== "SUCCESS") {
|
|
78
|
+
throw new Error(result.error?.message ?? "Failed to addText");
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
},
|
|
82
|
+
Notes_addTodo: async (_, args) => {
|
|
83
|
+
const { docId, input } = args;
|
|
84
|
+
const doc = await reactor.getDocument(docId);
|
|
85
|
+
if (!doc) {
|
|
86
|
+
throw new Error("Document not found");
|
|
87
|
+
}
|
|
88
|
+
const result = await reactor.addAction(docId, actions.addTodo(input));
|
|
89
|
+
if (result.status !== "SUCCESS") {
|
|
90
|
+
throw new Error(result.error?.message ?? "Failed to addTodo");
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
},
|
|
94
|
+
Notes_editNote: async (_, args) => {
|
|
95
|
+
const { docId, input } = args;
|
|
96
|
+
const doc = await reactor.getDocument(docId);
|
|
97
|
+
if (!doc) {
|
|
98
|
+
throw new Error("Document not found");
|
|
99
|
+
}
|
|
100
|
+
const result = await reactor.addAction(docId, actions.editNote(input));
|
|
101
|
+
if (result.status !== "SUCCESS") {
|
|
102
|
+
throw new Error(result.error?.message ?? "Failed to editNote");
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
},
|
|
106
|
+
Notes_editText: async (_, args) => {
|
|
107
|
+
const { docId, input } = args;
|
|
108
|
+
const doc = await reactor.getDocument(docId);
|
|
109
|
+
if (!doc) {
|
|
110
|
+
throw new Error("Document not found");
|
|
111
|
+
}
|
|
112
|
+
const result = await reactor.addAction(docId, actions.editText(input));
|
|
113
|
+
if (result.status !== "SUCCESS") {
|
|
114
|
+
throw new Error(result.error?.message ?? "Failed to editText");
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
Notes_editTodo: async (_, args) => {
|
|
119
|
+
const { docId, input } = args;
|
|
120
|
+
const doc = await reactor.getDocument(docId);
|
|
121
|
+
if (!doc) {
|
|
122
|
+
throw new Error("Document not found");
|
|
123
|
+
}
|
|
124
|
+
const result = await reactor.addAction(docId, actions.editTodo(input));
|
|
125
|
+
if (result.status !== "SUCCESS") {
|
|
126
|
+
throw new Error(result.error?.message ?? "Failed to editTodo");
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
},
|
|
130
|
+
Notes_deleteNote: async (_, args) => {
|
|
131
|
+
const { docId, input } = args;
|
|
132
|
+
const doc = await reactor.getDocument(docId);
|
|
133
|
+
if (!doc) {
|
|
134
|
+
throw new Error("Document not found");
|
|
135
|
+
}
|
|
136
|
+
const result = await reactor.addAction(docId, actions.deleteNote(input));
|
|
137
|
+
if (result.status !== "SUCCESS") {
|
|
138
|
+
throw new Error(result.error?.message ?? "Failed to deleteNote");
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/notes/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YA8EpB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
export const schema = gql `
|
|
3
|
+
"""
|
|
4
|
+
Queries: Notes Document
|
|
5
|
+
"""
|
|
6
|
+
type NotesQueries {
|
|
7
|
+
getDocument(docId: PHID!, driveId: PHID): Notes
|
|
8
|
+
getDocuments(driveId: String!): [Notes!]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Query {
|
|
12
|
+
Notes: NotesQueries
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
Mutations: Notes
|
|
17
|
+
"""
|
|
18
|
+
type Mutation {
|
|
19
|
+
Notes_createDocument(name: String!, driveId: String): String
|
|
20
|
+
|
|
21
|
+
Notes_addText(driveId: String, docId: PHID, input: Notes_AddTextInput): Int
|
|
22
|
+
Notes_addTodo(driveId: String, docId: PHID, input: Notes_AddTodoInput): Int
|
|
23
|
+
Notes_editNote(
|
|
24
|
+
driveId: String
|
|
25
|
+
docId: PHID
|
|
26
|
+
input: Notes_EditNoteInput
|
|
27
|
+
): Int
|
|
28
|
+
Notes_editText(
|
|
29
|
+
driveId: String
|
|
30
|
+
docId: PHID
|
|
31
|
+
input: Notes_EditTextInput
|
|
32
|
+
): Int
|
|
33
|
+
Notes_editTodo(
|
|
34
|
+
driveId: String
|
|
35
|
+
docId: PHID
|
|
36
|
+
input: Notes_EditTodoInput
|
|
37
|
+
): Int
|
|
38
|
+
Notes_deleteNote(
|
|
39
|
+
driveId: String
|
|
40
|
+
docId: PHID
|
|
41
|
+
input: Notes_DeleteNoteInput
|
|
42
|
+
): Int
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
Module: Notes
|
|
47
|
+
"""
|
|
48
|
+
input Notes_AddTextInput {
|
|
49
|
+
id: OID!
|
|
50
|
+
title: String!
|
|
51
|
+
date: Date!
|
|
52
|
+
content: String!
|
|
53
|
+
}
|
|
54
|
+
input Notes_AddTodoInput {
|
|
55
|
+
id: OID!
|
|
56
|
+
title: String!
|
|
57
|
+
date: Date!
|
|
58
|
+
done: Boolean!
|
|
59
|
+
}
|
|
60
|
+
input Notes_EditNoteInput {
|
|
61
|
+
id: OID!
|
|
62
|
+
title: String
|
|
63
|
+
date: Date
|
|
64
|
+
}
|
|
65
|
+
input Notes_EditTextInput {
|
|
66
|
+
id: OID!
|
|
67
|
+
title: String
|
|
68
|
+
date: Date
|
|
69
|
+
content: String
|
|
70
|
+
}
|
|
71
|
+
input Notes_EditTodoInput {
|
|
72
|
+
id: OID!
|
|
73
|
+
title: String
|
|
74
|
+
date: Date
|
|
75
|
+
done: Boolean
|
|
76
|
+
}
|
|
77
|
+
input Notes_DeleteNoteInput {
|
|
78
|
+
id: OID!
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import type { DocumentNode } from "graphql";
|
|
3
|
+
export declare class NotesCopySubgraph extends BaseSubgraph {
|
|
4
|
+
name: string;
|
|
5
|
+
typeDefs: DocumentNode;
|
|
6
|
+
resolvers: Record<string, unknown>;
|
|
7
|
+
additionalContextFields: {};
|
|
8
|
+
onSetup(): Promise<void>;
|
|
9
|
+
onDisconnect(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/notes copy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,IAAI,SAAgB;IACpB,QAAQ,EAAE,YAAY,CAAU;IAChC,SAAS,0BAAsB;IAC/B,uBAAuB,KAAM;IACvB,OAAO;IACP,YAAY;CACnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
+
import { schema } from "./schema.js";
|
|
3
|
+
import { getResolvers } from "./resolvers.js";
|
|
4
|
+
export class NotesCopySubgraph extends BaseSubgraph {
|
|
5
|
+
name = "notes-copy";
|
|
6
|
+
typeDefs = schema;
|
|
7
|
+
resolvers = getResolvers(this);
|
|
8
|
+
additionalContextFields = {};
|
|
9
|
+
async onSetup() { }
|
|
10
|
+
async onDisconnect() { }
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/notes copy/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAoB/D,eAAO,MAAM,YAAY,GACvB,UAAU,YAAY,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAwNxB,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { addFile } from "document-drive";
|
|
2
|
+
import { actions, } from "../../document-models/notes/index.js";
|
|
3
|
+
import { setName } from "document-model";
|
|
4
|
+
import { NoteSchema, TextSchema, TodoSchema, } from "../../document-models/notes/gen/schema/zod.js";
|
|
5
|
+
export const getResolvers = (subgraph) => {
|
|
6
|
+
const reactor = subgraph.reactor;
|
|
7
|
+
return {
|
|
8
|
+
Notes_Note: {
|
|
9
|
+
__resolveType(obj) {
|
|
10
|
+
if (TextSchema().safeParse(obj).success) {
|
|
11
|
+
return "Notes_Text";
|
|
12
|
+
}
|
|
13
|
+
if (TodoSchema().safeParse(obj).success) {
|
|
14
|
+
return "Notes_Todo";
|
|
15
|
+
}
|
|
16
|
+
return "Notes_INote";
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
Query: {
|
|
20
|
+
Notes: async () => {
|
|
21
|
+
return {
|
|
22
|
+
getDocument: async (args) => {
|
|
23
|
+
const { docId, driveId } = args;
|
|
24
|
+
if (!docId) {
|
|
25
|
+
throw new Error("Document id is required");
|
|
26
|
+
}
|
|
27
|
+
if (driveId) {
|
|
28
|
+
const docIds = await reactor.getDocuments(driveId);
|
|
29
|
+
if (!docIds.includes(docId)) {
|
|
30
|
+
throw new Error(`Document with id ${docId} is not part of ${driveId}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const doc = await reactor.getDocument(docId);
|
|
34
|
+
return {
|
|
35
|
+
driveId: driveId,
|
|
36
|
+
...doc,
|
|
37
|
+
...doc.header,
|
|
38
|
+
created: doc.header.createdAtUtcIso,
|
|
39
|
+
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
40
|
+
state: doc.state.global,
|
|
41
|
+
stateJSON: doc.state.global,
|
|
42
|
+
revision: doc.header?.revision?.global ?? 0,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
getDocuments: async (args) => {
|
|
46
|
+
const { driveId } = args;
|
|
47
|
+
const docsIds = await reactor.getDocuments(driveId);
|
|
48
|
+
const docs = await Promise.all(docsIds.map(async (docId) => {
|
|
49
|
+
const doc = await reactor.getDocument(docId);
|
|
50
|
+
return {
|
|
51
|
+
driveId: driveId,
|
|
52
|
+
...doc,
|
|
53
|
+
...doc.header,
|
|
54
|
+
created: doc.header.createdAtUtcIso,
|
|
55
|
+
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
56
|
+
state: doc.state.global,
|
|
57
|
+
stateJSON: doc.state.global,
|
|
58
|
+
revision: doc.header?.revision?.global ?? 0,
|
|
59
|
+
};
|
|
60
|
+
}));
|
|
61
|
+
return docs.filter((doc) => doc.header.documentType === "powerhouse/notes");
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
Mutation: {
|
|
67
|
+
Notes_createDocument: async (_, args) => {
|
|
68
|
+
const { driveId, name } = args;
|
|
69
|
+
const document = await reactor.addDocument("powerhouse/notes");
|
|
70
|
+
if (driveId) {
|
|
71
|
+
await reactor.addAction(driveId, addFile({
|
|
72
|
+
name,
|
|
73
|
+
id: document.header.id,
|
|
74
|
+
documentType: "powerhouse/notes",
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
if (name) {
|
|
78
|
+
await reactor.addAction(document.header.id, setName(name));
|
|
79
|
+
}
|
|
80
|
+
return document.header.id;
|
|
81
|
+
},
|
|
82
|
+
Notes_addText: async (_, args) => {
|
|
83
|
+
const { docId, input } = args;
|
|
84
|
+
const doc = await reactor.getDocument(docId);
|
|
85
|
+
if (!doc) {
|
|
86
|
+
throw new Error("Document not found");
|
|
87
|
+
}
|
|
88
|
+
const result = await reactor.addAction(docId, actions.addText(input));
|
|
89
|
+
if (result.status !== "SUCCESS") {
|
|
90
|
+
throw new Error(result.error?.message ?? "Failed to addText");
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
},
|
|
94
|
+
Notes_addTodo: async (_, args) => {
|
|
95
|
+
const { docId, input } = args;
|
|
96
|
+
const doc = await reactor.getDocument(docId);
|
|
97
|
+
if (!doc) {
|
|
98
|
+
throw new Error("Document not found");
|
|
99
|
+
}
|
|
100
|
+
const result = await reactor.addAction(docId, actions.addTodo(input));
|
|
101
|
+
if (result.status !== "SUCCESS") {
|
|
102
|
+
throw new Error(result.error?.message ?? "Failed to addTodo");
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
},
|
|
106
|
+
Notes_editNote: async (_, args) => {
|
|
107
|
+
const { docId, input } = args;
|
|
108
|
+
const doc = await reactor.getDocument(docId);
|
|
109
|
+
if (!doc) {
|
|
110
|
+
throw new Error("Document not found");
|
|
111
|
+
}
|
|
112
|
+
const result = await reactor.addAction(docId, actions.editNote(input));
|
|
113
|
+
if (result.status !== "SUCCESS") {
|
|
114
|
+
throw new Error(result.error?.message ?? "Failed to editNote");
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
Notes_editText: async (_, args) => {
|
|
119
|
+
const { docId, input } = args;
|
|
120
|
+
const doc = await reactor.getDocument(docId);
|
|
121
|
+
if (!doc) {
|
|
122
|
+
throw new Error("Document not found");
|
|
123
|
+
}
|
|
124
|
+
const result = await reactor.addAction(docId, actions.editText(input));
|
|
125
|
+
if (result.status !== "SUCCESS") {
|
|
126
|
+
throw new Error(result.error?.message ?? "Failed to editText");
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
},
|
|
130
|
+
Notes_editTodo: async (_, args) => {
|
|
131
|
+
const { docId, input } = args;
|
|
132
|
+
const doc = await reactor.getDocument(docId);
|
|
133
|
+
if (!doc) {
|
|
134
|
+
throw new Error("Document not found");
|
|
135
|
+
}
|
|
136
|
+
const result = await reactor.addAction(docId, actions.editTodo(input));
|
|
137
|
+
if (result.status !== "SUCCESS") {
|
|
138
|
+
throw new Error(result.error?.message ?? "Failed to editTodo");
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
},
|
|
142
|
+
Notes_deleteNote: async (_, args) => {
|
|
143
|
+
const { docId, input } = args;
|
|
144
|
+
const doc = await reactor.getDocument(docId);
|
|
145
|
+
if (!doc) {
|
|
146
|
+
throw new Error("Document not found");
|
|
147
|
+
}
|
|
148
|
+
const result = await reactor.addAction(docId, actions.deleteNote(input));
|
|
149
|
+
if (result.status !== "SUCCESS") {
|
|
150
|
+
throw new Error(result.error?.message ?? "Failed to deleteNote");
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/notes copy/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YA8EpB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
export const schema = gql `
|
|
3
|
+
"""
|
|
4
|
+
Queries: Notes Document
|
|
5
|
+
"""
|
|
6
|
+
type NotesQueries {
|
|
7
|
+
getDocument(docId: PHID!, driveId: PHID): Notes
|
|
8
|
+
getDocuments(driveId: String!): [Notes!]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Query {
|
|
12
|
+
Notes: NotesQueries
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
Mutations: Notes
|
|
17
|
+
"""
|
|
18
|
+
type Mutation {
|
|
19
|
+
Notes_createDocument(name: String!, driveId: String): String
|
|
20
|
+
|
|
21
|
+
Notes_addText(driveId: String, docId: PHID, input: Notes_AddTextInput): Int
|
|
22
|
+
Notes_addTodo(driveId: String, docId: PHID, input: Notes_AddTodoInput): Int
|
|
23
|
+
Notes_editNote(
|
|
24
|
+
driveId: String
|
|
25
|
+
docId: PHID
|
|
26
|
+
input: Notes_EditNoteInput
|
|
27
|
+
): Int
|
|
28
|
+
Notes_editText(
|
|
29
|
+
driveId: String
|
|
30
|
+
docId: PHID
|
|
31
|
+
input: Notes_EditTextInput
|
|
32
|
+
): Int
|
|
33
|
+
Notes_editTodo(
|
|
34
|
+
driveId: String
|
|
35
|
+
docId: PHID
|
|
36
|
+
input: Notes_EditTodoInput
|
|
37
|
+
): Int
|
|
38
|
+
Notes_deleteNote(
|
|
39
|
+
driveId: String
|
|
40
|
+
docId: PHID
|
|
41
|
+
input: Notes_DeleteNoteInput
|
|
42
|
+
): Int
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
Module: Notes
|
|
47
|
+
"""
|
|
48
|
+
input Notes_AddTextInput {
|
|
49
|
+
id: OID!
|
|
50
|
+
title: String!
|
|
51
|
+
date: Date!
|
|
52
|
+
content: String!
|
|
53
|
+
}
|
|
54
|
+
input Notes_AddTodoInput {
|
|
55
|
+
id: OID!
|
|
56
|
+
title: String!
|
|
57
|
+
date: Date!
|
|
58
|
+
done: Boolean!
|
|
59
|
+
}
|
|
60
|
+
input Notes_EditNoteInput {
|
|
61
|
+
id: OID!
|
|
62
|
+
title: String
|
|
63
|
+
date: Date
|
|
64
|
+
}
|
|
65
|
+
input Notes_EditTextInput {
|
|
66
|
+
id: OID!
|
|
67
|
+
title: String
|
|
68
|
+
date: Date
|
|
69
|
+
content: String
|
|
70
|
+
}
|
|
71
|
+
input Notes_EditTodoInput {
|
|
72
|
+
id: OID!
|
|
73
|
+
title: String
|
|
74
|
+
date: Date
|
|
75
|
+
done: Boolean
|
|
76
|
+
}
|
|
77
|
+
input Notes_DeleteNoteInput {
|
|
78
|
+
id: OID!
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AAGA,wBAaG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getConnectBaseViteConfig } from "@powerhousedao/builder-tools";
|
|
2
|
+
import { defineConfig, mergeConfig } from "vite";
|
|
3
|
+
export default defineConfig(({ mode }) => {
|
|
4
|
+
const baseConnectViteConfig = getConnectBaseViteConfig({
|
|
5
|
+
mode,
|
|
6
|
+
dirname: import.meta.dirname,
|
|
7
|
+
});
|
|
8
|
+
const additionalViteConfig = {
|
|
9
|
+
// add your own vite config here
|
|
10
|
+
};
|
|
11
|
+
const config = mergeConfig(baseConnectViteConfig, additionalViteConfig);
|
|
12
|
+
return config;
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAGA,wBAKG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@powerhousedao/notes-demo-package",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"development": "./index.ts",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./document-models": {
|
|
18
|
+
"development": "./document-models/index.ts",
|
|
19
|
+
"types": "./dist/document-models/index.d.ts",
|
|
20
|
+
"default": "./dist/document-models/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./editors": {
|
|
23
|
+
"development": "./editors/index.ts",
|
|
24
|
+
"types": "./dist/editors/index.d.ts",
|
|
25
|
+
"default": "./dist/editors/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./subgraphs": {
|
|
28
|
+
"development": "./subgraphs/index.ts",
|
|
29
|
+
"types": "./dist/subgraphs/index.d.ts",
|
|
30
|
+
"default": "./dist/subgraphs/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./processors": {
|
|
33
|
+
"development": "./processors/index.ts",
|
|
34
|
+
"types": "./dist/processors/index.d.ts",
|
|
35
|
+
"default": "./dist/processors/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./manifest": {
|
|
38
|
+
"development": "./powerhouse.manifest.json",
|
|
39
|
+
"default": "./dist/powerhouse.manifest.json"
|
|
40
|
+
},
|
|
41
|
+
"./style.css": "./dist/style.css"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"lint": "eslint . --cache",
|
|
45
|
+
"lint:fix": "eslint . --fix --cache",
|
|
46
|
+
"build:tsc": "tsc",
|
|
47
|
+
"build:tsc:watch": "tsc --watch",
|
|
48
|
+
"build:css": "npx @tailwindcss/cli -i ./style.css -o ./dist/style.css",
|
|
49
|
+
"build:css:watch": "npx @tailwindcss/cli -i ./style.css -o ./dist/style.css --watch",
|
|
50
|
+
"build": "npm run build:tsc && npm run build:css",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"prepublishOnly": "npm run build",
|
|
55
|
+
"generate": "ph-cli generate",
|
|
56
|
+
"connect": "ph-cli connect",
|
|
57
|
+
"reactor": "ph-cli reactor",
|
|
58
|
+
"service": "ph-cli service",
|
|
59
|
+
"service-startup": "bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-startup.sh",
|
|
60
|
+
"service-unstartup": "bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-unstartup.sh"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"@powerhousedao/builder-tools": "staging",
|
|
64
|
+
"@powerhousedao/common": "staging",
|
|
65
|
+
"@powerhousedao/design-system": "staging",
|
|
66
|
+
"@powerhousedao/document-engineering": "^1.39.0",
|
|
67
|
+
"@powerhousedao/vetra": "staging",
|
|
68
|
+
"document-model": "staging",
|
|
69
|
+
"graphql": "^16.10.0",
|
|
70
|
+
"graphql-tag": "^2.12.6",
|
|
71
|
+
"luxon": "^3.7.2",
|
|
72
|
+
"uuid": "^11.1.0",
|
|
73
|
+
"zod": "^3.24.2"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@openfeature/core": "^1.9.1",
|
|
77
|
+
"@electric-sql/pglite": "^0.2.17",
|
|
78
|
+
"@eslint/js": "^9.37.0",
|
|
79
|
+
"@powerhousedao/analytics-engine-core": "^0.5.0",
|
|
80
|
+
"@powerhousedao/codegen": "dev",
|
|
81
|
+
"@powerhousedao/config": "dev",
|
|
82
|
+
"@powerhousedao/connect": "dev",
|
|
83
|
+
"@powerhousedao/ph-cli": "dev",
|
|
84
|
+
"@powerhousedao/reactor-api": "dev",
|
|
85
|
+
"@powerhousedao/reactor-browser": "dev",
|
|
86
|
+
"@powerhousedao/reactor-local": "dev",
|
|
87
|
+
"@powerhousedao/scalars": "2.0.1",
|
|
88
|
+
"@powerhousedao/switchboard": "dev",
|
|
89
|
+
"@tailwindcss/cli": "^4.1.14",
|
|
90
|
+
"@types/node": "^22.13.11",
|
|
91
|
+
"@types/react": "^19.2.2",
|
|
92
|
+
"@types/react-dom": "^19.2.2",
|
|
93
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
94
|
+
"document-drive": "dev",
|
|
95
|
+
"eslint": "^9.37.0",
|
|
96
|
+
"eslint-plugin-react": "^7.37.5",
|
|
97
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
98
|
+
"globals": "^16.0.0",
|
|
99
|
+
"pm2": "^5.4.3",
|
|
100
|
+
"react": "^19.2.0",
|
|
101
|
+
"react-dom": "^19.2.0",
|
|
102
|
+
"storybook": "^8.6.14",
|
|
103
|
+
"tailwindcss": "^4.1.14",
|
|
104
|
+
"typescript": "^5.9.3",
|
|
105
|
+
"typescript-eslint": "^8.46.0",
|
|
106
|
+
"vite": "^7.1.9",
|
|
107
|
+
"vite-plugin-node-polyfills": "^0.24.0",
|
|
108
|
+
"vitest": "^3.0.9"
|
|
109
|
+
},
|
|
110
|
+
"peerDependencies": {
|
|
111
|
+
"react": "^19.2.0",
|
|
112
|
+
"react-dom": "^19.2.0"
|
|
113
|
+
},
|
|
114
|
+
"overrides": {
|
|
115
|
+
"react": "^19.2.0",
|
|
116
|
+
"react-dom": "^19.2.0"
|
|
117
|
+
}
|
|
118
|
+
}
|