@amityco/ts-sdk 7.29.1-e932a95f.0 → 7.30.1-729b252.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 (43) hide show
  1. package/dist/@types/core/events.d.ts +4 -0
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/domains/client.d.ts +2 -1
  4. package/dist/@types/domains/client.d.ts.map +1 -1
  5. package/dist/@types/domains/content.d.ts +6 -0
  6. package/dist/@types/domains/content.d.ts.map +1 -1
  7. package/dist/@types/domains/user.d.ts +16 -10
  8. package/dist/@types/domains/user.d.ts.map +1 -1
  9. package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
  10. package/dist/client/utils/autoSubscriptionManager.d.ts.map +1 -1
  11. package/dist/core/events.d.ts +3 -3
  12. package/dist/core/events.d.ts.map +1 -1
  13. package/dist/index.cjs.js +450 -138
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.esm.js +448 -139
  17. package/dist/index.umd.js +2 -2
  18. package/dist/userRepository/api/flagUser.d.ts.map +1 -1
  19. package/dist/userRepository/api/flagUserBehavior.d.ts +1 -1
  20. package/dist/userRepository/api/isUserFlaggedByMe.d.ts +9 -23
  21. package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
  22. package/dist/userRepository/api/unflagUser.d.ts +5 -4
  23. package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
  24. package/dist/userRepository/internalApi/getFlagsByMe.d.ts +4 -3
  25. package/dist/userRepository/internalApi/getFlagsByMe.d.ts.map +1 -1
  26. package/dist/userRepository/internalApi/tests/getFlagsByMe.test.d.ts +2 -0
  27. package/dist/userRepository/internalApi/tests/getFlagsByMe.test.d.ts.map +1 -0
  28. package/dist/userRepository/observers/getUser.d.ts.map +1 -1
  29. package/dist/userRepository/observers/getUsers/UserLiveCollectionController.d.ts.map +1 -1
  30. package/dist/userRepository/observers/searchUserByDisplayName/SearchUserLiveCollectionController.d.ts.map +1 -1
  31. package/dist/userRepository/utils/submitUserReport.d.ts.map +1 -1
  32. package/dist/userRepository/utils/userFlagByMe.d.ts +68 -0
  33. package/dist/userRepository/utils/userFlagByMe.d.ts.map +1 -0
  34. package/dist/userRepository/utils/userReport.d.ts +1 -1
  35. package/dist/utils/bloomFilter.d.ts +8 -3
  36. package/dist/utils/bloomFilter.d.ts.map +1 -1
  37. package/dist/utils/contentFlag.d.ts +1 -1
  38. package/dist/utils/contentFlagReason.d.ts +32 -0
  39. package/dist/utils/contentFlagReason.d.ts.map +1 -0
  40. package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -1
  41. package/dist/utils/tests/contentFlagReason.test.d.ts +2 -0
  42. package/dist/utils/tests/contentFlagReason.test.d.ts.map +1 -0
  43. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -21,6 +21,7 @@ var AmityAutoSubscription;
21
21
  AmityAutoSubscription["NETWORK"] = "network";
22
22
  AmityAutoSubscription["LIVESTREAM"] = "livestream";
23
23
  AmityAutoSubscription["BLOCK"] = "block";
24
+ AmityAutoSubscription["USER"] = "user";
24
25
  })(AmityAutoSubscription || (AmityAutoSubscription = {}));
25
26
 
26
27
  var UserTypeEnum;
@@ -58,7 +59,7 @@ var UserProfileFieldEnum;
58
59
  * Selects which of the caller's reports `UserRepository.unflagUser` withdraws, sent as the
59
60
  * `reportType` query parameter. The four typed members are the backend `reportType` wire
60
61
  * values and match `UserReportTypeEnum`. `UNTYPED` selects the typeless (legacy) report,
61
- * which `isUserFlaggedByMe` returns as `reportType: null`; it is a selector only, never
62
+ * which `user.getUserFlagsByMe()` returns as `reportType: null`; it is a selector only, never
62
63
  * stored, and the flag endpoint refuses it.
63
64
  */
64
65
  var UserReportTypeFilterEnum;
