@amityco/ts-sdk 7.29.1-0cb2e19.0 → 7.29.1-32c8dde1.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.
Files changed (48) hide show
  1. package/dist/@types/core/errors.d.ts +2 -1
  2. package/dist/@types/core/errors.d.ts.map +1 -1
  3. package/dist/@types/domains/user.d.ts +58 -0
  4. package/dist/@types/domains/user.d.ts.map +1 -1
  5. package/dist/index.cjs.js +311 -73
  6. package/dist/index.esm.js +313 -75
  7. package/dist/index.umd.js +2 -2
  8. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  9. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts.map +1 -1
  10. package/dist/postRepository/api/tests/integration/setup.d.ts +3 -3
  11. package/dist/report/api/isReportedByMe.d.ts.map +1 -1
  12. package/dist/userRepository/api/flagUser.d.ts.map +1 -1
  13. package/dist/userRepository/api/isUserFlaggedByMe.d.ts +26 -4
  14. package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
  15. package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -1
  16. package/dist/userRepository/api/unflagUser.d.ts +26 -4
  17. package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
  18. package/dist/userRepository/api/updateUser.d.ts.map +1 -1
  19. package/dist/userRepository/internalApi/getFlagsByMe.d.ts +21 -0
  20. package/dist/userRepository/internalApi/getFlagsByMe.d.ts.map +1 -0
  21. package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts +2 -2
  22. package/dist/userRepository/observers/getBlockedUsers/BlockedUserLiveCollectionController.d.ts.map +1 -1
  23. package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts +1 -1
  24. package/dist/userRepository/observers/getBlockingUsers/LiveCollectionController.d.ts.map +1 -1
  25. package/dist/userRepository/observers/getUsers/UserLiveCollectionController.d.ts +2 -2
  26. package/dist/userRepository/observers/getUsers/UserLiveCollectionController.d.ts.map +1 -1
  27. package/dist/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.d.ts +2 -2
  28. package/dist/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.d.ts.map +1 -1
  29. package/dist/userRepository/utils/submitUserReport.d.ts.map +1 -1
  30. package/dist/userRepository/utils/userReport.d.ts +16 -1
  31. package/dist/userRepository/utils/userReport.d.ts.map +1 -1
  32. package/dist/utils/bloomFilter.d.ts +9 -0
  33. package/dist/utils/bloomFilter.d.ts.map +1 -0
  34. package/dist/utils/linkedObject/tests/userLinkedObject.test.d.ts +2 -0
  35. package/dist/utils/linkedObject/tests/userLinkedObject.test.d.ts.map +1 -0
  36. package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -1
  37. package/dist/utils/tests/bloomFilter.test.d.ts +2 -0
  38. package/dist/utils/tests/bloomFilter.test.d.ts.map +1 -0
  39. package/dist/utils/tests/client.d.ts +1 -1
  40. package/dist/utils/tests/client.d.ts.map +1 -1
  41. package/dist/utils/tests/dummy/channel.d.ts +9 -9
  42. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  43. package/dist/utils/tests/dummy/community.d.ts +3 -3
  44. package/dist/utils/tests/dummy/message.d.ts +1 -1
  45. package/dist/utils/tests/dummy/token.d.ts +1 -1
  46. package/dist/utils/tests/dummy/user.d.ts +10 -12
  47. package/dist/utils/tests/dummy/user.d.ts.map +1 -1
  48. package/package.json +1 -1
@@ -28,7 +28,8 @@ declare global {
28
28
  VISITOR_USAGE_LIMIT_EXCEEDED = 400323,
29
29
  FEED_SNAPSHOT_EXPIRED = 400322,
30
30
  MAX_BLOCKED_USERS_REACHED = 400324,
31
- MODULE_NOT_ENTITLED = 400325
31
+ MODULE_NOT_ENTITLED = 400325,
32
+ VISITOR_REPORT_DENIED = 488999
32
33
  }
