@kubun/service-graph-api 0.17.2 → 0.18.0
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/handlers.d.ts +2 -1
- package/lib/handlers.js +23 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +22 -1
- package/package.json +20 -20
package/lib/handlers.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ export type CreateHandlersParams = {
|
|
|
15
15
|
signingIdentity: SigningIdentity | null;
|
|
16
16
|
transactionManager: TransactionManager;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type GraphHandlers = ProcedureHandlers<GraphProtocol>;
|
|
19
|
+
export declare function createGraphHandlers(params: CreateHandlersParams): GraphHandlers;
|
package/lib/handlers.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { stringifyToken } from '@kokuin/token';
|
|
2
|
+
import { MembershipCheckUnavailableError } from '@kubun/engine';
|
|
2
3
|
import { DocumentID } from '@kubun/id';
|
|
3
4
|
import { convertPatchInput, createMutationOperations, WriteAccessDeniedError } from '@kubun/mutation';
|
|
4
5
|
import { consume } from '@sozai/generator';
|
|
@@ -252,6 +253,16 @@ export function createGraphHandlers(params) {
|
|
|
252
253
|
tokens
|
|
253
254
|
});
|
|
254
255
|
} catch (cause) {
|
|
256
|
+
if (cause instanceof MembershipCheckUnavailableError) {
|
|
257
|
+
return toGraphResult({
|
|
258
|
+
data: null,
|
|
259
|
+
errors: [
|
|
260
|
+
new GraphQLError(cause.message, {
|
|
261
|
+
extensions: cause.extensions
|
|
262
|
+
})
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
255
266
|
if (cause instanceof WriteAccessDeniedError) {
|
|
256
267
|
return toGraphResult({
|
|
257
268
|
data: null,
|
|
@@ -505,6 +516,18 @@ export function createGraphHandlers(params) {
|
|
|
505
516
|
tokens
|
|
506
517
|
});
|
|
507
518
|
} catch (cause) {
|
|
519
|
+
if (cause instanceof MembershipCheckUnavailableError) {
|
|
520
|
+
// Keep the buffered writes so the caller can retry this transaction.
|
|
521
|
+
return {
|
|
522
|
+
success: false,
|
|
523
|
+
error: {
|
|
524
|
+
code: cause.code,
|
|
525
|
+
message: cause.message,
|
|
526
|
+
docID: cause.docID,
|
|
527
|
+
retryable: true
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
508
531
|
if (cause instanceof WriteAccessDeniedError) {
|
|
509
532
|
// Revocation between begin and commit — surface the reason on the
|
|
510
533
|
// wire via the typed `error` field so callers can distinguish
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { AccessRules } from '@kubun/plugin-service-api';
|
|
|
3
3
|
import type { TransactionManagerOptions } from './transaction-manager.js';
|
|
4
4
|
export type { GraphProtocol } from '@kubun/protocol';
|
|
5
5
|
export type { CreateHandlersParams } from './handlers.js';
|
|
6
|
-
export { createGraphHandlers } from './handlers.js';
|
|
6
|
+
export { createGraphHandlers, type GraphHandlers } from './handlers.js';
|
|
7
7
|
export type { TransactionManagerOptions } from './transaction-manager.js';
|
|
8
8
|
export { TransactionManager } from './transaction-manager.js';
|
|
9
9
|
export type GraphServicePluginOptions = {
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,29 @@
|
|
|
3
3
|
// and transaction-manager building blocks the RPC plugin still composes directly.
|
|
4
4
|
// The wire contract itself lives in `@kubun/protocol` and is re-exported here.
|
|
5
5
|
import { isSigningIdentity } from '@kokuin/token';
|
|
6
|
+
import { GRAPH_LONG_LIVED_PROCEDURES, graphProtocol } from '@kubun/protocol';
|
|
6
7
|
import { createGraphHandlers } from './handlers.js';
|
|
7
8
|
import { TransactionManager } from './transaction-manager.js';
|
|
8
9
|
export { createGraphHandlers } from './handlers.js';
|
|
9
10
|
export { TransactionManager } from './transaction-manager.js';
|
|
11
|
+
// The protocol's schemas carry `$id`s that `@kubun/protocol` also registers on the
|
|
12
|
+
// shared validator for standalone use. Compiled again inside the host's message
|
|
13
|
+
// schema they clash as ambiguous references, so the served copy drops them (nothing
|
|
14
|
+
// references them by `$ref`).
|
|
15
|
+
function withoutSchemaIDs(value) {
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
return value.map(withoutSchemaIDs);
|
|
18
|
+
}
|
|
19
|
+
if (value != null && typeof value === 'object') {
|
|
20
|
+
const copy = {};
|
|
21
|
+
for (const [key, entry] of Object.entries(value)){
|
|
22
|
+
if (key !== '$id' || typeof entry !== 'string') copy[key] = withoutSchemaIDs(entry);
|
|
23
|
+
}
|
|
24
|
+
return copy;
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
const servedGraphProtocol = withoutSchemaIDs(graphProtocol);
|
|
10
29
|
// The service name the provider registers under and the host toggles via `services`.
|
|
11
30
|
const GRAPH_SERVICE_NAME = 'graph';
|
|
12
31
|
/**
|
|
@@ -39,7 +58,9 @@ const GRAPH_SERVICE_NAME = 'graph';
|
|
|
39
58
|
// The typed `ProcedureHandlers<GraphProtocol>` narrows to the host's
|
|
40
59
|
// structural `Handlers` at this one seam, mirroring the host's serve cast.
|
|
41
60
|
handlers: handlers,
|
|
42
|
-
accessRules: options?.accessRules ?? {}
|
|
61
|
+
accessRules: options?.accessRules ?? {},
|
|
62
|
+
longLivedProcedures: GRAPH_LONG_LIVED_PROCEDURES,
|
|
63
|
+
protocol: servedGraphProtocol
|
|
43
64
|
});
|
|
44
65
|
return {
|
|
45
66
|
name: 'graph-service',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/service-graph-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,30 +15,30 @@
|
|
|
15
15
|
"LICENSE.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@enkaku/server": "^0.21.
|
|
19
|
-
"@kokuin/token": "^0.5.
|
|
20
|
-
"@kubun/engine": "^0.
|
|
21
|
-
"@kubun/hlc": "^0.
|
|
22
|
-
"@kubun/id": "^0.
|
|
23
|
-
"@kubun/mutation": "^0.
|
|
24
|
-
"@kubun/plugin-service-api": "^0.
|
|
25
|
-
"@kubun/protocol": "^0.
|
|
26
|
-
"@sozai/generator": "^0.2.
|
|
18
|
+
"@enkaku/server": "^0.21.5",
|
|
19
|
+
"@kokuin/token": "^0.5.1",
|
|
20
|
+
"@kubun/engine": "^0.18.0",
|
|
21
|
+
"@kubun/hlc": "^0.18.0",
|
|
22
|
+
"@kubun/id": "^0.18.0",
|
|
23
|
+
"@kubun/mutation": "^0.18.0",
|
|
24
|
+
"@kubun/plugin-service-api": "^0.18.0",
|
|
25
|
+
"@kubun/protocol": "^0.18.0",
|
|
26
|
+
"@sozai/generator": "^0.2.2",
|
|
27
27
|
"@sozai/runtime": "^0.1.0",
|
|
28
28
|
"graphql": "^17.0.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@enkaku/client": "^0.21.
|
|
32
|
-
"@enkaku/transport": "^0.21.
|
|
33
|
-
"@kokuin/capability": "^0.
|
|
31
|
+
"@enkaku/client": "^0.21.5",
|
|
32
|
+
"@enkaku/transport": "^0.21.5",
|
|
33
|
+
"@kokuin/capability": "^0.4.2",
|
|
34
34
|
"@kokuin/controller": "^0.1.0",
|
|
35
|
-
"@kubun/client": "^0.
|
|
36
|
-
"@kubun/db": "^0.
|
|
37
|
-
"@kubun/plugin-service-server": "^0.
|
|
38
|
-
"@kubun/store-controller": "^0.
|
|
39
|
-
"@kubun/store-delegation": "^0.
|
|
40
|
-
"@kubun/store-graph": "^0.
|
|
41
|
-
"@kubun/store-p2p": "^0.
|
|
35
|
+
"@kubun/client": "^0.18.0",
|
|
36
|
+
"@kubun/db": "^0.18.0",
|
|
37
|
+
"@kubun/plugin-service-server": "^0.18.0",
|
|
38
|
+
"@kubun/store-controller": "^0.18.0",
|
|
39
|
+
"@kubun/store-delegation": "^0.18.0",
|
|
40
|
+
"@kubun/store-graph": "^0.18.0",
|
|
41
|
+
"@kubun/store-p2p": "^0.18.0",
|
|
42
42
|
"@kubun/test-utils": "^0.0.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|