@postrun/react 1.2.0 → 1.3.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.
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -2
- package/dist/index.d.ts +33 -2
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -901,6 +901,37 @@ function useCreatePost(profileId) {
|
|
|
901
901
|
connectedChannels: connected.map((connection) => connection.platform).filter(js.isPostPlatform)
|
|
902
902
|
};
|
|
903
903
|
}
|
|
904
|
+
function useValidatePost(profileId) {
|
|
905
|
+
const { client, queryClient } = usePostrun();
|
|
906
|
+
const connections = useConnections(profileId);
|
|
907
|
+
const connected = connections.data?.data ?? [];
|
|
908
|
+
const mutation = reactQuery.useMutation(
|
|
909
|
+
{
|
|
910
|
+
mutationFn: async (input) => (await js.postsValidate({
|
|
911
|
+
client,
|
|
912
|
+
body: js.buildCreatePost({ ...input, profileId }, connected)
|
|
913
|
+
})).data
|
|
914
|
+
},
|
|
915
|
+
queryClient
|
|
916
|
+
);
|
|
917
|
+
const { mutateAsync } = mutation;
|
|
918
|
+
const validate = react.useCallback(
|
|
919
|
+
(input) => mutateAsync(input),
|
|
920
|
+
[mutateAsync]
|
|
921
|
+
);
|
|
922
|
+
const issues = mutation.data?.issues ?? [];
|
|
923
|
+
return {
|
|
924
|
+
validate,
|
|
925
|
+
// The server's verdict (undefined until the first call resolves).
|
|
926
|
+
publishable: mutation.data?.publishable,
|
|
927
|
+
issues,
|
|
928
|
+
isPending: mutation.isPending,
|
|
929
|
+
error: mutation.error,
|
|
930
|
+
// Connections must load before `validate` can resolve a channel.
|
|
931
|
+
isReady: connections.isSuccess,
|
|
932
|
+
connectedChannels: connected.map((connection) => connection.platform).filter(js.isPostPlatform)
|
|
933
|
+
};
|
|
934
|
+
}
|
|
904
935
|
function useUpdatePost(postId) {
|
|
905
936
|
const { client, queryClient } = usePostrun();
|
|
906
937
|
return reactQuery.useMutation(
|
|
@@ -1678,5 +1709,6 @@ exports.useSelectAccount = useSelectAccount;
|
|
|
1678
1709
|
exports.useUpdateMedia = useUpdateMedia;
|
|
1679
1710
|
exports.useUpdatePost = useUpdatePost;
|
|
1680
1711
|
exports.useUpdateProfile = useUpdateProfile;
|
|
1712
|
+
exports.useValidatePost = useValidatePost;
|
|
1681
1713
|
//# sourceMappingURL=index.cjs.map
|
|
1682
1714
|
//# sourceMappingURL=index.cjs.map
|