@streamlayer/sdk-web-api 1.6.13 → 1.6.15
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Client } from '@connectrpc/connect';
|
|
2
2
|
import { Atom } from 'nanostores';
|
|
3
3
|
import type { ServiceType, Message, PlainMessage, MethodInfoServerStreaming } from '@bufbuild/protobuf';
|
|
4
4
|
import { Transport } from './transport';
|
|
5
5
|
type StreamPromiseClient<T extends ServiceType> = {
|
|
6
|
-
[P in keyof
|
|
6
|
+
[P in keyof Client<T> as T['methods'][P] extends MethodInfoServerStreaming<any, any> ? P : never]: T['methods'][P] extends MethodInfoServerStreaming<any, any> ? Client<T>[P] : never;
|
|
7
7
|
};
|
|
8
8
|
type StreamMethods<T extends ServiceType> = {
|
|
9
9
|
[P in keyof StreamPromiseClient<T>]: P;
|
package/lib/grpc/subscription.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MapStore, SingleStore, createMapStore, createSingleStore } from '@streamlayer/sdk-web-interfaces';
|
|
2
2
|
import { isQuotaExceededError } from '@streamlayer/sdk-web-storage';
|
|
3
|
+
import { createLogger } from '@streamlayer/sdk-web-logger';
|
|
3
4
|
import { ConnectError, Code } from '@connectrpc/connect';
|
|
4
5
|
var ServerStreamSubscriptionStatus;
|
|
5
6
|
(function (ServerStreamSubscriptionStatus) {
|
|
@@ -12,6 +13,7 @@ var ServerStreamSubscriptionStatus;
|
|
|
12
13
|
ServerStreamSubscriptionStatus["Reconnect"] = "reconnect";
|
|
13
14
|
ServerStreamSubscriptionStatus["Reconnecting"] = "reconnecting";
|
|
14
15
|
})(ServerStreamSubscriptionStatus || (ServerStreamSubscriptionStatus = {}));
|
|
16
|
+
const consoleLog = createLogger('grpc:stream');
|
|
15
17
|
export class ServerStreamSubscription {
|
|
16
18
|
params;
|
|
17
19
|
streamCancel;
|
|
@@ -66,6 +68,12 @@ export class ServerStreamSubscription {
|
|
|
66
68
|
log.push(newLog);
|
|
67
69
|
this.state.setValue('log', log);
|
|
68
70
|
if (localStorage.getItem('SL_DEBUG')) {
|
|
71
|
+
if (msg.startsWith('received data')) {
|
|
72
|
+
consoleLog.trace({ name: this.options.name, attempt: this.attempt }, 'received data');
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
consoleLog.trace({ name: this.options.name, attempt: this.attempt }, msg);
|
|
76
|
+
}
|
|
69
77
|
try {
|
|
70
78
|
window.sessionStorage.setItem('slstreamlogs', window.sessionStorage.getItem('slstreamlogs') + '\n' + newLog);
|
|
71
79
|
}
|
package/lib/grpc/transport.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MapStore } from '@streamlayer/sdk-web-interfaces';
|
|
2
|
-
import { createRouterTransport, ConnectRouter, Interceptor,
|
|
2
|
+
import { createRouterTransport, ConnectRouter, Interceptor, Client, UnaryRequest, StreamRequest } from '@connectrpc/connect';
|
|
3
3
|
import type { ServiceType, Message, PlainMessage } from '@bufbuild/protobuf';
|
|
4
4
|
import { createGrpcWebTransport } from '@connectrpc/connect-web';
|
|
5
5
|
import { type KeyInput, nanoquery } from '@nanostores/query';
|
|
@@ -56,24 +56,24 @@ export declare class Transport {
|
|
|
56
56
|
refetchInterval?: number;
|
|
57
57
|
retryable?: boolean;
|
|
58
58
|
});
|
|
59
|
-
addSubscription: <T extends ServiceType, Req extends Message<Req>, Res extends Message<Res>>(method: ServerStreamSubscription<T, Req, Res>["method"], params: Atom<PlainMessage<Req>> | PlainMessage<Req>, options: ServerStreamSubscriptionOptions) => ServerStreamSubscription<ServiceType, Message<import("@bufbuild/protobuf").AnyMessage>, Message<import("@bufbuild/protobuf").AnyMessage>, never, never> | ServerStreamSubscription<T, Req, Res, keyof { [P in keyof
|
|
59
|
+
addSubscription: <T extends ServiceType, Req extends Message<Req>, Res extends Message<Res>>(method: ServerStreamSubscription<T, Req, Res>["method"], params: Atom<PlainMessage<Req>> | PlainMessage<Req>, options: ServerStreamSubscriptionOptions) => ServerStreamSubscription<ServiceType, Message<import("@bufbuild/protobuf").AnyMessage>, Message<import("@bufbuild/protobuf").AnyMessage>, never, never> | ServerStreamSubscription<T, Req, Res, keyof { [P in keyof Client<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? Client<T>[P] : never; }, { [P in keyof Client<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? Client<T>[P] : never; }[keyof { [P in keyof Client<T> as T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? P : never]: T["methods"][P] extends import("@bufbuild/protobuf").MethodInfoServerStreaming<any, any> ? Client<T>[P] : never; }]>;
|
|
60
60
|
removeSubscription: (subscription: ServerStreamSubscription<ServiceType, Message, Message>) => void;
|
|
61
61
|
disconnect: () => void;
|
|
62
62
|
registerInterceptor: (interceptor: Interceptor) => void;
|
|
63
63
|
removeInterceptor: (interceptor: Interceptor) => void;
|
|
64
|
-
getClient: <T extends ServiceType>(service: T) =>
|
|
65
|
-
getStreamClient: <T extends ServiceType>(service: T) =>
|
|
64
|
+
getClient: <T extends ServiceType>(service: T) => Client<T>;
|
|
65
|
+
getStreamClient: <T extends ServiceType>(service: T) => Client<T>;
|
|
66
66
|
createPromiseClient: <T extends ServiceType>(service: T, { params, method }: {
|
|
67
67
|
params?: KeyInput;
|
|
68
68
|
method: keyof T["methods"];
|
|
69
69
|
}) => {
|
|
70
|
-
client:
|
|
70
|
+
client: Client<T>;
|
|
71
71
|
createRequestOptions: (options: RequestOptions) => import("@connectrpc/connect").ContextValues;
|
|
72
72
|
queryKey: ((string | number | true) | import("nanostores").ReadableAtom<(string | number | true) | (false | void | null | undefined)> | import("@nanostores/query").FetcherStore<any, any>)[];
|
|
73
73
|
queryKeyStr: string;
|
|
74
74
|
};
|
|
75
75
|
createStreamClient: <T extends ServiceType>(service: T) => {
|
|
76
|
-
client:
|
|
76
|
+
client: Client<T>;
|
|
77
77
|
};
|
|
78
78
|
setSdkKey: (sdkKey: string) => void;
|
|
79
79
|
setAuth: (token: string, userId: string) => void;
|
package/lib/grpc/transport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MapStore, createMapStore } from '@streamlayer/sdk-web-interfaces';
|
|
2
2
|
import { nanoid } from 'nanoid';
|
|
3
|
-
import { createRouterTransport,
|
|
3
|
+
import { createRouterTransport, createClient, createContextValues, createContextKey, } from '@connectrpc/connect';
|
|
4
4
|
import { createGrpcWebTransport } from '@connectrpc/connect-web';
|
|
5
5
|
import { nanoquery } from '@nanostores/query';
|
|
6
6
|
import { __GRPC_DEVTOOLS_EXTENSION__ } from '../utils/devtools';
|
|
@@ -121,7 +121,7 @@ export class Transport {
|
|
|
121
121
|
if (this.clients.has(serviceName)) {
|
|
122
122
|
return this.clients.get(serviceName);
|
|
123
123
|
}
|
|
124
|
-
const client =
|
|
124
|
+
const client = createClient(service, this.transport);
|
|
125
125
|
this.clients.set(serviceName, client);
|
|
126
126
|
return client;
|
|
127
127
|
};
|
|
@@ -130,7 +130,7 @@ export class Transport {
|
|
|
130
130
|
if (this.clients.has(serviceName)) {
|
|
131
131
|
return this.clients.get(serviceName);
|
|
132
132
|
}
|
|
133
|
-
const client =
|
|
133
|
+
const client = createClient(service, this.streamTransport);
|
|
134
134
|
this.clients.set(serviceName, client);
|
|
135
135
|
return client;
|
|
136
136
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/sdk-web-api",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@streamlayer/sdk-web-interfaces": "^1.4.
|
|
25
|
-
"@streamlayer/sdk-web-logger": "^1.0.
|
|
26
|
-
"@streamlayer/sdk-web-storage": "^1.0.
|
|
24
|
+
"@streamlayer/sdk-web-interfaces": "^1.4.2",
|
|
25
|
+
"@streamlayer/sdk-web-logger": "^1.0.36",
|
|
26
|
+
"@streamlayer/sdk-web-storage": "^1.0.36"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@bufbuild/protobuf": "^1.10.0",
|
|
30
|
-
"@connectrpc/connect": "^1.
|
|
31
|
-
"@connectrpc/connect-web": "^1.
|
|
30
|
+
"@connectrpc/connect": "^1.6.1",
|
|
31
|
+
"@connectrpc/connect-web": "^1.6.1",
|
|
32
32
|
"@nanostores/query": "^0.2.10",
|
|
33
33
|
"@streamlayer/sl-eslib": "^5.130.0",
|
|
34
34
|
"@swc/helpers": "~0.5.15",
|