@florydev/linkedin-api-voyager 1.3.9 → 1.3.10
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.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/linkedin-sse.d.ts +6 -1
- package/lib/linkedin-sse.js +8 -5
- package/lib/teste.js +5 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/linkedin-sse.d.ts
CHANGED
|
@@ -39,5 +39,10 @@ export type ParseLinkedInSSEChunkArgs = {
|
|
|
39
39
|
onEvent: (data: unknown) => void;
|
|
40
40
|
onError: (error: unknown) => void;
|
|
41
41
|
};
|
|
42
|
+
export type LinkedInSSEArgs = {
|
|
43
|
+
topics?: LinkedInRealtimeTopicsParam;
|
|
44
|
+
onData: (data: unknown) => void;
|
|
45
|
+
onError?: (error: unknown) => void;
|
|
46
|
+
};
|
|
42
47
|
export declare const parseLinkedInSSEChunk: ({ buffer, chunk, topicsSet, onEvent, onError, }: ParseLinkedInSSEChunkArgs) => string;
|
|
43
|
-
export declare function linkedinSSE(topics
|
|
48
|
+
export declare function linkedinSSE({ topics, onData, onError, }: LinkedInSSEArgs): Promise<void>;
|
package/lib/linkedin-sse.js
CHANGED
|
@@ -84,8 +84,8 @@ const parseLinkedInSSEChunk = ({ buffer, chunk, topicsSet, onEvent, onError, })
|
|
|
84
84
|
return nextBuffer;
|
|
85
85
|
};
|
|
86
86
|
exports.parseLinkedInSSEChunk = parseLinkedInSSEChunk;
|
|
87
|
-
function linkedinSSE(
|
|
88
|
-
return __awaiter(this,
|
|
87
|
+
function linkedinSSE(_a) {
|
|
88
|
+
return __awaiter(this, arguments, void 0, function* ({ topics, onData, onError, }) {
|
|
89
89
|
if (!config_1.apiInstance) {
|
|
90
90
|
throw new Error("Client not initialized. Please call Client({ JSESSIONID, li_at }) first.");
|
|
91
91
|
}
|
|
@@ -107,15 +107,18 @@ function linkedinSSE(topics) {
|
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
109
|
let buffer = "";
|
|
110
|
-
const onEvent = (data) => data;
|
|
111
|
-
const
|
|
110
|
+
const onEvent = (data) => onData(data);
|
|
111
|
+
const onErr = (error) => {
|
|
112
|
+
if (onError)
|
|
113
|
+
onError(error);
|
|
114
|
+
};
|
|
112
115
|
response.data.on("data", (chunk) => {
|
|
113
116
|
buffer = (0, exports.parseLinkedInSSEChunk)({
|
|
114
117
|
buffer,
|
|
115
118
|
chunk,
|
|
116
119
|
topicsSet,
|
|
117
120
|
onEvent,
|
|
118
|
-
onError,
|
|
121
|
+
onError: onErr,
|
|
119
122
|
});
|
|
120
123
|
});
|
|
121
124
|
});
|
package/lib/teste.js
CHANGED
|
@@ -17,7 +17,11 @@ const linkedin_sse_1 = require("./linkedin-sse");
|
|
|
17
17
|
});
|
|
18
18
|
function start() {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
yield (0, linkedin_sse_1.linkedinSSE)(
|
|
20
|
+
yield (0, linkedin_sse_1.linkedinSSE)({
|
|
21
|
+
topics: ["Messages", "TypingIndicators"],
|
|
22
|
+
onData: (data) => console.log(data),
|
|
23
|
+
onError: (error) => console.error(error),
|
|
24
|
+
});
|
|
21
25
|
});
|
|
22
26
|
}
|
|
23
27
|
start();
|
package/package.json
CHANGED