@powerhousedao/vetra 6.0.0-dev.50 → 6.0.0-dev.53
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/dist/subgraphs/index.d.ts +0 -5
- package/dist/subgraphs/index.d.ts.map +1 -1
- package/dist/subgraphs/index.js +0 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/dist/subgraphs/__tests__/app-module-permissions.test.d.ts +0 -2
- package/dist/subgraphs/__tests__/app-module-permissions.test.d.ts.map +0 -1
- package/dist/subgraphs/__tests__/app-module-permissions.test.js +0 -436
- package/dist/subgraphs/app-module/index.d.ts +0 -11
- package/dist/subgraphs/app-module/index.d.ts.map +0 -1
- package/dist/subgraphs/app-module/index.js +0 -11
- package/dist/subgraphs/app-module/resolvers.d.ts +0 -3
- package/dist/subgraphs/app-module/resolvers.d.ts.map +0 -1
- package/dist/subgraphs/app-module/resolvers.js +0 -188
- package/dist/subgraphs/app-module/schema.d.ts +0 -3
- package/dist/subgraphs/app-module/schema.d.ts.map +0 -1
- package/dist/subgraphs/app-module/schema.js +0 -78
- package/dist/subgraphs/document-editor/index.d.ts +0 -11
- package/dist/subgraphs/document-editor/index.d.ts.map +0 -1
- package/dist/subgraphs/document-editor/index.js +0 -11
- package/dist/subgraphs/document-editor/resolvers.d.ts +0 -3
- package/dist/subgraphs/document-editor/resolvers.d.ts.map +0 -1
- package/dist/subgraphs/document-editor/resolvers.js +0 -158
- package/dist/subgraphs/document-editor/schema.d.ts +0 -3
- package/dist/subgraphs/document-editor/schema.d.ts.map +0 -1
- package/dist/subgraphs/document-editor/schema.js +0 -59
- package/dist/subgraphs/processor-module/index.d.ts +0 -10
- package/dist/subgraphs/processor-module/index.d.ts.map +0 -1
- package/dist/subgraphs/processor-module/index.js +0 -11
- package/dist/subgraphs/processor-module/resolvers.d.ts +0 -3
- package/dist/subgraphs/processor-module/resolvers.d.ts.map +0 -1
- package/dist/subgraphs/processor-module/resolvers.js +0 -173
- package/dist/subgraphs/processor-module/schema.d.ts +0 -3
- package/dist/subgraphs/processor-module/schema.d.ts.map +0 -1
- package/dist/subgraphs/processor-module/schema.js +0 -67
- package/dist/subgraphs/subgraph-module/index.d.ts +0 -10
- package/dist/subgraphs/subgraph-module/index.d.ts.map +0 -1
- package/dist/subgraphs/subgraph-module/index.js +0 -11
- package/dist/subgraphs/subgraph-module/resolvers.d.ts +0 -3
- package/dist/subgraphs/subgraph-module/resolvers.d.ts.map +0 -1
- package/dist/subgraphs/subgraph-module/resolvers.js +0 -128
- package/dist/subgraphs/subgraph-module/schema.d.ts +0 -3
- package/dist/subgraphs/subgraph-module/schema.d.ts.map +0 -1
- package/dist/subgraphs/subgraph-module/schema.js +0 -42
- package/dist/subgraphs/vetra-package/index.d.ts +0 -10
- package/dist/subgraphs/vetra-package/index.d.ts.map +0 -1
- package/dist/subgraphs/vetra-package/index.js +0 -11
- package/dist/subgraphs/vetra-package/resolvers.d.ts +0 -3
- package/dist/subgraphs/vetra-package/resolvers.d.ts.map +0 -1
- package/dist/subgraphs/vetra-package/resolvers.js +0 -248
- package/dist/subgraphs/vetra-package/schema.d.ts +0 -3
- package/dist/subgraphs/vetra-package/schema.d.ts.map +0 -1
- package/dist/subgraphs/vetra-package/schema.js +0 -108
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { addFile } from "document-drive";
|
|
2
|
-
import { setName } from "document-model";
|
|
3
|
-
import { GraphQLError } from "graphql";
|
|
4
|
-
import { actions, appModuleDocumentType, } from "@powerhousedao/vetra/document-models/app-module";
|
|
5
|
-
import { assertCanRead, assertCanWrite, assertCanExecuteOperation, canReadDocument, hasGlobalReadAccess, hasGlobalWriteAccess, } from "../permission-utils.js";
|
|
6
|
-
export const getResolvers = (subgraph) => {
|
|
7
|
-
const reactor = subgraph.reactor;
|
|
8
|
-
return {
|
|
9
|
-
Query: {
|
|
10
|
-
AppModule: (_, __, ctx) => {
|
|
11
|
-
return {
|
|
12
|
-
getDocument: async (args) => {
|
|
13
|
-
const { docId, driveId } = args;
|
|
14
|
-
if (!docId) {
|
|
15
|
-
throw new Error("Document id is required");
|
|
16
|
-
}
|
|
17
|
-
// Check read permission before accessing document
|
|
18
|
-
await assertCanRead(subgraph, docId, ctx);
|
|
19
|
-
if (driveId) {
|
|
20
|
-
const docIds = await reactor.getDocuments(driveId);
|
|
21
|
-
if (!docIds.includes(docId)) {
|
|
22
|
-
throw new Error(`Document with id ${docId} is not part of ${driveId}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const doc = await reactor.getDocument(docId);
|
|
26
|
-
return {
|
|
27
|
-
driveId: driveId,
|
|
28
|
-
...doc,
|
|
29
|
-
...doc.header,
|
|
30
|
-
created: doc.header.createdAtUtcIso,
|
|
31
|
-
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
32
|
-
state: doc.state.global,
|
|
33
|
-
stateJSON: doc.state.global,
|
|
34
|
-
revision: doc.header?.revision?.global ?? 0,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
getDocuments: async (args) => {
|
|
38
|
-
const { driveId } = args;
|
|
39
|
-
// Check read permission on drive before listing documents
|
|
40
|
-
await assertCanRead(subgraph, driveId, ctx);
|
|
41
|
-
const docsIds = await reactor.getDocuments(driveId);
|
|
42
|
-
const docs = await Promise.all(docsIds.map(async (docId) => {
|
|
43
|
-
const doc = await reactor.getDocument(docId);
|
|
44
|
-
return {
|
|
45
|
-
driveId: driveId,
|
|
46
|
-
...doc,
|
|
47
|
-
...doc.header,
|
|
48
|
-
created: doc.header.createdAtUtcIso,
|
|
49
|
-
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
50
|
-
state: doc.state.global,
|
|
51
|
-
stateJSON: doc.state.global,
|
|
52
|
-
revision: doc.header?.revision?.global ?? 0,
|
|
53
|
-
};
|
|
54
|
-
}));
|
|
55
|
-
const filteredByType = docs.filter((doc) => doc.header.documentType === appModuleDocumentType);
|
|
56
|
-
// If user doesn't have global read access, filter by document-level permissions
|
|
57
|
-
if (!hasGlobalReadAccess(ctx) &&
|
|
58
|
-
subgraph.documentPermissionService) {
|
|
59
|
-
const filteredDocs = [];
|
|
60
|
-
for (const doc of filteredByType) {
|
|
61
|
-
const canRead = await canReadDocument(subgraph, doc.id, ctx);
|
|
62
|
-
if (canRead) {
|
|
63
|
-
filteredDocs.push(doc);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return filteredDocs;
|
|
67
|
-
}
|
|
68
|
-
return filteredByType;
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
Mutation: {
|
|
74
|
-
AppModule_createDocument: async (_, args, ctx) => {
|
|
75
|
-
const { driveId, name } = args;
|
|
76
|
-
// If creating under a drive, check write permission on drive
|
|
77
|
-
if (driveId) {
|
|
78
|
-
await assertCanWrite(subgraph, driveId, ctx);
|
|
79
|
-
}
|
|
80
|
-
else if (!hasGlobalWriteAccess(ctx)) {
|
|
81
|
-
throw new GraphQLError("Forbidden: insufficient permissions to create documents");
|
|
82
|
-
}
|
|
83
|
-
const document = await reactor.addDocument(appModuleDocumentType);
|
|
84
|
-
if (driveId) {
|
|
85
|
-
await reactor.addAction(driveId, addFile({
|
|
86
|
-
name,
|
|
87
|
-
id: document.header.id,
|
|
88
|
-
documentType: appModuleDocumentType,
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
if (name) {
|
|
92
|
-
await reactor.addAction(document.header.id, setName(name));
|
|
93
|
-
}
|
|
94
|
-
return document.header.id;
|
|
95
|
-
},
|
|
96
|
-
AppModule_setAppName: async (_, args, ctx) => {
|
|
97
|
-
const { docId, input } = args;
|
|
98
|
-
// Check write permission before mutating document
|
|
99
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
100
|
-
await assertCanExecuteOperation(subgraph, docId, "SET_APP_NAME", ctx);
|
|
101
|
-
const doc = await reactor.getDocument(docId);
|
|
102
|
-
if (!doc) {
|
|
103
|
-
throw new Error("Document not found");
|
|
104
|
-
}
|
|
105
|
-
const result = await reactor.addAction(docId, actions.setAppName(input));
|
|
106
|
-
if (result.status !== "SUCCESS") {
|
|
107
|
-
throw new Error(result.error?.message ?? "Failed to setAppName");
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
},
|
|
111
|
-
AppModule_setAppStatus: async (_, args, ctx) => {
|
|
112
|
-
const { docId, input } = args;
|
|
113
|
-
// Check write permission before mutating document
|
|
114
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
115
|
-
await assertCanExecuteOperation(subgraph, docId, "SET_APP_STATUS", ctx);
|
|
116
|
-
const doc = await reactor.getDocument(docId);
|
|
117
|
-
if (!doc) {
|
|
118
|
-
throw new Error("Document not found");
|
|
119
|
-
}
|
|
120
|
-
const result = await reactor.addAction(docId, actions.setAppStatus(input));
|
|
121
|
-
if (result.status !== "SUCCESS") {
|
|
122
|
-
throw new Error(result.error?.message ?? "Failed to setAppStatus");
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
},
|
|
126
|
-
AppModule_addDocumentType: async (_, args, ctx) => {
|
|
127
|
-
const { docId, input } = args;
|
|
128
|
-
// Check write permission before mutating document
|
|
129
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
130
|
-
await assertCanExecuteOperation(subgraph, docId, "ADD_DOCUMENT_TYPE", ctx);
|
|
131
|
-
const doc = await reactor.getDocument(docId);
|
|
132
|
-
if (!doc) {
|
|
133
|
-
throw new Error("Document not found");
|
|
134
|
-
}
|
|
135
|
-
const result = await reactor.addAction(docId, actions.addDocumentType(input));
|
|
136
|
-
if (result.status !== "SUCCESS") {
|
|
137
|
-
throw new Error(result.error?.message ?? "Failed to addDocumentType");
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
},
|
|
141
|
-
AppModule_removeDocumentType: async (_, args, ctx) => {
|
|
142
|
-
const { docId, input } = args;
|
|
143
|
-
// Check write permission before mutating document
|
|
144
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
145
|
-
await assertCanExecuteOperation(subgraph, docId, "REMOVE_DOCUMENT_TYPE", ctx);
|
|
146
|
-
const doc = await reactor.getDocument(docId);
|
|
147
|
-
if (!doc) {
|
|
148
|
-
throw new Error("Document not found");
|
|
149
|
-
}
|
|
150
|
-
const result = await reactor.addAction(docId, actions.removeDocumentType(input));
|
|
151
|
-
if (result.status !== "SUCCESS") {
|
|
152
|
-
throw new Error(result.error?.message ?? "Failed to removeDocumentType");
|
|
153
|
-
}
|
|
154
|
-
return true;
|
|
155
|
-
},
|
|
156
|
-
AppModule_setDocumentTypes: async (_, args, ctx) => {
|
|
157
|
-
const { docId, input } = args;
|
|
158
|
-
// Check write permission before mutating document
|
|
159
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
160
|
-
await assertCanExecuteOperation(subgraph, docId, "SET_DOCUMENT_TYPES", ctx);
|
|
161
|
-
const doc = await reactor.getDocument(docId);
|
|
162
|
-
if (!doc) {
|
|
163
|
-
throw new Error("Document not found");
|
|
164
|
-
}
|
|
165
|
-
const result = await reactor.addAction(docId, actions.setDocumentTypes(input));
|
|
166
|
-
if (result.status !== "SUCCESS") {
|
|
167
|
-
throw new Error(result.error?.message ?? "Failed to setDocumentTypes");
|
|
168
|
-
}
|
|
169
|
-
return true;
|
|
170
|
-
},
|
|
171
|
-
AppModule_setDragAndDropEnabled: async (_, args, ctx) => {
|
|
172
|
-
const { docId, input } = args;
|
|
173
|
-
// Check write permission before mutating document
|
|
174
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
175
|
-
await assertCanExecuteOperation(subgraph, docId, "SET_DRAG_AND_DROP_ENABLED", ctx);
|
|
176
|
-
const doc = await reactor.getDocument(docId);
|
|
177
|
-
if (!doc) {
|
|
178
|
-
throw new Error("Document not found");
|
|
179
|
-
}
|
|
180
|
-
const result = await reactor.addAction(docId, actions.setDragAndDropEnabled(input));
|
|
181
|
-
if (result.status !== "SUCCESS") {
|
|
182
|
-
throw new Error(result.error?.message ?? "Failed to setDragAndDropEnabled");
|
|
183
|
-
}
|
|
184
|
-
return true;
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/app-module/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YA4EpB,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { gql } from "graphql-tag";
|
|
2
|
-
export const schema = gql `
|
|
3
|
-
"""
|
|
4
|
-
Queries: AppModule Document
|
|
5
|
-
"""
|
|
6
|
-
type AppModuleQueries {
|
|
7
|
-
getDocument(docId: PHID!, driveId: PHID): AppModule
|
|
8
|
-
getDocuments(driveId: String!): [AppModule!]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type Query {
|
|
12
|
-
AppModule: AppModuleQueries
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
"""
|
|
16
|
-
Mutations: AppModule
|
|
17
|
-
"""
|
|
18
|
-
type Mutation {
|
|
19
|
-
AppModule_createDocument(name: String!, driveId: String): String
|
|
20
|
-
|
|
21
|
-
AppModule_setAppName(
|
|
22
|
-
driveId: String
|
|
23
|
-
docId: PHID
|
|
24
|
-
input: AppModule_SetAppNameInput
|
|
25
|
-
): Int
|
|
26
|
-
AppModule_setAppStatus(
|
|
27
|
-
driveId: String
|
|
28
|
-
docId: PHID
|
|
29
|
-
input: AppModule_SetAppStatusInput
|
|
30
|
-
): Int
|
|
31
|
-
AppModule_addDocumentType(
|
|
32
|
-
driveId: String
|
|
33
|
-
docId: PHID
|
|
34
|
-
input: AppModule_AddDocumentTypeInput
|
|
35
|
-
): Int
|
|
36
|
-
AppModule_removeDocumentType(
|
|
37
|
-
driveId: String
|
|
38
|
-
docId: PHID
|
|
39
|
-
input: AppModule_RemoveDocumentTypeInput
|
|
40
|
-
): Int
|
|
41
|
-
AppModule_setDocumentTypes(
|
|
42
|
-
driveId: String
|
|
43
|
-
docId: PHID
|
|
44
|
-
input: AppModule_SetDocumentTypesInput
|
|
45
|
-
): Int
|
|
46
|
-
AppModule_setDragAndDropEnabled(
|
|
47
|
-
driveId: String
|
|
48
|
-
docId: PHID
|
|
49
|
-
input: AppModule_SetDragAndDropEnabledInput
|
|
50
|
-
): Int
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
"""
|
|
54
|
-
Module: BaseOperations
|
|
55
|
-
"""
|
|
56
|
-
input AppModule_SetAppNameInput {
|
|
57
|
-
name: String!
|
|
58
|
-
}
|
|
59
|
-
input AppModule_SetAppStatusInput {
|
|
60
|
-
status: AppModule_StatusType!
|
|
61
|
-
}
|
|
62
|
-
input AppModule_AddDocumentTypeInput {
|
|
63
|
-
documentType: String!
|
|
64
|
-
}
|
|
65
|
-
input AppModule_RemoveDocumentTypeInput {
|
|
66
|
-
documentType: String!
|
|
67
|
-
}
|
|
68
|
-
input AppModule_SetDocumentTypesInput {
|
|
69
|
-
documentTypes: [String!]!
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
"""
|
|
73
|
-
Module: DndOperations
|
|
74
|
-
"""
|
|
75
|
-
input AppModule_SetDragAndDropEnabledInput {
|
|
76
|
-
enabled: Boolean!
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
-
import type { DocumentNode } from "graphql";
|
|
3
|
-
export declare class DocumentEditorSubgraph 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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/document-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,IAAI,SAAqB;IACzB,QAAQ,EAAE,YAAY,CAAU;IAChC,SAAS,0BAAsB;IAC/B,uBAAuB,KAAM;IACvB,OAAO;IACP,YAAY;CACnB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
-
import { schema } from "./schema.js";
|
|
3
|
-
import { getResolvers } from "./resolvers.js";
|
|
4
|
-
export class DocumentEditorSubgraph extends BaseSubgraph {
|
|
5
|
-
name = "document-editor";
|
|
6
|
-
typeDefs = schema;
|
|
7
|
-
resolvers = getResolvers(this);
|
|
8
|
-
additionalContextFields = {};
|
|
9
|
-
async onSetup() { }
|
|
10
|
-
async onDisconnect() { }
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/document-editor/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,4BAA4B,CAAC;AA0BxE,eAAO,MAAM,YAAY,GACvB,UAAU,YAAY,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAmQxB,CAAC"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { addFile } from "document-drive";
|
|
2
|
-
import { setName } from "document-model";
|
|
3
|
-
import { GraphQLError } from "graphql";
|
|
4
|
-
import { actions, documentEditorDocumentType, } from "@powerhousedao/vetra/document-models/document-editor";
|
|
5
|
-
import { assertCanRead, assertCanWrite, assertCanExecuteOperation, canReadDocument, hasGlobalReadAccess, hasGlobalWriteAccess, } from "../permission-utils.js";
|
|
6
|
-
export const getResolvers = (subgraph) => {
|
|
7
|
-
const reactor = subgraph.reactor;
|
|
8
|
-
return {
|
|
9
|
-
Query: {
|
|
10
|
-
DocumentEditor: (_, __, ctx) => {
|
|
11
|
-
return {
|
|
12
|
-
getDocument: async (args) => {
|
|
13
|
-
const { docId, driveId } = args;
|
|
14
|
-
if (!docId) {
|
|
15
|
-
throw new Error("Document id is required");
|
|
16
|
-
}
|
|
17
|
-
// Check read permission before accessing document
|
|
18
|
-
await assertCanRead(subgraph, docId, ctx);
|
|
19
|
-
if (driveId) {
|
|
20
|
-
const docIds = await reactor.getDocuments(driveId);
|
|
21
|
-
if (!docIds.includes(docId)) {
|
|
22
|
-
throw new Error(`Document with id ${docId} is not part of ${driveId}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const doc = await reactor.getDocument(docId);
|
|
26
|
-
return {
|
|
27
|
-
driveId: driveId,
|
|
28
|
-
...doc,
|
|
29
|
-
...doc.header,
|
|
30
|
-
created: doc.header.createdAtUtcIso,
|
|
31
|
-
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
32
|
-
state: doc.state.global,
|
|
33
|
-
stateJSON: doc.state.global,
|
|
34
|
-
revision: doc.header?.revision?.global ?? 0,
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
getDocuments: async (args) => {
|
|
38
|
-
const { driveId } = args;
|
|
39
|
-
// Check read permission on drive before listing documents
|
|
40
|
-
await assertCanRead(subgraph, driveId, ctx);
|
|
41
|
-
const docsIds = await reactor.getDocuments(driveId);
|
|
42
|
-
const docs = await Promise.all(docsIds.map(async (docId) => {
|
|
43
|
-
const doc = await reactor.getDocument(docId);
|
|
44
|
-
return {
|
|
45
|
-
driveId: driveId,
|
|
46
|
-
...doc,
|
|
47
|
-
...doc.header,
|
|
48
|
-
created: doc.header.createdAtUtcIso,
|
|
49
|
-
lastModified: doc.header.lastModifiedAtUtcIso,
|
|
50
|
-
state: doc.state.global,
|
|
51
|
-
stateJSON: doc.state.global,
|
|
52
|
-
revision: doc.header?.revision?.global ?? 0,
|
|
53
|
-
};
|
|
54
|
-
}));
|
|
55
|
-
const filteredByType = docs.filter((doc) => doc.header.documentType === documentEditorDocumentType);
|
|
56
|
-
// If user doesn't have global read access, filter by document-level permissions
|
|
57
|
-
if (!hasGlobalReadAccess(ctx) &&
|
|
58
|
-
subgraph.documentPermissionService) {
|
|
59
|
-
const filteredDocs = [];
|
|
60
|
-
for (const doc of filteredByType) {
|
|
61
|
-
const canRead = await canReadDocument(subgraph, doc.id, ctx);
|
|
62
|
-
if (canRead) {
|
|
63
|
-
filteredDocs.push(doc);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return filteredDocs;
|
|
67
|
-
}
|
|
68
|
-
return filteredByType;
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
Mutation: {
|
|
74
|
-
DocumentEditor_createDocument: async (_, args, ctx) => {
|
|
75
|
-
const { driveId, name } = args;
|
|
76
|
-
// If creating under a drive, check write permission on drive
|
|
77
|
-
if (driveId) {
|
|
78
|
-
await assertCanWrite(subgraph, driveId, ctx);
|
|
79
|
-
}
|
|
80
|
-
else if (!hasGlobalWriteAccess(ctx)) {
|
|
81
|
-
throw new GraphQLError("Forbidden: insufficient permissions to create documents");
|
|
82
|
-
}
|
|
83
|
-
const document = await reactor.addDocument(documentEditorDocumentType);
|
|
84
|
-
if (driveId) {
|
|
85
|
-
await reactor.addAction(driveId, addFile({
|
|
86
|
-
name,
|
|
87
|
-
id: document.header.id,
|
|
88
|
-
documentType: documentEditorDocumentType,
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
if (name) {
|
|
92
|
-
await reactor.addAction(document.header.id, setName(name));
|
|
93
|
-
}
|
|
94
|
-
return document.header.id;
|
|
95
|
-
},
|
|
96
|
-
DocumentEditor_setEditorName: async (_, args, ctx) => {
|
|
97
|
-
const { docId, input } = args;
|
|
98
|
-
// Check write permission before mutating document
|
|
99
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
100
|
-
await assertCanExecuteOperation(subgraph, docId, "SET_EDITOR_NAME", ctx);
|
|
101
|
-
const doc = await reactor.getDocument(docId);
|
|
102
|
-
if (!doc) {
|
|
103
|
-
throw new Error("Document not found");
|
|
104
|
-
}
|
|
105
|
-
const result = await reactor.addAction(docId, actions.setEditorName(input));
|
|
106
|
-
if (result.status !== "SUCCESS") {
|
|
107
|
-
throw new Error(result.error?.message ?? "Failed to setEditorName");
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
},
|
|
111
|
-
DocumentEditor_addDocumentType: async (_, args, ctx) => {
|
|
112
|
-
const { docId, input } = args;
|
|
113
|
-
// Check write permission before mutating document
|
|
114
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
115
|
-
await assertCanExecuteOperation(subgraph, docId, "ADD_DOCUMENT_TYPE", ctx);
|
|
116
|
-
const doc = await reactor.getDocument(docId);
|
|
117
|
-
if (!doc) {
|
|
118
|
-
throw new Error("Document not found");
|
|
119
|
-
}
|
|
120
|
-
const result = await reactor.addAction(docId, actions.addDocumentType(input));
|
|
121
|
-
if (result.status !== "SUCCESS") {
|
|
122
|
-
throw new Error(result.error?.message ?? "Failed to addDocumentType");
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
},
|
|
126
|
-
DocumentEditor_removeDocumentType: async (_, args, ctx) => {
|
|
127
|
-
const { docId, input } = args;
|
|
128
|
-
// Check write permission before mutating document
|
|
129
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
130
|
-
await assertCanExecuteOperation(subgraph, docId, "REMOVE_DOCUMENT_TYPE", ctx);
|
|
131
|
-
const doc = await reactor.getDocument(docId);
|
|
132
|
-
if (!doc) {
|
|
133
|
-
throw new Error("Document not found");
|
|
134
|
-
}
|
|
135
|
-
const result = await reactor.addAction(docId, actions.removeDocumentType(input));
|
|
136
|
-
if (result.status !== "SUCCESS") {
|
|
137
|
-
throw new Error(result.error?.message ?? "Failed to removeDocumentType");
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
},
|
|
141
|
-
DocumentEditor_setEditorStatus: async (_, args, ctx) => {
|
|
142
|
-
const { docId, input } = args;
|
|
143
|
-
// Check write permission before mutating document
|
|
144
|
-
await assertCanWrite(subgraph, docId, ctx);
|
|
145
|
-
await assertCanExecuteOperation(subgraph, docId, "SET_EDITOR_STATUS", ctx);
|
|
146
|
-
const doc = await reactor.getDocument(docId);
|
|
147
|
-
if (!doc) {
|
|
148
|
-
throw new Error("Document not found");
|
|
149
|
-
}
|
|
150
|
-
const result = await reactor.addAction(docId, actions.setEditorStatus(input));
|
|
151
|
-
if (result.status !== "SUCCESS") {
|
|
152
|
-
throw new Error(result.error?.message ?? "Failed to setEditorStatus");
|
|
153
|
-
}
|
|
154
|
-
return true;
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/document-editor/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAyDpB,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { gql } from "graphql-tag";
|
|
2
|
-
export const schema = gql `
|
|
3
|
-
"""
|
|
4
|
-
Queries: DocumentEditor Document
|
|
5
|
-
"""
|
|
6
|
-
type DocumentEditorQueries {
|
|
7
|
-
getDocument(docId: PHID!, driveId: PHID): DocumentEditor
|
|
8
|
-
getDocuments(driveId: String!): [DocumentEditor!]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type Query {
|
|
12
|
-
DocumentEditor: DocumentEditorQueries
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
"""
|
|
16
|
-
Mutations: DocumentEditor
|
|
17
|
-
"""
|
|
18
|
-
type Mutation {
|
|
19
|
-
DocumentEditor_createDocument(name: String!, driveId: String): String
|
|
20
|
-
|
|
21
|
-
DocumentEditor_setEditorName(
|
|
22
|
-
driveId: String
|
|
23
|
-
docId: PHID
|
|
24
|
-
input: DocumentEditor_SetEditorNameInput
|
|
25
|
-
): Int
|
|
26
|
-
DocumentEditor_addDocumentType(
|
|
27
|
-
driveId: String
|
|
28
|
-
docId: PHID
|
|
29
|
-
input: DocumentEditor_AddDocumentTypeInput
|
|
30
|
-
): Int
|
|
31
|
-
DocumentEditor_removeDocumentType(
|
|
32
|
-
driveId: String
|
|
33
|
-
docId: PHID
|
|
34
|
-
input: DocumentEditor_RemoveDocumentTypeInput
|
|
35
|
-
): Int
|
|
36
|
-
DocumentEditor_setEditorStatus(
|
|
37
|
-
driveId: String
|
|
38
|
-
docId: PHID
|
|
39
|
-
input: DocumentEditor_SetEditorStatusInput
|
|
40
|
-
): Int
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
"""
|
|
44
|
-
Module: BaseOperations
|
|
45
|
-
"""
|
|
46
|
-
input DocumentEditor_SetEditorNameInput {
|
|
47
|
-
name: String!
|
|
48
|
-
}
|
|
49
|
-
input DocumentEditor_AddDocumentTypeInput {
|
|
50
|
-
id: OID!
|
|
51
|
-
documentType: String!
|
|
52
|
-
}
|
|
53
|
-
input DocumentEditor_RemoveDocumentTypeInput {
|
|
54
|
-
id: OID!
|
|
55
|
-
}
|
|
56
|
-
input DocumentEditor_SetEditorStatusInput {
|
|
57
|
-
status: DocumentEditor_StatusType!
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
-
export declare class ProcessorModuleSubgraph extends BaseSubgraph {
|
|
3
|
-
name: string;
|
|
4
|
-
typeDefs: import("graphql").DocumentNode;
|
|
5
|
-
resolvers: Record<string, unknown>;
|
|
6
|
-
additionalContextFields: {};
|
|
7
|
-
onSetup(): Promise<void>;
|
|
8
|
-
onDisconnect(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../subgraphs/processor-module/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,IAAI,SAAsB;IAC1B,QAAQ,iCAAU;IAClB,SAAS,0BAAsB;IAC/B,uBAAuB,KAAM;IACvB,OAAO;IACP,YAAY;CACnB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseSubgraph } from "@powerhousedao/reactor-api";
|
|
2
|
-
import { getResolvers } from "./resolvers.js";
|
|
3
|
-
import { schema } from "./schema.js";
|
|
4
|
-
export class ProcessorModuleSubgraph extends BaseSubgraph {
|
|
5
|
-
name = "processor-module";
|
|
6
|
-
typeDefs = schema;
|
|
7
|
-
resolvers = getResolvers(this);
|
|
8
|
-
additionalContextFields = {};
|
|
9
|
-
async onSetup() { }
|
|
10
|
-
async onDisconnect() { }
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/processor-module/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,4BAA4B,CAAC;AA2BxE,eAAO,MAAM,YAAY,GACvB,UAAU,YAAY,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CA0SxB,CAAC"}
|