@leaven-graphql/ws 0.1.0 → 0.2.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/LICENSE +1 -1
- package/README.md +326 -81
- package/dist/handler.d.ts +21 -2
- package/dist/handler.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4749 -4052
- package/dist/manager.d.ts +44 -9
- package/dist/manager.d.ts.map +1 -1
- package/dist/protocol.d.ts +30 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/pubsub.d.ts +13 -2
- package/dist/pubsub.d.ts.map +1 -1
- package/package.json +9 -6
package/dist/manager.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @leaven-graphql/ws - Subscription manager
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2026
|
|
4
|
+
* Copyright 2026 Joseph Quinn
|
|
5
5
|
* Licensed under the Apache License, Version 2.0
|
|
6
6
|
*/
|
|
7
7
|
import type { GraphQLSchema } from 'graphql';
|
|
8
|
-
import { type GraphQLRequest, type GraphQLResponse } from '@leaven-graphql/core';
|
|
8
|
+
import { LeavenExecutor, type ExecutorConfig, type GraphQLRequest, type GraphQLResponse } from '@leaven-graphql/core';
|
|
9
9
|
/**
|
|
10
10
|
* Subscription status
|
|
11
11
|
*/
|
|
@@ -39,17 +39,47 @@ export interface SubscriptionManagerConfig {
|
|
|
39
39
|
maxSubscriptionsPerConnection?: number;
|
|
40
40
|
/** Subscription timeout in milliseconds */
|
|
41
41
|
subscriptionTimeout?: number;
|
|
42
|
+
/**
|
|
43
|
+
* How operations are executed.
|
|
44
|
+
*
|
|
45
|
+
* - An existing {@link LeavenExecutor}: reuse it. Preferred when the process
|
|
46
|
+
* already has one (an HTTP transport, say) — a second executor re-prints
|
|
47
|
+
* the whole SDL to build its validation fingerprint and keeps its own
|
|
48
|
+
* document and compiled-query caches, so sharing halves both.
|
|
49
|
+
* - An {@link ExecutorConfig} without `schema`: build an executor with these
|
|
50
|
+
* options. Without this, subscriptions — the longest-lived transport —
|
|
51
|
+
* silently run on executor defaults and cannot inherit
|
|
52
|
+
* `introspection: false`, `maxDepth`, `maxComplexity` or a shared cache.
|
|
53
|
+
*
|
|
54
|
+
* Defaults to a new executor configured with `schema` alone.
|
|
55
|
+
*/
|
|
56
|
+
executor?: LeavenExecutor | Omit<ExecutorConfig, 'schema'>;
|
|
42
57
|
}
|
|
43
58
|
/**
|
|
44
59
|
* Manages GraphQL subscriptions
|
|
45
60
|
*/
|
|
46
61
|
export declare class SubscriptionManager {
|
|
47
62
|
private readonly executor;
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Subscriptions grouped by connection: `connectionId -> subscriptionId ->
|
|
65
|
+
* Subscription`.
|
|
66
|
+
*
|
|
67
|
+
* The nesting is load-bearing, not a convenience. graphql-ws operation ids
|
|
68
|
+
* are unique only WITHIN a connection — reference clients use a
|
|
69
|
+
* per-connection counter starting at `"1"` — so a flat map keyed on the
|
|
70
|
+
* client-supplied id alone lets one connection's subscribe clobber
|
|
71
|
+
* another's, and one connection's `complete` tear another's down.
|
|
72
|
+
*/
|
|
73
|
+
private readonly connections;
|
|
50
74
|
private readonly maxSubscriptionsPerConnection;
|
|
51
75
|
private readonly subscriptionTimeout;
|
|
52
76
|
constructor(config: SubscriptionManagerConfig);
|
|
77
|
+
/**
|
|
78
|
+
* Execute a single-result operation (query or mutation) on the same
|
|
79
|
+
* executor that serves subscriptions, so both transports honour the same
|
|
80
|
+
* limits and share the same caches.
|
|
81
|
+
*/
|
|
82
|
+
execute<TContext = unknown>(request: GraphQLRequest, context?: TContext): Promise<GraphQLResponse>;
|
|
53
83
|
/**
|
|
54
84
|
* Create a new subscription
|
|
55
85
|
*/
|
|
@@ -61,23 +91,28 @@ export declare class SubscriptionManager {
|
|
|
61
91
|
*/
|
|
62
92
|
private consumeIterator;
|
|
63
93
|
/**
|
|
64
|
-
* Unsubscribe from a subscription
|
|
94
|
+
* Unsubscribe from a subscription.
|
|
95
|
+
*
|
|
96
|
+
* Both identifiers are required: a subscription id is only unique within
|
|
97
|
+
* its connection, so a lookup by id alone would tear down whichever
|
|
98
|
+
* connection happened to register that id last.
|
|
65
99
|
*/
|
|
66
|
-
unsubscribe(subscriptionId: string): boolean;
|
|
100
|
+
unsubscribe(connectionId: string, subscriptionId: string): boolean;
|
|
67
101
|
/**
|
|
68
102
|
* Unsubscribe all subscriptions for a connection
|
|
69
103
|
*/
|
|
70
104
|
unsubscribeConnection(connectionId: string): number;
|
|
71
105
|
/**
|
|
72
|
-
* Get a subscription by ID
|
|
106
|
+
* Get a subscription by connection and subscription ID
|
|
73
107
|
*/
|
|
74
|
-
getSubscription(subscriptionId: string): Subscription | undefined;
|
|
108
|
+
getSubscription(connectionId: string, subscriptionId: string): Subscription | undefined;
|
|
75
109
|
/**
|
|
76
110
|
* Get all subscriptions for a connection
|
|
77
111
|
*/
|
|
78
112
|
getConnectionSubscriptions(connectionId: string): Subscription[];
|
|
79
113
|
/**
|
|
80
|
-
* Get the total number of
|
|
114
|
+
* Get the total number of tracked subscriptions (any status:
|
|
115
|
+
* 'pending' | 'active' | 'completed' | 'error')
|
|
81
116
|
*/
|
|
82
117
|
get subscriptionCount(): number;
|
|
83
118
|
/**
|
package/dist/manager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,KAAK,cAAc,EAC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,GACjB,OAAO,CAAC,eAAe,CAAC;IAK3B;;OAEG;IACU,SAAS,CAAC,QAAQ,GAAG,OAAO,EACvC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,EACzC,UAAU,EAAE,MAAM,IAAI,EACtB,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,IAAI,GACxD,OAAO,CAAC,YAAY,CAAC;IAsGxB;;OAEG;YACW,eAAe;IAmC7B;;;;;;OAMG;IACI,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;IAwBzE;;OAEG;IACI,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAiB1D;;OAEG;IACI,eAAe,CACpB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,GACrB,YAAY,GAAG,SAAS;IAI3B;;OAEG;IACI,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,EAAE;IAKvE;;;OAGG;IACH,IAAW,iBAAiB,IAAI,MAAM,CAMrC;IAED;;OAEG;IACH,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED;;OAEG;IACI,KAAK,IAAI,IAAI;CAMrB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,yBAAyB,GAChC,mBAAmB,CAErB"}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @leaven-graphql/ws - GraphQL over WebSocket protocol
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2026
|
|
4
|
+
* Copyright 2026 Joseph Quinn
|
|
5
5
|
* Licensed under the Apache License, Version 2.0
|
|
6
6
|
*
|
|
7
7
|
* Implements graphql-ws protocol
|
|
@@ -97,10 +97,33 @@ export interface CompleteMessage {
|
|
|
97
97
|
* All message types
|
|
98
98
|
*/
|
|
99
99
|
export type Message = ConnectionInitMessage | ConnectionAckMessage | PingMessage | PongMessage | SubscribeMessage | NextMessage | ErrorMessage | CompleteMessage;
|
|
100
|
+
/**
|
|
101
|
+
* Options for {@link parseMessage}
|
|
102
|
+
*/
|
|
103
|
+
export interface ParseMessageOptions {
|
|
104
|
+
/**
|
|
105
|
+
* Require a string `id` on the message types that carry one
|
|
106
|
+
* (`subscribe`, `next`, `error`, `complete`). Defaults to `true`.
|
|
107
|
+
*
|
|
108
|
+
* `true` is correct for a server parsing CLIENT -> server frames: an
|
|
109
|
+
* operation frame with no id cannot be routed, so rejecting it is the only
|
|
110
|
+
* safe option.
|
|
111
|
+
*
|
|
112
|
+
* Pass `false` when parsing SERVER -> client frames on the client side. A
|
|
113
|
+
* lenient peer may omit the id on `next`/`error`, and a parse throw there is
|
|
114
|
+
* far more disruptive (it tears down the whole connection) than tolerating
|
|
115
|
+
* the frame.
|
|
116
|
+
*/
|
|
117
|
+
requireId?: boolean;
|
|
118
|
+
}
|
|
100
119
|
/**
|
|
101
120
|
* Parse a WebSocket message
|
|
121
|
+
*
|
|
122
|
+
* By default this is strict about the `id` field (see
|
|
123
|
+
* {@link ParseMessageOptions.requireId}); pass `{ requireId: false }` to
|
|
124
|
+
* restore the lenient behaviour for peer frames that may omit it.
|
|
102
125
|
*/
|
|
103
|
-
export declare function parseMessage(data: string | Buffer): Message;
|
|
126
|
+
export declare function parseMessage(data: string | Buffer, options?: ParseMessageOptions): Message;
|
|
104
127
|
/**
|
|
105
128
|
* Format a message for sending
|
|
106
129
|
*/
|
|
@@ -117,10 +140,14 @@ export declare function createNextMessage(id: string, data: Record<string, unkno
|
|
|
117
140
|
}[]): NextMessage;
|
|
118
141
|
/**
|
|
119
142
|
* Create an error message
|
|
143
|
+
*
|
|
144
|
+
* The parameter is deliberately looser than {@link ErrorMessage.payload}, and
|
|
145
|
+
* matches {@link createNextMessage}: graphql-js hands back
|
|
146
|
+
* `GraphQLFormattedError`, an interface with no index signature, so requiring
|
|
147
|
+
* one here would reject the very errors this is called with.
|
|
120
148
|
*/
|
|
121
149
|
export declare function createErrorMessage(id: string, errors: readonly {
|
|
122
150
|
message: string;
|
|
123
|
-
[key: string]: unknown;
|
|
124
151
|
}[]): ErrorMessage;
|
|
125
152
|
/**
|
|
126
153
|
* Create a complete message
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,oBAAY,WAAW;IACrB,cAAc,oBAAoB;IAClC,aAAa,mBAAmB;IAChC,IAAI,SAAS;IACb,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC,cAAc,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW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MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,oBAAoB,CAKtB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAChD,MAAM,CAAC,EAAE,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,GACtC,WAAW,CASb;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,GACrC,YAAY,CAMd;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,CAKjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,WAAW,CAKb"}
|
package/dist/pubsub.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @leaven-graphql/ws - PubSub implementation
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2026
|
|
4
|
+
* Copyright 2026 Joseph Quinn
|
|
5
5
|
* Licensed under the Apache License, Version 2.0
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
@@ -27,14 +27,25 @@ export interface PubSubConfig {
|
|
|
27
27
|
maxSubscribersPerTopic?: number;
|
|
28
28
|
/** Enable topic wildcards */
|
|
29
29
|
wildcards?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Maximum number of payloads buffered by an `asyncIterator` while no
|
|
32
|
+
* consumer is pulling. When the buffer is full, the OLDEST payload is
|
|
33
|
+
* dropped to make room for the newest (drop-oldest policy), so a slow
|
|
34
|
+
* consumer sees the most recent events rather than growing the queue
|
|
35
|
+
* without bound. Unlimited by default.
|
|
36
|
+
*/
|
|
37
|
+
maxQueueSize?: number;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* In-memory PubSub implementation
|
|
33
41
|
*/
|
|
34
42
|
export declare class PubSub implements PubSubEngine {
|
|
35
43
|
private readonly subscribers;
|
|
44
|
+
/** Wildcard patterns, pre-split at subscribe time (pattern -> parts) */
|
|
45
|
+
private readonly wildcardPatterns;
|
|
36
46
|
private readonly maxSubscribersPerTopic;
|
|
37
47
|
private readonly wildcards;
|
|
48
|
+
private readonly maxQueueSize;
|
|
38
49
|
private nextId;
|
|
39
50
|
constructor(config?: PubSubConfig);
|
|
40
51
|
/**
|
|
@@ -50,7 +61,7 @@ export declare class PubSub implements PubSubEngine {
|
|
|
50
61
|
*/
|
|
51
62
|
private publishToWildcards;
|
|
52
63
|
/**
|
|
53
|
-
* Check if a topic pattern matches
|
|
64
|
+
* Check if a pre-split topic pattern matches
|
|
54
65
|
*/
|
|
55
66
|
private matchesWildcard;
|
|
56
67
|
/**
|
package/dist/pubsub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pubsub.d.ts","sourceRoot":"","sources":["../src/pubsub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,CACrC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,KAC3B,MAAM,IAAI,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,sBAAsB,CAAC,EAAE,MAAM,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C7B,MAAM,IAAI;IA+Cb;;OAEG;IACI,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI;IAmB5D;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA2B1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAwBvB;;OAEG;IACI,aAAa,CAAC,CAAC,GAAG,OAAO,EAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GACvB,qBAAqB,CAAC,CAAC,CAAC;IAmF3B;;OAEG;IACI,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIhD;;OAEG;IACI,SAAS,IAAI,MAAM,EAAE;IAI5B;;OAEG;IACI,KAAK,IAAI,IAAI;CAIrB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE1D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaven-graphql/ws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "WebSocket subscriptions support for Leaven GraphQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
14
17
|
"files": [
|
|
15
18
|
"dist",
|
|
16
19
|
"README.md"
|
|
@@ -21,16 +24,16 @@
|
|
|
21
24
|
"websocket",
|
|
22
25
|
"subscriptions"
|
|
23
26
|
],
|
|
24
|
-
"author": "
|
|
27
|
+
"author": "Joseph Quinn",
|
|
25
28
|
"license": "Apache-2.0",
|
|
26
29
|
"dependencies": {
|
|
27
30
|
"graphql": "^16.8.0",
|
|
28
|
-
"@leaven-graphql/core": "0.
|
|
29
|
-
"@leaven-graphql/context": "0.
|
|
30
|
-
"@leaven-graphql/errors": "0.
|
|
31
|
+
"@leaven-graphql/core": "0.2.0",
|
|
32
|
+
"@leaven-graphql/context": "0.2.0",
|
|
33
|
+
"@leaven-graphql/errors": "0.2.0"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
|
-
"@types/bun": "^1.
|
|
36
|
+
"@types/bun": "^1.3.12",
|
|
34
37
|
"typescript": "^5.3.0"
|
|
35
38
|
},
|
|
36
39
|
"peerDependencies": {
|