@powerhousedao/codegen 4.0.0-staging.1 → 4.0.0-staging.2
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.
|
@@ -7,6 +7,7 @@ force: true
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
8
8
|
import { type Subgraph } from "@powerhousedao/reactor-api";
|
|
9
9
|
import { addFile } from "document-drive";
|
|
10
|
+
import { DocumentNotFoundError } from "document-drive/server/error";
|
|
10
11
|
import { actions } from "../../document-models/<%- h.changeCase.param(documentType) %>/index.js";
|
|
11
12
|
import { generateId } from "document-model";
|
|
12
13
|
|
|
@@ -23,9 +24,14 @@ export const getResolvers = (subgraph: Subgraph): Record<string, any> => {
|
|
|
23
24
|
const driveId: string = args.driveId || DEFAULT_DRIVE_ID;
|
|
24
25
|
const docId: string = args.docId || "";
|
|
25
26
|
const doc = await reactor.getDocument(driveId, docId);
|
|
26
|
-
|
|
27
|
+
if (!doc) {
|
|
28
|
+
throw new DocumentNotFoundError(docId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
27
32
|
driveId: driveId,
|
|
28
33
|
...doc,
|
|
34
|
+
...doc.header,
|
|
29
35
|
state: doc.state.global,
|
|
30
36
|
stateJSON: doc.state.global,
|
|
31
37
|
revision: doc.header.revision["global"] ?? 0,
|
|
@@ -34,12 +40,21 @@ export const getResolvers = (subgraph: Subgraph): Record<string, any> => {
|
|
|
34
40
|
getDocuments: async (args: any) => {
|
|
35
41
|
const driveId: string = args.driveId || DEFAULT_DRIVE_ID;
|
|
36
42
|
const docsIds = await reactor.getDocuments(driveId);
|
|
43
|
+
if (!docsIds) {
|
|
44
|
+
throw new DocumentNotFoundError(driveId);
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
const docs = await Promise.all(
|
|
38
48
|
docsIds.map(async (docId) => {
|
|
39
49
|
const doc = await reactor.getDocument(driveId, docId);
|
|
50
|
+
if (!doc) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
return {
|
|
41
55
|
driveId: driveId,
|
|
42
56
|
...doc,
|
|
57
|
+
...doc.header,
|
|
43
58
|
state: doc.state.global,
|
|
44
59
|
stateJSON: doc.state.global,
|
|
45
60
|
revision: doc.header.revision["global"] ?? 0,
|
|
@@ -48,7 +63,7 @@ export const getResolvers = (subgraph: Subgraph): Record<string, any> => {
|
|
|
48
63
|
);
|
|
49
64
|
|
|
50
65
|
return docs.filter(
|
|
51
|
-
(doc) => doc.header.documentType === "<%- documentTypeId %>",
|
|
66
|
+
(doc) => doc && doc.header.documentType === "<%- documentTypeId %>",
|
|
52
67
|
);
|
|
53
68
|
},
|
|
54
69
|
};
|
|
@@ -88,6 +103,9 @@ export const getResolvers = (subgraph: Subgraph): Record<string, any> => {
|
|
|
88
103
|
const driveId: string = args.driveId || DEFAULT_DRIVE_ID;
|
|
89
104
|
const docId: string = args.docId || "";
|
|
90
105
|
const doc = await reactor.getDocument(driveId, docId);
|
|
106
|
+
if (!doc) {
|
|
107
|
+
throw new DocumentNotFoundError(docId);
|
|
108
|
+
}
|
|
91
109
|
|
|
92
110
|
await reactor.addAction(
|
|
93
111
|
driveId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/codegen",
|
|
3
|
-
"version": "4.0.0-staging.
|
|
3
|
+
"version": "4.0.0-staging.2",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"kysely": "^0.28.2",
|
|
34
34
|
"kysely-pglite": "^0.6.1",
|
|
35
35
|
"prettier": "^3.4.2",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"@powerhousedao/config": "4.0.0-staging.2",
|
|
37
|
+
"document-model": "4.0.0-staging.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@graphql-codegen/core": "^4.0.2",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"husky": "^8.0.3",
|
|
45
45
|
"vitest": "^3.1.2",
|
|
46
46
|
"zod": "^3.24.3",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"document-drive": "4.0.0-staging.2",
|
|
48
|
+
"@powerhousedao/reactor-api": "4.0.0-staging.2"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build:tsc": "tsc --build",
|