Skip to content

Commit 53a3e97

Browse files
Sync period
1 parent 061d0cf commit 53a3e97

5 files changed

Lines changed: 57 additions & 23 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@linkedapi/node",
3-
"version": "2.3.6",
3+
"version": "2.3.7",
44
"description": "Control your LinkedIn accounts and retrieve real-time data, all through this Node.js SDK.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,27 @@ class LinkedApi {
261261
* Each conversation must be synced once before you can poll it for messages. This is a time-consuming
262262
* process that retrieves the conversation history and prepares it for future updates.
263263
*
264-
* @param params - Parameters including the person's URL
265-
* @returns Promise resolving to the sync action
264+
* Syncing lasts for a limited period: `days` (1-90, 30 by default) counted from the moment the action
265+
* starts running. The action returns the resulting `syncUntil` deadline, which {@link pollConversations}
266+
* also reports. Once it passes, the conversation stops being updated — polling keeps returning the
267+
* messages collected so far. Call this action again on the same person to start a new period; the
268+
* accumulated history is preserved.
269+
*
270+
* @param params - Parameters including the person's URL and, optionally, how many days to sync for
271+
* @returns Promise resolving to the sync action with the `syncUntil` deadline
266272
*
267273
* @see {@link https://linkedapi.io/docs/working-with-conversations/ Working with Conversations Documentation}
268274
* @see {@link https://linkedapi.io/docs/action-st-sync-conversation/ st.syncConversation Action Documentation}
269275
*
270276
* @example
271277
* ```typescript
272278
* const workflow = await linkedapi.syncConversation.execute({
273-
* personUrl: "https://www.linkedin.com/in/john-doe"
279+
* personUrl: "https://www.linkedin.com/in/john-doe",
280+
* days: 14
274281
* });
275282
*
276-
* await linkedapi.syncConversation.result(workflow.workflowId);
277-
* console.log("Conversation synced and ready for polling");
283+
* const { syncUntil } = await linkedapi.syncConversation.result(workflow.workflowId);
284+
* console.log(`Conversation synced, updates continue until ${syncUntil}`);
278285
* ```
279286
*/
280287
public syncConversation: SyncConversation;
@@ -382,20 +389,27 @@ class LinkedApi {
382389
* Each conversation must be synced once before you can poll it for messages. This retrieves the conversation
383390
* history from Sales Navigator and prepares it for future updates.
384391
*
385-
* @param params - Parameters including the person's URL
386-
* @returns Promise resolving to the sync action
392+
* Syncing lasts for a limited period: `days` (1-90, 30 by default) counted from the moment the action
393+
* starts running. The action returns the resulting `syncUntil` deadline, which {@link pollConversations}
394+
* also reports. Once it passes, the conversation stops being updated — polling keeps returning the
395+
* messages collected so far. Call this action again on the same person to start a new period; the
396+
* accumulated history is preserved.
397+
*
398+
* @param params - Parameters including the person's URL and, optionally, how many days to sync for
399+
* @returns Promise resolving to the sync action with the `syncUntil` deadline
387400
*
388401
* @see {@link https://linkedapi.io/docs/working-with-conversations/ Working with Conversations Documentation}
389402
* @see {@link https://linkedapi.io/docs/action-nv-sync-conversation/ nv.syncConversation Action Documentation}
390403
*
391404
* @example
392405
* ```typescript
393406
* const workflow = await linkedapi.nvSyncConversation.execute({
394-
* personUrl: "https://www.linkedin.com/in/john-doe"
407+
* personUrl: "https://www.linkedin.com/in/john-doe",
408+
* days: 14
395409
* });
396410
*
397-
* await linkedapi.nvSyncConversation.result(workflow.workflowId);
398-
* console.log("Sales Navigator conversation synced and ready for polling");
411+
* const { syncUntil } = await linkedapi.nvSyncConversation.result(workflow.workflowId);
412+
* console.log(`Sales Navigator conversation synced, updates continue until ${syncUntil}`);
399413
* ```
400414
*/
401415
public nvSyncConversation: NvSyncConversation;
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { Operation, TOperationName } from '../core';
2-
import { VoidWorkflowMapper } from '../mappers';
3-
import { TNvSyncConversationParams } from '../types';
2+
import { SimpleWorkflowMapper } from '../mappers';
3+
import { TNvSyncConversationParams, TNvSyncConversationResult } from '../types';
44

5-
export class NvSyncConversation extends Operation<TNvSyncConversationParams, void> {
5+
export class NvSyncConversation extends Operation<
6+
TNvSyncConversationParams,
7+
TNvSyncConversationResult
8+
> {
69
public override readonly operationName: TOperationName = 'nvSyncConversation';
7-
protected override readonly mapper = new VoidWorkflowMapper<TNvSyncConversationParams>(
8-
'nv.syncConversation',
9-
);
10+
protected override readonly mapper = new SimpleWorkflowMapper<
11+
TNvSyncConversationParams,
12+
TNvSyncConversationResult
13+
>({
14+
actionType: 'nv.syncConversation',
15+
});
1016
}
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Operation, TOperationName } from '../core';
2-
import { VoidWorkflowMapper } from '../mappers';
3-
import { TSyncConversationParams } from '../types';
2+
import { SimpleWorkflowMapper } from '../mappers';
3+
import { TSyncConversationParams, TSyncConversationResult } from '../types';
44

5-
export class SyncConversation extends Operation<TSyncConversationParams, void> {
5+
export class SyncConversation extends Operation<TSyncConversationParams, TSyncConversationResult> {
66
public override readonly operationName: TOperationName = 'syncConversation';
7-
protected override readonly mapper = new VoidWorkflowMapper<TSyncConversationParams>(
8-
'st.syncConversation',
9-
);
7+
protected override readonly mapper = new SimpleWorkflowMapper<
8+
TSyncConversationParams,
9+
TSyncConversationResult
10+
>({
11+
actionType: 'st.syncConversation',
12+
});
1013
}

src/types/actions/message.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export interface TSendMessageManageConversation {
1313

1414
export interface TSyncConversationParams extends TBaseActionParams {
1515
personUrl: string;
16+
days?: number;
17+
}
18+
19+
export interface TSyncConversationResult {
20+
syncUntil: string;
1621
}
1722

1823
export interface TSyncInboxParams extends TBaseActionParams {}
@@ -26,6 +31,11 @@ export interface TNvSendMessageParams extends TBaseActionParams {
2631

2732
export interface TNvSyncConversationParams extends TBaseActionParams {
2833
personUrl: string;
34+
days?: number;
35+
}
36+
37+
export interface TNvSyncConversationResult {
38+
syncUntil: string;
2939
}
3040

3141
export interface TNvSyncInboxParams extends TBaseActionParams {}
@@ -59,6 +69,7 @@ export interface TConversationPollResult {
5969
since?: string;
6070
type: TConversationType;
6171
messages: TMessage[];
72+
syncUntil: string;
6273
}
6374

6475
export interface TInboxPollRequest {

0 commit comments

Comments
 (0)