@kubun/server 0.3.0 → 0.3.1
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/lib/data/graphql.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { KubunDB } from '@kubun/db';
|
|
2
|
+
import type { Context } from '@kubun/graphql';
|
|
3
|
+
import type { DocumentNode } from '@kubun/protocol';
|
|
3
4
|
import { type ExecutionArgs, type GraphQLSchema, type OperationTypeNode } from 'graphql';
|
|
4
5
|
export type ExecutionContext = {
|
|
5
6
|
db: KubunDB;
|
|
6
7
|
viewerDID: string;
|
|
7
|
-
mutatedDocuments?: Record<string,
|
|
8
|
+
mutatedDocuments?: Record<string, DocumentNode>;
|
|
8
9
|
};
|
|
9
|
-
export declare function createContext(ctx: ExecutionContext):
|
|
10
|
+
export declare function createContext(ctx: ExecutionContext): Context;
|
|
10
11
|
export type ExecuteGraphQLParams = {
|
|
11
12
|
context: ExecutionContext;
|
|
12
13
|
schema: GraphQLSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/data/graphql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/data/graphql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAuB,MAAM,gBAAgB,CAAA;AAElE,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,aAAa,EAElB,KAAK,iBAAiB,EAEvB,MAAM,SAAS,CAAA;AAGhB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,OAAO,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CAChD,CAAA;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAsK5D;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,EAAE,aAAa,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,iBAAiB,CAAA;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC,CAAA;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,GAAG,aAAa,CAiB5E"}
|
package/lib/data/mutations.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Validator } from '@enkaku/schema';
|
|
2
|
-
import type {
|
|
3
|
-
import { type DocumentData } from '@kubun/protocol';
|
|
2
|
+
import type { KubunDB } from '@kubun/db';
|
|
3
|
+
import { type DocumentData, type DocumentNode } from '@kubun/protocol';
|
|
4
4
|
type DocumentValidator = Validator<DocumentData>;
|
|
5
5
|
type ValidatorsRecord = Record<string, Promise<DocumentValidator>>;
|
|
6
6
|
export type MutationContext = {
|
|
@@ -8,6 +8,6 @@ export type MutationContext = {
|
|
|
8
8
|
validators: ValidatorsRecord;
|
|
9
9
|
};
|
|
10
10
|
export declare function getDocumentValidator(ctx: MutationContext, id: string): Promise<DocumentValidator>;
|
|
11
|
-
export declare function applyMutation(ctx: MutationContext, token: string): Promise<
|
|
11
|
+
export declare function applyMutation(ctx: MutationContext, token: string): Promise<DocumentNode>;
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/data/mutations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,gBAAgB,CAAA;AAExE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/data/mutations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,gBAAgB,CAAA;AAExE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAA;AAMxB,KAAK,iBAAiB,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;AAChD,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAElE,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,OAAO,CAAA;IACX,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOjG;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAiF9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/handlers/graph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/handlers/graph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAA4B,OAAO,EAAE,MAAM,WAAW,CAAA;AAGlE,OAAO,KAAK,EAKV,aAAa,EACd,MAAM,iBAAiB,CAAA;AAsBxB,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,OAAO,CAAA;CACZ,CAAA;AAED,wBAAgB,cAAc,CAC5B,cAAc,EAAE,oBAAoB,GACnC,iBAAiB,CAAC,aAAa,CAAC,CA4IlC"}
|
package/lib/handlers/graph.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defer } from '@enkaku/async';
|
|
2
1
|
import { fromB64, toB64 } from '@enkaku/codec';
|
|
2
|
+
import { consume } from '@enkaku/generator';
|
|
3
3
|
import { createSchema } from '@kubun/graphql';
|
|
4
4
|
import { AttachmentID } from '@kubun/id';
|
|
5
5
|
import { GraphModel } from '@kubun/protocol';
|
|
@@ -143,29 +143,19 @@ export function createHandlers(handlersParams) {
|
|
|
143
143
|
if ('errors' in subscription) {
|
|
144
144
|
return toGraphResult(subscription);
|
|
145
145
|
}
|
|
146
|
-
const generator = subscription;
|
|
147
|
-
let aborted = false;
|
|
148
|
-
const done = defer();
|
|
149
|
-
ctx.signal.addEventListener('abort', ()=>{
|
|
150
|
-
aborted = true;
|
|
151
|
-
generator.return(null);
|
|
152
|
-
if (ctx.signal.reason === 'Close') {
|
|
153
|
-
done.resolve(null);
|
|
154
|
-
} else {
|
|
155
|
-
done.reject(ctx.signal.reason);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
146
|
const writer = ctx.writable.getWriter();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
147
|
+
try {
|
|
148
|
+
await consume(subscription, async (value)=>{
|
|
149
|
+
await writer.write(toGraphResult(value));
|
|
150
|
+
}, ctx.signal);
|
|
151
|
+
} catch (reason) {
|
|
152
|
+
if (reason !== 'Close') {
|
|
153
|
+
throw reason;
|
|
163
154
|
}
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
} finally{
|
|
156
|
+
await writer.close();
|
|
166
157
|
}
|
|
167
|
-
|
|
168
|
-
return done.promise;
|
|
158
|
+
return null;
|
|
169
159
|
}
|
|
170
160
|
};
|
|
171
161
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -18,23 +18,24 @@
|
|
|
18
18
|
"@automerge/automerge": "^2.2.8",
|
|
19
19
|
"@enkaku/async": "^0.12.0",
|
|
20
20
|
"@enkaku/codec": "^0.12.0",
|
|
21
|
+
"@enkaku/generator": "^0.12.0",
|
|
21
22
|
"@enkaku/schema": "^0.12.0",
|
|
22
23
|
"@enkaku/server": "^0.12.0",
|
|
23
24
|
"@enkaku/token": "^0.12.0",
|
|
24
25
|
"@enkaku/transport": "^0.12.0",
|
|
25
26
|
"graphql": "^16.9.0",
|
|
26
|
-
"@kubun/
|
|
27
|
-
"@kubun/
|
|
27
|
+
"@kubun/client": "^0.3.1",
|
|
28
|
+
"@kubun/graphql": "^0.3.1",
|
|
29
|
+
"@kubun/protocol": "^0.3.1",
|
|
28
30
|
"@kubun/id": "^0.3.0",
|
|
29
|
-
"@kubun/
|
|
30
|
-
"@kubun/db": "^0.3.0"
|
|
31
|
+
"@kubun/db": "^0.3.1"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@databases/pg-test": "^3.1.2",
|
|
34
35
|
"@enkaku/stream": "^0.12.0",
|
|
35
36
|
"graphql-relay": "^0.10.2",
|
|
36
|
-
"@kubun/db-postgres": "^0.3.
|
|
37
|
-
"@kubun/db-sqlite": "^0.3.
|
|
37
|
+
"@kubun/db-postgres": "^0.3.1",
|
|
38
|
+
"@kubun/db-sqlite": "^0.3.1"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"build:clean": "del lib",
|