@kubun/plugin-service-api 0.17.0 → 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/index.d.ts +41 -0
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
|
@@ -49,6 +49,13 @@ export type ServiceHandlerContext = {
|
|
|
49
49
|
* comes from the handler. With no `subject`, the caller acts only for itself.
|
|
50
50
|
*/
|
|
51
51
|
authorize: (subject?: string) => Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Server-derived group ID for this serve, when the transport is bound to a
|
|
54
|
+
* group tunnel. Injected per-serve as a constant (never read from the wire
|
|
55
|
+
* message/param), so a handler cannot spoof it. `undefined` outside a group
|
|
56
|
+
* context.
|
|
57
|
+
*/
|
|
58
|
+
groupID?: string;
|
|
52
59
|
};
|
|
53
60
|
/** A single namespaced procedure handler, e.g. the impl behind `echo/ping`. */
|
|
54
61
|
export type ServiceHandler = (context: ServiceHandlerContext) => unknown | Promise<unknown>;
|
|
@@ -68,6 +75,17 @@ export type ServiceProviderImpl = {
|
|
|
68
75
|
name: string;
|
|
69
76
|
handlers: Handlers;
|
|
70
77
|
accessRules?: AccessRules;
|
|
78
|
+
/**
|
|
79
|
+
* Procedures whose calls stay open for as long as the caller wants them, such as
|
|
80
|
+
* subscriptions. The host does not expire them, and bounds how many each caller
|
|
81
|
+
* holds open instead (see {@link ServiceServerLimits}).
|
|
82
|
+
*/
|
|
83
|
+
longLivedProcedures?: ReadonlyArray<string>;
|
|
84
|
+
/**
|
|
85
|
+
* The wire definition of this service's procedures. When every served service
|
|
86
|
+
* declares one, the host validates incoming messages against their union.
|
|
87
|
+
*/
|
|
88
|
+
protocol?: ServiceProtocol;
|
|
71
89
|
};
|
|
72
90
|
/**
|
|
73
91
|
* Per-service configuration, keyed by service NAME. Discriminated by explicit
|
|
@@ -83,9 +101,26 @@ export type ServiceProviderImpl = {
|
|
|
83
101
|
export type ServiceConfig = boolean | {
|
|
84
102
|
rules?: AccessRules;
|
|
85
103
|
handlers?: Handlers;
|
|
104
|
+
longLivedProcedures?: ReadonlyArray<string>;
|
|
105
|
+
/** Wire definition of a custom service's procedures; see {@link ServiceProviderImpl.protocol}. */
|
|
106
|
+
protocol?: ServiceProtocol;
|
|
107
|
+
};
|
|
108
|
+
/** Per-serve limits on the calls a host `serve()` runs. Every field is optional. */
|
|
109
|
+
export type ServiceServerLimits = {
|
|
110
|
+
/**
|
|
111
|
+
* How long a call that is not long-lived may stay open before the server fails it
|
|
112
|
+
* with `EK05`. Enkaku's default (300 s) when omitted.
|
|
113
|
+
*/
|
|
114
|
+
callTimeoutMs?: number;
|
|
115
|
+
/** Long-lived calls one caller may hold open on this serve. Defaults to 64. */
|
|
116
|
+
maxLongLivedCallsPerCaller?: number;
|
|
117
|
+
/** Long-lived calls all callers together may hold open on this serve. Defaults to 1000. */
|
|
118
|
+
maxLongLivedCalls?: number;
|
|
86
119
|
};
|
|
87
120
|
/** Parameters for a single host `serve()` call. */
|
|
88
121
|
export type ServiceServerServeParams = {
|
|
122
|
+
/** Limits on this serve's calls. See {@link ServiceServerLimits}. */
|
|
123
|
+
limits?: ServiceServerLimits;
|
|
89
124
|
/** Server-side transport this server reads and writes. */
|
|
90
125
|
transport: ServiceServerTransport;
|
|
91
126
|
/** Which services to serve, keyed by service name. See {@link ServiceConfig}. */
|
|
@@ -106,4 +141,10 @@ export type ServiceServerServeParams = {
|
|
|
106
141
|
cache?: DIDCache;
|
|
107
142
|
/** Aborts the server when signalled. */
|
|
108
143
|
signal?: AbortSignal;
|
|
144
|
+
/**
|
|
145
|
+
* Server-derived group ID for this serve, plumbed into each served handler's
|
|
146
|
+
* context as {@link ServiceHandlerContext.groupID}. Set when the transport is
|
|
147
|
+
* bound to a group tunnel; omitted outside a group context.
|
|
148
|
+
*/
|
|
149
|
+
groupID?: string;
|
|
109
150
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/plugin-service-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"LICENSE.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@enkaku/protocol": "^0.21.
|
|
19
|
-
"@enkaku/server": "^0.21.
|
|
20
|
-
"@kokuin/token": "^0.5.
|
|
18
|
+
"@enkaku/protocol": "^0.21.5",
|
|
19
|
+
"@enkaku/server": "^0.21.5",
|
|
20
|
+
"@kokuin/token": "^0.5.1"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|