@ecency/sdk 1.5.11 → 1.5.13

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.
@@ -413,6 +413,25 @@ function isCommunity(value) {
413
413
  return typeof value === "string" ? /^hive-\d+$/.test(value) : false;
414
414
  }
415
415
 
416
+ // src/modules/core/utils/pagination-helpers.ts
417
+ function isWrappedResponse(response) {
418
+ return response && typeof response === "object" && "data" in response && "pagination" in response && Array.isArray(response.data);
419
+ }
420
+ function normalizeToWrappedResponse(response, limit) {
421
+ if (isWrappedResponse(response)) {
422
+ return response;
423
+ }
424
+ return {
425
+ data: Array.isArray(response) ? response : [],
426
+ pagination: {
427
+ total: Array.isArray(response) ? response.length : 0,
428
+ limit,
429
+ offset: 0,
430
+ has_next: false
431
+ }
432
+ };
433
+ }
434
+
416
435
  // src/modules/core/queries/get-dynamic-props-query-options.ts
417
436
  function getDynamicPropsQueryOptions() {
418
437
  return reactQuery.queryOptions({
@@ -866,7 +885,7 @@ function getAccountSubscriptionsQueryOptions(username) {
866
885
  }
867
886
  });
868
887
  }
869
- function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
888
+ function getBookmarksQueryOptions(activeUsername, code) {
870
889
  return reactQuery.queryOptions({
871
890
  queryKey: ["accounts", "bookmarks", activeUsername],
872
891
  enabled: !!activeUsername && !!code,
@@ -889,7 +908,7 @@ function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
889
908
  }
890
909
  });
891
910
  }
