@kubun/server 0.2.2 → 0.2.3
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,14 +1,10 @@
|
|
|
1
|
-
import type { Document, DocumentData, QueryDocumentsParams } from '@kubun/db';
|
|
1
|
+
import type { Document, DocumentData, ListDocumentsParams, QueryDocumentsParams } from '@kubun/db';
|
|
2
2
|
import { SchemaBuilder, type SharedDefinitions } from '@kubun/graphql';
|
|
3
3
|
import type { DocumentID } from '@kubun/id';
|
|
4
4
|
import { type Connection, type ConnectionArguments } from 'graphql-relay';
|
|
5
|
-
export type ContextListDocumentsParams = {
|
|
6
|
-
model: string | null;
|
|
7
|
-
ids: Array<string>;
|
|
8
|
-
};
|
|
9
5
|
export type Context = {
|
|
10
6
|
createDocument: (modelID: string, data: DocumentData) => Promise<Document>;
|
|
11
|
-
listDocuments: (params:
|
|
7
|
+
listDocuments: (params: ListDocumentsParams) => Promise<Array<Document>>;
|
|
12
8
|
loadDocument: (id: DocumentID | string) => Promise<Document | null>;
|
|
13
9
|
queryDocuments: (params: QueryDocumentsParams) => Promise<Connection<Document>>;
|
|
14
10
|
viewerDID: string;
|
|
@@ -17,8 +13,8 @@ export type Context = {
|
|
|
17
13
|
export declare class ServerSchemaBuilder extends SchemaBuilder<Document, Context> {
|
|
18
14
|
getViewer(ctx: Context): string;
|
|
19
15
|
loadDocument(id: string, ctx: Context): Promise<Document | null>;
|
|
20
|
-
resolveConnection(model: string
|
|
21
|
-
resolveList(model: string
|
|
16
|
+
resolveConnection(model: string, args: ConnectionArguments, ctx: Context): Promise<Connection<Document>>;
|
|
17
|
+
resolveList(model: string, docIDs: Array<string>, ctx: Context): Promise<Array<Document>>;
|
|
22
18
|
buildMutations(id: string, definitions: SharedDefinitions<Document, Context>): void;
|
|
23
19
|
}
|
|
24
20
|
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/data/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/data/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAClG,OAAO,EAAkB,aAAa,EAAE,KAAK,iBAAiB,EAAU,MAAM,gBAAgB,CAAA;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mBAAmB,EAEzB,MAAM,eAAe,CAAA;AAEtB,MAAM,MAAM,OAAO,GAAG;IACpB,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1E,aAAa,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;IACxE,YAAY,EAAE,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAA;IACnE,cAAc,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC/E,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAC5C,CAAA;AAED,qBAAa,mBAAoB,SAAQ,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC;IACvE,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAIzB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAIhE,iBAAiB,CACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,mBAAmB,EACzB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAI1B,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAI/F,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI;CAiEpF"}
|
package/lib/data/graphql.js
CHANGED
|
@@ -11,13 +11,13 @@ export class ServerSchemaBuilder extends SchemaBuilder {
|
|
|
11
11
|
async resolveConnection(model, args, ctx) {
|
|
12
12
|
return await ctx.queryDocuments({
|
|
13
13
|
...args,
|
|
14
|
-
model
|
|
14
|
+
modelIDs: this.getModelIDs(model)
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
async resolveList(model,
|
|
17
|
+
async resolveList(model, docIDs, ctx) {
|
|
18
18
|
return await ctx.listDocuments({
|
|
19
|
-
model,
|
|
20
|
-
|
|
19
|
+
modelIDs: this.getModelIDs(model),
|
|
20
|
+
docIDs
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
buildMutations(id, definitions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/handlers/graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAIV,OAAO,EAER,MAAM,WAAW,CAAA;AAElB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/handlers/graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAIV,OAAO,EAER,MAAM,WAAW,CAAA;AAElB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAA;AAOxB,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,OAAO,CAAA;CACZ,CAAA;AAcD,wBAAgB,cAAc,CAC5B,cAAc,EAAE,oBAAoB,GACnC,iBAAiB,CAAC,aAAa,CAAC,CAyJlC"}
|
package/lib/handlers/graph.js
CHANGED
|
@@ -38,39 +38,6 @@ export function createHandlers(handlersParams) {
|
|
|
38
38
|
async function loadDocument(id) {
|
|
39
39
|
return await db.getDocument(typeof id === 'string' ? DocumentID.fromString(id) : id);
|
|
40
40
|
}
|
|
41
|
-
async function listDocuments(params) {
|
|
42
|
-
const graphModels = await getGraphModels(contextParams.schemaID);
|
|
43
|
-
const models = new Set();
|
|
44
|
-
if (params.model === null) {
|
|
45
|
-
// Match all concrete models
|
|
46
|
-
for (const [id, model] of Object.entries(graphModels)){
|
|
47
|
-
if (model.behavior !== 'interface') {
|
|
48
|
-
models.add(id);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
const matchModel = graphModels[params.model];
|
|
53
|
-
if (matchModel == null) {
|
|
54
|
-
// Model does not exist in graph
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
if (matchModel.behavior === 'interface') {
|
|
58
|
-
// Match all concrete models for the given interface
|
|
59
|
-
for (const [id, model] of Object.entries(graphModels)){
|
|
60
|
-
if (model.interfaces.includes(params.model)) {
|
|
61
|
-
models.add(id);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
// Matches a concrete model
|
|
66
|
-
models.add(params.model);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return await db.listDocuments({
|
|
70
|
-
modelIDs: Array.from(models),
|
|
71
|
-
docIDS: params.ids
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
41
|
// TODO: access control filtering
|
|
75
42
|
async function queryDocuments(params) {
|
|
76
43
|
const { entries, hasMore } = await db.queryDocuments(params);
|
|
@@ -89,7 +56,7 @@ export function createHandlers(handlersParams) {
|
|
|
89
56
|
}
|
|
90
57
|
return {
|
|
91
58
|
createDocument,
|
|
92
|
-
listDocuments,
|
|
59
|
+
listDocuments: async (params)=>await db.listDocuments(params),
|
|
93
60
|
loadDocument,
|
|
94
61
|
queryDocuments,
|
|
95
62
|
mutatedDocuments: contextParams.mutatedDocuments,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"@enkaku/transport": "^0.11.0",
|
|
25
25
|
"graphql": "^16.9.0",
|
|
26
26
|
"graphql-relay": "^0.10.2",
|
|
27
|
-
"@kubun/client": "^0.2.
|
|
28
|
-
"@kubun/
|
|
27
|
+
"@kubun/client": "^0.2.2",
|
|
28
|
+
"@kubun/db": "^0.2.2",
|
|
29
29
|
"@kubun/id": "^0.2.0",
|
|
30
|
-
"@kubun/
|
|
31
|
-
"@kubun/protocol": "^0.2.
|
|
30
|
+
"@kubun/graphql": "^0.2.4",
|
|
31
|
+
"@kubun/protocol": "^0.2.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@databases/pg-test": "^3.1.2",
|