Skip to content

Commit

Permalink
feat: update to api version 131.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Sep 18, 2024
1 parent 8b37723 commit 74e3dca
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/StreamChannel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChannelApi } from './gen/chat/ChannelApi';
import { ChannelGetOrCreateRequest, QueryMembersRequest } from './gen/models';
import { ChannelGetOrCreateRequest, QueryMembersPayload } from './gen/models';
import { OmitTypeId } from './types';

export class StreamChannel extends ChannelApi {
Expand Down Expand Up @@ -27,7 +27,7 @@ export class StreamChannel extends ChannelApi {
}
};

queryMembers(request?: { payload?: OmitTypeId<QueryMembersRequest> }) {
queryMembers(request?: { payload?: OmitTypeId<QueryMembersPayload> }) {
return this.chatApi.queryMembers({
payload: {
id: this.id,
Expand Down
4 changes: 2 additions & 2 deletions src/StreamClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StreamVideoClient } from './StreamVideoClient';
import crypto from 'crypto';
import { StreamChatClient } from './StreamChatClient';
import { CallTokenPayload, UserTokenPayload } from './types';
import { QueryBannedUsersRequest, UserRequest } from './gen/models';
import { QueryBannedUsersPayload, UserRequest } from './gen/models';
import { StreamModerationClient } from './StreamModerationClient';

export interface StreamClientOptions {
Expand Down Expand Up @@ -67,7 +67,7 @@ export class StreamClient extends CommonApi {
return this.updateUsers({ users: payload });
};

queryBannedUsers = (request?: { payload?: QueryBannedUsersRequest }) => {
queryBannedUsers = (request?: { payload?: QueryBannedUsersPayload }) => {
return this.chat.queryBannedUsers(request);
};

Expand Down
17 changes: 17 additions & 0 deletions src/gen/chat/ChannelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
UpdateChannelPartialResponse,
UpdateChannelRequest,
UpdateChannelResponse,
UpdateMemberPartialRequest,
UpdateMemberPartialResponse,
} from '../models';

export class ChannelApi {
Expand Down Expand Up @@ -167,6 +169,21 @@ export class ChannelApi {
});
};

updateMemberPartial = (
request: UpdateMemberPartialRequest & { user_id: string },
): Promise<StreamResponse<UpdateMemberPartialResponse>> => {
if (!this.id) {
throw new Error(
`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
);
}
return this.chatApi.updateMemberPartial({
id: this.id,
type: this.type,
...request,
});
};

sendMessage = (
request: SendMessageRequest,
): Promise<StreamResponse<SendMessageResponse>> => {
Expand Down
50 changes: 42 additions & 8 deletions src/gen/chat/ChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ import {
PollResponse,
PollVoteResponse,
PollVotesResponse,
QueryBannedUsersRequest,
QueryBannedUsersPayload,
QueryBannedUsersResponse,
QueryChannelsRequest,
QueryChannelsResponse,
QueryMembersRequest,
QueryMessageFlagsRequest,
QueryMembersPayload,
QueryMessageFlagsPayload,
QueryMessageFlagsResponse,
QueryMessageHistoryRequest,
QueryMessageHistoryResponse,
Expand All @@ -66,7 +66,7 @@ import {
QueryThreadsResponse,
ReactionRemovalResponse,
Response,
SearchRequest,
SearchPayload,
SearchResponse,
SendEventRequest,
SendMessageRequest,
Expand All @@ -92,6 +92,8 @@ import {
UpdateChannelTypeResponse,
UpdateCommandRequest,
UpdateCommandResponse,
UpdateMemberPartialRequest,
UpdateMemberPartialResponse,
UpdateMessagePartialRequest,
UpdateMessagePartialResponse,
UpdateMessageRequest,
Expand Down Expand Up @@ -440,6 +442,38 @@ export class ChatApi extends BaseApi {
return { ...response.body, metadata: response.metadata };
};

updateMemberPartial = async (
request: UpdateMemberPartialRequest & {
user_id: string;
type: string;
id: string;
},
): Promise<StreamResponse<UpdateMemberPartialResponse>> => {
const pathParams = {
user_id: request?.user_id,
type: request?.type,
id: request?.id,
};
const body = {
unset: request?.unset,
set: request?.set,
};

const response = await this.sendRequest<
StreamResponse<UpdateMemberPartialResponse>
>(
'PATCH',
'/api/v2/chat/channels/{type}/{id}/member/{user_id}',
pathParams,
undefined,
body,
);

decoders.UpdateMemberPartialResponse?.(response.body);

return { ...response.body, metadata: response.metadata };
};

sendMessage = async (
request: SendMessageRequest & { type: string; id: string },
): Promise<StreamResponse<SendMessageResponse>> => {
Expand Down Expand Up @@ -900,7 +934,7 @@ export class ChatApi extends BaseApi {
};

queryMembers = async (request?: {
payload?: QueryMembersRequest;
payload?: QueryMembersPayload;
}): Promise<StreamResponse<MembersResponse>> => {
const queryParams = {
payload: request?.payload,
Expand Down Expand Up @@ -1329,7 +1363,7 @@ export class ChatApi extends BaseApi {
};

queryMessageFlags = async (request?: {
payload?: QueryMessageFlagsRequest;
payload?: QueryMessageFlagsPayload;
}): Promise<StreamResponse<QueryMessageFlagsResponse>> => {
const queryParams = {
payload: request?.payload,
Expand Down Expand Up @@ -1690,7 +1724,7 @@ export class ChatApi extends BaseApi {
};

queryBannedUsers = async (request?: {
payload?: QueryBannedUsersRequest;
payload?: QueryBannedUsersPayload;
}): Promise<StreamResponse<QueryBannedUsersResponse>> => {
const queryParams = {
payload: request?.payload,
Expand All @@ -1706,7 +1740,7 @@ export class ChatApi extends BaseApi {
};

search = async (request?: {
payload?: SearchRequest;
payload?: SearchPayload;
}): Promise<StreamResponse<SearchResponse>> => {
const queryParams = {
payload: request?.payload,
Expand Down
50 changes: 31 additions & 19 deletions src/gen/model-decoders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ decoders.ChannelStateResponse = (input?: Record<string, any>) => {

hide_messages_before: { type: 'DatetimeType', isSingle: true },

pending_messages: { type: 'PendingMessage', isSingle: false },
pending_messages: { type: 'PendingMessageResponse', isSingle: false },

read: { type: 'ReadStateResponse', isSingle: false },

Expand All @@ -400,7 +400,7 @@ decoders.ChannelStateResponseFields = (input?: Record<string, any>) => {

hide_messages_before: { type: 'DatetimeType', isSingle: true },

pending_messages: { type: 'PendingMessage', isSingle: false },
pending_messages: { type: 'PendingMessageResponse', isSingle: false },

read: { type: 'ReadStateResponse', isSingle: false },

Expand Down Expand Up @@ -445,6 +445,8 @@ decoders.ConfigResponse = (input?: Record<string, any>) => {
created_at: { type: 'DatetimeType', isSingle: true },

updated_at: { type: 'DatetimeType', isSingle: true },

velocity_filter_config: { type: 'VelocityFilterConfig', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -570,8 +572,6 @@ decoders.Flag2 = (input?: Record<string, any>) => {

updated_at: { type: 'DatetimeType', isSingle: true },

moderation_payload: { type: 'ModerationPayload', isSingle: true },

user: { type: 'UserObject', isSingle: true },
};
return decode(typeMappings, input);
Expand Down Expand Up @@ -1057,13 +1057,6 @@ decoders.MessageWithChannelResponse = (input?: Record<string, any>) => {
return decode(typeMappings, input);
};

decoders.ModerationPayload = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
created_at: { type: 'DatetimeType', isSingle: true },
};
return decode(typeMappings, input);
};

decoders.ModerationUsageStats = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
updated_at: { type: 'DatetimeType', isSingle: true },
Expand Down Expand Up @@ -1121,13 +1114,13 @@ decoders.OwnUser = (input?: Record<string, any>) => {
return decode(typeMappings, input);
};

decoders.PendingMessage = (input?: Record<string, any>) => {
decoders.PendingMessageResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
channel: { type: 'Channel', isSingle: true },
channel: { type: 'ChannelResponse', isSingle: true },

message: { type: 'Message', isSingle: true },
message: { type: 'MessageResponse', isSingle: true },

user: { type: 'UserObject', isSingle: true },
user: { type: 'UserResponse', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1450,8 +1443,6 @@ decoders.ReviewQueueItem = (input?: Record<string, any>) => {
feeds_v2_reaction: { type: 'Reaction', isSingle: true },

message: { type: 'Message', isSingle: true },

moderation_payload: { type: 'ModerationPayload', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1606,7 +1597,7 @@ decoders.ThreadStateResponse = (input?: Record<string, any>) => {

updated_at: { type: 'DatetimeType', isSingle: true },

latest_replies: { type: 'Message', isSingle: false },
latest_replies: { type: 'MessageResponse', isSingle: false },

deleted_at: { type: 'DatetimeType', isSingle: true },

Expand All @@ -1629,7 +1620,7 @@ decoders.TruncateChannelResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
channel: { type: 'ChannelResponse', isSingle: true },

message: { type: 'Message', isSingle: true },
message: { type: 'MessageResponse', isSingle: true },
};
return decode(typeMappings, input);
};
Expand Down Expand Up @@ -1725,6 +1716,13 @@ decoders.UpdateCommandResponse = (input?: Record<string, any>) => {
return decode(typeMappings, input);
};

decoders.UpdateMemberPartialResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
channel_member: { type: 'ChannelMemberResponse', isSingle: true },
};
return decode(typeMappings, input);
};

decoders.UpdateMessagePartialResponse = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
message: { type: 'Message', isSingle: true },
Expand Down Expand Up @@ -1860,6 +1858,20 @@ decoders.UserResponse = (input?: Record<string, any>) => {
return decode(typeMappings, input);
};

decoders.VelocityFilterConfig = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
rule: { type: 'VelocityFilterConfigRule', isSingle: false },
};
return decode(typeMappings, input);
};

decoders.VelocityFilterConfigRule = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
timeout: { type: 'DatetimeType', isSingle: true },
};
return decode(typeMappings, input);
};

decoders.WSEvent = (input?: Record<string, any>) => {
const typeMappings: TypeMapping = {
created_at: { type: 'DatetimeType', isSingle: true },
Expand Down
Loading

0 comments on commit 74e3dca

Please sign in to comment.