@@ -145,6 +146,7 @@ const ContentFeedType = Object.freeze({
145
146
  var ContentFlagReasonEnum;
146
147
  (function (ContentFlagReasonEnum) {
147
148
  ContentFlagReasonEnum["CommunityGuidelines"] = "Against community guidelines";
149
+ ContentFlagReasonEnum["ChildEndangerment"] = "Child endangerment";
148
150
  ContentFlagReasonEnum["HarassmentOrBullying"] = "Harassment or bullying";
149
151
  ContentFlagReasonEnum["SelfHarmOrSuicide"] = "Self-harm or suicide";
150
152
  ContentFlagReasonEnum["ViolenceOrThreateningContent"] = "Violence or threatening content";
@@ -343,8 +345,8 @@ var AmityLiveViewerCountMode;
343
345
 
344
346
  function getVersion() {
345
347
  try {
346
- // the string ''v7.29.0-esm'' should be replaced by actual value by @rollup/plugin-replace
347
- return 'v7.29.0-esm';
348
+ // the string ''v7.30.0-esm'' should be replaced by actual value by @rollup/plugin-replace
349
+ return 'v7.30.0-esm';
348
350
  }
349
351
  catch (error) {
350
352
  return '__dev__';
@@ -1836,15 +1838,64 @@ async function modifyMqttConnection() {
1836
1838
  }
1837
1839
  }
1838
1840
 
1841
+ class SessionWatcher {
1842
+ constructor() {
1843
+ this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
1844
+ this._listener = new Map();
1845
+ }
1846
+ onSessionStateChange(callback) {
1847
+ this._listener.set(callback, callback);
1848
+ return () => {
1849
+ this._listener.delete(callback);
1850
+ };
1851
+ }
1852
+ setSessionState(state, reason) {
1853
+ if (this._sessionState === state)
1854
+ return;
1855
+ this._sessionState = state;
1856
+ this._listener.forEach(cb => cb(state, reason));
1857
+ }
1858
+ destroy() {
1859
+ this._listener.clear();
1860
+ }
1861
+ }
1862
+ let instance$b;
1863
+ var SessionWatcher$1 = {
1864
+ getInstance: () => {
1865
+ if (!instance$b) {
1866
+ instance$b = new SessionWatcher();
1867
+ }
1868
+ return instance$b;
1869
+ },
1870
+ };
1871
+
1872
+ /**
1873
+ * ```js
1874
+ * import { onSessionStateChange } from '@amityco/ts-sdk'
1875
+ * const dispose = onSessionStateChange((state: Amity.SessionStates) => {
1876
+ * // ...
1877
+ * })
1878
+ * ```
1879
+ *
1880
+ * Fired when any {@link Amity.Client} has a session state change
1881
+ *
1882
+ * @param callback The function to call when the event was fired
1883
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
1884
+ *
1885
+ * @category Client Events
1886
+ */
1887
+ const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
1888
+
1839
1889
  /**
1840
1890
  * ```js
1841
1891
  * import { getFlagsByMe } from '~/userRepository/internalApi/getFlagsByMe'
1842
1892
  * const { isFlagByMe, flags } = await getFlagsByMe('userId')
1843
1893
  * ```
1844
1894
  *
1845
- * The v4 read behind `user.getUserFlagsByMe()` and the deprecated
1846
- * `UserRepository.isUserFlaggedByMe`: `GET /api/v4/users/:userId/isFlagByMe`, returned as
1847
- * received. Nothing is filtered, cached or persisted, and `hashFlag` is not consulted here.
1895
+ * The v4 read behind `user.getUserFlagsByMe()`, the background confirm of
1896
+ * `user.isFlaggedByMe`, and the deprecated `UserRepository.isUserFlaggedByMe`:
1897
+ * `GET /api/v4/users/:userId/isFlagByMe`, returned as received. Nothing is filtered, cached or
1898
+ * persisted here, and `hashFlag` is not consulted.
1848
1899
  * This is the Web counterpart of iOS `ASCUserService.getFlagsByMe` and Android
1849
1900
  * `UserRepository.getFlagsByMe`, kept apart from the deprecated public function so the
1850
1901
  * user-object read does not change if that function ever does.
@@ -1905,35 +1956,72 @@ const locationsFor = (value, bits, hashes) => {
1905
1956
  }
1906
1957
  return locations;
1907
1958
  };
1959
+ /** Standard or URL-safe base64, padding optional. Anything else is not a filter we can read. */
1960
+ const BASE64 = /^[A-Za-z0-9+/_-]*={0,2}$/;
1908
1961
  /**
1909
- * Whether `value` is probably in the filter. `false` is exact; `true` may be a false positive.
1910
- * A missing filter (`null`, the server's value when nobody has flagged the object), a missing
1911
- * value or a malformed filter all answer `false`.
1962
+ * Whether `value` is probably in the filter. `false` is exact; `true` means "maybe", which may be
1963
+ * a false positive. `null` (the server's value when nobody has flagged the object), a missing
1964
+ * filter or a missing value answer `false`.
1965
+ *
1966
+ * A filter that cannot be read answers `true` ("maybe") and never throws, so the caller asks the
1967
+ * server instead of trusting a "definitely not" it cannot back up (REQ-017): `bits` or `hashes`
1968
+ * not a positive integer, a `hash` that is not base64, or a `hash` shorter than `ceil(bits / 8)`
1969
+ * bytes.
1912
1970
  */
1913
1971
  const testBloomFilter = (hashFlag, value) => {
1914
1972
  if (!hashFlag || !value)
1915
1973
  return false;
1916
1974
  const { bits, hashes, hash } = hashFlag;
1917
- if (!(bits > 0) || !(hashes > 0) || typeof hash !== 'string')
1918
- return false;
1975
+ if (!Number.isInteger(bits) || bits <= 0)
1976
+ return true;
1977
+ if (!Number.isInteger(hashes) || hashes <= 0)
1978
+ return true;
1979
+ if (typeof hash !== 'string' || !BASE64.test(hash))
1980
+ return true;
1919
1981
  let buckets;
1920
1982
  try {
1921
1983
  buckets = toUint8Array(hash);
1922
1984
  }
1923
1985
  catch (_a) {
1924
- return false;
1986
+ return true;
1925
1987
  }
1988
+ if (buckets.length < Math.ceil(bits / 8))
1989
+ return true;
1926
1990
  const locations = locationsFor(value, bits, hashes);
1927
1991
  for (let i = 0; i < locations.length; i += 1) {
1928
1992
  const index = Math.floor(locations[i] / 8);
1929
1993
  const bit = 1 << locations[i] % 8;
1930
- if (index >= buckets.length || (buckets[index] & bit) === 0)
1994
+ if ((buckets[index] & bit) === 0)
1931
1995
  return false;
1932
1996
  }
1933
1997
  return true;
1934
1998
  };
1935
1999
 
1936
- /** The current user's id, or `undefined` when there is no active client (the getter never throws). */
2000
+ /**
2001
+ * Flag state of the current user on a target user, behind `Amity.User.isFlaggedByMe` and
2002
+ * `Amity.User.getUserFlagsByMe()` (`user.check_flag_by_me` v1, REQ-011, REQ-012, REQ-016).
2003
+ *
2004
+ * `hashFlag` is a Bloom filter of reporter ids. "Definitely not" is exact. "Maybe" can be a
2005
+ * false positive caused by other reporters, so the SDK confirms it with the server once per
2006
+ * `hashFlag` value and records the answer in the cache under its own key, never on the user's
2007
+ * cache row (REQ-015). Observers are told through `local.user.flagConfirmed` when a recorded
2008
+ * answer changes what a user object would show.
2009
+ *
2010
+ * Not exported from the public API.
2011
+ */
2012
+ /** Confirms for the same user are at least this far apart, as Android's `EkoFlag.expired`. */
2013
+ const FLAG_CONFIRM_INTERVAL = 1000;
2014
+ const cacheKey = (userId) => ['userFlagByMe', 'get', userId];
2015
+ const lastConfirmAt = new Map();
2016
+ /**
2017
+ * Bumped by the current user's own flag and unflag. A confirm or exact read that started before
2018
+ * one of them must not record its answer, because the write may have changed it while the
2019
+ * `hashFlag` stayed the same.
2020
+ */
2021
+ const generations = new Map();
2022
+ const generationOf = (userId) => { var _a; return (_a = generations.get(userId)) !== null && _a !== void 0 ? _a : 0; };
2023
+ const bumpGeneration = (userId) => generations.set(userId, generationOf(userId) + 1);
2024
+ /** The current user's id, or `undefined` when there is no active client. Never throws. */
1937
2025
  const currentUserId = () => {
1938
2026
  try {
1939
2027
  return getActiveClient().userId;
@@ -1942,43 +2030,223 @@ const currentUserId = () => {
1942
2030
  return undefined;
1943
2031
  }
1944
2032
  };
2033
+ const readRecord = (userId) => {
2034
+ var _a;
2035
+ try {
2036
+ return (_a = pullFromCache(cacheKey(userId))) === null || _a === void 0 ? void 0 : _a.data;
2037
+ }
2038
+ catch (_b) {
2039
+ return undefined;
2040
+ }
2041
+ };
1945
2042
  /**
1946
- * One `getUserFlagsByMe` closure per userId, remembering the newest user object linked for
1947
- * that id. Live objects and collections compare snapshots with `isEqual`, which compares
1948
- * functions by reference: a fresh closure on every linked object would make two reads of the
1949
- * same user unequal and re-dispatch snapshots that did not change.
2043
+ * The server's answer recorded for this user and this exact `hashFlag`, or `undefined` when there
2044
+ * is none for the current user. Never throws.
1950
2045
  */
1951
- const flagsByMeEntries = new Map();
2046
+ const readConfirmedFlag = (userId, hashFlag) => {
2047
+ const me = currentUserId();
2048
+ if (!me || !hashFlag || typeof hashFlag.hash !== 'string')
2049
+ return undefined;
2050
+ const record = readRecord(userId);
2051
+ if (!record || record.reporterId !== me || record.hash !== hashFlag.hash)
2052
+ return undefined;
2053
+ return record.isFlagByMe;
2054
+ };
1952
2055
  /**
1953
- * A Bloom filter has no false negatives, so `isFlaggedByMe === false` is exact and the request
1954
- * can be skipped (REQ-012). The newest user object linked for that id is tested, as of its last
1955
- * update. Without a filter to test, or without a current user, the server is asked.
2056
+ * The v4 request in flight per user, with the generation it started in. A confirm and an exact
2057
+ * read of the same user share one request; a request that started before the current user's own
2058
+ * flag or unflag is not joined.
1956
2059
  */
1957
- const knownNotFlaggedByMe = (userId) => {
2060
+ const inFlight = new Map();
2061
+ const requestFlagsByMe = (userId) => {
2062
+ const generation = generationOf(userId);
2063
+ const pending = inFlight.get(userId);
2064
+ if (pending && pending.generation === generation)
2065
+ return pending.promise;
2066
+ const promise = getFlagsByMe(userId).finally(() => {
2067
+ var _a;
2068
+ if (((_a = inFlight.get(userId)) === null || _a === void 0 ? void 0 : _a.promise) === promise)
2069
+ inFlight.delete(userId);
2070
+ });
2071
+ inFlight.set(userId, { generation, promise });
2072
+ return promise;
2073
+ };
2074
+ const notifyObservers = (userId) => fireEvent('local.user.flagConfirmed', { userId });
2075
+ /**
2076
+ * Records `isFlagByMe` for `hashFlag`. A "maybe" without a record shows `true`, so observers are
2077
+ * told only when the shown value changes.
2078
+ */
2079
+ const recordFlag = (userId, hashFlag, isFlagByMe) => {
1958
2080
  var _a;
1959
2081
  const me = currentUserId();
1960
- const user = (_a = flagsByMeEntries.get(userId)) === null || _a === void 0 ? void 0 : _a.latest;
1961
- if (!me || !user || user.hashFlag === undefined)
2082
+ if (!me || typeof hashFlag.hash !== 'string')
2083
+ return;
2084
+ const shown = (_a = readConfirmedFlag(userId, hashFlag)) !== null && _a !== void 0 ? _a : true;
2085
+ const record = { reporterId: me, hash: hashFlag.hash, isFlagByMe };
2086
+ pushToCache(cacheKey(userId), record);
2087
+ if (shown !== isFlagByMe)
2088
+ notifyObservers(userId);
2089
+ };
2090
+ /**
2091
+ * Starts one background confirm of a "maybe" (REQ-016): at most one in flight per user, and
2092
+ * confirms for the same user at least {@link FLAG_CONFIRM_INTERVAL} apart. A failed confirm
2093
+ * records nothing, surfaces no error, and a later read tries again.
2094
+ */
2095
+ const confirmFlagByMe = (userId, hashFlag) => {
2096
+ if (inFlight.has(userId))
2097
+ return;
2098
+ const now = Date.now();
2099
+ const last = lastConfirmAt.get(userId);
2100
+ if (last !== undefined && now - last < FLAG_CONFIRM_INTERVAL)
2101
+ return;
2102
+ const me = currentUserId();
2103
+ const generation = generationOf(userId);
2104
+ lastConfirmAt.set(userId, now);
2105
+ requestFlagsByMe(userId)
2106
+ .then(({ isFlagByMe }) => {
2107
+ if (currentUserId() !== me || generationOf(userId) !== generation)
2108
+ return;
2109
+ recordFlag(userId, hashFlag, isFlagByMe);
2110
+ })
2111
+ .catch(() => {
2112
+ // Not an answer: isFlaggedByMe stays true until a later read confirms again.
2113
+ });
2114
+ };
2115
+ /**
2116
+ * The value of `Amity.User.isFlaggedByMe` for a user object whose confirmed answer was captured
2117
+ * (`confirmed`) when the object was linked, so a held object never changes (REQ-014).
2118
+ *
2119
+ * - No current user, `hashFlag: null` or a missing `hashFlag`, or "definitely not": `false`.
2120
+ * - "Maybe" with a confirmed answer: that answer, no request.
2121
+ * - "Maybe" without one: `true`, and one background confirm (REQ-016).
2122
+ *
2123
+ * The linked object declares this as a getter inside an object spread, which the build compiles
2124
+ * to `Object.assign`, so it runs once when the user is linked and the object keeps that value.
2125
+ */
2126
+ const isFlaggedByMeFor = (user, confirmed) => {
2127
+ const me = currentUserId();
2128
+ if (!me || !user.hashFlag || !testBloomFilter(user.hashFlag, me))
1962
2129
  return false;
1963
- return !testBloomFilter(user.hashFlag, me);
2130
+ if (confirmed !== undefined)
2131
+ return confirmed;
2132
+ confirmFlagByMe(user.userId, user.hashFlag);
2133
+ return true;
2134
+ };
2135
+ const NOT_FLAGGED = { isFlagByMe: false, flags: [] };
2136
+ const isNotOlder = (next, current) => {
2137
+ var _a, _b;
2138
+ const nextAt = Date.parse((_a = next.updatedAt) !== null && _a !== void 0 ? _a : '');
2139
+ const currentAt = Date.parse((_b = current.updatedAt) !== null && _b !== void 0 ? _b : '');
2140
+ return Number.isNaN(nextAt) || Number.isNaN(currentAt) || nextAt >= currentAt;
2141
+ };
2142
+ /**
2143
+ * One `getUserFlagsByMe` closure per userId, remembering the newest user object linked for that
2144
+ * id. Live objects and collections compare snapshots with `isEqual`, which compares functions by
2145
+ * reference, so a fresh closure per linked object would re-dispatch unchanged snapshots
2146
+ * (REQ-015). An older snapshot linked later does not replace a newer one.
2147
+ */
2148
+ const flagsByMeEntries = new Map();
2149
+ /**
2150
+ * `Amity.User.getUserFlagsByMe()` (REQ-012): `{ isFlagByMe: false, flags: [] }` with no request
2151
+ * when the newest linked user says "not flagged", including a confirmed `false`. Otherwise the
2152
+ * v4 read, returned as is; a confirm already in flight for the user is joined instead of sending
2153
+ * a second request. Its `isFlagByMe` is recorded as the confirmed answer for the
2154
+ * `hashFlag` it was read for; `flags[]` is never stored (REQ-009). A missing `hashFlag` is
2155
+ * unknown, so the server is asked.
2156
+ */
2157
+ const readFlagsByMe = async (userId) => {
2158
+ var _a, _b;
2159
+ const me = currentUserId();
2160
+ const { hashFlag } = (_b = (_a = flagsByMeEntries.get(userId)) === null || _a === void 0 ? void 0 : _a.latest) !== null && _b !== void 0 ? _b : {};
2161
+ if (me && hashFlag !== undefined) {
2162
+ if (!hashFlag || !testBloomFilter(hashFlag, me))
2163
+ return Object.assign(Object.assign({}, NOT_FLAGGED), { flags: [] });
2164
+ if (readConfirmedFlag(userId, hashFlag) === false)
2165
+ return Object.assign(Object.assign({}, NOT_FLAGGED), { flags: [] });
2166
+ }
2167
+ const generation = generationOf(userId);
2168
+ const result = await requestFlagsByMe(userId);
2169
+ if (hashFlag && currentUserId() === me && generationOf(userId) === generation) {
2170
+ recordFlag(userId, hashFlag, result.isFlagByMe);
2171
+ }
2172
+ return result;
1964
2173
  };
1965
2174
  const getUserFlagsByMeFor = (user) => {
1966
2175
  let entry = flagsByMeEntries.get(user.userId);
1967
2176
  if (!entry) {
1968
- entry = {
1969
- latest: user,
1970
- getUserFlagsByMe: async () => {
1971
- if (knownNotFlaggedByMe(user.userId))
1972
- return { isFlagByMe: false, flags: [] };
1973
- return getFlagsByMe(user.userId);
1974
- },
1975
- };
2177
+ entry = { latest: user, getUserFlagsByMe: () => readFlagsByMe(user.userId) };
1976
2178
  flagsByMeEntries.set(user.userId, entry);
1977
2179
  }
1978
- entry.latest = user;
2180
+ else if (isNotOlder(user, entry.latest)) {
2181
+ entry.latest = user;
2182
+ }
1979
2183
  return entry.getUserFlagsByMe;
1980
2184
  };
2185
+ /**
2186
+ * The current user's own flag succeeded (REQ-016). Their report may leave `hashFlag` unchanged
2187
+ * when other reporters had already set all of their bits, so the answer is known: record `true`
2188
+ * for the `hashFlag` the response carries, or drop the answer when it carries none.
2189
+ */
2190
+ const onFlaggedByMe = (user, userId) => {
2191
+ bumpGeneration(userId);
2192
+ if (user === null || user === void 0 ? void 0 : user.hashFlag) {
2193
+ recordFlag(userId, user.hashFlag, true);
2194
+ return;
2195
+ }
2196
+ const dropped = readRecord(userId);
2197
+ dropFromCache(cacheKey(userId), true);
2198
+ if ((dropped === null || dropped === void 0 ? void 0 : dropped.isFlagByMe) === false)
2199
+ notifyObservers(userId);
2200
+ };
2201
+ /**
2202
+ * The current user's own unflag succeeded (`user.unflag` REQ-010, REQ-016). A per-type unflag can
2203
+ * leave other reports in place, so the answer is dropped, never set to `false`; the next "maybe"
2204
+ * is confirmed again.
2205
+ */
2206
+ const onUnflaggedByMe = (userId) => {
2207
+ bumpGeneration(userId);
2208
+ const dropped = readRecord(userId);
2209
+ dropFromCache(cacheKey(userId), true);
2210
+ if ((dropped === null || dropped === void 0 ? void 0 : dropped.isFlagByMe) === false)
2211
+ notifyObservers(userId);
2212
+ };
2213
+ /** Forgets every in-memory trace of the current user's flag state. Records live in the cache. */
2214
+ const resetUserFlagByMe = () => {
2215
+ flagsByMeEntries.clear();
2216
+ inFlight.clear();
2217
+ lastConfirmAt.clear();
2218
+ generations.clear();
2219
+ };
2220
+ /**
2221
+ * Registered through `setupLoginSubscriptions`. Every confirmed answer belongs to the current
2222
+ * user, so the state is cleared on logout; the records themselves go with the cache, and each
2223
+ * also carries the reporter's id.
2224
+ */
2225
+ const userFlagByMeOnLoginHandler = () => {
2226
+ const unsubscribe = onSessionStateChange(state => {
2227
+ if (state === "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */ || state === "terminated" /* Amity.SessionStates.TERMINATED */) {
2228
+ resetUserFlagByMe();
2229
+ }
2230
+ });
2231
+ return () => {
2232
+ unsubscribe();
2233
+ resetUserFlagByMe();
2234
+ };
2235
+ };
2236
+ /**
2237
+ * Called with the cached user when a recorded answer changes what that user would show, so live
2238
+ * objects and live collections deliver it again (REQ-016, delivery).
2239
+ */
2240
+ const onUserFlagConfirmed = (callback) => createEventSubscriber(getActiveClient(), 'user/onUserFlagConfirmed', 'local.user.flagConfirmed', ({ userId }) => {
2241
+ var _a;
2242
+ const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
2243
+ if (user)
2244
+ callback(user);
2245
+ });
2246
+
1981
2247
  const userLinkedObject = (user) => {
2248
+ // Captured now, so a user object the app holds never changes after a confirm (REQ-014).
2249
+ const confirmedFlagByMe = readConfirmedFlag(user.userId, user.hashFlag);
1982
2250
  return Object.assign(Object.assign({}, user), { get avatar() {
1983
2251
  var _a;
1984
2252
  if (!user.avatarFileId)
@@ -1989,9 +2257,10 @@ const userLinkedObject = (user) => {
1989
2257
  return avatar;
1990
2258
  },
1991
2259
  get isFlaggedByMe() {
1992
- // Local Bloom-filter test on this object's own hashFlag: exact when false, "probably"
1993
- // when true, type-blind, no request. getUserFlagsByMe() gives the exact, per-type answer.
1994
- return testBloomFilter(user.hashFlag, currentUserId());
2260
+ // Bloom test on this object's hashFlag: "definitely not" is exact and sends nothing.
2261
+ // "Maybe" returns the answer confirmed for this hashFlag, or true while one background
2262
+ // confirm runs (REQ-011, REQ-016). Never throws.
2263
+ return isFlaggedByMeFor(user, confirmedFlagByMe);
1995
2264
  },
1996
2265
  /* begin_public_function
1997
2266
  id: user.get_flags_by_me
@@ -2263,13 +2532,13 @@ class NetworkActivitiesWatcher {
2263
2532
  this._listener.clear();
2264
2533
  }
2265
2534
  }
2266
- let instance$b;
2535
+ let instance$a;
2267
2536
  var NetworkActivitiesWatcher$1 = {
2268
2537
  getInstance: () => {
2269
- if (!instance$b) {
2270
- instance$b = new NetworkActivitiesWatcher();
2538
+ if (!instance$a) {
2539
+ instance$a = new NetworkActivitiesWatcher();
2271
2540
  }
2272
- return instance$b;
2541
+ return instance$a;
2273
2542
  },
2274
2543
  };
2275
2544
 
@@ -2453,54 +2722,6 @@ const createHttpTransport = (endpoint) => {
2453
2722
  return instance;
2454
2723
  };
2455
2724
 
2456
- class SessionWatcher {
2457
- constructor() {
2458
- this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
2459
- this._listener = new Map();
2460
- }
2461
- onSessionStateChange(callback) {
2462
- this._listener.set(callback, callback);
2463
- return () => {
2464
- this._listener.delete(callback);
2465
- };
2466
- }
2467
- setSessionState(state, reason) {
2468
- if (this._sessionState === state)
2469
- return;
2470
- this._sessionState = state;
2471
- this._listener.forEach(cb => cb(state, reason));
2472
- }
2473
- destroy() {
2474
- this._listener.clear();
2475
- }
2476
- }
2477
- let instance$a;
2478
- var SessionWatcher$1 = {
2479
- getInstance: () => {
2480
- if (!instance$a) {
2481
- instance$a = new SessionWatcher();
2482
- }
2483
- return instance$a;
2484
- },
2485
- };
2486
-
2487
- /**
2488
- * ```js
2489
- * import { onSessionStateChange } from '@amityco/ts-sdk'
2490
- * const dispose = onSessionStateChange((state: Amity.SessionStates) => {
2491
- * // ...
2492
- * })
2493
- * ```
2494
- *
2495
- * Fired when any {@link Amity.Client} has a session state change
2496
- *
2497
- * @param callback The function to call when the event was fired
2498
- * @returns an {@link Amity.Unsubscriber} function to stop listening
2499
- *
2500
- * @category Client Events
2501
- */
2502
- const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
2503
-
2504
2725
  const TOPICS = {
2505
2726
  [AmityAutoSubscription.NETWORK]: [getNetworkTopic],
2506
2727
  [AmityAutoSubscription.CHAT]: [
@@ -2510,6 +2731,7 @@ const TOPICS = {
2510
2731
  ],
2511
2732
  [AmityAutoSubscription.LIVESTREAM]: [getLiveStreamTopic],
2512
2733
  [AmityAutoSubscription.BLOCK]: [getMyFollowersTopic, getMyFollowingsTopic],
2734
+ [AmityAutoSubscription.USER]: [() => getUserTopic(getActiveUser())], // global ban
2513
2735
  };
2514
2736
  const DEFAULT_TOPICS = [
2515
2737
  AmityAutoSubscription.CHAT,
@@ -8584,7 +8806,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
8584
8806
  // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
8585
8807
  // the channel because currently backend can't handle this, so every time a user is banned from
8586
8808
  // a channel or the channel is deleted the channel's unread count will not be reset to zero
8587
- onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler());
8809
+ onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler(), channelActivityOnLoginHandler(), userFlagByMeOnLoginHandler());
8588
8810
  if (client.useLegacyUnreadCount) {
8589
8811
  subscriptions.push(readReceiptSyncEngineOnLoginHandler());
8590
8812
  }
@@ -15630,8 +15852,11 @@ const flagUser = async (userId, options) => {
15630
15852
  if (client.cache) {
15631
15853
  ingestInCache(payload);
15632
15854
  }
15855
+ const flagged = (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
15856
+ // The caller's own report may leave hashFlag unchanged; record that they flagged (REQ-016).
15857
+ onFlaggedByMe(flagged, userId);
15633
15858
  fireEvent('user.flagged', data);
15634
- return userLinkedObject((_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0]);
15859
+ return userLinkedObject(flagged);
15635
15860
  };
15636
15861
  /* end_public_function */
15637
15862
 
@@ -15651,8 +15876,11 @@ const submitUserReport = async (apiName, userId, body) => {
15651
15876
  if (client.cache) {
15652
15877
  ingestInCache(payload);
15653
15878
  }
15879
+ const flagged = (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
15880
+ // The caller's own report may leave hashFlag unchanged; record that they flagged (REQ-016).
15881
+ onFlaggedByMe(flagged, userId);
15654
15882
  fireEvent('user.flagged', data);
15655
- return userLinkedObject((_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0]);
15883
+ return userLinkedObject(flagged);
15656
15884
  };
15657
15885
 
15658
15886
  /** Maximum `comment` length, in string length units, after trimming. */
@@ -15706,7 +15934,7 @@ const toUserProfileReportBody = (options) => {
15706
15934
  };
15707
15935
  /**
15708
15936
  * Validates `flagUserBehavior` options and builds its request body. `reason` must be one
15709
- * of the nine `ContentFlagReasonEnum` values and is sent as that canonical label;
15937
+ * of the `ContentFlagReasonEnum` values and is sent as that canonical label;
15710
15938
  * `reportType` is always `behavior`.
15711
15939
  *
15712
15940
  * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
@@ -15787,7 +16015,7 @@ const flagUserProfile = async (userId, options) => submitUserReport('flagUserPro
15787
16015
  * })
15788
16016
  * ```
15789
16017
  *
15790
- * Reports a user's behavior. `reason` is required and is one of the nine
16018
+ * Reports a user's behavior. `reason` is required and is one of the
15791
16019
  * `ContentFlagReasonEnum` values, sent as its canonical label. Reporter text, including
15792
16020
  * the explanation for `Others`, always travels in `comment`; the reason never carries text.
15793
16021
  *
@@ -15831,14 +16059,15 @@ const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBe
15831
16059
  * untouched. Withdrawing a report that does not exist succeeds and changes nothing.
15832
16060
  *
15833
16061
  * The returned user is persisted to the cache, so its `hashFlag` says whether the caller
15834
- * still holds any report on the user. Do not flip a local "flagged by me" flag to `false`
15835
- * after a per-type withdrawal; read the fresh user, or call `isUserFlaggedByMe` for the
15836
- * remaining per-type state (`flags`).
16062
+ * may still hold a report on the user. Do not flip a local "flagged by me" flag to `false`
16063
+ * after a per-type withdrawal; observe the user and read `isFlaggedByMe`, or call
16064
+ * `user.getUserFlagsByMe()` for the remaining per-type state (`flags`). The SDK drops the
16065
+ * answer it confirmed for this user, so the next "maybe" is confirmed again.
15837
16066
  *
15838
16067
  * Sends `DELETE /api/v4/me/flags/:userId`, with `?reportType=<type>` when one is given.
15839
16068
  *
15840
16069
  * @param userId The ID of the user to unflag
15841
- * @param options Optional; `reportType` selects a single report to withdraw. For a report that `isUserFlaggedByMe` lists with `reportType: null`, pass `UserReportTypeFilterEnum.UNTYPED`
16070
+ * @param options Optional; `reportType` selects a single report to withdraw. For a report that `user.getUserFlagsByMe()` lists with `reportType: null`, pass `UserReportTypeFilterEnum.UNTYPED`
15842
16071
  * @returns `true` once the server has processed the withdrawal
15843
16072
  * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `reportType` is not a `UserReportTypeFilterEnum` value, before any request is made
15844
16073
  *
@@ -15857,6 +16086,8 @@ const unflagUser = async (userId, options) => {
15857
16086
  if (client.cache) {
15858
16087
  ingestInCache(payload);
15859
16088
  }
16089
+ // Drop the confirmed answer; never set it to false: other reports may remain (REQ-010).
16090
+ onUnflaggedByMe(userId);
15860
16091
  fireEvent('user.unflagged', data);
15861
16092
  return !!payload;
15862
16093
  };
@@ -15868,33 +16099,19 @@ const unflagUser = async (userId, options) => {
15868
16099
  /**
15869
16100
  * ```js
15870
16101
  * import { UserRepository } from '@amityco/ts-sdk'
15871
- *
15872
- * const { isFlagByMe, flags } = await UserRepository.isUserFlaggedByMe('userId')
15873
- *
15874
- * // Grey out the report options already used; null marks the typeless report.
15875
- * const used = new Set(flags.map(flag => flag.reportType))
16102
+ * const isFlagged = await UserRepository.isUserFlaggedByMe(userId)
15876
16103
  * ```
15877
16104
  *
15878
- * Returns whether the caller has reported a user, with each of the caller's own reports
15879
- * on that user, exactly as `GET /api/v4/users/:userId/isFlagByMe` answers. Each report
15880
- * carries `reportType`, `reason`, `comment` and `createdAt`; a field the report does not
15881
- * have is `null`. `reportType: null` is the typeless (legacy) report, which `unflagUser`
15882
- * withdraws with `UserReportTypeFilterEnum.UNTYPED`. Only the caller's reports come back.
16105
+ * Whether the current user has reported a user. Sends one request per call and caches
16106
+ * nothing.
15883
16107
  *
15884
- * This is the only source of per-type state. Nothing is filtered, cached or persisted:
15885
- * the call reads the server every time and does not consult `hashFlag`, which is a
15886
- * type-blind bloom filter. Call it again after a flag or unflag when the UI needs the
15887
- * updated per-type state.
15888
- *
15889
- * Breaking change: earlier versions returned a boolean from the v3 endpoint, which the
15890
- * backend has deprecated. Read `isFlagByMe` on the result for the same answer.
15891
- *
15892
- * @deprecated On an {@link Amity.User} you already hold, read `user.isFlaggedByMe` for a
15893
- * request-free badge and call `user.getUserFlagsByMe()` for the reports; it skips the request
15894
- * when the Bloom test says the user is not flagged. This function remains the underlying request.
16108
+ * @deprecated Read `user.isFlaggedByMe` on an {@link Amity.User} for a yes/no hint that
16109
+ * usually needs no request, and call `user.getUserFlagsByMe()` for the exact answer with the
16110
+ * caller's reports by type. Observe the user with `UserRepository.getUser(userId, callback)`
16111
+ * to follow a flag or unflag.
15895
16112
  *
15896
16113
  * @param userId The ID of the user to check
15897
- * @returns the caller's {@link Amity.UserFlagByMe} on that user
16114
+ * @returns `true` if the current user has reported the user, `false` if not
15898
16115
  *
15899
16116
  * @category Report API
15900
16117
  * @async
@@ -15902,7 +16119,8 @@ const unflagUser = async (userId, options) => {
15902
16119
  const isUserFlaggedByMe = async (userId) => {
15903
16120
  const client = getActiveClient();
15904
16121
  client.log('user/isUserFlaggedByMe', userId);
15905
- return getFlagsByMe(userId);
16122
+ const { isFlagByMe } = await getFlagsByMe(userId);
16123
+ return isFlagByMe;
15906
16124
  };
15907
16125
  /* end_public_function */
15908
16126
 
@@ -16141,7 +16359,7 @@ const getUser = (userId, callback) => {
16141
16359
  const reactor = (response) => {
16142
16360
  return callback(Object.assign(Object.assign({}, response), { data: response.data ? LinkedObject.user(response.data) : response.data }));
16143
16361
  };
16144
- return liveObject(userId, reactor, 'userId', getUser$1, [
16362
+ const unsubscribeUser = liveObject(userId, reactor, 'userId', getUser$1, [
16145
16363
  onUserFetched,
16146
16364
  onUserUpdated,
16147
16365
  onUserDeleted$2,
@@ -16149,6 +16367,17 @@ const getUser = (userId, callback) => {
16149
16367
  onUserUnflagged,
16150
16368
  onUserFlagCleared,
16151
16369
  ]);
16370
+ // A confirmed flag answer leaves the cached user row unchanged, so the live object's own
16371
+ // dedupe would drop it. Deliver the re-linked user directly (user.check_flag_by_me REQ-016).
16372
+ const unsubscribeFlag = onUserFlagConfirmed(user => {
16373
+ if (user.userId !== userId)
16374
+ return;
16375
+ callback({ data: LinkedObject.user(user), loading: false, origin: 'event' });
16376
+ });
16377
+ return () => {
16378
+ unsubscribeUser();
16379
+ unsubscribeFlag();
16380
+ };
16152
16381
  };
16153
16382
  /* end_public_function */
16154
16383
 
@@ -16246,13 +16475,24 @@ class UserLiveCollectionController extends LiveCollectionController {
16246
16475
  this.queryStreamController.appendToQueryStream(response, direction, refresh);
16247
16476
  }
16248
16477
  startSubscription() {
16249
- return this.queryStreamController.subscribeRTE([
16250
- { fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
16251
- { fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
16252
- { fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
16253
- { fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
16254
- { fn: onUserFlagCleared, action: EnumUserActions.OnUserFlagCleared },
16255
- ]);
16478
+ return [
16479
+ ...this.queryStreamController.subscribeRTE([
16480
+ { fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
16481
+ { fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
16482
+ { fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
16483
+ { fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
16484
+ { fn: onUserFlagCleared, action: EnumUserActions.OnUserFlagCleared },
16485
+ ]),
16486
+ // A confirmed flag answer changes isFlaggedByMe on a listed user without changing its
16487
+ // cache row (user.check_flag_by_me REQ-016). Re-link only collections that hold it.
16488
+ onUserFlagConfirmed(user => {
16489
+ var _a;
16490
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
16491
+ if (!(collection === null || collection === void 0 ? void 0 : collection.data.includes(user.userId)))
16492
+ return;
16493
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
16494
+ }),
16495
+ ];
16256
16496
  }
16257
16497
  notifyChange({ origin, loading, error }) {
16258
16498
  var _a, _b;
@@ -16804,13 +17044,24 @@ class SearchUserLiveCollectionController extends LiveCollectionController {
16804
17044
  this.queryStreamController.appendToQueryStream(response, direction, refresh);
16805
17045
  }
16806
17046
  startSubscription() {
16807
- return this.queryStreamController.subscribeRTE([
16808
- { fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
16809
- { fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
16810
- { fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
16811
- { fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
16812
- { fn: onUserFlagCleared, action: EnumUserActions.OnUserFlagCleared },
16813
- ]);
17047
+ return [
17048
+ ...this.queryStreamController.subscribeRTE([
17049
+ { fn: onUserDeleted$2, action: EnumUserActions.OnUserDeleted },
17050
+ { fn: onUserUpdated, action: EnumUserActions.OnUserUpdated },
17051
+ { fn: onUserFlagged, action: EnumUserActions.OnUserFlagged },
17052
+ { fn: onUserUnflagged, action: EnumUserActions.OnUserUnflagged },
17053
+ { fn: onUserFlagCleared, action: EnumUserActions.OnUserFlagCleared },
17054
+ ]),
17055
+ // A confirmed flag answer changes isFlaggedByMe on a listed user without changing its
17056
+ // cache row (user.check_flag_by_me REQ-016). Re-link only collections that hold it.
17057
+ onUserFlagConfirmed(user => {
17058
+ var _a;
17059
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
17060
+ if (!(collection === null || collection === void 0 ? void 0 : collection.data.includes(user.userId)))
17061
+ return;
17062
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
17063
+ }),
17064
+ ];
16814
17065
  }
16815
17066
  notifyChange({ origin, loading, error }) {
16816
17067
  var _a, _b;
@@ -20760,7 +21011,7 @@ const isLegacyContentFlagReason = (input) => input === undefined || typeof input
20760
21011
  /**
20761
21012
  * Validates an `Amity.ContentFlagOptions` argument. Untyped (plain JS) callers can pass
20762
21013
  * anything at runtime, so the checks do not trust the declared type: the value must be a
20763
- * plain object, `reason` must be one of the nine `ContentFlagReasonEnum` values and
21014
+ * plain object, `reason` must be one of the `ContentFlagReasonEnum` values and
20764
21015
  * `detail`, when supplied, must be a string (`null` is not a valid supplied detail).
20765
21016
  *
20766
21017
  * @param apiName used in the error message, e.g. `flagPost`
@@ -37939,4 +38190,62 @@ class AmityAttachmentProductTags {
37939
38190
  }
37940
38191
  }
37941
38192
 
37942
- export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserProfileFieldEnum, UserReportTypeEnum, UserReportTypeFilterEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastMessage, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
38193
+ /**
38194
+ * Stable, cross-platform key per report category. Android and iOS expose the same
38195
+ * keys on `AmityContentFlagReasonType.key`. A UIKit builds its string key from it
38196
+ * (`amity_social_label_report_reason_<key>`), so a released key is never renamed.
38197
+ * The key is not derived from the enum member name on purpose: the existing UIKit
38198
+ * string keys do not follow it (`selling_restricted`, `violence_or_threatening`).
38199
+ */
38200
+ const CONTENT_FLAG_REASON_KEYS = Object.freeze({
38201
+ [ContentFlagReasonEnum.CommunityGuidelines]: 'community_guidelines',
38202
+ [ContentFlagReasonEnum.ChildEndangerment]: 'child_endangerment',
38203
+ [ContentFlagReasonEnum.HarassmentOrBullying]: 'harassment_or_bullying',
38204
+ [ContentFlagReasonEnum.SelfHarmOrSuicide]: 'self_harm_or_suicide',
38205
+ [ContentFlagReasonEnum.ViolenceOrThreateningContent]: 'violence_or_threatening',
38206
+ [ContentFlagReasonEnum.SellingRestrictedItems]: 'selling_restricted',
38207
+ [ContentFlagReasonEnum.SexualContentOrNudity]: 'sexual_content_or_nudity',
38208
+ [ContentFlagReasonEnum.SpamOrScams]: 'spam_or_scams',
38209
+ [ContentFlagReasonEnum.FalseInformation]: 'false_information',
38210
+ [ContentFlagReasonEnum.Others]: 'others',
38211
+ });
38212
+ /* begin_public_function
38213
+ id: content_flag_reason.get_reasons
38214
+ */
38215
+ /**
38216
+ * ```js
38217
+ * import { getContentFlagReasons, AmityContentFlagReasonType } from '@amityco/ts-sdk'
38218
+ * const reasons = getContentFlagReasons().filter(r => r !== AmityContentFlagReasonType.Others)
38219
+ * ```
38220
+ *
38221
+ * Returns every report category in display order, with `Others` last. Render a report
38222
+ * picker from this list rather than a copy, so a category added in a later SDK release
38223
+ * appears without a UI change. Each value is also its English default label.
38224
+ *
38225
+ * @returns a new array on every call; mutating it does not affect the SDK
38226
+ *
38227
+ * @category Content Flag
38228
+ */
38229
+ const getContentFlagReasons = () => Object.values(ContentFlagReasonEnum);
38230
+ /* end_public_function */
38231
+ /* begin_public_function
38232
+ id: content_flag_reason.get_key
38233
+ */
38234
+ /**
38235
+ * ```js
38236
+ * import { getContentFlagReasonKey, AmityContentFlagReasonType } from '@amityco/ts-sdk'
38237
+ * getContentFlagReasonKey(AmityContentFlagReasonType.ChildEndangerment) // 'child_endangerment'
38238
+ * ```
38239
+ *
38240
+ * Returns the stable, cross-platform key of a report category, for building a
38241
+ * localisation key. Never send the key to the server: flag with the enum value.
38242
+ *
38243
+ * @param reason an `AmityContentFlagReasonType` (`ContentFlagReasonEnum`) value
38244
+ * @returns the category's snake_case key
38245
+ *
38246
+ * @category Content Flag
38247
+ */
38248
+ const getContentFlagReasonKey = (reason) => CONTENT_FLAG_REASON_KEYS[reason];
38249
+ /* end_public_function */
38250
+
38251
+ export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, ContentFlagReasonEnum as AmityContentFlagReasonType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserProfileFieldEnum, UserReportTypeEnum, UserReportTypeFilterEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getContentFlagReasonKey, getContentFlagReasons, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastMessage, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };