@kubun/plugin-rpc 0.11.0 → 0.12.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/index.js +2 -2
- package/lib/transaction-manager.d.ts +3 -1
- package/lib/transaction-manager.js +3 -3
- package/package.json +24 -24
package/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { TransactionManager } from './transaction-manager.js';
|
|
|
17
17
|
const servers = [];
|
|
18
18
|
const signer = isSigningIdentity(params.identity) ? params.identity : null;
|
|
19
19
|
const transactionManager = new TransactionManager({
|
|
20
|
-
|
|
20
|
+
runtime: params.runtime,
|
|
21
21
|
...options?.transactionConfig
|
|
22
22
|
});
|
|
23
23
|
const handlers = createGraphHandlers({
|
|
@@ -34,7 +34,7 @@ import { TransactionManager } from './transaction-manager.js';
|
|
|
34
34
|
serve: (transport, signal)=>{
|
|
35
35
|
const accessRules = options?.accessRules;
|
|
36
36
|
const baseParams = {
|
|
37
|
-
|
|
37
|
+
runtime: params.runtime,
|
|
38
38
|
handlers,
|
|
39
39
|
logger: params.getLogger('rpc-server'),
|
|
40
40
|
signal,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DocumentMutation, DocumentNode } from '@kubun/protocol';
|
|
2
|
+
import type { Runtime } from '@sozai/runtime';
|
|
2
3
|
export type BufferedMutation = {
|
|
3
4
|
mutation: DocumentMutation;
|
|
4
5
|
jwt: string;
|
|
@@ -16,7 +17,8 @@ export type TransactionContext = {
|
|
|
16
17
|
status: TransactionStatus;
|
|
17
18
|
};
|
|
18
19
|
export type TransactionManagerOptions = {
|
|
19
|
-
|
|
20
|
+
/** Host runtime, used to mint each transaction's id. */
|
|
21
|
+
runtime: Runtime;
|
|
20
22
|
perDIDLimit?: number;
|
|
21
23
|
globalLimit?: number;
|
|
22
24
|
timeoutMS?: number;
|
|
@@ -2,14 +2,14 @@ const DEFAULT_PER_DID_LIMIT = 3;
|
|
|
2
2
|
const DEFAULT_GLOBAL_LIMIT = 20;
|
|
3
3
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
4
4
|
export class TransactionManager {
|
|
5
|
-
#
|
|
5
|
+
#runtime;
|
|
6
6
|
#globalLimit;
|
|
7
7
|
#perDIDLimit;
|
|
8
8
|
#timeoutMS;
|
|
9
9
|
#transactions = new Map();
|
|
10
10
|
#sweepInterval = null;
|
|
11
11
|
constructor(options){
|
|
12
|
-
this.#
|
|
12
|
+
this.#runtime = options.runtime;
|
|
13
13
|
this.#globalLimit = options.globalLimit ?? DEFAULT_GLOBAL_LIMIT;
|
|
14
14
|
this.#perDIDLimit = options.perDIDLimit ?? DEFAULT_PER_DID_LIMIT;
|
|
15
15
|
this.#timeoutMS = options.timeoutMS ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -29,7 +29,7 @@ export class TransactionManager {
|
|
|
29
29
|
throw new Error(`Per-DID transaction limit reached (${this.#perDIDLimit}) for ${callerDID}. Cannot create new transaction.`);
|
|
30
30
|
}
|
|
31
31
|
const ctx = {
|
|
32
|
-
id: this.#getRandomID(),
|
|
32
|
+
id: this.#runtime.getRandomID(),
|
|
33
33
|
callerDID,
|
|
34
34
|
graphID,
|
|
35
35
|
mutations: [],
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/plugin-rpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
|
+
"sideEffects": false,
|
|
5
6
|
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": "./lib/index.js"
|
|
10
9
|
},
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"types": "lib/index.d.ts",
|
|
11
12
|
"files": [
|
|
12
13
|
"lib/*",
|
|
13
14
|
"LICENSE.md"
|
|
14
15
|
],
|
|
15
|
-
"sideEffects": false,
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
17
|
+
"@enkaku/server": "^0.20.0",
|
|
18
|
+
"@kokuin/token": "^0.3.0",
|
|
19
|
+
"@sozai/generator": "^0.2.0",
|
|
18
20
|
"@sozai/runtime": "^0.1.0",
|
|
19
|
-
"@enkaku/server": "^0.18.1",
|
|
20
|
-
"@kokuin/token": "^0.1.1",
|
|
21
21
|
"graphql": "^16.14.2",
|
|
22
|
-
"@kubun/
|
|
23
|
-
"@kubun/
|
|
24
|
-
"@kubun/engine": "^0.
|
|
25
|
-
"@kubun/
|
|
26
|
-
"@kubun/
|
|
27
|
-
"@kubun/protocol": "^0.
|
|
22
|
+
"@kubun/graphql": "^0.12.0",
|
|
23
|
+
"@kubun/db": "^0.12.0",
|
|
24
|
+
"@kubun/engine": "^0.12.0",
|
|
25
|
+
"@kubun/hlc": "^0.12.0",
|
|
26
|
+
"@kubun/mutation": "^0.12.0",
|
|
27
|
+
"@kubun/protocol": "^0.12.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@kubun/client": "^0.
|
|
33
|
-
"@kubun/
|
|
34
|
-
"@kubun/store-
|
|
35
|
-
"@kubun/
|
|
36
|
-
"@kubun/store-p2p": "^0.
|
|
37
|
-
"@kubun/test-utils": "^0.
|
|
30
|
+
"@enkaku/transport": "^0.20.0",
|
|
31
|
+
"@kokuin/capability": "^0.2.1",
|
|
32
|
+
"@kubun/client": "^0.12.0",
|
|
33
|
+
"@kubun/id": "^0.12.0",
|
|
34
|
+
"@kubun/store-graph": "^0.12.0",
|
|
35
|
+
"@kubun/store-delegation": "^0.12.0",
|
|
36
|
+
"@kubun/store-p2p": "^0.12.0",
|
|
37
|
+
"@kubun/test-utils": "^0.12.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
+
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
40
41
|
"build:clean": "del lib",
|
|
41
42
|
"build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
42
43
|
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
43
|
-
"
|
|
44
|
+
"test": "pnpm run test:types && pnpm run test:unit",
|
|
44
45
|
"test:types": "tsc --noEmit -p tsconfig.test.json",
|
|
45
|
-
"test:unit": "vitest run"
|
|
46
|
-
"test": "pnpm run test:types && pnpm run test:unit"
|
|
46
|
+
"test:unit": "vitest run"
|
|
47
47
|
}
|
|
48
48
|
}
|