@stream-io/node-sdk 0.3.1 → 0.4.1
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/dist/index.cjs.js +4136 -9282
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.es.js +4136 -9206
- package/dist/index.es.js.map +1 -1
- package/dist/src/BaseApi.d.ts +10 -0
- package/dist/src/StreamCall.d.ts +5 -37
- package/dist/src/StreamChannel.d.ts +7 -34
- package/dist/src/StreamChatClient.d.ts +2 -25
- package/dist/src/StreamClient.d.ts +51 -59
- package/dist/src/StreamModerationClient.d.ts +3 -0
- package/dist/src/StreamVideoClient.d.ts +2 -18
- package/dist/src/gen/chat/ChannelApi.d.ts +33 -0
- package/dist/src/gen/chat/ChatApi.d.ts +241 -0
- package/dist/src/gen/common/CommonApi.d.ts +99 -0
- package/dist/src/gen/model-decoders/index.d.ts +3 -0
- package/dist/src/gen/models/index.d.ts +3881 -0
- package/dist/src/gen/moderation/ModerationApi.d.ts +38 -0
- package/dist/src/gen/video/CallApi.d.ts +56 -0
- package/dist/src/gen/video/VideoApi.d.ts +151 -0
- package/dist/src/types.d.ts +25 -0
- package/dist/src/utils/create-token.d.ts +2 -0
- package/dist/src/utils/rate-limit.d.ts +2 -0
- package/index.ts +2 -3
- package/package.json +5 -4
- package/src/BaseApi.ts +115 -0
- package/src/StreamCall.ts +9 -199
- package/src/StreamChannel.ts +23 -246
- package/src/StreamChatClient.ts +3 -122
- package/src/StreamClient.ts +101 -345
- package/src/StreamModerationClient.ts +3 -0
- package/src/StreamVideoClient.ts +3 -95
- package/src/gen/chat/ChannelApi.ts +270 -0
- package/src/gen/chat/ChatApi.ts +1857 -0
- package/src/gen/common/CommonApi.ts +1004 -0
- package/src/gen/model-decoders/index.ts +1897 -0
- package/src/gen/models/index.ts +6794 -0
- package/src/gen/moderation/ModerationApi.ts +476 -0
- package/src/gen/video/CallApi.ts +309 -0
- package/src/gen/video/VideoApi.ts +1007 -0
- package/src/types.ts +35 -0
- package/src/utils/create-token.ts +6 -1
- package/src/utils/rate-limit.ts +21 -0
- package/dist/src/gen/chat/apis/ProductchatApi.d.ts +0 -1750
- package/dist/src/gen/chat/apis/index.d.ts +0 -1
- package/dist/src/gen/chat/index.d.ts +0 -3
- package/dist/src/gen/chat/models/index.d.ts +0 -14865
- package/dist/src/gen/chat/runtime.d.ts +0 -180
- package/dist/src/gen/video/apis/ProductvideoApi.d.ts +0 -648
- package/dist/src/gen/video/apis/index.d.ts +0 -1
- package/dist/src/gen/video/index.d.ts +0 -3
- package/dist/src/gen/video/models/index.d.ts +0 -5011
- package/dist/src/gen/video/runtime.d.ts +0 -180
- package/src/gen/chat/.openapi-generator/FILES +0 -6
- package/src/gen/chat/.openapi-generator/VERSION +0 -1
- package/src/gen/chat/.openapi-generator-ignore +0 -23
- package/src/gen/chat/apis/ProductchatApi.ts +0 -7007
- package/src/gen/chat/apis/index.ts +0 -3
- package/src/gen/chat/index.ts +0 -5
- package/src/gen/chat/models/index.ts +0 -14766
- package/src/gen/chat/runtime.ts +0 -415
- package/src/gen/video/.openapi-generator/FILES +0 -6
- package/src/gen/video/.openapi-generator/VERSION +0 -1
- package/src/gen/video/.openapi-generator-ignore +0 -23
- package/src/gen/video/apis/ProductvideoApi.ts +0 -2575
- package/src/gen/video/apis/index.ts +0 -3
- package/src/gen/video/index.ts +0 -5
- package/src/gen/video/models/index.ts +0 -5000
- package/src/gen/video/runtime.ts +0 -415
package/src/types.ts
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
export type OmitTypeId<T> = Omit<T, 'type' | 'id' | 'connection_id'>;
|
|
2
2
|
|
|
3
|
+
export interface ApiConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
token: string;
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
timeout: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface RequestMetadata {
|
|
11
|
+
responseHeaders: Headers;
|
|
12
|
+
rateLimit: RateLimit;
|
|
13
|
+
responseCode: number;
|
|
14
|
+
clientRequestId: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type StreamResponse<T> = T & {
|
|
18
|
+
metadata: RequestMetadata;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class StreamError extends Error {
|
|
22
|
+
constructor(
|
|
23
|
+
message: string,
|
|
24
|
+
public metadata: Partial<RequestMetadata>,
|
|
25
|
+
public code?: number,
|
|
26
|
+
errorOptions?: ErrorOptions,
|
|
27
|
+
) {
|
|
28
|
+
super(message, errorOptions);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RateLimit {
|
|
33
|
+
rateLimit?: number;
|
|
34
|
+
rateLimitRemaining?: number;
|
|
35
|
+
rateLimitReset?: Date;
|
|
36
|
+
}
|
|
37
|
+
|
|
3
38
|
interface BaseTokenPayload {
|
|
4
39
|
user_id: string;
|
|
5
40
|
exp: number;
|
|
@@ -2,7 +2,12 @@ import jwt, { Secret, SignOptions } from 'jsonwebtoken';
|
|
|
2
2
|
|
|
3
3
|
export function JWTUserToken(
|
|
4
4
|
apiSecret: Secret,
|
|
5
|
-
payload: {
|
|
5
|
+
payload: {
|
|
6
|
+
user_id: string;
|
|
7
|
+
exp: number;
|
|
8
|
+
iat: number;
|
|
9
|
+
call_cids?: string[];
|
|
10
|
+
} & { [key: string]: any },
|
|
6
11
|
) {
|
|
7
12
|
// make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
8
13
|
if (jwt == null || jwt.sign == null) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RateLimit } from '../types';
|
|
2
|
+
|
|
3
|
+
export const getRateLimitFromResponseHeader = (responseHeaders: Headers) => {
|
|
4
|
+
const rateLimit = responseHeaders.has('x-ratelimit-limit')
|
|
5
|
+
? +responseHeaders.get('x-ratelimit-limit')!
|
|
6
|
+
: undefined;
|
|
7
|
+
const rateLimitRemaining = responseHeaders.has('x-ratelimit-remaining')
|
|
8
|
+
? +responseHeaders.get('x-ratelimit-remaining')!
|
|
9
|
+
: undefined;
|
|
10
|
+
const rateLimitReset = responseHeaders.has('x-ratelimit-reset')
|
|
11
|
+
? new Date(+responseHeaders.get('x-ratelimit-reset')! * 1000)
|
|
12
|
+
: undefined;
|
|
13
|
+
|
|
14
|
+
const result: RateLimit = {
|
|
15
|
+
rateLimit,
|
|
16
|
+
rateLimitRemaining,
|
|
17
|
+
rateLimitReset,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return result;
|
|
21
|
+
};
|