@ecency/sdk 1.5.10 → 1.5.12

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,49 @@ function getActiveAccountBookmarksQueryOptions(activeUsername, code) {
889
908
  }
890
909
  });
891
910
  }
892
- function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
911
+ function getBookmarksInfiniteQueryOptions(activeUsername, code, limit = 10) {
912
+ return reactQuery.infiniteQueryOptions({
913
+ queryKey: ["accounts", "bookmarks", "infinite", activeUsername, limit],
914
+ queryFn: async ({ pageParam = 0 }) => {
915
+ if (!activeUsername || !code) {
916
+ return {
917
+ data: [],
918
+ pagination: {
919
+ total: 0,
920
+ limit,
921
+ offset: 0,
922
+ has_next: false
923
+ }
924
+ };
925
+ }
926
+ const fetchApi = getBoundFetch();
927
+ const response = await fetchApi(
928
+ `${CONFIG.privateApiHost}/private-api/bookmarks?format=wrapped&offset=${pageParam}&limit=${limit}`,
929
+ {
930
+ method: "POST",
931
+ headers: {
932
+ "Content-Type": "application/json"
933
+ },
934
+ body: JSON.stringify({ code })
935
+ }
936
+ );
937
+ if (!response.ok) {
938
+ throw new Error(`Failed to fetch bookmarks: ${response.status}`);
939
+ }
940
+ const json = await response.json();
941
+ return normalizeToWrappedResponse(json, limit);
942
+ },
943
+ initialPageParam: 0,
944
+ getNextPageParam: (lastPage) => {
945
+ if (lastPage.pagination.has_next) {
946
+ return lastPage.pagination.offset + lastPage.pagination.limit;
947
+ }
948
+ return void 0;
949
+ },
950
+ enabled: !!activeUsername && !!code
951
+ });
952
+ }
953
+ function getFavouritesQueryOptions(activeUsername, code) {
893
954
  return reactQuery.queryOptions({
894
955
  queryKey: ["accounts", "favourites", activeUsername],
895
956
  enabled: !!activeUsername && !!code,
@@ -912,6 +973,48 @@ function getActiveAccountFavouritesQueryOptions(activeUsername, code) {
912
973
  }
913
974
  });
914
975
  }
