| Export | Description |
|---|
createLinkedInAdapter(config?) / createXAdapter(config?) / createFacebookAdapter(config?) / createInstagramAdapter(config?) | Factory per platform; config is { baseUrl?, constraints?: Partial<SocialPlatformConstraints> } (LinkedInAdapterConfig, XAdapterConfig, FacebookAdapterConfig, InstagramAdapterConfig) |
LINKEDIN_CONSTRAINTS / X_CONSTRAINTS / FACEBOOK_CONSTRAINTS / INSTAGRAM_CONSTRAINTS | Default SocialPlatformConstraints per platform |
createAdapterRegistry(adapters) | AdapterRegistry — list(), keys(), find(key) (or undefined), resolve(key) (throws) |
validatePost(post, constraints) | Pre-publish check → SocialValidationResult { ok, issues } |
Subpaths: @venturekit-pro/social/adapters/{linkedin,x,facebook,instagram} export the matching factory and constants.
SocialAdapter
| Member | Description |
|---|
key / displayName / constraints | Identity and limits (SocialPlatformKey is 'linkedin' | 'x' | 'facebook' | 'instagram' | string) |
validate(post) | Sync validation against constraints |
publish(post, credentials) | Publish; returns PublishResult { externalRef, publishedUrl?, publishedAt } |
verify?(externalRef, credentials) | Optional: confirm a post is still live → VerifyResult |
parseWebhook?(payload, headers) | Optional: normalize a platform webhook → WebhookEvent | null |
| Class | When |
|---|
SocialAuthError | Credentials rejected / expired — refresh and retry |
SocialRateLimitError | Platform throttled the call; retryAfterSeconds? when the platform said so |
SocialValidationError | Body or media rejected (permanent) — surface to the editor |
SocialPublishError | Transient or unexpected publish failure — retry with backoff |
| Function | Description |
|---|
downloadMedia(url, platform, options) | Fetch an http(s) media URL into bytes, capped by size and a 30 s timeout (DownloadMediaOptions); errors are typed for the given platform |
ensureUploadableImage(bytes, declaredMimeType, accepted, platform) | Sniff the real format and convert to JPEG when it is not in the accepted set (needs the optional sharp peer) |
sniffImageMime(bytes) | MIME type from the magic number, or undefined |
filenameForMime(mimeType) | A filename with the right extension for multipart uploads |
simplifyRatio(width, height) | '16:9'-style aspect ratio string used by the aspect-ratio constraint |
vendorFetch(platform, url, options?) | The error-mapping fetch the adapters use — maps 401/403 → SocialAuthError, 429 → SocialRateLimitError (FetchOptions → FetchResult) |
| Function | Description |
|---|
listSocialPlatforms(q) | All SocialPlatformRows |
getSocialPlatformByKey(q, key) | One row or null |
createSocialPlatform(q, input) | Insert (CreateSocialPlatformInput) |
patchSocialPlatform(q, key, patch) | Update status / displayName / description / meta (PatchSocialPlatformInput) |
deleteSocialPlatform(q, key) | Returns true when a row was removed |
isUniqueViolation(err) / isForeignKeyViolation(err) | Postgres error-code guards for catalog writes |
getSocialMigrationsDir() | Absolute path of the shipped vk_social_*.sql migrations (auto-discovered by vk migrate) |
SocialPlatformRow: key, displayName, status (SocialPlatformStatus = 'available' \| 'deprecated' \| 'disabled'), description, meta, introducedAt, deprecatedAt, disabledAt, createdAt, updatedAt.
SocialPost (body, media?, link?, firstComment?, idempotencyKey?), SocialMedia (url, mimeType, sizeBytes?, altText?, width?, height?), OAuthCredentials (accessToken, refreshToken?, expiresAt?, authorRef), SocialPlatformConstraints (maxBodyChars, minBodyChars, minHashtags, maxHashtags, allowedMimeTypes, maxMediaCount, allowedAspectRatios, maxMediaSizeBytes, supportsFirstComment), SocialValidationResult, SocialValidationIssue, SocialValidationCode, PublishResult, VerifyResult, WebhookEvent, AdapterRegistry.