@amityco/ts-sdk 7.27.2-c6896ad9.0 → 7.27.2-fb0fef3d.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 (70) hide show
  1. package/dist/@types/core/errors.d.ts +1 -2
  2. package/dist/@types/core/errors.d.ts.map +1 -1
  3. package/dist/@types/core/transport.d.ts +0 -1
  4. package/dist/@types/core/transport.d.ts.map +1 -1
  5. package/dist/@types/domains/client.d.ts +0 -86
  6. package/dist/@types/domains/client.d.ts.map +1 -1
  7. package/dist/@types/domains/content.d.ts +0 -11
  8. package/dist/@types/domains/content.d.ts.map +1 -1
  9. package/dist/client/api/createClient.d.ts.map +1 -1
  10. package/dist/client/api/index.d.ts +0 -1
  11. package/dist/client/api/index.d.ts.map +1 -1
  12. package/dist/client/index.d.ts +0 -1
  13. package/dist/client/index.d.ts.map +1 -1
  14. package/dist/commentRepository/api/flagComment.d.ts +5 -72
  15. package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
  16. package/dist/core/errors.d.ts +0 -20
  17. package/dist/core/errors.d.ts.map +1 -1
  18. package/dist/core/transports/utils.d.ts.map +1 -1
  19. package/dist/index.cjs.js +43 -491
  20. package/dist/index.d.ts +0 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.esm.js +44 -490
  23. package/dist/index.umd.js +2 -2
  24. package/dist/messageRepository/api/flagMessage.d.ts +6 -73
  25. package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
  26. package/dist/postRepository/api/flagPost.d.ts +6 -73
  27. package/dist/postRepository/api/flagPost.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/client/api/getModuleSettings.d.ts +0 -25
  30. package/dist/client/api/getModuleSettings.d.ts.map +0 -1
  31. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts +0 -2
  32. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts.map +0 -1
  33. package/dist/client/utils/parseModuleSettings.d.ts +0 -9
  34. package/dist/client/utils/parseModuleSettings.d.ts.map +0 -1
  35. package/dist/client/utils/resolveModuleAvailability.d.ts +0 -39
  36. package/dist/client/utils/resolveModuleAvailability.d.ts.map +0 -1
  37. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts +0 -2
  38. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts.map +0 -1
  39. package/dist/commentRepository/api/flagCommentWithOptions.d.ts +0 -13
  40. package/dist/commentRepository/api/flagCommentWithOptions.d.ts.map +0 -1
  41. package/dist/commentRepository/api/flagCommentWithReasonString.d.ts +0 -16
  42. package/dist/commentRepository/api/flagCommentWithReasonString.d.ts.map +0 -1
  43. package/dist/commentRepository/api/tests/integration/flagCommentWithOptions.integration.test.d.ts +0 -2
  44. package/dist/commentRepository/api/tests/integration/flagCommentWithOptions.integration.test.d.ts.map +0 -1
  45. package/dist/commentRepository/api/tests/integration/flagCommentWithReasonString.integration.test.d.ts +0 -2
  46. package/dist/commentRepository/api/tests/integration/flagCommentWithReasonString.integration.test.d.ts.map +0 -1
  47. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts +0 -2
  48. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts.map +0 -1
  49. package/dist/messageRepository/api/flagMessageWithOptions.d.ts +0 -13
  50. package/dist/messageRepository/api/flagMessageWithOptions.d.ts.map +0 -1
  51. package/dist/messageRepository/api/flagMessageWithReasonString.d.ts +0 -17
  52. package/dist/messageRepository/api/flagMessageWithReasonString.d.ts.map +0 -1
  53. package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts +0 -2
  54. package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts.map +0 -1
  55. package/dist/messageRepository/api/tests/integration/flagMessageWithOptions.integration.test.d.ts +0 -2
  56. package/dist/messageRepository/api/tests/integration/flagMessageWithOptions.integration.test.d.ts.map +0 -1
  57. package/dist/messageRepository/api/tests/integration/flagMessageWithReasonString.integration.test.d.ts +0 -2
  58. package/dist/messageRepository/api/tests/integration/flagMessageWithReasonString.integration.test.d.ts.map +0 -1
  59. package/dist/postRepository/api/flagPostWithOptions.d.ts +0 -13
  60. package/dist/postRepository/api/flagPostWithOptions.d.ts.map +0 -1
  61. package/dist/postRepository/api/flagPostWithReasonString.d.ts +0 -16
  62. package/dist/postRepository/api/flagPostWithReasonString.d.ts.map +0 -1
  63. package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts +0 -2
  64. package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts.map +0 -1
  65. package/dist/postRepository/api/tests/integration/flagPostWithOptions.integration.test.d.ts +0 -2
  66. package/dist/postRepository/api/tests/integration/flagPostWithOptions.integration.test.d.ts.map +0 -1
  67. package/dist/postRepository/api/tests/integration/flagPostWithReasonString.integration.test.d.ts +0 -2
  68. package/dist/postRepository/api/tests/integration/flagPostWithReasonString.integration.test.d.ts.map +0 -1
  69. package/dist/utils/contentFlag.d.ts +0 -28
  70. package/dist/utils/contentFlag.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -812,40 +812,6 @@ class ASCConnectionError extends ASCError {
812
812
  this.event = event;
813
813
  }
