@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.cjs.js CHANGED
@@ -37,6 +37,7 @@ exports.AmityAutoSubscription = void 0;
37
37
  AmityAutoSubscription["NETWORK"] = "network";
38
38
  AmityAutoSubscription["LIVESTREAM"] = "livestream";
39
39
  AmityAutoSubscription["BLOCK"] = "block";
40
+ AmityAutoSubscription["USER"] = "user";
40
41
  })(exports.AmityAutoSubscription || (exports.AmityAutoSubscription = {}));
41
42
 
42
43
  exports.UserTypeEnum = void 0;
@@ -74,7 +75,7 @@ exports.UserProfileFieldEnum = void 0;
74
75
  * Selects which of the caller's reports `UserRepository.unflagUser` withdraws, sent as the
75
76
  * `reportType` query parameter. The four typed members are the backend `reportType` wire
76
77
  * values and match `UserReportTypeEnum`. `UNTYPED` selects the typeless (legacy) report,
77
- * which `isUserFlaggedByMe` returns as `reportType: null`; it is a selector only, never
78
+ * which `user.getUserFlagsByMe()` returns as `reportType: null`; it is a selector only, never
78
79
  * stored, and the flag endpoint refuses it.
79
80
  */
80
81
  exports.UserReportTypeFilterEnum = void 0;
