@pipedream/linkupapi 0.2.0 → 1.0.0

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/linkupapi.app.mjs CHANGED
@@ -1,4 +1,9 @@
1
1
  import { axios } from "@pipedream/platform";
2
+ import {
3
+ ACTIONS,
4
+ BASE_URL,
5
+ ENDPOINTS,
6
+ } from "./common/constants.mjs";
2
7
 
3
8
  export default {
4
9
  type: "app",
@@ -7,18 +12,20 @@ export default {
7
12
  email: {
8
13
  type: "string",
9
14
  label: "Email",
10
- description: "Email address for LinkedIn account",
15
+ description: "Email address for the LinkedIn account.",
16
+ optional: true,
11
17
  },
12
18
  password: {
13
19
  type: "string",
14
20
  label: "Password",
15
- description: "Password for LinkedIn account",
21
+ description: "Password for the LinkedIn account.",
16
22
  secret: true,
23
+ optional: true,
17
24
  },
18
25
  country: {
19
26
  type: "string",
20
27
  label: "Country",
21
- description: "Country code for proxy selection",
28
+ description: "Country code for proxy selection (e.g. `US`, `UK`, `FR`). Defaults to `FR` server-side.",
22
29
  optional: true,
23
30
  options: [
24
31
  "US",
@@ -34,16 +41,15 @@ export default {
34
41
  "IN",
35
42
  ],
36
43
  },
37
- loginToken: {
44
+ accountId: {
38
45
  type: "string",
39
- label: "Login Token",
40
- description: "LinkedIn authentication token obtained from login/verify process",
41
- secret: true,
46
+ label: "Account ID",
47
+ description: "The persistent account identifier (e.g. `acc_abc123`). Run **Connect Account** to create one, or **List Accounts** to look up existing account IDs.",
42
48
  },
43
49
  code: {
44
50
  type: "string",
45
51
  label: "Verification Code",
46
- description: "Verification code received via email",
52
+ description: "Verification code received via email or challenge.",
47
53
  },
48
54
  linkedinUrl: {
49
55
  type: "string",
@@ -53,35 +59,27 @@ export default {
53
59
  conversationId: {
54
60
  type: "string",
55
61
  label: "Conversation ID",
56
- description: "LinkedIn conversation identifier",
62
+ description: "LinkedIn conversation identifier. Pick from your inbox, or run **List Inbox** to find one.",
57
63
  async options({
58
- prevContext, loginToken,
64
+ prevContext, accountId,
59
65
  }) {
60
- if (!loginToken || prevContext?.nextCursor === null) {
66
+ if (!accountId || prevContext?.nextCursor === null) {
61
67
  return [];
62
68
  }
63
- const {
64
- data: {
65
- conversations,
66
- next_cursor,
67
- },
68
- } = await this.getConversations({
69
- data: {
70
- login_token: loginToken,
71
- next_cursor: prevContext?.nextCursor,
69
+ const { data } = await this.listInbox({
70
+ accountId,
71
+ params: {
72
+ cursor: prevContext?.nextCursor,
72
73
  },
73
74
  });
75
+ const conversations = data?.conversations || [];
74
76
  return {
75
- options: conversations.map(({
76
- conversation_id: value,
77
- last_message: { text },
78
- participant: { name },
79
- }) => ({
80
- label: `${name || "Unknown"} - ${text?.substring(0, 50) || "No message"}`,
81
- value,
77
+ options: conversations.map((conversation) => ({
78
+ label: `${conversation.participant?.name || "Unknown"} - ${conversation.last_message?.text?.slice(0, 50) || "No message"}`,
79
+ value: conversation.conversation_id,
82
80
  })),
83
81
  context: {
84
- nextCursor: next_cursor,
82
+ nextCursor: data?.next_cursor || null,
85
83
  },
86
84
  };
87
85
  },
@@ -89,25 +87,48 @@ export default {
89
87
  messageText: {
90
88
  type: "string",
91
89
  label: "Message Text",
92
- description: "Message content",
90
+ description: "Message content.",
93
91
  },
94
92
  location: {
95
93
  type: "string[]",
96
94
  label: "Locations",
97
- description: "Geographic locations to filter",
95
+ description: "Geographic locations to filter, passed as an array of strings, e.g. `[\"San Francisco, CA\", \"Paris, France\"]`.",
98
96
  optional: true,
99
97
  },
100
98
  companyUrl: {
101
99
  type: "string[]",
102
100
  label: "Company URLs",
103
- description: "LinkedIn company URLs. Eg. `https://www.linkedin.com/company/stripe/`",
101
+ description: "LinkedIn company URLs to filter (passed as an array). Eg. `https://www.linkedin.com/company/stripe/`",
102
+ optional: true,
103
+ },
104
+ keyword: {
105
+ type: "string",
106
+ label: "Keyword",
107
+ description: "Free-text keyword to search by.",
108
+ optional: true,
109
+ },
110
+ totalResults: {
111
+ type: "integer",
112
+ label: "Total Results",
113
+ description: "Maximum number of results to return.",
114
+ optional: true,
115
+ min: 1,
116
+ default: 50,
117
+ },
118
+ identifier: {
119
+ type: "string",
120
+ label: "Identifier",
121
+ description: "LinkedIn public identifier (public ID) of the target profile.",
122
+ optional: true,
123
+ },
124
+ profileUrn: {
125
+ type: "string",
126
+ label: "Profile URN",
127
+ description: "LinkedIn profile URN of the target (e.g. `ACoAAB...`).",
104
128
  optional: true,
105
129
  },
106
130
  },
107
131
  methods: {
108
- getUrl(path) {
109
- return `https://api.linkupapi.com/v1${path}`;
110
- },
111
132
  _getHeaders() {
112
133
  return {
113
134
  "x-api-key": this.$auth.api_key,
@@ -119,85 +140,140 @@ export default {
119
140
  } = {}) {
120
141
  return axios($, {
121
142
  ...opts,
122
- url: this.getUrl(path),
143
+ url: `${BASE_URL}${path}`,
123
144
  headers: this._getHeaders(),
124
145
  });
125
146
  },
126
- post(opts = {}) {
147
+ _post(opts = {}) {
127
148
  return this._makeRequest({
128
149
  method: "POST",
129
150
  ...opts,
130
151
  });
131
152
  },
132
- login(opts = {}) {
133
- return this.post({
134
- path: "/auth/login",
153
+ // Shared wrapper for the V2 action envelope: { account_id, action, params }.
154
+ _action({
155
+ path, action, accountId, params, ...opts
156
+ } = {}) {
157
+ return this._post({
158
+ ...opts,
159
+ path,
160
+ data: {
161
+ account_id: accountId,
162
+ action,
163
+ params,
164
+ },
165
+ });
166
+ },
167
+ async _paginate({
168
+ requestPage, getItems, getNext, max,
169
+ }) {
170
+ const results = [];
171
+ let next;
172
+ let page = [];
173
+ do {
174
+ const response = await requestPage({
175
+ next,
176
+ count: max - results.length,
177
+ });
178
+ page = getItems(response) || [];
179
+ results.push(...page.slice(0, max - results.length));
180
+ next = getNext(response);
181
+ } while (next && page.length && results.length < max);
182
+ return results;
183
+ },
184
+ connectAccount(opts = {}) {
185
+ return this._post({
186
+ path: ENDPOINTS.LOGIN,
135
187
  ...opts,
136
188
  });
137
189
  },
138
- verify(opts = {}) {
139
- return this.post({
140
- path: "/auth/verify",
190
+ verifyCheckpoint(opts = {}) {
191
+ return this._post({
192
+ path: ENDPOINTS.CHECKPOINT,
193
+ ...opts,
194
+ });
195
+ },
196
+ listAccounts(opts = {}) {
197
+ return this._makeRequest({
198
+ path: ENDPOINTS.ACCOUNTS,
199
+ ...opts,
200
+ });
201
+ },
202
+ getAccountDetails({
203
+ accountId, ...opts
204
+ } = {}) {
205
+ return this._makeRequest({
206
+ path: `${ENDPOINTS.ACCOUNTS}/${encodeURIComponent(accountId)}`,
141
207
  ...opts,
142
208
  });
143
209
  },
144
210
  getProfileInfo(opts = {}) {
145
- return this.post({
146
- path: "/profile/info",
211
+ return this._action({
212
+ path: ENDPOINTS.PROFILES,
213
+ action: ACTIONS.GET,
147
214
  ...opts,
148
215
  });
149
216
  },
150
217
  searchProfiles(opts = {}) {
151
- return this.post({
152
- path: "/profile/search",
218
+ return this._action({
219
+ path: ENDPOINTS.PROFILES,
220
+ action: ACTIONS.SEARCH_PEOPLE,
153
221
  ...opts,
154
222
  });
155
223
  },
156
224
  searchCompanies(opts = {}) {
157
- return this.post({
158
- path: "/companies/search",
225
+ return this._action({
226
+ path: ENDPOINTS.PROFILES,
227
+ action: ACTIONS.SEARCH_COMPANIES,
159
228
  ...opts,
160
229
  });
161
230
  },
162
231
  getCompanyInfo(opts = {}) {
163
- return this.post({
164
- path: "/companies/info",
232
+ return this._action({
233
+ path: ENDPOINTS.PROFILES,
234
+ action: ACTIONS.GET_COMPANY,
165
235
  ...opts,
166
236
  });
167
237
  },
168
238
  connectToProfile(opts = {}) {
169
- return this.post({
170
- path: "/network/connect",
239
+ return this._action({
240
+ path: ENDPOINTS.NETWORK,
241
+ action: ACTIONS.INVITE,
171
242
  ...opts,
172
243
  });
173
244
  },
174
- getInvitationsStatus(opts = {}) {
175
- return this.post({
176
- path: "/network/invitations",
245
+ getInvitations(opts = {}) {
246
+ return this._action({
247
+ path: ENDPOINTS.NETWORK,
248
+ action: ACTIONS.LIST_INVITATIONS,
177
249
  ...opts,
178
250
  });
179
251
  },
180
252
  sendMessage(opts = {}) {
181
- return this.post({
182
- path: "/messages/send-message",
253
+ return this._action({
254
+ path: ENDPOINTS.MESSAGES,
255
+ action: ACTIONS.SEND,
183
256
  ...opts,
184
257
  });
185
258
  },
186
259
  getConversationMessages(opts = {}) {
187
- return this.post({
188
- path: "/messages/conversation",
260
+ return this._action({
261
+ path: ENDPOINTS.MESSAGES,
262
+ action: ACTIONS.GET_CONVERSATION,
189
263
  ...opts,
190
264
  });
191
265
  },
192
- getConversations(opts = {}) {
193
- return this.post({
194
- path: "/messages/inbox",
266
+ listInbox(opts = {}) {
267
+ return this._action({
268
+ path: ENDPOINTS.MESSAGES,
269
+ action: ACTIONS.LIST_INBOX,
195
270
  ...opts,
196
271
  });
197
272
  },
198
273
  createComment(opts = {}) {
199
- return this.post({
200
- path: "/posts/comment",
274
+ return this._action({
275
+ path: ENDPOINTS.CONTENT,
276
+ action: ACTIONS.COMMENT,
201
277
  ...opts,
202
278
  });
203
279
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/linkupapi",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "Pipedream LinkupAPI Components",
5
5
  "main": "linkupapi.app.mjs",
6
6
  "keywords": [
@@ -1,56 +0,0 @@
1
- import app from "../../linkupapi.app.mjs";
2
-
3
- export default {
4
- type: "action",
5
- key: "linkupapi-login",
6
- name: "Login",
7
- description: "Authenticate with LinkedIn credentials. [See the documentation](https://docs.linkupapi.com/api-reference/linkup/authentication/login)",
8
- version: "0.0.2",
9
- props: {
10
- app,
11
- email: {
12
- propDefinition: [
13
- app,
14
- "email",
15
- ],
16
- },
17
- password: {
18
- propDefinition: [
19
- app,
20
- "password",
21
- ],
22
- },
23
- country: {
24
- propDefinition: [
25
- app,
26
- "country",
27
- ],
28
- },
29
- },
30
- annotations: {
31
- readOnlyHint: false,
32
- destructiveHint: false,
33
- openWorldHint: true,
34
- },
35
- async run({ $ }) {
36
- const {
37
- app,
38
- email,
39
- password,
40
- country,
41
- } = this;
42
-
43
- const response = await app.login({
44
- $,
45
- data: {
46
- email,
47
- password,
48
- country,
49
- },
50
- });
51
-
52
- $.export("$summary", "Successfully authenticated with LinkedIn account");
53
-
54
- return response;
55
- },
56
- };
package/common/utils.mjs DELETED
@@ -1,9 +0,0 @@
1
- function getOptionalProp(value, separator = ";") {
2
- return Array.isArray(value) && value.length > 0
3
- ? value.join(separator)
4
- : undefined;
5
- }
6
-
7
- export default {
8
- getOptionalProp,
9
- };