33
34
  const enum ClientError {
34
35
  UNKNOWN_ERROR = 800000,
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/@types/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,UAAU;YACnB,KAAK,UAAU;YACf,KAAK,UAAU;SAChB;QAED,WAAW,WAAW;YACpB,WAAW,SAAS;YACpB,YAAY,SAAS;YACrB,iBAAiB,SAAS;YAC1B,cAAc,SAAS;YACvB,QAAQ,SAAS;YACjB,SAAS,SAAS;YAClB,aAAa,SAAS;YACtB,gBAAgB,SAAS;YACzB,WAAW,SAAS;YACpB,UAAU,SAAS;YACnB,WAAW,SAAS;YACpB,cAAc,SAAS;YACvB,0BAA0B,SAAS;YACnC,uBAAuB,SAAS;YAChC,cAAc,SAAS;YACvB,gBAAgB,SAAS;YACzB,cAAc,SAAS;YACvB,yBAAyB,SAAS;YAClC,qBAAqB,SAAS;YAC9B,4BAA4B,SAAS;YACrC,qBAAqB,SAAS;YAC9B,yBAAyB,SAAS;YAClC,mBAAmB,SAAS;SAC7B;QAED,WAAW,WAAW;YACpB,aAAa,SAAS;YACtB,kBAAkB,SAAS;YAC3B,iBAAiB,SAAS;YAC1B,gBAAgB,SAAS;YACzB,YAAY,SAAS;YACrB,aAAa,SAAS;YACtB,wBAAwB,SAAS;SAClC;QAED,KAAK,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;KAC5C;CACF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/@types/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,UAAU;YACnB,KAAK,UAAU;YACf,KAAK,UAAU;SAChB;QAED,WAAW,WAAW;YACpB,WAAW,SAAS;YACpB,YAAY,SAAS;YACrB,iBAAiB,SAAS;YAC1B,cAAc,SAAS;YACvB,QAAQ,SAAS;YACjB,SAAS,SAAS;YAClB,aAAa,SAAS;YACtB,gBAAgB,SAAS;YACzB,WAAW,SAAS;YACpB,UAAU,SAAS;YACnB,WAAW,SAAS;YACpB,cAAc,SAAS;YACvB,0BAA0B,SAAS;YACnC,uBAAuB,SAAS;YAChC,cAAc,SAAS;YACvB,gBAAgB,SAAS;YACzB,cAAc,SAAS;YACvB,yBAAyB,SAAS;YAClC,qBAAqB,SAAS;YAC9B,4BAA4B,SAAS;YACrC,qBAAqB,SAAS;YAC9B,yBAAyB,SAAS;YAClC,mBAAmB,SAAS;YAE5B,qBAAqB,SAAS;SAC/B;QAED,WAAW,WAAW;YACpB,aAAa,SAAS;YACtB,kBAAkB,SAAS;YAC3B,iBAAiB,SAAS;YAC1B,gBAAgB,SAAS;YACzB,YAAY,SAAS;YACrB,aAAa,SAAS;YACtB,wBAAwB,SAAS;SAClC;QAED,KAAK,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;KAC5C;CACF"}
@@ -27,6 +27,20 @@ export declare enum UserProfileFieldEnum {
27
27
  DESCRIPTION = "description",
28
28
  AVATAR = "avatarFileId"
29
29
  }
30
+ /**
31
+ * Selects which of the caller's reports `UserRepository.unflagUser` withdraws, sent as the
32
+ * `reportType` query parameter. The four typed members are the backend `reportType` wire
33
+ * values and match `UserReportTypeEnum`. `UNTYPED` selects the typeless (legacy) report,
34
+ * which `isUserFlaggedByMe` returns as `reportType: null`; it is a selector only, never
35
+ * stored, and the flag endpoint refuses it.
36
+ */
37
+ export declare enum UserReportTypeFilterEnum {
38
+ DISPLAY_NAME = "displayName",
39
+ DESCRIPTION = "description",
40
+ AVATAR = "avatarFileId",
41
+ BEHAVIOR = "behavior",
42
+ UNTYPED = "untyped"
43
+ }
30
44
  export {};
31
45
  declare global {
32
46
  namespace Amity {
@@ -70,6 +84,36 @@ declare global {
70
84
  reason: ContentFlagReasonEnum;
71
85
  comment?: string;
72
86
  };
87
+ type UserReportTypeFilter = `${UserReportTypeFilterEnum}`;
88
+ /**
89
+ * Options of `UserRepository.unflagUser`. Omit `reportType` to withdraw every report
90
+ * the caller filed on the user; pass one to withdraw only that report.
91
+ */
92
+ type UserReportTypeFilterOptions = {
93
+ reportType?: Amity.UserReportTypeFilter;
94
+ };
95
+ /**
96
+ * One of the caller's own reports on a user, as the backend returns it in
97
+ * `UserRepository.isUserFlaggedByMe`. Every field is always present; a field the
98
+ * report does not carry is `null`. `reportType: null` is the typeless report (withdrawn
99
+ * with `UserReportTypeFilterEnum.UNTYPED`) and `createdAt: null` marks a report filed
100
+ * before report types existed.
101
+ */
102
+ type UserFlag = {
103
+ reportType: `${UserReportTypeEnum}` | null;
104
+ reason: string | null;
105
+ comment: string | null;
106
+ createdAt: string | null;
107
+ };
108
+ /**
109
+ * Result of `UserRepository.isUserFlaggedByMe`: the `GET /api/v4/users/:userId/isFlagByMe`
110
+ * payload as is. `isFlagByMe` says whether the caller holds any report on the user;
111
+ * `flags` lists the caller's own reports. Other users' reports are never included.
112
+ */
113
+ type UserFlagByMe = {
114
+ isFlagByMe: boolean;
115
+ flags: Amity.UserFlag[];
116
+ };
73
117
  type RawUser = {
74
118
  _id: string;
75
119
  userId: string;
@@ -87,6 +131,20 @@ declare global {
87
131
  } & Amity.Metadata & Amity.Taggable & Amity.Flaggable & Amity.Accredited & Amity.Timestamps & Amity.SoftDelete & Amity.Subscribable;
88
132
  type User = Amity.InternalUser & {
89
133
  avatar?: Amity.File<'image'> | null;
134
+ /**
135
+ * Whether the current user has probably flagged this user, computed locally from
136
+ * `hashFlag` (a Bloom filter of reporter ids) with no request. `false` is exact; `true`
137
+ * may be a false positive, and it says nothing about the report type. For the exact,
138
+ * per-type answer call `getUserFlagsByMe()`.
139
+ */
140
+ readonly isFlaggedByMe: boolean;
141
+ /**
142
+ * The current user's own reports on this user, from `GET /api/v4/users/:userId/isFlagByMe`.
143
+ * When `isFlaggedByMe` is `false` (exact, as of this user object's last update) it resolves
144
+ * `{ isFlagByMe: false, flags: [] }` without a request; otherwise it reads the server and
145
+ * returns the payload as is, including `isFlagByMe: false` after a Bloom false positive.
146
+ */
147
+ getUserFlagsByMe: () => Promise<Amity.UserFlagByMe>;
90
148
  };
91
149
  type QueryUsers = {
92
150
  filter?: 'all' | 'flagged';
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,0BAAkB,YAAY;IAC5B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,GAAG,QAAQ;CACZ;AAED,oBAAY,iBAAiB;IAC3B,YAAY,gBAAgB;IAC5B,cAAc,kBAAkB;IAChC,OAAO,WAAW;CACnB;AAED,oBAAY,kBAAkB;IAC5B,YAAY,gBAAgB;IAC5B,WAAW,gBAAgB;IAC3B,MAAM,iBAAiB;IACvB,QAAQ,aAAa;CACtB;AAED;;;;;GAKG;AACH,oBAAY,oBAAoB;IAC9B,YAAY,gBAAgB;IAC5B,WAAW,gBAAgB;IAC3B,MAAM,iBAAiB;CACxB;AAED,OAAO,EAAE,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,WAAW,cAAc;YACvB,YAAY,iBAAiB;YAC7B,WAAW,gBAAgB;SAC5B;QAED,KAAK,mBAAmB,GAAG,wBAAwB,CAAC;QAEpD,KAAK,UAAU,GAAG,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;QAE5C,WAAW,oBAAoB;YAC7B,YAAY,iBAAiB;YAC7B,WAAW,gBAAgB;YAC3B,WAAW,gBAAgB;SAC5B;QAED,KAAK,gBAAgB,GAAG,GAAG,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAExD,KAAK,aAAa,GAAG,iBAAiB,CAAC;QAEvC,KAAK,cAAc,GACf,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,aAAa,GACb,eAAe,CAAC;QAEpB,KAAK,QA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AAG;YACtB,WAAW,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;YAChD,MAAM,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;YAC3B,MAAM,CAAC,EAAE,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,oBAAoB,CAAC;YAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,SAAS,CAAC,EAAE,mBAAmB,CAAC;YAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC;SAClC,CAAC;QAEF,KAAK,kBAAkB,GAAG,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QAErF,KAAK,wBAAwB,GAAG,KAAK,CAAC,oBAAoB,CACxD,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CACvC,CAAC;QAEF,KAAK,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,CAAC;QAE/D,KAAK,uBAAuB,GAAG,KAAK,CAAC,mBAAmB,CACtD,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,EAC5B,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CACzB,CAAC;KACH;CACF"}
package/dist/index.cjs.js CHANGED
@@ -70,6 +70,21 @@ exports.UserProfileFieldEnum = void 0;
70
70
  UserProfileFieldEnum["DESCRIPTION"] = "description";
71
71
  UserProfileFieldEnum["AVATAR"] = "avatarFileId";
72
72
  })(exports.UserProfileFieldEnum || (exports.UserProfileFieldEnum = {}));
73
+ /**
74
+ * Selects which of the caller's reports `UserRepository.unflagUser` withdraws, sent as the
75
+ * `reportType` query parameter. The four typed members are the backend `reportType` wire
76
+ * values and match `UserReportTypeEnum`. `UNTYPED` selects the typeless (legacy) report,
77
+ * which `isUserFlaggedByMe` returns as `reportType: null`; it is a selector only, never
78
+ * stored, and the flag endpoint refuses it.
79
+ */
80
+ exports.UserReportTypeFilterEnum = void 0;
81
+ (function (UserReportTypeFilterEnum) {
82
+ UserReportTypeFilterEnum["DISPLAY_NAME"] = "displayName";
83
+ UserReportTypeFilterEnum["DESCRIPTION"] = "description";
84
+ UserReportTypeFilterEnum["AVATAR"] = "avatarFileId";
85
+ UserReportTypeFilterEnum["BEHAVIOR"] = "behavior";
86
+ UserReportTypeFilterEnum["UNTYPED"] = "untyped";
87
+ })(exports.UserReportTypeFilterEnum || (exports.UserReportTypeFilterEnum = {}));
73
88
 
74
89
  const FileType = Object.freeze({
75
90
  FILE: 'file',
@@ -1837,18 +1852,163 @@ async function modifyMqttConnection() {
1837
1852
  }
1838
1853
  }
1839
1854
 
1855
+ /**
1856
+ * ```js
1857
+ * import { getFlagsByMe } from '~/userRepository/internalApi/getFlagsByMe'
1858
+ * const { isFlagByMe, flags } = await getFlagsByMe('userId')
1859
+ * ```
1860
+ *
1861
+ * The v4 read behind `user.getUserFlagsByMe()` and the deprecated
1862
+ * `UserRepository.isUserFlaggedByMe`: `GET /api/v4/users/:userId/isFlagByMe`, returned as
1863
+ * received. Nothing is filtered, cached or persisted, and `hashFlag` is not consulted here.
1864
+ * This is the Web counterpart of iOS `ASCUserService.getFlagsByMe` and Android
1865
+ * `UserRepository.getFlagsByMe`, kept apart from the deprecated public function so the
1866
+ * user-object read does not change if that function ever does.
1867
+ *
1868
+ * @param userId The ID of the user whose reports by the caller are read
1869
+ * @returns the caller's {@link Amity.UserFlagByMe} on that user
1870
+ *
1871
+ * @category Private
1872
+ * @async
1873
+ */
1874
+ const getFlagsByMe = async (userId) => {
1875
+ const client = getActiveClient();
1876
+ client.log('user/getFlagsByMe', userId);
1877
+ const { data } = await client.http.get(`/api/v4/users/${encodeURIComponent(userId)}/isFlagByMe`);
1878
+ return data;
1879
+ };
1880
+
1881
+ /* eslint-disable no-bitwise */
1882
+ /**
1883
+ * Client-side test of the `hashFlag` Bloom filter the backend attaches to flaggable objects.
1884
+ *
1885
+ * The filter holds the ids of every user who flagged the object: `bits` is its size, `hashes`
1886
+ * the number of hash functions per id and `hash` the bit array, base64-encoded. This is a port
1887
+ * of the test iOS (`_BloomFilter`) and Android (`EkoBloomFilter`) already run: FNV-1a 32-bit
1888
+ * over the UTF-8 bytes of the id with seeds `0` and `1576284489`, combined by double hashing
1889
+ * (`(a + i·b) mod bits`). A Bloom filter has no false negatives, so `false` is exact; `true`
1890
+ * means "probably", because another id's hashes may have set the same bits. The filter knows
1891
+ * nothing about report types.
1892
+ */
1893
+ const FNV_OFFSET_BASIS = 0x811c9dc5;
1894
+ const FNV_PRIME = 16777619;
1895
+ const SECOND_SEED = 1576284489;
1896
+ /** FNV-1a with the same mixing step and signed-byte handling as the native SDKs. */
1897
+ const fnv1a = (bytes, seed) => {
1898
+ let a = (FNV_OFFSET_BASIS ^ seed) >>> 0;
1899
+ for (let i = 0; i < bytes.length; i += 1) {
1900
+ // Bytes are `char` on iOS and `byte` on Android: both signed, so 0x80..0xff sign-extend.
1901
+ const byte = bytes[i] > 127 ? bytes[i] - 256 : bytes[i];
1902
+ a = Math.imul((a ^ byte) >>> 0, FNV_PRIME) >>> 0;
1903
+ }
1904
+ a = (a + (a << 13)) >>> 0;
1905
+ a = (a ^ (a >>> 7)) >>> 0;
1906
+ a = (a + (a << 3)) >>> 0;
1907
+ a = (a ^ (a >>> 17)) >>> 0;
1908
+ a = (a + (a << 5)) >>> 0;
1909
+ return a;
1910
+ };
1911
+ /** Bit positions for `value`, reproducing the native SDKs' signed 32-bit arithmetic. */
1912
+ const locationsFor = (value, bits, hashes) => {
1913
+ const bytes = jsBase64.toUint8Array(jsBase64.encode(value)); // UTF-8 bytes of the id
1914
+ const a = fnv1a(bytes, 0) | 0;
1915
+ const b = fnv1a(bytes, SECOND_SEED) | 0;
1916
+ const locations = [];
1917
+ let x = a % bits;
1918
+ for (let i = 0; i < hashes; i += 1) {
1919
+ locations.push(x < 0 ? x + bits : x);
1920
+ x = ((x + b) | 0) % bits;
1921
+ }
1922
+ return locations;
1923
+ };
1924
+ /**
1925
+ * Whether `value` is probably in the filter. `false` is exact; `true` may be a false positive.
1926
+ * A missing filter (`null`, the server's value when nobody has flagged the object), a missing
1927
+ * value or a malformed filter all answer `false`.
1928
+ */
1929
+ const testBloomFilter = (hashFlag, value) => {
1930
+ if (!hashFlag || !value)
1931
+ return false;
1932
+ const { bits, hashes, hash } = hashFlag;
1933
+ if (!(bits > 0) || !(hashes > 0) || typeof hash !== 'string')
1934
+ return false;
1935
+ let buckets;
1936
+ try {
1937
+ buckets = jsBase64.toUint8Array(hash);
1938
+ }
1939
+ catch (_a) {
1940
+ return false;
1941
+ }
1942
+ const locations = locationsFor(value, bits, hashes);
1943
+ for (let i = 0; i < locations.length; i += 1) {
1944
+ const index = Math.floor(locations[i] / 8);
1945
+ const bit = 1 << locations[i] % 8;
1946
+ if (index >= buckets.length || (buckets[index] & bit) === 0)
1947
+ return false;
1948
+ }
1949
+ return true;
1950
+ };
1951
+
1952
+ /** The current user's id, or `undefined` when there is no active client (the getter never throws). */
1953
+ const currentUserId = () => {
1954
+ try {
1955
+ return getActiveClient().userId;
1956
+ }
1957
+ catch (_a) {
1958
+ return undefined;
1959
+ }
1960
+ };
1961
+ /**
1962
+ * One `getUserFlagsByMe` closure per userId, remembering the newest user object linked for
1963
+ * that id. Live objects and collections compare snapshots with `isEqual`, which compares
1964
+ * functions by reference: a fresh closure on every linked object would make two reads of the
1965
+ * same user unequal and re-dispatch snapshots that did not change.
1966
+ */
1967
+ const flagsByMeEntries = new Map();
1968
+ /**
1969
+ * A Bloom filter has no false negatives, so `isFlaggedByMe === false` is exact and the request
1970
+ * can be skipped (REQ-012). The newest user object linked for that id is tested, as of its last
1971
+ * update. Without a filter to test, or without a current user, the server is asked.
1972
+ */
1973
+ const knownNotFlaggedByMe = (userId) => {
1974
+ var _a;
1975
+ const me = currentUserId();
1976
+ const user = (_a = flagsByMeEntries.get(userId)) === null || _a === void 0 ? void 0 : _a.latest;
1977
+ if (!me || !user || user.hashFlag === undefined)
1978
+ return false;
1979
+ return !testBloomFilter(user.hashFlag, me);
1980
+ };
1981
+ const getUserFlagsByMeFor = (user) => {
1982
+ let entry = flagsByMeEntries.get(user.userId);
1983
+ if (!entry) {
1984
+ entry = {
1985
+ latest: user,
1986
+ getUserFlagsByMe: async () => {
1987
+ if (knownNotFlaggedByMe(user.userId))
1988
+ return { isFlagByMe: false, flags: [] };
1989
+ return getFlagsByMe(user.userId);
1990
+ },
1991
+ };
1992
+ flagsByMeEntries.set(user.userId, entry);
1993
+ }
1994
+ entry.latest = user;
1995
+ return entry.getUserFlagsByMe;
1996
+ };
1840
1997
  const userLinkedObject = (user) => {
1841
1998
  return Object.assign(Object.assign({}, user), { get avatar() {
1842
1999
  var _a;
1843
2000
  if (!user.avatarFileId)
1844
- return undefined;
1845
- const avatar = (_a = pullFromCache([
1846
- 'file',
1847
- 'get',
1848
- `${user.avatarFileId}`,
1849
- ])) === null || _a === void 0 ? void 0 : _a.data;
2001
+ return null;
2002
+ const avatar = (_a = pullFromCache(['file', 'get', user.avatarFileId])) === null || _a === void 0 ? void 0 : _a.data;
2003
+ if (!avatar)
2004
+ return null;
1850
2005
  return avatar;
1851
- } });
2006
+ },
2007
+ get isFlaggedByMe() {
2008
+ // Local Bloom-filter test on this object's own hashFlag: exact when false, "probably"
2009
+ // when true, type-blind, no request. getUserFlagsByMe() gives the exact, per-type answer.
2010
+ return testBloomFilter(user.hashFlag, currentUserId());
2011
+ }, getUserFlagsByMe: getUserFlagsByMeFor(user) });
1852
2012
  };
1853
2013
 
1854
2014
  /* begin_public_function
@@ -3097,12 +3257,19 @@ const getSubChannelMessagePreview = (subChannelId) => {
3097
3257
  };
3098
3258
 
3099
3259
  const getSubChannelMessagePreviewWithUser = (subChannel) => {
3100
- var _a;
3101
3260
  const messagePreview = subChannel.messagePreviewId
3102
3261
  ? getSubChannelMessagePreview(subChannel.subChannelId)
3103
3262
  : null;
3104
3263
  const messagePreviewWithUser = messagePreview
3105
- ? Object.assign(Object.assign({}, messagePreview), { user: (_a = pullFromCache(['user', 'get', messagePreview === null || messagePreview === void 0 ? void 0 : messagePreview.creatorId])) === null || _a === void 0 ? void 0 : _a.data }) : null;
3264
+ ? Object.assign(Object.assign({}, messagePreview), { user: (() => {
3265
+ var _a;
3266
+ const internalUser = (_a = pullFromCache([
3267
+ 'user',
3268
+ 'get',
3269
+ messagePreview === null || messagePreview === void 0 ? void 0 : messagePreview.creatorId,
3270
+ ])) === null || _a === void 0 ? void 0 : _a.data;
3271
+ return internalUser ? userLinkedObject(internalUser) : undefined;
3272
+ })() }) : null;
3106
3273
  return Object.assign(Object.assign({}, subChannel), { messagePreview: messagePreviewWithUser });
3107
3274
  };
3108
3275
 
@@ -15407,7 +15574,7 @@ const updateUser = async (userId, patch) => {
15407
15574
  ingestInCache(payload, { cachedAt });
15408
15575
  fireEvent('user.updated', data);
15409
15576
  return {
15410
- data: payload.users.find(user => user.userId === userId),
15577
+ data: userLinkedObject(payload.users.find(user => user.userId === userId)),
15411
15578
  cachedAt,
15412
15579
  };
15413
15580
  };
@@ -15459,7 +15626,7 @@ const flagUser = async (userId, options) => {
15459
15626
  ingestInCache(payload);
15460
15627
  }
15461
15628
  fireEvent('user.flagged', data);
15462
- return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
15629
+ return userLinkedObject((_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0]);
15463
15630
  };
15464
15631
  /* end_public_function */
15465
15632
 
@@ -15480,13 +15647,14 @@ const submitUserReport = async (apiName, userId, body) => {
15480
15647
  ingestInCache(payload);
15481
15648
  }
15482
15649
  fireEvent('user.flagged', data);
15483
- return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
15650
+ return userLinkedObject((_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0]);
15484
15651
  };
