@amityco/ts-sdk 0.0.1-689c36a.0 → 0.0.1-6a755fa.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/cache.d.ts +1 -1
- package/dist/@types/core/cache.d.ts.map +1 -1
- package/dist/@types/core/paging.d.ts +10 -10
- package/dist/@types/core/paging.d.ts.map +1 -1
- package/dist/@types/core/query.d.ts +5 -4
- package/dist/@types/core/query.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts +3 -3
- package/dist/channel/api/queryChannels.d.ts +1 -1
- package/dist/community/api/getRecommendedCommunities.d.ts +32 -0
- package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -0
- package/dist/community/api/getTopTrendingCommunities.d.ts +32 -0
- package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -0
- package/dist/community/api/index.d.ts +2 -0
- package/dist/community/api/index.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts +1 -1
- package/dist/core/query/paging.d.ts +3 -3
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/feed/api/queryGlobalFeed.d.ts +1 -1
- package/dist/index.cjs.js +132 -4
- package/dist/index.esm.js +131 -5
- package/dist/index.umd.js +5 -5
- package/dist/post/api/queryPosts.d.ts +2 -2
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/role/api/queryRoles.d.ts +1 -1
- package/dist/stream/api/queryStreams.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/cache.ts +1 -1
- package/src/@types/core/paging.ts +9 -9
- package/src/@types/core/query.ts +8 -4
- package/src/community/api/getRecommendedCommunities.ts +86 -0
- package/src/community/api/getTopTrendingCommunities.ts +86 -0
- package/src/community/api/index.ts +3 -0
- package/src/core/query/paging.ts +10 -10
- package/src/post/api/queryPosts.ts +2 -2
|
@@ -42,7 +42,7 @@ declare global {
|
|
|
42
42
|
/**
|
|
43
43
|
* Minimal CacheEntry alias, used mostly
|
|
44
44
|
*/
|
|
45
|
-
type Cached<T extends unknown = unknown> = (T extends Amity.Paged<any> ? T : {
|
|
45
|
+
type Cached<T extends unknown = unknown> = (T extends Amity.Paged<any, infer K> ? T : {
|
|
46
46
|
data: T;
|
|
47
47
|
}) & {
|
|
48
48
|
cachedAt: CacheOptions['cachedAt'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/@types/core/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAA;AAET,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd;;;;;WAKG;QACH,KAAK,YAAY,GAAG,CAClB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,EAAE,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;SAAE,CACzF,CAAA;QAED;;;WAGG;QACH,KAAK,QAAQ,GAAG,YAAY,EAAE,CAAA;QAE9B;;;;WAIG;QACH,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI;YAC7C,GAAG,EAAE,QAAQ,CAAA;YACb,IAAI,EAAE,CAAC,CAAA;SACR,GAAG,YAAY,CAAA;QAEhB;;;;;;;;;;WAUG;QACH,KAAK,YAAY,GAAG;YAClB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;YAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;SAClB,CAAA;QAGD;;WAEG;QACF,KAAK,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAC1C,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/@types/core/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAA;AAET,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd;;;;;WAKG;QACH,KAAK,YAAY,GAAG,CAClB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,EAAE,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;SAAE,CACzF,CAAA;QAED;;;WAGG;QACH,KAAK,QAAQ,GAAG,YAAY,EAAE,CAAA;QAE9B;;;;WAIG;QACH,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI;YAC7C,GAAG,EAAE,QAAQ,CAAA;YACb,IAAI,EAAE,CAAC,CAAA;SACR,GAAG,YAAY,CAAA;QAEhB;;;;;;;;;;WAUG;QACH,KAAK,YAAY,GAAG;YAClB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;YAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;SAClB,CAAA;QAGD;;WAEG;QACF,KAAK,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAC1C,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAC/B,CAAC,GACD;YAAE,IAAI,EAAE,CAAC,CAAA;SAAE,CACf,GAAG;YACH,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;SACnC,CAAA;QAED;;;;WAIG;QACH,KAAK,KAAK,GAAG;YACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;YAChC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;SACnD,CAAA;KACF;CACF"}
|
|
@@ -2,19 +2,19 @@ export {};
|
|
|
2
2
|
declare global {
|
|
3
3
|
namespace Amity {
|
|
4
4
|
type PaginationStyles = 'skiplimit' | 'afterbefore' | 'afterbeforeraw';
|
|
5
|
-
type
|
|
5
|
+
type PageLimit = {
|
|
6
6
|
limit: number;
|
|
7
7
|
};
|
|
8
|
-
type PrevPage<T extends number | string
|
|
8
|
+
type PrevPage<T extends number | string> = PageLimit & {
|
|
9
9
|
after?: never;
|
|
10
10
|
before?: T;
|
|
11
11
|
};
|
|
12
|
-
type NextPage<T extends number | string
|
|
12
|
+
type NextPage<T extends number | string> = PageLimit & {
|
|
13
13
|
after?: T;
|
|
14
14
|
before?: never;
|
|
15
15
|
};
|
|
16
|
-
type Page
|
|
17
|
-
type PageRaw =
|
|
16
|
+
type Page = PrevPage<number> | NextPage<number>;
|
|
17
|
+
type PageRaw = (PrevPage<string> | NextPage<string>) & {
|
|
18
18
|
updatedAt?: string;
|
|
19
19
|
};
|
|
20
20
|
type SkipLimitPagination = {
|
|
@@ -28,13 +28,13 @@ declare global {
|
|
|
28
28
|
last?: number;
|
|
29
29
|
};
|
|
30
30
|
type AfterBeforeRawPagination = PageRaw;
|
|
31
|
-
type Pages = {
|
|
32
|
-
nextPage?:
|
|
33
|
-
prevPage?:
|
|
31
|
+
type Pages<T extends (Page | PageRaw)> = {
|
|
32
|
+
nextPage?: T;
|
|
33
|
+
prevPage?: T;
|
|
34
34
|
};
|
|
35
|
-
type Paged<T> = {
|
|
35
|
+
type Paged<T, K extends (Page | PageRaw) = Page> = {
|
|
36
36
|
data: T[];
|
|
37
|
-
} & Pages
|
|
37
|
+
} & Pages<K>;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
//# sourceMappingURL=paging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../../src/@types/core/paging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAA;AAET,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,gBAAgB,GAAG,WAAW,GAAG,aAAa,GAAG,gBAAgB,CAAA;QAEtE,KAAK,
|
|
1
|
+
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../../src/@types/core/paging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAA;AAET,OAAO,CAAC,MAAM,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C,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI;YAAE,IAAI,EAAE,CAAC,EAAE,CAAA;SAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;KAC5E;CACF"}
|
|
@@ -32,19 +32,20 @@ declare global {
|
|
|
32
32
|
loading: boolean;
|
|
33
33
|
error?: any;
|
|
34
34
|
};
|
|
35
|
-
type Snapshot<T> = (T extends Amity.Cached<infer T2> ? T2 extends Amity.Paged<infer T3> ? {
|
|
35
|
+
type Snapshot<T> = (T extends Amity.Cached<infer T2> ? T2 extends Amity.Paged<infer T3, infer T4> ? {
|
|
36
36
|
data: T3[] | undefined;
|
|
37
|
-
} & Pages & {
|
|
37
|
+
} & Pages<T4> & {
|
|
38
38
|
cachedAt?: CacheOptions['cachedAt'];
|
|
39
39
|
} : {
|
|
40
40
|
data: T2;
|
|
41
41
|
} & {
|
|
42
42
|
cachedAt?: CacheOptions['cachedAt'];
|
|
43
|
-
} : T extends Amity.Paged<infer T3> ? {
|
|
43
|
+
} : T extends Amity.Paged<infer T3, infer T4> ? {
|
|
44
44
|
data: T3[] | undefined;
|
|
45
|
-
} & Pages : {
|
|
45
|
+
} & Pages<T4> : {
|
|
46
46
|
data: T | undefined;
|
|
47
47
|
}) & SnapshotOptions;
|
|
48
|
+
type RunQueryOptions<T> = T extends Amity.AsyncFunc<infer Args, infer Returned> ? Omit<Amity.Snapshot<Returned>, 'data'> : never;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/@types/core/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAA;AAET,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,QAAQ,GAAG;YACd,QAAQ,EAAE,MAAM,CAAA;SACjB,CAAA;QAED,KAAK,KAAK,GAAG;YACX,QAAQ,EA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AM,EAAE,CAAC,GACvC;YAAE,IAAI,EAAE,EAAE,EAAE,GAAG,SAAS,CAAA;SAAE,GAAG,KAAK,CAAC,EAAE,CAAC,GACtC;YAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAA;SAAE,CAC9B,GAAG,eAAe,CAAA;QAEnB,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,MAAM,QAAQ,CAAC,GAC3E,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,GACtC,KAAK,CAAA;KACV;CACF"}
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
export declare const queryCategories: (query?: {
|
|
16
16
|
sortBy?: "lastCreated" | "firstCreated" | "name" | undefined;
|
|
17
17
|
isDeleted?: Amity.Category['isDeleted'];
|
|
18
|
-
page?: Amity.Page
|
|
18
|
+
page?: Amity.Page | undefined;
|
|
19
19
|
} | undefined) => Promise<{
|
|
20
20
|
data: Amity.Category[];
|
|
21
|
-
prevPage: Amity.Page
|
|
22
|
-
nextPage: Amity.Page
|
|
21
|
+
prevPage: Amity.Page | undefined;
|
|
22
|
+
nextPage: Amity.Page | undefined;
|
|
23
23
|
}>;
|
|
24
24
|
//# sourceMappingURL=queryCategories.d.ts.map
|
|
@@ -19,7 +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
|
-
page?: Amity.Page
|
|
22
|
+
page?: Amity.Page | undefined;
|
|
23
23
|
} | undefined): Promise<Amity.Cached<Amity.Paged<Amity.Channel>>>;
|
|
24
24
|
/**
|
|
25
25
|
* ```js
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
4
|
+
* const communities = await getRecommendedCommunities()
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* Gets a list of recommended {@link Amity.Community} objects
|
|
8
|
+
*
|
|
9
|
+
* @param query The query parameters
|
|
10
|
+
* @returns A list of {@link Amity.Community} objects
|
|
11
|
+
*
|
|
12
|
+
* @category Community API
|
|
13
|
+
* @async
|
|
14
|
+
*/
|
|
15
|
+
export declare const getRecommendedCommunities: {
|
|
16
|
+
(query?: Partial<Amity.PageLimit> | undefined): Promise<Amity.Cached<Amity.Community[]>>;
|
|
17
|
+
/**
|
|
18
|
+
* ```js
|
|
19
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
20
|
+
* const communities = getRecommendedCommunities.locally()
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Gets a list of recommended {@link Amity.Community} objects from cache
|
|
24
|
+
*
|
|
25
|
+
* @param query The query parameters
|
|
26
|
+
* @returns communities
|
|
27
|
+
*
|
|
28
|
+
* @category Community API
|
|
29
|
+
*/
|
|
30
|
+
locally(query: Parameters<typeof getRecommendedCommunities>[0]): Amity.Cached<Amity.Community[]> | undefined;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=getRecommendedCommunities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRecommendedCommunities.d.ts","sourceRoot":"","sources":["../../../src/community/api/getRecommendedCommunities.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB;oDAEnC,QAAQ,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC;IA0B3C;;;;;;;;;;;;OAYG;mBAEM,WAAW,gCAAgC,CAAC,CAAC,CAAC,CAAC,GACrD,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,CAAC,GAAG,SAAS;CAjB7C,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
4
|
+
* const trendingCommunities = await getTopTrendingCommunities()
|
|
5
|
+
* ```
|
|
6
|
+
*
|
|
7
|
+
* Gets a list of top trending {@link Amity.Community} objects
|
|
8
|
+
*
|
|
9
|
+
* @param query The query parameters
|
|
10
|
+
* @returns A list of {@link Amity.Community} objects
|
|
11
|
+
*
|
|
12
|
+
* @category Community API
|
|
13
|
+
* @async
|
|
14
|
+
*/
|
|
15
|
+
export declare const getTopTrendingCommunities: {
|
|
16
|
+
(query?: Partial<Amity.PageLimit> | undefined): Promise<Amity.Cached<Amity.Community[]>>;
|
|
17
|
+
/**
|
|
18
|
+
* ```js
|
|
19
|
+
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
20
|
+
* const communities = getTopTrendingCommunities.locally()
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Gets a list of top trending {@link Amity.Community} objects from cache
|
|
24
|
+
*
|
|
25
|
+
* @param query The query parameters
|
|
26
|
+
* @returns communities
|
|
27
|
+
*
|
|
28
|
+
* @category Community API
|
|
29
|
+
*/
|
|
30
|
+
locally(query: Parameters<typeof getTopTrendingCommunities>[0]): Amity.Cached<Amity.Community[]> | undefined;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=getTopTrendingCommunities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTopTrendingCommunities.d.ts","sourceRoot":"","sources":["../../../src/community/api/getTopTrendingCommunities.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB;oDAEnC,QAAQ,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC;IA0B3C;;;;;;;;;;;;OAYG;mBAEM,WAAW,gCAAgC,CAAC,CAAC,CAAC,CAAC,GACrD,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,CAAC,GAAG,SAAS;CAjB7C,CAAA"}
|
|
@@ -11,4 +11,6 @@ export * from './addCommunityMembers';
|
|
|
11
11
|
export * from './removeCommunityMembers';
|
|
12
12
|
export * from './addCommunityMembersRole';
|
|
13
13
|
export * from './removeCommunityMembersRole';
|
|
14
|
+
export * from './getTopTrendingCommunities';
|
|
15
|
+
export * from './getRecommendedCommunities';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/community/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAEhC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AAExC,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/community/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAEhC,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AAExC,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAE5C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA"}
|
|
@@ -22,7 +22,7 @@ export declare const queryCommunities: {
|
|
|
22
22
|
hasFlag?: boolean | undefined;
|
|
23
23
|
tags?: Amity.Taggable['tags'];
|
|
24
24
|
sortBy?: "displayName" | "firstCreated" | "lastCreated" | undefined;
|
|
25
|
-
page?: Amity.Page
|
|
25
|
+
page?: Amity.Page | undefined;
|
|
26
26
|
} | undefined): Promise<Amity.Cached<Amity.Paged<Amity.Community>>>;
|
|
27
27
|
/**
|
|
28
28
|
* ```js
|
|
@@ -33,7 +33,7 @@ export declare const isAfterBeforeRaw: (json: Object) => json is Amity.PageRaw;
|
|
|
33
33
|
*
|
|
34
34
|
* @hidden
|
|
35
35
|
*/
|
|
36
|
-
export declare const isPaged: <T extends unknown>(payload: any) => payload is Amity.Paged<T>;
|
|
36
|
+
export declare const isPaged: <T extends unknown>(payload: any) => payload is Amity.Paged<T, any>;
|
|
37
37
|
/**
|
|
38
38
|
* Converts a paging object into a b64 string token
|
|
39
39
|
*
|
|
@@ -52,7 +52,7 @@ export declare const toToken: (paging: Amity.Page | Amity.PageRaw | undefined, s
|
|
|
52
52
|
*
|
|
53
53
|
* @hidden
|
|
54
54
|
*/
|
|
55
|
-
export declare const toPage: (token?: string | undefined) => Amity.Page |
|
|
55
|
+
export declare const toPage: (token?: string | undefined) => Amity.Page | undefined;
|
|
56
56
|
/**
|
|
57
57
|
* Converts a b64 string token into a paging object
|
|
58
58
|
*
|
|
@@ -61,5 +61,5 @@ export declare const toPage: (token?: string | undefined) => Amity.Page | null;
|
|
|
61
61
|
*
|
|
62
62
|
* @hidden
|
|
63
63
|
*/
|
|
64
|
-
export declare const toPageRaw: (token?: string | undefined) => Amity.PageRaw |
|
|
64
|
+
export declare const toPageRaw: (token?: string | undefined) => Amity.PageRaw | undefined;
|
|
65
65
|
//# sourceMappingURL=paging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../../src/core/query/paging.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,sCAEvC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,SAAU,MAAM,wCAEzC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,SAAU,MAAM,0BAE5C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,+BAAgC,GAAG,
|
|
1
|
+
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../../src/core/query/paging.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,sCAEvC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,SAAU,MAAM,wCAEzC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,SAAU,MAAM,0BAE5C,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,+BAAgC,GAAG,mCAMtD,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,WACV,MAAM,IAAI,GAAG,MAAM,OAAO,GAAG,SAAS,SACvC,MAAM,gBAAgB,KAC5B,MAAM,KAAK,GAAG,SA8ChB,CAAA;AAGD;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,kCAA0B,MAAM,IAAI,GAAG,SA0BzD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,kCAA0B,MAAM,OAAO,GAAG,SAW/D,CAAA"}
|
|
@@ -16,7 +16,7 @@ export declare const queryGlobalFeed: {
|
|
|
16
16
|
(query?: {
|
|
17
17
|
dataTypes?: ("video" | "image" | "file" | "liveStream")[] | undefined;
|
|
18
18
|
useCustomRanking?: boolean | undefined;
|
|
19
|
-
page?: Amity.Page
|
|
19
|
+
page?: Amity.Page | undefined;
|
|
20
20
|
} | undefined): Promise<Amity.Cached<Amity.Paged<Amity.Post>>>;
|
|
21
21
|
/**
|
|
22
22
|
* ```js
|
package/dist/index.cjs.js
CHANGED
|
@@ -132,7 +132,7 @@ const toToken = (paging, style) => {
|
|
|
132
132
|
*/
|
|
133
133
|
const toPage = (token) => {
|
|
134
134
|
if (!token)
|
|
135
|
-
return
|
|
135
|
+
return undefined;
|
|
136
136
|
// don't try catch, let it throw
|
|
137
137
|
const json = JSON.parse(jsBase64.decode(token));
|
|
138
138
|
if (isSkipLimit(json)) {
|
|
@@ -155,7 +155,7 @@ const toPage = (token) => {
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
return
|
|
158
|
+
return undefined;
|
|
159
159
|
};
|
|
160
160
|
/**
|
|
161
161
|
* Converts a b64 string token into a paging object
|
|
@@ -167,13 +167,13 @@ const toPage = (token) => {
|
|
|
167
167
|
*/
|
|
168
168
|
const toPageRaw = (token) => {
|
|
169
169
|
if (!token)
|
|
170
|
-
return
|
|
170
|
+
return undefined;
|
|
171
171
|
// don't try catch, let it throw
|
|
172
172
|
const json = JSON.parse(jsBase64.decode(token));
|
|
173
173
|
if (isAfterBeforeRaw(json)) {
|
|
174
174
|
return json;
|
|
175
175
|
}
|
|
176
|
-
return
|
|
176
|
+
return undefined;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
/**
|
|
@@ -17387,6 +17387,132 @@ const removeCommunityMembersRole = async (communityId, roleId, userIds) => {
|
|
|
17387
17387
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && !communityUser.roles.includes(roleId));
|
|
17388
17388
|
};
|
|
17389
17389
|
|
|
17390
|
+
/**
|
|
17391
|
+
* ```js
|
|
17392
|
+
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
17393
|
+
* const trendingCommunities = await getTopTrendingCommunities()
|
|
17394
|
+
* ```
|
|
17395
|
+
*
|
|
17396
|
+
* Gets a list of top trending {@link Amity.Community} objects
|
|
17397
|
+
*
|
|
17398
|
+
* @param query The query parameters
|
|
17399
|
+
* @returns A list of {@link Amity.Community} objects
|
|
17400
|
+
*
|
|
17401
|
+
* @category Community API
|
|
17402
|
+
* @async
|
|
17403
|
+
*/
|
|
17404
|
+
const getTopTrendingCommunities = async (query) => {
|
|
17405
|
+
const client = getActiveClient();
|
|
17406
|
+
client.log('channel/getTopTrendingCommunities', query);
|
|
17407
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17408
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
17409
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
17410
|
+
const { data } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
17411
|
+
const { communities } = data;
|
|
17412
|
+
const cachedAt = client.cache && Date.now();
|
|
17413
|
+
if (client.cache) {
|
|
17414
|
+
ingestInCache(data, { cachedAt });
|
|
17415
|
+
const cacheKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
17416
|
+
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
|
|
17417
|
+
}
|
|
17418
|
+
return { data: communities, cachedAt };
|
|
17419
|
+
};
|
|
17420
|
+
/**
|
|
17421
|
+
* ```js
|
|
17422
|
+
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
17423
|
+
* const communities = getTopTrendingCommunities.locally()
|
|
17424
|
+
* ```
|
|
17425
|
+
*
|
|
17426
|
+
* Gets a list of top trending {@link Amity.Community} objects from cache
|
|
17427
|
+
*
|
|
17428
|
+
* @param query The query parameters
|
|
17429
|
+
* @returns communities
|
|
17430
|
+
*
|
|
17431
|
+
* @category Community API
|
|
17432
|
+
*/
|
|
17433
|
+
getTopTrendingCommunities.locally = (query) => {
|
|
17434
|
+
var _a, _b;
|
|
17435
|
+
const client = getActiveClient();
|
|
17436
|
+
client.log('community/getTopTrendingCommunities.locally', query);
|
|
17437
|
+
if (!client.cache)
|
|
17438
|
+
return;
|
|
17439
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17440
|
+
const queryKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
17441
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
17442
|
+
if (!(data === null || data === void 0 ? void 0 : data.communities.length))
|
|
17443
|
+
return;
|
|
17444
|
+
const communities = data.communities
|
|
17445
|
+
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
17446
|
+
.filter(Boolean)
|
|
17447
|
+
.map(({ data }) => data);
|
|
17448
|
+
return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
|
|
17449
|
+
? { data: communities, cachedAt }
|
|
17450
|
+
: undefined;
|
|
17451
|
+
};
|
|
17452
|
+
|
|
17453
|
+
/**
|
|
17454
|
+
* ```js
|
|
17455
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
17456
|
+
* const communities = await getRecommendedCommunities()
|
|
17457
|
+
* ```
|
|
17458
|
+
*
|
|
17459
|
+
* Gets a list of recommended {@link Amity.Community} objects
|
|
17460
|
+
*
|
|
17461
|
+
* @param query The query parameters
|
|
17462
|
+
* @returns A list of {@link Amity.Community} objects
|
|
17463
|
+
*
|
|
17464
|
+
* @category Community API
|
|
17465
|
+
* @async
|
|
17466
|
+
*/
|
|
17467
|
+
const getRecommendedCommunities = async (query) => {
|
|
17468
|
+
const client = getActiveClient();
|
|
17469
|
+
client.log('channel/getRecommendedCommunities', query);
|
|
17470
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17471
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
17472
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
17473
|
+
const { data } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
17474
|
+
const { communities } = data;
|
|
17475
|
+
const cachedAt = client.cache && Date.now();
|
|
17476
|
+
if (client.cache) {
|
|
17477
|
+
ingestInCache(data, { cachedAt });
|
|
17478
|
+
const cacheKey = ['community', 'recommended', { params: { options: { limit } } }];
|
|
17479
|
+
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
|
|
17480
|
+
}
|
|
17481
|
+
return { data: communities, cachedAt };
|
|
17482
|
+
};
|
|
17483
|
+
/**
|
|
17484
|
+
* ```js
|
|
17485
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
17486
|
+
* const communities = getRecommendedCommunities.locally()
|
|
17487
|
+
* ```
|
|
17488
|
+
*
|
|
17489
|
+
* Gets a list of recommended {@link Amity.Community} objects from cache
|
|
17490
|
+
*
|
|
17491
|
+
* @param query The query parameters
|
|
17492
|
+
* @returns communities
|
|
17493
|
+
*
|
|
17494
|
+
* @category Community API
|
|
17495
|
+
*/
|
|
17496
|
+
getRecommendedCommunities.locally = (query) => {
|
|
17497
|
+
var _a, _b;
|
|
17498
|
+
const client = getActiveClient();
|
|
17499
|
+
client.log('community/getRecommendedCommunities.locally', query);
|
|
17500
|
+
if (!client.cache)
|
|
17501
|
+
return;
|
|
17502
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17503
|
+
const queryKey = ['community', 'recommended', { params: { options: { limit } } }];
|
|
17504
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
17505
|
+
if (!(data === null || data === void 0 ? void 0 : data.communities.length))
|
|
17506
|
+
return;
|
|
17507
|
+
const communities = data.communities
|
|
17508
|
+
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
17509
|
+
.filter(Boolean)
|
|
17510
|
+
.map(({ data }) => data);
|
|
17511
|
+
return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
|
|
17512
|
+
? { data: communities, cachedAt }
|
|
17513
|
+
: undefined;
|
|
17514
|
+
};
|
|
17515
|
+
|
|
17390
17516
|
/**
|
|
17391
17517
|
* ```js
|
|
17392
17518
|
* import { deletePost } from '@amityco/ts-sdk'
|
|
@@ -20657,8 +20783,10 @@ exports.getMyFollowingsTopic = getMyFollowingsTopic;
|
|
|
20657
20783
|
exports.getPost = getPost;
|
|
20658
20784
|
exports.getPostTopic = getPostTopic;
|
|
20659
20785
|
exports.getPosts = getPosts;
|
|
20786
|
+
exports.getRecommendedCommunities = getRecommendedCommunities;
|
|
20660
20787
|
exports.getRole = getRole;
|
|
20661
20788
|
exports.getStream = getStream;
|
|
20789
|
+
exports.getTopTrendingCommunities = getTopTrendingCommunities;
|
|
20662
20790
|
exports.getUser = getUser;
|
|
20663
20791
|
exports.getUserTopic = getUserTopic;
|
|
20664
20792
|
exports.getUsers = getUsers;
|
package/dist/index.esm.js
CHANGED
|
@@ -119,7 +119,7 @@ const toToken = (paging, style) => {
|
|
|
119
119
|
*/
|
|
120
120
|
const toPage = (token) => {
|
|
121
121
|
if (!token)
|
|
122
|
-
return
|
|
122
|
+
return undefined;
|
|
123
123
|
// don't try catch, let it throw
|
|
124
124
|
const json = JSON.parse(decode(token));
|
|
125
125
|
if (isSkipLimit(json)) {
|
|
@@ -142,7 +142,7 @@ const toPage = (token) => {
|
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
return
|
|
145
|
+
return undefined;
|
|
146
146
|
};
|
|
147
147
|
/**
|
|
148
148
|
* Converts a b64 string token into a paging object
|
|
@@ -154,13 +154,13 @@ const toPage = (token) => {
|
|
|
154
154
|
*/
|
|
155
155
|
const toPageRaw = (token) => {
|
|
156
156
|
if (!token)
|
|
157
|
-
return
|
|
157
|
+
return undefined;
|
|
158
158
|
// don't try catch, let it throw
|
|
159
159
|
const json = JSON.parse(decode(token));
|
|
160
160
|
if (isAfterBeforeRaw(json)) {
|
|
161
161
|
return json;
|
|
162
162
|
}
|
|
163
|
-
return
|
|
163
|
+
return undefined;
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
/**
|
|
@@ -17374,6 +17374,132 @@ const removeCommunityMembersRole = async (communityId, roleId, userIds) => {
|
|
|
17374
17374
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && !communityUser.roles.includes(roleId));
|
|
17375
17375
|
};
|
|
17376
17376
|
|
|
17377
|
+
/**
|
|
17378
|
+
* ```js
|
|
17379
|
+
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
17380
|
+
* const trendingCommunities = await getTopTrendingCommunities()
|
|
17381
|
+
* ```
|
|
17382
|
+
*
|
|
17383
|
+
* Gets a list of top trending {@link Amity.Community} objects
|
|
17384
|
+
*
|
|
17385
|
+
* @param query The query parameters
|
|
17386
|
+
* @returns A list of {@link Amity.Community} objects
|
|
17387
|
+
*
|
|
17388
|
+
* @category Community API
|
|
17389
|
+
* @async
|
|
17390
|
+
*/
|
|
17391
|
+
const getTopTrendingCommunities = async (query) => {
|
|
17392
|
+
const client = getActiveClient();
|
|
17393
|
+
client.log('channel/getTopTrendingCommunities', query);
|
|
17394
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17395
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
17396
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
17397
|
+
const { data } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
17398
|
+
const { communities } = data;
|
|
17399
|
+
const cachedAt = client.cache && Date.now();
|
|
17400
|
+
if (client.cache) {
|
|
17401
|
+
ingestInCache(data, { cachedAt });
|
|
17402
|
+
const cacheKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
17403
|
+
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
|
|
17404
|
+
}
|
|
17405
|
+
return { data: communities, cachedAt };
|
|
17406
|
+
};
|
|
17407
|
+
/**
|
|
17408
|
+
* ```js
|
|
17409
|
+
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
17410
|
+
* const communities = getTopTrendingCommunities.locally()
|
|
17411
|
+
* ```
|
|
17412
|
+
*
|
|
17413
|
+
* Gets a list of top trending {@link Amity.Community} objects from cache
|
|
17414
|
+
*
|
|
17415
|
+
* @param query The query parameters
|
|
17416
|
+
* @returns communities
|
|
17417
|
+
*
|
|
17418
|
+
* @category Community API
|
|
17419
|
+
*/
|
|
17420
|
+
getTopTrendingCommunities.locally = (query) => {
|
|
17421
|
+
var _a, _b;
|
|
17422
|
+
const client = getActiveClient();
|
|
17423
|
+
client.log('community/getTopTrendingCommunities.locally', query);
|
|
17424
|
+
if (!client.cache)
|
|
17425
|
+
return;
|
|
17426
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17427
|
+
const queryKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
17428
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
17429
|
+
if (!(data === null || data === void 0 ? void 0 : data.communities.length))
|
|
17430
|
+
return;
|
|
17431
|
+
const communities = data.communities
|
|
17432
|
+
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
17433
|
+
.filter(Boolean)
|
|
17434
|
+
.map(({ data }) => data);
|
|
17435
|
+
return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
|
|
17436
|
+
? { data: communities, cachedAt }
|
|
17437
|
+
: undefined;
|
|
17438
|
+
};
|
|
17439
|
+
|
|
17440
|
+
/**
|
|
17441
|
+
* ```js
|
|
17442
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
17443
|
+
* const communities = await getRecommendedCommunities()
|
|
17444
|
+
* ```
|
|
17445
|
+
*
|
|
17446
|
+
* Gets a list of recommended {@link Amity.Community} objects
|
|
17447
|
+
*
|
|
17448
|
+
* @param query The query parameters
|
|
17449
|
+
* @returns A list of {@link Amity.Community} objects
|
|
17450
|
+
*
|
|
17451
|
+
* @category Community API
|
|
17452
|
+
* @async
|
|
17453
|
+
*/
|
|
17454
|
+
const getRecommendedCommunities = async (query) => {
|
|
17455
|
+
const client = getActiveClient();
|
|
17456
|
+
client.log('channel/getRecommendedCommunities', query);
|
|
17457
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17458
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
17459
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
17460
|
+
const { data } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
17461
|
+
const { communities } = data;
|
|
17462
|
+
const cachedAt = client.cache && Date.now();
|
|
17463
|
+
if (client.cache) {
|
|
17464
|
+
ingestInCache(data, { cachedAt });
|
|
17465
|
+
const cacheKey = ['community', 'recommended', { params: { options: { limit } } }];
|
|
17466
|
+
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
|
|
17467
|
+
}
|
|
17468
|
+
return { data: communities, cachedAt };
|
|
17469
|
+
};
|
|
17470
|
+
/**
|
|
17471
|
+
* ```js
|
|
17472
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
17473
|
+
* const communities = getRecommendedCommunities.locally()
|
|
17474
|
+
* ```
|
|
17475
|
+
*
|
|
17476
|
+
* Gets a list of recommended {@link Amity.Community} objects from cache
|
|
17477
|
+
*
|
|
17478
|
+
* @param query The query parameters
|
|
17479
|
+
* @returns communities
|
|
17480
|
+
*
|
|
17481
|
+
* @category Community API
|
|
17482
|
+
*/
|
|
17483
|
+
getRecommendedCommunities.locally = (query) => {
|
|
17484
|
+
var _a, _b;
|
|
17485
|
+
const client = getActiveClient();
|
|
17486
|
+
client.log('community/getRecommendedCommunities.locally', query);
|
|
17487
|
+
if (!client.cache)
|
|
17488
|
+
return;
|
|
17489
|
+
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
17490
|
+
const queryKey = ['community', 'recommended', { params: { options: { limit } } }];
|
|
17491
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
17492
|
+
if (!(data === null || data === void 0 ? void 0 : data.communities.length))
|
|
17493
|
+
return;
|
|
17494
|
+
const communities = data.communities
|
|
17495
|
+
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
17496
|
+
.filter(Boolean)
|
|
17497
|
+
.map(({ data }) => data);
|
|
17498
|
+
return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
|
|
17499
|
+
? { data: communities, cachedAt }
|
|
17500
|
+
: undefined;
|
|
17501
|
+
};
|
|
17502
|
+
|
|
17377
17503
|
/**
|
|
17378
17504
|
* ```js
|
|
17379
17505
|
* import { deletePost } from '@amityco/ts-sdk'
|
|
@@ -20589,4 +20715,4 @@ const onStreamRecorded = (callback) => {
|
|
|
20589
20715
|
return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
|
|
20590
20716
|
};
|
|
20591
20717
|
|
|
20592
|
-
export { API_REGIONS, SubscriptionLevels, VERSION$1 as VERSION, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRole, addReaction, backupCache, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createMessage, createPost, createQuery, createReport, createStream, declineFollower, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getPost, getPostTopic, getPosts, getRole, getStream, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, mergeInCache, observeChannel, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePost, observePosts, observeUser, onChannelDeleted, onChannelJoined, onChannelLeft, 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, onMemberAdded, onMemberRemoved, onMessageCreated, onMessageDeleted, onMessageUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRole, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, wipeCache };
|
|
20718
|
+
export { API_REGIONS, SubscriptionLevels, VERSION$1 as VERSION, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRole, addReaction, backupCache, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createMessage, createPost, createQuery, createReport, createStream, declineFollower, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, 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, mergeInCache, observeChannel, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePost, observePosts, observeUser, onChannelDeleted, onChannelJoined, onChannelLeft, 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, onMemberAdded, onMemberRemoved, onMessageCreated, onMessageDeleted, onMessageUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRole, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, wipeCache };
|