@@ -161,6 +162,7 @@ const ContentFeedType = Object.freeze({
161
162
  exports.ContentFlagReasonEnum = void 0;
162
163
  (function (ContentFlagReasonEnum) {
163
164
  ContentFlagReasonEnum["CommunityGuidelines"] = "Against community guidelines";
165
+ ContentFlagReasonEnum["ChildEndangerment"] = "Child endangerment";
164
166
  ContentFlagReasonEnum["HarassmentOrBullying"] = "Harassment or bullying";
165
167
  ContentFlagReasonEnum["SelfHarmOrSuicide"] = "Self-harm or suicide";
166
168
  ContentFlagReasonEnum["ViolenceOrThreateningContent"] = "Violence or threatening content";
@@ -359,8 +361,8 @@ exports.AmityLiveViewerCountMode = void 0;
359
361
 
360
362
  function getVersion() {
361
363
  try {
362
- // the string ''v7.29.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
363
- return 'v7.29.0-cjs';
364
+ // the string ''v7.30.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
365
+ return 'v7.30.0-cjs';
364
366
  }
365
367
  catch (error) {
366
368
  return '__dev__';
@@ -1852,15 +1854,64 @@ async function modifyMqttConnection() {
1852
1854
  }
1853
1855
  }
1854
1856
 
1857
+ class SessionWatcher {
1858
+ constructor() {
1859
+ this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
1860
+ this._listener = new Map();
1861
+ }
1862
+ onSessionStateChange(callback) {
1863
+ this._listener.set(callback, callback);
1864
+ return () => {
1865
+ this._listener.delete(callback);
1866
+ };
1867
+ }
1868
+ setSessionState(state, reason) {
1869
+ if (this._sessionState === state)
1870
+ return;
1871
+ this._sessionState = state;
1872
+ this._listener.forEach(cb => cb(state, reason));
1873
+ }
1874
+ destroy() {
1875
+ this._listener.clear();
1876
+ }
1877
+ }
1878
+ let instance$b;
1879
+ var SessionWatcher$1 = {
1880
+ getInstance: () => {
1881
+ if (!instance$b) {
1882
+ instance$b = new SessionWatcher();
1883
+ }
1884
+ return instance$b;
1885
+ },
1886
+ };
1887
+
1888
+ /**
1889
+ * ```js
1890
+ * import { onSessionStateChange } from '@amityco/ts-sdk'
1891
+ * const dispose = onSessionStateChange((state: Amity.SessionStates) => {
1892
+ * // ...
1893
+ * })
1894
+ * ```
1895
+ *
1896
+ * Fired when any {@link Amity.Client} has a session state change
1897
+ *
1898
+ * @param callback The function to call when the event was fired
1899
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
1900
+ *
1901
+ * @category Client Events
1902
+ */
1903
+ const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
1904
+
1855
1905
  /**
1856
1906
  * ```js
1857
1907
  * import { getFlagsByMe } from '~/userRepository/internalApi/getFlagsByMe'
1858
1908
  * const { isFlagByMe, flags } = await getFlagsByMe('userId')
1859
1909
  * ```
1860
1910
  *
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.
1911
+ * The v4 read behind `user.getUserFlagsByMe()`, the background confirm of
1912
+ * `user.isFlaggedByMe`, and the deprecated `UserRepository.isUserFlaggedByMe`:
1913
+ * `GET /api/v4/users/:userId/isFlagByMe`, returned as received. Nothing is filtered, cached or
1914
+ * persisted here, and `hashFlag` is not consulted.
1864
1915
  * This is the Web counterpart of iOS `ASCUserService.getFlagsByMe` and Android
1865
1916
  * `UserRepository.getFlagsByMe`, kept apart from the deprecated public function so the
1866
1917
  * user-object read does not change if that function ever does.
@@ -1921,35 +1972,72 @@ const locationsFor = (value, bits, hashes) => {
1921
1972
  }
1922
1973
  return locations;
1923
1974
  };
1975
+ /** Standard or URL-safe base64, padding optional. Anything else is not a filter we can read. */
1976
+ const BASE64 = /^[A-Za-z0-9+/_-]*={0,2}$/;
1924
1977
  /**
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`.
1978
+ * Whether `value` is probably in the filter. `false` is exact; `true` means "maybe", which may be
1979
+ * a false positive. `null` (the server's value when nobody has flagged the object), a missing
1980
+ * filter or a missing value answer `false`.
1981
+ *
1982
+ * A filter that cannot be read answers `true` ("maybe") and never throws, so the caller asks the
1983
+ * server instead of trusting a "definitely not" it cannot back up (REQ-017): `bits` or `hashes`
1984
+ * not a positive integer, a `hash` that is not base64, or a `hash` shorter than `ceil(bits / 8)`
1985
+ * bytes.
1928
1986
  */
1929
1987
  const testBloomFilter = (hashFlag, value) => {
1930
1988
  if (!hashFlag || !value)
1931
1989
  return false;
1932
1990
  const { bits, hashes, hash } = hashFlag;
1933
- if (!(bits > 0) || !(hashes > 0) || typeof hash !== 'string')
1934
- return false;
1991
+ if (!Number.isInteger(bits) || bits <= 0)
1992
+ return true;
1993
+ if (!Number.isInteger(hashes) || hashes <= 0)
1994
+ return true;
1995
+ if (typeof hash !== 'string' || !BASE64.test(hash))
1996
+ return true;
1935
1997
  let buckets;
1936
1998
  try {
1937
1999
  buckets = jsBase64.toUint8Array(hash);
1938
2000
  }
1939
2001
  catch (_a) {
1940
- return false;
2002
+ return true;
1941
2003
  }
2004
+ if (buckets.length < Math.ceil(bits / 8))
2005
+ return true;
1942
2006
  const locations = locationsFor(value, bits, hashes);
1943
2007
  for (let i = 0; i < locations.length; i += 1) {
1944
2008
  const index = Math.floor(locations[i] / 8);
1945
2009
  const bit = 1 << locations[i] % 8;
1946
- if (index >= buckets.length || (buckets[index] & bit) === 0)
2010
+ if ((buckets[index] & bit) === 0)
1947
2011
  return false;
1948
2012
  }
1949
2013
  return true;
1950
2014
  };
1951
2015
 
1952
- /** The current user's id, or `undefined` when there is no active client (the getter never throws). */
2016
+ /**
2017
+ * Flag state of the current user on a target user, behind `Amity.User.isFlaggedByMe` and
2018
+ * `Amity.User.getUserFlagsByMe()` (`user.check_flag_by_me` v1, REQ-011, REQ-012, REQ-016).
2019
+ *
2020
+ * `hashFlag` is a Bloom filter of reporter ids. "Definitely not" is exact. "Maybe" can be a
2021
+ * false positive caused by other reporters, so the SDK confirms it with the server once per
2022
+ * `hashFlag` value and records the answer in the cache under its own key, never on the user's
2023
+ * cache row (REQ-015). Observers are told through `local.user.flagConfirmed` when a recorded
2024
+ * answer changes what a user object would show.
2025
+ *
2026
+ * Not exported from the public API.
2027
+ */
2028
+ /** Confirms for the same user are at least this far apart, as Android's `EkoFlag.expired`. */
2029
+ const FLAG_CONFIRM_INTERVAL = 1000;
2030
+ const cacheKey = (userId) => ['userFlagByMe', 'get', userId];
2031
+ const lastConfirmAt = new Map();
2032
+ /**
2033
+ * Bumped by the current user's own flag and unflag. A confirm or exact read that started before
2034
+ * one of them must not record its answer, because the write may have changed it while the
2035
+ * `hashFlag` stayed the same.
2036
+ */
2037
+ const generations = new Map();
2038
+ const generationOf = (userId) => { var _a; return (_a = generations.get(userId)) !== null && _a !== void 0 ? _a : 0; };
2039
+ const bumpGeneration = (userId) => generations.set(userId, generationOf(userId) + 1);
2040
+ /** The current user's id, or `undefined` when there is no active client. Never throws. */
1953
2041
  const currentUserId = () => {
1954
2042
  try {
1955
2043
  return getActiveClient().userId;
@@ -1958,43 +2046,223 @@ const currentUserId = () => {
1958
2046
  return undefined;
1959
2047
  }
1960
2048
  };
2049
+ const readRecord = (userId) => {
2050
+ var _a;
2051
+ try {
2052
+ return (_a = pullFromCache(cacheKey(userId))) === null || _a === void 0 ? void 0 : _a.data;
2053
+ }
2054
+ catch (_b) {
2055
+ return undefined;
2056
+ }
2057
+ };
1961
2058
  /**
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.
2059
+ * The server's answer recorded for this user and this exact `hashFlag`, or `undefined` when there
2060
+ * is none for the current user. Never throws.
1966
2061
  */
1967
- const flagsByMeEntries = new Map();
2062
+ const readConfirmedFlag = (userId, hashFlag) => {
2063
+ const me = currentUserId();
2064
+ if (!me || !hashFlag || typeof hashFlag.hash !== 'string')
2065
+ return undefined;
2066
+ const record = readRecord(userId);
2067
+ if (!record || record.reporterId !== me || record.hash !== hashFlag.hash)
2068
+ return undefined;
2069
+ return record.isFlagByMe;
2070
+ };
1968
2071
  /**
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.
2072
+ * The v4 request in flight per user, with the generation it started in. A confirm and an exact
2073
+ * read of the same user share one request; a request that started before the current user's own
2074
+ * flag or unflag is not joined.
1972
2075
  */
1973
- const knownNotFlaggedByMe = (userId) => {
2076
+ const inFlight = new Map();
2077
+ const requestFlagsByMe = (userId) => {
2078
+ const generation = generationOf(userId);
2079
+ const pending = inFlight.get(userId);
2080
+ if (pending && pending.generation === generation)
2081
+ return pending.promise;
2082
+ const promise = getFlagsByMe(userId).finally(() => {
2083
+ var _a;
2084
+ if (((_a = inFlight.get(userId)) === null || _a === void 0 ? void 0 : _a.promise) === promise)
2085
+ inFlight.delete(userId);
2086
+ });
2087
+ inFlight.set(userId, { generation, promise });
2088
+ return promise;
2089
+ };
2090
+ const notifyObservers = (userId) => fireEvent('local.user.flagConfirmed', { userId });
2091
+ /**
2092
+ * Records `isFlagByMe` for `hashFlag`. A "maybe" without a record shows `true`, so observers are
2093
+ * told only when the shown value changes.
2094
+ */
2095
+ const recordFlag = (userId, hashFlag, isFlagByMe) => {
1974
2096
  var _a;
1975
2097
  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)
2098
+ if (!me || typeof hashFlag.hash !== 'string')
2099
+ return;
2100
+ const shown = (_a = readConfirmedFlag(userId, hashFlag)) !== null && _a !== void 0 ? _a : true;
2101
+ const record = { reporterId: me, hash: hashFlag.hash, isFlagByMe };
2102
+ pushToCache(cacheKey(userId), record);
2103
+ if (shown !== isFlagByMe)
2104
+ notifyObservers(userId);
2105
+ };
2106
+ /**
2107
+ * Starts one background confirm of a "maybe" (REQ-016): at most one in flight per user, and
2108
+ * confirms for the same user at least {@link FLAG_CONFIRM_INTERVAL} apart. A failed confirm
2109
+ * records nothing, surfaces no error, and a later read tries again.
2110
+ */
2111
+ const confirmFlagByMe = (userId, hashFlag) => {
2112
+ if (inFlight.has(userId))
2113
+ return;
2114
+ const now = Date.now();
2115
+ const last = lastConfirmAt.get(userId);
2116
+ if (last !== undefined && now - last < FLAG_CONFIRM_INTERVAL)
2117
+ return;
2118
+ const me = currentUserId();
2119
+ const generation = generationOf(userId);
2120
+ lastConfirmAt.set(userId, now);
2121
+ requestFlagsByMe(userId)
2122
+ .then(({ isFlagByMe }) => {
2123
+ if (currentUserId() !== me || generationOf(userId) !== generation)
2124
+ return;
2125
+ recordFlag(userId, hashFlag, isFlagByMe);
2126
+ })
2127
+ .catch(() => {
2128
+ // Not an answer: isFlaggedByMe stays true until a later read confirms again.
2129
+ });
2130
+ };
2131
+ /**
2132
+ * The value of `Amity.User.isFlaggedByMe` for a user object whose confirmed answer was captured
2133
+ * (`confirmed`) when the object was linked, so a held object never changes (REQ-014).
2134
+ *
2135
+ * - No current user, `hashFlag: null` or a missing `hashFlag`, or "definitely not": `false`.
2136
+ * - "Maybe" with a confirmed answer: that answer, no request.
2137
+ * - "Maybe" without one: `true`, and one background confirm (REQ-016).
2138
+ *
2139
+ * The linked object declares this as a getter inside an object spread, which the build compiles
2140
+ * to `Object.assign`, so it runs once when the user is linked and the object keeps that value.
2141
+ */
2142
+ const isFlaggedByMeFor = (user, confirmed) => {
2143
+ const me = currentUserId();
2144
+ if (!me || !user.hashFlag || !testBloomFilter(user.hashFlag, me))
1978
2145
  return false;
1979
- return !testBloomFilter(user.hashFlag, me);
2146
+ if (confirmed !== undefined)
2147
+ return confirmed;
2148
+ confirmFlagByMe(user.userId, user.hashFlag);
2149
+ return true;
2150
+ };
2151
+ const NOT_FLAGGED = { isFlagByMe: false, flags: [] };
2152
+ const isNotOlder = (next, current) => {
2153
+ var _a, _b;
2154
+ const nextAt = Date.parse((_a = next.updatedAt) !== null && _a !== void 0 ? _a : '');
2155
+ const currentAt = Date.parse((_b = current.updatedAt) !== null && _b !== void 0 ? _b : '');
2156
+ return Number.isNaN(nextAt) || Number.isNaN(currentAt) || nextAt >= currentAt;
2157
+ };
2158
+ /**
2159
+ * One `getUserFlagsByMe` closure per userId, remembering the newest user object linked for that
2160
+ * id. Live objects and collections compare snapshots with `isEqual`, which compares functions by
2161
+ * reference, so a fresh closure per linked object would re-dispatch unchanged snapshots
2162
+ * (REQ-015). An older snapshot linked later does not replace a newer one.
2163
+ */
2164
+ const flagsByMeEntries = new Map();
2165
+ /**
2166
+ * `Amity.User.getUserFlagsByMe()` (REQ-012): `{ isFlagByMe: false, flags: [] }` with no request
2167
+ * when the newest linked user says "not flagged", including a confirmed `false`. Otherwise the
2168
+ * v4 read, returned as is; a confirm already in flight for the user is joined instead of sending
2169
+ * a second request. Its `isFlagByMe` is recorded as the confirmed answer for the
2170
+ * `hashFlag` it was read for; `flags[]` is never stored (REQ-009). A missing `hashFlag` is
2171
+ * unknown, so the server is asked.
2172
+ */
2173
+ const readFlagsByMe = async (userId) => {
2174
+ var _a, _b;
2175
+ const me = currentUserId();
2176
+ const { hashFlag } = (_b = (_a = flagsByMeEntries.get(userId)) === null || _a === void 0 ? void 0 : _a.latest) !== null && _b !== void 0 ? _b : {};
2177
+ if (me && hashFlag !== undefined) {
2178
+ if (!hashFlag || !testBloomFilter(hashFlag, me))
2179
+ return Object.assign(Object.assign({}, NOT_FLAGGED), { flags: [] });
2180
+ if (readConfirmedFlag(userId, hashFlag) === false)
2181
+ return Object.assign(Object.assign({}, NOT_FLAGGED), { flags: [] });
2182
+ }
2183
+ const generation = generationOf(userId);
2184
+ const result = await requestFlagsByMe(userId);
2185
+ if (hashFlag && currentUserId() === me && generationOf(userId) === generation) {
2186
+ recordFlag(userId, hashFlag, result.isFlagByMe);
2187
+ }
2188
+ return result;
1980
2189
  };
1981
2190
  const getUserFlagsByMeFor = (user) => {
1982
2191
  let entry = flagsByMeEntries.get(user.userId);
1983
2192
  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
- };
2193
+ entry = { latest: user, getUserFlagsByMe: () => readFlagsByMe(user.userId) };
1992
2194
  flagsByMeEntries.set(user.userId, entry);
1993
2195
  }
1994
- entry.latest = user;
2196
+ else if (isNotOlder(user, entry.latest)) {
2197
+ entry.latest = user;
2198
+ }
1995
2199
  return entry.getUserFlagsByMe;
1996
2200
  };
2201
+ /**
2202
+ * The current user's own flag succeeded (REQ-016). Their report may leave `hashFlag` unchanged
2203
+ * when other reporters had already set all of their bits, so the answer is known: record `true`
2204
+ * for the `hashFlag` the response carries, or drop the answer when it carries none.
2205
+ */
2206
+ const onFlaggedByMe = (user, userId) => {
2207
+ bumpGeneration(userId);
2208
+ if (user === null || user === void 0 ? void 0 : user.hashFlag) {
2209
+ recordFlag(userId, user.hashFlag, true);
2210
+ return;
2211
+ }
2212
+ const dropped = readRecord(userId);
2213
+ dropFromCache(cacheKey(userId), true);
2214
+ if ((dropped === null || dropped === void 0 ? void 0 : dropped.isFlagByMe) === false)
2215
+ notifyObservers(userId);
2216
+ };
2217
+ /**
2218
+ * The current user's own unflag succeeded (`user.unflag` REQ-010, REQ-016). A per-type unflag can
2219
+ * leave other reports in place, so the answer is dropped, never set to `false`; the next "maybe"
2220
+ * is confirmed again.
2221
+ */
2222
+ const onUnflaggedByMe = (userId) => {
2223
+ bumpGeneration(userId);
2224
+ const dropped = readRecord(userId);
2225
+ dropFromCache(cacheKey(userId), true);
2226
+ if ((dropped === null || dropped === void 0 ? void 0 : dropped.isFlagByMe) === false)
2227
+ notifyObservers(userId);
2228
+ };
2229
+ /** Forgets every in-memory trace of the current user's flag state. Records live in the cache. */
2230
+ const resetUserFlagByMe = () => {
2231
+ flagsByMeEntries.clear();
2232
+ inFlight.clear();
2233
+ lastConfirmAt.clear();
2234
+ generations.clear();
2235
+ };
2236
+ /**
2237
+ * Registered through `setupLoginSubscriptions`. Every confirmed answer belongs to the current
2238
+ * user, so the state is cleared on logout; the records themselves go with the cache, and each
2239
+ * also carries the reporter's id.
2240
+ */
2241
+ const userFlagByMeOnLoginHandler = () => {
2242
+ const unsubscribe = onSessionStateChange(state => {
2243
+ if (state === "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */ || state === "terminated" /* Amity.SessionStates.TERMINATED */) {
2244
+ resetUserFlagByMe();
2245
+ }
2246
+ });
2247
+ return () => {
2248
+ unsubscribe();
2249
+ resetUserFlagByMe();
2250
+ };
2251
+ };
2252
+ /**
2253
+ * Called with the cached user when a recorded answer changes what that user would show, so live
2254
+ * objects and live collections deliver it again (REQ-016, delivery).
2255
+ */
2256
+ const onUserFlagConfirmed = (callback) => createEventSubscriber(getActiveClient(), 'user/onUserFlagConfirmed', 'local.user.flagConfirmed', ({ userId }) => {
2257
+ var _a;
2258
+ const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
2259
+ if (user)
2260
+ callback(user);
2261
+ });
2262
+
1997
2263
  const userLinkedObject = (user) => {
2264
+ // Captured now, so a user object the app holds never changes after a confirm (REQ-014).
2265
+ const confirmedFlagByMe = readConfirmedFlag(user.userId, user.hashFlag);
1998
2266
  return Object.assign(Object.assign({}, user), { get avatar() {
1999
2267
  var _a;
2000
2268
  if (!user.avatarFileId)
@@ -2005,9 +2273,10 @@ const userLinkedObject = (user) => {
2005
2273
  return avatar;
2006
2274
  },
2007
2275
  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());
2276
+ // Bloom test on this object's hashFlag: "definitely not" is exact and sends nothing.
2277
+ // "Maybe" returns the answer confirmed for this hashFlag, or true while one background
2278
+ // confirm runs (REQ-011, REQ-016). Never throws.
2279
+ return isFlaggedByMeFor(user, confirmedFlagByMe);
2011
2280
  },
2012
2281
  /* begin_public_function
2013
2282
  id: user.get_flags_by_me
@@ -2279,13 +2548,13 @@ class NetworkActivitiesWatcher {
2279
2548
  this._listener.clear();
2280
2549
  }
2281
2550
  }
2282
- let instance$b;
2551
+ let instance$a;
2283
2552
  var NetworkActivitiesWatcher$1 = {
2284
2553
  getInstance: () => {
2285
- if (!instance$b) {
2286
- instance$b = new NetworkActivitiesWatcher();
2554
+ if (!instance$a) {
2555
+ instance$a = new NetworkActivitiesWatcher();
2287
2556
  }
2288
- return instance$b;
2557
+ return instance$a;
2289
2558
  },
2290
2559
  };
2291
2560
 
@@ -2469,54 +2738,6 @@ const createHttpTransport = (endpoint) => {
2469
2738
  return instance;
2470
2739
  };
2471
2740
 
2472
- class SessionWatcher {
2473
- constructor() {
2474
- this._sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
2475
- this._listener = new Map();
2476
- }
2477
- onSessionStateChange(callback) {
2478
- this._listener.set(callback, callback);
2479
- return () => {
2480
- this._listener.delete(callback);
2481
- };
2482
- }
2483
- setSessionState(state, reason) {
2484
- if (this._sessionState === state)
2485
- return;
2486
- this._sessionState = state;
2487
- this._listener.forEach(cb => cb(state, reason));
2488
- }
2489
- destroy() {
2490
- this._listener.clear();
2491
- }
2492
- }
2493
- let instance$a;
2494
- var SessionWatcher$1 = {
2495
- getInstance: () => {
2496
- if (!instance$a) {
2497
- instance$a = new SessionWatcher();
2498
- }
2499
- return instance$a;
2500
- },
2501
- };
2502
-
2503
- /**
2504
- * ```js
2505
- * import { onSessionStateChange } from '@amityco/ts-sdk'
2506
- * const dispose = onSessionStateChange((state: Amity.SessionStates) => {
2507
- * // ...
2508
- * })
2509
- * ```
2510
- *
2511
- * Fired when any {@link Amity.Client} has a session state change
2512
- *
2513
- * @param callback The function to call when the event was fired
2514
- * @returns an {@link Amity.Unsubscriber} function to stop listening
2515
- *
2516
- * @category Client Events
2517
- */
2518
- const onSessionStateChange = (callback) => SessionWatcher$1.getInstance().onSessionStateChange(callback);
2519
-
2520
2741
  const TOPICS = {
2521
2742
  [exports.AmityAutoSubscription.NETWORK]: [getNetworkTopic],
2522
2743
  [exports.AmityAutoSubscription.CHAT]: [
@@ -2526,6 +2747,7 @@ const TOPICS = {
2526
2747
  ],
2527
2748
  [exports.AmityAutoSubscription.LIVESTREAM]: [getLiveStreamTopic],
2528
2749
  [exports.AmityAutoSubscription.BLOCK]: [getMyFollowersTopic, getMyFollowingsTopic],
2750
+ [exports.AmityAutoSubscription.USER]: [() => getUserTopic(getActiveUser())], // global ban
2529
2751
  };
2530
2752
  const DEFAULT_TOPICS = [
2531
2753
  exports.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,9 +38190,68 @@ class AmityAttachmentProductTags {
37939
38190
  }
37940
38191
  }
37941
38192
 
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
+ [exports.ContentFlagReasonEnum.CommunityGuidelines]: 'community_guidelines',
38202
+ [exports.ContentFlagReasonEnum.ChildEndangerment]: 'child_endangerment',
38203
+ [exports.ContentFlagReasonEnum.HarassmentOrBullying]: 'harassment_or_bullying',
38204
+ [exports.ContentFlagReasonEnum.SelfHarmOrSuicide]: 'self_harm_or_suicide',
38205
+ [exports.ContentFlagReasonEnum.ViolenceOrThreateningContent]: 'violence_or_threatening',
38206
+ [exports.ContentFlagReasonEnum.SellingRestrictedItems]: 'selling_restricted',
38207
+ [exports.ContentFlagReasonEnum.SexualContentOrNudity]: 'sexual_content_or_nudity',
38208
+ [exports.ContentFlagReasonEnum.SpamOrScams]: 'spam_or_scams',
38209
+ [exports.ContentFlagReasonEnum.FalseInformation]: 'false_information',
38210
+ [exports.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(exports.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
+
37942
38251
  exports.API_REGIONS = API_REGIONS;
37943
38252
  exports.AdRepository = index$6;
37944
38253
  exports.AmityAttachmentProductTags = AmityAttachmentProductTags;
38254
+ exports.AmityContentFlagReasonType = exports.ContentFlagReasonEnum;
37945
38255
  exports.AmityModuleNotEntitledError = AmityModuleNotEntitledError;
37946
38256
  exports.CategoryRepository = index$g;
37947
38257
  exports.ChannelRepository = index$k;
@@ -38005,6 +38315,8 @@ exports.getChannelTopic = getChannelTopic;
38005
38315
  exports.getCommentTopic = getCommentTopic;
38006
38316
  exports.getCommunityStoriesTopic = getCommunityStoriesTopic;
38007
38317
  exports.getCommunityTopic = getCommunityTopic;
38318
+ exports.getContentFlagReasonKey = getContentFlagReasonKey;
38319
+ exports.getContentFlagReasons = getContentFlagReasons;
38008
38320
  exports.getLiveReactionTopic = getLiveReactionTopic;
38009
38321
  exports.getLiveStreamTopic = getLiveStreamTopic;
38010
38322
  exports.getMarkedMessageTopic = getMarkedMessageTopic;