@amityco/ts-sdk 7.27.2-9bed893.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 (32) 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/client/api/createClient.d.ts.map +1 -1
  8. package/dist/client/api/index.d.ts +0 -1
  9. package/dist/client/api/index.d.ts.map +1 -1
  10. package/dist/client/index.d.ts +0 -1
  11. package/dist/client/index.d.ts.map +1 -1
  12. package/dist/core/errors.d.ts +0 -20
  13. package/dist/core/errors.d.ts.map +1 -1
  14. package/dist/core/transports/utils.d.ts.map +1 -1
  15. package/dist/index.cjs.js +1 -228
  16. package/dist/index.d.ts +0 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.esm.js +2 -227
  19. package/dist/index.umd.js +2 -2
  20. package/package.json +1 -1
  21. package/dist/client/api/getModuleSettings.d.ts +0 -25
  22. package/dist/client/api/getModuleSettings.d.ts.map +0 -1
  23. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts +0 -2
  24. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts.map +0 -1
  25. package/dist/client/utils/parseModuleSettings.d.ts +0 -9
  26. package/dist/client/utils/parseModuleSettings.d.ts.map +0 -1
  27. package/dist/client/utils/resolveModuleAvailability.d.ts +0 -39
  28. package/dist/client/utils/resolveModuleAvailability.d.ts.map +0 -1
  29. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts +0 -2
  30. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts.map +0 -1
  31. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts +0 -2
  32. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts.map +0 -1
package/dist/index.esm.js CHANGED
@@ -796,28 +796,6 @@ class ASCConnectionError extends ASCError {
796
796
  this.event = event;
797
797
  }
798
798
  }
799
- /**
800
- * Thrown when the network does not own a module the call needs. Raised from
801
- * any module endpoint under `enforce` enforcement, mapped from app code
802
- * `400325` — never from HTTP 403 alone, which already covers a role problem
803
- * (`400300` / `400301`), a visitor (`403999`) and a bot (`403998`).
804
- *
805
- * `modules` carries **every** key the refusal named, as raw strings, so a
806
- * caller can say which entitlement is absent without a second request.
807
- *
808
- * @category Errors
809
- */
810
- class AmityModuleNotEntitledError extends ASCApiError {
811
- /**
812
- * @param message The server's message, e.g. `Module not entitled: chat, live`
813
- * @param modules Every module key from the rejection's `data.modules`
814
- */
815
- constructor(message, modules = []) {
816
- super(message, 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */, "error" /* Amity.ErrorLevel.ERROR */);
817
- this.modules = modules;
818
- this.type = 'AmityModuleNotEntitledError';
819
- }
820
- }
821
799
 
822
800
  let activeClient = null;
823
801
  /**
@@ -1967,22 +1945,6 @@ function computeUrl(type, region) {
1967
1945
 
1968
1946
  const uuid = () => uuid$1.v4().toString();
1969
1947
 
1970
- /**
1971
- * Reads the module keys a `MODULE_NOT_ENTITLED` rejection named.
1972
- *
1973
- * Every entry is kept, as a raw string: one call can need more than one
1974
- * module, and a key this build predates is still the only part of the
1975
- * payload a customer can act on.
1976
- *
1977
- * @category Transport
1978
- * @hidden
1979
- */
1980
- const extractNotEntitledModules = (data) => {
1981
- const { modules } = data !== null && data !== void 0 ? data : {};
1982
- if (!Array.isArray(modules))
1983
- return [];
1984
- return modules.filter((module) => typeof module === 'string');
1985
- };
1986
1948
  /**
1987
1949
  * Unwraps v3 server payload (for error handling and type extraction)
1988
1950
  *
@@ -2002,15 +1964,6 @@ const unwrapPayload = (response) => {
2002
1964
  throw new ASCUnknownError(response.code);
2003
1965
  }
2004
1966
  else if (response.status === 'error') {
2005
- /*
2006
- * An entitlement refusal must not arrive as a generic failure: a customer
2007
- * cannot then tell a module they have not bought from an outage. Keyed on
2008
- * the app code, never on the HTTP status, so a role or membership problem
2009
- * still maps to the generic error.
2010
- */
2011
- if (response.code === 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */) {
2012
- throw new AmityModuleNotEntitledError(response.message, extractNotEntitledModules(response.data));
2013
- }
2014
1967
  throw new ASCApiError(response.message, response.code, "error" /* Amity.ErrorLevel.ERROR */);
2015
1968
  }
2016
1969
  // unjust, but helps force uncast "T | undefined" to allow deconstruction without warnings
@@ -5523,95 +5476,6 @@ const getForYouFeedSetting = async () => {
5523
5476
  };
5524
5477
  /* end_public_function */
5525
5478
 
