@amityco/ts-sdk 0.0.1-beta.29 → 0.0.1-beta.30

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.
Files changed (35) hide show
  1. package/dist/@types/domains/channel.d.ts +11 -0
  2. package/dist/@types/domains/channel.d.ts.map +1 -1
  3. package/dist/channel/api/queryChannelMembers.d.ts +1 -8
  4. package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
  5. package/dist/channel/observers/index.d.ts +1 -0
  6. package/dist/channel/observers/index.d.ts.map +1 -1
  7. package/dist/channel/observers/liveChannelMembers.d.ts +20 -0
  8. package/dist/channel/observers/liveChannelMembers.d.ts.map +1 -0
  9. package/dist/channel/observers/tests/liveChannelMembers.test.d.ts +2 -0
  10. package/dist/channel/observers/tests/liveChannelMembers.test.d.ts.map +1 -0
  11. package/dist/client/api/getToken.d.ts +1 -3
  12. package/dist/client/api/getToken.d.ts.map +1 -1
  13. package/dist/core/query/filtering.d.ts +1 -0
  14. package/dist/core/query/filtering.d.ts.map +1 -1
  15. package/dist/core/query/query.d.ts.map +1 -1
  16. package/dist/index.cjs.js +105 -2
  17. package/dist/index.esm.js +104 -3
  18. package/dist/index.umd.js +4 -4
  19. package/dist/utils/tests/dummy/channel.d.ts +29 -3
  20. package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
  21. package/dist/utils/tests/utils.d.ts +1 -0
  22. package/dist/utils/tests/utils.d.ts.map +1 -1
  23. package/package.json +2 -2
  24. package/src/@types/domains/channel.ts +19 -0
  25. package/src/channel/api/queryChannelMembers.ts +3 -8
  26. package/src/channel/observers/index.ts +1 -0
  27. package/src/channel/observers/liveChannelMembers.ts +159 -0
  28. package/src/channel/observers/tests/liveChannelMembers.test.ts +165 -0
  29. package/src/channel/observers/tests/liveChannels.test.ts +17 -9
  30. package/src/client/api/isConnected.ts +1 -1
  31. package/src/core/query/filtering.ts +6 -0
  32. package/src/core/query/query.ts +2 -3
  33. package/src/core/tests/query/query.test.ts +93 -11
  34. package/src/utils/tests/dummy/channel.ts +57 -17
  35. package/src/utils/tests/utils.ts +10 -0
@@ -19,6 +19,7 @@ declare global {
19
19
  autoDeleteMessageByFlagLimit?: number;
20
20
  memberCount?: number;
21
21
  messageCount?: number;
22
+ moderatorMemberCount?: number;
22
23
  lastActivity?: Amity.timestamp;
23
24
  unreadCount: number;
24
25
  hasMention: boolean;
@@ -36,6 +37,16 @@ declare global {
36
37
  };
37
38
  type ChannelLiveCollection = Amity.LiveCollectionParams<Omit<QueryChannels, 'page'>>;
38
39
  type ChannelLiveCollectionCache = Amity.LiveCollectionCache<Amity.Channel['channelId'], Pick<QueryChannels, 'page'>>;
40
+ type QueryChannelMembers = {
41
+ channelId: Amity.Channel['channelId'];
42
+ memberships?: Array<Exclude<Amity.Membership<'channel'>['membership'], 'none'> | 'muted'>;
43
+ roles?: string[];
44
+ sortBy?: 'firstCreated' | 'lastCreated';
45
+ search?: string;
46
+ page?: Amity.Page;
47
+ };
48
+ type ChannelMembersLiveCollection = Amity.LiveCollectionParams<Omit<QueryChannelMembers, 'page'>>;
49
+ type ChannelMembersLiveCollectionCache = Amity.LiveCollectionCache<Amity.Membership<'channel'>['userId'], Pick<QueryChannelMembers, 'page'>>;
39
50
  }
40
51
  }
41
52
  //# sourceMappingURL=channel.d.ts.map
@@ -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,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;QAEvE,KAAK,iBAAiB,GAClB,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,eAAe,GACf,iBAAiB,CAAC;QAEtB,KAAK,OAAO,CAAC,CAAC,SAAS,WAAW,GAAG,GAAG,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AAC;QAErF,KAAK,0BAA0B,GAAG,KAAK,CAAC,mBAAmB,CACzD,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAC1B,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAC5B,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACtC,WAAW,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;YAC1F,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;YACjB,MAAM,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC;YACxC,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC;SACnB,CAAC;QAEF,KAAK,4BAA4B,GAAG,KAAK,CAAC,oBAAoB,CAC5D,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAClC,CAAC;QAEF,KAAK,iCAAiC,GAAG,KAAK,CAAC,mBAAmB,CAChE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACrC,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAClC,CAAC;KACH;CACF"}
@@ -13,14 +13,7 @@
13
13
  * @async
