stream-chat 9.0.0 → 9.0.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/cjs/index.browser.cjs +40 -40
- package/dist/cjs/index.browser.cjs.map +2 -2
- package/dist/cjs/index.node.cjs +40 -40
- package/dist/cjs/index.node.cjs.map +2 -2
- package/dist/esm/index.js +40 -40
- package/dist/esm/index.js.map +2 -2
- package/dist/types/client.d.ts +3 -3
- package/dist/types/constants.d.ts +21 -3
- package/dist/types/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/client.ts +21 -16
- package/src/constants.ts +19 -20
- package/src/types.ts +2 -17
- package/src/utils.ts +6 -7
package/dist/types/client.d.ts
CHANGED
|
@@ -1064,12 +1064,12 @@ export declare class StreamChat {
|
|
|
1064
1064
|
* updateMessage - Update the given message
|
|
1065
1065
|
*
|
|
1066
1066
|
* @param {Omit<MessageResponse, 'mentioned_users'> & { mentioned_users?: string[] }} message object, id needs to be specified
|
|
1067
|
-
* @param {string | { id: string }} [
|
|
1067
|
+
* @param {string | { id: string }} [partialUserOrUserId]
|
|
1068
1068
|
* @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
|
|
1069
1069
|
*
|
|
1070
1070
|
* @return {{ message: LocalMessage | MessageResponse }} Response that includes the message
|
|
1071
1071
|
*/
|
|
1072
|
-
updateMessage(message: LocalMessage | Partial<MessageResponse>,
|
|
1072
|
+
updateMessage(message: LocalMessage | Partial<MessageResponse>, partialUserOrUserId?: string | {
|
|
1073
1073
|
id: string;
|
|
1074
1074
|
}, options?: UpdateMessageOptions): Promise<UpdateMessageAPIResponse>;
|
|
1075
1075
|
/**
|
|
@@ -1085,7 +1085,7 @@ export declare class StreamChat {
|
|
|
1085
1085
|
*
|
|
1086
1086
|
* @return {{ message: MessageResponse }} Response that includes the updated message
|
|
1087
1087
|
*/
|
|
1088
|
-
partialUpdateMessage(id: string, partialMessageObject: PartialMessageUpdate,
|
|
1088
|
+
partialUpdateMessage(id: string, partialMessageObject: PartialMessageUpdate, partialUserOrUserId?: string | {
|
|
1089
1089
|
id: string;
|
|
1090
1090
|
}, options?: UpdateMessageOptions): Promise<UpdateMessageAPIResponse>;
|
|
1091
1091
|
deleteMessage(messageID: string, hardDelete?: boolean): Promise<APIResponse & {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReservedUpdatedMessageFields } from './types';
|
|
2
1
|
export declare const DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
|
|
3
2
|
export declare const DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
|
|
4
3
|
export declare const DEFAULT_MESSAGE_SET_PAGINATION: {
|
|
@@ -8,5 +7,24 @@ export declare const DEFAULT_MESSAGE_SET_PAGINATION: {
|
|
|
8
7
|
export declare const DEFAULT_UPLOAD_SIZE_LIMIT_BYTES: number;
|
|
9
8
|
export declare const API_MAX_FILES_ALLOWED_PER_MESSAGE = 10;
|
|
10
9
|
export declare const MAX_CHANNEL_MEMBER_COUNT_IN_CHANNEL_QUERY = 100;
|
|
11
|
-
export declare const RESERVED_UPDATED_MESSAGE_FIELDS:
|
|
12
|
-
|
|
10
|
+
export declare const RESERVED_UPDATED_MESSAGE_FIELDS: {
|
|
11
|
+
readonly created_at: true;
|
|
12
|
+
readonly deleted_at: true;
|
|
13
|
+
readonly pinned_at: true;
|
|
14
|
+
readonly updated_at: true;
|
|
15
|
+
readonly command: true;
|
|
16
|
+
readonly mentioned_users: true;
|
|
17
|
+
readonly quoted_message: true;
|
|
18
|
+
readonly latest_reactions: true;
|
|
19
|
+
readonly own_reactions: true;
|
|
20
|
+
readonly reaction_counts: true;
|
|
21
|
+
readonly reply_count: true;
|
|
22
|
+
readonly i18n: true;
|
|
23
|
+
readonly type: true;
|
|
24
|
+
readonly html: true;
|
|
25
|
+
readonly __html: true;
|
|
26
|
+
readonly user: true;
|
|
27
|
+
};
|
|
28
|
+
export declare const LOCAL_MESSAGE_FIELDS: {
|
|
29
|
+
readonly error: true;
|
|
30
|
+
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { StableWSConnection } from './connection';
|
|
|
5
5
|
import type { Role } from './permissions';
|
|
6
6
|
import type { CustomAttachmentData, CustomChannelData, CustomCommandData, CustomEventData, CustomMemberData, CustomMessageData, CustomPollData, CustomPollOptionData, CustomReactionData, CustomThreadData, CustomUserData } from './custom_types';
|
|
7
7
|
import type { NotificationManager } from './notifications';
|
|
8
|
+
import type { RESERVED_UPDATED_MESSAGE_FIELDS } from './constants';
|
|
8
9
|
/**
|
|
9
10
|
* Utility Types
|
|
10
11
|
*/
|
|
@@ -2122,7 +2123,7 @@ export type TokenOrProvider = null | string | TokenProvider | undefined;
|
|
|
2122
2123
|
export type TokenProvider = () => Promise<string>;
|
|
2123
2124
|
export type TranslationLanguages = 'af' | 'am' | 'ar' | 'az' | 'bg' | 'bn' | 'bs' | 'cs' | 'da' | 'de' | 'el' | 'en' | 'es' | 'es-MX' | 'et' | 'fa' | 'fa-AF' | 'fi' | 'fr' | 'fr-CA' | 'ha' | 'he' | 'hi' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ka' | 'ko' | 'lt' | 'lv' | 'ms' | 'nl' | 'no' | 'pl' | 'ps' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'so' | 'sq' | 'sr' | 'sv' | 'sw' | 'ta' | 'th' | 'tl' | 'tr' | 'uk' | 'ur' | 'vi' | 'zh' | 'zh-TW' | (string & {});
|
|
2124
2125
|
export type TypingStartEvent = Event;
|
|
2125
|
-
export type ReservedUpdatedMessageFields =
|
|
2126
|
+
export type ReservedUpdatedMessageFields = keyof typeof RESERVED_UPDATED_MESSAGE_FIELDS;
|
|
2126
2127
|
export type UpdatedMessage = Omit<MessageResponse, ReservedUpdatedMessageFields> & {
|
|
2127
2128
|
mentioned_users?: string[];
|
|
2128
2129
|
type?: MessageLabel;
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -2860,28 +2860,28 @@ export class StreamChat {
|
|
|
2860
2860
|
* updateMessage - Update the given message
|
|
2861
2861
|
*
|
|
2862
2862
|
* @param {Omit<MessageResponse, 'mentioned_users'> & { mentioned_users?: string[] }} message object, id needs to be specified
|
|
2863
|
-
* @param {string | { id: string }} [
|
|
2863
|
+
* @param {string | { id: string }} [partialUserOrUserId]
|
|
2864
2864
|
* @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
|
|
2865
2865
|
*
|
|
2866
2866
|
* @return {{ message: LocalMessage | MessageResponse }} Response that includes the message
|
|
2867
2867
|
*/
|
|
2868
2868
|
async updateMessage(
|
|
2869
2869
|
message: LocalMessage | Partial<MessageResponse>,
|
|
2870
|
-
|
|
2870
|
+
partialUserOrUserId?: string | { id: string },
|
|
2871
2871
|
options?: UpdateMessageOptions,
|
|
2872
2872
|
) {
|
|
2873
2873
|
if (!message.id) {
|
|
2874
|
-
throw Error('Please specify the message
|
|
2874
|
+
throw Error('Please specify the message.id when calling updateMessage');
|
|
2875
2875
|
}
|
|
2876
|
+
|
|
2877
|
+
// should not include user object
|
|
2876
2878
|
const payload = toUpdatedMessagePayload(message);
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
};
|
|
2884
|
-
}
|
|
2879
|
+
|
|
2880
|
+
// add user_id (if exists)
|
|
2881
|
+
if (typeof partialUserOrUserId === 'string') {
|
|
2882
|
+
payload.user_id = partialUserOrUserId;
|
|
2883
|
+
} else if (typeof partialUserOrUserId?.id === 'string') {
|
|
2884
|
+
payload.user_id = partialUserOrUserId.id;
|
|
2885
2885
|
}
|
|
2886
2886
|
|
|
2887
2887
|
return await this.post<UpdateMessageAPIResponse>(
|
|
@@ -2909,16 +2909,21 @@ export class StreamChat {
|
|
|
2909
2909
|
async partialUpdateMessage(
|
|
2910
2910
|
id: string,
|
|
2911
2911
|
partialMessageObject: PartialMessageUpdate,
|
|
2912
|
-
|
|
2912
|
+
partialUserOrUserId?: string | { id: string },
|
|
2913
2913
|
options?: UpdateMessageOptions,
|
|
2914
2914
|
) {
|
|
2915
2915
|
if (!id) {
|
|
2916
|
-
throw Error('Please specify the message
|
|
2916
|
+
throw Error('Please specify the message.id when calling partialUpdateMessage');
|
|
2917
2917
|
}
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2918
|
+
|
|
2919
|
+
let user: { id: string } | undefined = undefined;
|
|
2920
|
+
|
|
2921
|
+
if (typeof partialUserOrUserId === 'string') {
|
|
2922
|
+
user = { id: partialUserOrUserId };
|
|
2923
|
+
} else if (typeof partialUserOrUserId?.id === 'string') {
|
|
2924
|
+
user = { id: partialUserOrUserId.id };
|
|
2921
2925
|
}
|
|
2926
|
+
|
|
2922
2927
|
return await this.put<UpdateMessageAPIResponse>(
|
|
2923
2928
|
this.baseURL + `/messages/${encodeURIComponent(id)}`,
|
|
2924
2929
|
{
|
package/src/constants.ts
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import type { ReservedUpdatedMessageFields } from './types';
|
|
2
|
-
|
|
3
1
|
export const DEFAULT_QUERY_CHANNELS_MESSAGE_LIST_PAGE_SIZE = 25;
|
|
4
2
|
export const DEFAULT_QUERY_CHANNEL_MESSAGE_LIST_PAGE_SIZE = 100;
|
|
5
3
|
export const DEFAULT_MESSAGE_SET_PAGINATION = { hasNext: false, hasPrev: false };
|
|
6
4
|
export const DEFAULT_UPLOAD_SIZE_LIMIT_BYTES = 100 * 1024 * 1024; // 100 MB
|
|
7
5
|
export const API_MAX_FILES_ALLOWED_PER_MESSAGE = 10;
|
|
8
6
|
export const MAX_CHANNEL_MEMBER_COUNT_IN_CHANNEL_QUERY = 100;
|
|
9
|
-
export const RESERVED_UPDATED_MESSAGE_FIELDS
|
|
7
|
+
export const RESERVED_UPDATED_MESSAGE_FIELDS = {
|
|
10
8
|
// Dates should not be converted back to ISO strings as JS looses precision on them (milliseconds)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
created_at: true,
|
|
10
|
+
deleted_at: true,
|
|
11
|
+
pinned_at: true,
|
|
12
|
+
updated_at: true,
|
|
13
|
+
command: true,
|
|
16
14
|
// Back-end enriches these fields
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
mentioned_users: true,
|
|
16
|
+
quoted_message: true,
|
|
19
17
|
// Client-specific fields
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
latest_reactions: true,
|
|
19
|
+
own_reactions: true,
|
|
20
|
+
reaction_counts: true,
|
|
21
|
+
reply_count: true,
|
|
24
22
|
// Message text related fields that shouldn't be in update
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
i18n: true,
|
|
24
|
+
type: true,
|
|
25
|
+
html: true,
|
|
26
|
+
__html: true,
|
|
27
|
+
user: true,
|
|
28
|
+
} as const;
|
|
30
29
|
|
|
31
|
-
export const LOCAL_MESSAGE_FIELDS =
|
|
30
|
+
export const LOCAL_MESSAGE_FIELDS = { error: true } as const;
|
package/src/types.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
CustomUserData,
|
|
18
18
|
} from './custom_types';
|
|
19
19
|
import type { NotificationManager } from './notifications';
|
|
20
|
+
import type { RESERVED_UPDATED_MESSAGE_FIELDS } from './constants';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Utility Types
|
|
@@ -2945,23 +2946,7 @@ export type TranslationLanguages =
|
|
|
2945
2946
|
|
|
2946
2947
|
export type TypingStartEvent = Event;
|
|
2947
2948
|
|
|
2948
|
-
export type ReservedUpdatedMessageFields =
|
|
2949
|
-
| 'command'
|
|
2950
|
-
| 'created_at'
|
|
2951
|
-
| 'deleted_at'
|
|
2952
|
-
| 'html'
|
|
2953
|
-
| 'i18n'
|
|
2954
|
-
| 'latest_reactions'
|
|
2955
|
-
// the the original array of UserResponse object is converted to array of user ids and re-inserted before sending the update request
|
|
2956
|
-
| 'mentioned_users'
|
|
2957
|
-
| 'own_reactions'
|
|
2958
|
-
| 'pinned_at'
|
|
2959
|
-
| 'quoted_message'
|
|
2960
|
-
| 'reaction_counts'
|
|
2961
|
-
| 'reply_count'
|
|
2962
|
-
| 'type'
|
|
2963
|
-
| 'updated_at'
|
|
2964
|
-
| '__html';
|
|
2949
|
+
export type ReservedUpdatedMessageFields = keyof typeof RESERVED_UPDATED_MESSAGE_FIELDS;
|
|
2965
2950
|
|
|
2966
2951
|
export type UpdatedMessage = Omit<MessageResponse, ReservedUpdatedMessageFields> & {
|
|
2967
2952
|
mentioned_users?: string[];
|
package/src/utils.ts
CHANGED
|
@@ -367,14 +367,14 @@ export const localMessageToNewMessagePayload = (localMessage: LocalMessage): Mes
|
|
|
367
367
|
export const toUpdatedMessagePayload = (
|
|
368
368
|
message: LocalMessage | Partial<MessageResponse>,
|
|
369
369
|
): UpdatedMessage => {
|
|
370
|
+
const reservedKeys = {
|
|
371
|
+
...RESERVED_UPDATED_MESSAGE_FIELDS,
|
|
372
|
+
...LOCAL_MESSAGE_FIELDS,
|
|
373
|
+
} as const;
|
|
374
|
+
|
|
370
375
|
const messageFields = Object.fromEntries(
|
|
371
376
|
Object.entries(message).filter(
|
|
372
|
-
([key]) =>
|
|
373
|
-
![...RESERVED_UPDATED_MESSAGE_FIELDS, ...LOCAL_MESSAGE_FIELDS].includes(
|
|
374
|
-
key as
|
|
375
|
-
| (typeof RESERVED_UPDATED_MESSAGE_FIELDS)[number]
|
|
376
|
-
| (typeof LOCAL_MESSAGE_FIELDS)[number],
|
|
377
|
-
),
|
|
377
|
+
([key]) => !reservedKeys[key as keyof typeof reservedKeys],
|
|
378
378
|
),
|
|
379
379
|
) as UpdatedMessage;
|
|
380
380
|
|
|
@@ -384,7 +384,6 @@ export const toUpdatedMessagePayload = (
|
|
|
384
384
|
mentioned_users: message.mentioned_users?.map((user) =>
|
|
385
385
|
typeof user === 'string' ? user : user.id,
|
|
386
386
|
),
|
|
387
|
-
user_id: message.user?.id ?? message.user_id,
|
|
388
387
|
};
|
|
389
388
|
};
|
|
390
389
|
|