@amityco/ts-sdk 0.0.1-beta.21 → 0.0.1-beta.24
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/@types/domains/channel.d.ts +1 -2
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +5 -2
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +2 -2
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/reaction.d.ts +1 -1
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts +2 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts +1 -0
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/channel/api/updateChannel.d.ts +1 -1
- package/dist/channel/api/updateChannel.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts +3 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts +1 -0
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts +1 -0
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/index.cjs.js +204 -68
- package/dist/index.esm.js +203 -68
- package/dist/index.umd.js +5 -5
- package/dist/message/api/createMessage.d.ts +2 -2
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/api/updateMessage.d.ts +2 -2
- package/dist/message/api/updateMessage.d.ts.map +1 -1
- package/dist/message/events/onMessageUpdated.d.ts.map +1 -1
- package/dist/reaction/events/onReactionAdded.d.ts.map +1 -1
- package/dist/reaction/utils/index.d.ts +1 -0
- package/dist/reaction/utils/index.d.ts.map +1 -1
- package/dist/reaction/utils/prepareMessagePayloadForCache.d.ts +3 -0
- package/dist/reaction/utils/prepareMessagePayloadForCache.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +1 -2
- package/src/@types/domains/content.ts +7 -1
- package/src/@types/domains/message.ts +2 -1
- package/src/@types/domains/reaction.ts +1 -1
- package/src/channel/api/queryChannelMembers.ts +4 -4
- package/src/channel/api/queryChannels.ts +1 -0
- package/src/channel/api/updateChannel.ts +1 -1
- package/src/client/api/connectClient.ts +12 -7
- package/src/comment/api/queryComments.ts +6 -3
- package/src/core/model/identifyModel.ts +18 -0
- package/src/core/query/paging.ts +3 -3
- package/src/core/query/query.ts +19 -1
- package/src/message/api/createMessage.ts +24 -8
- package/src/message/api/updateMessage.ts +2 -2
- package/src/message/events/onMessageUpdated.ts +9 -1
- package/src/reaction/events/onReactionAdded.ts +4 -0
- package/src/reaction/utils/index.ts +1 -0
- package/src/reaction/utils/prepareMessagePayloadForCache.ts +40 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Amity {
|
|
4
|
-
type ChannelType = '
|
|
4
|
+
type ChannelType = 'broadcast' | 'conversation' | 'community' | 'live';
|
|
5
5
|
type Channel<T extends ChannelType = any> = {
|
|
6
6
|
channelId: string;
|
|
7
7
|
displayName?: string;
|
|
8
8
|
avatarFileId?: File<'image'>['fileId'];
|
|
9
|
-
description?: string;
|
|
10
9
|
type: T;
|
|
11
10
|
isDistinct?: boolean;
|
|
12
11
|
isMuted?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;QAEvE,KAAK,OAAO,CAAC,CAAC,SAAS,WAAW,GAAG,GAAG,IAAI;YAC1C,SAAS,EAAE,MAAM,CAAC;YAClB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,YAAY,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;YACvC,IAAI,EAAE,CAAC,CAAC;YAER,UAAU,CAAC,EAAE,OAAO,CAAC;YAErB,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,WAAW,CAAC,EAAE,MAAM,CAAC;YAErB,aAAa,CAAC,EAAE,OAAO,CAAC;YACxB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;YAE1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;YACnC,4BAA4B,CAAC,EAAE,MAAM,CAAC;YAEtC,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,YAAY,CAAC,EAAE,MAAM,CAAC;YAEtB,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;SAChC,GAAG,KAAK,CAAC,QAAQ,GAChB,KAAK,CAAC,QAAQ,GACd,KAAK,CAAC,UAAU,GAChB,KAAK,CAAC,UAAU,CAAC;KACpB;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export {};
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Amity {
|
|
4
|
-
type ContentType = 'text' | 'image' | 'file' | 'video' | 'json' | string;
|
|
4
|
+
type ContentType = 'text' | 'image' | 'file' | 'video' | 'poll' | 'json' | string;
|
|
5
5
|
type ContentDataText = {
|
|
6
6
|
text: string;
|
|
7
7
|
};
|
|
@@ -14,7 +14,10 @@ declare global {
|
|
|
14
14
|
type ContentDataVideo = {
|
|
15
15
|
videoId: Amity.File<'file'>['fileId'];
|
|
16
16
|
};
|
|
17
|
-
type
|
|
17
|
+
type ContentDataPoll = {
|
|
18
|
+
pollId: Amity.Poll['pollId'];
|
|
19
|
+
};
|
|
20
|
+
type ContentData<T extends ContentType> = T extends 'text' ? ContentDataText : T extends 'file' ? ContentDataFile : T extends 'image' ? ContentDataImage : T extends 'video' ? ContentDataVideo : T extends 'poll' ? ContentDataPoll : T extends 'json' ? Record<string, unknown> : T extends string ? string | Record<string, unknown> : never;
|
|
18
21
|
type Content<T extends ContentType, K extends 'type' | 'dataType' = 'dataType'> = {
|
|
19
22
|
[S in K]?: T;
|
|
20
23
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;QAElF,KAAK,eAAe,GAAG;YACrB,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QAEF,KAAK,eAAe,GAAG;YACrB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;SACtC,CAAC;QAEF,KAAK,gBAAgB,GAAG;YACtB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;SACxC,CAAC;QAEF,KAAK,gBAAgB,GAAG;YACtB,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;SACvC,CAAC;QAEF,KAAK,eAAe,GAAG;YACrB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC9B,CAAC;QAEF,KAAK,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,MAAM,GACtD,eAAe,GACf,CAAC,SAAS,MAAM,GAChB,eAAe,GACf,CAAC,SAAS,OAAO,GACjB,gBAAgB,GAChB,CAAC,SAAS,OAAO,GACjB,gBAAgB,GAChB,CAAC,SAAS,MAAM,GAChB,eAAe,GACf,CAAC,SAAS,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,CAAC,SAAS,MAAM,GAChB,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAAC;QAEV,KAAK,OAAO,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,MAAM,GAAG,UAAU,GAAG,UAAU,IAAI;aAC/E,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;SACb,GAAG;YAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;SAAE,CAAC;KAC9B;CACF"}
|
|
@@ -4,7 +4,7 @@ declare global {
|
|
|
4
4
|
type MessageContentType = 'text' | 'file' | 'image' | 'video' | 'audio' | 'custom';
|
|
5
5
|
type MessageContent<T extends Amity.MessageContentType = any> = T extends 'file' | 'image' | 'video' | 'audio' ? {
|
|
6
6
|
fileId: string;
|
|
7
|
-
} :
|
|
7
|
+
} : unknown;
|
|
8
8
|
type Message<T extends Amity.MessageContentType = any> = {
|
|
9
9
|
messageId: string;
|
|
10
10
|
channelId: Amity.Channel['channelId'];
|
|
@@ -13,7 +13,7 @@ declare global {
|
|
|
13
13
|
childrenNumber: number;
|
|
14
14
|
channelSegment: number;
|
|
15
15
|
editedAt: Amity.timestamp;
|
|
16
|
-
} & Amity.Content<T, 'type'> & Amity.MessageContent<T> & Amity.Metadata & Amity.Timestamps & Amity.SoftDelete & Amity.Reactable & Amity.Mentionable<'user' | 'channel'>;
|
|
16
|
+
} & Amity.Content<T, 'type'> & Amity.MessageContent<T> & Amity.Metadata & Amity.Timestamps & Amity.SoftDelete & Amity.Taggable & Amity.Reactable & Amity.Mentionable<'user' | 'channel'>;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;QAEnF,KAAK,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,kBAAkB,GAAG,GAAG,IAAI,CAAC,SAC7D,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,GAClB,
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;QAEnF,KAAK,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,kBAAkB,GAAG,GAAG,IAAI,CAAC,SAC7D,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,GAClB,OAAO,CAAC;QAEZ,KAAK,OAAO,CAAC,CAAC,SAAS,KAAK,CAAC,kBAAkB,GAAG,GAAG,IAAI;YACvD,SAAS,EAAE,MAAM,CAAC;YAElB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACtC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAE7B,QAAQ,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;YAChC,cAAc,EAAE,MAAM,CAAC;YAEvB,cAAc,EAAE,MAAM,CAAC;YAEvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;SAC3B,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,GAC1B,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GACvB,KAAK,CAAC,QAAQ,GACd,KAAK,CAAC,UAAU,GAChB,KAAK,CAAC,UAAU,GAChB,KAAK,CAAC,QAAQ,GACd,KAAK,CAAC,SAAS,GACf,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;KACzC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;QAEpD,KAAK,OAAO,GAAG;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC9B,GAAG,KAAK,CAAC,SAAS,CAAC;QAEpB,KAAK,QAAQ,GAAG,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAElE,KAAK,SAAS,GAAG;YACf,cAAc,EAAE,MAAM,CAAC;YACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;YAEvB,cAAc,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG;gBAChC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;QAEpD,KAAK,OAAO,GAAG;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC9B,GAAG,KAAK,CAAC,SAAS,CAAC;QAEpB,KAAK,QAAQ,GAAG,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAElE,KAAK,SAAS,GAAG;YACf,cAAc,EAAE,MAAM,CAAC;YACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;YAEvB,cAAc,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG;gBAChC,SAAS,EAAE,KAAK,GAAG,QAAQ,CAAC;aAC7B,CAAC;SACH,CAAC;QAEF,KAAK,aAAa,GAAG;YACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;SACrB,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;KACvC;CACF"}
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
export declare const queryChannelMembers: {
|
|
16
16
|
(query: {
|
|
17
17
|
channelId: string;
|
|
18
|
-
|
|
18
|
+
memberships?: ('muted' | 'banned' | 'member')[];
|
|
19
19
|
roles?: string[];
|
|
20
20
|
sortBy?: 'firstCreated' | 'lastCreated';
|
|
21
|
+
search?: string;
|
|
21
22
|
page?: Amity.Page;
|
|
22
23
|
}): Promise<Amity.Cached<Amity.Paged<Amity.Membership<'channel'>>>>;
|
|
23
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/api/queryChannelMembers.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;KAaK;AACL,eAAO,MAAM,mBAAmB;YAAiB;QAC/C,SAAS,EAAE,MAAM,CAAC;QAClB,
|
|
1
|
+
{"version":3,"file":"queryChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/api/queryChannelMembers.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;KAaK;AACL,eAAO,MAAM,mBAAmB;YAAiB;QAC/C,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,CAAC,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC;QAChD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,MAAM,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;QACxC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;KACnB,GAAG,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAgCnE;;;;;;;;;;;;OAYG;mBACmC,WAAW,0BAA0B,CAAC,CAAC,CAAC,CAAC;CAf9E,CAAC"}
|
|
@@ -19,6 +19,7 @@ export declare const queryChannels: {
|
|
|
19
19
|
membership?: "all" | "member" | "notMember" | undefined;
|
|
20
20
|
sortBy?: "displayName" | "firstCreated" | "lastCreated" | undefined;
|
|
21
21
|
types?: Amity.ChannelType | undefined;
|
|
22
|
+
isDeleted?: Amity.Channel['isDeleted'];
|
|
22
23
|
tags?: Amity.Taggable['tags'];
|
|
23
24
|
excludeTags?: Amity.Taggable['tags'];
|
|
24
25
|
page?: Amity.Page | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryChannels.d.ts","sourceRoot":"","sources":["../../../src/channel/api/queryChannels.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;;;;;;
|
|
1
|
+
{"version":3,"file":"queryChannels.d.ts","sourceRoot":"","sources":["../../../src/channel/api/queryChannels.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa;;;;;;oBAKZ,MAAM,OAAO,CAAC,WAAW,CAAC;eAC/B,MAAM,QAAQ,CAAC,MAAM,CAAC;sBACf,MAAM,QAAQ,CAAC,MAAM,CAAC;;oBAElC,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;IA8CrD;;;;;;;;;;;;OAYG;mBAC6B,WAAW,oBAAoB,CAAC,CAAC,CAAC,CAAC;CAflE,CAAC"}
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
* @category Channel API
|
|
14
14
|
* @async
|
|
15
15
|
*/
|
|
16
|
-
export declare const updateChannel: (channelId: Amity.Channel['channelId'], patch: Patch<Amity.Channel, 'displayName' | '
|
|
16
|
+
export declare const updateChannel: (channelId: Amity.Channel['channelId'], patch: Patch<Amity.Channel, 'displayName' | 'avatarFileId' | 'tags' | 'metadata'>) => Promise<Amity.Cached<Amity.Channel>>;
|
|
17
17
|
//# sourceMappingURL=updateChannel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateChannel.d.ts","sourceRoot":"","sources":["../../../src/channel/api/updateChannel.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,cACb,MAAM,OAAO,CAAC,WAAW,CAAC,SAC9B,MAAM,MAAM,OAAO,EAAE,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"updateChannel.d.ts","sourceRoot":"","sources":["../../../src/channel/api/updateChannel.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,cACb,MAAM,OAAO,CAAC,WAAW,CAAC,SAC9B,MAAM,MAAM,OAAO,EAAE,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,UAAU,CAAC,KAChF,QAAQ,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,CAkBrC,CAAC"}
|
|
@@ -23,5 +23,7 @@ export declare const connectClient: (params: {
|
|
|
23
23
|
displayName?: Amity.User['displayName'];
|
|
24
24
|
authToken?: string;
|
|
25
25
|
deviceId?: Amity.Device['deviceId'];
|
|
26
|
-
}
|
|
26
|
+
}, config?: {
|
|
27
|
+
disableRTE: boolean;
|
|
28
|
+
} | undefined) => Promise<boolean>;
|
|
27
29
|
//# sourceMappingURL=connectClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/connectClient.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"connectClient.d.ts","sourceRoot":"","sources":["../../../src/client/api/connectClient.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,WAChB;IACN,MAAM,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;CACrC;gBACsB,OAAO;kBAC7B,QAAQ,OAAO,CA8CjB,CAAC"}
|
|
@@ -16,6 +16,7 @@ export declare const queryComments: {
|
|
|
16
16
|
(query: {
|
|
17
17
|
referenceType: Amity.Comment['referenceType'];
|
|
18
18
|
referenceId: Amity.Comment['referenceId'];
|
|
19
|
+
sortBy?: 'lastCreated' | 'firstCreated' | 'lastUpdated' | 'firstUpdated';
|
|
19
20
|
parentId?: Amity.Comment['commentId'] | null;
|
|
20
21
|
hasFlag?: boolean;
|
|
21
22
|
isDeleted?: Amity.Comment['isDeleted'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryComments.d.ts","sourceRoot":"","sources":["../../../src/comment/api/queryComments.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;YAAiB;QACzC,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;QAC9C,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAC1C,QAAQ,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;QAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;KACnB,GAAG,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"queryComments.d.ts","sourceRoot":"","sources":["../../../src/comment/api/queryComments.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;YAAiB;QACzC,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;QAC9C,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;QAC1C,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,cAAc,CAAC;QACzE,QAAQ,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;QAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;KACnB,GAAG,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAkDrD;;;;;;;;;;;;OAYG;mBAEM,WAAW,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACzC,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,SAAS;CAjBtD,CAAC"}
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
* @returns the name of the corresponding store
|
|
6
6
|
*/
|
|
7
7
|
export declare const identifyModel: (model: Record<string, unknown>) => keyof Amity.Model | undefined;
|
|
8
|
+
export declare const identifyModelKey: (model: Record<string, unknown>) => string | undefined;
|
|
8
9
|
//# sourceMappingURL=identifyModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identifyModel.d.ts","sourceRoot":"","sources":["../../../src/core/model/identifyModel.ts"],"names":[],"mappings":"AA8CA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UAAW,OAAO,MAAM,EAAE,OAAO,CAAC,kCAM3D,CAAC"}
|
|
1
|
+
{"version":3,"file":"identifyModel.d.ts","sourceRoot":"","sources":["../../../src/core/model/identifyModel.ts"],"names":[],"mappings":"AA8CA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,UAAW,OAAO,MAAM,EAAE,OAAO,CAAC,kCAM3D,CAAC;AAUF,eAAO,MAAM,gBAAgB,UAAW,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,GAAG,SAQ1E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/core/query/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/core/query/query.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,oIAE2C,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,oIAEkD,CAAC;AAEzE;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,oIAE4D,CAAC;AAEnF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,UAAW,GAAG,4BACF,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,WAAY,GAAG,yBAElC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,oEAEnB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW;;;CAGH,CAAC;AAEtB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,WAAW,aACf,MAAM,KACf,MAAM,YAKR,CAAC;AA4BF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ,8IAE4B,IAAI,yBAC1C,MAAM,YAAY,SA2E5B,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -9,6 +9,7 @@ var debug = require('debug');
|
|
|
9
9
|
var axios = require('axios');
|
|
10
10
|
var HttpAgent = require('agentkeepalive');
|
|
11
11
|
var io = require('socket.io-client');
|
|
12
|
+
var nativeIdGenerator = require('react-native-uuid');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
15
|
|
|
@@ -18,6 +19,7 @@ var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
|
|
|
18
19
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
19
20
|
var HttpAgent__default = /*#__PURE__*/_interopDefaultLegacy(HttpAgent);
|
|
20
21
|
var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
|
|
22
|
+
var nativeIdGenerator__default = /*#__PURE__*/_interopDefaultLegacy(nativeIdGenerator);
|
|
21
23
|
|
|
22
24
|
var _a$1;
|
|
23
25
|
/* eslint-disable no-undef */
|
|
@@ -98,19 +100,19 @@ const toToken = (paging, style) => {
|
|
|
98
100
|
"before" or "after" value. if that would change,
|
|
99
101
|
we'd need to move toward a more simple: `!paging.before`
|
|
100
102
|
*/
|
|
101
|
-
if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.before)) {
|
|
103
|
+
if (!Number.isNaN(Number(paging === null || paging === void 0 ? void 0 : paging.before))) {
|
|
102
104
|
payload = {
|
|
103
105
|
before: paging.before,
|
|
104
106
|
last: paging.limit,
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
|
-
else if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.after)) {
|
|
109
|
+
else if (!Number.isNaN(Number(paging === null || paging === void 0 ? void 0 : paging.after))) {
|
|
108
110
|
payload = {
|
|
109
111
|
after: paging.after,
|
|
110
112
|
first: paging.limit,
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
|
-
else if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.limit)) {
|
|
115
|
+
else if (!Number.isNaN(Number(paging === null || paging === void 0 ? void 0 : paging.limit))) {
|
|
114
116
|
payload = {
|
|
115
117
|
last: paging.limit,
|
|
116
118
|
};
|
|
@@ -179,6 +181,121 @@ const toPageRaw = (token) => {
|
|
|
179
181
|
return undefined;
|
|
180
182
|
};
|
|
181
183
|
|
|
184
|
+
/** @hidden */
|
|
185
|
+
const idResolvers = {
|
|
186
|
+
user: ({ userId }) => userId,
|
|
187
|
+
file: ({ fileId }) => fileId,
|
|
188
|
+
role: ({ roleId }) => roleId,
|
|
189
|
+
channel: ({ channelId }) => channelId,
|
|
190
|
+
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
191
|
+
message: ({ messageId }) => messageId,
|
|
192
|
+
community: ({ communityId }) => communityId,
|
|
193
|
+
category: ({ categoryId }) => categoryId,
|
|
194
|
+
communityUsers: ({ communityId, userId }) => `${communityId}#${userId}`,
|
|
195
|
+
post: ({ postId }) => postId,
|
|
196
|
+
comment: ({ commentId }) => commentId,
|
|
197
|
+
poll: ({ pollId }) => pollId,
|
|
198
|
+
reaction: ({ reactionId }) => reactionId,
|
|
199
|
+
stream: ({ streamId }) => streamId,
|
|
200
|
+
follow: ({ from, to }) => `${from}#${to}`,
|
|
201
|
+
followCount: ({ userId }) => userId,
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Retrieve the id resolver matching a domain name
|
|
205
|
+
*
|
|
206
|
+
* @param name the domain name for the resolve
|
|
207
|
+
* @returns an idResolver function for the given domain name
|
|
208
|
+
*/
|
|
209
|
+
const getResolver = (name) => idResolvers[name];
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Identification criterias
|
|
213
|
+
*
|
|
214
|
+
* As key, the name of the identified model ;
|
|
215
|
+
* As value, the list of properties to consider a given model as of type
|
|
216
|
+
*
|
|
217
|
+
* Used as source of truth for {@link identifyModel}
|
|
218
|
+
*
|
|
219
|
+
* @hidden
|
|
220
|
+
*/
|
|
221
|
+
const CRITERIAS = {
|
|
222
|
+
file: ['fileId', 'attributes'],
|
|
223
|
+
user: ['userId', 'avatarFileId'],
|
|
224
|
+
role: ['roleId'],
|
|
225
|
+
channel: ['channelId', 'rateLimit'],
|
|
226
|
+
channelUsers: ['channelId', 'userId', 'membership'],
|
|
227
|
+
message: ['messageId'],
|
|
228
|
+
community: ['communityId', 'onlyAdminCanPost'],
|
|
229
|
+
category: ['categoryId'],
|
|
230
|
+
communityUsers: ['userId', 'communityId', 'communityMembership'],
|
|
231
|
+
post: ['postId', 'feedId'],
|
|
232
|
+
comment: ['commentId', 'referenceId'],
|
|
233
|
+
poll: ['pollId'],
|
|
234
|
+
reaction: ['reactionId'],
|
|
235
|
+
stream: ['streamId'],
|
|
236
|
+
follow: ['from', 'to'],
|
|
237
|
+
followCount: ['userId', 'followerCount'],
|
|
238
|
+
};
|
|
239
|
+
/** @hidden */
|
|
240
|
+
const hasKeys = (object, needles) => {
|
|
241
|
+
const haystack = Object.keys(object);
|
|
242
|
+
return needles.every(needle => haystack.includes(needle));
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Finds the name of the store for a given unknown model
|
|
246
|
+
*
|
|
247
|
+
* @param model one of the {@link Amity.Model} to identify
|
|
248
|
+
* @returns the name of the corresponding store
|
|
249
|
+
*/
|
|
250
|
+
const identifyModel = (model) => {
|
|
251
|
+
var _a;
|
|
252
|
+
// we cannot avoid "as" in here because Object.entries does not
|
|
253
|
+
// allow anything else than "string" as key in the iterator type
|
|
254
|
+
const criterias = Object.entries(CRITERIAS);
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
256
|
+
return (_a = criterias.find(([_, keys]) => hasKeys(model, keys))) === null || _a === void 0 ? void 0 : _a[0];
|
|
257
|
+
};
|
|
258
|
+
/*
|
|
259
|
+
* Identify the modal key for a model
|
|
260
|
+
* Used to get args for optimistic updates
|
|
261
|
+
* Example: createMessage: get messageId on optimistic message creation
|
|
262
|
+
*
|
|
263
|
+
* @param model to be recognized
|
|
264
|
+
* @returns model key array if one if found or undefined
|
|
265
|
+
*/
|
|
266
|
+
const identifyModelKey = (model) => {
|
|
267
|
+
var _a;
|
|
268
|
+
const modalKey = identifyModel(model);
|
|
269
|
+
if (!modalKey) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
return (_a = CRITERIAS[modalKey]) === null || _a === void 0 ? void 0 : _a[0];
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* A map of v3 response keys to a store name.
|
|
277
|
+
* @hidden
|
|
278
|
+
*/
|
|
279
|
+
const PAYLOAD2MODEL = {
|
|
280
|
+
users: 'user',
|
|
281
|
+
files: 'file',
|
|
282
|
+
roles: 'role',
|
|
283
|
+
channels: 'channel',
|
|
284
|
+
channelUsers: 'channelUsers',
|
|
285
|
+
messages: 'message',
|
|
286
|
+
communities: 'community',
|
|
287
|
+
categories: 'category',
|
|
288
|
+
communityUsers: 'communityUsers',
|
|
289
|
+
posts: 'post',
|
|
290
|
+
postChildren: 'post',
|
|
291
|
+
comments: 'comment',
|
|
292
|
+
polls: 'poll',
|
|
293
|
+
reactions: 'reaction',
|
|
294
|
+
videoStreamings: 'stream',
|
|
295
|
+
follows: 'follow',
|
|
296
|
+
followCounts: 'followCount',
|
|
297
|
+
};
|
|
298
|
+
|
|
182
299
|
/* eslint-disable no-use-before-define */
|
|
183
300
|
/**
|
|
184
301
|
* Type guard to check and cast that a given async function is has the ".locally" property
|
|
@@ -323,7 +440,23 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
323
440
|
loading: true,
|
|
324
441
|
}));
|
|
325
442
|
}
|
|
326
|
-
|
|
443
|
+
let optimisticArgs = args;
|
|
444
|
+
/* get args for optimistic method calls
|
|
445
|
+
*
|
|
446
|
+
* On optimistic updates, the modal key for the update needs to be passed to
|
|
447
|
+
* the server so as to avoid duplicate modal creation
|
|
448
|
+
*
|
|
449
|
+
* ex: on creating a new message pass the modalKey is messageId, pass this
|
|
450
|
+
* id onto the server so that a duplicate with seperate messageId is not
|
|
451
|
+
* created.
|
|
452
|
+
*/
|
|
453
|
+
if (isMutator(func)) {
|
|
454
|
+
// @ts-ignore
|
|
455
|
+
const modelKey = local && local.data && identifyModelKey(local.data);
|
|
456
|
+
// @ts-ignore
|
|
457
|
+
optimisticArgs = modelKey ? [Object.assign(Object.assign({}, args[0]), { [modelKey]: local.data[modelKey] })] : args;
|
|
458
|
+
}
|
|
459
|
+
func(...optimisticArgs)
|
|
327
460
|
.then(fresh => {
|
|
328
461
|
// @ts-ignore i know.
|
|
329
462
|
// isLocal(local) && syncInCache(local, fresh)
|
|
@@ -20216,57 +20349,6 @@ const onClientBanned = (callback) => {
|
|
|
20216
20349
|
});
|
|
20217
20350
|
};
|
|
20218
20351
|
|
|
20219
|
-
/** @hidden */
|
|
20220
|
-
const idResolvers = {
|
|
20221
|
-
user: ({ userId }) => userId,
|
|
20222
|
-
file: ({ fileId }) => fileId,
|
|
20223
|
-
role: ({ roleId }) => roleId,
|
|
20224
|
-
channel: ({ channelId }) => channelId,
|
|
20225
|
-
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
20226
|
-
message: ({ messageId }) => messageId,
|
|
20227
|
-
community: ({ communityId }) => communityId,
|
|
20228
|
-
category: ({ categoryId }) => categoryId,
|
|
20229
|
-
communityUsers: ({ communityId, userId }) => `${communityId}#${userId}`,
|
|
20230
|
-
post: ({ postId }) => postId,
|
|
20231
|
-
comment: ({ commentId }) => commentId,
|
|
20232
|
-
poll: ({ pollId }) => pollId,
|
|
20233
|
-
reaction: ({ reactionId }) => reactionId,
|
|
20234
|
-
stream: ({ streamId }) => streamId,
|
|
20235
|
-
follow: ({ from, to }) => `${from}#${to}`,
|
|
20236
|
-
followCount: ({ userId }) => userId,
|
|
20237
|
-
};
|
|
20238
|
-
/**
|
|
20239
|
-
* Retrieve the id resolver matching a domain name
|
|
20240
|
-
*
|
|
20241
|
-
* @param name the domain name for the resolve
|
|
20242
|
-
* @returns an idResolver function for the given domain name
|
|
20243
|
-
*/
|
|
20244
|
-
const getResolver = (name) => idResolvers[name];
|
|
20245
|
-
|
|
20246
|
-
/**
|
|
20247
|
-
* A map of v3 response keys to a store name.
|
|
20248
|
-
* @hidden
|
|
20249
|
-
*/
|
|
20250
|
-
const PAYLOAD2MODEL = {
|
|
20251
|
-
users: 'user',
|
|
20252
|
-
files: 'file',
|
|
20253
|
-
roles: 'role',
|
|
20254
|
-
channels: 'channel',
|
|
20255
|
-
channelUsers: 'channelUsers',
|
|
20256
|
-
messages: 'message',
|
|
20257
|
-
communities: 'community',
|
|
20258
|
-
categories: 'category',
|
|
20259
|
-
communityUsers: 'communityUsers',
|
|
20260
|
-
posts: 'post',
|
|
20261
|
-
postChildren: 'post',
|
|
20262
|
-
comments: 'comment',
|
|
20263
|
-
polls: 'poll',
|
|
20264
|
-
reactions: 'reaction',
|
|
20265
|
-
videoStreamings: 'stream',
|
|
20266
|
-
follows: 'follow',
|
|
20267
|
-
followCounts: 'followCount',
|
|
20268
|
-
};
|
|
20269
|
-
|
|
20270
20352
|
/**
|
|
20271
20353
|
* Ingest a payload (v3) into the cache
|
|
20272
20354
|
*
|
|
@@ -20340,7 +20422,7 @@ const onUserDeleted = (callback) => createUserEventSubscriber('user.deleted', ca
|
|
|
20340
20422
|
* @category Client API
|
|
20341
20423
|
* @async
|
|
20342
20424
|
*/
|
|
20343
|
-
const connectClient = async (params) => {
|
|
20425
|
+
const connectClient = async (params, config) => {
|
|
20344
20426
|
var _a;
|
|
20345
20427
|
const client = getActiveClient();
|
|
20346
20428
|
client.log('client/api/connectClient', Object.assign({ apiKey: client.apiKey }, params));
|
|
@@ -20365,7 +20447,9 @@ const connectClient = async (params) => {
|
|
|
20365
20447
|
client.userId = params.userId;
|
|
20366
20448
|
client.accessToken = accessToken;
|
|
20367
20449
|
setActiveUser(users[0]);
|
|
20368
|
-
|
|
20450
|
+
if ((config === null || config === void 0 ? void 0 : config.disableRTE) !== true) {
|
|
20451
|
+
subscribeTopic(getNetworkTopic());
|
|
20452
|
+
}
|
|
20369
20453
|
const subscriptions = [
|
|
20370
20454
|
onClientBanned(() => {
|
|
20371
20455
|
disconnectClient();
|
|
@@ -21311,6 +21395,8 @@ queryMessages.locally = (query) => {
|
|
|
21311
21395
|
: undefined;
|
|
21312
21396
|
};
|
|
21313
21397
|
|
|
21398
|
+
const uuid = () => nativeIdGenerator__default["default"].v4().toString();
|
|
21399
|
+
|
|
21314
21400
|
/**
|
|
21315
21401
|
* ```js
|
|
21316
21402
|
* import { createMessage } from '@amityco/ts-sdk'
|
|
@@ -21361,12 +21447,23 @@ const createMessage = async (bundle) => {
|
|
|
21361
21447
|
createMessage.optimistically = (bundle) => {
|
|
21362
21448
|
var _a, _b;
|
|
21363
21449
|
const client = getActiveClient();
|
|
21364
|
-
client.log('user/createMessage.locally', bundle);
|
|
21365
21450
|
if (!client.cache)
|
|
21366
21451
|
return;
|
|
21367
|
-
|
|
21368
|
-
|
|
21369
|
-
|
|
21452
|
+
/*
|
|
21453
|
+
* when creating messages optimistically a messageId needs to be added by the
|
|
21454
|
+
* client, created a new variable so as to allow backward compatibility of API
|
|
21455
|
+
*
|
|
21456
|
+
* Updated to handle client requirement to add messageId while uploading
|
|
21457
|
+
* message with image. Temporary!
|
|
21458
|
+
*/
|
|
21459
|
+
const bundleWithMessageId = Object.assign({ messageId: uuid() }, bundle);
|
|
21460
|
+
// only log if cache is enabled
|
|
21461
|
+
client.log('user/createMessage.locally', bundleWithMessageId);
|
|
21462
|
+
const channel = pullFromCache(['channel', 'get', bundleWithMessageId.channelId]);
|
|
21463
|
+
upsertInCache(['channel', 'get', bundleWithMessageId.channelId], Object.assign(Object.assign({}, channel === null || channel === void 0 ? void 0 : channel.data), { messageCount: ((_a = channel === null || channel === void 0 ? void 0 : channel.data.messageCount) !== null && _a !== void 0 ? _a : 0) + 1 }));
|
|
21464
|
+
// as reused to update created and updated time, which should be the same
|
|
21465
|
+
const createdTime = new Date().toISOString();
|
|
21466
|
+
const message = Object.assign({ userId: client.userId, channelSegment: ((_b = channel === null || channel === void 0 ? void 0 : channel.data.messageCount) !== null && _b !== void 0 ? _b : 0) + 1, createdAt: createdTime, updatedAt: createdTime }, bundleWithMessageId);
|
|
21370
21467
|
pushToCache(['message', 'get', message.messageId], message, { cachedAt: -1 });
|
|
21371
21468
|
fireEvent('v3.message.didCreate', { messages: [message] });
|
|
21372
21469
|
return {
|
|
@@ -22427,6 +22524,10 @@ const queryComments = async (query) => {
|
|
|
22427
22524
|
const client = getActiveClient();
|
|
22428
22525
|
client.log('comment/queryComments', query);
|
|
22429
22526
|
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
22527
|
+
const options = {
|
|
22528
|
+
type: params.sortBy ? 'pagination' : undefined,
|
|
22529
|
+
token: toToken(page, params.sortBy ? 'skiplimit' : 'afterbefore'),
|
|
22530
|
+
};
|
|
22430
22531
|
// const filterByParentId = query.parentId !== undefined
|
|
22431
22532
|
// API-FIX: parameters should be querystring. (1)
|
|
22432
22533
|
// API-FIX: backend should answer Amity.Response (2)
|
|
@@ -22434,9 +22535,7 @@ const queryComments = async (query) => {
|
|
|
22434
22535
|
const { data } = await client.http.get(`/api/v3/comments`, {
|
|
22435
22536
|
params: Object.assign(Object.assign({}, params), {
|
|
22436
22537
|
// filterByParentId, API-FIX: backend does not support this boolean LOL. what the hell seriously.
|
|
22437
|
-
options
|
|
22438
|
-
token: toToken(page, 'afterbefore'),
|
|
22439
|
-
} }),
|
|
22538
|
+
options }),
|
|
22440
22539
|
});
|
|
22441
22540
|
// API-FIX: backend should answer Amity.Response (2)
|
|
22442
22541
|
// const { paging, comments } = unwrapPayload(data)
|
|
@@ -22771,6 +22870,38 @@ const preparePayloadForCache = (event, payload) => {
|
|
|
22771
22870
|
}
|
|
22772
22871
|
};
|
|
22773
22872
|
|
|
22873
|
+
/** @hidden */
|
|
22874
|
+
/*
|
|
22875
|
+
* @param message payload from http request without myReactions
|
|
22876
|
+
* add myReactions to http response if the event was a reaction event
|
|
22877
|
+
*/
|
|
22878
|
+
const prepareMessagePayloadForCache = (payload) => {
|
|
22879
|
+
const client = getActiveClient();
|
|
22880
|
+
const cached = pullFromCache(['message', 'get', payload.messageId]);
|
|
22881
|
+
// '[]' in cases where the new reaction is the first one
|
|
22882
|
+
const myReactions = (cached === null || cached === void 0 ? void 0 : cached.data.myReactions) || [];
|
|
22883
|
+
// add myReactions to the payload
|
|
22884
|
+
Object.assign(payload, { myReactions });
|
|
22885
|
+
// check if there are any updates to the reactions
|
|
22886
|
+
const latestReaction = payload === null || payload === void 0 ? void 0 : payload.latestReaction;
|
|
22887
|
+
const isLatestReactionMine = latestReaction && latestReaction.userId === client.userId;
|
|
22888
|
+
if (!isLatestReactionMine) {
|
|
22889
|
+
return;
|
|
22890
|
+
}
|
|
22891
|
+
// new reaction added
|
|
22892
|
+
if (latestReaction.eventName === 'add' && !myReactions.includes(latestReaction.reactionName)) {
|
|
22893
|
+
Object.assign(payload, {
|
|
22894
|
+
myReactions: [...myReactions, latestReaction.reactionName],
|
|
22895
|
+
});
|
|
22896
|
+
}
|
|
22897
|
+
// existing reaction removed
|
|
22898
|
+
if (latestReaction.eventName === 'remove' && myReactions.includes(latestReaction.reactionName)) {
|
|
22899
|
+
Object.assign(payload, {
|
|
22900
|
+
myReactions: myReactions.filter(x => x !== latestReaction.reactionName),
|
|
22901
|
+
});
|
|
22902
|
+
}
|
|
22903
|
+
};
|
|
22904
|
+
|
|
22774
22905
|
/**
|
|
22775
22906
|
* ```js
|
|
22776
22907
|
* import { addReaction } from '@amityco/ts-sdk'
|
|
@@ -23819,9 +23950,9 @@ const leaveChannel = async (channelId) => {
|
|
|
23819
23950
|
const queryChannelMembers = async (query) => {
|
|
23820
23951
|
const client = getActiveClient();
|
|
23821
23952
|
client.log('channel/queryChannelMembers', query);
|
|
23822
|
-
const _a = query !== null && query !== void 0 ? query : {}, { page, channelId
|
|
23823
|
-
const { data } = await client.http.get(`/api/
|
|
23824
|
-
params: Object.assign(Object.assign({}, params), {
|
|
23953
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page, channelId } = _a, params = __rest(_a, ["page", "channelId"]);
|
|
23954
|
+
const { data } = await client.http.get(`/api/v4/channels/${encodeURIComponent(channelId)}/users`, {
|
|
23955
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
23825
23956
|
token: toToken(page, 'skiplimit'),
|
|
23826
23957
|
} }),
|
|
23827
23958
|
});
|
|
@@ -24192,7 +24323,12 @@ const onMessageUpdated = (callback) => {
|
|
|
24192
24323
|
const client = getActiveClient();
|
|
24193
24324
|
const filter = (payload) => {
|
|
24194
24325
|
ingestInCache(payload);
|
|
24195
|
-
|
|
24326
|
+
const message = payload.messages[0];
|
|
24327
|
+
// if payload does not have myReactions
|
|
24328
|
+
if (!(message === null || message === void 0 ? void 0 : message.myReactions)) {
|
|
24329
|
+
prepareMessagePayloadForCache(message);
|
|
24330
|
+
}
|
|
24331
|
+
callback(message);
|
|
24196
24332
|
};
|
|
24197
24333
|
return createEventSubscriber(client, 'message/onMessageUpdated', 'v3.message.didUpdate', filter);
|
|
24198
24334
|
};
|