976
+ function getFavouritesInfiniteQueryOptions(activeUsername, code, limit = 10) {
977
+ return reactQuery.infiniteQueryOptions({
978
+ queryKey: ["accounts", "favourites", "infinite", activeUsername, limit],
979
+ queryFn: async ({ pageParam = 0 }) => {
980
+ if (!activeUsername || !code) {
981
+ return {
982
+ data: [],
983
+ pagination: {
984
+ total: 0,
985
+ limit,
986
+ offset: 0,
987
+ has_next: false
988
+ }
989
+ };
990
+ }
991
+ const fetchApi = getBoundFetch();
992
+ const response = await fetchApi(
993
+ `${CONFIG.privateApiHost}/private-api/favorites?format=wrapped&offset=${pageParam}&limit=${limit}`,
994
+ {
995
+ method: "POST",
996
+ headers: {
997
+ "Content-Type": "application/json"
998
+ },
999
+ body: JSON.stringify({ code })
1000
+ }
1001
+ );
1002
+ if (!response.ok) {
1003
+ throw new Error(`Failed to fetch favorites: ${response.status}`);
1004
+ }
1005
+ const json = await response.json();
1006
+ return normalizeToWrappedResponse(json, limit);
1007
+ },
1008
+ initialPageParam: 0,
1009
+ getNextPageParam: (lastPage) => {
1010
+ if (lastPage.pagination.has_next) {
1011
+ return lastPage.pagination.offset + lastPage.pagination.limit;
1012
+ }
1013
+ return void 0;
1014
+ },
1015
+ enabled: !!activeUsername && !!code
1016
+ });
1017
+ }
915
1018
  function getAccountRecoveriesQueryOptions(username, code) {
916
1019
  return reactQuery.queryOptions({
917
1020
  enabled: !!username && !!code,
@@ -1245,6 +1348,50 @@ function getFragmentsQueryOptions(username, code) {
1245
1348
  enabled: !!username && !!code
1246
1349
  });
1247
1350
  }
1351
+ function getFragmentsInfiniteQueryOptions(username, code, limit = 10) {
1352
+ return reactQuery.infiniteQueryOptions({
1353
+ queryKey: ["posts", "fragments", "infinite", username, limit],
1354
+ queryFn: async ({ pageParam = 0 }) => {
1355
+ if (!username || !code) {
1356
+ return {
1357
+ data: [],
1358
+ pagination: {
1359
+ total: 0,
1360
+ limit,
1361
+ offset: 0,
1362
+ has_next: false
1363
+ }
1364
+ };
1365
+ }
1366
+ const fetchApi = getBoundFetch();
1367
+ const response = await fetchApi(
1368
+ `${CONFIG.privateApiHost}/private-api/fragments?format=wrapped&offset=${pageParam}&limit=${limit}`,
1369
+ {
1370
+ method: "POST",
1371
+ headers: {
1372
+ "Content-Type": "application/json"
1373
+ },
1374
+ body: JSON.stringify({
1375
+ code
1376
+ })
1377
+ }
1378
+ );
1379
+ if (!response.ok) {
1380
+ throw new Error(`Failed to fetch fragments: ${response.status}`);
1381
+ }
1382
+ const json = await response.json();
1383
+ return normalizeToWrappedResponse(json, limit);
1384
+ },
1385
+ initialPageParam: 0,
1386
+ getNextPageParam: (lastPage) => {
1387
+ if (lastPage.pagination.has_next) {
1388
+ return lastPage.pagination.offset + lastPage.pagination.limit;
1389
+ }
1390
+ return void 0;
1391
+ },
1392
+ enabled: !!username && !!code
1393
+ });
1394
+ }
1248
1395
  function getPromotedPostsQuery(type = "feed") {
1249
1396
  return reactQuery.queryOptions({
1250
1397
  queryKey: ["posts", "promoted", type],
@@ -1865,6 +2012,50 @@ function getSchedulesQueryOptions(activeUsername, code) {
1865
2012
  enabled: !!activeUsername && !!code
1866
2013
  });
1867
2014
  }
2015
+ function getSchedulesInfiniteQueryOptions(activeUsername, code, limit = 10) {
2016
+ return reactQuery.infiniteQueryOptions({
2017
+ queryKey: ["posts", "schedules", "infinite", activeUsername, limit],
2018
+ queryFn: async ({ pageParam = 0 }) => {
2019
+ if (!activeUsername || !code) {
2020
+ return {
2021
+ data: [],
2022
+ pagination: {
2023
+ total: 0,
2024
+ limit,
2025
+ offset: 0,
2026
+ has_next: false
2027
+ }
2028
+ };
2029
+ }
2030
+ const fetchApi = getBoundFetch();
2031
+ const response = await fetchApi(
2032
+ `${CONFIG.privateApiHost}/private-api/schedules?format=wrapped&offset=${pageParam}&limit=${limit}`,
2033
+ {
2034
+ method: "POST",
2035
+ headers: {
2036
+ "Content-Type": "application/json"
2037
+ },
2038
+ body: JSON.stringify({
2039
+ code
2040
+ })
2041
+ }
2042
+ );
2043
+ if (!response.ok) {
2044
+ throw new Error(`Failed to fetch schedules: ${response.status}`);
2045
+ }
2046
+ const json = await response.json();
2047
+ return normalizeToWrappedResponse(json, limit);
2048
+ },
2049
+ initialPageParam: 0,
2050
+ getNextPageParam: (lastPage) => {
2051
+ if (lastPage.pagination.has_next) {
2052
+ return lastPage.pagination.offset + lastPage.pagination.limit;
2053
+ }
2054
+ return void 0;
2055
+ },
2056
+ enabled: !!activeUsername && !!code
2057
+ });
2058
+ }
1868
2059
  function getDraftsQueryOptions(activeUsername, code) {
1869
2060
  return reactQuery.queryOptions({
1870
2061
  queryKey: ["posts", "drafts", activeUsername],
@@ -1890,6 +2081,50 @@ function getDraftsQueryOptions(activeUsername, code) {
1890
2081
  enabled: !!activeUsername && !!code
1891
2082
  });
1892
2083
  }
2084
+ function getDraftsInfiniteQueryOptions(activeUsername, code, limit = 10) {
2085
+ return reactQuery.infiniteQueryOptions({
2086
+ queryKey: ["posts", "drafts", "infinite", activeUsername, limit],
2087
+ queryFn: async ({ pageParam = 0 }) => {
2088
+ if (!activeUsername || !code) {
2089
+ return {
2090
+ data: [],
2091
+ pagination: {
2092
+ total: 0,
2093
+ limit,
2094
+ offset: 0,
2095
+ has_next: false
2096
+ }
2097
+ };
2098
+ }
2099
+ const fetchApi = getBoundFetch();
2100
+ const response = await fetchApi(
2101
+ `${CONFIG.privateApiHost}/private-api/drafts?format=wrapped&offset=${pageParam}&limit=${limit}`,
2102
+ {
2103
+ method: "POST",
2104
+ headers: {
2105
+ "Content-Type": "application/json"
2106
+ },
2107
+ body: JSON.stringify({
2108
+ code
2109
+ })
2110
+ }
2111
+ );
2112
+ if (!response.ok) {
2113
+ throw new Error(`Failed to fetch drafts: ${response.status}`);
2114
+ }
2115
+ const json = await response.json();
2116
+ return normalizeToWrappedResponse(json, limit);
2117
+ },
2118
+ initialPageParam: 0,
2119
+ getNextPageParam: (lastPage) => {
2120
+ if (lastPage.pagination.has_next) {
2121
+ return lastPage.pagination.offset + lastPage.pagination.limit;
2122
+ }
2123
+ return void 0;
2124
+ },
2125
+ enabled: !!activeUsername && !!code
2126
+ });
2127
+ }
1893
2128
  async function fetchUserImages(code) {
1894
2129
  const fetchApi = getBoundFetch();
1895
2130
  const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images", {
@@ -1930,6 +2165,50 @@ function getGalleryImagesQueryOptions(activeUsername, code) {
1930
2165
  enabled: !!activeUsername && !!code
1931
2166
  });
1932
2167
  }
2168
+ function getImagesInfiniteQueryOptions(username, code, limit = 10) {
2169
+ return reactQuery.infiniteQueryOptions({
2170
+ queryKey: ["posts", "images", "infinite", username, limit],
2171
+ queryFn: async ({ pageParam = 0 }) => {
2172
+ if (!username || !code) {
2173
+ return {
2174
+ data: [],
2175
+ pagination: {
2176
+ total: 0,
2177
+ limit,
2178
+ offset: 0,
2179
+ has_next: false
2180
+ }
2181
+ };
2182
+ }
2183
+ const fetchApi = getBoundFetch();
2184
+ const response = await fetchApi(
2185
+ `${CONFIG.privateApiHost}/private-api/images?format=wrapped&offset=${pageParam}&limit=${limit}`,
2186
+ {
2187
+ method: "POST",
2188
+ headers: {
2189
+ "Content-Type": "application/json"
2190
+ },
2191
+ body: JSON.stringify({
2192
+ code
2193
+ })
2194
+ }
2195
+ );
2196
+ if (!response.ok) {
2197
+ throw new Error(`Failed to fetch images: ${response.status}`);
2198
+ }
2199
+ const json = await response.json();
2200
+ return normalizeToWrappedResponse(json, limit);
2201
+ },
2202
+ initialPageParam: 0,
2203
+ getNextPageParam: (lastPage) => {
2204
+ if (lastPage.pagination.has_next) {
2205
+ return lastPage.pagination.offset + lastPage.pagination.limit;
2206
+ }
2207
+ return void 0;
2208
+ },
2209
+ enabled: !!username && !!code
2210
+ });
2211
+ }
1933
2212
  function getCommentHistoryQueryOptions(author, permlink, onlyMeta = false) {
1934
2213
  return reactQuery.queryOptions({
1935
2214
  queryKey: ["posts", "comment-history", author, permlink, onlyMeta],
@@ -5215,9 +5494,9 @@ exports.getAccountReputationsQueryOptions = getAccountReputationsQueryOptions;
5215
5494
  exports.getAccountSubscriptionsQueryOptions = getAccountSubscriptionsQueryOptions;
5216
5495
  exports.getAccountVoteHistoryInfiniteQueryOptions = getAccountVoteHistoryInfiniteQueryOptions;
5217
5496
  exports.getAccountsQueryOptions = getAccountsQueryOptions;
5218
- exports.getActiveAccountBookmarksQueryOptions = getActiveAccountBookmarksQueryOptions;
5219
- exports.getActiveAccountFavouritesQueryOptions = getActiveAccountFavouritesQueryOptions;
5220
5497
  exports.getAnnouncementsQueryOptions = getAnnouncementsQueryOptions;
5498
+ exports.getBookmarksInfiniteQueryOptions = getBookmarksInfiniteQueryOptions;
5499
+ exports.getBookmarksQueryOptions = getBookmarksQueryOptions;
5221
5500
  exports.getBoostPlusAccountPricesQueryOptions = getBoostPlusAccountPricesQueryOptions;
5222
5501
  exports.getBoostPlusPricesQueryOptions = getBoostPlusPricesQueryOptions;
5223
5502
  exports.getBotsQueryOptions = getBotsQueryOptions;
@@ -5246,11 +5525,15 @@ exports.getDiscoverLeaderboardQueryOptions = getDiscoverLeaderboardQueryOptions;
5246
5525
  exports.getDiscussion = getDiscussion;
5247
5526
  exports.getDiscussionQueryOptions = getDiscussionQueryOptions;
5248
5527
  exports.getDiscussionsQueryOptions = getDiscussionsQueryOptions;
5528
+ exports.getDraftsInfiniteQueryOptions = getDraftsInfiniteQueryOptions;
5249
5529
  exports.getDraftsQueryOptions = getDraftsQueryOptions;
5250
5530
  exports.getDynamicPropsQueryOptions = getDynamicPropsQueryOptions;
5251
5531
  exports.getEntryActiveVotesQueryOptions = getEntryActiveVotesQueryOptions;
5532
+ exports.getFavouritesInfiniteQueryOptions = getFavouritesInfiniteQueryOptions;
5533
+ exports.getFavouritesQueryOptions = getFavouritesQueryOptions;
5252
5534
  exports.getFollowCountQueryOptions = getFollowCountQueryOptions;
5253
5535
  exports.getFollowingQueryOptions = getFollowingQueryOptions;
5536
+ exports.getFragmentsInfiniteQueryOptions = getFragmentsInfiniteQueryOptions;
5254
5537
  exports.getFragmentsQueryOptions = getFragmentsQueryOptions;
5255
5538
  exports.getFriendsInfiniteQueryOptions = getFriendsInfiniteQueryOptions;
5256
5539
  exports.getGalleryImagesQueryOptions = getGalleryImagesQueryOptions;
@@ -5268,6 +5551,7 @@ exports.getHiveEngineUnclaimedRewards = getHiveEngineUnclaimedRewards;
5268
5551
  exports.getHiveHbdStatsQueryOptions = getHiveHbdStatsQueryOptions;
5269
5552
  exports.getHivePoshLinksQueryOptions = getHivePoshLinksQueryOptions;
5270
5553
  exports.getHivePrice = getHivePrice;
5554
+ exports.getImagesInfiniteQueryOptions = getImagesInfiniteQueryOptions;
5271
5555
  exports.getImagesQueryOptions = getImagesQueryOptions;
5272
5556
  exports.getIncomingRcQueryOptions = getIncomingRcQueryOptions;
5273
5557
  exports.getMarketData = getMarketData;
@@ -5312,6 +5596,7 @@ exports.getRelationshipBetweenAccounts = getRelationshipBetweenAccounts;
5312
5596
  exports.getRelationshipBetweenAccountsQueryOptions = getRelationshipBetweenAccountsQueryOptions;
5313
5597
  exports.getRewardedCommunitiesQueryOptions = getRewardedCommunitiesQueryOptions;
5314
5598
  exports.getSavingsWithdrawFromQueryOptions = getSavingsWithdrawFromQueryOptions;
5599
+ exports.getSchedulesInfiniteQueryOptions = getSchedulesInfiniteQueryOptions;
5315
5600
  exports.getSchedulesQueryOptions = getSchedulesQueryOptions;
5316
5601
  exports.getSearchAccountQueryOptions = getSearchAccountQueryOptions;
5317
5602
  exports.getSearchAccountsByUsernameQueryOptions = getSearchAccountsByUsernameQueryOptions;
@@ -5340,12 +5625,14 @@ exports.getWithdrawRoutesQueryOptions = getWithdrawRoutesQueryOptions;
5340
5625
  exports.getWitnessesInfiniteQueryOptions = getWitnessesInfiniteQueryOptions;
5341
5626
  exports.hsTokenRenew = hsTokenRenew;
5342
5627
  exports.isCommunity = isCommunity;
5628
+ exports.isWrappedResponse = isWrappedResponse;
5343
5629
  exports.lookupAccountsQueryOptions = lookupAccountsQueryOptions;
5344
5630
  exports.makeQueryClient = makeQueryClient;
5345
5631
  exports.mapThreadItemsToWaveEntries = mapThreadItemsToWaveEntries;
5346
5632
  exports.markNotifications = markNotifications;
5347
5633
  exports.moveSchedule = moveSchedule;
5348
5634
  exports.normalizePost = normalizePost;
5635
+ exports.normalizeToWrappedResponse = normalizeToWrappedResponse;
5349
5636
  exports.normalizeWaveEntryFromApi = normalizeWaveEntryFromApi;
5350
5637
  exports.onboardEmail = onboardEmail;
5351
5638
  exports.parseAccounts = parseAccounts;