14
14
  * */
15
15
  export declare const queryChannelMembers: {
16
- (query: {
17
- channelId: string;
18
- memberships?: ('muted' | 'banned' | 'member')[];
19
- roles?: string[];
20
- sortBy?: 'firstCreated' | 'lastCreated';
21
- search?: string;
22
- page?: Amity.Page;
23
- }): Promise<Amity.Cached<Amity.Paged<Amity.Membership<'channel'>>>>;
16
+ (query: Amity.QueryChannelMembers): Promise<Amity.Cached<Amity.Paged<Amity.Membership<'channel'>>>>;
24
17
  /**
25
18
  * ```js
26
19
  * import { queryChannelMembers } from '@amityco/ts-sdk'
@@ -1 +1 @@
1
- {"version":3,"file":"queryChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/api/queryChannelMembers.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;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;IAkCnE;;;;;;;;;;;;OAYG;mBACmC,WAAW,0BAA0B,CAAC,CAAC,CAAC,CAAC;CAf9E,CAAC"}
1
+ {"version":3,"file":"queryChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/api/queryChannelMembers.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;KAaK;AACL,eAAO,MAAM,mBAAmB;YACvB,MAAM,mBAAmB,GAC/B,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAkClE;;;;;;;;;;;;OAYG;mBACmC,WAAW,0BAA0B,CAAC,CAAC,CAAC,CAAC;CAf9E,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './observeChannel';
2
2
  export * from './observeChannels';
3
3
  export * from './liveChannels';
4
+ export * from './liveChannelMembers';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channel/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channel/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ```js
3
+ * import { liveChannelMembers } from '@amityco/ts-sdk'
4
+ *
5
+ * let channelMembers = []
6
+ * const unsub = liveChannelMembers({
7
+ * channelId: Amity.Channel['channelId'],
8
+ * }, response => merge(channelMembers, response.data))
9
+ * ```
10
+ *
11
+ * Observe all mutations on a list of {@link Amity.ChannelUser}s
12
+ *
13
+ * @param params for querying channel users
14
+ * @param callback the function to call when new data are available
15
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channel users
16
+ *
17
+ * @category Channel Live Collection
18
+ */
19
+ export declare const liveChannelMembers: (params: Amity.ChannelMembersLiveCollection, callback: Amity.LiveCollectionCallback<Amity.Membership<'channel'>>, config?: Amity.LiveCollectionConfig) => () => void;
20
+ //# sourceMappingURL=liveChannelMembers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/observers/liveChannelMembers.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB,WACrB,MAAM,4BAA4B,YAChC,MAAM,sBAAsB,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,WAC1D,MAAM,oBAAoB,eAoHpC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=liveChannelMembers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveChannelMembers.test.d.ts","sourceRoot":"","sources":["../../../../src/channel/observers/tests/liveChannelMembers.test.ts"],"names":[],"mappings":""}
@@ -15,7 +15,5 @@ export declare const getToken: (params: {
15
15
  displayName: Amity.User['displayName'];
16
16
  authToken?: string;
17
17
  deviceId: Amity.Device['deviceId'];
18
- }) => Promise<Amity.Tokens & {
19
- users: Amity.User[];
20
- }>;
18
+ }) => Promise<T>;
21
19
  //# sourceMappingURL=getToken.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getToken.d.ts","sourceRoot":"","sources":["../../../src/client/api/getToken.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,WAAkB;IACrC,MAAM,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,WAAW,EAAE,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;CACpC;WAMiE,MAAM,IAAI,EAAE;EAa7E,CAAC"}