814
814
  }
815
- /**
816
- * Thrown when the network does not own a module the call needs. Raised from
817
- * any module endpoint under `enforce` enforcement, mapped from app code
818
- * `400325` — never from HTTP 403 alone, which already covers a role problem
819
- * (`400300` / `400301`), a visitor (`403999`) and a bot (`403998`).
820
- *
821
- * `modules` carries **every** key the refusal named, as raw strings, so a
822
- * caller can say which entitlement is absent without a second request.
823
- *
824
- * @category Errors
825
- */
826
- class AmityModuleNotEntitledError extends ASCApiError {
827
- /**
828
- * @param message The server's message, e.g. `Module not entitled: chat, live`
829
- * @param modules Every module key from the rejection's `data.modules`
830
- */
831
- constructor(message, modules = []) {
832
- super(message, 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */, "error" /* Amity.ErrorLevel.ERROR */);
833
- this.modules = modules;
834
- this.type = 'AmityModuleNotEntitledError';
835
- }
836
- }
837
- /**
838
- * Input sanitization related error
839
- * @category Errors
840
- */
841
- class ASCInvalidParameterError extends ASCError {
842
- /**
843
- * @param message A custom error message
844
- */
845
- constructor(message) {
846
- super(message, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
847
- }
848
- }
849
815
 
850
816
  let activeClient = null;
851
817
  /**
@@ -1995,22 +1961,6 @@ function computeUrl(type, region) {
1995
1961
 
1996
1962
  const uuid = () => uuid__default["default"].v4().toString();
1997
1963
 
1998
- /**
1999
- * Reads the module keys a `MODULE_NOT_ENTITLED` rejection named.
2000
- *
2001
- * Every entry is kept, as a raw string: one call can need more than one
2002
- * module, and a key this build predates is still the only part of the
2003
- * payload a customer can act on.
2004
- *
2005
- * @category Transport
2006
- * @hidden
2007
- */
2008
- const extractNotEntitledModules = (data) => {
2009
- const { modules } = data !== null && data !== void 0 ? data : {};
2010
- if (!Array.isArray(modules))
2011
- return [];
2012
- return modules.filter((module) => typeof module === 'string');
2013
- };
2014
1964
  /**
2015
1965
  * Unwraps v3 server payload (for error handling and type extraction)
2016
1966
  *
@@ -2030,15 +1980,6 @@ const unwrapPayload = (response) => {
2030
1980
  throw new ASCUnknownError(response.code);
2031
1981
  }
2032
1982
  else if (response.status === 'error') {
2033
- /*
2034
- * An entitlement refusal must not arrive as a generic failure: a customer
2035
- * cannot then tell a module they have not bought from an outage. Keyed on
2036
- * the app code, never on the HTTP status, so a role or membership problem
2037
- * still maps to the generic error.
2038
- */
2039
- if (response.code === 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */) {
2040
- throw new AmityModuleNotEntitledError(response.message, extractNotEntitledModules(response.data));
2041
- }
2042
1983
  throw new ASCApiError(response.message, response.code, "error" /* Amity.ErrorLevel.ERROR */);
2043
1984
  }
2044
1985
  // unjust, but helps force uncast "T | undefined" to allow deconstruction without warnings
@@ -5535,95 +5476,6 @@ const getForYouFeedSetting = async () => {
5535
5476
  };
5536
5477
  /* end_public_function */
5537
5478
 
