@postrun/react 2.1.0 → 2.2.1

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.
package/dist/index.cjs CHANGED
@@ -140,6 +140,10 @@ var connectionKeys = {
140
140
  detail: (id) => [...connectionKeys.details(), id],
141
141
  accounts: (id) => [...connectionKeys.all, "accounts", id]
142
142
  };
143
+ var tiktokKeys = {
144
+ all: [ROOT, "tiktok"],
145
+ creatorInfo: (connectionId) => [...tiktokKeys.all, "creator-info", connectionId]
146
+ };
143
147
 
144
148
  // src/profiles.ts
145
149
  function useProfiles(query) {
@@ -615,6 +619,8 @@ async function uploadBytes(target, file, options = {}) {
615
619
  }
616
620
 
617
621
  // src/media.ts
622
+ var MEDIA_POLL_INTERVAL_MS = 1500;
623
+ var MEDIA_POLL_TIMEOUT_MS = 30 * 60 * 1e3;
618
624
  async function pollUntilSettled(client, id, signal, onTick) {
619
625
  let latest;
620
626
  await pWaitFor__default.default(
@@ -626,7 +632,7 @@ async function pollUntilSettled(client, id, signal, onTick) {
626
632
  onTick?.(latest);
627
633
  return latest.status === "ready" || latest.status === "failed";
628
634
  },
629
- { interval: 1500, timeout: 3e5 }
635
+ { interval: MEDIA_POLL_INTERVAL_MS, timeout: MEDIA_POLL_TIMEOUT_MS }
630
636
  );
631
637
  if (!latest) {
632
638
  throw new Error("Media polling returned no result.");
@@ -964,6 +970,19 @@ function useDeletePost() {
964
970
  queryClient
965
971
  );
966
972
  }
973
+ function useTikTokCreatorInfo(connectionId) {
974
+ const { client, queryClient } = usePostrun();
975
+ return reactQuery.useQuery(
976
+ {
977
+ // `connectionId ?? ''` only ever keys the cache when the query is enabled
978
+ // (a non-null id), so the empty fallback is never used to fetch.
979
+ queryKey: tiktokKeys.creatorInfo(connectionId ?? ""),
980
+ queryFn: async () => (await js.tiktokCreatorInfo({ client, path: { id: connectionId ?? "" } })).data,
981
+ enabled: connectionId !== null
982
+ },
983
+ queryClient
984
+ );
985
+ }
967
986
  function fileKey(file) {
968
987
  return file ? `${file.name}:${file.size}:${file.lastModified}` : "";
969
988
  }
@@ -1688,6 +1707,7 @@ exports.connectionKeys = connectionKeys;
1688
1707
  exports.mediaKeys = mediaKeys;
1689
1708
  exports.postKeys = postKeys;
1690
1709
  exports.profileKeys = profileKeys;
1710
+ exports.tiktokKeys = tiktokKeys;
1691
1711
  exports.useCalendar = useCalendar;
1692
1712
  exports.useConnect = useConnect;
1693
1713
  exports.useConnection = useConnection;
@@ -1712,6 +1732,7 @@ exports.useProfile = useProfile;
1712
1732
  exports.useProfiles = useProfiles;
1713
1733
  exports.useProfilesInfinite = useProfilesInfinite;
1714
1734
  exports.useSelectAccount = useSelectAccount;
1735
+ exports.useTikTokCreatorInfo = useTikTokCreatorInfo;
1715
1736
  exports.useUpdateMedia = useUpdateMedia;
1716
1737
  exports.useUpdatePost = useUpdatePost;
1717
1738
  exports.useUpdateProfile = useUpdateProfile;