1
+ {"version":3,"file":"getToken.d.ts","sourceRoot":"","sources":["../../../src/client/api/getToken.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,WAAkB;IACrC,MAAM,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,WAAW,EAAE,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;CACpC,eAmBA,CAAC"}
@@ -9,4 +9,5 @@
9
9
  * @hidden
10
10
  */
11
11
  export declare const filterByPropEquality: <T = Record<string, unknown>>(collection: T[], key: keyof T, value: any) => T[];
12
+ export declare const filterByPropInclusion: <T = Record<string, unknown>>(collection: T[], key: keyof T, value: any[] | undefined) => T[];
12
13
  //# sourceMappingURL=filtering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAC4E,CAAC"}
1
+ {"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAC4E,CAAC;AAEzF,eAAO,MAAM,qBAAqB,sEAGzB,GAAG,EAAE,GAAG,SAAS,QACoE,CAAC"}
@@ -1 +1 @@
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,WAAY,MAAM,QAAQ,+BAE7C,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,SAwF5B,CAAC"}
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,WAAY,MAAM,QAAQ,+BAE7C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW;;;CAGH,CAAC;AAEtB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,WAAW,aACf,MAAM,KACf,MAAM,YAKR,CAAC;AA2BF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ,8IAE4B,IAAI,yBAC1C,MAAM,YAAY,SAwF5B,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -560,7 +560,8 @@ function createSnapshot(data, options) {
560
560
  *
561
561
  * @hidden
562
562
  */
563
- const filterByPropEquality = (collection, key, value) => (value !== undefined ? collection.filter(item => item[key] === value) : collection);
563
+ const filterByPropEquality = (collection, key, value) => (value !== undefined ? collection.filter(item => item[key] === value) : collection);
564
+ const filterByPropInclusion = (collection, key, value) => (value !== undefined ? collection.filter(item => value.includes(item[key])) : collection);
564
565
 
565
566
  // Note:
566
567
  // this file should contain a suite of sorting utilities to help the
@@ -20573,7 +20574,7 @@ const isConnected = () => {
20573
20574
  const client = getActiveClient();
20574
20575
  client.log('client/api/isConnected', client);
20575
20576
  return !!(client.userId &&
20576
- ((_b = (_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization) === null || _b === void 0 ? void 0 : _b.length) &&
20577
+ ((_b = String((_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization)) === null || _b === void 0 ? void 0 : _b.length) &&
20577
20578
  client.ws.connected);
20578
20579
  };
20579
20580
 
@@ -25019,6 +25020,106 @@ const liveChannels = (params, callback, config) => {
25019
25020
  };
25020
25021
  };
25021
25022
 
25023
+ /**
25024
+ * ```js
25025
+ * import { liveChannelMembers } from '@amityco/ts-sdk'
25026
+ *
25027
+ * let channelMembers = []
25028
+ * const unsub = liveChannelMembers({
25029
+ * channelId: Amity.Channel['channelId'],
25030
+ * }, response => merge(channelMembers, response.data))
25031
+ * ```
25032
+ *
25033
+ * Observe all mutations on a list of {@link Amity.ChannelUser}s
25034
+ *
25035
+ * @param params for querying channel users
25036
+ * @param callback the function to call when new data are available
25037
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channel users
25038
+ *
25039
+ * @category Channel Live Collection
25040
+ */
25041
+ const liveChannelMembers = (params, callback, config) => {
25042
+ const { log, cache } = getActiveClient();
25043
+ if (!cache) {
25044
+ console.log(ENABLE_CACHE_MESSAGE);
25045
+ }
25046
+ const timestamp = Date.now();
25047
+ log(`liveChannelMembers(tmpid: ${timestamp}) > listen`);
25048
+ const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
25049
+ const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
25050
+ const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
25051
+ const disposers = [];
25052
+ const cacheKey = ['channelUsers', 'collection', { channelId: params.channelId }];
25053
+ const responder = (data) => {
25054
+ var _a, _b;
25055
+ let channelMembers = (_a = data.data
25056
+ .map(id => pullFromCache(['channelUsers', 'get', id]))
25057
+ .filter(Boolean)
25058
+ .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
25059
+ channelMembers = filterByPropEquality(channelMembers, 'roles', params.roles);
25060
+ channelMembers = filterByPropInclusion(channelMembers, 'membership', params.memberships);
25061
+ if (params.search) {
25062
+ const containsMatcher = new RegExp(params.search);
25063
+ channelMembers = channelMembers.filter(m => m.userId.match(containsMatcher));
25064
+ }
25065
+ // sort, 'lastCreated' is the default sort order
25066
+ const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
25067
+ channelMembers = channelMembers.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
25068
+ callback({
25069
+ onNextPage: onFetch,
25070
+ data: channelMembers,
25071
+ hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
25072
+ loading: data.loading,
25073
+ error: data.error,
25074
+ });
25075
+ };
25076
+ const realtimeRouter = (channelMember, action) => {
25077
+ var _a;
25078
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25079
+ if (!collection)
25080
+ return;
25081
+ const channelMemberCacheId = getResolver('channelUsers')({
25082
+ channelId: params.channelId,
25083
+ userId: channelMember.userId,
25084
+ });
25085
+ if (action === 'onMemberAdded') {
25086
+ collection.data = [...new Set([channelMemberCacheId, ...collection.data])];
25087
+ }
25088
+ else {
25089
+ collection.data = collection.data.filter(m => m !== channelMemberCacheId);
25090
+ }
25091
+ pushToCache(cacheKey, collection);
25092
+ responder(collection);
25093
+ };
25094
+ const onFetch = () => {
25095
+ var _a, _b, _c;
25096
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25097
+ const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
25098
+ if (channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
25099
+ return;
25100
+ const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
25101
+ runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
25102
+ const data = {
25103
+ loading,
25104
+ error,
25105
+ params: { page },
25106
+ data: channelMembers,
25107
+ };
25108
+ if (result) {
25109
+ data.data = [...new Set([...channelMembers, ...result.map(getResolver('channelUsers'))])];
25110
+ }
25111
+ pushToCache(cacheKey, data);
25112
+ responder(data);
25113
+ }, queryOptions(policy));
25114
+ };
25115
+ disposers.push(onChannelMemberAdded((_, member) => realtimeRouter(member, 'onMemberAdded')), onChannelMemberRemoved((_, member) => realtimeRouter(member, 'onMemberRemoved')));
25116
+ onFetch();
25117
+ return () => {
25118
+ log(`liveChannelMembers(tmpid: ${timestamp}) > dispose`);
25119
+ disposers.forEach(fn => fn());
25120
+ };
25121
+ };
25122
+
25022
25123
  /**
25023
25124
  * ```js
25024
25125
  * import { onMessageCreated } from '@amityco/ts-sdk'
@@ -27505,6 +27606,7 @@ exports.dropFromCache = dropFromCache;
27505
27606
  exports.enableCache = enableCache;
27506
27607
  exports.fileUrlWithSize = fileUrlWithSize;
27507
27608
  exports.filterByPropEquality = filterByPropEquality;
27609
+ exports.filterByPropInclusion = filterByPropInclusion;
27508
27610
  exports.follow = follow;
27509
27611
  exports.getActiveClient = getActiveClient;
27510
27612
  exports.getCategory = getCategory;
@@ -27551,6 +27653,7 @@ exports.joinChannel = joinChannel;
27551
27653
  exports.joinCommunity = joinCommunity;
27552
27654
  exports.leaveChannel = leaveChannel;
27553
27655
  exports.leaveCommunity = leaveCommunity;
27656
+ exports.liveChannelMembers = liveChannelMembers;
27554
27657
  exports.liveChannels = liveChannels;
27555
27658
  exports.liveComments = liveComments;
27556
27659
  exports.liveFollowers = liveFollowers;
package/dist/index.esm.js CHANGED
@@ -546,7 +546,8 @@ function createSnapshot(data, options) {
546
546
  *
547
547
  * @hidden
548
548
  */
549
- const filterByPropEquality = (collection, key, value) => (value !== undefined ? collection.filter(item => item[key] === value) : collection);
549
+ const filterByPropEquality = (collection, key, value) => (value !== undefined ? collection.filter(item => item[key] === value) : collection);
550
+ const filterByPropInclusion = (collection, key, value) => (value !== undefined ? collection.filter(item => value.includes(item[key])) : collection);
550
551
 
551
552
  // Note:
552
553
  // this file should contain a suite of sorting utilities to help the
@@ -20559,7 +20560,7 @@ const isConnected = () => {
20559
20560
  const client = getActiveClient();
20560
20561
  client.log('client/api/isConnected', client);
20561
20562
  return !!(client.userId &&
20562
- ((_b = (_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization) === null || _b === void 0 ? void 0 : _b.length) &&
20563
+ ((_b = String((_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization)) === null || _b === void 0 ? void 0 : _b.length) &&
20563
20564
  client.ws.connected);
20564
20565
  };
20565
20566
 
@@ -25005,6 +25006,106 @@ const liveChannels = (params, callback, config) => {
25005
25006
  };
25006
25007
  };
25007
25008
 
25009
+ /**
25010
+ * ```js
25011
+ * import { liveChannelMembers } from '@amityco/ts-sdk'
25012
+ *
25013
+ * let channelMembers = []
25014
+ * const unsub = liveChannelMembers({
25015
+ * channelId: Amity.Channel['channelId'],
25016
+ * }, response => merge(channelMembers, response.data))
25017
+ * ```
25018
+ *
25019
+ * Observe all mutations on a list of {@link Amity.ChannelUser}s
25020
+ *
25021
+ * @param params for querying channel users
25022
+ * @param callback the function to call when new data are available
25023
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channel users
25024
+ *
25025
+ * @category Channel Live Collection
25026
+ */
25027
+ const liveChannelMembers = (params, callback, config) => {
25028
+ const { log, cache } = getActiveClient();
25029
+ if (!cache) {
25030
+ console.log(ENABLE_CACHE_MESSAGE);
25031
+ }
25032
+ const timestamp = Date.now();
25033
+ log(`liveChannelMembers(tmpid: ${timestamp}) > listen`);
25034
+ const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
25035
+ const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
25036
+ const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
25037
+ const disposers = [];
25038
+ const cacheKey = ['channelUsers', 'collection', { channelId: params.channelId }];
25039
+ const responder = (data) => {
25040
+ var _a, _b;
25041
+ let channelMembers = (_a = data.data
25042
+ .map(id => pullFromCache(['channelUsers', 'get', id]))
25043
+ .filter(Boolean)
25044
+ .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
25045
+ channelMembers = filterByPropEquality(channelMembers, 'roles', params.roles);
25046
+ channelMembers = filterByPropInclusion(channelMembers, 'membership', params.memberships);
25047
+ if (params.search) {
25048
+ const containsMatcher = new RegExp(params.search);
25049
+ channelMembers = channelMembers.filter(m => m.userId.match(containsMatcher));
25050
+ }
25051
+ // sort, 'lastCreated' is the default sort order
25052
+ const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
25053
+ channelMembers = channelMembers.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
25054
+ callback({
25055
+ onNextPage: onFetch,
25056
+ data: channelMembers,
25057
+ hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
25058
+ loading: data.loading,
25059
+ error: data.error,
25060
+ });
25061
+ };
25062
+ const realtimeRouter = (channelMember, action) => {
25063
+ var _a;
25064
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25065
+ if (!collection)
25066
+ return;
25067
+ const channelMemberCacheId = getResolver('channelUsers')({
25068
+ channelId: params.channelId,
25069
+ userId: channelMember.userId,
25070
+ });
25071
+ if (action === 'onMemberAdded') {
25072
+ collection.data = [...new Set([channelMemberCacheId, ...collection.data])];
25073
+ }
25074
+ else {
25075
+ collection.data = collection.data.filter(m => m !== channelMemberCacheId);
25076
+ }
25077
+ pushToCache(cacheKey, collection);
25078
+ responder(collection);
25079
+ };
25080
+ const onFetch = () => {
25081
+ var _a, _b, _c;
25082
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25083
+ const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
25084
+ if (channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
25085
+ return;
25086
+ const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
25087
+ runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
25088
+ const data = {
25089
+ loading,
25090
+ error,
25091
+ params: { page },
25092
+ data: channelMembers,
25093
+ };
25094
+ if (result) {
25095
+ data.data = [...new Set([...channelMembers, ...result.map(getResolver('channelUsers'))])];
25096
+ }
25097
+ pushToCache(cacheKey, data);
25098
+ responder(data);
25099
+ }, queryOptions(policy));
25100
+ };
25101
+ disposers.push(onChannelMemberAdded((_, member) => realtimeRouter(member, 'onMemberAdded')), onChannelMemberRemoved((_, member) => realtimeRouter(member, 'onMemberRemoved')));
25102
+ onFetch();
25103
+ return () => {
25104
+ log(`liveChannelMembers(tmpid: ${timestamp}) > dispose`);
25105
+ disposers.forEach(fn => fn());
25106
+ };
25107
+ };
25108
+
25008
25109
  /**
25009
25110
  * ```js
25010
25111
  * import { onMessageCreated } from '@amityco/ts-sdk'
@@ -27438,4 +27539,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
27438
27539
  return { accessToken: data.accessToken };
27439
27540
  };
27440
27541
 
27441
- export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, SubscriptionLevels, VERSION$1 as VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getCategory, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getStream, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveChannels, liveComments, liveFollowers, liveFollowings, liveMessages, livePosts, liveReactions, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMemberAdded, onChannelMemberRemoved, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, votePoll, wipeCache };
27542
+ export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, SubscriptionLevels, VERSION$1 as VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, filterByPropInclusion, follow, getActiveClient, getCategory, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getStream, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveChannelMembers, liveChannels, liveComments, liveFollowers, liveFollowings, liveMessages, livePosts, liveReactions, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMemberAdded, onChannelMemberRemoved, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, votePoll, wipeCache };