@corsair-dev/linkedin 0.1.3 → 0.1.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EAER,uBAAuB,EAEvB,MAAM,cAAc,CAAC;AActB,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,kBAAkB;;;;;;;CASM,CAAC;AAEtC,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,uBAAuB,IAC5D,eAAe,CACd,eAAe,EACf,sBAAsB,CAAC,CAAC,CAAC,EACzB,uBAAuB,CAAC,CAAC,CAAC,CAC1B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACzC,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,kBAAkB,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;IAC3D,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACnD,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACrD,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,QAAQ,EAAE,gBA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AuB,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACtE,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,oBAAoB,CACjD,OAAO,cAAc,EACrB,qBAAqB,EACrB,SAAS,EACT,OAAO,kBAAkB,CACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CACxD,qBAAqB,EACrB,OAAO,kBAAkB,CACzB,CAAC;AAEF,QAAA,MAAM,eAAe,EAAG,SAAkB,CAAC;AAE3C,QAAA,MAAM,sBAAsB,IAAc,CAAC;AAE3C,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,qBAAqB,IAAI,aAAa,CAC9E,UAAU,EACV,OAAO,cAAc,EACrB,OAAO,uBAAuB,EAC9B,OAAO,sBAAsB,EAC7B,CAAC,EACD,OAAO,eAAe,EACtB,OAAO,kBAAkB,CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;AAE/E,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,IACjE,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAEvB,wBAAgB,QAAQ,CAAC,KAAK,CAAC,CAAC,SAAS,qBAAqB,EAG7D,eAAe,GAAE,qBAAqB,GAAG,CAAmC,GAC1E,sBAAsB,CAAC,CAAC,CAAC,CA8C3B"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{AuthMissingError as mt,getOAuthAccessToken as ht}from"corsair/core";import{resolveManagedAccessToken as It}from"corsair/hub";import{logEventFromContext as S}from"corsair/core";import{ApiError as A,request as ce}from"corsair/http";var d=class extends Error{constructor(i,o,c,p){super(i);this.status=o;this.code=c;this.retryAfter=p;this.name="LinkedInAPIError"}},le="https://api.linkedin.com",pe="202501",w=2048;async function C(n,t,i={}){if(n.length>w)throw new d(`LinkedIn endpoint exceeds ${w} characters`);let{method:o="GET",body:c,query:p}=i,k={BASE:le,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:t,HEADERS:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,"X-Restli-Protocol-Version":"2.0.0","LinkedIn-Version":pe}},de={method:o,url:n,body:o==="POST"||o==="PUT"||o==="PATCH"?c:void 0,mediaType:"application/json; charset=utf-8",query:o==="GET"?p:void 0};try{return await ce(k,de)}catch(h){throw h instanceof A?new d(h.message,h.status,void 0,h.retryAfter):h instanceof Error?new d(h.message):new d("Unknown LinkedIn API error")}}function ge(n){return n instanceof d||n instanceof A?n.status===401:!1}async function r(n,t,i={}){try{return await C(n,t.key,i)}catch(o){if(ge(o)&&t._refreshAuth){let c=await t._refreshAuth();return await C(n,c,i)}throw o}}var T=async(n,t)=>{let i=await r("/v2/adTargetingFacets",n,{method:"GET"});return await S(n,"linkedin.ads.getTargetingFacets",{...t},"completed"),i},U=async(n,t)=>{let i=await r("/v2/audienceCounts",n,{method:"POST",body:{target:t.target}});return await S(n,"linkedin.ads.getAudienceCounts",{...t},"completed"),i},v=async(n,t)=>{let i={q:"TYPEAHEAD","typeahead.query.text":t.query};t.type&&(i["typeahead.type"]=t.type);let o=await r("/v2/adTargetingEntities",n,{method:"GET",query:i});return await S(n,"linkedin.ads.searchTargetingEntities",{...t},"completed"),o};import{logEventFromContext as me}from"corsair/core";var G=async(n,t)=>{let i=await r(`/v2/socialActions/${encodeURIComponent(t.commented_on_urn)}/comments`,n,{method:"POST",body:{actor:t.actor,object:t.commented_on_urn,message:{text:t.message}}});return await me(n,"linkedin.comments.create",{...t},"completed"),i};import{logEventFromContext as y}from"corsair/core";var O=async(n,t)=>{let i=await r(`/v2/images/${encodeURIComponent(t.image_urn)}`,n,{method:"GET"});return await y(n,"linkedin.images.get",{...t},"completed"),i},_=async(n,t)=>{let i={};if(t.urns&&t.urns.length>0)i.q="urns",i.urns=t.urns;else if(t.owner)i.q="owner",i.owner=t.owner;else throw new d("getImages requires owner or a non-empty urns list");t.start!==void 0&&(i.start=t.start),t.count!==void 0&&(i.count=t.count);let o=await r("/v2/images",n,{method:"GET",query:i});return await y(n,"linkedin.images.list",{...t},"completed"),o},z=async(n,t)=>{let i=await r("/rest/images?action=initializeUpload",n,{method:"POST",body:{initializeUploadRequest:{owner:t.owner}}});return await y(n,"linkedin.images.initializeUpload",{...t},"completed"),i},N=async(n,t)=>{let i={registerUploadRequest:{recipes:["urn:li:digitalmediaRecipe:feedshare-image"],owner:t.owner,serviceRelationships:[{relationshipType:"OWNER",identifier:"urn:li:userGeneratedContent"}]}},o=await r("/v2/assets?action=registerUpload",n,{method:"POST",body:i});return await y(n,"linkedin.images.registerUpload",{...t},"completed"),o};import{logEventFromContext as L}from"corsair/core";var D=async(n,t)=>{let i=t.role_assignee;if(!i){let p=await r("/v2/userinfo",n,{method:"GET"}),k=p.sub??p.id;if(!k)throw new d("Could not determine the authenticated member id to list organizations.");i=`urn:li:person:${k}`}let o={q:"roleAssignee",roleAssignee:i,state:t.state??"APPROVED"};t.role&&t.role.length>0&&(o.role=t.role),t.start!==void 0&&(o.start=t.start),t.count!==void 0&&(o.count=t.count);let c=await r("/v2/organizationAcls",n,{method:"GET",query:o});return await L(n,"linkedin.organizations.getCompanyInfo",{...t},"completed"),c},x=async(n,t)=>{let i=await r("/v2/organizationalEntityFollowerStatistics",n,{method:"GET",query:{q:"organizationHandle",organization:t.organization_urn}}),o=i.elements?.[0],c=o?.totalFollowerCount,p=o?.organizationFollowerCount;return await L(n,"linkedin.organizations.getNetworkSize",{...t},"completed"),{totalFollowerCount:typeof c=="number"?c:void 0,organizationFollowerCount:typeof p=="number"?p:void 0,elements:i.elements}},j=async(n,t)=>{let i={q:"organization",organization:t.organization_urn};t.start!==void 0&&(i.start=t.start),t.count!==void 0&&(i.count=t.count),t.time_integrated?.start&&t.time_integrated?.end&&(i.timeIntervals=`(timeDuration:(start:${t.time_integrated.start},end:${t.time_integrated.end}))`);let o=await r("/v2/organizationPageStatistics",n,{method:"GET",query:i});return await L(n,"linkedin.organizations.getPageStats",{...t},"completed"),o},q=async(n,t)=>{let i={q:"organization",organization:t.organization_urn};t.start!==void 0&&(i.start=t.start),t.count!==void 0&&(i.count=t.count),t.time_integrated?.start&&t.time_integrated?.end&&(i.timeIntervals=`(timeDuration:(start:${t.time_integrated.start},end:${t.time_integrated.end}))`);let o=await r("/v2/organizationalEntityShareStatistics",n,{method:"GET",query:i});return await L(n,"linkedin.organizations.getShareStats",{...t},"completed"),o};import{logEventFromContext as I}from"corsair/core";var F=async(n,t)=>{let i={author:t.author,commentary:t.commentary,visibility:t.visibility??"PUBLIC",lifecycleState:t.lifecycleState??"PUBLISHED"};t.isReshareDisabledByAuthor!==void 0&&(i.isReshareDisabledByAuthor=t.isReshareDisabledByAuthor);let o={};if(t.article_url){let p={source:t.article_url};t.article_title&&(p.title=t.article_title),t.article_description&&(p.description=t.article_description),o.article=p}t.image_urn&&(o.media={id:t.image_urn}),Object.keys(o).length>0&&(i.content=o);let c=await r("/rest/posts",n,{method:"POST",body:i});return await I(n,"linkedin.posts.create",{...t},"completed"),c},M=async(n,t)=>{let i={originalUrl:t.article_url};t.article_title&&(i.title={text:t.article_title}),t.article_description&&(i.description={text:t.article_description}),t.article_thumbnail&&(i.thumbnail=t.article_thumbnail);let o={author:t.authorUrn,lifecycleState:t.lifecycleState??"PUBLISHED",specificContent:{"com.linkedin.ugc.ShareContent":{shareCommentary:{text:t.text??""},shareMediaCategory:"ARTICLE",media:[i]}},visibility:{"com.linkedin.ugc.MemberNetworkVisibility":t.visibility??"PUBLIC"}},c=await r("/v2/ugcPosts",n,{method:"POST",body:o});return await I(n,"linkedin.posts.createArticleShare",{...t},"completed"),c},B=async(n,t)=>{let i=await r(`/rest/posts/${encodeURIComponent(t.post_urn)}`,n,{method:"GET"});return await I(n,"linkedin.posts.getContent",{...t},"completed"),i},V=async(n,t)=>(await r(`/rest/posts/${encodeURIComponent(t.post_id)}`,n,{method:"DELETE"}),await I(n,"linkedin.posts.delete",{...t},"completed"),{success:!0}),H=async(n,t)=>(await r(`/v2/shares/${encodeURIComponent(t.share_id)}`,n,{method:"DELETE"}),await I(n,"linkedin.posts.deleteShare",{...t},"completed"),{success:!0}),K=async(n,t)=>(await r(`/v2/ugcPosts/${encodeURIComponent(t.ugc_post_urn)}`,n,{method:"DELETE"}),await I(n,"linkedin.posts.deleteUgc",{...t},"completed"),{success:!0});import{logEventFromContext as $}from"corsair/core";var Q=async(n,t)=>{let i=await r("/v2/userinfo",n,{method:"GET",query:t.projection?{projection:t.projection}:void 0}),o=i.sub??i.id;if(o&&n.db.users)try{await n.db.users.upsertByEntityId(o,{id:o,sub:i.sub,name:i.name,given_name:i.given_name,family_name:i.family_name,picture:i.picture,email:i.email,locale:i.locale,vanityName:i.vanityName,headline:i.headline})}catch{}return await $(n,"linkedin.profile.getMyInfo",{...t},"completed"),i},W=async(n,t)=>{let i=await r(`/v2/people/${encodeURIComponent(t.person_id)}`,n,{method:"GET",query:t.projection?{projection:t.projection}:void 0});return await $(n,"linkedin.profile.getPerson",{...t},"completed"),i};import{logEventFromContext as ye}from"corsair/core";var X=async(n,t)=>{let i=await r(`/v2/socialActions/${encodeURIComponent(t.entity_urn)}/reactions`,n,{method:"GET",query:{start:t.start,count:t.count}});return await ye(n,"linkedin.reactions.list",{...t},"completed"),i};import{logEventFromContext as Ee}from"corsair/core";var Y=async(n,t)=>{let i={};if(t.video_urn)i.q="urns",i.urns=t.video_urn;else if(t.urns&&t.urns.length>0)i.q="urns",i.urns=t.urns;else if(t.owner)i.q="owner",i.owner=t.owner;else throw new d("getVideos requires video_urn, owner, or a non-empty urns list");t.start!==void 0&&(i.start=t.start),t.count!==void 0&&(i.count=t.count);let o=await r("/v2/videos",n,{method:"GET",query:i});return await Ee(n,"linkedin.videos.list",{...t},"completed"),o};import{z as e}from"zod";var u=e.object({start:e.number().optional(),count:e.number().optional(),total:e.number().optional(),links:e.array(e.record(e.string(),e.unknown())).optional()}).optional(),g=e.string().describe("A LinkedIn URN, e.g. urn:li:person:123, urn:li:organization:456, or urn:li:ugcPost:789."),Pe=e.object({projection:e.string().optional().describe('Optional projection of profile fields to return (e.g. "(sub,name,email)").')}).describe("Fetch the authenticated LinkedIn member's profile (name, headline, profile picture)."),Re=e.object({person_id:e.string().describe("The LinkedIn member ID of the person whose profile to retrieve."),projection:e.string().optional().describe("Optional projection of fields. Defaults to the lite profile; add headline and vanityName for the basic profile (requires r_basicprofile).")}).describe("Retrieve a LinkedIn member profile by person ID."),we=e.object({author:g.describe("Author URN. Use urn:li:person:... to post as a person (w_member_social) or urn:li:organization:... to post as an organization (w_organization_social)."),commentary:e.string().describe("The text commentary (body) of the post."),visibility:e.enum(["PUBLIC","CONNECTIONS","LOGGED_IN_MEMBERS"]).optional().describe("Who can see the post. Defaults to PUBLIC."),lifecycleState:e.enum(["PUBLISHED","DRAFT"]).optional().describe("PUBLISHED to post immediately, DRAFT to save as a draft."),isReshareDisabledByAuthor:e.boolean().optional().describe("When true, other members cannot reshare this post."),article_url:e.string().optional().describe("Optional URL to attach as article content with the post."),article_title:e.string().optional().describe("Title for the attached article. Requires article_url."),article_description:e.string().optional().describe("Description for the attached article. Requires article_url."),image_urn:g.optional().describe("Optional image URN to attach as media.")}).refine(n=>!(n.article_url&&n.image_urn),{message:"A post can attach either an article (article_url) or an image (image_urn), not both."}).describe("Create a new LinkedIn post for a member or organization."),Ce=e.object({authorUrn:g.describe("Author URN, e.g. urn:li:person:... or urn:li:organization:...."),text:e.string().optional().describe("Optional commentary to include alongside the shared URL."),article_url:e.string().describe("The URL to share as an article."),article_title:e.string().optional().describe("Optional title for the article."),article_description:e.string().optional().describe("Optional description for the article."),article_thumbnail:e.string().optional().describe("Optional thumbnail URL for the article."),visibility:e.enum(["PUBLIC","CONNECTIONS"]).optional().describe("Visibility of the share. Defaults to PUBLIC."),lifecycleState:e.enum(["PUBLISHED","DRAFT"]).optional().describe("PUBLISHED to post immediately, DRAFT to save as a draft.")}).describe("Create an article or URL share on LinkedIn via the UGC Posts API."),Ae=e.object({post_urn:e.string().describe("The post URN (e.g. urn:li:post:1234567890) whose content to retrieve.")}).describe("Retrieve detailed content of a specific LinkedIn post."),Te=e.object({post_id:e.string().describe("The post URN or ID to delete via the Posts API (idempotent, returns 204).")}).describe("Delete a LinkedIn post using the Posts API REST endpoint."),Ue=e.object({share_id:e.string().describe("The share ID of the LinkedIn share to delete.")}).describe("Delete a specific LinkedIn post (share) by its share_id."),ve=e.object({ugc_post_urn:e.string().describe("The UGC post URN (e.g. urn:li:ugcPost:12345) to delete.")}).describe("Delete a UGC post using the legacy v2/ugcPosts endpoint (idempotent)."),Ge=e.object({commented_on_urn:e.string().describe("URN of the object being commented on: a share, UGC post, or parent comment."),actor:g.describe("URN of the member or organization posting the comment, e.g. urn:li:person:... or urn:li:organization:...."),message:e.string().describe("The text of the comment (max 3000 characters).")}).describe("Create a first-level or nested comment on a LinkedIn share, UGC post, or comment."),Oe=e.object({entity_urn:e.string().describe("URN of the entity (share, post, or comment) whose reactions to list."),start:e.number().optional().describe("Pagination start index. Defaults to 0."),count:e.number().optional().describe("Number of reactions to return per page.")}).describe("Retrieve reactions (likes, celebrations, etc.) on a LinkedIn entity."),_e=e.object({image_urn:e.string().describe("The image URN (e.g. urn:li:image:C4D22...) whose details to retrieve.")}).describe("Retrieve details of a single LinkedIn image by its URN."),ze=e.object({owner:g.optional().describe("Owner URN. Returns images owned by this member/org."),urns:e.array(e.string()).optional().describe("Specific image URNs to fetch in a single batch request."),start:e.number().optional().describe("Pagination start index."),count:e.number().optional().describe("Number of images per page.")}).refine(n=>!!(n.owner||n.urns&&n.urns.length>0),{message:"getImages requires owner or a non-empty urns list \u2014 LinkedIn rejects /v2/images without a q finder."}).describe("Retrieve LinkedIn image metadata (download URLs, status, dimensions)."),Ne=e.object({owner:g.describe("Owner URN that will own the uploaded image, e.g. urn:li:person:... or urn:li:organization:....")}).describe("Initialize a LinkedIn image upload and return a presigned upload URL plus the image URN."),De=e.object({owner:g.describe("Owner URN for the media asset, e.g. urn:li:person:... or urn:li:organization:....")}).describe("Register a native LinkedIn image upload for feed shares and return a presigned upload URL plus the digital media asset URN."),xe=e.object({video_urn:e.string().optional().describe("A single video URN to retrieve."),owner:g.optional().describe("Owner URN. Returns videos owned by this account."),urns:e.array(e.string()).optional().describe("Specific video URNs to fetch in a batch."),start:e.number().optional().describe("Pagination start index."),count:e.number().optional().describe("Number of videos per page.")}).refine(n=>!!(n.video_urn||n.owner||n.urns&&n.urns.length>0),{message:"getVideos requires video_urn, owner, or a non-empty urns list \u2014 LinkedIn rejects /v2/videos without a q finder."}).describe("Retrieve LinkedIn video metadata (duration, dimensions, download URLs)."),je=e.object({role_assignee:g.optional().describe("Person URN whose organization roles to list. Defaults to the authenticated member."),role:e.array(e.enum(["ADMINISTRATOR","DIRECT_SPONSORED_CONTENT_POSTER","RECRUITING_POSTER","LEAD_GEN_FORMS_MANAGER","CONTENT_ADMIN","ANALYTICS_ROLE"])).optional().describe("Filter to specific organization roles."),state:e.enum(["APPROVED","PENDING","REVOKED"]).optional().describe("Filter to ACLs in a given state. Defaults to APPROVED."),start:e.number().int().min(0).optional().describe("Zero-based pagination offset into the role list."),count:e.number().int().min(1).optional().describe("Maximum number of roles to return per page.")}).describe("Retrieve organizations where the authenticated user has specific roles (ACLs)."),qe=e.object({organization_urn:g.describe("The organization URN (e.g. urn:li:organization:2414183) whose follower count to retrieve.")}).describe("Retrieve the follower count for a LinkedIn organization."),Fe=e.object({organization_urn:g.describe("The organization URN whose page statistics to retrieve."),time_integrated:e.object({start:e.number().optional(),end:e.number().optional()}).optional().describe("Optional time range for time-bound (aggregate) statistics."),start:e.number().optional().describe("Pagination start index."),count:e.number().optional().describe("Number of results per page.")}).describe("Retrieve page statistics (page views, custom button clicks) for a LinkedIn organization."),Me=e.object({organization_urn:g.describe("The organization URN whose share statistics to retrieve."),time_integrated:e.object({start:e.number().optional(),end:e.number().optional()}).optional().describe("Optional time range to filter statistics."),start:e.number().optional().describe("Pagination start index."),count:e.number().optional().describe("Number of results per page.")}).describe("Retrieve share statistics (impressions, clicks, likes, comments, shares) for an organization."),Be=e.object({}).describe("Retrieve available ad targeting facets from the LinkedIn Marketing API (locations, industries, job functions, etc.)."),Ve=e.object({target:e.record(e.string(),e.unknown()).describe("Targeting criteria to estimate audience size for, as a LinkedIn targeting object (e.g. { and: [ { or: [...] }] }).")}).describe("Retrieve audience size counts for specified targeting criteria."),He=e.object({query:e.string().describe("Typeahead search query for targeting entities."),type:e.string().optional().describe("Optional facet type to scope the search (e.g. locations, titles, industries).")}).describe("Search ad targeting entities (geographies, job titles, industries) via typeahead search."),s={GetMyInfo:Pe,GetPerson:Re,CreatePost:we,CreateArticleShare:Ce,GetPostContent:Ae,DeletePost:Te,DeleteSharePost:Ue,DeleteUgcPost:ve,CreateComment:Ge,ListReactions:Oe,GetImage:_e,GetImages:ze,InitializeImageUpload:Ne,RegisterImageUpload:De,GetVideos:xe,GetCompanyInfo:je,GetNetworkSize:qe,GetOrgPageStats:Fe,GetShareStats:Me,GetAdTargetingFacets:Be,GetAudienceCounts:Ve,SearchAdTargetingEntities:He},Ke=e.object({sub:e.string().optional(),id:e.string().optional(),name:e.string().nullable().optional(),given_name:e.string().nullable().optional(),family_name:e.string().nullable().optional(),picture:e.string().nullable().optional(),email:e.string().nullable().optional(),locale:e.string().nullable().optional(),vanityName:e.string().optional(),headline:e.string().optional()}).loose().describe("The authenticated LinkedIn member profile."),$e=e.object({id:e.string().describe("The member ID."),localizedFirstName:e.string().optional(),localizedLastName:e.string().optional(),localizedHeadline:e.string().optional(),vanityName:e.string().optional(),firstName:e.record(e.string(),e.unknown()).optional(),lastName:e.record(e.string(),e.unknown()).optional(),headline:e.record(e.string(),e.unknown()).optional(),profilePicture:e.object({"displayImage~":e.string().optional(),"displayImage~:playableStreams":e.array(e.record(e.string(),e.unknown())).optional()}).loose().optional()}).loose(),Qe=e.object({id:e.string().describe("The URN of the newly created post.")}).describe("Result of creating a LinkedIn post."),We=e.object({id:e.string().describe("The URN of the newly created UGC post."),activity:e.string().optional()}).describe("Result of creating an article/URL share."),Xe=e.object({id:e.string(),author:e.string().optional(),commentary:e.string().optional(),visibility:e.string().optional(),lifecycleState:e.string().optional(),createdAt:e.record(e.string(),e.unknown()).optional(),isReshareDisabledByAuthor:e.boolean().optional(),media:e.record(e.string(),e.unknown()).optional(),content:e.record(e.string(),e.unknown()).optional()}).loose().describe("Detailed content of a LinkedIn post."),P=e.object({success:e.boolean().describe("Whether the delete operation completed.")}).describe("Result of deleting a post."),Ye=e.object({id:e.string().optional().describe("The URN of the created comment."),message:e.string().optional().describe("The comment text."),object:e.string().optional().describe("The URN the comment was posted on."),lastModified:e.record(e.string(),e.unknown()).optional()}).loose().describe("Result of creating a comment."),Ze=e.object({actor:e.string().optional().describe("URN of the member who reacted."),type:e.string().optional().describe("Reaction type, e.g. LIKE, CELEBRATION."),created:e.record(e.string(),e.unknown()).optional()}).loose(),Je=e.object({elements:e.array(Ze).describe("The reactions on the entity."),paging:u}).loose().describe("Reactions on a LinkedIn entity."),Z=e.object({id:e.string().describe("The image URN."),owner:e.string().optional(),status:e.string().optional().describe("UPLOADING, AVAILABLE, WAITING_UPLOAD, etc."),downloadUrl:e.string().nullable().optional(),original:e.object({size:e.string().optional(),width:e.number().optional(),height:e.number().optional()}).loose().optional()}).loose(),et=Z,tt=e.object({elements:e.array(Z),paging:u}).loose(),nt=e.object({value:e.object({image:e.string().describe("The new image URN to use when attaching the image to a post."),uploadUrl:e.string().optional().describe("Presigned URL to PUT the image bytes to."),uploadUrlExpiresAt:e.number().optional().describe("Epoch millis when the upload URL expires.")}).loose()}).loose().describe("Result of initializing an image upload."),it=e.object({value:e.object({asset:e.string().describe("The digital media asset URN to reference in a post."),mediaArtifact:e.string().optional(),uploadMechanism:e.record(e.string(),e.unknown()).optional().describe("Contains the uploadUrl under com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest.")}).loose()}).loose().describe("Result of registering an image upload."),ot=e.object({id:e.string().describe("The video URN."),owner:e.string().optional(),status:e.string().optional().describe("UPLOADING, AVAILABLE, etc."),downloadUrl:e.string().nullable().optional(),durationMilliseconds:e.number().optional(),original:e.object({width:e.number().optional(),height:e.number().optional()}).loose().optional()}).loose(),rt=e.object({elements:e.array(ot),paging:u}).loose(),st=e.object({organization:e.string().optional().describe("Organization URN."),organizationRoleAssignee:e.string().optional(),role:e.string().optional().describe("The role held, e.g. ADMINISTRATOR."),state:e.string().optional()}).loose(),at=e.object({elements:e.array(st),paging:u}).loose(),dt=e.object({totalFollowerCount:e.number().optional().describe("Total followers of the organization."),organizationFollowerCount:e.number().optional(),elements:e.array(e.record(e.string(),e.unknown())).optional(),paging:u}).loose().describe("Follower count for a LinkedIn organization."),J=e.record(e.string(),e.unknown()),ct=e.object({elements:e.array(J).describe("Page statistics entries."),paging:u}).loose(),lt=e.object({elements:e.array(J).describe("Share statistics entries."),paging:u}).loose(),pt=e.object({facets:e.array(e.record(e.string(),e.unknown())).optional().describe("Available targeting facets."),elements:e.array(e.record(e.string(),e.unknown())).optional()}).loose(),gt=e.object({elements:e.array(e.record(e.string(),e.unknown())).optional().describe("Audience size entries for the given targeting criteria."),paging:u}).loose(),ut=e.object({elements:e.array(e.record(e.string(),e.unknown())).optional().describe("Matching targeting entities."),paging:u}).loose(),a={GetMyInfo:Ke,GetPerson:$e,CreatePost:Qe,CreateArticleShare:We,GetPostContent:Xe,DeletePost:P,DeleteSharePost:P,DeleteUgcPost:P,CreateComment:Ye,ListReactions:Je,GetImage:et,GetImages:tt,InitializeImageUpload:nt,RegisterImageUpload:it,GetVideos:rt,GetCompanyInfo:at,GetNetworkSize:dt,GetOrgPageStats:ct,GetShareStats:lt,GetAdTargetingFacets:pt,GetAudienceCounts:gt,SearchAdTargetingEntities:ut};var R={getMyInfo:Q,getPerson:W},m={create:F,createArticleShare:M,getContent:B,delete:V,deleteShare:H,deleteUgc:K},ee={create:G},te={list:X},f={get:O,list:_,initializeUpload:z,registerUpload:N},ne={list:Y},b={getCompanyInfo:D,getNetworkSize:x,getPageStats:j,getShareStats:q},E={getTargetingFacets:T,getAudienceCounts:U,searchTargetingEntities:v};import{ApiError as oe}from"corsair/http";function ie(n){if(n instanceof d||n instanceof oe)return n.status}var re={RATE_LIMIT_ERROR:{match:n=>{if(ie(n)===429)return!0;let t=n.message.toLowerCase();return t.includes("rate_limited")||t.includes("too many requests")||t.includes("429")},handler:async n=>{let t;return(n instanceof d&&n.retryAfter!==void 0||n instanceof oe&&n.retryAfter!==void 0)&&(t=n.retryAfter),{maxRetries:5,headersRetryAfterMs:t}}},AUTH_ERROR:{match:n=>{if(ie(n)===401)return!0;let t=n.message.toLowerCase();return t.includes("unauthorized")||t.includes("invalid_auth")},handler:async()=>({maxRetries:0})},DEFAULT:{match:()=>!0,handler:async()=>({maxRetries:0})}};import{z as l}from"zod";var se=l.object({id:l.string().describe("The LinkedIn member ID of the authenticated user."),sub:l.string().optional().describe("The OIDC subject identifier."),name:l.string().nullable().optional().describe("Display name of the member."),given_name:l.string().nullable().optional().describe("First name."),family_name:l.string().nullable().optional().describe("Last name."),picture:l.string().nullable().optional().describe("Profile picture URL."),email:l.string().nullable().optional().describe("Primary email address."),locale:l.string().nullable().optional().describe("Preferred locale."),headline:l.string().nullable().optional().describe("Profile headline."),vanityName:l.string().nullable().optional().describe("Public vanity name."),createdAt:l.coerce.date().nullable().optional(),updatedAt:l.coerce.date().nullable().optional()});var ae={version:"1.0.0",entities:{users:se}};var ft={oauth_2:{integration:[]},managed:{integration:[]}},bt={profile:{getMyInfo:R.getMyInfo,getPerson:R.getPerson},posts:{create:m.create,createArticleShare:m.createArticleShare,getContent:m.getContent,delete:m.delete,deleteShare:m.deleteShare,deleteUgc:m.deleteUgc},comments:{create:ee.create},reactions:{list:te.list},images:{get:f.get,list:f.list,initializeUpload:f.initializeUpload,registerUpload:f.registerUpload},videos:{list:ne.list},organizations:{getCompanyInfo:b.getCompanyInfo,getNetworkSize:b.getNetworkSize,getPageStats:b.getPageStats,getShareStats:b.getShareStats},ads:{getTargetingFacets:E.getTargetingFacets,getAudienceCounts:E.getAudienceCounts,searchTargetingEntities:E.searchTargetingEntities}},kt={"profile.getMyInfo":{input:s.GetMyInfo,output:a.GetMyInfo},"profile.getPerson":{input:s.GetPerson,output:a.GetPerson},"posts.create":{input:s.CreatePost,output:a.CreatePost},"posts.createArticleShare":{input:s.CreateArticleShare,output:a.CreateArticleShare},"posts.getContent":{input:s.GetPostContent,output:a.GetPostContent},"posts.delete":{input:s.DeletePost,output:a.DeletePost},"posts.deleteShare":{input:s.DeleteSharePost,output:a.DeleteSharePost},"posts.deleteUgc":{input:s.DeleteUgcPost,output:a.DeleteUgcPost},"comments.create":{input:s.CreateComment,output:a.CreateComment},"reactions.list":{input:s.ListReactions,output:a.ListReactions},"images.get":{input:s.GetImage,output:a.GetImage},"images.list":{input:s.GetImages,output:a.GetImages},"images.initializeUpload":{input:s.InitializeImageUpload,output:a.InitializeImageUpload},"images.registerUpload":{input:s.RegisterImageUpload,output:a.RegisterImageUpload},"videos.list":{input:s.GetVideos,output:a.GetVideos},"organizations.getCompanyInfo":{input:s.GetCompanyInfo,output:a.GetCompanyInfo},"organizations.getNetworkSize":{input:s.GetNetworkSize,output:a.GetNetworkSize},"organizations.getPageStats":{input:s.GetOrgPageStats,output:a.GetOrgPageStats},"organizations.getShareStats":{input:s.GetShareStats,output:a.GetShareStats},"ads.getTargetingFacets":{input:s.GetAdTargetingFacets,output:a.GetAdTargetingFacets},"ads.getAudienceCounts":{input:s.GetAudienceCounts,output:a.GetAudienceCounts},"ads.searchTargetingEntities":{input:s.SearchAdTargetingEntities,output:a.SearchAdTargetingEntities}},yt={"profile.getMyInfo":{riskLevel:"read",description:"Fetch the authenticated LinkedIn member's profile."},"profile.getPerson":{riskLevel:"read",description:"Retrieve a LinkedIn member profile by person ID."},"posts.create":{riskLevel:"write",description:"Create a new LinkedIn post for a member or organization."},"posts.createArticleShare":{riskLevel:"write",description:"Create an article or URL share on LinkedIn."},"posts.getContent":{riskLevel:"read",description:"Retrieve detailed content of a specific LinkedIn post."},"posts.delete":{riskLevel:"destructive",irreversible:!0,description:"Delete a LinkedIn post via the Posts API."},"posts.deleteShare":{riskLevel:"destructive",irreversible:!0,description:"Delete a LinkedIn post (share) by its share_id."},"posts.deleteUgc":{riskLevel:"destructive",irreversible:!0,description:"Delete a UGC post via the legacy v2/ugcPosts endpoint."},"comments.create":{riskLevel:"write",description:"Create a comment on a LinkedIn share, UGC post, or comment."},"reactions.list":{riskLevel:"read",description:"List reactions on a LinkedIn entity."},"images.get":{riskLevel:"read",description:"Retrieve details of a single LinkedIn image by URN."},"images.list":{riskLevel:"read",description:"Retrieve LinkedIn image metadata."},"images.initializeUpload":{riskLevel:"write",description:"Initialize a LinkedIn image upload and return an upload URL."},"images.registerUpload":{riskLevel:"write",description:"Register a native image upload for feed shares."},"videos.list":{riskLevel:"read",description:"Retrieve LinkedIn video metadata."},"organizations.getCompanyInfo":{riskLevel:"read",description:"Retrieve organizations where the user has roles."},"organizations.getNetworkSize":{riskLevel:"read",description:"Retrieve the follower count for a LinkedIn organization."},"organizations.getPageStats":{riskLevel:"read",description:"Retrieve page statistics for a LinkedIn organization."},"organizations.getShareStats":{riskLevel:"read",description:"Retrieve share statistics for an organization."},"ads.getTargetingFacets":{riskLevel:"read",description:"Retrieve available LinkedIn ad targeting facets."},"ads.getAudienceCounts":{riskLevel:"read",description:"Retrieve audience size counts for targeting criteria."},"ads.searchTargetingEntities":{riskLevel:"read",description:"Search LinkedIn ad targeting entities via typeahead."}},Lt="oauth_2";function on(n={}){let t={...n,authType:n.authType??Lt};return{id:"linkedin",schema:ae,options:t,authConfig:ft,oauthConfig:{providerName:"LinkedIn",authUrl:"https://www.linkedin.com/oauth/v2/authorization",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",tokenAuthMethod:"body",scopes:["openid","profile","email","r_basicprofile","r_member_social","w_member_social","r_organization_social","w_organization_social","rw_organization_admin","r_organization_admin","r_organization_relationships","r_ads","rw_ads","r_1st_connections_size"]},hooks:t.hooks,endpoints:bt,endpointSchemas:kt,endpointMeta:yt,errorHandlers:{...re,...t.errorHandlers},keyBuilder:async i=>{if(t.key)return t.key;if(i.authType==="oauth_2")return ht(i,{plugin:"linkedin",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",tokenAuthMethod:"body"});if(i.authType==="managed")return It(i,"linkedin");throw new mt("linkedin","oauth_2")}}}export{kt as LinkedInEndpointSchemas,bt as LinkedInEndpointsNested,on as linkedin,ft as linkedinAuthConfig};
1
+ import{AuthMissingError as jn,getOAuthAccessToken as Mn}from"corsair/core";import{resolveManagedAccessToken as Fn}from"corsair/hub";import{logEventFromContext as k}from"corsair/core";import{ApiError as Z,request as bt}from"corsair/http";function A(n){return encodeURIComponent(String(n)).replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/'/g,"%27")}function P(n){return Array.isArray(n)?`List(${n.map(P).join(",")})`:n!==null&&typeof n=="object"?`(${Object.entries(n).filter(([,o])=>o!==void 0).map(([o,i])=>`${P(o)}:${P(i)}`).join(",")})`:n===""?"''":typeof n=="string"||typeof n=="number"||typeof n=="boolean"?A(n):"''"}function g(n){return{restli:P(n)}}function u(n){return g([...n])}function Q(n){if(!n)return"";let t=[];for(let[o,i]of Object.entries(n)){if(i===void 0)continue;let r=typeof i=="object"?i.restli:A(i);t.push(`${encodeURIComponent(o)}=${r}`)}return t.length>0?`?${t.join("&")}`:""}function m(n){return encodeURIComponent(n)}var It=/^[A-Za-z0-9_(),~:.*$-]+$/;function U(n){if(n)return It.test(n)?{restli:n}:n}var l=class extends Error{constructor(o,i,r,Y){super(o);this.status=i;this.code=r;this.retryAfter=Y;this.name="LinkedInAPIError"}},ft="https://api.linkedin.com",yt="202611",W=2048,X=16384;async function J(n,t,o={}){if(n.length>W)throw new l(`LinkedIn endpoint exceeds ${W} characters`);let{method:i="GET",body:r,query:Y,headers:ut,responseHeader:gt}=o,$=`${n}${Q(Y)}`;if($.length>X)throw new l(`LinkedIn request URL exceeds ${X} characters`);let K={"Content-Type":"application/json",Authorization:`Bearer ${t}`,"X-Restli-Protocol-Version":"2.0.0"};n.startsWith("/rest/")&&(K["LinkedIn-Version"]=yt);let mt={BASE:ft,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:t,HEADERS:K},ht={method:i,url:$,body:i==="POST"||i==="PUT"||i==="PATCH"?r:void 0,mediaType:"application/json; charset=utf-8",headers:ut,responseHeader:gt};try{return await bt(mt,ht)}catch(L){throw L instanceof Z?new l(L.message,L.status,void 0,L.retryAfter):L instanceof Error?new l(L.message):new l("Unknown LinkedIn API error")}}function Et(n){return n instanceof l||n instanceof Z?n.status===401:!1}async function s(n,t,o={}){try{return await J(n,t.key,o)}catch(i){if(Et(i)&&t._refreshAuth){let r=await t._refreshAuth();return await J(n,r,o)}throw i}}var ee="urn:li:adTargetingFacet:";function Lt(n){return n.startsWith(ee)?n:`${ee}${n}`}function G(n,t){return n.startsWith("urn:li:")?n:`urn:li:${t}:${n}`}function At(n){let t="urn:li:sponsoredAccount:";return n.startsWith(t)?n.slice(t.length):n}function te(n){let t={};for(let[o,i]of Object.entries(n))i&&i.length>0&&(t[o]={values:[...i]});return Object.keys(t).length>0?g(t):void 0}var ne=async(n,t)=>{let o=await s("/rest/adTargetingFacets",n,{method:"GET"});return await k(n,"linkedin.ads.getTargetingFacets",{...t},"completed"),o},oe=async(n,t)=>{let o=await s("/rest/audienceCounts",n,{method:"GET",query:{q:"targetingCriteriaV2",targetingCriteria:g(t.target)}});return await k(n,"linkedin.ads.getAudienceCounts",{...t},"completed"),o},ie=async(n,t)=>{let o=t.facet??t.type??"",i={q:"typeahead",queryVersion:"QUERY_USES_URNS",facet:Lt(o),query:t.query,entityType:t.entity_type,locale:t.locale?g(t.locale):void 0},r=await s("/rest/adTargetingEntities",n,{method:"GET",query:i});return await k(n,"linkedin.ads.searchTargetingEntities",{...t},"completed"),r},se=async(n,t)=>{let o=await s("/rest/adAccounts",n,{method:"GET",query:{q:"search",search:te({status:t.status,type:t.type}),sortOrder:t.sort_order,pageSize:t.page_size,pageToken:t.page_token}});return await k(n,"linkedin.ads.listAccounts",{...t},"completed"),o},kt=["ACTIVE","PAUSED","ARCHIVED","COMPLETED","CANCELED","DRAFT"],re=async(n,t)=>{let o=(t.status?.length??0)>0,i=await s(`/rest/adAccounts/${encodeURIComponent(At(t.ad_account))}/adCampaigns`,n,{method:"GET",query:{q:"search",search:te({status:o?t.status:kt,type:t.type,campaignGroup:t.campaign_group}),sortOrder:t.sort_order,pageSize:t.page_size,pageToken:t.page_token}});return await k(n,"linkedin.ads.listCampaigns",{...t},"completed"),i},ae=async(n,t)=>{let o={q:"analytics",pivot:t.pivot,timeGranularity:t.time_granularity,dateRange:g(t.date_range)};t.accounts&&t.accounts.length>0&&(o.accounts=u(t.accounts.map(r=>G(r,"sponsoredAccount")))),t.campaign_groups&&t.campaign_groups.length>0&&(o.campaignGroups=u(t.campaign_groups.map(r=>G(r,"sponsoredCampaignGroup")))),t.campaigns&&t.campaigns.length>0&&(o.campaigns=u(t.campaigns.map(r=>G(r,"sponsoredCampaign")))),t.fields&&t.fields.length>0&&(o.fields={restli:t.fields.map(r=>encodeURIComponent(r)).join(",")});let i=await s("/rest/adAnalytics",n,{method:"GET",query:o});return await k(n,"linkedin.ads.getAnalytics",{...t},"completed"),i};import{logEventFromContext as ce}from"corsair/core";var St=/^urn:li:comment:\((urn:li:[^,]+),[^)]+\)$/,le=async(n,t)=>{let o={actor:t.actor,object:t.commented_on_urn,message:{text:t.message}},i=St.exec(t.commented_on_urn);i?.[1]&&(o.object=i[1],o.parentComment=t.commented_on_urn);let r=await s(`/rest/socialActions/${m(t.commented_on_urn)}/comments`,n,{method:"POST",body:o});return await ce(n,"linkedin.comments.create",{...t},"completed"),r},de=async(n,t)=>{let o=await s(`/rest/socialActions/${m(t.entity_urn)}/comments`,n,{method:"GET",query:{start:t.start,count:t.count}});return await ce(n,"linkedin.comments.list",{...t},"completed"),o};import{logEventFromContext as C}from"corsair/core";function z(n,t){let o=t.results??{},i=n.map(r=>o[r]).filter(r=>r!==void 0);return{...t,elements:i}}function D(n){return{q:"associatedAccount",associatedAccount:n.associated_account,start:n.start,count:n.count}}var pe=async(n,t)=>{let o=await s(`/rest/images/${m(t.image_urn)}`,n,{method:"GET"});return await C(n,"linkedin.images.get",{...t},"completed"),o},ue=async(n,t)=>{let o;if(t.urns&&t.urns.length>0){let i=t.urns,r=await s("/rest/images",n,{method:"GET",query:{ids:u(i)}});o=z(i,r)}else{if(!t.associated_account)throw new l("getImages requires a non-empty urns list or associated_account (LinkedIn has no finder by owner)");o=await s("/rest/images",n,{method:"GET",query:D(t)})}return await C(n,"linkedin.images.list",{...t},"completed"),o};async function ge(n,t){return s("/rest/images?action=initializeUpload",n,{method:"POST",body:{initializeUploadRequest:{owner:t}}})}var me=async(n,t)=>{let o=await ge(n,t.owner);return await C(n,"linkedin.images.initializeUpload",{...t},"completed"),o},he=async(n,t)=>{let o=await ge(n,t.owner);return await C(n,"linkedin.images.registerUpload",{...t},"completed"),o};import{logEventFromContext as S}from"corsair/core";function v(n,t){if(!(n?.start===void 0&&n?.end===void 0))return g({timeRange:{start:n?.start,end:n?.end},timeGranularityType:t??"DAY"})}var Ie=async(n,t)=>{let i={q:"roleAssignee",role:Array.isArray(t.role)?t.role[0]:t.role,state:t.state??"APPROVED",start:t.start,count:t.count},r=await s("/rest/organizationAcls",n,{method:"GET",query:i});return await S(n,"linkedin.organizations.getCompanyInfo",{...t},"completed"),r},be=async(n,t)=>{let o=await s(`/rest/networkSizes/${m(t.organization_urn)}`,n,{method:"GET",query:{edgeType:"COMPANY_FOLLOWED_BY_MEMBER"}});return await S(n,"linkedin.organizations.getNetworkSize",{...t},"completed"),{...o,totalFollowerCount:o.firstDegreeSize}},fe=async(n,t)=>{let o=await s("/rest/organizationalEntityFollowerStatistics",n,{method:"GET",query:{q:"organizationalEntity",organizationalEntity:t.organization_urn,timeIntervals:v(t.time_integrated,t.time_granularity)}});return await S(n,"linkedin.organizations.getFollowerStats",{...t},"completed"),o},ye=async(n,t)=>{let o=await s("/rest/organizationPageStatistics",n,{method:"GET",query:{q:"organization",organization:t.organization_urn,timeIntervals:v(t.time_integrated,t.time_granularity),start:t.start,count:t.count}});return await S(n,"linkedin.organizations.getPageStats",{...t},"completed"),o},Ee=async(n,t)=>{let o={q:"organizationalEntity",organizationalEntity:t.organization_urn,timeIntervals:v(t.time_integrated,t.time_granularity)};t.shares&&t.shares.length>0&&(o.shares=u(t.shares)),t.ugc_posts&&t.ugc_posts.length>0&&(o.ugcPosts=u(t.ugc_posts));let i=await s("/rest/organizationalEntityShareStatistics",n,{method:"GET",query:o});return await S(n,"linkedin.organizations.getShareStats",{...t},"completed"),i};import{logEventFromContext as b}from"corsair/core";var Le={feedDistribution:"MAIN_FEED",targetEntities:[],thirdPartyDistributionChannels:[]};function Ae(n){let t={source:n.article_url};return n.article_title&&(t.title=n.article_title),n.article_description&&(t.description=n.article_description),n.article_thumbnail&&(t.thumbnail=n.article_thumbnail),t}async function ke(n,t){let o=await s("/rest/posts",n,{method:"POST",body:t,responseHeader:"x-restli-id"});if(typeof o=="string"&&o.length>0)return{id:o};throw new l("LinkedIn accepted the post but returned no x-restli-id header. Check the author feed before retrying, the post was probably created.")}function _e(n,t){return n.startsWith("urn:li:")?n:`urn:li:${t}:${n}`}async function x(n,t){await s(`/rest/posts/${m(t)}`,n,{method:"DELETE"})}var Se=async(n,t)=>{if(t.image_alt_text&&!t.image_urn)throw new l("image_alt_text requires image_urn: attach the image the alt text describes.",400,"invalid_input");let o={author:t.author,commentary:t.commentary,visibility:t.visibility??"PUBLIC",distribution:Le,lifecycleState:t.lifecycleState??"PUBLISHED"};if(t.isReshareDisabledByAuthor!==void 0&&(o.isReshareDisabledByAuthor=t.isReshareDisabledByAuthor),t.article_url)o.content={article:Ae(t)};else if(t.image_urn){let r={id:t.image_urn};t.image_alt_text&&(r.altText=t.image_alt_text),o.content={media:r}}let i=await ke(n,o);return await b(n,"linkedin.posts.create",{...t},"completed"),i},Re=async(n,t)=>{let o={author:t.authorUrn,commentary:t.text??"",visibility:t.visibility??"PUBLIC",distribution:Le,lifecycleState:t.lifecycleState??"PUBLISHED",content:{article:Ae(t)}},i=await ke(n,o);return await b(n,"linkedin.posts.createArticleShare",{...t},"completed"),i},we=async(n,t)=>{let o=await s(`/rest/posts/${m(t.post_urn)}`,n,{method:"GET",query:{viewContext:t.view_context}});return await b(n,"linkedin.posts.getContent",{...t},"completed"),o},Pe=async(n,t)=>{let o=await s("/rest/posts",n,{method:"GET",query:{author:t.author,q:"author",start:t.start,count:t.count,sortBy:t.sort_by,viewContext:t.view_context},headers:{"X-RestLi-Method":"FINDER"}});return await b(n,"linkedin.posts.list",{...t},"completed"),o},Ce=async(n,t)=>(await x(n,t.post_id),await b(n,"linkedin.posts.delete",{...t},"completed"),{success:!0}),Te=async(n,t)=>(await x(n,_e(t.share_id,"share")),await b(n,"linkedin.posts.deleteShare",{...t},"completed"),{success:!0}),Ne=async(n,t)=>(await x(n,_e(t.ugc_post_urn,"ugcPost")),await b(n,"linkedin.posts.deleteUgc",{...t},"completed"),{success:!0});import{logEventFromContext as Ue}from"corsair/core";var Ge=async(n,t)=>{let o=await s("/v2/userinfo",n,{method:"GET",query:{projection:U(t.projection)}}),i=o.sub??o.id;if(i&&n.db.users)try{await n.db.users.upsertByEntityId(i,{id:i,sub:o.sub,name:o.name,given_name:o.given_name,family_name:o.family_name,picture:o.picture,email:o.email,locale:o.locale,vanityName:o.vanityName,headline:o.headline})}catch{}return await Ue(n,"linkedin.profile.getMyInfo",{...t},"completed"),o},Oe="urn:li:person:",ze=async(n,t)=>{let o=t.person_id.startsWith(Oe)?t.person_id.slice(Oe.length):t.person_id,i=await s(`/v2/people/(id:${A(o)})`,n,{method:"GET",query:{projection:U(t.projection)}});return await Ue(n,"linkedin.profile.getPerson",{...t},"completed"),i};import{logEventFromContext as Nt}from"corsair/core";var De=async(n,t)=>{let o=await s(`/rest/reactions/(entity:${A(t.entity_urn)})`,n,{method:"GET",query:{q:"entity",sort:g({value:t.sort??"REVERSE_CHRONOLOGICAL"}),start:t.start,count:t.count}});return await Nt(n,"linkedin.reactions.list",{...t},"completed"),o};import{logEventFromContext as Ut}from"corsair/core";var ve=async(n,t)=>{let o=t.video_urn?[t.video_urn]:t.urns&&t.urns.length>0?t.urns:void 0,i;if(o){let r=await s("/rest/videos",n,{method:"GET",query:{ids:u(o)}});i=z(o,r)}else{if(!t.associated_account)throw new l("getVideos requires video_urn, a non-empty urns list, or associated_account (LinkedIn has no finder by owner)");i=await s("/rest/videos",n,{method:"GET",query:D(t)})}return await Ut(n,"linkedin.videos.list",{...t},"completed"),i};import{z as e}from"zod";var d=e.object({start:e.number().optional(),count:e.number().optional(),total:e.number().optional(),links:e.array(e.record(e.string(),e.unknown())).optional()}).loose().optional(),h=e.string().describe("A LinkedIn URN, e.g. urn:li:person:123, urn:li:organization:456, or urn:li:ugcPost:789."),R=e.object({actor:e.string().optional(),impersonator:e.string().optional(),time:e.number().optional()}).loose(),y=e.number().int().min(0).optional().describe("Zero-based index of the first result to return."),T=e.number().int().min(1).optional().describe("Number of results per page."),V=e.object({start:e.number().optional().describe("Start of the range, in epoch milliseconds."),end:e.number().optional().describe("End of the range, in epoch milliseconds. LinkedIn uses the current time when unset.")}).optional(),He=e.string().regex(/^urn:li:image:/,"Must be an image URN (urn:li:image:...)."),zt=e.object({projection:e.string().optional().describe('Optional projection of profile fields to return (e.g. "(sub,name,email)").')}).describe("Fetch the authenticated member's OpenID Connect profile (id, name, picture, email). Scopes: openid, profile, email."),Dt=e.object({person_id:e.string().describe("The member ID, or a person URN (urn:li:person:{id}), of the profile to retrieve."),projection:e.string().optional().describe("Optional projection of fields. Defaults to the lite profile; add headline and vanityName for the basic profile (requires r_basicprofile).")}).describe("Retrieve a LinkedIn member profile by person ID via /v2/people/(id:{id}). Scope: r_basicprofile. LinkedIn restricts lookups of other members to approved developers."),vt=e.enum(["PUBLIC","CONNECTIONS","LOGGED_IN"]).optional().describe("Who can see the post: PUBLIC (anyone), CONNECTIONS (1st-degree network) or LOGGED_IN (signed-in members). Defaults to PUBLIC."),Ye=e.enum(["PUBLISHED"]).optional().describe("PUBLISHED is the only lifecycle state LinkedIn accepts when creating a post. Defaults to PUBLISHED."),xt=e.object({author:h.describe("Author URN. Use urn:li:person:... to post as a member (w_member_social) or urn:li:organization:... to post as an organization (w_organization_social)."),commentary:e.string().describe("The text commentary (body) of the post."),visibility:vt,lifecycleState:Ye,isReshareDisabledByAuthor:e.boolean().optional().describe("When true, other members cannot reshare this post."),article_url:e.string().optional().describe("Optional URL to attach as article content with the post."),article_title:e.string().max(400).optional().describe("Title for the attached article, under 400 characters. Required with article_url: LinkedIn does not scrape the URL."),article_description:e.string().optional().describe("Description for the attached article. Requires article_url."),article_thumbnail:He.optional().describe("Image URN (urn:li:image:...) for the article thumbnail, from images.initializeUpload. Requires article_url."),image_urn:h.optional().describe("Optional media URN to attach (urn:li:image:... from images.initializeUpload)."),image_alt_text:e.string().optional().describe("Alt text for the attached image. Requires image_urn.")}).refine(n=>!n.image_alt_text||!!n.image_urn,{message:"image_alt_text requires image_urn."}).refine(n=>!(n.article_url&&n.image_urn),{message:"A post can attach either an article (article_url) or an image (image_urn), not both."}).refine(n=>!n.article_url||!!n.article_title,{message:"article_title is required with article_url: the Posts API does not scrape article URLs."}).refine(n=>!!n.article_url||!(n.article_title||n.article_description||n.article_thumbnail),{message:"article_title, article_description and article_thumbnail require article_url."}).describe("Create a LinkedIn post for a member or organization via the Posts API (/rest/posts)."),jt=e.object({authorUrn:h.describe("Author URN, e.g. urn:li:person:... (w_member_social) or urn:li:organization:... (w_organization_social)."),text:e.string().optional().describe("Optional commentary to include alongside the shared URL."),article_url:e.string().describe("The URL to share as an article."),article_title:e.string().max(400).describe("Title for the article, under 400 characters. Required: the Posts API does not scrape the URL."),article_description:e.string().optional().describe("Optional description for the article."),article_thumbnail:He.optional().describe("Optional thumbnail as an image URN (urn:li:image:...) from images.initializeUpload. The Posts API does not accept a thumbnail URL."),visibility:e.enum(["PUBLIC","CONNECTIONS"]).optional().describe("Visibility of the share. Defaults to PUBLIC."),lifecycleState:Ye}).describe("Create an article (URL) post on LinkedIn. Now sent to the Posts API (/rest/posts); the legacy /v2/ugcPosts call it used is replaced."),$e=e.enum(["READER","AUTHOR"]).optional().describe("READER (default) returns the post as a reader sees it; AUTHOR includes the author's view, e.g. drafts and failed publishes."),Mt=e.object({post_urn:e.string().describe("The post URN (urn:li:share:... or urn:li:ugcPost:...) whose content to retrieve."),view_context:$e}).describe("Retrieve a LinkedIn post by URN. Scopes: r_organization_social for organization posts; member posts need r_member_social, which LinkedIn no longer grants to new apps."),Ft=e.object({author:h.describe("Author URN whose posts to list, e.g. urn:li:organization:2414183."),start:y,count:e.number().int().min(1).max(100).optional().describe("Posts per page, up to 100. LinkedIn defaults to 10."),sort_by:e.enum(["LAST_MODIFIED","CREATED"]).optional().describe("Sort order. LinkedIn defaults to LAST_MODIFIED."),view_context:$e}).describe("List posts by an author (organization or member). Scopes: r_organization_social for organizations; member authors need r_member_social, which LinkedIn no longer grants to new apps."),qt=e.object({post_id:e.string().describe("The post URN (urn:li:share:... or urn:li:ugcPost:...) to delete. Idempotent: LinkedIn returns 204 even if already deleted.")}).describe("Delete a LinkedIn post via the Posts API. Scopes: w_member_social or w_organization_social."),Vt=e.object({share_id:e.string().describe("The share ID (e.g. 6844785523593134080) or share URN (urn:li:share:...) to delete.")}).describe("Delete a LinkedIn share. Now sent to the Posts API (DELETE /rest/posts/{share URN}); the retired /v2/shares call it used is replaced."),Bt=e.object({ugc_post_urn:e.string().describe("The UGC post URN (e.g. urn:li:ugcPost:12345) or its numeric ID to delete.")}).describe("Delete a UGC post. Now sent to the Posts API (DELETE /rest/posts/{ugcPost URN}); the legacy /v2/ugcPosts call it used is replaced."),Ht=e.object({commented_on_urn:e.string().describe("URN of what is being commented on: a post (urn:li:share:..., urn:li:ugcPost:..., urn:li:activity:...) or, for a reply, the parent comment URN (urn:li:comment:(...))."),actor:h.describe("URN of the member or organization posting the comment, e.g. urn:li:person:... or urn:li:organization:...."),message:e.string().describe("The text of the comment.")}).describe("Create a comment, or a reply to a comment, on a LinkedIn post. Scopes: w_member_social or w_organization_social per the Posts API. The 202611 Comments reference lists the Community Management *_feed scopes instead; which it enforces is unconfirmed."),Yt=e.object({entity_urn:e.string().describe("URN of the post (urn:li:share:..., urn:li:ugcPost:..., urn:li:activity:...) or comment whose comments to list."),start:y,count:T}).describe("List comments on a LinkedIn post or comment. Scope: r_organization_social for organization posts per the Posts API. The 202611 Comments reference lists the Community Management *_feed scopes instead; which it enforces is unconfirmed."),$t=e.object({entity_urn:e.string().describe("URN of the entity (share, UGC post, activity or comment) whose reactions to list."),sort:e.enum(["REVERSE_CHRONOLOGICAL","CHRONOLOGICAL","RELEVANCE"]).optional().describe("Sort order. Defaults to REVERSE_CHRONOLOGICAL (newest first)."),start:y,count:T}).describe("List reactions (LIKE, PRAISE, EMPATHY, INTEREST, APPRECIATION, ENTERTAINMENT) on a LinkedIn entity via the Reactions API. Scope: r_organization_social for organization posts."),Kt=e.object({image_urn:e.string().describe("The image URN (e.g. urn:li:image:C4E10AQFn10iWtKexVA) whose details to retrieve.")}).describe("Retrieve details of a single LinkedIn image by its URN. Scopes: w_organization_social or rw_ads (w_member_social alone cannot read images)."),Ke=e.string().regex(/^urn:li:sponsoredAccount:/,"Must be an ad account URN (urn:li:sponsoredAccount:...)."),Qt=e.object({urns:e.array(e.string()).optional().describe("Image URNs to fetch in one batch request."),associated_account:Ke.optional().describe("Ad account URN (urn:li:sponsoredAccount:...) whose media-library images to list, newest first. LinkedIn has no finder by member or organization owner."),start:y,count:e.number().int().min(1).max(1e3).optional().describe("Images per page with associated_account, up to 1,000. LinkedIn defaults to 10.")}).refine(n=>!!(n.associated_account||n.urns&&n.urns.length>0),{message:"getImages requires a non-empty urns list or associated_account (LinkedIn has no finder by owner)."}).describe("Retrieve LinkedIn image metadata (download URLs, status) for a batch of URNs or for an ad account media library. Scopes: w_organization_social or rw_ads."),Wt=e.object({owner:h.describe("Owner URN that will own the uploaded image, e.g. urn:li:person:... or urn:li:organization:....")}).describe("Initialize a LinkedIn image upload and return a presigned upload URL plus the image URN. Scopes: w_member_social, w_organization_social or rw_ads."),Xt=e.object({owner:h.describe("Owner URN for the image, e.g. urn:li:person:... or urn:li:organization:....")}).describe("Start an image upload. Now sent to the Images API (/rest/images?action=initializeUpload), which LinkedIn says replaces the Assets API registerUpload call; returns the same shape as images.initializeUpload."),Jt=e.object({video_urn:e.string().optional().describe("A single video URN to retrieve."),urns:e.array(e.string()).optional().describe("Video URNs to fetch in one batch request."),associated_account:Ke.optional().describe("Ad account URN (urn:li:sponsoredAccount:...) whose media-library videos to list, newest first. LinkedIn has no finder by member or organization owner."),start:y,count:e.number().int().min(1).max(1e3).optional().describe("Videos per page with associated_account, up to 1,000. LinkedIn defaults to 10.")}).refine(n=>!!(n.video_urn||n.associated_account||n.urns&&n.urns.length>0),{message:"getVideos requires video_urn, a non-empty urns list, or associated_account (LinkedIn has no finder by owner)."}).describe("Retrieve LinkedIn video metadata (status, duration, download URL) for URNs or for an ad account media library. Scopes: w_organization_social, r_ads or rw_ads."),xe=e.enum(["ADMINISTRATOR","DIRECT_SPONSORED_CONTENT_POSTER","RECRUITING_POSTER","LEAD_CAPTURE_ADMINISTRATOR","LEAD_GEN_FORMS_MANAGER","ANALYST","CURATOR","CONTENT_ADMINISTRATOR"]),Zt=e.object({role:e.union([xe,e.array(xe).max(1)]).optional().describe("Only return this role, e.g. ADMINISTRATOR. LinkedIn filters on one role per request; a one-item array is accepted."),state:e.enum(["APPROVED","REQUESTED","REJECTED","REVOKED"]).optional().describe("Only return roles in this state. Defaults to APPROVED."),start:y,count:T}).describe("List the organizations where the authenticated member holds a role (organization ACLs). Scopes: r_organization_admin or rw_organization_admin."),N=h.describe("The organization URN, e.g. urn:li:organization:2414183."),en=e.object({organization_urn:N}).describe("Retrieve an organization's total follower count via the networkSizes API. Scope: rw_organization_admin."),tn=e.object({organization_urn:N,time_integrated:V.describe("Optional time range. Without it, LinkedIn returns lifetime follower counts by seniority, industry, function, region and more; with it, daily, weekly or monthly follower gains (last 12 months, up to 2 days ago)."),time_granularity:e.enum(["DAY","WEEK","MONTH"]).optional().describe("Bucket size for a time range. Defaults to DAY.")}).refine(n=>!n.time_integrated||n.time_integrated.start!==void 0,{message:"time_integrated needs start for follower statistics (LinkedIn requires timeRange.start)."}).describe("Retrieve an organization's follower statistics: lifetime follower demographics or follower gains over time. Scope: rw_organization_admin."),nn=e.object({organization_urn:N,time_integrated:V.describe("Optional time range. Without it, LinkedIn returns lifetime statistics broken down by region, industry, function and more."),time_granularity:e.enum(["DAY","MONTH"]).optional().describe("Bucket size for a time range. Defaults to DAY."),start:y,count:T}).describe("Retrieve page statistics (page views, custom button clicks) for a LinkedIn organization. Scope: rw_organization_admin."),on=e.object({organization_urn:N,time_integrated:V.describe("Optional time range. Without it, LinkedIn returns lifetime totals (organic only, rolling 12 months). Cannot be combined with shares or ugc_posts."),time_granularity:e.enum(["DAY","MONTH"]).optional().describe("Bucket size for a time range. Defaults to DAY."),shares:e.array(e.string()).optional().describe("Share URNs (urn:li:share:...) to return per-post statistics for."),ugc_posts:e.array(e.string()).optional().describe("UGC post URNs (urn:li:ugcPost:...) to return per-post statistics for.")}).refine(n=>!(n.time_integrated&&((n.shares?.length??0)>0||(n.ugc_posts?.length??0)>0)),{message:"LinkedIn does not support time-bound statistics for specific shares or UGC posts."}).describe("Retrieve organic share statistics (impressions, clicks, reactions, comments, shares, engagement) for an organization or for specific posts. Scope: rw_organization_admin."),sn=e.object({}).describe("List the ad targeting facets (locations, industries, titles, skills, ...) and the finders each supports. Needs the Advertising API product."),je=e.record(e.string(),e.array(e.string())),rn=e.object({include:e.object({and:e.array(e.object({or:je.describe('Facet URN to the values that match, e.g. { "urn:li:adTargetingFacet:locations": ["urn:li:geo:102221843"] }.')})).min(1)}).describe("Every and-clause must match; within a clause, any value."),exclude:e.object({or:je}).optional().describe("Members matching any of these values are excluded.")}).describe('A targetingCriteria object, e.g. { include: { and: [ { or: { "urn:li:adTargetingFacet:locations": ["urn:li:geo:102221843"] } } ] } }.'),an=e.object({target:rn}).describe("Estimate the audience size for ad targeting criteria (q=targetingCriteriaV2). LinkedIn returns 0 below 300 members. Needs the Advertising API product."),cn=e.object({query:e.string().describe('Partial text to match, e.g. "softw".'),facet:e.string().optional().describe("Facet to search: a facet name such as locations, titles, industries or skills, or a facet URN (urn:li:adTargetingFacet:locations). Required unless type is set."),type:e.string().optional().describe("Older name for facet, kept for existing callers. Used only when facet is not set."),entity_type:e.enum(["AGE","COMPANY","COMPANY_SIZE","DEGREE","FIELD_OF_STUDY","FUNCTION","GENDER","GROUP","INDUSTRY","INTEREST","LOCALE","SCHOOL","SENIORITY","SKILL","TITLE","YEARS_OF_EXPERIENCE","MEMBER_BEHAVIOR"]).optional().describe("Only return entities of this type."),locale:e.object({language:e.string().describe("Lowercase ISO-639 language code, e.g. en."),country:e.string().describe("Uppercase ISO-3166 country code, e.g. US.")}).optional().describe("Language for entity names. LinkedIn defaults to en_US.")}).refine(n=>!!(n.facet??n.type)?.trim(),{message:'searchTargetingEntities requires facet (e.g. "locations").'}).describe("Search ad targeting entities (locations, titles, industries, skills, ...) by typeahead within one facet. Needs the Advertising API product."),Qe=e.enum(["ASCENDING","DESCENDING"]).optional().describe("Sort by ID. LinkedIn defaults to ASCENDING."),We=e.number().int().min(1).max(1e3).optional().describe("Results per page, up to 1,000."),Xe=e.string().optional().describe("metadata.nextPageToken from the previous page."),ln=e.object({status:e.array(e.enum(["ACTIVE","DRAFT","CANCELED","PENDING_DELETION","REMOVED"])).optional().describe("Only return accounts in these statuses."),type:e.array(e.enum(["BUSINESS","ENTERPRISE"])).optional().describe("Only return accounts of these types."),page_size:We,page_token:Xe,sort_order:Qe}).describe("List the ad accounts the authenticated member can access. Scope: r_ads (or rw_ads)."),dn=e.enum(["ACTIVE","PAUSED","ARCHIVED","COMPLETED","CANCELED","DRAFT","PENDING_DELETION","REMOVED"]),pn=e.string().describe("Ad account ID (e.g. 507404993) or URN (urn:li:sponsoredAccount:507404993)."),un=e.object({ad_account:pn,status:e.array(dn).optional().describe("Only return campaigns in these statuses. Defaults to every status except PENDING_DELETION and REMOVED, since LinkedIn requires a search criterion."),type:e.array(e.enum(["TEXT_AD","SPONSORED_UPDATES","SPONSORED_INMAILS","DYNAMIC"])).optional().describe("Only return campaigns of these types."),campaign_group:e.array(e.string()).optional().describe("Only return campaigns in these campaign groups (urn:li:sponsoredCampaignGroup:...)."),page_size:We,page_token:Xe,sort_order:Qe}).describe("List the campaigns in an ad account. Scope: r_ads (or rw_ads)."),Me=e.object({year:e.number().int().describe("Four-digit year."),month:e.number().int().min(1).max(12).describe("Month, 1-12."),day:e.number().int().min(1).max(31).describe("Day of the month.")}),gn=e.object({pivot:e.enum(["COMPANY","ACCOUNT","SHARE","CAMPAIGN","CREATIVE","CAMPAIGN_GROUP","CONVERSION","CONVERSATION_NODE","CONVERSATION_NODE_OPTION_INDEX","SERVING_LOCATION","CARD_INDEX","MEMBER_COMPANY_SIZE","MEMBER_INDUSTRY","MEMBER_SENIORITY","MEMBER_JOB_TITLE","MEMBER_JOB_FUNCTION","MEMBER_COUNTRY_V2","MEMBER_REGION_V2","MEMBER_COUNTY","MEMBER_COMPANY","MEMBER_DESIGNATED_MARKET_AREA","PLACEMENT_NAME","IMPRESSION_DEVICE_TYPE","EVENT_STAGE"]).describe("What each row is grouped by, e.g. CAMPAIGN or CREATIVE."),time_granularity:e.enum(["ALL","DAILY","MONTHLY","YEARLY"]).describe("ALL for one row per pivot value, or DAILY/MONTHLY/YEARLY rows."),date_range:e.object({start:Me.describe("Inclusive start date."),end:Me.optional().describe("Inclusive end date. Open-ended when unset.")}).describe("Reporting date range."),accounts:e.array(e.string()).optional().describe("Ad account IDs or URNs (urn:li:sponsoredAccount:...) to report on."),campaigns:e.array(e.string()).optional().describe("Campaign IDs or URNs (urn:li:sponsoredCampaign:...) to report on."),campaign_groups:e.array(e.string()).optional().describe("Campaign group IDs or URNs (urn:li:sponsoredCampaignGroup:...) to report on."),fields:e.array(e.string()).max(20).optional().describe("Metrics to return, up to 20 (e.g. impressions, clicks, costInLocalCurrency, dateRange, pivotValues). Without it LinkedIn returns impressions and clicks; list dateRange and pivotValues to keep them.")}).refine(n=>(n.accounts?.length??0)>0||(n.campaigns?.length??0)>0||(n.campaign_groups?.length??0)>0,{message:"getAnalytics requires at least one of accounts, campaigns or campaign_groups."}).describe("Retrieve ad performance (impressions, clicks, spend, conversions) for accounts, campaign groups or campaigns, grouped by one pivot. Scope: r_ads_reporting."),a={GetMyInfo:zt,GetPerson:Dt,CreatePost:xt,CreateArticleShare:jt,GetPostContent:Mt,ListPosts:Ft,DeletePost:qt,DeleteSharePost:Vt,DeleteUgcPost:Bt,CreateComment:Ht,ListComments:Yt,ListReactions:$t,GetImage:Kt,GetImages:Qt,InitializeImageUpload:Wt,RegisterImageUpload:Xt,GetVideos:Jt,GetCompanyInfo:Zt,GetNetworkSize:en,GetFollowerStats:tn,GetOrgPageStats:nn,GetShareStats:on,GetAdTargetingFacets:sn,GetAudienceCounts:an,SearchAdTargetingEntities:cn,ListAdAccounts:ln,ListAdCampaigns:un,GetAdAnalytics:gn},mn=e.object({sub:e.string().optional().describe("The member ID (OIDC subject)."),id:e.string().optional(),name:e.string().nullable().optional(),given_name:e.string().nullable().optional(),family_name:e.string().nullable().optional(),picture:e.string().nullable().optional(),email:e.string().nullable().optional(),email_verified:e.boolean().nullable().optional(),locale:e.string().nullable().optional().describe('e.g. "en-US".'),vanityName:e.string().optional(),headline:e.string().optional()}).loose().describe("The authenticated LinkedIn member (OpenID Connect userinfo)."),j=e.object({localized:e.record(e.string(),e.string()).optional(),preferredLocale:e.object({country:e.string().optional(),language:e.string().optional()}).loose().optional()}).loose(),hn=e.object({id:e.string().describe("The member ID."),localizedFirstName:e.string().optional(),localizedLastName:e.string().optional(),localizedHeadline:e.string().optional(),vanityName:e.string().optional(),firstName:j.optional(),lastName:j.optional(),headline:j.optional(),profilePicture:e.object({displayImage:e.string().optional().describe("Digital media asset URN of the profile photo.")}).loose().optional()}).loose(),Fe=e.object({id:e.string().describe("URN of the new post (urn:li:share:... or urn:li:ugcPost:...), from the x-restli-id header.")}).describe("Result of creating a LinkedIn post."),Je=e.object({id:e.string().describe("The post URN (urn:li:share:... or urn:li:ugcPost:...)."),author:e.string().optional(),commentary:e.string().optional(),visibility:e.string().optional().describe("PUBLIC, CONNECTIONS, LOGGED_IN or CONTAINER."),lifecycleState:e.string().optional().describe("PUBLISHED, DRAFT, PUBLISH_REQUESTED or PUBLISH_FAILED."),lifecycleStateInfo:e.record(e.string(),e.unknown()).optional(),distribution:e.object({feedDistribution:e.string().optional(),targetEntities:e.array(e.record(e.string(),e.unknown())).optional(),thirdPartyDistributionChannels:e.array(e.unknown()).optional()}).loose().optional(),content:e.record(e.string(),e.unknown()).optional().describe("media, article, multiImage, poll, ... depending on the post."),container:e.string().optional(),contentLandingPage:e.string().optional(),contentCallToActionLabel:e.string().optional(),isReshareDisabledByAuthor:e.boolean().optional(),reshareContext:e.object({parent:e.string().optional(),root:e.string().optional()}).loose().optional(),adContext:e.record(e.string(),e.unknown()).optional(),createdAt:e.number().optional().describe("Epoch milliseconds."),publishedAt:e.number().optional().describe("Epoch milliseconds."),lastModifiedAt:e.number().optional().describe("Epoch milliseconds.")}).loose(),In=e.object({elements:e.array(Je),paging:d}).loose().describe("A page of posts; paging.links holds the next page link."),M=e.object({success:e.boolean().describe("Whether the delete operation completed.")}).describe("Result of deleting a post."),Ze=e.object({id:e.string().optional().describe("The comment ID."),commentUrn:e.string().optional().describe("Comment URN, usable as the parent of a reply."),actor:e.string().optional(),agent:e.string().optional(),object:e.string().optional().describe("URN of the post that holds the comment."),parentComment:e.string().optional(),message:e.object({text:e.string().optional(),attributes:e.array(e.record(e.string(),e.unknown())).optional()}).loose().optional().describe("The comment text and any mentions."),content:e.array(e.record(e.string(),e.unknown())).optional(),created:R.optional(),lastModified:R.optional(),likesSummary:e.record(e.string(),e.unknown()).optional()}).loose(),bn=e.object({elements:e.array(Ze),paging:d}).loose(),fn=e.object({id:e.string().optional().describe("Reaction URN, urn:li:reaction:(actor,entity)."),reactionType:e.string().optional().describe("LIKE, PRAISE, EMPATHY, INTEREST, APPRECIATION, ENTERTAINMENT (MAYBE is deprecated)."),root:e.string().optional().describe("URN of the thread reacted to."),created:R.optional().describe("created.actor is who reacted."),lastModified:R.optional(),deleted:R.optional()}).loose(),yn=e.object({elements:e.array(fn),paging:d}).loose().describe("Reactions on a LinkedIn entity."),et=e.object({associatedAccount:e.string().optional(),assetName:e.string().optional(),mediaLibraryStatus:e.string().optional()}).loose(),q=e.object({id:e.string().describe("The image URN."),owner:e.string().optional(),status:e.string().optional().describe("WAITING_UPLOAD, PROCESSING, AVAILABLE or PROCESSING_FAILED."),downloadUrl:e.string().nullable().optional(),downloadUrlExpiresAt:e.number().optional(),altText:e.string().optional(),aspectRatioHeight:e.number().optional(),aspectRatioWidth:e.number().optional(),mediaLibraryMetadata:et.optional()}).loose(),tt=e.record(e.string(),e.number()).optional().describe("Per-URN HTTP status from the batch lookup."),nt=e.record(e.string(),e.record(e.string(),e.unknown())).optional().describe("Per-URN errors from the batch lookup, e.g. NOT_FOUND."),En=e.object({elements:e.array(q).describe("The images found, in request order for a urns lookup, newest first for an ad account."),results:e.record(e.string(),q).optional(),statuses:tt,errors:nt,paging:d}).loose(),qe=e.object({value:e.object({image:e.string().describe("The new image URN to use when attaching the image to a post."),uploadUrl:e.string().optional().describe("Presigned URL to PUT the image bytes to."),uploadUrlExpiresAt:e.number().optional().describe("Epoch millis when the upload URL expires.")}).loose()}).loose().describe("Result of initializing an image upload."),Ve=e.object({id:e.string().describe("The video URN."),owner:e.string().optional(),status:e.string().optional().describe("WAITING_UPLOAD, PROCESSING, AVAILABLE or PROCESSING_FAILED."),processingFailureReason:e.string().optional(),downloadUrl:e.string().nullable().optional(),downloadUrlExpiresAt:e.number().optional(),duration:e.number().optional().describe("Length in milliseconds."),aspectRatioWidth:e.number().optional(),aspectRatioHeight:e.number().optional(),thumbnail:e.string().optional(),captions:e.string().optional(),mediaLibraryMetadata:et.optional()}).loose(),Ln=e.object({elements:e.array(Ve).describe("The videos found, in request order for a URN lookup, newest first for an ad account."),results:e.record(e.string(),Ve).optional(),statuses:tt,errors:nt,paging:d}).loose(),An=e.object({organization:e.string().optional().describe("Organization URN."),roleAssignee:e.string().optional().describe("Person URN."),role:e.string().optional().describe("The role held, e.g. ADMINISTRATOR."),state:e.string().optional().describe("APPROVED, REQUESTED, REJECTED or REVOKED.")}).loose(),kn=e.object({elements:e.array(An),paging:d}).loose(),_n=e.object({firstDegreeSize:e.number().optional().describe("Total followers of the organization, as LinkedIn returns it."),totalFollowerCount:e.number().optional().describe("Same value as firstDegreeSize, kept for existing callers.")}).loose().describe("Follower count for a LinkedIn organization."),f=e.object({organicFollowerCount:e.number().optional(),paidFollowerCount:e.number().optional()}).loose(),O=e.object({start:e.number().optional(),end:e.number().optional()}).loose(),Sn=e.object({organizationalEntity:e.string().optional(),timeRange:O.optional(),followerGains:e.object({organicFollowerGain:e.number().optional(),paidFollowerGain:e.number().optional()}).loose().optional().describe("Present for time-bound requests."),followerCountsByAssociationType:e.array(e.object({followerCounts:f.optional()}).loose()).optional(),followerCountsBySeniority:e.array(e.object({followerCounts:f.optional()}).loose()).optional(),followerCountsByIndustry:e.array(e.object({followerCounts:f.optional()}).loose()).optional(),followerCountsByFunction:e.array(e.object({followerCounts:f.optional()}).loose()).optional(),followerCountsByStaffCountRange:e.array(e.object({followerCounts:f.optional()}).loose()).optional(),followerCountsByGeo:e.array(e.object({followerCounts:f.optional()}).loose()).optional(),followerCountsByGeoCountry:e.array(e.object({followerCounts:f.optional()}).loose()).optional()}).loose(),Rn=e.object({elements:e.array(Sn),paging:d}).loose(),wn=e.object({organization:e.string().optional(),timeRange:O.optional(),totalPageStatistics:e.record(e.string(),e.unknown()).optional().describe("views (allPageViews, careersPageViews, ...) and clicks.")}).loose(),Pn=e.object({elements:e.array(wn).describe("Page statistics entries."),paging:d}).loose(),Cn=e.object({organizationalEntity:e.string().optional(),share:e.string().optional(),ugcPost:e.string().optional(),timeRange:O.optional(),totalShareStatistics:e.object({impressionCount:e.number().optional(),uniqueImpressionsCount:e.number().optional(),clickCount:e.number().optional(),likeCount:e.number().optional(),commentCount:e.number().optional(),shareCount:e.number().optional(),engagement:e.number().optional()}).loose().optional()}).loose(),Tn=e.object({elements:e.array(Cn).describe("Share statistics entries. Posts with no activity are left out and have counts of 0."),paging:d}).loose(),Nn=e.object({elements:e.array(e.object({facetName:e.string().optional(),adTargetingFacetUrn:e.string().optional(),entityTypes:e.array(e.string()).optional(),availableEntityFinders:e.array(e.string()).optional().describe("e.g. AD_TARGETING_FACET, TYPEAHEAD, SIMILAR_ENTITIES.")}).loose()),paging:d}).loose(),On=e.object({elements:e.array(e.object({total:e.number().optional().describe("Audience size; 0 when below 300 members."),active:e.number().optional().describe("Members more likely to visit LinkedIn.")}).loose()),paging:d}).loose(),Un=e.object({elements:e.array(e.object({urn:e.string().optional(),name:e.string().optional(),facetUrn:e.string().optional()}).loose()),paging:d}).loose(),ot=e.object({nextPageToken:e.string().optional().describe("Pass as page_token for the next page; absent on the last page.")}).loose().optional(),F=e.object({amount:e.string().optional(),currencyCode:e.string().optional()}).loose(),Gn=e.object({id:e.number().optional(),name:e.string().optional(),currency:e.string().optional(),status:e.string().optional(),type:e.string().optional(),reference:e.string().optional().describe("Organization or person URN that owns the account."),test:e.boolean().optional(),servingStatuses:e.array(e.string()).optional(),changeAuditStamps:e.record(e.string(),e.unknown()).optional(),version:e.record(e.string(),e.unknown()).optional()}).loose(),zn=e.object({elements:e.array(Gn),metadata:ot}).loose(),Dn=e.object({id:e.number().optional(),name:e.string().optional(),account:e.string().optional(),campaignGroup:e.string().optional(),status:e.string().optional(),type:e.string().optional(),costType:e.string().optional(),dailyBudget:F.optional(),totalBudget:F.optional(),unitCost:F.optional(),runSchedule:O.optional(),targetingCriteria:e.record(e.string(),e.unknown()).optional(),locale:e.record(e.string(),e.unknown()).optional(),servingStatuses:e.array(e.string()).optional(),test:e.boolean().optional(),changeAuditStamps:e.record(e.string(),e.unknown()).optional()}).loose(),vn=e.object({elements:e.array(Dn),metadata:ot}).loose(),Be=e.object({year:e.number().optional(),month:e.number().optional(),day:e.number().optional()}).loose(),xn=e.object({elements:e.array(e.object({pivotValues:e.array(e.string()).optional(),dateRange:e.object({start:Be.optional(),end:Be.optional()}).loose().optional(),impressions:e.number().optional(),clicks:e.number().optional(),costInLocalCurrency:e.string().optional().describe("Spend as a decimal string.")}).loose()),paging:d}).loose().describe("Ad analytics rows (up to 15,000; LinkedIn does not page them)."),c={GetMyInfo:mn,GetPerson:hn,CreatePost:Fe,CreateArticleShare:Fe,GetPostContent:Je,ListPosts:In,DeletePost:M,DeleteSharePost:M,DeleteUgcPost:M,CreateComment:Ze,ListComments:bn,ListReactions:yn,GetImage:q,GetImages:En,InitializeImageUpload:qe,RegisterImageUpload:qe,GetVideos:Ln,GetCompanyInfo:kn,GetNetworkSize:_n,GetFollowerStats:Rn,GetOrgPageStats:Pn,GetShareStats:Tn,GetAdTargetingFacets:Nn,GetAudienceCounts:On,SearchAdTargetingEntities:Un,ListAdAccounts:zn,ListAdCampaigns:vn,GetAdAnalytics:xn};var B={getMyInfo:Ge,getPerson:ze},I={create:Se,createArticleShare:Re,getContent:we,list:Pe,delete:Ce,deleteShare:Te,deleteUgc:Ne},H={create:le,list:de},it={list:De},w={get:pe,list:ue,initializeUpload:me,registerUpload:he},st={list:ve},_={getCompanyInfo:Ie,getNetworkSize:be,getFollowerStats:fe,getPageStats:ye,getShareStats:Ee},E={getTargetingFacets:ne,getAudienceCounts:oe,searchTargetingEntities:ie,listAccounts:se,listCampaigns:re,getAnalytics:ae};import{ApiError as at}from"corsair/http";function rt(n){if(n instanceof l||n instanceof at)return n.status}var ct={RATE_LIMIT_ERROR:{match:n=>{if(rt(n)===429)return!0;let t=n.message.toLowerCase();return t.includes("rate_limited")||t.includes("too many requests")||t.includes("429")},handler:async n=>{let t;return(n instanceof l&&n.retryAfter!==void 0||n instanceof at&&n.retryAfter!==void 0)&&(t=n.retryAfter),{maxRetries:0,headersRetryAfterMs:t}}},AUTH_ERROR:{match:n=>{if(rt(n)===401)return!0;let t=n.message.toLowerCase();return t.includes("unauthorized")||t.includes("invalid_auth")},handler:async()=>({maxRetries:0})},DEFAULT:{match:()=>!0,handler:async()=>({maxRetries:0})}};import{z as p}from"zod";var lt=p.object({id:p.string().describe("The LinkedIn member ID of the authenticated user."),sub:p.string().optional().describe("The OIDC subject identifier."),name:p.string().nullable().optional().describe("Display name of the member."),given_name:p.string().nullable().optional().describe("First name."),family_name:p.string().nullable().optional().describe("Last name."),picture:p.string().nullable().optional().describe("Profile picture URL."),email:p.string().nullable().optional().describe("Primary email address."),locale:p.string().nullable().optional().describe("Preferred locale."),headline:p.string().nullable().optional().describe("Profile headline."),vanityName:p.string().nullable().optional().describe("Public vanity name."),createdAt:p.coerce.date().nullable().optional(),updatedAt:p.coerce.date().nullable().optional()});var dt={version:"1.0.0",entities:{users:lt}};var qn={oauth_2:{integration:[]},managed:{integration:[]}},Vn={profile:{getMyInfo:B.getMyInfo,getPerson:B.getPerson},posts:{create:I.create,createArticleShare:I.createArticleShare,getContent:I.getContent,list:I.list,delete:I.delete,deleteShare:I.deleteShare,deleteUgc:I.deleteUgc},comments:{create:H.create,list:H.list},reactions:{list:it.list},images:{get:w.get,list:w.list,initializeUpload:w.initializeUpload,registerUpload:w.registerUpload},videos:{list:st.list},organizations:{getCompanyInfo:_.getCompanyInfo,getNetworkSize:_.getNetworkSize,getFollowerStats:_.getFollowerStats,getPageStats:_.getPageStats,getShareStats:_.getShareStats},ads:{getTargetingFacets:E.getTargetingFacets,getAudienceCounts:E.getAudienceCounts,searchTargetingEntities:E.searchTargetingEntities,listAccounts:E.listAccounts,listCampaigns:E.listCampaigns,getAnalytics:E.getAnalytics}},Bn={"profile.getMyInfo":{input:a.GetMyInfo,output:c.GetMyInfo},"profile.getPerson":{input:a.GetPerson,output:c.GetPerson},"posts.create":{input:a.CreatePost,output:c.CreatePost},"posts.createArticleShare":{input:a.CreateArticleShare,output:c.CreateArticleShare},"posts.getContent":{input:a.GetPostContent,output:c.GetPostContent},"posts.list":{input:a.ListPosts,output:c.ListPosts},"posts.delete":{input:a.DeletePost,output:c.DeletePost},"posts.deleteShare":{input:a.DeleteSharePost,output:c.DeleteSharePost},"posts.deleteUgc":{input:a.DeleteUgcPost,output:c.DeleteUgcPost},"comments.create":{input:a.CreateComment,output:c.CreateComment},"comments.list":{input:a.ListComments,output:c.ListComments},"reactions.list":{input:a.ListReactions,output:c.ListReactions},"images.get":{input:a.GetImage,output:c.GetImage},"images.list":{input:a.GetImages,output:c.GetImages},"images.initializeUpload":{input:a.InitializeImageUpload,output:c.InitializeImageUpload},"images.registerUpload":{input:a.RegisterImageUpload,output:c.RegisterImageUpload},"videos.list":{input:a.GetVideos,output:c.GetVideos},"organizations.getCompanyInfo":{input:a.GetCompanyInfo,output:c.GetCompanyInfo},"organizations.getNetworkSize":{input:a.GetNetworkSize,output:c.GetNetworkSize},"organizations.getFollowerStats":{input:a.GetFollowerStats,output:c.GetFollowerStats},"organizations.getPageStats":{input:a.GetOrgPageStats,output:c.GetOrgPageStats},"organizations.getShareStats":{input:a.GetShareStats,output:c.GetShareStats},"ads.getTargetingFacets":{input:a.GetAdTargetingFacets,output:c.GetAdTargetingFacets},"ads.getAudienceCounts":{input:a.GetAudienceCounts,output:c.GetAudienceCounts},"ads.searchTargetingEntities":{input:a.SearchAdTargetingEntities,output:c.SearchAdTargetingEntities},"ads.listAccounts":{input:a.ListAdAccounts,output:c.ListAdAccounts},"ads.listCampaigns":{input:a.ListAdCampaigns,output:c.ListAdCampaigns},"ads.getAnalytics":{input:a.GetAdAnalytics,output:c.GetAdAnalytics}},Hn={"profile.getMyInfo":{riskLevel:"read",description:"Fetch the authenticated member's profile (id, name, picture, email). Scopes: openid, profile, email."},"profile.getPerson":{riskLevel:"read",description:"Retrieve a LinkedIn member profile by person ID. Scope: r_basicprofile; LinkedIn limits lookups of other members to approved developers."},"posts.create":{riskLevel:"write",description:"Create a LinkedIn post (text, article or image) as a member (w_member_social) or organization (w_organization_social)."},"posts.createArticleShare":{riskLevel:"write",description:"Share a URL as an article post. Now uses the Posts API (/rest/posts) instead of the legacy /v2/ugcPosts; article_title is required. Scopes: w_member_social or w_organization_social."},"posts.getContent":{riskLevel:"read",description:"Retrieve a LinkedIn post by URN. Scope: r_organization_social for organization posts."},"posts.list":{riskLevel:"read",description:"List an organization's posts, newest first, with paging. Scope: r_organization_social."},"posts.delete":{riskLevel:"destructive",irreversible:!0,description:"Delete a LinkedIn post via the Posts API. Scopes: w_member_social or w_organization_social."},"posts.deleteShare":{riskLevel:"destructive",irreversible:!0,description:"Delete a LinkedIn share by ID or URN. Now uses the Posts API; the /v2/shares endpoint is retired. Scopes: w_member_social or w_organization_social."},"posts.deleteUgc":{riskLevel:"destructive",irreversible:!0,description:"Delete a UGC post by URN. Now uses the Posts API instead of the legacy /v2/ugcPosts. Scopes: w_member_social or w_organization_social."},"comments.create":{riskLevel:"write",description:"Comment on a LinkedIn post, or reply to a comment. Scopes: w_member_social or w_organization_social per the Posts API. The 202611 Comments reference lists the Community Management *_feed scopes instead; which it enforces is unconfirmed."},"comments.list":{riskLevel:"read",description:"List comments on a LinkedIn post or comment. Scope: r_organization_social per the Posts API. The 202611 Comments reference lists the Community Management *_feed scopes instead; which it enforces is unconfirmed."},"reactions.list":{riskLevel:"read",description:"List reactions on a LinkedIn post or comment via the Reactions API. Scope: r_organization_social."},"images.get":{riskLevel:"read",description:"Retrieve a LinkedIn image (status, download URL) by URN. Scopes: w_organization_social or rw_ads."},"images.list":{riskLevel:"read",description:"Retrieve LinkedIn images by URN, or an ad account's media-library images. Scopes: w_organization_social or rw_ads."},"images.initializeUpload":{riskLevel:"write",description:"Start a LinkedIn image upload: returns an upload URL and the image URN to attach to a post. Scopes: w_member_social, w_organization_social or rw_ads."},"images.registerUpload":{riskLevel:"write",description:"Start an image upload. Now the same Images API call as images.initializeUpload, which LinkedIn says replaces the Assets API registerUpload; returns value.image and value.uploadUrl."},"videos.list":{riskLevel:"read",description:"Retrieve LinkedIn videos by URN, or an ad account's media-library videos. Scopes: w_organization_social, r_ads or rw_ads."},"organizations.getCompanyInfo":{riskLevel:"read",description:"List the organizations where the authenticated member holds a role. Scopes: r_organization_admin or rw_organization_admin."},"organizations.getNetworkSize":{riskLevel:"read",description:"Retrieve an organization's total follower count (networkSizes API). Scope: rw_organization_admin."},"organizations.getFollowerStats":{riskLevel:"read",description:"Retrieve an organization's follower demographics, or follower gains over time. Scope: rw_organization_admin."},"organizations.getPageStats":{riskLevel:"read",description:"Retrieve page view and click statistics for an organization. Scope: rw_organization_admin."},"organizations.getShareStats":{riskLevel:"read",description:"Retrieve organic post statistics for an organization or specific posts. Scope: rw_organization_admin."},"ads.getTargetingFacets":{riskLevel:"read",description:"List LinkedIn ad targeting facets. Needs the Advertising API product."},"ads.getAudienceCounts":{riskLevel:"read",description:"Estimate the audience size for ad targeting criteria. Needs the Advertising API product."},"ads.searchTargetingEntities":{riskLevel:"read",description:"Search ad targeting entities in one facet by typeahead. Needs the Advertising API product."},"ads.listAccounts":{riskLevel:"read",description:"List the ad accounts the authenticated member can access. Scope: r_ads."},"ads.listCampaigns":{riskLevel:"read",description:"List the campaigns in an ad account. Scope: r_ads."},"ads.getAnalytics":{riskLevel:"read",description:"Retrieve ad performance (impressions, clicks, spend) for accounts, campaign groups or campaigns. Scope: r_ads_reporting."}},pt=["openid","profile","email","w_member_social"],Mo=[...pt,"r_basicprofile","r_organization_social","w_organization_social","r_organization_admin","rw_organization_admin","r_ads","rw_ads","r_ads_reporting"],Yn="oauth_2";function Fo(n={}){let t={...n,authType:n.authType??Yn};return{id:"linkedin",schema:dt,options:t,authConfig:qn,oauthConfig:{providerName:"LinkedIn",authUrl:"https://www.linkedin.com/oauth/v2/authorization",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",tokenAuthMethod:"body",scopes:[...t.scopes??pt]},hooks:t.hooks,endpoints:Vn,endpointSchemas:Bn,endpointMeta:Hn,errorHandlers:{...ct,...t.errorHandlers},keyBuilder:async o=>{if(t.key)return t.key;if(o.authType==="oauth_2")return Mn(o,{plugin:"linkedin",tokenUrl:"https://www.linkedin.com/oauth/v2/accessToken",tokenAuthMethod:"body"});if(o.authType==="managed")return Fn(o,"linkedin");throw new jn("linkedin","oauth_2")}}}export{Mo as LINKEDIN_ADVERTISING_SCOPES,pt as LINKEDIN_SELF_SERVE_SCOPES,Bn as LinkedInEndpointSchemas,Vn as LinkedInEndpointsNested,Fo as linkedin,qn as linkedinAuthConfig};
@@ -0,0 +1,31 @@
1
+ /** A query value that is already a Rest.li 2.0 expression; sent unchanged. */
2
+ export type RestliExpression = {
3
+ readonly restli: string;
4
+ };
5
+ export type RestliQueryValue = string | number | boolean | RestliExpression | undefined;
6
+ export type RestliQuery = Record<string, RestliQueryValue>;
7
+ /**
8
+ * Percent-encodes one Rest.li key or leaf value. encodeURIComponent leaves
9
+ * ( ) ' unescaped, but Rest.li 2.0 reserves them, so they are escaped too.
10
+ */
11
+ export declare function encodeRestliValue(value: string | number | boolean): string;
12
+ /** Serializes a JSON-like value to Rest.li 2.0 syntax (objects, arrays, scalars). */
13
+ export declare function toRestli(value: unknown): string;
14
+ /** Wraps a serialized Rest.li value so the client sends it unencoded. */
15
+ export declare function restli(value: unknown): RestliExpression;
16
+ /** `List(a,b)` with each item percent-encoded, as Rest.li 2.0 expects. */
17
+ export declare function restliList(values: ReadonlyArray<string>): RestliExpression;
18
+ /**
19
+ * Builds a query string. Plain values are percent-encoded; Rest.li
20
+ * expressions are appended as they are. Undefined values are skipped.
21
+ */
22
+ export declare function buildRestliQueryString(query: RestliQuery | undefined): string;
23
+ /** Path segment for a URN key, e.g. /rest/posts/urn%3Ali%3Ashare%3A123. */
24
+ export declare function encodeUrnPath(urn: string): string;
25
+ /**
26
+ * A projection such as (id,localizedFirstName) is Rest.li syntax and is sent
27
+ * unencoded. Anything outside the projection character set is percent-encoded
28
+ * instead, so caller input can never add query parameters.
29
+ */
30
+ export declare function projectionParam(projection: string | undefined): RestliQueryValue;
31
+ //# sourceMappingURL=restli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restli.d.ts","sourceRoot":"","sources":["../restli.ts"],"names":[],"mappings":"AAaA,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GACzB,MAAM,GACN,MAAM,GACN,OAAO,GACP,gBAAgB,GAChB,SAAS,CAAC;AAEb,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAK1E;AAED,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqB/C;AAED,yEAAyE;AACzE,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAEvD;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAE1E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAU7E;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,GAC5B,gBAAgB,CAKlB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wire.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.test.d.ts","sourceRoot":"","sources":["../wire.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/linkedin",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "LinkedIn plugin for Corsair",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "tsup": "^8.0.1",
27
27
  "typescript": "^5.9.3",
28
28
  "zod": "^4.1.13",
29
- "corsair": "0.2.58"
29
+ "corsair": "0.2.59"
30
30
  },
31
31
  "keywords": [
32
32
  "corsair",