5526
- const ENFORCEMENT_MODES = ['off', 'shadow', 'enforce'];
5527
- /**
5528
- * An unrecognised mode decodes to `off`, and so does an absent one. A mode
5529
- * this build does not know must not withhold anything — defaulting to
5530
- * `enforce` would let a server-side rename black out a customer's app.
5531
- *
5532
- * @category private
5533
- */
5534
- const parseEnforcement = (mode) => {
5535
- const match = ENFORCEMENT_MODES.find(value => value === mode);
5536
- return match !== null && match !== void 0 ? match : 'off';
5537
- };
5538
- const parseGrants = (modules) => {
5539
- const grants = {};
5540
- Object.entries(modules !== null && modules !== void 0 ? modules : {}).forEach(([key, granted]) => {
5541
- grants[key] = granted === true;
5542
- });
5543
- return grants;
5544
- };
5545
- /**
5546
- * Every catalog entry survives, including one whose key this build has never
5547
- * heard of, so a module added server-side is still listable.
5548
- *
5549
- * @category private
5550
- */
5551
- const parseCatalog = (catalog) => {
5552
- const parsed = {};
5553
- Object.entries(catalog !== null && catalog !== void 0 ? catalog : {}).forEach(([key, definition]) => {
5554
- const rawRequires = definition === null || definition === void 0 ? void 0 : definition.requires;
5555
- const requires = Array.isArray(rawRequires)
5556
- ? rawRequires.filter((entry) => typeof entry === 'string')
5557
- : [];
5558
- parsed[key] = {
5559
- label: typeof (definition === null || definition === void 0 ? void 0 : definition.label) === 'string' ? definition.label : key,
5560
- kind: (definition === null || definition === void 0 ? void 0 : definition.kind) === 'setting' ? 'setting' : 'api',
5561
- requires,
5562
- };
5563
- });
5564
- return parsed;
5565
- };
5566
- /**
5567
- * Decodes `GET /api/v3/network-settings/modules`. Nothing is trimmed: the
5568
- * catalog is the dependency table callers resolve against, and a client that
5569
- * cannot see it has to hardcode one.
5570
- *
5571
- * @category private
5572
- */
5573
- const parseModuleSettings = (raw) => {
5574
- var _a;
5575
- return ({
5576
- 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),
5577
- modules: parseGrants(raw === null || raw === void 0 ? void 0 : raw.modules),
5578
- catalog: parseCatalog(raw === null || raw === void 0 ? void 0 : raw.catalog),
5579
- });
5580
- };
5581
-
5582
- /* begin_public_function
5583
- id: client.getModuleSettings
5584
- */
5585
- /**
5586
- * ```js
5587
- * import { Client } from '@amityco/ts-sdk'
5588
- * const moduleSettings = await Client.getModuleSettings()
5589
- * ```
5590
- *
5591
- * Fetches the network's module entitlements: which modules the network was
5592
- * granted, whether core is enforcing those grants, and the catalog of all
5593
- * modules with their dependency chains.
5594
- *
5595
- * The payload is returned whole — `catalog` is the dependency table
5596
- * {@link resolveModuleAvailability} reads, and a client that cannot see it has
5597
- * to hardcode one.
5598
- *
5599
- * The read is **advisory**. It tells a host what to offer; under `enforce` the
5600
- * backend refuses a call to an unowned module regardless of what was resolved
5601
- * here, and that refusal arrives as `AmityModuleNotEntitledError`.
5602
- *
5603
- * @returns A Promise of {@link Amity.ModuleSettings} object
5604
- *
5605
- * @category Client API
5606
- * @async
5607
- */
5608
- const getModuleSettings = async () => {
5609
- const client = getActiveClient();
5610
- const { data } = await client.http.get(`/api/v3/network-settings/modules`);
5611
- return parseModuleSettings(data);
5612
- };
5613
- /* end_public_function */
5614
-
5615
5479
  const checkUserPermission = (userId, permission) => {
5616
5480
  var _a;
5617
5481
  const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -9336,7 +9200,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
9336
9200
  getMarkerSyncConsistentMode,
9337
9201
  getProductCatalogueSetting,
9338
9202
  getForYouFeedSetting,
9339
- getModuleSettings,
9340
9203
  /**
9341
9204
  * Prefix for the deviceId key in the local storage or async storage.
9342
9205
  * This is allow user to have multiple SDK client and Mqtt client within the same app.
@@ -10382,92 +10245,6 @@ const getUserUnread = (callback) => {
10382
10245
  };
10383
10246
  };
10384
10247
 
10385
- /**
10386
- * ```js
10387
- * import { Client, resolveModuleAvailability } from '@amityco/ts-sdk'
10388
- *
10389
- * const moduleSettings = await Client.getModuleSettings()
10390
- *
10391
- * if (resolveModuleAvailability(moduleSettings, 'live').isAvailable) {
10392
- * // offer the Live entry point
10393
- * }
10394
- * ```
10395
- *
10396
- * Resolves whether one module is usable on this network.
10397
- *
10398
- * Availability is a function of all three fields of
10399
- * {@link Amity.ModuleSettings} — the enforcement mode, the module's own grant,
10400
- * and its prerequisite chain — combined in that order. Reading `modules`
10401
- * directly contradicts the mode: staging answers `mode: 'off'` with
10402
- * `modules: {}`, and every module still works.
10403
- *
10404
- * The dependency table comes from the payload's `catalog`, never from a
10405
- * hardcoded copy, so a chain the backend changes takes effect without an SDK
10406
- * release.
10407
- *
10408
- * The SDK does not hold the settings — the caller keeps what it fetched and
10409
- * resolves against it. With no settings at all (a fetch that never succeeded)
10410
- * the caller reads that as every module available: under `enforce` the backend
10411
- * refuses the calls anyway, so the exposure is a screen that offers too much,
10412
- * not one that withholds what a customer paid for.
10413
- *
10414
- * @param moduleSettings The network's module settings
10415
- * @param moduleKey The module to resolve — an {@link Amity.ModuleKey}, so the
10416
- * 15 keys this build knows complete and type-check while a catalog entry it
10417
- * does not know still resolves.
10418
- * @returns An {@link Amity.ModuleAvailability} answer
10419
- *
10420
- * @category Client API
10421
- */
10422
- const resolveModuleAvailability = (moduleSettings, moduleKey, seen = new Set()) => {
10423
- var _a, _b, _c, _d, _e;
10424
- const isGranted = (_a = moduleSettings.modules[moduleKey]) !== null && _a !== void 0 ? _a : false;
10425
- /*
10426
- * Not enforcing: nothing is withheld, and no graph walk is needed. This has
10427
- * to come first — `off` and `shadow` resolve available whatever the grant
10428
- * says, and a cycle would otherwise return unavailable under `off` too.
10429
- */
10430
- if (moduleSettings.enforcement !== 'enforce') {
10431
- return { moduleKey, isAvailable: true, isGranted };
10432
- }
10433
- // A cycle in `requires` resolves unavailable rather than recursing.
10434
- if (seen.has(moduleKey)) {
10435
- return {
10436
- moduleKey,
10437
- isAvailable: false,
10438
- isGranted,
10439
- reason: 'prerequisiteUnavailable',
10440
- unsatisfied: (_c = (_b = moduleSettings.catalog[moduleKey]) === null || _b === void 0 ? void 0 : _b.requires) !== null && _c !== void 0 ? _c : [],
10441
- };
10442
- }
10443
- // The module's own grant is evaluated before its prerequisites, so
10444
- // `notGranted` is reported in preference when both hold.
10445
- if (!isGranted) {
10446
- return { moduleKey, isAvailable: false, isGranted, reason: 'notGranted' };
10447
- }
10448
- const requires = (_e = (_d = moduleSettings.catalog[moduleKey]) === null || _d === void 0 ? void 0 : _d.requires) !== null && _e !== void 0 ? _e : [];
10449
- if (requires.length === 0)
10450
- return { moduleKey, isAvailable: true, isGranted };
10451
- // `requires` is satisfied by any one entry, transitively.
10452
- const isSatisfied = requires.some(dependency => resolveModuleAvailability(moduleSettings, dependency, new Set([...seen, moduleKey]))
10453
- .isAvailable);
10454
- if (isSatisfied)
10455
- return { moduleKey, isAvailable: true, isGranted };
10456
- /*
10457
- * `unsatisfied` carries the whole `requires` list rather than one entry. Any
10458
- * one of them would have satisfied the requirement, so naming a single
10459
- * module misdirects: telling a Community-only customer "Comment needs post"
10460
- * hides that Story would also have done.
10461
- */
10462
- return {
10463
- moduleKey,
10464
- isAvailable: false,
10465
- isGranted,
10466
- reason: 'prerequisiteUnavailable',
10467
- unsatisfied: requires,
10468
- };
10469
- };
10470
-
10471
10248
  var index$t = /*#__PURE__*/Object.freeze({
10472
10249
  __proto__: null,
10473
10250
  getActiveClient: getActiveClient,
@@ -10491,7 +10268,6 @@ var index$t = /*#__PURE__*/Object.freeze({
10491
10268
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10492
10269
  getProductCatalogueSetting: getProductCatalogueSetting,
10493
10270
  getForYouFeedSetting: getForYouFeedSetting,
10494
- getModuleSettings: getModuleSettings,
10495
10271
  loginAsVisitor: loginAsVisitor,
10496
10272
  loginAsBot: loginAsBot,
10497
10273
  getCurrentUser: getCurrentUser,
@@ -10519,8 +10295,7 @@ var index$t = /*#__PURE__*/Object.freeze({
10519
10295
  startMarkerSync: startMarkerSync,
10520
10296
  startUnreadSync: startUnreadSync,
10521
10297
  stopUnreadSync: stopUnreadSync,
10522
- getMarkerSyncConsistentMode: getMarkerSyncConsistentMode,
10523
- resolveModuleAvailability: resolveModuleAvailability
10298
+ getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
10524
10299
  });
10525
10300
 
10526
10301
  /* begin_public_function
@@ -37135,4 +36910,4 @@ class AmityAttachmentProductTags {
37135
36910
  }
37136
36911
  }
37137
36912
 
37138
- export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserReportTypeEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
36913
+ export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserReportTypeEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };