@powerhousedao/reactor-api 1.14.2 → 1.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -4
- package/dist/index.js +40 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/subgraphs/auth/index.ts +2 -4
- package/src/subgraphs/auth/utils/helpers.ts +0 -4
- package/src/subgraphs/auth/utils/session.ts +0 -5
- package/src/subgraphs/drive/index.ts +12 -1
- package/src/subgraphs/manager.ts +3 -1
- package/src/utils/create-schema.ts +30 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/reactor-api",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@types/pg": "^8.11.10",
|
|
24
24
|
"esbuild": "^0.24.0",
|
|
25
25
|
"graphql-tag": "^2.12.6",
|
|
26
|
-
"document-drive": "1.13.2",
|
|
27
26
|
"@powerhousedao/scalars": "1.16.0",
|
|
27
|
+
"document-drive": "1.13.2",
|
|
28
28
|
"document-model": "2.15.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
@@ -104,7 +104,7 @@ export class AuthSubgraph extends Subgraph {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
const nonce = generateUUID().replace(/-/g, "");
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
const message = new SiweMessage({
|
|
109
109
|
address,
|
|
110
110
|
nonce,
|
|
@@ -112,7 +112,6 @@ export class AuthSubgraph extends Subgraph {
|
|
|
112
112
|
domain,
|
|
113
113
|
version: "1",
|
|
114
114
|
chainId: 1,
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
116
115
|
}).prepareMessage();
|
|
117
116
|
const textToHex = (textMessage: string) =>
|
|
118
117
|
`0x${Buffer.from(textMessage, "utf8").toString("hex")}`;
|
|
@@ -155,7 +154,7 @@ export class AuthSubgraph extends Subgraph {
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
// verify signature
|
|
158
|
-
|
|
157
|
+
|
|
159
158
|
const parsedMessage = new SiweMessage(challenge.message);
|
|
160
159
|
try {
|
|
161
160
|
await verifySignature(parsedMessage, signature);
|
|
@@ -172,7 +171,6 @@ export class AuthSubgraph extends Subgraph {
|
|
|
172
171
|
|
|
173
172
|
// create user and session
|
|
174
173
|
const user = await upsertUser(db, {
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
176
174
|
address: parsedMessage.address as `0x${string}`,
|
|
177
175
|
networkId: "1",
|
|
178
176
|
chainId: 1,
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
1
|
import { randomUUID } from "crypto";
|
|
6
2
|
import { GraphQLError } from "graphql";
|
|
7
3
|
import jwt from "jsonwebtoken";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
6
1
|
import { GraphQLError } from "graphql";
|
|
7
2
|
import ms from "ms";
|
|
8
3
|
import { SiweMessage } from "siwe";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
TransmitterType,
|
|
15
15
|
} from "document-model-libs/document-drive";
|
|
16
16
|
import { Asset } from "document-model-libs/real-world-assets";
|
|
17
|
-
import { BaseAction, Operation } from "document-model/document";
|
|
17
|
+
import { BaseAction, Document, Operation } from "document-model/document";
|
|
18
18
|
import {
|
|
19
19
|
DocumentModelInput,
|
|
20
20
|
DocumentModelState,
|
|
@@ -177,6 +177,17 @@ export class DriveSubgraph extends Subgraph {
|
|
|
177
177
|
return obj.documentType ? "FileNode" : "FolderNode";
|
|
178
178
|
},
|
|
179
179
|
},
|
|
180
|
+
Document: {
|
|
181
|
+
operations: async (
|
|
182
|
+
obj: Document,
|
|
183
|
+
{ first, skip }: { first: number; skip: number },
|
|
184
|
+
ctx: Context,
|
|
185
|
+
) => {
|
|
186
|
+
const limit = first ?? 0;
|
|
187
|
+
const start = skip ?? 0;
|
|
188
|
+
return obj.operations.global.slice(start, start + limit);
|
|
189
|
+
},
|
|
190
|
+
},
|
|
180
191
|
Query: {
|
|
181
192
|
drive: async (_: unknown, args: unknown, ctx: Context) => {
|
|
182
193
|
if (!ctx.driveId) throw new Error("Drive ID is required");
|
package/src/subgraphs/manager.ts
CHANGED
|
@@ -108,7 +108,9 @@ export class SubgraphManager {
|
|
|
108
108
|
});
|
|
109
109
|
await subgraphInstance.onSetup();
|
|
110
110
|
this.subgraphs.unshift(subgraphInstance);
|
|
111
|
-
console.log(
|
|
111
|
+
console.log(
|
|
112
|
+
`> Registered ${this.path.endsWith("/") ? this.path : this.path + "/"}${subgraphInstance.name} subgraph.`,
|
|
113
|
+
);
|
|
112
114
|
await this.updateRouter();
|
|
113
115
|
}
|
|
114
116
|
|
|
@@ -52,10 +52,10 @@ export const getDocumentModelTypeDefs = (
|
|
|
52
52
|
.join("\n")};
|
|
53
53
|
|
|
54
54
|
type ${documentModel.name} implements IDocument {
|
|
55
|
-
id:
|
|
55
|
+
id: String!
|
|
56
56
|
name: String!
|
|
57
57
|
documentType: String!
|
|
58
|
-
operations: [Operation!]!
|
|
58
|
+
operations(skip: Int, first: Int): [Operation!]!
|
|
59
59
|
revision: Int!
|
|
60
60
|
created: DateTime!
|
|
61
61
|
lastModified: DateTime!
|
|
@@ -67,19 +67,46 @@ export const getDocumentModelTypeDefs = (
|
|
|
67
67
|
const schema = gql`
|
|
68
68
|
${scalarsTypeDefs.join("\n").replaceAll(";", "")}
|
|
69
69
|
|
|
70
|
+
type PHOperationContext {
|
|
71
|
+
signer: Signer
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type Signer {
|
|
75
|
+
user: SignerUser
|
|
76
|
+
app: SignerApp
|
|
77
|
+
signatures: [String!]!
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type SignerUser {
|
|
81
|
+
address: String!
|
|
82
|
+
networkId: String!
|
|
83
|
+
chainId: Int!
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type SignerApp {
|
|
87
|
+
name: String!
|
|
88
|
+
key: String!
|
|
89
|
+
}
|
|
90
|
+
|
|
70
91
|
type Operation {
|
|
92
|
+
id: String!
|
|
71
93
|
type: String!
|
|
72
94
|
index: Int!
|
|
73
95
|
timestamp: DateTime!
|
|
74
96
|
hash: String!
|
|
97
|
+
skip: Int
|
|
98
|
+
inputText: String
|
|
99
|
+
error: String
|
|
100
|
+
context: PHOperationContext
|
|
75
101
|
}
|
|
76
102
|
interface IDocument {
|
|
103
|
+
id: String!
|
|
77
104
|
name: String!
|
|
78
105
|
documentType: String!
|
|
79
106
|
revision: Int!
|
|
80
107
|
created: DateTime!
|
|
81
108
|
lastModified: DateTime!
|
|
82
|
-
operations: [Operation!]!
|
|
109
|
+
operations(first: Int, skip: Int): [Operation!]!
|
|
83
110
|
}
|
|
84
111
|
${dmSchema.replaceAll(";", "")}
|
|
85
112
|
|