892
- function getActiveAccountBookmarksInfiniteQueryOptions(activeUsername, code, limit = 10) {
911
+ function getBookmarksInfiniteQueryOptions(activeUsername, code, limit = 10) {
893
912
  return reactQuery.infiniteQueryOptions({
894
913
  queryKey: ["accounts", "bookmarks", "infinite", activeUsername, limit],
895
914
  queryFn: async ({ pageParam = 0 }) => {
@@ -918,7 +937,8 @@ function getActiveAccountBookmarksInfiniteQueryOptions(activeUsername, code, lim
918
937
  if (!response.ok) {
919
938
  throw new Error(`Failed to fetch bookmarks: ${response.status}`);
920
939
  }
921
- return response.json();
940
+ const json = await response.json();
941
+ return normalizeToWrappedResponse(json, limit);
922
942
  },
923
943
  initialPageParam: 0,
924
944
  getNextPageParam: (lastPage) => {
@@ -930,7 +950,7 @@ function getActiveAccountBookmarksInfiniteQueryOptions(activeUsername, code, lim
930
950
  enabled: !!activeUsername && !!code
931
951
  });
932
952
  }
933
- function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
953
+ function getFavouritesQueryOptions(activeUsername, code) {
934
954
  return reactQuery.queryOptions({
935
955
  queryKey: ["accounts", "favourites", activeUsername],
936
956
  enabled: !!activeUsername && !!code,
@@ -953,7 +973,7 @@ function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
953
973
  }
954
974
  });
955
975
  }
956
- function getActiveAccountFavouritesInfiniteQueryOptions(activeUsername, code, limit = 10) {
976
+ function getFavouritesInfiniteQueryOptions(activeUsername, code, limit = 10) {
957
977
  return reactQuery.infiniteQueryOptions({
958
978
  queryKey: ["accounts", "favourites", "infinite", activeUsername, limit],
959
979
  queryFn: async ({ pageParam = 0 }) => {
@@ -982,7 +1002,8 @@ function getActiveAccountFavouritesInfiniteQueryOptions(activeUsername, code, li
982
1002
  if (!response.ok) {
983
1003
  throw new Error(`Failed to fetch favorites: ${response.status}`);
984
1004
  }
985
- return response.json();
1005
+ const json = await response.json();
1006
+ return normalizeToWrappedResponse(json, limit);
986
1007
  },
987
1008
  initialPageParam: 0,
988
1009
  getNextPageParam: (lastPage) => {
@@ -1358,7 +1379,8 @@ function getFragmentsInfiniteQueryOptions(username, code, limit = 10) {
1358
1379
  if (!response.ok) {
1359
1380
  throw new Error(`Failed to fetch fragments: ${response.status}`);
1360
1381
  }
1361
- return response.json();
1382
+ const json = await response.json();
1383
+ return normalizeToWrappedResponse(json, limit);
1362
1384
  },
1363
1385
  initialPageParam: 0,
1364
1386
  getNextPageParam: (lastPage) => {
@@ -2021,7 +2043,8 @@ function getSchedulesInfiniteQueryOptions(activeUsername, code, limit = 10) {
2021
2043
  if (!response.ok) {
2022
2044
  throw new Error(`Failed to fetch schedules: ${response.status}`);
2023
2045
  }
2024
- return response.json();
2046
+ const json = await response.json();
2047
+ return normalizeToWrappedResponse(json, limit);
2025
2048
  },
2026
2049
  initialPageParam: 0,
2027
2050
  getNextPageParam: (lastPage) => {
@@ -2089,7 +2112,8 @@ function getDraftsInfiniteQueryOptions(activeUsername, code, limit = 10) {
2089
2112
  if (!response.ok) {
2090
2113
  throw new Error(`Failed to fetch drafts: ${response.status}`);
2091
2114
  }
2092
- return response.json();
2115
+ const json = await response.json();
2116
+ return normalizeToWrappedResponse(json, limit);
2093
2117
  },
2094
2118
  initialPageParam: 0,
2095
2119
  getNextPageParam: (lastPage) => {
@@ -2172,7 +2196,8 @@ function getImagesInfiniteQueryOptions(username, code, limit = 10) {
2172
2196
  if (!response.ok) {
2173
2197
  throw new Error(`Failed to fetch images: ${response.status}`);
2174
2198
  }
2175
- return response.json();
2199
+ const json = await response.json();
2200
+ return normalizeToWrappedResponse(json, limit);
2176
2201
  },
2177
2202
  initialPageParam: 0,
2178
2203
  getNextPageParam: (lastPage) => {
@@ -2315,8 +2340,8 @@ function toEntryArray(x) {
2315
2340
  return Array.isArray(x) ? x : [];
2316
2341
  }
2317
2342
  async function getVisibleFirstLevelThreadItems(container) {
2318
- const queryOptions86 = getDiscussionsQueryOptions(container, "created" /* created */, true);
2319
- const discussionItemsRaw = await CONFIG.queryClient.fetchQuery(queryOptions86);
2343
+ const queryOptions87 = getDiscussionsQueryOptions(container, "created" /* created */, true);
2344
+ const discussionItemsRaw = await CONFIG.queryClient.fetchQuery(queryOptions87);
2320
2345
  const discussionItems = toEntryArray(discussionItemsRaw);
2321
2346
  if (discussionItems.length <= 1) {
2322
2347
  return [];
@@ -4267,6 +4292,15 @@ function getReceivedVestingSharesQueryOptions(username) {
4267
4292
  }
4268
4293
  });
4269
4294
  }
4295
+ function getRecurrentTransfersQueryOptions(username) {
4296
+ return reactQuery.queryOptions({
4297
+ queryKey: ["wallet", "recurrent-transfers", username],
4298
+ queryFn: () => CONFIG.hiveClient.call("condenser_api", "find_recurrent_transfers", [
4299
+ username
4300
+ ]),
4301
+ enabled: !!username
4302
+ });
4303
+ }
4270
4304
  function getWitnessesInfiniteQueryOptions(limit) {
4271
4305
  return reactQuery.infiniteQueryOptions({
4272
4306
  queryKey: ["witnesses", "list", limit],
@@ -5469,11 +5503,9 @@ exports.getAccountReputationsQueryOptions = getAccountReputationsQueryOptions;
5469
5503
  exports.getAccountSubscriptionsQueryOptions = getAccountSubscriptionsQueryOptions;
5470
5504
  exports.getAccountVoteHistoryInfiniteQueryOptions = getAccountVoteHistoryInfiniteQueryOptions;
5471
5505
  exports.getAccountsQueryOptions = getAccountsQueryOptions;
5472
- exports.getActiveAccountBookmarksInfiniteQueryOptions = getActiveAccountBookmarksInfiniteQueryOptions;
5473
- exports.getActiveAccountBookmarksQueryOptions = getActiveAccountBookmarksQueryOptions;
5474
- exports.getActiveAccountFavouritesInfiniteQueryOptions = getActiveAccountFavouritesInfiniteQueryOptions;
5475
- exports.getActiveAccountFavouritesQueryOptions = getActiveAccountFavouritesQueryOptions;
5476
5506
  exports.getAnnouncementsQueryOptions = getAnnouncementsQueryOptions;
5507
+ exports.getBookmarksInfiniteQueryOptions = getBookmarksInfiniteQueryOptions;
5508
+ exports.getBookmarksQueryOptions = getBookmarksQueryOptions;
5477
5509
  exports.getBoostPlusAccountPricesQueryOptions = getBoostPlusAccountPricesQueryOptions;
5478
5510
  exports.getBoostPlusPricesQueryOptions = getBoostPlusPricesQueryOptions;
5479
5511
  exports.getBotsQueryOptions = getBotsQueryOptions;
@@ -5506,6 +5538,8 @@ exports.getDraftsInfiniteQueryOptions = getDraftsInfiniteQueryOptions;
5506
5538
  exports.getDraftsQueryOptions = getDraftsQueryOptions;
5507
5539
  exports.getDynamicPropsQueryOptions = getDynamicPropsQueryOptions;
5508
5540
  exports.getEntryActiveVotesQueryOptions = getEntryActiveVotesQueryOptions;
5541
+ exports.getFavouritesInfiniteQueryOptions = getFavouritesInfiniteQueryOptions;
5542
+ exports.getFavouritesQueryOptions = getFavouritesQueryOptions;
5509
5543
  exports.getFollowCountQueryOptions = getFollowCountQueryOptions;
5510
5544
  exports.getFollowingQueryOptions = getFollowingQueryOptions;
5511
5545
  exports.getFragmentsInfiniteQueryOptions = getFragmentsInfiniteQueryOptions;
@@ -5565,6 +5599,7 @@ exports.getQueryClient = getQueryClient;
5565
5599
  exports.getRcStatsQueryOptions = getRcStatsQueryOptions;
5566
5600
  exports.getReblogsQueryOptions = getReblogsQueryOptions;
5567
5601
  exports.getReceivedVestingSharesQueryOptions = getReceivedVestingSharesQueryOptions;
5602
+ exports.getRecurrentTransfersQueryOptions = getRecurrentTransfersQueryOptions;
5568
5603
  exports.getReferralsInfiniteQueryOptions = getReferralsInfiniteQueryOptions;
5569
5604
  exports.getReferralsStatsQueryOptions = getReferralsStatsQueryOptions;
5570
5605
  exports.getRelationshipBetweenAccounts = getRelationshipBetweenAccounts;
@@ -5600,12 +5635,14 @@ exports.getWithdrawRoutesQueryOptions = getWithdrawRoutesQueryOptions;
5600
5635
  exports.getWitnessesInfiniteQueryOptions = getWitnessesInfiniteQueryOptions;
5601
5636
  exports.hsTokenRenew = hsTokenRenew;
5602
5637
  exports.isCommunity = isCommunity;
5638
+ exports.isWrappedResponse = isWrappedResponse;
5603
5639
  exports.lookupAccountsQueryOptions = lookupAccountsQueryOptions;
5604
5640
  exports.makeQueryClient = makeQueryClient;
5605
5641
  exports.mapThreadItemsToWaveEntries = mapThreadItemsToWaveEntries;
5606
5642
  exports.markNotifications = markNotifications;
5607
5643
  exports.moveSchedule = moveSchedule;
5608
5644
  exports.normalizePost = normalizePost;
5645
+ exports.normalizeToWrappedResponse = normalizeToWrappedResponse;
5609
5646
  exports.normalizeWaveEntryFromApi = normalizeWaveEntryFromApi;
5610
5647
  exports.onboardEmail = onboardEmail;
5611
5648
  exports.parseAccounts = parseAccounts;