@postrun/react 2.15.0 → 2.17.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 +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -637,8 +637,9 @@ interface UseMediaUploadOptions {
|
|
|
637
637
|
/**
|
|
638
638
|
* Upload one OR many files and get back platform-validated assets. The hook owns
|
|
639
639
|
* the whole journey per file: create the asset (the API auto-detects
|
|
640
|
-
* kind/content_type from the bytes),
|
|
641
|
-
* poll until processing settles, and expose
|
|
640
|
+
* kind/content_type from the bytes), upload the bytes with a resumable multipart
|
|
641
|
+
* upload (live `progress`), poll until processing settles, and expose
|
|
642
|
+
* `media.per_platform` (per-target
|
|
642
643
|
* status, url, warnings,
|
|
643
644
|
* errors). Every file gets its own `MediaUploadItem` slot in `items`; `ready` is
|
|
644
645
|
* the settled assets to attach to a post; `remove`/`reset` abort in-flight work.
|
|
@@ -2400,7 +2401,7 @@ declare function useValidatePost(profileId: string): {
|
|
|
2400
2401
|
validate: (input: Omit<ComposePostInput, "profileId">) => Promise<PostValidation>;
|
|
2401
2402
|
publishable: boolean | undefined;
|
|
2402
2403
|
issues: {
|
|
2403
|
-
code: "unauthorized" | "forbidden" | "not_found" | "conflict" | "validation_failed" | "rate_limited" | "internal_error" | "idempotency_key_invalid" | "idempotency_key_reused" | "idempotency_request_in_progress" | "account_not_available" | "connection_reauth_required" | "connection_not_pending" | "not_implemented" | "connection_discovery_failed" | "tiktok_creator_info_unavailable" | "media_processing" | "not_publishable" | "invalid_connection" | "invalid_media" | "profile_scope_invalid" | "media_unprobeable" | "media_too_large" | "media_aspect_ratio_unsupported" | "media_resolution_too_low" | "media_gif_unsupported" | "media_format_recompressed" | "media_resolution_downscaled" | "video_container_unsupported" | "video_codec_unsupported" | "video_audio_codec_unsupported" | "video_too_large" | "video_too_small" | "video_dimensions_unsupported" | "video_dimensions_too_large" | "video_fps_unsupported" | "video_fps_too_low" | "video_aspect_unsupported" | "video_duration_too_short" | "video_duration_exceeds_max" | "video_transform_failed" | "media_fetch_failed" | "document_format_unsupported" | "document_too_large" | "document_too_many_pages" | "media_format_indeterminate" | "media_format_unsupported" | "media_count_invalid" | "body_too_long" | "content_missing" | "content_conflict" | "content_incomplete" | "content_kind_mismatch" | "media_type_mismatch" | "tag_limit_exceeded" | "reel_field_on_non_reel" | "field_placement_invalid" | "media_not_ready" | "media_failed" | "media_unsupported" | "media_kind_mismatch" | "variant_unparseable" | "publishing_unavailable" | "x_duplicate_content" | "x_not_authorized" | "x_access_not_permitted" | "x_rate_limited" | "x_publish_failed" | "x_media_upload_failed" | "linkedin_duplicate_content" | "linkedin_auth_expired" | "linkedin_permission_denied" | "linkedin_rate_limited" | "linkedin_media_processing" | "linkedin_media_failed" | "linkedin_media_upload_failed" | "linkedin_publish_failed" | "instagram_media_processing" | "instagram_container_expired" | "instagram_container_failed" | "instagram_rate_limited" | "instagram_not_authorized" | "instagram_publish_failed" | "facebook_reel_processing" | "facebook_reel_failed" | "facebook_rate_limited" | "facebook_not_authorized" | "facebook_publish_failed" | "tiktok_privacy_not_allowed" | "tiktok_duration_exceeds_max" | "tiktok_media_processing" | "tiktok_not_authorized" | "tiktok_rate_limited" | "tiktok_url_ownership_unverified" | "tiktok_unaudited_private_only" | "tiktok_spam_risk" | "tiktok_publish_failed" | "post_publish_failed" | "post_partially_published" | "connection_platform_mismatch" | "connection_removed";
|
|
2404
|
+
code: "unauthorized" | "forbidden" | "not_found" | "conflict" | "validation_failed" | "rate_limited" | "internal_error" | "idempotency_key_invalid" | "idempotency_key_reused" | "idempotency_request_in_progress" | "account_not_available" | "connection_reauth_required" | "connection_not_pending" | "not_implemented" | "connection_discovery_failed" | "tiktok_creator_info_unavailable" | "media_processing" | "media_upload_init_failed" | "media_upload_incomplete" | "not_publishable" | "invalid_connection" | "invalid_media" | "profile_scope_invalid" | "media_unprobeable" | "media_too_large" | "media_aspect_ratio_unsupported" | "media_resolution_too_low" | "media_gif_unsupported" | "media_format_recompressed" | "media_resolution_downscaled" | "video_container_unsupported" | "video_codec_unsupported" | "video_audio_codec_unsupported" | "video_too_large" | "video_too_small" | "video_dimensions_unsupported" | "video_dimensions_too_large" | "video_fps_unsupported" | "video_fps_too_low" | "video_aspect_unsupported" | "video_duration_too_short" | "video_duration_exceeds_max" | "video_transform_failed" | "media_fetch_failed" | "document_format_unsupported" | "document_too_large" | "document_too_many_pages" | "media_format_indeterminate" | "media_format_unsupported" | "media_count_invalid" | "body_too_long" | "content_missing" | "content_conflict" | "content_incomplete" | "content_kind_mismatch" | "media_type_mismatch" | "tag_limit_exceeded" | "reel_field_on_non_reel" | "field_placement_invalid" | "media_not_ready" | "media_failed" | "media_unsupported" | "media_kind_mismatch" | "variant_unparseable" | "publishing_unavailable" | "x_duplicate_content" | "x_not_authorized" | "x_access_not_permitted" | "x_rate_limited" | "x_publish_failed" | "x_media_upload_failed" | "linkedin_duplicate_content" | "linkedin_auth_expired" | "linkedin_permission_denied" | "linkedin_rate_limited" | "linkedin_media_processing" | "linkedin_media_failed" | "linkedin_media_upload_failed" | "linkedin_publish_failed" | "instagram_media_processing" | "instagram_container_expired" | "instagram_container_failed" | "instagram_rate_limited" | "instagram_daily_limit_reached" | "instagram_aspect_ratio_unsupported" | "instagram_media_unsupported" | "instagram_not_authorized" | "instagram_publish_failed" | "facebook_reel_processing" | "facebook_reel_failed" | "facebook_rate_limited" | "facebook_duplicate_content" | "facebook_temporarily_blocked" | "facebook_not_authorized" | "facebook_publish_failed" | "tiktok_privacy_not_allowed" | "tiktok_duration_exceeds_max" | "tiktok_media_processing" | "tiktok_not_authorized" | "tiktok_rate_limited" | "tiktok_url_ownership_unverified" | "tiktok_unaudited_private_only" | "tiktok_spam_risk" | "tiktok_publish_failed" | "post_publish_failed" | "post_partially_published" | "connection_platform_mismatch" | "connection_removed";
|
|
2404
2405
|
message: string;
|
|
2405
2406
|
hint?: string;
|
|
2406
2407
|
allowed?: Array<string>;
|
|
@@ -2941,9 +2942,9 @@ interface XPreviewQuotedTweet {
|
|
|
2941
2942
|
* pixel URL. Documents aren't previewable and are dropped.
|
|
2942
2943
|
*/
|
|
2943
2944
|
/** One variant's media reference — the WRITE (compose, id-only) OR the READ
|
|
2944
|
-
* (enriched, carries the full
|
|
2945
|
-
* variant unions, never re-declared. The
|
|
2946
|
-
*
|
|
2945
|
+
* (enriched, carries the full `MediaResource` inline) shape. Both are derived
|
|
2946
|
+
* from the SDK variant unions, never re-declared. The read member's inline asset
|
|
2947
|
+
* IS the shared `Media` component (same type as `MediaResource`), so no bridge. */
|
|
2947
2948
|
type VariantMediaRef = NonNullable<PostVariantInput['media']>[number] | NonNullable<PostVariant['media']>[number];
|
|
2948
2949
|
/**
|
|
2949
2950
|
* Resolve a variant's media to renderable items for ONE platform target.
|
package/dist/index.d.ts
CHANGED
|
@@ -637,8 +637,9 @@ interface UseMediaUploadOptions {
|
|
|
637
637
|
/**
|
|
638
638
|
* Upload one OR many files and get back platform-validated assets. The hook owns
|
|
639
639
|
* the whole journey per file: create the asset (the API auto-detects
|
|
640
|
-
* kind/content_type from the bytes),
|
|
641
|
-
* poll until processing settles, and expose
|
|
640
|
+
* kind/content_type from the bytes), upload the bytes with a resumable multipart
|
|
641
|
+
* upload (live `progress`), poll until processing settles, and expose
|
|
642
|
+
* `media.per_platform` (per-target
|
|
642
643
|
* status, url, warnings,
|
|
643
644
|
* errors). Every file gets its own `MediaUploadItem` slot in `items`; `ready` is
|
|
644
645
|
* the settled assets to attach to a post; `remove`/`reset` abort in-flight work.
|
|
@@ -2400,7 +2401,7 @@ declare function useValidatePost(profileId: string): {
|
|
|
2400
2401
|
validate: (input: Omit<ComposePostInput, "profileId">) => Promise<PostValidation>;
|
|
2401
2402
|
publishable: boolean | undefined;
|
|
2402
2403
|
issues: {
|
|
2403
|
-
code: "unauthorized" | "forbidden" | "not_found" | "conflict" | "validation_failed" | "rate_limited" | "internal_error" | "idempotency_key_invalid" | "idempotency_key_reused" | "idempotency_request_in_progress" | "account_not_available" | "connection_reauth_required" | "connection_not_pending" | "not_implemented" | "connection_discovery_failed" | "tiktok_creator_info_unavailable" | "media_processing" | "not_publishable" | "invalid_connection" | "invalid_media" | "profile_scope_invalid" | "media_unprobeable" | "media_too_large" | "media_aspect_ratio_unsupported" | "media_resolution_too_low" | "media_gif_unsupported" | "media_format_recompressed" | "media_resolution_downscaled" | "video_container_unsupported" | "video_codec_unsupported" | "video_audio_codec_unsupported" | "video_too_large" | "video_too_small" | "video_dimensions_unsupported" | "video_dimensions_too_large" | "video_fps_unsupported" | "video_fps_too_low" | "video_aspect_unsupported" | "video_duration_too_short" | "video_duration_exceeds_max" | "video_transform_failed" | "media_fetch_failed" | "document_format_unsupported" | "document_too_large" | "document_too_many_pages" | "media_format_indeterminate" | "media_format_unsupported" | "media_count_invalid" | "body_too_long" | "content_missing" | "content_conflict" | "content_incomplete" | "content_kind_mismatch" | "media_type_mismatch" | "tag_limit_exceeded" | "reel_field_on_non_reel" | "field_placement_invalid" | "media_not_ready" | "media_failed" | "media_unsupported" | "media_kind_mismatch" | "variant_unparseable" | "publishing_unavailable" | "x_duplicate_content" | "x_not_authorized" | "x_access_not_permitted" | "x_rate_limited" | "x_publish_failed" | "x_media_upload_failed" | "linkedin_duplicate_content" | "linkedin_auth_expired" | "linkedin_permission_denied" | "linkedin_rate_limited" | "linkedin_media_processing" | "linkedin_media_failed" | "linkedin_media_upload_failed" | "linkedin_publish_failed" | "instagram_media_processing" | "instagram_container_expired" | "instagram_container_failed" | "instagram_rate_limited" | "instagram_not_authorized" | "instagram_publish_failed" | "facebook_reel_processing" | "facebook_reel_failed" | "facebook_rate_limited" | "facebook_not_authorized" | "facebook_publish_failed" | "tiktok_privacy_not_allowed" | "tiktok_duration_exceeds_max" | "tiktok_media_processing" | "tiktok_not_authorized" | "tiktok_rate_limited" | "tiktok_url_ownership_unverified" | "tiktok_unaudited_private_only" | "tiktok_spam_risk" | "tiktok_publish_failed" | "post_publish_failed" | "post_partially_published" | "connection_platform_mismatch" | "connection_removed";
|
|
2404
|
+
code: "unauthorized" | "forbidden" | "not_found" | "conflict" | "validation_failed" | "rate_limited" | "internal_error" | "idempotency_key_invalid" | "idempotency_key_reused" | "idempotency_request_in_progress" | "account_not_available" | "connection_reauth_required" | "connection_not_pending" | "not_implemented" | "connection_discovery_failed" | "tiktok_creator_info_unavailable" | "media_processing" | "media_upload_init_failed" | "media_upload_incomplete" | "not_publishable" | "invalid_connection" | "invalid_media" | "profile_scope_invalid" | "media_unprobeable" | "media_too_large" | "media_aspect_ratio_unsupported" | "media_resolution_too_low" | "media_gif_unsupported" | "media_format_recompressed" | "media_resolution_downscaled" | "video_container_unsupported" | "video_codec_unsupported" | "video_audio_codec_unsupported" | "video_too_large" | "video_too_small" | "video_dimensions_unsupported" | "video_dimensions_too_large" | "video_fps_unsupported" | "video_fps_too_low" | "video_aspect_unsupported" | "video_duration_too_short" | "video_duration_exceeds_max" | "video_transform_failed" | "media_fetch_failed" | "document_format_unsupported" | "document_too_large" | "document_too_many_pages" | "media_format_indeterminate" | "media_format_unsupported" | "media_count_invalid" | "body_too_long" | "content_missing" | "content_conflict" | "content_incomplete" | "content_kind_mismatch" | "media_type_mismatch" | "tag_limit_exceeded" | "reel_field_on_non_reel" | "field_placement_invalid" | "media_not_ready" | "media_failed" | "media_unsupported" | "media_kind_mismatch" | "variant_unparseable" | "publishing_unavailable" | "x_duplicate_content" | "x_not_authorized" | "x_access_not_permitted" | "x_rate_limited" | "x_publish_failed" | "x_media_upload_failed" | "linkedin_duplicate_content" | "linkedin_auth_expired" | "linkedin_permission_denied" | "linkedin_rate_limited" | "linkedin_media_processing" | "linkedin_media_failed" | "linkedin_media_upload_failed" | "linkedin_publish_failed" | "instagram_media_processing" | "instagram_container_expired" | "instagram_container_failed" | "instagram_rate_limited" | "instagram_daily_limit_reached" | "instagram_aspect_ratio_unsupported" | "instagram_media_unsupported" | "instagram_not_authorized" | "instagram_publish_failed" | "facebook_reel_processing" | "facebook_reel_failed" | "facebook_rate_limited" | "facebook_duplicate_content" | "facebook_temporarily_blocked" | "facebook_not_authorized" | "facebook_publish_failed" | "tiktok_privacy_not_allowed" | "tiktok_duration_exceeds_max" | "tiktok_media_processing" | "tiktok_not_authorized" | "tiktok_rate_limited" | "tiktok_url_ownership_unverified" | "tiktok_unaudited_private_only" | "tiktok_spam_risk" | "tiktok_publish_failed" | "post_publish_failed" | "post_partially_published" | "connection_platform_mismatch" | "connection_removed";
|
|
2404
2405
|
message: string;
|
|
2405
2406
|
hint?: string;
|
|
2406
2407
|
allowed?: Array<string>;
|
|
@@ -2941,9 +2942,9 @@ interface XPreviewQuotedTweet {
|
|
|
2941
2942
|
* pixel URL. Documents aren't previewable and are dropped.
|
|
2942
2943
|
*/
|
|
2943
2944
|
/** One variant's media reference — the WRITE (compose, id-only) OR the READ
|
|
2944
|
-
* (enriched, carries the full
|
|
2945
|
-
* variant unions, never re-declared. The
|
|
2946
|
-
*
|
|
2945
|
+
* (enriched, carries the full `MediaResource` inline) shape. Both are derived
|
|
2946
|
+
* from the SDK variant unions, never re-declared. The read member's inline asset
|
|
2947
|
+
* IS the shared `Media` component (same type as `MediaResource`), so no bridge. */
|
|
2947
2948
|
type VariantMediaRef = NonNullable<PostVariantInput['media']>[number] | NonNullable<PostVariant['media']>[number];
|
|
2948
2949
|
/**
|
|
2949
2950
|
* Resolve a variant's media to renderable items for ONE platform target.
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, memo, useMemo, useState, Fragment as Fragment$1, useRef, useLayoutEffect, useCallback, useEffect, createElement, useContext, useId } from 'react';
|
|
3
3
|
import { useInfiniteQuery, useQuery, useMutation, QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { xPollDurationLabel, linkedinPollDurationLabel, createPostrunClient, profilesList, profilesGet, profilesCreate, profilesUpdate, profilesDelete, connectionsConnect, connectionsListByProfile, connectionsGet, connectionsListAccounts, connectionsSelect, connectionsDelete, mediaGet, mediaList, mediaUpdate, mediaDelete, postsList, postsGet, postsCreate, buildCreatePost, isPostPlatform, failedVariants, isPublished, postsValidate, postsUpdate, postsDelete, tiktokCreatorInfo, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, captionMaxFor, commercialLabelNotice, commercialDisclosureIncomplete, setCommercialDisclosure, setBrandKind, TIKTOK_DISCLOSURE_REQUIRED_HINT, TIKTOK_BRANDED_CONTENT_POLICY_URL, TIKTOK_MUSIC_CONFIRMATION_URL, interactionRows, interactionValueKey, toggleInteraction, tiktokOptionsReady, TIKTOK_PROCESSING_NOTICE, brandedContentDeclared, mediaCreate,
|
|
4
|
+
import { xPollDurationLabel, linkedinPollDurationLabel, createPostrunClient, profilesList, profilesGet, profilesCreate, profilesUpdate, profilesDelete, connectionsConnect, connectionsListByProfile, connectionsGet, connectionsListAccounts, connectionsSelect, connectionsDelete, mediaGet, mediaList, mediaUpdate, mediaDelete, postsList, postsGet, postsCreate, buildCreatePost, isPostPlatform, failedVariants, isPublished, postsValidate, postsUpdate, postsDelete, tiktokCreatorInfo, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, captionMaxFor, commercialLabelNotice, commercialDisclosureIncomplete, setCommercialDisclosure, setBrandKind, TIKTOK_DISCLOSURE_REQUIRED_HINT, TIKTOK_BRANDED_CONTENT_POLICY_URL, TIKTOK_MUSIC_CONFIRMATION_URL, interactionRows, interactionValueKey, toggleInteraction, tiktokOptionsReady, TIKTOK_PROCESSING_NOTICE, brandedContentDeclared, mediaCreate, uploadFile, PostrunError } from '@postrun/js';
|
|
5
5
|
export { TIKTOK_CAPTION_MAX, UploadError, captionMaxFor } from '@postrun/js';
|
|
6
6
|
import Nango, { AuthError } from '@nangohq/frontend';
|
|
7
7
|
import pWaitFor, { TimeoutError } from 'p-wait-for';
|
|
@@ -603,7 +603,10 @@ async function runUpload(client, file, options, signal, callbacks) {
|
|
|
603
603
|
}
|
|
604
604
|
})).data;
|
|
605
605
|
if (created.upload) {
|
|
606
|
-
await
|
|
606
|
+
await uploadFile(file, {
|
|
607
|
+
mediaId: created.id,
|
|
608
|
+
session: created.upload,
|
|
609
|
+
client,
|
|
607
610
|
onProgress: callbacks.onProgress,
|
|
608
611
|
signal
|
|
609
612
|
});
|
|
@@ -930,9 +933,6 @@ function resourceFor(ref, fallback) {
|
|
|
930
933
|
}
|
|
931
934
|
return fallback?.find((asset) => asset.id === ref.media_id);
|
|
932
935
|
}
|
|
933
|
-
function renditionFor(asset, target) {
|
|
934
|
-
return asset.per_platform[target];
|
|
935
|
-
}
|
|
936
936
|
function resolveVariantMedia(refs, target, fallback) {
|
|
937
937
|
return (refs ?? []).flatMap((ref) => {
|
|
938
938
|
const asset = resourceFor(ref, fallback);
|
|
@@ -946,7 +946,7 @@ function resolveVariantMedia(refs, target, fallback) {
|
|
|
946
946
|
const alt = ref.alt_text_override ?? asset.alt_text ?? void 0;
|
|
947
947
|
const width = asset.source?.width ?? void 0;
|
|
948
948
|
const height = asset.source?.height ?? void 0;
|
|
949
|
-
const rendition =
|
|
949
|
+
const rendition = asset.per_platform[target];
|
|
950
950
|
if (asset.status === "ready" && rendition?.status === "ready" && rendition.url) {
|
|
951
951
|
return [
|
|
952
952
|
{
|