@amityco/ts-sdk 6.10.0 → 6.10.1-50f2392.0
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/core/events.d.ts +2 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/query.d.ts +5 -1
- package/dist/@types/core/query.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/subChannel.d.ts +4 -1
- package/dist/@types/domains/subChannel.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts.map +1 -1
- package/dist/channelRepsitory/events/index.d.ts +2 -0
- package/dist/channelRepsitory/events/index.d.ts.map +1 -1
- package/dist/channelRepsitory/events/onChannelMemberRoleAdded.d.ts +17 -0
- package/dist/channelRepsitory/events/onChannelMemberRoleAdded.d.ts.map +1 -0
- package/dist/channelRepsitory/events/onChannelMemberRoleRemoved.d.ts +17 -0
- package/dist/channelRepsitory/events/onChannelMemberRoleRemoved.d.ts.map +1 -0
- package/dist/commentRepository/api/isCommentFlaggedByMe.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/query/paging.d.ts +8 -1
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/index.cjs.js +77 -18
- package/dist/index.esm.js +77 -18
- package/dist/index.umd.js +1 -1
- package/dist/subChannelRepository/api/querySubChannels.d.ts +2 -2
- package/dist/subChannelRepository/api/querySubChannels.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/getSubChannels.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +2 -0
- package/src/@types/core/query.ts +2 -2
- package/src/@types/domains/channel.ts +3 -1
- package/src/@types/domains/subChannel.ts +2 -1
- package/src/channelRepsitory/channelMembership/observers/getMembers.ts +4 -0
- package/src/channelRepsitory/channelModeration/api/addRole.ts +3 -0
- package/src/channelRepsitory/channelModeration/api/removeRole.ts +3 -0
- package/src/channelRepsitory/events/index.ts +3 -0
- package/src/channelRepsitory/events/onChannelMemberRoleAdded.ts +35 -0
- package/src/channelRepsitory/events/onChannelMemberRoleRemoved.ts +41 -0
- package/src/commentRepository/api/isCommentFlaggedByMe.ts +4 -9
- package/src/commentRepository/api/queryComments.ts +1 -1
- package/src/commentRepository/observers/getComments.ts +1 -1
- package/src/core/query/paging.ts +3 -1
- package/src/subChannelRepository/api/querySubChannels.ts +18 -6
- package/src/subChannelRepository/observers/getSubChannels.ts +5 -4
package/dist/index.esm.js
CHANGED
|
@@ -23446,6 +23446,56 @@ const onChannelMemberUnbanned = (callback) => {
|
|
|
23446
23446
|
return createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
|
|
23447
23447
|
};
|
|
23448
23448
|
|
|
23449
|
+
/**
|
|
23450
|
+
* ```js
|
|
23451
|
+
* import { onChannelMemberRoleAdded } from '@amityco/ts-sdk'
|
|
23452
|
+
* const dispose = onChannelMemberRoleAdded((channel, member) => {
|
|
23453
|
+
* // ...
|
|
23454
|
+
* })
|
|
23455
|
+
* ```
|
|
23456
|
+
*
|
|
23457
|
+
* Fired when any {@link Amity.channelUsers} 's role has been added to any {@link Amity.Channel}
|
|
23458
|
+
*
|
|
23459
|
+
* @param callback The function to call when the event was fired
|
|
23460
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23461
|
+
*
|
|
23462
|
+
* @category Channel Events
|
|
23463
|
+
*/
|
|
23464
|
+
const onChannelMemberRoleAdded = (callback) => {
|
|
23465
|
+
const client = getActiveClient();
|
|
23466
|
+
const filter = async (payload) => {
|
|
23467
|
+
const { channels, channelUsers } = payload;
|
|
23468
|
+
callback(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member'));
|
|
23469
|
+
};
|
|
23470
|
+
return createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', filter);
|
|
23471
|
+
};
|
|
23472
|
+
|
|
23473
|
+
/**
|
|
23474
|
+
* ```js
|
|
23475
|
+
* import { onChannelMemberRoleRemoved } from '@amityco/ts-sdk'
|
|
23476
|
+
* const dispose = onChannelMemberRoleRemoved((channel, member) => {
|
|
23477
|
+
* // ...
|
|
23478
|
+
* })
|
|
23479
|
+
* ```
|
|
23480
|
+
*
|
|
23481
|
+
* Fired when any {@link Amity.channelUsers} 's role has been deleted to any {@link Amity.Channel}
|
|
23482
|
+
*
|
|
23483
|
+
* @param callback The function to call when the event was fired
|
|
23484
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
23485
|
+
*
|
|
23486
|
+
* @category Channel Events
|
|
23487
|
+
*/
|
|
23488
|
+
const onChannelMemberRoleRemoved = (callback) => {
|
|
23489
|
+
const client = getActiveClient();
|
|
23490
|
+
const filter = async (payload) => {
|
|
23491
|
+
const preparedPayload = await prepareChannelPayload(payload);
|
|
23492
|
+
const { channels, channelUsers } = preparedPayload;
|
|
23493
|
+
ingestInCache(preparedPayload);
|
|
23494
|
+
callback(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member'));
|
|
23495
|
+
};
|
|
23496
|
+
return createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
|
|
23497
|
+
};
|
|
23498
|
+
|
|
23449
23499
|
const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
|
|
23450
23500
|
var _a;
|
|
23451
23501
|
if (!sourceModel) {
|
|
@@ -24071,7 +24121,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
24071
24121
|
responder(data);
|
|
24072
24122
|
}, queryOptions(policy));
|
|
24073
24123
|
};
|
|
24074
|
-
disposers.push(onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onChannelMemberBanned(realtimeRouter()), onChannelMemberUnbanned(realtimeRouter()));
|
|
24124
|
+
disposers.push(onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onChannelMemberBanned(realtimeRouter()), onChannelMemberUnbanned(realtimeRouter()), onChannelMemberRoleAdded(realtimeRouter()), onChannelMemberRoleRemoved(realtimeRouter()));
|
|
24075
24125
|
onFetch(true);
|
|
24076
24126
|
return () => {
|
|
24077
24127
|
log(`getMembers(tmpid: ${timestamp}) > dispose`);
|
|
@@ -24142,6 +24192,7 @@ const addRole = async (channelId, roleId, userIds) => {
|
|
|
24142
24192
|
const data = await prepareChannelPayload(payload);
|
|
24143
24193
|
if (client.cache)
|
|
24144
24194
|
ingestInCache(data);
|
|
24195
|
+
fireEvent('local.channel-moderator.role-added', data);
|
|
24145
24196
|
const { channelUsers } = data;
|
|
24146
24197
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.roles.includes(roleId));
|
|
24147
24198
|
};
|
|
@@ -24173,6 +24224,7 @@ const removeRole = async (channelId, roleId, userIds) => {
|
|
|
24173
24224
|
const data = await prepareChannelPayload(payload);
|
|
24174
24225
|
if (client.cache)
|
|
24175
24226
|
ingestInCache(data);
|
|
24227
|
+
fireEvent('local.channel-moderator.role-removed', data);
|
|
24176
24228
|
const { channelUsers } = data;
|
|
24177
24229
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && !channelUser.roles.includes(roleId));
|
|
24178
24230
|
};
|
|
@@ -24279,6 +24331,8 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
24279
24331
|
onChannelMemberRemoved: onChannelMemberRemoved,
|
|
24280
24332
|
onChannelMemberBanned: onChannelMemberBanned,
|
|
24281
24333
|
onChannelMemberUnbanned: onChannelMemberUnbanned,
|
|
24334
|
+
onChannelMemberRoleAdded: onChannelMemberRoleAdded,
|
|
24335
|
+
onChannelMemberRoleRemoved: onChannelMemberRoleRemoved,
|
|
24282
24336
|
observeChannel: observeChannel,
|
|
24283
24337
|
observeChannels: observeChannels,
|
|
24284
24338
|
getChannel: getChannel,
|
|
@@ -29827,10 +29881,10 @@ function merge(collection1, collection2) {
|
|
|
29827
29881
|
const querySubChannels = async (query) => {
|
|
29828
29882
|
const client = getActiveClient();
|
|
29829
29883
|
client.log('channel/querySubChannels', query);
|
|
29830
|
-
const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted"]);
|
|
29884
|
+
const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted, pageToken } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted", "pageToken"]);
|
|
29831
29885
|
const response = await client.http.get(`/api/v5/message-feeds/channel/${channelId}`, {
|
|
29832
29886
|
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
29833
|
-
token: toToken(page, 'afterbefore'),
|
|
29887
|
+
token: pageToken || toToken(page, 'afterbefore'),
|
|
29834
29888
|
} }),
|
|
29835
29889
|
});
|
|
29836
29890
|
const _b = response.data, { paging } = _b, payload = __rest(_b, ["paging"]);
|
|
@@ -29849,7 +29903,13 @@ const querySubChannels = async (query) => {
|
|
|
29849
29903
|
fireEvent('local.message-feed.fetched', data);
|
|
29850
29904
|
const nextPage = toPage(paging.next);
|
|
29851
29905
|
const prevPage = toPage(paging.previous);
|
|
29852
|
-
return {
|
|
29906
|
+
return {
|
|
29907
|
+
data: subChannels,
|
|
29908
|
+
cachedAt,
|
|
29909
|
+
prevPage,
|
|
29910
|
+
nextPage,
|
|
29911
|
+
paging,
|
|
29912
|
+
};
|
|
29853
29913
|
};
|
|
29854
29914
|
/* end_public_function */
|
|
29855
29915
|
/**
|
|
@@ -29886,7 +29946,7 @@ querySubChannels.locally = (query) => {
|
|
|
29886
29946
|
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
29887
29947
|
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
29888
29948
|
return subChannels.length === ((_c = data === null || data === void 0 ? void 0 : data.subChannels) === null || _c === void 0 ? void 0 : _c.length)
|
|
29889
|
-
? { data: subChannels, cachedAt, prevPage, nextPage }
|
|
29949
|
+
? { data: subChannels, cachedAt, prevPage, nextPage, paging: data === null || data === void 0 ? void 0 : data.paging }
|
|
29890
29950
|
: undefined;
|
|
29891
29951
|
};
|
|
29892
29952
|
|
|
@@ -29924,7 +29984,7 @@ const getSubChannels = (params, callback, config) => {
|
|
|
29924
29984
|
let snapshot;
|
|
29925
29985
|
const disposers = [];
|
|
29926
29986
|
const responder = (data) => {
|
|
29927
|
-
var _a;
|
|
29987
|
+
var _a, _b;
|
|
29928
29988
|
let subChannels = data.data;
|
|
29929
29989
|
if (!params.includeDeleted) {
|
|
29930
29990
|
subChannels = filterByPropEquality(subChannels, 'isDeleted', false);
|
|
@@ -29933,7 +29993,7 @@ const getSubChannels = (params, callback, config) => {
|
|
|
29933
29993
|
callback({
|
|
29934
29994
|
onNextPage: onFetch,
|
|
29935
29995
|
data: subChannels,
|
|
29936
|
-
hasNextPage: !!((_a = data.params) === null || _a === void 0 ? void 0 : _a.
|
|
29996
|
+
hasNextPage: !!((_b = (_a = data.params) === null || _a === void 0 ? void 0 : _a.paging) === null || _b === void 0 ? void 0 : _b.next),
|
|
29937
29997
|
loading: data.loading,
|
|
29938
29998
|
error: data.error,
|
|
29939
29999
|
});
|
|
@@ -29954,16 +30014,17 @@ const getSubChannels = (params, callback, config) => {
|
|
|
29954
30014
|
responder(snapshot);
|
|
29955
30015
|
};
|
|
29956
30016
|
const onFetch = () => {
|
|
30017
|
+
var _a, _b, _c, _d;
|
|
29957
30018
|
const subChannels = snapshot ? snapshot.data : [];
|
|
29958
|
-
if (subChannels.length > 0 && !(snapshot === null || snapshot === void 0 ? void 0 : snapshot.params.
|
|
30019
|
+
if (subChannels.length > 0 && !((_b = (_a = snapshot === null || snapshot === void 0 ? void 0 : snapshot.params) === null || _a === void 0 ? void 0 : _a.paging) === null || _b === void 0 ? void 0 : _b.next)) {
|
|
29959
30020
|
return;
|
|
29960
30021
|
}
|
|
29961
|
-
const query = createQuery(querySubChannels, Object.assign(Object.assign({}, queryParams), { page: (snapshot === null || snapshot === void 0 ? void 0 : snapshot.params.page) ? Object.assign(Object.assign({}, snapshot === null || snapshot === void 0 ? void 0 : snapshot.params.page), { limit }) : { limit } }));
|
|
29962
|
-
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30022
|
+
const query = createQuery(querySubChannels, Object.assign(Object.assign({}, queryParams), { page: (snapshot === null || snapshot === void 0 ? void 0 : snapshot.params.page) ? Object.assign(Object.assign({}, snapshot === null || snapshot === void 0 ? void 0 : snapshot.params.page), { limit }) : { limit }, pageToken: (_d = (_c = snapshot === null || snapshot === void 0 ? void 0 : snapshot.params) === null || _c === void 0 ? void 0 : _c.paging) === null || _d === void 0 ? void 0 : _d.next }));
|
|
30023
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page, paging }) => {
|
|
29963
30024
|
snapshot = {
|
|
29964
30025
|
loading,
|
|
29965
30026
|
error,
|
|
29966
|
-
params: { page },
|
|
30027
|
+
params: { page, paging },
|
|
29967
30028
|
data: result ? merge(subChannels, result.map(convertGetterPropsToStatic)) : subChannels,
|
|
29968
30029
|
};
|
|
29969
30030
|
responder(snapshot);
|
|
@@ -33197,13 +33258,10 @@ const unflagComment = async (commentId) => {
|
|
|
33197
33258
|
* @async
|
|
33198
33259
|
* */
|
|
33199
33260
|
const isCommentFlaggedByMe = async (commentId) => {
|
|
33200
|
-
var _a, _b;
|
|
33201
33261
|
const client = getActiveClient();
|
|
33202
33262
|
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
33203
|
-
const { result,
|
|
33204
|
-
|
|
33205
|
-
}))) !== null && _a !== void 0 ? _a : {};
|
|
33206
|
-
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
33263
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
33264
|
+
return result;
|
|
33207
33265
|
};
|
|
33208
33266
|
/* end_public_function */
|
|
33209
33267
|
|
|
@@ -33337,11 +33395,12 @@ const getComment = (commentId, callback) => {
|
|
|
33337
33395
|
* @async
|
|
33338
33396
|
*/
|
|
33339
33397
|
const queryComments = async (query) => {
|
|
33398
|
+
var _a;
|
|
33340
33399
|
const client = getActiveClient();
|
|
33341
33400
|
client.log('comment/queryComments', query);
|
|
33342
33401
|
const { page = { limit: 10 }, includeDeleted } = query, params = __rest(query, ["page", "includeDeleted"]);
|
|
33343
33402
|
const options = {
|
|
33344
|
-
type: params.sortBy ? 'pagination' : undefined,
|
|
33403
|
+
type: params.sortBy || ((_a = query.page) === null || _a === void 0 ? void 0 : _a.limit) ? 'pagination' : undefined,
|
|
33345
33404
|
token: toToken(page, params.sortBy ? 'skiplimit' : 'afterbefore'),
|
|
33346
33405
|
};
|
|
33347
33406
|
// const filterByParentId = query.parentId !== undefined
|
|
@@ -33461,7 +33520,7 @@ const getComments = (params, callback, config) => {
|
|
|
33461
33520
|
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
33462
33521
|
runQuery(query, ({ data: result, error, loading, prevPage, nextPage }) => {
|
|
33463
33522
|
// depend on sortBy value we have two different pagination type
|
|
33464
|
-
const page = queryParams.sortBy ? nextPage : prevPage;
|
|
33523
|
+
const page = queryParams.sortBy || (params === null || params === void 0 ? void 0 : params.limit) ? nextPage : prevPage;
|
|
33465
33524
|
const data = {
|
|
33466
33525
|
loading,
|
|
33467
33526
|
error,
|