5538
- const ENFORCEMENT_MODES = ['off', 'shadow', 'enforce'];
5539
- /**
5540
- * An unrecognised mode decodes to `off`, and so does an absent one. A mode
5541
- * this build does not know must not withhold anything — defaulting to
5542
- * `enforce` would let a server-side rename black out a customer's app.
5543
- *
5544
- * @category private
5545
- */
5546
- const parseEnforcement = (mode) => {
5547
- const match = ENFORCEMENT_MODES.find(value => value === mode);
5548
- return match !== null && match !== void 0 ? match : 'off';
5549
- };
5550
- const parseGrants = (modules) => {
5551
- const grants = {};
5552
- Object.entries(modules !== null && modules !== void 0 ? modules : {}).forEach(([key, granted]) => {
5553
- grants[key] = granted === true;
5554
- });
5555
- return grants;
5556
- };
5557
- /**
5558
- * Every catalog entry survives, including one whose key this build has never
5559
- * heard of, so a module added server-side is still listable.
5560
- *
5561
- * @category private
5562
- */
5563
- const parseCatalog = (catalog) => {
5564
- const parsed = {};
5565
- Object.entries(catalog !== null && catalog !== void 0 ? catalog : {}).forEach(([key, definition]) => {
5566
- const rawRequires = definition === null || definition === void 0 ? void 0 : definition.requires;
5567
- const requires = Array.isArray(rawRequires)
5568
- ? rawRequires.filter((entry) => typeof entry === 'string')
5569
- : [];
5570
- parsed[key] = {
5571
- label: typeof (definition === null || definition === void 0 ? void 0 : definition.label) === 'string' ? definition.label : key,
5572
- kind: (definition === null || definition === void 0 ? void 0 : definition.kind) === 'setting' ? 'setting' : 'api',
5573
- requires,
5574
- };
5575
- });
5576
- return parsed;
5577
- };
5578
- /**
5579
- * Decodes `GET /api/v3/network-settings/modules`. Nothing is trimmed: the
5580
- * catalog is the dependency table callers resolve against, and a client that
5581
- * cannot see it has to hardcode one.
5582
- *
5583
- * @category private
5584
- */
5585
- const parseModuleSettings = (raw) => {
5586
- var _a;
5587
- return ({
5588
- 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),
5589
- modules: parseGrants(raw === null || raw === void 0 ? void 0 : raw.modules),
5590
- catalog: parseCatalog(raw === null || raw === void 0 ? void 0 : raw.catalog),
5591
- });
5592
- };
5593
-
5594
- /* begin_public_function
5595
- id: client.getModuleSettings
5596
- */
5597
- /**
5598
- * ```js
5599
- * import { Client } from '@amityco/ts-sdk'
5600
- * const moduleSettings = await Client.getModuleSettings()
5601
- * ```
5602
- *
5603
- * Fetches the network's module entitlements: which modules the network was
5604
- * granted, whether core is enforcing those grants, and the catalog of all
5605
- * modules with their dependency chains.
5606
- *
5607
- * The payload is returned whole — `catalog` is the dependency table
5608
- * {@link resolveModuleAvailability} reads, and a client that cannot see it has
5609
- * to hardcode one.
5610
- *
5611
- * The read is **advisory**. It tells a host what to offer; under `enforce` the
5612
- * backend refuses a call to an unowned module regardless of what was resolved
5613
- * here, and that refusal arrives as `AmityModuleNotEntitledError`.
5614
- *
5615
- * @returns A Promise of {@link Amity.ModuleSettings} object
5616
- *
5617
- * @category Client API
5618
- * @async
5619
- */
5620
- const getModuleSettings = async () => {
5621
- const client = getActiveClient();
5622
- const { data } = await client.http.get(`/api/v3/network-settings/modules`);
5623
- return parseModuleSettings(data);
5624
- };
5625
- /* end_public_function */
5626
-
5627
5479
  const checkUserPermission = (userId, permission) => {
5628
5480
  var _a;
5629
5481
  const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -9348,7 +9200,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
9348
9200
  getMarkerSyncConsistentMode,
9349
9201
  getProductCatalogueSetting,
9350
9202
  getForYouFeedSetting,
9351
- getModuleSettings,
9352
9203
  /**
9353
9204
  * Prefix for the deviceId key in the local storage or async storage.
9354
9205
  * This is allow user to have multiple SDK client and Mqtt client within the same app.
@@ -10394,92 +10245,6 @@ const getUserUnread = (callback) => {
10394
10245
  };
10395
10246
  };
10396
10247
 
10397
- /**
10398
- * ```js
10399
- * import { Client, resolveModuleAvailability } from '@amityco/ts-sdk'
10400
- *
10401
- * const moduleSettings = await Client.getModuleSettings()
10402
- *
10403
- * if (resolveModuleAvailability(moduleSettings, 'live').isAvailable) {
10404
- * // offer the Live entry point
10405
- * }
10406
- * ```
10407
- *
10408
- * Resolves whether one module is usable on this network.
10409
- *
10410
- * Availability is a function of all three fields of
10411
- * {@link Amity.ModuleSettings} — the enforcement mode, the module's own grant,
10412
- * and its prerequisite chain — combined in that order. Reading `modules`
10413
- * directly contradicts the mode: staging answers `mode: 'off'` with
10414
- * `modules: {}`, and every module still works.
10415
- *
10416
- * The dependency table comes from the payload's `catalog`, never from a
10417
- * hardcoded copy, so a chain the backend changes takes effect without an SDK
10418
- * release.
10419
- *
10420
- * The SDK does not hold the settings — the caller keeps what it fetched and
10421
- * resolves against it. With no settings at all (a fetch that never succeeded)
10422
- * the caller reads that as every module available: under `enforce` the backend
10423
- * refuses the calls anyway, so the exposure is a screen that offers too much,
10424
- * not one that withholds what a customer paid for.
10425
- *
10426
- * @param moduleSettings The network's module settings
10427
- * @param moduleKey The module to resolve — an {@link Amity.ModuleKey}, so the
10428
- * 15 keys this build knows complete and type-check while a catalog entry it
10429
- * does not know still resolves.
10430
- * @returns An {@link Amity.ModuleAvailability} answer
10431
- *
10432
- * @category Client API
10433
- */
10434
- const resolveModuleAvailability = (moduleSettings, moduleKey, seen = new Set()) => {
10435
- var _a, _b, _c, _d, _e;
10436
- const isGranted = (_a = moduleSettings.modules[moduleKey]) !== null && _a !== void 0 ? _a : false;
10437
- /*
10438
- * Not enforcing: nothing is withheld, and no graph walk is needed. This has
10439
- * to come first — `off` and `shadow` resolve available whatever the grant
10440
- * says, and a cycle would otherwise return unavailable under `off` too.
10441
- */
10442
- if (moduleSettings.enforcement !== 'enforce') {
10443
- return { moduleKey, isAvailable: true, isGranted };
10444
- }
10445
- // A cycle in `requires` resolves unavailable rather than recursing.
10446
- if (seen.has(moduleKey)) {
10447
- return {
10448
- moduleKey,
10449
- isAvailable: false,
10450
- isGranted,
10451
- reason: 'prerequisiteUnavailable',
10452
- unsatisfied: (_c = (_b = moduleSettings.catalog[moduleKey]) === null || _b === void 0 ? void 0 : _b.requires) !== null && _c !== void 0 ? _c : [],
10453
- };
10454
- }
10455
- // The module's own grant is evaluated before its prerequisites, so
10456
- // `notGranted` is reported in preference when both hold.
10457
- if (!isGranted) {
10458
- return { moduleKey, isAvailable: false, isGranted, reason: 'notGranted' };
10459
- }
10460
- const requires = (_e = (_d = moduleSettings.catalog[moduleKey]) === null || _d === void 0 ? void 0 : _d.requires) !== null && _e !== void 0 ? _e : [];
10461
- if (requires.length === 0)
10462
- return { moduleKey, isAvailable: true, isGranted };
10463
- // `requires` is satisfied by any one entry, transitively.
10464
- const isSatisfied = requires.some(dependency => resolveModuleAvailability(moduleSettings, dependency, new Set([...seen, moduleKey]))
10465
- .isAvailable);
10466
- if (isSatisfied)
10467
- return { moduleKey, isAvailable: true, isGranted };
10468
- /*
10469
- * `unsatisfied` carries the whole `requires` list rather than one entry. Any
10470
- * one of them would have satisfied the requirement, so naming a single
10471
- * module misdirects: telling a Community-only customer "Comment needs post"
10472
- * hides that Story would also have done.
10473
- */
10474
- return {
10475
- moduleKey,
10476
- isAvailable: false,
10477
- isGranted,
10478
- reason: 'prerequisiteUnavailable',
10479
- unsatisfied: requires,
10480
- };
10481
- };
10482
-
10483
10248
  var index$t = /*#__PURE__*/Object.freeze({
10484
10249
  __proto__: null,
10485
10250
  getActiveClient: getActiveClient,
@@ -10503,7 +10268,6 @@ var index$t = /*#__PURE__*/Object.freeze({
10503
10268
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10504
10269
  getProductCatalogueSetting: getProductCatalogueSetting,
10505
10270
  getForYouFeedSetting: getForYouFeedSetting,
10506
- getModuleSettings: getModuleSettings,
10507
10271
  loginAsVisitor: loginAsVisitor,
10508
10272
  loginAsBot: loginAsBot,
10509
10273
  getCurrentUser: getCurrentUser,
@@ -10531,8 +10295,7 @@ var index$t = /*#__PURE__*/Object.freeze({
10531
10295
  startMarkerSync: startMarkerSync,
10532
10296
  startUnreadSync: startUnreadSync,
10533
10297
  stopUnreadSync: stopUnreadSync,
10534
- getMarkerSyncConsistentMode: getMarkerSyncConsistentMode,
10535
- resolveModuleAvailability: resolveModuleAvailability
10298
+ getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
10536
10299
  });
10537
10300
 
10538
10301
  /* begin_public_function
@@ -20172,82 +19935,23 @@ getDeliveredUsers.locally = (query) => {
20172
19935
  return { data: users, cachedAt, prevPage, nextPage };
20173
19936
  };
20174
19937
 
20175
- const CONTENT_FLAG_REASONS = Object.values(exports.ContentFlagReasonEnum);
20176
- /**
20177
- * True when a public `flagX(id, input)` argument is the legacy shape (a reason string
20178
- * or nothing). Anything else is routed to the `Amity.ContentFlagOptions` path, whose
20179
- * validation rejects malformed values before any request is made.
20180
- */
20181
- const isLegacyContentFlagReason = (input) => input === undefined || typeof input === 'string';
20182
- /**
20183
- * Validates an `Amity.ContentFlagOptions` argument. Untyped (plain JS) callers can pass
20184
- * anything at runtime, so the checks do not trust the declared type: the value must be a
20185
- * plain object, `reason` must be one of the nine `ContentFlagReasonEnum` values and
20186
- * `detail`, when supplied, must be a string (`null` is not a valid supplied detail).
20187
- *
20188
- * @param apiName used in the error message, e.g. `flagPost`
20189
- * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
20190
- */
20191
- const validateContentFlagOptions = (apiName, options) => {
20192
- if (typeof options !== 'object' || options === null || Array.isArray(options)) {
20193
- throw new ASCInvalidParameterError(`${apiName}: expected an options object \`{ reason, detail? }\``);
20194
- }
20195
- const { reason, detail } = options;
20196
- if (typeof reason !== 'string' || !CONTENT_FLAG_REASONS.includes(reason)) {
20197
- throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
20198
- }
20199
- if (detail !== undefined && typeof detail !== 'string') {
20200
- throw new ASCInvalidParameterError(`${apiName}: \`detail\` must be a string when supplied`);
20201
- }
20202
- return { reason: reason, detail };
20203
- };
20204
- /**
20205
- * Builds the request body for validated options. `detail` is forwarded unchanged (empty
20206
- * and whitespace-only strings included) and omitted from the body when `undefined`; the
20207
- * backend enforces the 300-character limit.
20208
- */
20209
- const toContentFlagBody = ({ reason, detail }) => detail === undefined ? { reason } : { reason, detail };
20210
-
20211
- /**
20212
- * New `flagMessage(messageId, { reason, detail? })` implementation. Any category,
20213
- * including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
20214
- * whitespace-only strings included) and omitted from the request body when `undefined`;
20215
- * the backend enforces the 300-character limit.
20216
- *
20217
- * Not exported from the public API. It is reached through the
20218
- * `MessageRepository.flagMessage(messageId, options)` overload; see `flagMessage.ts`.
20219
- *
20220
- * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
20221
- */
20222
- const flagMessageWithOptions = async (messageId, options) => {
20223
- const client = getActiveClient();
20224
- client.log('message/flag', messageId);
20225
- const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
20226
- const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
20227
- if (client.cache) {
20228
- const messagePayload = await prepareMessagePayload(payload);
20229
- ingestInCache(messagePayload);
20230
- }
20231
- fireEvent('message.flagged', payload);
20232
- return !!payload;
20233
- };
20234
-
19938
+ /* begin_public_function
19939
+ id: message.flag
19940
+ */
20235
19941
  /**
20236
- * Legacy `flagMessage(messageId, reason?)` implementation, kept verbatim so existing
20237
- * callers keep the exact request body they had before the options contract existed:
20238
- *
20239
- * - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
20240
- * - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
20241
- * - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
20242
- * (for `undefined` the message body carries `detail: undefined`, which JSON serialization omits)
19942
+ * ```js
19943
+ * import { MessageRepository } from '@amityco/ts-sdk'
19944
+ * const flagged = await MessageRepository.flagMessage(messageId, reason)
19945
+ * ```
20243
19946
  *
20244
- * Not exported from the public API. It is reached through the deprecated
20245
- * `MessageRepository.flagMessage(messageId, reason)` overload; see `flagMessage.ts`.
19947
+ * @param messageId of the message to flag
19948
+ * @param reason the reason to flag the message
19949
+ * @returns the created report result
20246
19950
  *
20247
- * @deprecated Use `flagMessageWithOptions` (the `{ reason, detail? }` contract) for new code.
20248
- * This path stays available throughout the current major version.
20249
- */
20250
- const flagMessageWithReasonString = async (messageId, reason) => {
19951
+ * @category Message API
19952
+ * @async
19953
+ * */
19954
+ const flagMessage = async (messageId, reason) => {
20251
19955
  const client = getActiveClient();
20252
19956
  client.log('message/flag', messageId);
20253
19957
  const isPredefinedReason = reason &&
@@ -20264,42 +19968,6 @@ const flagMessageWithReasonString = async (messageId, reason) => {
20264
19968
  fireEvent('message.flagged', payload);
20265
19969
  return !!payload;
20266
19970
  };
20267
-
20268
- /* begin_public_function
20269
- id: message.flag
20270
- */
20271
- /**
20272
- * ```js
20273
- * import { MessageRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
20274
- *
20275
- * // No reason.
20276
- * await MessageRepository.flagMessage(messageId)
20277
- *
20278
- * // Category plus optional reporter context (any category, including Others).
20279
- * await MessageRepository.flagMessage(messageId, {
20280
- * reason: ContentFlagReasonEnum.SpamOrScams,
20281
- * detail: 'Repeated promotional links',
20282
- * })
20283
- * ```
20284
- *
20285
- * Reports a message to moderation. Three call shapes are accepted (see the overloads):
20286
- * id-only, an options object, and the deprecated legacy reason string. The public
20287
- * name only dispatches on the input shape; the two implementations are kept separate
20288
- * so the legacy path is untouched by the new contract:
20289
- *
20290
- * - `undefined` or a string → `flagMessageWithReasonString` (unchanged legacy mapping)
20291
- * - anything else → `flagMessageWithOptions` (validated `{ reason, detail? }`)
20292
- *
20293
- * @param messageId The ID of the message to flag
20294
- * @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
20295
- * @returns `true` when the report was created
20296
- *
20297
- * @category Message API
20298
- * @async
20299
- * */
20300
- const flagMessage = (messageId, input) => isLegacyContentFlagReason(input)
20301
- ? flagMessageWithReasonString(messageId, input)
20302
- : flagMessageWithOptions(messageId, input);
20303
19971
  /* end_public_function */
20304
19972
 
20305
19973
  /* begin_public_function
@@ -27445,21 +27113,23 @@ const declineComment = async (commentId, reason) => {
27445
27113
  };
27446
27114
  /* end_public_function */
27447
27115
 
27116
+ /* begin_public_function
27117
+ id: comment.flag
27118
+ */
27448
27119
  /**
27449
- * Legacy `flagComment(commentId, reason?)` implementation, kept verbatim so existing
27450
- * callers keep the exact request body they had before the options contract existed:
27451
- *
27452
- * - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
27453
- * - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
27454
- * - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
27120
+ * ```js
27121
+ * import { CommentRepository } from '@amityco/ts-sdk'
27122
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
27123
+ * ```
27455
27124
  *
27456
- * Not exported from the public API. It is reached through the deprecated
27457
- * `CommentRepository.flagComment(commentId, reason)` overload; see `flagComment.ts`.
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
27458
27128
  *
27459
- * @deprecated Use `flagCommentWithOptions` (the `{ reason, detail? }` contract) for new code.
27460
- * This path stays available throughout the current major version.
27461
- */
27462
- const flagCommentWithReasonString = async (commentId, reason) => {
27129
+ * @category Comment API
27130
+ * @async
27131
+ * */
27132
+ const flagComment = async (commentId, reason) => {
27463
27133
  const client = getActiveClient();
27464
27134
  client.log('comment/flagComment', commentId);
27465
27135
  const isPredefinedReason = reason &&
@@ -27475,65 +27145,6 @@ const flagCommentWithReasonString = async (commentId, reason) => {
27475
27145
  fireEvent('comment.flagged', payload);
27476
27146
  return !!payload;
27477
27147
  };
27478
-
27479
- /**
27480
- * New `flagComment(commentId, { reason, detail? })` implementation. Any category,
27481
- * including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
27482
- * whitespace-only strings included) and omitted from the request body when `undefined`;
27483
- * the backend enforces the 300-character limit.
27484
- *
27485
- * Not exported from the public API. It is reached through the
27486
- * `CommentRepository.flagComment(commentId, options)` overload; see `flagComment.ts`.
27487
- *
27488
- * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
27489
- */
27490
- const flagCommentWithOptions = async (commentId, options) => {
27491
- const client = getActiveClient();
27492
- client.log('comment/flagComment', commentId);
27493
- const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
27494
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
27495
- if (client.cache) {
27496
- ingestInCache(payload);
27497
- }
27498
- fireEvent('comment.flagged', payload);
27499
- return !!payload;
27500
- };
27501
-
27502
- /* begin_public_function
27503
- id: comment.flag
27504
- */
27505
- /**
27506
- * ```js
27507
- * import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
27508
- *
27509
- * // No reason: sent as Others with an empty detail.
27510
- * await CommentRepository.flagComment(commentId)
27511
- *
27512
- * // Category plus optional reporter context (any category, including Others).
27513
- * await CommentRepository.flagComment(commentId, {
27514
- * reason: ContentFlagReasonEnum.SpamOrScams,
27515
- * detail: 'Repeated promotional links',
27516
- * })
27517
- * ```
27518
- *
27519
- * Reports a comment to moderation. Three call shapes are accepted (see the overloads):
27520
- * id-only, an options object, and the deprecated legacy reason string. The public
27521
- * name only dispatches on the input shape; the two implementations are kept separate
27522
- * so the legacy path is untouched by the new contract:
27523
- *
27524
- * - `undefined` or a string → `flagCommentWithReasonString` (unchanged legacy mapping)
27525
- * - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
27526
- *
27527
- * @param commentId The ID of the comment to flag
27528
- * @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
27529
- * @returns `true` when the report was created
27530
- *
27531
- * @category Comment API
27532
- * @async
27533
- * */
27534
- const flagComment = (commentId, input) => isLegacyContentFlagReason(input)
27535
- ? flagCommentWithReasonString(commentId, input)
27536
- : flagCommentWithOptions(commentId, input);
27537
27148
  /* end_public_function */
27538
27149
 
27539
27150
  /* begin_public_function
@@ -29887,44 +29498,23 @@ const declinePost = async (postId) => {
29887
29498
  };
29888
29499
  /* end_public_function */
29889
29500
 
29501
+ /* begin_public_function
29502
+ id: post.flag
29503
+ */
29890
29504
  /**
29891
- * New `flagPost(postId, { reason, detail? })` implementation. Any category, including
29892
- * `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
29893
- * whitespace-only strings included) and omitted from the request body when `undefined`;
29894
- * the backend enforces the 300-character limit.
29895
- *
29896
- * Not exported from the public API. It is reached through the
29897
- * `PostRepository.flagPost(postId, options)` overload; see `flagPost.ts`.
29898
- *
29899
- * @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
29900
- */
29901
- const flagPostWithOptions = async (postId, options) => {
29902
- const client = getActiveClient();
29903
- client.log('post/flagPost', postId);
29904
- const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
29905
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
29906
- if (client.cache) {
29907
- ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
29908
- }
29909
- fireEvent('post.flagged', payload);
29910
- return !!payload;
29911
- };
29912
-
29913
- /**
29914
- * Legacy `flagPost(postId, reason?)` implementation, kept verbatim so existing
29915
- * callers keep the exact request body they had before the options contract existed:
29916
- *
29917
- * - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
29918
- * - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
29919
- * - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
29505
+ * ```js
29506
+ * import { PostRepository } from '@amityco/ts-sdk'
29507
+ * const flagged = await PostRepository.flagPost(postId, reason)
29508
+ * ```
29920
29509
  *
29921
- * Not exported from the public API. It is reached through the deprecated
29922
- * `PostRepository.flagPost(postId, reason)` overload; see `flagPost.ts`.
29510
+ * @param postId of the post to flag
29511
+ * @param reason the reason to flag the post
29512
+ * @returns a boolean
29923
29513
  *
29924
- * @deprecated Use `flagPostWithOptions` (the `{ reason, detail? }` contract) for new code.
29925
- * This path stays available throughout the current major version.
29926
- */
29927
- const flagPostWithReasonString = async (postId, reason) => {
29514
+ * @category Post API
29515
+ * @async
29516
+ * */
29517
+ const flagPost = async (postId, reason) => {
29928
29518
  const client = getActiveClient();
29929
29519
  client.log('post/flagPost', postId);
29930
29520
  const isPredefinedReason = reason &&
@@ -29940,42 +29530,6 @@ const flagPostWithReasonString = async (postId, reason) => {
29940
29530
  fireEvent('post.flagged', payload);
29941
29531
  return !!payload;
29942
29532
  };
29943
-
29944
- /* begin_public_function
29945
- id: post.flag
29946
- */
29947
- /**
29948
- * ```js
29949
- * import { PostRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
29950
- *
29951
- * // No reason.
29952
- * await PostRepository.flagPost(postId)
29953
- *
29954
- * // Category plus optional reporter context (any category, including Others).
29955
- * await PostRepository.flagPost(postId, {
29956
- * reason: ContentFlagReasonEnum.SpamOrScams,
29957
- * detail: 'Repeated promotional links',
29958
- * })
29959
- * ```
29960
- *
29961
- * Reports a post to moderation. Three call shapes are accepted (see the overloads):
29962
- * id-only, an options object, and the deprecated legacy reason string. The public
29963
- * name only dispatches on the input shape; the two implementations are kept separate
29964
- * so the legacy path is untouched by the new contract:
29965
- *
29966
- * - `undefined` or a string → `flagPostWithReasonString` (unchanged legacy mapping)
29967
- * - anything else → `flagPostWithOptions` (validated `{ reason, detail? }`)
29968
- *
29969
- * @param postId The ID of the post to flag
29970
- * @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
29971
- * @returns `true` when the report was created
29972
- *
29973
- * @category Post API
29974
- * @async
29975
- * */
29976
- const flagPost = (postId, input) => isLegacyContentFlagReason(input)
29977
- ? flagPostWithReasonString(postId, input)
29978
- : flagPostWithOptions(postId, input);
29979
29533
  /* end_public_function */
29980
29534
 
29981
29535
  /* begin_public_function
@@ -37359,7 +36913,6 @@ class AmityAttachmentProductTags {
37359
36913
  exports.API_REGIONS = API_REGIONS;
37360
36914
  exports.AdRepository = index$6;
37361
36915
  exports.AmityAttachmentProductTags = AmityAttachmentProductTags;
37362
- exports.AmityModuleNotEntitledError = AmityModuleNotEntitledError;
37363
36916
  exports.CategoryRepository = index$g;
37364
36917
  exports.ChannelRepository = index$k;
37365
36918
  exports.Client = index$t;
@@ -37468,7 +37021,6 @@ exports.pushToCache = pushToCache;
37468
37021
  exports.queryCache = queryCache;
37469
37022
  exports.queryOptions = queryOptions;
37470
37023
  exports.queryRoles = queryRoles;
37471
- exports.resolveModuleAvailability = resolveModuleAvailability;
37472
37024
  exports.restoreCache = restoreCache;
37473
37025
  exports.runQuery = runQuery;
37474
37026
  exports.sortByChannelSegment = sortByChannelSegment;
package/dist/index.d.ts CHANGED
@@ -35,6 +35,4 @@ export * as EventRepository from './eventRepository';
35
35
  export * as ProductRepository from './productRepository';
36
36
  export * as CuratedContentRepository from './curatedContentRepository';
37
37
  export { AmityAttachmentProductTags } from './productRepository/helpers';
38
- export { AmityModuleNotEntitledError } from './core/errors';
39
- export { resolveModuleAvailability } from './client/utils/resolveModuleAvailability';
40
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAE5B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,cAAc,YAAY,CAAC;AAG3B,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;A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