← Public packages
@kentcdodds/linkedin
Headless helpers for LinkedIn identity, requests, and guarded posting using the saved linkedin OAuth integration.
Files
import { packageStorage } from 'kody:runtime'
import {
registerVideoUpload,
uploadVideoPart,
finalizeVideoUpload,
getPersonUrn,
} from './client.ts'
import { linkedinRequest, LINKEDIN_VERSION } from './request.ts'
import { uploadVideoBounded, inspectVideoJob, type VideoApi } from './video-upload-engine.ts'
import { videoStore } from './video-upload-store.ts'
function api(): VideoApi {
return {
store: videoStore(packageStorage() as any),
sourceFetch: fetch,
owner: async () => (await getPersonUrn()).personUrn,
register: (size) => registerVideoUpload({ fileSizeBytes: size, confirm: true }),
part: async (url, bytes) =>
String(
(await uploadVideoPart({ uploadUrl: url, bytes, confirm: true })).uploadedPartId ?? '',
),
finalize: (video, uploadToken, uploadedPartIds) =>
finalizeVideoUpload({ video, uploadToken, uploadedPartIds, confirm: true }),
status: async (video) =>
String(
(await linkedinRequest<any>('/rest/videos/' + encodeURIComponent(video), { restli: true, linkedinVersion: LINKEDIN_VERSION }))
.status ?? 'UNKNOWN',
),
}
}
/** Upload only, never post. Strong source ETag required; checkpoint contains no capability URLs. */
export default async function uploadVideo(p: {
uploadKey: string
sourceId: string
sourceUrl: string
confirm?: boolean
dryRun?: boolean
}) {
return uploadVideoBounded(p, api())
}
/** Read-only reconciliation of the existing upload; never re-register or finalize. */
export async function getVideoUploadStatus(p: { uploadKey: string }) {
return inspectVideoJob(p.uploadKey, api())
}