15485
15652
 
15486
15653
  /** Maximum `comment` length, in string length units, after trimming. */
15487
15654
  const USER_REPORT_COMMENT_MAX_LENGTH = 300;
15488
15655
  const PROFILE_FIELDS = Object.values(exports.UserProfileFieldEnum);
15489
15656
  const BEHAVIOR_REASONS = Object.values(exports.ContentFlagReasonEnum);
15657
+ const REPORT_TYPE_FILTERS = Object.values(exports.UserReportTypeFilterEnum);
15490
15658
  const assertOptionsObject = (apiName, options, shape) => {
15491
15659
  if (typeof options !== 'object' || options === null || Array.isArray(options)) {
15492
15660
  throw new ASCInvalidParameterError(`${apiName}: expected an options object \`${shape}\``);
@@ -15546,6 +15714,28 @@ const toUserBehaviorReportBody = (options) => {
15546
15714
  }
15547
15715
  return withComment({ reportType: 'behavior', reason }, normalizeUserReportComment(apiName, comment));
15548
15716
  };
15717
+ /**
15718
+ * Validates the optional `{ reportType? }` of `unflagUser` and builds its query parameters.
15719
+ * Returns `undefined` when no `reportType` is given, so the request carries no query string
15720
+ * and withdraws every report the caller filed on the user. The server validates the value
15721
+ * too (422); this local check only saves the round-trip for the string alias, which admits
15722
+ * raw strings. Untyped callers can pass anything at runtime, so nothing is trusted from the
15723
+ * declared type.
15724
+ *
15725
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed or `reportType` is unknown
15726
+ */
15727
+ const toUserReportTypeFilter = (options) => {
15728
+ if (options === undefined)
15729
+ return undefined;
15730
+ const apiName = 'unflagUser';
15731
+ const { reportType } = assertOptionsObject(apiName, options, '{ reportType? }');
15732
+ if (reportType === undefined)
15733
+ return undefined;
15734
+ if (typeof reportType !== 'string' || !REPORT_TYPE_FILTERS.includes(reportType)) {
15735
+ throw new ASCInvalidParameterError(`${apiName}: \`reportType\` must be a \`UserReportTypeFilterEnum\` value`);
15736
+ }
15737
+ return { reportType: reportType };
15738
+ };
15549
15739
 
15550
15740
  /* begin_public_function
15551
15741
  id: user.flag_profile
@@ -15618,20 +15808,46 @@ const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBe
15618
15808
  */
15619
15809
  /**
15620
15810
  * ```js
15621
- * import { UserRepository } from '@amityco/ts-sdk'
15622
- * const unflagged = await UserRepository.unflagUser('post', postId)
15811
+ * import { UserRepository, UserReportTypeFilterEnum } from '@amityco/ts-sdk'
15812
+ *
15813
+ * // Withdraw every report I filed on the user.
15814
+ * const unflagged = await UserRepository.unflagUser('userId')
15815
+ *
15816
+ * // Withdraw only my behavior report; my other reports on the user stay.
15817
+ * await UserRepository.unflagUser('userId', { reportType: UserReportTypeFilterEnum.BEHAVIOR })
15818
+ *
15819
+ * // Withdraw only my typeless (legacy) report.
15820
+ * await UserRepository.unflagUser('userId', { reportType: UserReportTypeFilterEnum.UNTYPED })
15623
15821
  * ```
15624
15822
  *
15823
+ * Withdraws the caller's reports on a user. Without `reportType` every report the caller
15824
+ * filed on that user is withdrawn, as before. With `reportType` only the caller's report
15825
+ * of that type is withdrawn; the caller's other reports and other users' reports are
15826
+ * untouched. Withdrawing a report that does not exist succeeds and changes nothing.
15827
+ *
15828
+ * The returned user is persisted to the cache, so its `hashFlag` says whether the caller
15829
+ * still holds any report on the user. Do not flip a local "flagged by me" flag to `false`
15830
+ * after a per-type withdrawal; read the fresh user, or call `isUserFlaggedByMe` for the
15831
+ * remaining per-type state (`flags`).
15832
+ *
15833
+ * Sends `DELETE /api/v4/me/flags/:userId`, with `?reportType=<type>` when one is given.
15834
+ *
15625
15835
  * @param userId The ID of the user to unflag
15626
- * @returns the deleted report result
15836
+ * @param options Optional; `reportType` selects a single report to withdraw. For a report that `isUserFlaggedByMe` lists with `reportType: null`, pass `UserReportTypeFilterEnum.UNTYPED`
15837
+ * @returns `true` once the server has processed the withdrawal
15838
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `reportType` is not a `UserReportTypeFilterEnum` value, before any request is made
15627
15839
  *
15628
15840
  * @category User API
15629
15841
  * @async
15630
15842
  * */
15631
- const unflagUser = async (userId) => {
15632
- const client = getActiveClient();
15633
- client.log('user/unflag', userId);
15634
- const { data } = await client.http.delete(`/api/v4/me/flags/${encodeURIComponent(userId)}`);
15843
+ const unflagUser = async (userId, options) => {
15844
+ const client = getActiveClient();
15845
+ client.log('user/unflag', { userId, options });
15846
+ const params = toUserReportTypeFilter(options);
15847
+ const url = `/api/v4/me/flags/${encodeURIComponent(userId)}`;
15848
+ const { data } = params
15849
+ ? await client.http.delete(url, { params })
15850
+ : await client.http.delete(url);
15635
15851
  const payload = prepareUserPayload(data);
15636
15852
  if (client.cache) {
15637
15853
  ingestInCache(payload);
@@ -15647,11 +15863,33 @@ const unflagUser = async (userId) => {
15647
15863
  /**
15648
15864
  * ```js
15649
15865
  * import { UserRepository } from '@amityco/ts-sdk'
15650
- * const isFlagged = await UserRepository.isUserFlaggedByMe(postId)
15866
+ *
15867
+ * const { isFlagByMe, flags } = await UserRepository.isUserFlaggedByMe('userId')
15868
+ *
15869
+ * // Grey out the report options already used; null marks the typeless report.
15870
+ * const used = new Set(flags.map(flag => flag.reportType))
15651
15871
  * ```
15652
15872
  *
15653
- * @param userId The ID of the thing to check a report to.
15654
- * @returns `true` if the report is created by me, `false` if doesn't.
15873
+ * Returns whether the caller has reported a user, with each of the caller's own reports
15874
+ * on that user, exactly as `GET /api/v4/users/:userId/isFlagByMe` answers. Each report
15875
+ * carries `reportType`, `reason`, `comment` and `createdAt`; a field the report does not
15876
+ * have is `null`. `reportType: null` is the typeless (legacy) report, which `unflagUser`
15877
+ * withdraws with `UserReportTypeFilterEnum.UNTYPED`. Only the caller's reports come back.
15878
+ *
15879
+ * This is the only source of per-type state. Nothing is filtered, cached or persisted:
15880
+ * the call reads the server every time and does not consult `hashFlag`, which is a
15881
+ * type-blind bloom filter. Call it again after a flag or unflag when the UI needs the
15882
+ * updated per-type state.
15883
+ *
15884
+ * Breaking change: earlier versions returned a boolean from the v3 endpoint, which the
15885
+ * backend has deprecated. Read `isFlagByMe` on the result for the same answer.
15886
+ *
15887
+ * @deprecated On an {@link Amity.User} you already hold, read `user.isFlaggedByMe` for a
15888
+ * request-free badge and call `user.getUserFlagsByMe()` for the reports; it skips the request
15889
+ * when the Bloom test says the user is not flagged. This function remains the underlying request.
15890
+ *
15891
+ * @param userId The ID of the user to check
15892
+ * @returns the caller's {@link Amity.UserFlagByMe} on that user
15655
15893
  *
15656
15894
  * @category Report API
15657
15895
  * @async
@@ -15659,8 +15897,7 @@ const unflagUser = async (userId) => {
15659
15897
  const isUserFlaggedByMe = async (userId) => {
15660
15898
  const client = getActiveClient();
15661
15899
  client.log('user/isUserFlaggedByMe', userId);
15662
- const { data: { isFlagByMe }, } = await client.http.get(`/api/v3/users/${userId}/isFlagByMe`);
15663
- return isFlagByMe;
15900
+ return getFlagsByMe(userId);
15664
15901
  };
15665
15902
  /* end_public_function */
15666
15903
 
@@ -15910,16 +16147,14 @@ const getUser = (userId, callback) => {
15910
16147
  };
15911
16148
  /* end_public_function */
15912
16149
 
15913
- class UserPaginationController extends PaginationController {
15914
- async getRequest(queryParams, token) {
15915
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
15916
- const options = token ? { token } : { limit };
15917
- const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
15918
- params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
15919
- });
15920
- return queryResponse;
15921
- }
15922
- }
16150
+ var EnumUserActions;
16151
+ (function (EnumUserActions) {
16152
+ EnumUserActions["OnUserDeleted"] = "onUserDeleted";
16153
+ EnumUserActions["OnUserUpdated"] = "onUserUpdated";
16154
+ EnumUserActions["OnUserFlagged"] = "onUserFlagged";
16155
+ EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
16156
+ EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
16157
+ })(EnumUserActions || (EnumUserActions = {}));
15923
16158
 
15924
16159
  class UserQueryStreamController extends QueryStreamController {
15925
16160
  constructor(query, cacheKey, notifyChange, preparePayload) {
@@ -15967,14 +16202,16 @@ class UserQueryStreamController extends QueryStreamController {
15967
16202
  }
15968
16203
  }
15969
16204
 
15970
- var EnumUserActions;
15971
- (function (EnumUserActions) {
15972
- EnumUserActions["OnUserDeleted"] = "onUserDeleted";
15973
- EnumUserActions["OnUserUpdated"] = "onUserUpdated";
15974
- EnumUserActions["OnUserFlagged"] = "onUserFlagged";
15975
- EnumUserActions["OnUserUnflagged"] = "onUserUnflagged";
15976
- EnumUserActions["OnUserFlagCleared"] = "onUserFlagCleared";
15977
- })(EnumUserActions || (EnumUserActions = {}));
16205
+ class UserPaginationController extends PaginationController {
16206
+ async getRequest(queryParams, token) {
16207
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
16208
+ const options = token ? { token } : { limit };
16209
+ const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
16210
+ params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
16211
+ });
16212
+ return queryResponse;
16213
+ }
16214
+ }
15978
16215
 
15979
16216
  class UserLiveCollectionController extends LiveCollectionController {
15980
16217
  constructor(query, callback) {
@@ -16091,16 +16328,17 @@ const getUsers = (params, callback, config) => {
16091
16328
  };
16092
16329
  /* end_public_function */
16093
16330
 
16094
- class BlockedUserPaginationController extends PaginationController {
16095
- async getRequest(queryParams, token) {
16096
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
16097
- const options = token ? { token } : { limit };
16098
- const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
16099
- params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
16100
- });
16101
- return queryResponse;
16331
+ const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
16332
+ var _a;
16333
+ if (!sourceModel) {
16334
+ return sourceModel;
16102
16335
  }
16103
- }
16336
+ const cacheKey = [destinationDomain, 'get', `${sourceModel[sourceModelProp]}`];
16337
+ const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
16338
+ if (!model)
16339
+ return;
16340
+ return callback(model);
16341
+ });
16104
16342
 
16105
16343
  var EnumBlockActions;
16106
16344
  (function (EnumBlockActions) {
@@ -16156,17 +16394,16 @@ class BlockedUserQueryStreamController extends QueryStreamController {
16156
16394
  }
16157
16395
  }
16158
16396
 
16159
- const convertEventPayload = (eventHandler, sourceModelProp, destinationDomain) => (callback) => eventHandler(sourceModel => {
16160
- var _a;
16161
- if (!sourceModel) {
16162
- return sourceModel;
16397
+ class BlockedUserPaginationController extends PaginationController {
16398
+ async getRequest(queryParams, token) {
16399
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
16400
+ const options = token ? { token } : { limit };
16401
+ const { data: queryResponse } = await this.http.get('/api/v4/me/user-blocks', {
16402
+ params: Object.assign(Object.assign({}, params), { options, isDeleted: false }),
16403
+ });
16404
+ return queryResponse;
16163
16405
  }
16164
- const cacheKey = [destinationDomain, 'get', `${sourceModel[sourceModelProp]}`];
16165
- const model = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
16166
- if (!model)
16167
- return;
16168
- return callback(model);
16169
- });
16406
+ }
16170
16407
 
16171
16408
  class BlockedUserLiveCollectionController extends LiveCollectionController {
16172
16409
  constructor(query, callback) {
@@ -16476,17 +16713,6 @@ const getBlockingUsers = (callback) => {
16476
16713
  };
16477
16714
  /* end_public_function */
16478
16715
 
16479
- class SearchUserPaginationController extends PaginationController {
16480
- async getRequest(queryParams, token) {
16481
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
16482
- const options = token ? { token } : { limit };
16483
- const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
16484
- params: Object.assign(Object.assign({}, params), { keyword: displayName, options, isDeleted: false }),
16485
- });
16486
- return queryResponse;
16487
- }
16488
- }
16489
-
16490
16716
  class SearchUserQueryStreamController extends QueryStreamController {
16491
16717
  constructor(query, cacheKey, notifyChange, preparePayload) {
16492
16718
  super(query, cacheKey);
@@ -16533,6 +16759,17 @@ class SearchUserQueryStreamController extends QueryStreamController {
16533
16759
  }
16534
16760
  }
16535
16761
 
16762
+ class SearchUserPaginationController extends PaginationController {
16763
+ async getRequest(queryParams, token) {
16764
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, displayName } = queryParams, params = __rest(queryParams, ["limit", "displayName"]);
16765
+ const options = token ? { token } : { limit };
16766
+ const { data: queryResponse } = await this.http.get(`/api/v3/users`, {
16767
+ params: Object.assign(Object.assign({}, params), { keyword: displayName, options, isDeleted: false }),
16768
+ });
16769
+ return queryResponse;
16770
+ }
16771
+ }
16772
+
16536
16773
  class SearchUserLiveCollectionController extends LiveCollectionController {
16537
16774
  constructor(query, callback) {
16538
16775
  var _a;
@@ -19210,7 +19447,8 @@ const getPostReport = async ({ client, referenceId, }) => {
19210
19447
  };
19211
19448
  const getUserReport = async ({ client, referenceId, }) => {
19212
19449
  var _a;
19213
- const { data } = await client.http.get(`/api/v3/users/${referenceId}/isflagbyme`);
19450
+ // v3 isFlagByMe is deprecated by the backend; v4 answers the same boolean plus the caller's flags.
19451
+ const { data } = await client.http.get(`/api/v4/users/${encodeURIComponent(referenceId)}/isFlagByMe`);
19214
19452
  const { result, isFlagByMe } = data !== null && data !== void 0 ? data : {};
19215
19453
  return (_a = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _a !== void 0 ? _a : false;
19216
19454
  };