@amityco/ts-sdk 7.28.0 → 7.28.1-295600.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 (96) hide show
  1. package/dist/@types/core/errors.d.ts +4 -1
  2. package/dist/@types/core/errors.d.ts.map +1 -1
  3. package/dist/@types/core/transport.d.ts +1 -0
  4. package/dist/@types/core/transport.d.ts.map +1 -1
  5. package/dist/@types/domains/client.d.ts +86 -0
  6. package/dist/@types/domains/client.d.ts.map +1 -1
  7. package/dist/@types/domains/content.d.ts +11 -0
  8. package/dist/@types/domains/content.d.ts.map +1 -1
  9. package/dist/@types/domains/user.d.ts +31 -0
  10. package/dist/@types/domains/user.d.ts.map +1 -1
  11. package/dist/client/api/createClient.d.ts.map +1 -1
  12. package/dist/client/api/getModuleSettings.d.ts +25 -0
  13. package/dist/client/api/getModuleSettings.d.ts.map +1 -0
  14. package/dist/client/api/index.d.ts +1 -0
  15. package/dist/client/api/index.d.ts.map +1 -1
  16. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts +2 -0
  17. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts.map +1 -0
  18. package/dist/client/index.d.ts +1 -0
  19. package/dist/client/index.d.ts.map +1 -1
  20. package/dist/client/utils/parseModuleSettings.d.ts +9 -0
  21. package/dist/client/utils/parseModuleSettings.d.ts.map +1 -0
  22. package/dist/client/utils/resolveModuleAvailability.d.ts +39 -0
  23. package/dist/client/utils/resolveModuleAvailability.d.ts.map +1 -0
  24. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts +2 -0
  25. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts.map +1 -0
  26. package/dist/commentRepository/api/flagComment.d.ts +72 -5
  27. package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
  28. package/dist/commentRepository/internalApi/flagCommentWithOptions.d.ts +13 -0
  29. package/dist/commentRepository/internalApi/flagCommentWithOptions.d.ts.map +1 -0
  30. package/dist/commentRepository/internalApi/flagCommentWithReasonString.d.ts +17 -0
  31. package/dist/commentRepository/internalApi/flagCommentWithReasonString.d.ts.map +1 -0
  32. package/dist/commentRepository/internalApi/index.d.ts +2 -0
  33. package/dist/commentRepository/internalApi/index.d.ts.map +1 -1
  34. package/dist/commentRepository/internalApi/tests/integration/flagCommentWithOptions.integration.test.d.ts +2 -0
  35. package/dist/commentRepository/internalApi/tests/integration/flagCommentWithOptions.integration.test.d.ts.map +1 -0
  36. package/dist/commentRepository/internalApi/tests/integration/flagCommentWithReasonString.integration.test.d.ts +2 -0
  37. package/dist/commentRepository/internalApi/tests/integration/flagCommentWithReasonString.integration.test.d.ts.map +1 -0
  38. package/dist/core/errors.d.ts +20 -0
  39. package/dist/core/errors.d.ts.map +1 -1
  40. package/dist/core/transports/tests/integration/serverErrorCodes.integration.test.d.ts +2 -0
  41. package/dist/core/transports/tests/integration/serverErrorCodes.integration.test.d.ts.map +1 -0
  42. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts +2 -0
  43. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts.map +1 -0
  44. package/dist/core/transports/utils.d.ts.map +1 -1
  45. package/dist/index.cjs.js +673 -52
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.esm.js +672 -53
  49. package/dist/index.umd.js +2 -2
  50. package/dist/messageRepository/api/flagMessage.d.ts +73 -6
  51. package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
  52. package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts +2 -0
  53. package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts.map +1 -0
  54. package/dist/messageRepository/internalApi/flagMessageWithOptions.d.ts +13 -0
  55. package/dist/messageRepository/internalApi/flagMessageWithOptions.d.ts.map +1 -0
  56. package/dist/messageRepository/internalApi/flagMessageWithReasonString.d.ts +18 -0
  57. package/dist/messageRepository/internalApi/flagMessageWithReasonString.d.ts.map +1 -0
  58. package/dist/messageRepository/internalApi/tests/integration/flagMessageWithOptions.integration.test.d.ts +2 -0
  59. package/dist/messageRepository/internalApi/tests/integration/flagMessageWithOptions.integration.test.d.ts.map +1 -0
  60. package/dist/messageRepository/internalApi/tests/integration/flagMessageWithReasonString.integration.test.d.ts +2 -0
  61. package/dist/messageRepository/internalApi/tests/integration/flagMessageWithReasonString.integration.test.d.ts.map +1 -0
  62. package/dist/postRepository/api/flagPost.d.ts +73 -6
  63. package/dist/postRepository/api/flagPost.d.ts.map +1 -1
  64. package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts +2 -0
  65. package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts.map +1 -0
  66. package/dist/postRepository/internalApi/flagPostWithOptions.d.ts +13 -0
  67. package/dist/postRepository/internalApi/flagPostWithOptions.d.ts.map +1 -0
  68. package/dist/postRepository/internalApi/flagPostWithReasonString.d.ts +17 -0
  69. package/dist/postRepository/internalApi/flagPostWithReasonString.d.ts.map +1 -0
  70. package/dist/postRepository/internalApi/index.d.ts +2 -0
  71. package/dist/postRepository/internalApi/index.d.ts.map +1 -1
  72. package/dist/postRepository/internalApi/tests/integration/flagPostWithOptions.integration.test.d.ts +2 -0
  73. package/dist/postRepository/internalApi/tests/integration/flagPostWithOptions.integration.test.d.ts.map +1 -0
  74. package/dist/postRepository/internalApi/tests/integration/flagPostWithReasonString.integration.test.d.ts +2 -0
  75. package/dist/postRepository/internalApi/tests/integration/flagPostWithReasonString.integration.test.d.ts.map +1 -0
  76. package/dist/userRepository/api/flagUser.d.ts +50 -9
  77. package/dist/userRepository/api/flagUser.d.ts.map +1 -1
  78. package/dist/userRepository/api/flagUserBehavior.d.ts +29 -0
  79. package/dist/userRepository/api/flagUserBehavior.d.ts.map +1 -0
  80. package/dist/userRepository/api/flagUserProfile.d.ts +29 -0
  81. package/dist/userRepository/api/flagUserProfile.d.ts.map +1 -0
  82. package/dist/userRepository/api/index.d.ts +2 -0
  83. package/dist/userRepository/api/index.d.ts.map +1 -1
  84. package/dist/userRepository/api/tests/integration/flagUser.overloads.integration.test.d.ts +2 -0
  85. package/dist/userRepository/api/tests/integration/flagUser.overloads.integration.test.d.ts.map +1 -0
  86. package/dist/userRepository/api/tests/integration/flagUserBehavior.integration.test.d.ts +2 -0
  87. package/dist/userRepository/api/tests/integration/flagUserBehavior.integration.test.d.ts.map +1 -0
  88. package/dist/userRepository/api/tests/integration/flagUserProfile.integration.test.d.ts +2 -0
  89. package/dist/userRepository/api/tests/integration/flagUserProfile.integration.test.d.ts.map +1 -0
  90. package/dist/userRepository/utils/submitUserReport.d.ts +10 -0
  91. package/dist/userRepository/utils/submitUserReport.d.ts.map +1 -0
  92. package/dist/userRepository/utils/userReport.d.ts +35 -0
  93. package/dist/userRepository/utils/userReport.d.ts.map +1 -0
  94. package/dist/utils/contentFlag.d.ts +28 -0
  95. package/dist/utils/contentFlag.d.ts.map +1 -0
  96. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -58,6 +58,18 @@ exports.UserReportTypeEnum = void 0;
