1+ import LinkedApi , { LinkedApiError } from 'linkedapi-node' ;
2+
3+ async function advancedUsageExample ( ) : Promise < void > {
4+ const linkedapi = new LinkedApi ( {
5+ linkedApiToken : process . env . LINKED_API_TOKEN ! ,
6+ identificationToken : process . env . IDENTIFICATION_TOKEN ! ,
7+ } ) ;
8+
9+ try {
10+ await customWorkflowExample ( linkedapi ) ;
11+ await cancelWorkflowExample ( linkedapi ) ;
12+ } catch ( error ) {
13+ if ( error instanceof LinkedApiError ) {
14+ console . error ( '🚨 Linked API Error:' , error . message ) ;
15+ console . error ( '📝 Details:' , error . details ) ;
16+ } else {
17+ console . error ( '💥 Unknown error:' , error ) ;
18+ }
19+ }
20+ }
21+
22+ async function customWorkflowExample ( linkedapi : LinkedApi ) : Promise < void > {
23+ console . log ( '🚀 Linked API custom workflow example starting...' ) ;
24+ const workflowId = await linkedapi . customWorkflow . execute ( {
25+ actionType : 'st.searchPeople' ,
26+ limit : 3 ,
27+ filter : {
28+ locations : [ "San Francisco" ] ,
29+ } ,
30+ then : {
31+ actionType : 'st.doForPeople' ,
32+ then : {
33+ actionType : 'st.openPersonPage' ,
34+ basicInfo : true ,
35+ then : {
36+ actionType : 'st.retrievePersonSkills' ,
37+ }
38+ }
39+ }
40+ } ) ;
41+ console . log ( '🔍 Workflow started: ' , workflowId ) ;
42+ const result = await linkedapi . customWorkflow . result ( workflowId ) ;
43+
44+ console . log ( '✅ Custom workflow executed successfully' ) ;
45+ console . log ( '🔍 Result: ' , JSON . stringify ( result . data , null , 2 ) ) ;
46+ }
47+
48+ async function cancelWorkflowExample ( linkedapi : LinkedApi ) : Promise < void > {
49+ console . log ( '🚀 Linked API cancel workflow example starting...' ) ;
50+ const workflowId = await linkedapi . searchPeople . execute ( {
51+ limit : 3 ,
52+ filter : {
53+ locations : [ "San Francisco" ] ,
54+ } ,
55+ } ) ;
56+ console . log ( '🔍 Workflow started: ' , workflowId ) ;
57+ const result = await linkedapi . searchPeople . cancel ( workflowId ) ;
58+ console . log ( '✅ Workflow cancelled: ' , result ) ;
59+ }
60+
61+
62+ if ( require . main === module ) {
63+ advancedUsageExample ( ) ;
64+ }
0 commit comments