58
58
  UserReportTypeEnum["AVATAR"] = "avatarFileId";
59
59
  UserReportTypeEnum["BEHAVIOR"] = "behavior";
60
60
  })(exports.UserReportTypeEnum || (exports.UserReportTypeEnum = {}));
61
+ /**
62
+ * The profile field a user is reported for in `UserRepository.flagUserProfile`.
63
+ * Each member is the backend `reportType` wire value. There is deliberately no
64
+ * behavior member: behavior reports need a reason and go through
65
+ * `UserRepository.flagUserBehavior`.
66
+ */
67
+ exports.UserProfileFieldEnum = void 0;
68
+ (function (UserProfileFieldEnum) {
69
+ UserProfileFieldEnum["DISPLAY_NAME"] = "displayName";
70
+ UserProfileFieldEnum["DESCRIPTION"] = "description";
71
+ UserProfileFieldEnum["AVATAR"] = "avatarFileId";
72
+ })(exports.UserProfileFieldEnum || (exports.UserProfileFieldEnum = {}));
61
73
 
62
74
  const FileType = Object.freeze({
63
75
  FILE: 'file',
@@ -812,6 +824,40 @@ class ASCConnectionError extends ASCError {
812
824
  this.event = event;
813
825
  }
814
826
  }
827
+ /**
828
+ * Thrown when the network does not own a module the call needs. Raised from
829
+ * any module endpoint under `enforce` enforcement, mapped from app code
830
+ * `400325` — never from HTTP 403 alone, which already covers a role problem
831
+ * (`400300` / `400301`), a visitor (`403999`) and a bot (`403998`).
832
+ *
833
+ * `modules` carries **every** key the refusal named, as raw strings, so a
834
+ * caller can say which entitlement is absent without a second request.
835
+ *
836
+ * @category Errors
837
+ */
838
+ class AmityModuleNotEntitledError extends ASCApiError {
839
+ /**
840
+ * @param message The server's message, e.g. `Module not entitled: chat, live`
841
+ * @param modules Every module key from the rejection's `data.modules`
842
+ */
843
+ constructor(message, modules = []) {
844
+ super(message, 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */, "error" /* Amity.ErrorLevel.ERROR */);
845
+ this.modules = modules;
846
+ this.type = 'AmityModuleNotEntitledError';
847
+ }
848
+ }
849
+ /**
850
+ * Input sanitization related error
851
+ * @category Errors
852
+ */
853
+ class ASCInvalidParameterError extends ASCError {
854
+ /**
855
+ * @param message A custom error message
856
+ */
857
+ constructor(message) {
858
+ super(message, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
859
+ }
860
+ }
815
861
 
816
862
  let activeClient = null;
817
863
  /**
@@ -1961,6 +2007,22 @@ function computeUrl(type, region) {
1961
2007
 
1962
2008
  const uuid = () => uuid__default["default"].v4().toString();
1963
2009
 
2010
+ /**
2011
+ * Reads the module keys a `MODULE_NOT_ENTITLED` rejection named.
2012
+ *
2013
+ * Every entry is kept, as a raw string: one call can need more than one
2014
+ * module, and a key this build predates is still the only part of the
2015
+ * payload a customer can act on.
2016
+ *
2017
+ * @category Transport
2018
+ * @hidden
2019
+ */
2020
+ const extractNotEntitledModules = (data) => {
2021
+ const { modules } = data !== null && data !== void 0 ? data : {};
2022
+ if (!Array.isArray(modules))
2023
+ return [];
2024
+ return modules.filter((module) => typeof module === 'string');
2025
+ };
1964
2026
  /**
1965
2027
  * Unwraps v3 server payload (for error handling and type extraction)
1966
2028
  *
@@ -1980,6 +2042,15 @@ const unwrapPayload = (response) => {
1980
2042
  throw new ASCUnknownError(response.code);
1981
2043
  }
1982
2044
  else if (response.status === 'error') {
2045
+ /*
2046
+ * An entitlement refusal must not arrive as a generic failure: a customer
2047
+ * cannot then tell a module they have not bought from an outage. Keyed on
2048
+ * the app code, never on the HTTP status, so a role or membership problem
2049
+ * still maps to the generic error.
2050
+ */
2051
+ if (response.code === 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */) {
2052
+ throw new AmityModuleNotEntitledError(response.message, extractNotEntitledModules(response.data));
2053
+ }
1983
2054
  throw new ASCApiError(response.message, response.code, "error" /* Amity.ErrorLevel.ERROR */);
1984
2055
  }
1985
2056
  // unjust, but helps force uncast "T | undefined" to allow deconstruction without warnings
@@ -5476,6 +5547,95 @@ const getForYouFeedSetting = async () => {
5476
5547
  };
5477
5548
  /* end_public_function */
5478
5549
 
5550
+ const ENFORCEMENT_MODES = ['off', 'shadow', 'enforce'];
5551
+ /**
5552
+ * An unrecognised mode decodes to `off`, and so does an absent one. A mode
5553
+ * this build does not know must not withhold anything — defaulting to
5554
+ * `enforce` would let a server-side rename black out a customer's app.
5555
+ *
5556
+ * @category private
5557
+ */
5558
+ const parseEnforcement = (mode) => {
5559
+ const match = ENFORCEMENT_MODES.find(value => value === mode);
5560
+ return match !== null && match !== void 0 ? match : 'off';
5561
+ };
5562
+ const parseGrants = (modules) => {
5563
+ const grants = {};
5564
+ Object.entries(modules !== null && modules !== void 0 ? modules : {}).forEach(([key, granted]) => {
5565
+ grants[key] = granted === true;
5566
+ });
5567
+ return grants;
5568
+ };
5569
+ /**
5570
+ * Every catalog entry survives, including one whose key this build has never
5571
+ * heard of, so a module added server-side is still listable.
5572
+ *
5573
+ * @category private
5574
+ */
5575
+ const parseCatalog = (catalog) => {
5576
+ const parsed = {};
5577
+ Object.entries(catalog !== null && catalog !== void 0 ? catalog : {}).forEach(([key, definition]) => {
5578
+ const rawRequires = definition === null || definition === void 0 ? void 0 : definition.requires;
5579
+ const requires = Array.isArray(rawRequires)
5580
+ ? rawRequires.filter((entry) => typeof entry === 'string')
5581
+ : [];
5582
+ parsed[key] = {
5583
+ label: typeof (definition === null || definition === void 0 ? void 0 : definition.label) === 'string' ? definition.label : key,
5584
+ kind: (definition === null || definition === void 0 ? void 0 : definition.kind) === 'setting' ? 'setting' : 'api',
5585
+ requires,
5586
+ };
5587
+ });
5588
+ return parsed;
5589
+ };
5590
+ /**
5591
+ * Decodes `GET /api/v3/network-settings/modules`. Nothing is trimmed: the
5592
+ * catalog is the dependency table callers resolve against, and a client that
5593
+ * cannot see it has to hardcode one.
5594
+ *
5595
+ * @category private
5596
+ */
5597
+ const parseModuleSettings = (raw) => {
5598
+ var _a;
5599
+ return ({
5600
+ enforcement: parseEnforcement((_a = raw === null || raw === void 0 ? void 0 : raw.enforcement) !== null && _a !== void 0 ? _a : raw === null || raw === void 0 ? void 0 : raw.mode),
5601
+ modules: parseGrants(raw === null || raw === void 0 ? void 0 : raw.modules),
5602
+ catalog: parseCatalog(raw === null || raw === void 0 ? void 0 : raw.catalog),
5603
+ });
5604
+ };
5605
+
5606
+ /* begin_public_function
5607
+ id: client.getModuleSettings
5608
+ */
5609
+ /**
5610
+ * ```js
5611
+ * import { Client } from '@amityco/ts-sdk'
5612
+ * const moduleSettings = await Client.getModuleSettings()
5613
+ * ```
5614
+ *
5615
+ * Fetches the network's module entitlements: which modules the network was
5616
+ * granted, whether core is enforcing those grants, and the catalog of all
5617
+ * modules with their dependency chains.
5618
+ *
5619
+ * The payload is returned whole — `catalog` is the dependency table
5620
+ * {@link resolveModuleAvailability} reads, and a client that cannot see it has
5621
+ * to hardcode one.
5622
+ *
5623
+ * The read is **advisory**. It tells a host what to offer; under `enforce` the
5624
+ * backend refuses a call to an unowned module regardless of what was resolved
5625
+ * here, and that refusal arrives as `AmityModuleNotEntitledError`.
5626
+ *
5627
+ * @returns A Promise of {@link Amity.ModuleSettings} object
5628
+ *
5629
+ * @category Client API
5630
+ * @async
5631
+ */
5632
+ const getModuleSettings = async () => {
5633
+ const client = getActiveClient();
5634
+ const { data } = await client.http.get(`/api/v3/network-settings/modules`);
5635
+ return parseModuleSettings(data);
5636
+ };
5637
+ /* end_public_function */
5638
+
5479
5639
  const checkUserPermission = (userId, permission) => {
5480
5640
  var _a;
5481
5641
  const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -9200,6 +9360,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
9200
9360
  getMarkerSyncConsistentMode,
9201
9361
  getProductCatalogueSetting,
9202
9362
  getForYouFeedSetting,
9363
+ getModuleSettings,
9203
9364
  /**
9204
9365
  * Prefix for the deviceId key in the local storage or async storage.
9205
9366
  * This is allow user to have multiple SDK client and Mqtt client within the same app.
@@ -10245,6 +10406,92 @@ const getUserUnread = (callback) => {
10245
10406
  };
10246
10407
  };
10247
10408
 
10409
+ /**
10410
+ * ```js
10411
+ * import { Client, resolveModuleAvailability } from '@amityco/ts-sdk'
10412
+ *
10413
+ * const moduleSettings = await Client.getModuleSettings()
10414
+ *
10415
+ * if (resolveModuleAvailability(moduleSettings, 'live').isAvailable) {
10416
+ * // offer the Live entry point
10417
+ * }
10418
+ * ```
10419
+ *
10420
+ * Resolves whether one module is usable on this network.
10421
+ *
10422
+ * Availability is a function of all three fields of
10423
+ * {@link Amity.ModuleSettings} — the enforcement mode, the module's own grant,
10424
+ * and its prerequisite chain — combined in that order. Reading `modules`
10425
+ * directly contradicts the mode: staging answers `mode: 'off'` with
10426
+ * `modules: {}`, and every module still works.
10427
+ *
10428
+ * The dependency table comes from the payload's `catalog`, never from a
10429
+ * hardcoded copy, so a chain the backend changes takes effect without an SDK
10430
+ * release.
10431
+ *
10432
+ * The SDK does not hold the settings — the caller keeps what it fetched and
10433
+ * resolves against it. With no settings at all (a fetch that never succeeded)
10434
+ * the caller reads that as every module available: under `enforce` the backend
10435
+ * refuses the calls anyway, so the exposure is a screen that offers too much,
10436
+ * not one that withholds what a customer paid for.
10437
+ *
10438
+ * @param moduleSettings The network's module settings
10439
+ * @param moduleKey The module to resolve — an {@link Amity.ModuleKey}, so the
10440
+ * 15 keys this build knows complete and type-check while a catalog entry it
10441
+ * does not know still resolves.
10442
+ * @returns An {@link Amity.ModuleAvailability} answer
10443
+ *
10444
+ * @category Client API
10445
+ */
10446
+ const resolveModuleAvailability = (moduleSettings, moduleKey, seen = new Set()) => {
10447
+ var _a, _b, _c, _d, _e;
10448
+ const isGranted = (_a = moduleSettings.modules[moduleKey]) !== null && _a !== void 0 ? _a : false;
10449
+ /*
10450
+ * Not enforcing: nothing is withheld, and no graph walk is needed. This has
10451
+ * to come first — `off` and `shadow` resolve available whatever the grant
10452
+ * says, and a cycle would otherwise return unavailable under `off` too.
10453
+ */
10454
+ if (moduleSettings.enforcement !== 'enforce') {
10455
+ return { moduleKey, isAvailable: true, isGranted };
10456
+ }
10457
+ // A cycle in `requires` resolves unavailable rather than recursing.
10458
+ if (seen.has(moduleKey)) {
10459
+ return {
10460
+ moduleKey,
10461
+ isAvailable: false,
10462
+ isGranted,
10463
+ reason: 'prerequisiteUnavailable',
10464
+ unsatisfied: (_c = (_b = moduleSettings.catalog[moduleKey]) === null || _b === void 0 ? void 0 : _b.requires) !== null && _c !== void 0 ? _c : [],
10465
+ };
10466
+ }
10467
+ // The module's own grant is evaluated before its prerequisites, so
10468
+ // `notGranted` is reported in preference when both hold.
10469
+ if (!isGranted) {
10470
+ return { moduleKey, isAvailable: false, isGranted, reason: 'notGranted' };
10471
+ }
10472
+ const requires = (_e = (_d = moduleSettings.catalog[moduleKey]) === null || _d === void 0 ? void 0 : _d.requires) !== null && _e !== void 0 ? _e : [];
10473
+ if (requires.length === 0)
10474
+ return { moduleKey, isAvailable: true, isGranted };
10475
+ // `requires` is satisfied by any one entry, transitively.
10476
+ const isSatisfied = requires.some(dependency => resolveModuleAvailability(moduleSettings, dependency, new Set([...seen, moduleKey]))
10477
+ .isAvailable);
10478
+ if (isSatisfied)
10479
+ return { moduleKey, isAvailable: true, isGranted };
10480
+ /*
10481
+ * `unsatisfied` carries the whole `requires` list rather than one entry. Any
10482
+ * one of them would have satisfied the requirement, so naming a single
10483
+ * module misdirects: telling a Community-only customer "Comment needs post"
10484
+ * hides that Story would also have done.
10485
+ */
10486
+ return {
10487
+ moduleKey,
10488
+ isAvailable: false,
10489
+ isGranted,
10490
+ reason: 'prerequisiteUnavailable',
10491
+ unsatisfied: requires,
10492
+ };
10493
+ };
10494
+
10248
10495
  var index$t = /*#__PURE__*/Object.freeze({
10249
10496
  __proto__: null,
10250
10497
  getActiveClient: getActiveClient,
@@ -10268,6 +10515,7 @@ var index$t = /*#__PURE__*/Object.freeze({
10268
10515
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10269
10516
  getProductCatalogueSetting: getProductCatalogueSetting,
10270
10517
  getForYouFeedSetting: getForYouFeedSetting,
10518
+ getModuleSettings: getModuleSettings,
10271
10519
  loginAsVisitor: loginAsVisitor,
10272
10520
  loginAsBot: loginAsBot,
10273
10521
  getCurrentUser: getCurrentUser,
@@ -10295,7 +10543,8 @@ var index$t = /*#__PURE__*/Object.freeze({
10295
10543
  startMarkerSync: startMarkerSync,
10296
10544
  startUnreadSync: startUnreadSync,
10297
10545
  stopUnreadSync: stopUnreadSync,
10298
- getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
10546
+ getMarkerSyncConsistentMode: getMarkerSyncConsistentMode,
10547
+ resolveModuleAvailability: resolveModuleAvailability
10299
10548
  });
10300
10549
 
10301
10550
  /* begin_public_function
@@ -13226,7 +13475,7 @@ const getWatchSessionStorage = () => {
13226
13475
  return storageInstance;
13227
13476
  };
13228
13477
 
13229
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8U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*
13231
13480
  * The crypto algorithm used for importing key and signing string
13232
13481
  */
@@ -15025,18 +15274,18 @@ const buildFlagUserBody = (options) => {
15025
15274
  /**
15026
15275
  * ```js
15027
15276
  * import { UserRepository } from '@amityco/ts-sdk'
15277
+ *
15278
+ * // Typeless report (supported).
15028
15279
  * const flagged = await UserRepository.flagUser('userId')
15029
- * const flaggedBehavior = await UserRepository.flagUser('userId', {
15030
- * reportType: 'behavior',
15031
- * reason: 'Harassment or bullying',
15032
- * comment: 'optional free-text',
15033
- * })
15034
15280
  * ```
15035
15281
  *
15282
+ * Flags a user. Two call shapes are accepted (see the overloads): id-only, which
15283
+ * sends no body and stays supported, and the deprecated structured options object,
15284
+ * whose request mapping is unchanged. New code reporting a profile field or behavior
15285
+ * should use `flagUserProfile` or `flagUserBehavior`.
15286
+ *
15036
15287
  * @param userId The ID of the user to be flagged
15037
- * @param options Optional report metadata forwarded to the server as the request
15038
- * body: `reportType`, `reason`, `comment`. Only non-null fields are included.
15039
- * All validation is server-side; a bodyless call produces a typeless report.
15288
+ * @param options Deprecated report metadata; omit for a typeless report
15040
15289
  * @returns the flagged {@link Amity.User}
15041
15290
  *
15042
15291
  * @category User API
@@ -15057,6 +15306,156 @@ const flagUser = async (userId, options) => {
15057
15306
  };
15058
15307
  /* end_public_function */
15059
15308
 
15309
+ /**
15310
+ * Sends a validated split user report (`flagUserProfile` / `flagUserBehavior`) to the
15311
+ * same endpoint as `flagUser`, then persists the returned user and fires `user.flagged`
15312
+ * exactly as `flagUser` does, so all three calls share return, cache and event behaviour.
15313
+ *
15314
+ * Not exported from the public API.
15315
+ */
15316
+ const submitUserReport = async (apiName, userId, body) => {
15317
+ var _a;
15318
+ const client = getActiveClient();
15319
+ client.log(`user/${apiName}`, { userId, body });
15320
+ const { data } = await client.http.post(`/api/v4/me/flags/${encodeURIComponent(userId)}`, body);
15321
+ const payload = prepareUserPayload(data);
15322
+ if (client.cache) {
15323
+ ingestInCache(payload);
15324
+ }
15325
+ fireEvent('user.flagged', data);
15326
+ return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
15327
+ };
15328
+
15329
+ /** Maximum `comment` length, in string length units, after trimming. */
15330
+ const USER_REPORT_COMMENT_MAX_LENGTH = 300;
15331
+ const PROFILE_FIELDS = Object.values(exports.UserProfileFieldEnum);
15332
+ const BEHAVIOR_REASONS = Object.values(exports.ContentFlagReasonEnum);
15333
+ const assertOptionsObject = (apiName, options, shape) => {
15334
+ if (typeof options !== 'object' || options === null || Array.isArray(options)) {
15335
+ throw new ASCInvalidParameterError(`${apiName}: expected an options object \`${shape}\``);
15336
+ }
15337
+ return options;
15338
+ };
15339
+ /**
15340
+ * Normalizes an optional reporter `comment`: it must be a string when supplied (`null`
15341
+ * is not a valid supplied comment); it is trimmed; a blank result is omitted (the
15342
+ * backend rejects `""`); a result longer than 300 characters is rejected before any
15343
+ * request. Otherwise the trimmed text is returned unchanged.
15344
+ *
15345
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` for a non-string or over-length comment
15346
+ */
15347
+ const normalizeUserReportComment = (apiName, comment) => {
15348
+ if (comment === undefined)
15349
+ return undefined;
15350
+ if (typeof comment !== 'string') {
15351
+ throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be a string when supplied`);
15352
+ }
15353
+ const trimmed = comment.trim();
15354
+ if (trimmed.length === 0)
15355
+ return undefined;
15356
+ if (trimmed.length > USER_REPORT_COMMENT_MAX_LENGTH) {
15357
+ throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be at most ${USER_REPORT_COMMENT_MAX_LENGTH} characters after trimming`);
15358
+ }
15359
+ return trimmed;
15360
+ };
15361
+ const withComment = (body, comment) => comment === undefined ? body : Object.assign(Object.assign({}, body), { comment });
15362
+ /**
15363
+ * Validates `flagUserProfile` options and builds its request body. Untyped callers can
15364
+ * pass anything at runtime, so nothing is trusted from the declared type. Any `reason`
15365
+ * key is ignored and never sent.
15366
+ *
15367
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
15368
+ */
15369
+ const toUserProfileReportBody = (options) => {
15370
+ const apiName = 'flagUserProfile';
15371
+ const { field, comment } = assertOptionsObject(apiName, options, '{ field, comment? }');
15372
+ if (typeof field !== 'string' || !PROFILE_FIELDS.includes(field)) {
15373
+ throw new ASCInvalidParameterError(`${apiName}: \`field\` must be a \`UserProfileFieldEnum\` value`);
15374
+ }
15375
+ return withComment({ reportType: field }, normalizeUserReportComment(apiName, comment));
15376
+ };
15377
+ /**
15378
+ * Validates `flagUserBehavior` options and builds its request body. `reason` must be one
15379
+ * of the nine `ContentFlagReasonEnum` values and is sent as that canonical label;
15380
+ * `reportType` is always `behavior`.
15381
+ *
15382
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
15383
+ */
15384
+ const toUserBehaviorReportBody = (options) => {
15385
+ const apiName = 'flagUserBehavior';
15386
+ const { reason, comment } = assertOptionsObject(apiName, options, '{ reason, comment? }');
15387
+ if (typeof reason !== 'string' || !BEHAVIOR_REASONS.includes(reason)) {
15388
+ throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
15389
+ }
15390
+ return withComment({ reportType: 'behavior', reason }, normalizeUserReportComment(apiName, comment));
15391
+ };
15392
+
15393
+ /* begin_public_function
15394
+ id: user.flag_profile
15395
+ */
15396
+ /**
15397
+ * ```js
15398
+ * import { UserRepository, UserProfileFieldEnum } from '@amityco/ts-sdk'
15399
+ * const flagged = await UserRepository.flagUserProfile('userId', {
15400
+ * field: UserProfileFieldEnum.AVATAR,
15401
+ * comment: 'Nudity in profile photo',
15402
+ * })
15403
+ * ```
15404
+ *
15405
+ * Reports one of a user's profile fields (display name, description or avatar). The
15406
+ * call has no reason: profile reports never carry one, so the backend's reason rules
15407
+ * cannot be violated from here. A `reason` key passed at runtime is ignored and never sent.
15408
+ *
15409
+ * `comment` is trimmed; a blank comment is omitted from the request; a comment longer
15410
+ * than 300 characters after trimming is rejected before any request. Otherwise the
15411
+ * trimmed text is sent unchanged.
15412
+ *
15413
+ * Sends `POST /api/v4/me/flags/:userId` with `{ reportType: <field>, comment? }`.
15414
+ *
15415
+ * @param userId The ID of the user to be reported
15416
+ * @param options `field` is a `UserProfileFieldEnum` value; `comment` is optional free text
15417
+ * @returns the flagged {@link Amity.User}
15418
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, or `comment` is over 300 characters, before any request is made
15419
+ *
15420
+ * @category User API
15421
+ * @async
15422
+ * */
15423
+ const flagUserProfile = async (userId, options) => submitUserReport('flagUserProfile', userId, toUserProfileReportBody(options));
15424
+ /* end_public_function */
15425
+
15426
+ /* begin_public_function
15427
+ id: user.flag_behavior
15428
+ */
15429
+ /**
15430
+ * ```js
15431
+ * import { UserRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
15432
+ * const flagged = await UserRepository.flagUserBehavior('userId', {
15433
+ * reason: ContentFlagReasonEnum.Others,
15434
+ * comment: 'Impersonating our brand',
15435
+ * })
15436
+ * ```
15437
+ *
15438
+ * Reports a user's behavior. `reason` is required and is one of the nine
15439
+ * `ContentFlagReasonEnum` values, sent as its canonical label. Reporter text, including
15440
+ * the explanation for `Others`, always travels in `comment`; the reason never carries text.
15441
+ *
15442
+ * `comment` is trimmed; a blank comment is omitted from the request; a comment longer
15443
+ * than 300 characters after trimming is rejected before any request. Otherwise the
15444
+ * trimmed text is sent unchanged.
15445
+ *
15446
+ * Sends `POST /api/v4/me/flags/:userId` with `{ reportType: 'behavior', reason, comment? }`.
15447
+ *
15448
+ * @param userId The ID of the user to be reported
15449
+ * @param options `reason` is a `ContentFlagReasonEnum` value; `comment` is optional free text
15450
+ * @returns the flagged {@link Amity.User}
15451
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, `reason` is missing or unknown, or `comment` is over 300 characters, before any request is made
15452
+ *
15453
+ * @category User API
15454
+ * @async
15455
+ * */
15456
+ const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBehavior', userId, toUserBehaviorReportBody(options));
15457
+ /* end_public_function */
15458
+
15060
15459
  /* begin_public_function
15061
15460
  id: user.unflag
15062
15461
  */
@@ -16231,6 +16630,8 @@ var index$r = /*#__PURE__*/Object.freeze({
16231
16630
  getUserByIds: getUserByIds,
16232
16631
  updateUser: updateUser,
16233
16632
  flagUser: flagUser,
16633
+ flagUserProfile: flagUserProfile,
16634
+ flagUserBehavior: flagUserBehavior,
16234
16635
  unflagUser: unflagUser,
16235
16636
  isUserFlaggedByMe: isUserFlaggedByMe,
16236
16637
  getAllBlockedUsers: getAllBlockedUsers,
@@ -19935,23 +20336,85 @@ getDeliveredUsers.locally = (query) => {
19935
20336
  return { data: users, cachedAt, prevPage, nextPage };
19936
20337
  };
19937
20338
 
19938
- /* begin_public_function
19939
- id: message.flag
19940
- */
20339
+ const CONTENT_FLAG_REASONS = Object.values(exports.ContentFlagReasonEnum);
19941
20340
  /**
19942
- * ```js
19943
- * import { MessageRepository } from '@amityco/ts-sdk'
19944
- * const flagged = await MessageRepository.flagMessage(messageId, reason)
19945
- * ```
20341
+ * True when a public `flagX(id, input)` argument is the legacy shape (a reason string
20342
+ * or nothing). Anything else is routed to the `Amity.ContentFlagOptions` path, whose
20343
+ * validation rejects malformed values before any request is made.
20344
+ */
20345
+ const isLegacyContentFlagReason = (input) => input === undefined || typeof input === 'string';
20346
+ /**
20347
+ * Validates an `Amity.ContentFlagOptions` argument. Untyped (plain JS) callers can pass
20348
+ * anything at runtime, so the checks do not trust the declared type: the value must be a
20349
+ * plain object, `reason` must be one of the nine `ContentFlagReasonEnum` values and
20350
+ * `detail`, when supplied, must be a string (`null` is not a valid supplied detail).
19946
20351
  *
19947
- * @param messageId of the message to flag
19948
- * @param reason the reason to flag the message
19949
- * @returns the created report result
20352
+ * @param apiName used in the error message, e.g. `flagPost`
20353
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
20354
+ */
20355
+ const validateContentFlagOptions = (apiName, options) => {
20356
+ if (typeof options !== 'object' || options === null || Array.isArray(options)) {
20357
+ throw new ASCInvalidParameterError(`${apiName}: expected an options object \`{ reason, detail? }\``);
20358
+ }
20359
+ const { reason, detail } = options;
20360
+ if (typeof reason !== 'string' || !CONTENT_FLAG_REASONS.includes(reason)) {
20361
+ throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
20362
+ }
20363
+ if (detail !== undefined && typeof detail !== 'string') {
20364
+ throw new ASCInvalidParameterError(`${apiName}: \`detail\` must be a string when supplied`);
20365
+ }
20366
+ return { reason: reason, detail };
20367
+ };
20368
+ /**
20369
+ * Builds the request body for validated options. `detail` is forwarded unchanged (empty
20370
+ * and whitespace-only strings included) and omitted from the body when `undefined`; the
20371
+ * backend enforces the 300-character limit.
20372
+ */
20373
+ const toContentFlagBody = ({ reason, detail }) => detail === undefined ? { reason } : { reason, detail };
20374
+
20375
+ /**
20376
+ * New `flagMessage(messageId, { reason, detail? })` implementation. Any category,
20377
+ * including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
20378
+ * whitespace-only strings included) and omitted from the request body when `undefined`;
20379
+ * the backend enforces the 300-character limit.
19950
20380
  *
19951
- * @category Message API
19952
- * @async
19953
- * */
19954
- const flagMessage = async (messageId, reason) => {
20381
+ * Not exported from the public API. It is reached through the
20382
+ * `MessageRepository.flagMessage(messageId, options)` overload; see `api/flagMessage.ts`.
20383
+ *
20384
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
20385
+ */
20386
+ const flagMessageWithOptions = async (messageId, options) => {
20387
+ // Validate first: an input error must surface as INVALID_PARAMETERS regardless of
20388
+ // whether a client is active, and validation needs nothing from the client.
20389
+ const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
20390
+ const client = getActiveClient();
20391
+ client.log('message/flag', messageId);
20392
+ const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
20393
+ if (client.cache) {
20394
+ const messagePayload = await prepareMessagePayload(payload);
20395
+ ingestInCache(messagePayload);
20396
+ }
20397
+ fireEvent('message.flagged', payload);
20398
+ return !!payload;
20399
+ };
20400
+
20401
+ /**
20402
+ * Legacy `flagMessage(messageId, reason?)` implementation, kept verbatim so existing
20403
+ * callers keep the exact request body they had before the options contract existed:
20404
+ *
20405
+ * - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
20406
+ * - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
20407
+ * - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
20408
+ * (for `undefined` the message body carries `detail: undefined`, which JSON serialization omits)
20409
+ *
20410
+ * Not exported from the public API. It is reached through the deprecated
20411
+ * `MessageRepository.flagMessage(messageId, reason)` overload; see `api/flagMessage.ts`.
20412
+ *
20413
+ * Not itself deprecated: it implements the deprecated legacy-string overload of the public
20414
+ * `flagMessage`, which carries the deprecation tag. New code should use `flagMessageWithOptions`
20415
+ * (the `{ reason, detail? }` contract). This path stays available throughout the current major version.
20416
+ */
20417
+ const flagMessageWithReasonString = async (messageId, reason) => {
19955
20418
  const client = getActiveClient();
19956
20419
  client.log('message/flag', messageId);
19957
20420
  const isPredefinedReason = reason &&
@@ -19968,6 +20431,42 @@ const flagMessage = async (messageId, reason) => {
19968
20431
  fireEvent('message.flagged', payload);
19969
20432
  return !!payload;
19970
20433
  };
20434
+
20435
+ /* begin_public_function
20436
+ id: message.flag
20437
+ */
20438
+ /**
20439
+ * ```js
20440
+ * import { MessageRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
20441
+ *
20442
+ * // No reason.
20443
+ * await MessageRepository.flagMessage(messageId)
20444
+ *
20445
+ * // Category plus optional reporter context (any category, including Others).
20446
+ * await MessageRepository.flagMessage(messageId, {
20447
+ * reason: ContentFlagReasonEnum.SpamOrScams,
20448
+ * detail: 'Repeated promotional links',
20449
+ * })
20450
+ * ```
20451
+ *
20452
+ * Reports a message to moderation. Three call shapes are accepted (see the overloads):
20453
+ * id-only, an options object, and the deprecated legacy reason string. The public
20454
+ * name only dispatches on the input shape; the two implementations are kept separate
20455
+ * so the legacy path is untouched by the new contract:
20456
+ *
20457
+ * - `undefined` or a string → `flagMessageWithReasonString` (unchanged legacy mapping)
20458
+ * - anything else → `flagMessageWithOptions` (validated `{ reason, detail? }`)
20459
+ *
20460
+ * @param messageId The ID of the message to flag
20461
+ * @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
20462
+ * @returns `true` when the report was created
20463
+ *
20464
+ * @category Message API
20465
+ * @async
20466
+ * */
20467
+ const flagMessage = (messageId, input) => isLegacyContentFlagReason(input)
20468
+ ? flagMessageWithReasonString(messageId, input)
20469
+ : flagMessageWithOptions(messageId, input);
19971
20470
  /* end_public_function */
19972
20471
 
19973
20472
  /* begin_public_function
@@ -27113,23 +27612,22 @@ const declineComment = async (commentId, reason) => {
27113
27612
  };
27114
27613
  /* end_public_function */
27115
27614
 
27116
- /* begin_public_function
27117
- id: comment.flag
27118
- */
27119
27615
  /**
27120
- * ```js
27121
- * import { CommentRepository } from '@amityco/ts-sdk'
27122
- * const flagged = await CommentRepository.flagComment(commentId, reason)
27123
- * ```
27616
+ * Legacy `flagComment(commentId, reason?)` implementation, kept verbatim so existing
27617
+ * callers keep the exact request body they had before the options contract existed:
27124
27618
  *
27125
- * @param commentId The ID of the comment to flag
27126
- * @param reason the reason to flag the comment
27127
- * @returns the created report result
27619
+ * - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
27620
+ * - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
27621
+ * - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
27128
27622
  *
27129
- * @category Comment API
27130
- * @async
27131
- * */
27132
- const flagComment = async (commentId, reason) => {
27623
+ * Not exported from the public API. It is reached through the deprecated
27624
+ * `CommentRepository.flagComment(commentId, reason)` overload; see `api/flagComment.ts`.
27625
+ *
27626
+ * Not itself deprecated: it implements the deprecated legacy-string overload of the public
27627
+ * `flagComment`, which carries the deprecation tag. New code should use `flagCommentWithOptions`
27628
+ * (the `{ reason, detail? }` contract). This path stays available throughout the current major version.
27629
+ */
27630
+ const flagCommentWithReasonString = async (commentId, reason) => {
27133
27631
  const client = getActiveClient();
27134
27632
  client.log('comment/flagComment', commentId);
27135
27633
  const isPredefinedReason = reason &&
@@ -27145,6 +27643,67 @@ const flagComment = async (commentId, reason) => {
27145
27643
  fireEvent('comment.flagged', payload);
27146
27644
  return !!payload;
27147
27645
  };
27646
+
27647
+ /**
27648
+ * New `flagComment(commentId, { reason, detail? })` implementation. Any category,
27649
+ * including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
27650
+ * whitespace-only strings included) and omitted from the request body when `undefined`;
27651
+ * the backend enforces the 300-character limit.
27652
+ *
27653
+ * Not exported from the public API. It is reached through the
27654
+ * `CommentRepository.flagComment(commentId, options)` overload; see `api/flagComment.ts`.
27655
+ *
27656
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
27657
+ */
27658
+ const flagCommentWithOptions = async (commentId, options) => {
27659
+ // Validate first: an input error must surface as INVALID_PARAMETERS regardless of
27660
+ // whether a client is active, and validation needs nothing from the client.
27661
+ const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
27662
+ const client = getActiveClient();
27663
+ client.log('comment/flagComment', commentId);
27664
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
27665
+ if (client.cache) {
27666
+ ingestInCache(payload);
27667
+ }
27668
+ fireEvent('comment.flagged', payload);
27669
+ return !!payload;
27670
+ };
27671
+
27672
+ /* begin_public_function
27673
+ id: comment.flag
27674
+ */
27675
+ /**
27676
+ * ```js
27677
+ * import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
27678
+ *
27679
+ * // No reason: sent as Others with an empty detail.
27680
+ * await CommentRepository.flagComment(commentId)
27681
+ *
27682
+ * // Category plus optional reporter context (any category, including Others).
27683
+ * await CommentRepository.flagComment(commentId, {
27684
+ * reason: ContentFlagReasonEnum.SpamOrScams,
27685
+ * detail: 'Repeated promotional links',
27686
+ * })
27687
+ * ```
27688
+ *
27689
+ * Reports a comment to moderation. Three call shapes are accepted (see the overloads):
27690
+ * id-only, an options object, and the deprecated legacy reason string. The public
27691
+ * name only dispatches on the input shape; the two implementations are kept separate
27692
+ * so the legacy path is untouched by the new contract:
27693
+ *
27694
+ * - `undefined` or a string → `flagCommentWithReasonString` (unchanged legacy mapping)
27695
+ * - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
27696
+ *
27697
+ * @param commentId The ID of the comment to flag
27698
+ * @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
27699
+ * @returns `true` when the report was created
27700
+ *
27701
+ * @category Comment API
27702
+ * @async
27703
+ * */
27704
+ const flagComment = (commentId, input) => isLegacyContentFlagReason(input)
27705
+ ? flagCommentWithReasonString(commentId, input)
27706
+ : flagCommentWithOptions(commentId, input);
27148
27707
  /* end_public_function */
27149
27708
 
27150
27709
  /* begin_public_function
@@ -29498,23 +30057,47 @@ const declinePost = async (postId) => {
29498
30057
  };
29499
30058
  /* end_public_function */
29500
30059
 
29501
- /* begin_public_function
29502
- id: post.flag
29503
- */
29504
30060
  /**
29505
- * ```js
29506
- * import { PostRepository } from '@amityco/ts-sdk'
29507
- * const flagged = await PostRepository.flagPost(postId, reason)
29508
- * ```
30061
+ * New `flagPost(postId, { reason, detail? })` implementation. Any category, including
30062
+ * `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
30063
+ * whitespace-only strings included) and omitted from the request body when `undefined`;
30064
+ * the backend enforces the 300-character limit.
29509
30065
  *
29510
- * @param postId of the post to flag
29511
- * @param reason the reason to flag the post
29512
- * @returns a boolean
30066
+ * Not exported from the public API. It is reached through the
30067
+ * `PostRepository.flagPost(postId, options)` overload; see `api/flagPost.ts`.
29513
30068
  *
29514
- * @category Post API
29515
- * @async
29516
- * */
29517
- const flagPost = async (postId, reason) => {
30069
+ * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
30070
+ */
30071
+ const flagPostWithOptions = async (postId, options) => {
30072
+ // Validate first: an input error must surface as INVALID_PARAMETERS regardless of
30073
+ // whether a client is active, and validation needs nothing from the client.
30074
+ const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
30075
+ const client = getActiveClient();
30076
+ client.log('post/flagPost', postId);
30077
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
30078
+ if (client.cache) {
30079
+ ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
30080
+ }
30081
+ fireEvent('post.flagged', payload);
30082
+ return !!payload;
30083
+ };
30084
+
30085
+ /**
30086
+ * Legacy `flagPost(postId, reason?)` implementation, kept verbatim so existing
30087
+ * callers keep the exact request body they had before the options contract existed:
30088
+ *
30089
+ * - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
30090
+ * - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
30091
+ * - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
30092
+ *
30093
+ * Not exported from the public API. It is reached through the deprecated
30094
+ * `PostRepository.flagPost(postId, reason)` overload; see `api/flagPost.ts`.
30095
+ *
30096
+ * Not itself deprecated: it implements the deprecated legacy-string overload of the public
30097
+ * `flagPost`, which carries the deprecation tag. New code should use `flagPostWithOptions`
30098
+ * (the `{ reason, detail? }` contract). This path stays available throughout the current major version.
30099
+ */
30100
+ const flagPostWithReasonString = async (postId, reason) => {
29518
30101
  const client = getActiveClient();
29519
30102
  client.log('post/flagPost', postId);
29520
30103
  const isPredefinedReason = reason &&
@@ -29530,6 +30113,42 @@ const flagPost = async (postId, reason) => {
29530
30113
  fireEvent('post.flagged', payload);
29531
30114
  return !!payload;
29532
30115
  };
30116
+
30117
+ /* begin_public_function
30118
+ id: post.flag
30119
+ */
30120
+ /**
30121
+ * ```js
30122
+ * import { PostRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
30123
+ *
30124
+ * // No reason.
30125
+ * await PostRepository.flagPost(postId)
30126
+ *
30127
+ * // Category plus optional reporter context (any category, including Others).
30128
+ * await PostRepository.flagPost(postId, {
30129
+ * reason: ContentFlagReasonEnum.SpamOrScams,
30130
+ * detail: 'Repeated promotional links',
30131
+ * })
30132
+ * ```
30133
+ *
30134
+ * Reports a post to moderation. Three call shapes are accepted (see the overloads):
30135
+ * id-only, an options object, and the deprecated legacy reason string. The public
30136
+ * name only dispatches on the input shape; the two implementations are kept separate
30137
+ * so the legacy path is untouched by the new contract:
30138
+ *
30139
+ * - `undefined` or a string → `flagPostWithReasonString` (unchanged legacy mapping)
30140
+ * - anything else → `flagPostWithOptions` (validated `{ reason, detail? }`)
30141
+ *
30142
+ * @param postId The ID of the post to flag
30143
+ * @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
30144
+ * @returns `true` when the report was created
30145
+ *
30146
+ * @category Post API
30147
+ * @async
30148
+ * */
30149
+ const flagPost = (postId, input) => isLegacyContentFlagReason(input)
30150
+ ? flagPostWithReasonString(postId, input)
30151
+ : flagPostWithOptions(postId, input);
29533
30152
  /* end_public_function */
29534
30153
 
29535
30154
  /* begin_public_function
@@ -36913,6 +37532,7 @@ class AmityAttachmentProductTags {
36913
37532
  exports.API_REGIONS = API_REGIONS;
36914
37533
  exports.AdRepository = index$6;
36915
37534
  exports.AmityAttachmentProductTags = AmityAttachmentProductTags;
37535
+ exports.AmityModuleNotEntitledError = AmityModuleNotEntitledError;
36916
37536
  exports.CategoryRepository = index$g;
36917
37537
  exports.ChannelRepository = index$k;
36918
37538
  exports.Client = index$t;
@@ -37021,6 +37641,7 @@ exports.pushToCache = pushToCache;
37021
37641
  exports.queryCache = queryCache;
37022
37642
  exports.queryOptions = queryOptions;
37023
37643
  exports.queryRoles = queryRoles;
37644
+ exports.resolveModuleAvailability = resolveModuleAvailability;
37024
37645
  exports.restoreCache = restoreCache;
37025
37646
  exports.runQuery = runQuery;
37026
37647
  exports.sortByChannelSegment = sortByChannelSegment;