@entergreat/unipile-wrapper 1.0.12 → 2.1.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.
Files changed (101) hide show
  1. package/README.md +290 -161
  2. package/dist/client/httpClient.d.ts +14 -0
  3. package/dist/client/httpClient.d.ts.map +1 -0
  4. package/dist/client/httpClient.js +50 -0
  5. package/dist/client/httpClient.js.map +1 -0
  6. package/dist/client/index.d.ts +2 -0
  7. package/dist/client/index.d.ts.map +1 -0
  8. package/dist/client/index.js +2 -0
  9. package/dist/client/index.js.map +1 -0
  10. package/dist/index.d.ts +12 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +21 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/services/accountService.d.ts +11 -0
  15. package/dist/services/accountService.d.ts.map +1 -0
  16. package/dist/services/accountService.js +17 -0
  17. package/dist/services/accountService.js.map +1 -0
  18. package/dist/services/baseService.d.ts +10 -0
  19. package/dist/services/baseService.d.ts.map +1 -0
  20. package/dist/services/baseService.js +23 -0
  21. package/dist/services/baseService.js.map +1 -0
  22. package/dist/services/companyService.d.ts +11 -0
  23. package/dist/services/companyService.d.ts.map +1 -0
  24. package/dist/services/companyService.js +26 -0
  25. package/dist/services/companyService.js.map +1 -0
  26. package/dist/services/index.d.ts +6 -0
  27. package/dist/services/index.d.ts.map +1 -0
  28. package/dist/services/index.js +6 -0
  29. package/dist/services/index.js.map +1 -0
  30. package/dist/services/profileService.d.ts +20 -0
  31. package/dist/services/profileService.d.ts.map +1 -0
  32. package/dist/services/profileService.js +85 -0
  33. package/dist/services/profileService.js.map +1 -0
  34. package/dist/services/searchService.d.ts +19 -0
  35. package/dist/services/searchService.d.ts.map +1 -0
  36. package/dist/services/searchService.js +54 -0
  37. package/dist/services/searchService.js.map +1 -0
  38. package/dist/types/account.d.ts +8 -0
  39. package/dist/types/account.d.ts.map +1 -0
  40. package/dist/types/account.js +2 -0
  41. package/dist/types/account.js.map +1 -0
  42. package/dist/types/common.d.ts +19 -0
  43. package/dist/types/common.d.ts.map +1 -0
  44. package/dist/types/common.js +2 -0
  45. package/dist/types/common.js.map +1 -0
  46. package/dist/types/company.d.ts +11 -0
  47. package/dist/types/company.d.ts.map +1 -0
  48. package/dist/types/company.js +2 -0
  49. package/dist/types/company.js.map +1 -0
  50. package/dist/types/index.d.ts +6 -0
  51. package/dist/types/index.d.ts.map +1 -0
  52. package/dist/types/index.js +6 -0
  53. package/dist/types/index.js.map +1 -0
  54. package/dist/types/profile.d.ts +46 -0
  55. package/dist/types/profile.d.ts.map +1 -0
  56. package/dist/types/profile.js +2 -0
  57. package/dist/types/profile.js.map +1 -0
  58. package/dist/types/search.d.ts +22 -0
  59. package/dist/types/search.d.ts.map +1 -0
  60. package/dist/types/search.js +2 -0
  61. package/dist/types/search.js.map +1 -0
  62. package/dist/utils/helpers.d.ts +14 -0
  63. package/dist/utils/helpers.d.ts.map +1 -0
  64. package/dist/utils/helpers.js +34 -0
  65. package/dist/utils/helpers.js.map +1 -0
  66. package/dist/utils/index.d.ts +4 -0
  67. package/dist/utils/index.d.ts.map +1 -0
  68. package/dist/utils/index.js +4 -0
  69. package/dist/utils/index.js.map +1 -0
  70. package/dist/utils/urlBuilder.d.ts +11 -0
  71. package/dist/utils/urlBuilder.d.ts.map +1 -0
  72. package/dist/utils/urlBuilder.js +23 -0
  73. package/dist/utils/urlBuilder.js.map +1 -0
  74. package/dist/utils/validators.d.ts +13 -0
  75. package/dist/utils/validators.d.ts.map +1 -0
  76. package/dist/utils/validators.js +39 -0
  77. package/dist/utils/validators.js.map +1 -0
  78. package/package.json +19 -8
  79. package/src/client/httpClient.ts +61 -0
  80. package/src/client/index.ts +1 -0
  81. package/src/index.ts +31 -0
  82. package/src/services/accountService.ts +21 -0
  83. package/src/services/baseService.ts +31 -0
  84. package/src/services/companyService.ts +37 -0
  85. package/src/services/index.ts +5 -0
  86. package/src/services/profileService.ts +142 -0
  87. package/src/services/searchService.ts +88 -0
  88. package/src/types/account.ts +9 -0
  89. package/src/types/common.ts +21 -0
  90. package/src/types/company.ts +13 -0
  91. package/src/types/index.ts +5 -0
  92. package/src/types/profile.ts +50 -0
  93. package/src/types/search.ts +27 -0
  94. package/src/utils/helpers.ts +41 -0
  95. package/src/utils/index.ts +3 -0
  96. package/src/utils/urlBuilder.ts +29 -0
  97. package/src/utils/validators.ts +47 -0
  98. package/tsconfig.json +21 -0
  99. package/src/index.js +0 -3
  100. package/src/services/linkedinService.js +0 -260
  101. package/src/utils/api.js +0 -28
package/README.md CHANGED
@@ -1,216 +1,345 @@
1
1
  # Unipile Wrapper
2
2
 
3
- ## Overview 🌐
4
- A lightweight JavaScript wrapper for Unipile's social network automation platform. This wrapper simplifies the interaction with Unipile's API, currently focusing on LinkedIn automation features. The wrapper provides an easy-to-use interface for common LinkedIn operations while handling the underlying API communication with Unipile.
3
+ ## Overview
5
4
 
6
- ## Features
7
- - Simplified interface for Unipile's LinkedIn API
5
+ A lightweight TypeScript wrapper for Unipile's social network automation platform. This wrapper simplifies the interaction with Unipile's API, currently focusing on LinkedIn automation features. The wrapper provides a modular, type-safe interface for common LinkedIn operations.
6
+
7
+ ## Features
8
+
9
+ - Full TypeScript support with type definitions
10
+ - Modular architecture with domain-based services
8
11
  - Easy account connection using li_at cookies
9
12
  - Streamlined search capabilities (URL-based and parameter-based)
10
- - Profile management (retrieve and edit)
13
+ - Profile management (retrieve, edit, add experience)
14
+ - Company information retrieval
11
15
  - Built-in pagination support
12
- - Clean error handling
16
+ - Centralized validation and error handling
13
17
  - Promise-based async/await interface
14
18
 
15
- ## Prerequisites 📋
19
+ ## Prerequisites
20
+
21
+ - Node.js 16+
16
22
  - An active Unipile account
17
23
  - Unipile API token
18
24
  - Access to a Unipile subdomain and port
19
25
 
20
- ## Installation 🛠️
26
+ ## Installation
27
+
21
28
  ```bash
22
29
  npm install @entergreat/unipile-wrapper
23
30
  ```
24
31
 
25
- ## Configuration ⚙️
32
+ ## Configuration
33
+
26
34
  Initialize the wrapper with your Unipile credentials:
27
35
 
28
- ```javascript
29
- import { LinkedinService } from 'unipile-linkedin-wrapper';
36
+ ```typescript
37
+ import { LinkedinService } from '@entergreat/unipile-wrapper';
30
38
 
31
- const linkedinService = new LinkedinService({
39
+ // With default accountId (recommended for single-account usage)
40
+ const linkedin = new LinkedinService({
32
41
  unipileToken: 'your-unipile-token',
33
42
  subdomain: 'your-subdomain',
34
- port: 'port-number'
43
+ port: 443,
44
+ accountId: 'your-account-id' // Optional: set default accountId
45
+ });
46
+
47
+ // Without default accountId (for multi-account usage)
48
+ const linkedin = new LinkedinService({
49
+ unipileToken: 'your-unipile-token',
50
+ subdomain: 'your-subdomain',
51
+ port: 443
35
52
  });
36
53
  ```
37
54
 
38
- ## Usage 🚀
55
+ When `accountId` is set in config, you don't need to pass it to each method. You can still override it per-call:
56
+
57
+ ```typescript
58
+ // Uses default accountId from config
59
+ await linkedin.search.byParams({ params: { keywords: 'developer' } });
60
+
61
+ // Override with different accountId
62
+ await linkedin.search.byParams({
63
+ accountId: 'different-account-id',
64
+ params: { keywords: 'developer' }
65
+ });
66
+ ```
67
+
68
+ ## Architecture
69
+
70
+ The wrapper is organized into domain-based services:
71
+
72
+ ```
73
+ LinkedinService
74
+ ├── account → Account connection
75
+ ├── search → LinkedIn search operations
76
+ ├── profile → Profile management
77
+ └── company → Company information
78
+ ```
79
+
80
+ ## Usage
39
81
 
40
82
  ### Connect LinkedIn Account
83
+
41
84
  Add a LinkedIn account to Unipile using a li_at cookie:
42
85
 
43
- ```javascript
44
- try {
45
- const account = await linkedinService.connect({
46
- loginCookie: 'your-li-at-cookie'
47
- });
48
- console.log('Successfully connected account to Unipile:', account);
49
- } catch (error) {
50
- console.error('Connection failed:', error);
51
- }
86
+ ```typescript
87
+ const account = await linkedin.account.connect({
88
+ loginCookie: 'your-li-at-cookie'
89
+ });
52
90
  ```
53
91
 
54
92
  ### Search LinkedIn
93
+
55
94
  #### Using Parameters
56
- ```javascript
57
- const searchParams = {
58
- keywords: 'software engineer',
59
- location: 'United States',
60
- // Additional LinkedIn search parameters
61
- };
62
95
 
63
- try {
64
- const results = await linkedinService.searchByParams({
65
- accountId: 'your-unipile-account-id',
66
- params: searchParams,
67
- cursor: '', // for pagination
68
- limit: 10
69
- });
70
- console.log('Search results:', results);
71
- } catch (error) {
72
- console.error('Search failed:', error);
73
- }
96
+ ```typescript
97
+ const results = await linkedin.search.byParams({
98
+ accountId: 'your-unipile-account-id',
99
+ params: {
100
+ keywords: 'software engineer',
101
+ location: 'United States'
102
+ },
103
+ cursor: '', // for pagination
104
+ limit: 10
105
+ });
74
106
  ```
75
107
 
76
108
  #### Using LinkedIn URL
77
- ```javascript
78
- try {
79
- const results = await linkedinService.searchByUrl({
80
- accountId: 'your-unipile-account-id',
81
- searchUrl: 'linkedin-search-url',
82
- cursor: '', // for pagination
83
- limit: 10
84
- });
85
- console.log('Search results:', results);
86
- } catch (error) {
87
- console.error('Search failed:', error);
88
- }
109
+
110
+ ```typescript
111
+ const results = await linkedin.search.byUrl({
112
+ accountId: 'your-unipile-account-id',
113
+ searchUrl: 'https://www.linkedin.com/search/results/people/?keywords=developer',
114
+ cursor: '',
115
+ limit: 10
116
+ });
89
117
  ```
90
118
 
91
- ### Edit LinkedIn Profile
92
- Update the authenticated account's LinkedIn profile:
119
+ #### Retrieve Search Parameters
93
120
 
94
- ```javascript
95
- try {
96
- const result = await linkedinService.editProfile({
97
- accountId: 'your-unipile-account-id',
98
- profileData: {
99
- headline: 'Senior Software Engineer | Node.js Expert'
100
- }
101
- });
102
- console.log('Profile updated successfully:', result);
103
- } catch (error) {
104
- console.error('Profile update failed:', error);
105
- }
121
+ ```typescript
122
+ const suggestions = await linkedin.search.retrieveParameters({
123
+ accountId: 'your-unipile-account-id',
124
+ type: 'LOCATION',
125
+ keywords: 'new york',
126
+ limit: 5
127
+ });
106
128
  ```
107
129
 
108
- #### Update multiple fields at once:
109
- ```javascript
110
- try {
111
- const result = await linkedinService.editProfile({
112
- accountId: 'your-unipile-account-id',
113
- profileData: {
114
- headline: 'Full Stack Developer',
115
- summary: 'Passionate developer with 10+ years of experience...',
116
- location: { id: '105015875' },
117
- experience: {
118
- skills: ['JavaScript', 'Python', 'React', 'Node.js']
119
- }
120
- }
121
- });
122
- console.log('Profile updated successfully:', result);
123
- } catch (error) {
124
- console.error('Profile update failed:', error);
125
- }
130
+ ### Profile Management
131
+
132
+ #### Retrieve Profile
133
+
134
+ ```typescript
135
+ const profile = await linkedin.profile.retrieve({
136
+ accountId: 'your-unipile-account-id',
137
+ profileId: 'john-doe-123',
138
+ linkedinSections: ['experience', 'education'],
139
+ notify: false
140
+ });
141
+ ```
142
+
143
+ #### Edit Profile
144
+
145
+ ```typescript
146
+ const result = await linkedin.profile.edit({
147
+ accountId: 'your-unipile-account-id',
148
+ profileData: {
149
+ headline: 'Senior Software Engineer | Node.js Expert',
150
+ summary: 'Passionate developer with 10+ years of experience...',
151
+ location: { id: '105015875' }
152
+ }
153
+ });
126
154
  ```
127
155
 
128
- ## API Reference 📚
156
+ #### Add Experience
157
+
158
+ ```typescript
159
+ const result = await linkedin.profile.addExperience({
160
+ accountId: 'your-unipile-account-id',
161
+ experience: {
162
+ role: 'Software Engineer',
163
+ company: 'Acme Corp',
164
+ company_id: '123456',
165
+ description: 'Building awesome products',
166
+ location: 'Tel Aviv, Israel',
167
+ start_month: 3,
168
+ start_year: 2024,
169
+ skills: ['TypeScript', 'Node.js', 'React'],
170
+ notify_network: false
171
+ }
172
+ });
173
+ ```
174
+
175
+ ### Company Information
176
+
177
+ ```typescript
178
+ // By company ID
179
+ const company = await linkedin.company.retrieve({
180
+ accountId: 'your-unipile-account-id',
181
+ companyId: '123456'
182
+ });
183
+
184
+ // By company URL
185
+ const company = await linkedin.company.retrieve({
186
+ accountId: 'your-unipile-account-id',
187
+ companyUrl: 'https://www.linkedin.com/company/acme-corp'
188
+ });
189
+ ```
190
+
191
+ ## API Reference
129
192
 
130
193
  ### LinkedinService
131
194
 
132
195
  #### Constructor
133
- ```javascript
196
+
197
+ ```typescript
134
198
  new LinkedinService({
135
- unipileToken: string, // Your Unipile API token
136
- subdomain: string, // Your Unipile subdomain
137
- port: number // Unipile port number
199
+ unipileToken: string, // Your Unipile API token
200
+ subdomain: string, // Your Unipile subdomain
201
+ port: number | string, // Unipile port number
202
+ accountId?: string // Optional: default account ID for all methods
138
203
  })
139
204
  ```
140
205
 
141
- #### Methods
206
+ ### AccountService (`linkedin.account`)
142
207
 
143
- ##### connect({ loginCookie: string })
208
+ #### `connect({ loginCookie })`
144
209
  Connects a LinkedIn account to Unipile using a li_at cookie.
145
- - **Parameters:**
146
- - `loginCookie`: LinkedIn li_at cookie value
147
- - **Returns:** Promise with Unipile account connection details
148
-
149
- ##### searchByParams({ accountId: string, params?: object, cursor?: string, limit?: number })
150
- Performs a LinkedIn search through Unipile using specified parameters.
151
- - **Parameters:**
152
- - `accountId`: Unipile account ID (required)
153
- - `params`: LinkedIn search parameters (optional, default: {})
154
- - `cursor`: Pagination cursor (optional, default: "")
155
- - `limit`: Results per page (optional, default: 10)
156
- - **Returns:** Promise with search results
157
- - **Note:** Automatically sets `api: "classic"` and `category: "people"`
158
-
159
- ##### searchByUrl({ accountId: string, searchUrl: string, cursor?: string, limit?: number })
160
- Performs a LinkedIn search through Unipile using a LinkedIn search URL.
161
- - **Parameters:**
162
- - `accountId`: Unipile account ID (required)
163
- - `searchUrl`: LinkedIn search URL (required)
164
- - `cursor`: Pagination cursor (optional, default: "")
165
- - `limit`: Results per page (optional, default: 10)
166
- - **Returns:** Promise with search results
167
-
168
- ##### retrieveSearchParameters({ accountId: string, type: string, keywords?: string, limit?: number })
169
- Retrieves LinkedIn search parameter suggestions from Unipile.
170
- - **Parameters:**
171
- - `accountId`: Unipile account ID (required)
172
- - `type`: Parameter type to retrieve (required)
173
- - `keywords`: Search keywords for suggestions (optional, default: "")
174
- - `limit`: Number of suggestions (optional, default: 3)
175
- - **Returns:** Promise with search parameter suggestions
176
-
177
- ##### retrieveProfile({ accountId: string, profileId: string, linkedinSections?: array, notify?: boolean })
178
- Retrieves a LinkedIn user profile through Unipile.
179
- - **Parameters:**
180
- - `accountId`: Unipile account ID (required)
181
- - `profileId`: LinkedIn profile ID or URL (required)
182
- - `linkedinSections`: Array of specific LinkedIn sections to retrieve (optional, default: [])
183
- - `notify`: Whether to notify the profile owner (optional, default: false)
184
- - **Returns:** Promise with user profile data
185
-
186
- ##### editProfile({ accountId: string, profileData: object })
187
- Edits the LinkedIn profile of the account owner through Unipile.
188
- - **Parameters:**
189
- - `accountId`: Unipile account ID (required)
190
- - `profileData`: Object containing profile fields to update (required)
191
- - Supported fields include: `headline`, `summary`, `location`, `picture`, `experience`, `education`, and more
192
- - Nested objects are automatically converted to Unipile's bracket notation format
193
- - Example fields:
194
- - `headline`: string - Professional headline
195
- - `summary`: string - Profile bio/summary
196
- - `location`: object - Location with `id` field
197
- - `picture`: object - Profile/cover picture settings
198
- - `experience`: object - Experience data with `skills` array, positions, etc.
199
- - `education`: object - Education entries
200
- - **Returns:** Promise with updated profile data
201
- - **Note:** Only the account owner's profile can be edited (the profile associated with the accountId)
202
-
203
- ## Error Handling ⚠️
204
- The wrapper provides error handling for common Unipile API interactions:
205
- - Validates required parameters (e.g., accountId)
206
- - Propagates Unipile API errors with original error messages
207
- - Wraps API calls in try-catch blocks for easier error handling
208
-
209
- ## Dependencies 🔧
210
- - Requires `api.js` utility for HTTP requests to Unipile API
211
-
212
- ## Contributing 🤝
210
+
211
+ | Parameter | Type | Required | Description |
212
+ |-----------|------|----------|-------------|
213
+ | loginCookie | string | Yes | LinkedIn li_at cookie value |
214
+
215
+ ### SearchService (`linkedin.search`)
216
+
217
+ #### `byParams({ accountId, params, cursor, limit })`
218
+ Performs a LinkedIn search using specified parameters.
219
+
220
+ | Parameter | Type | Required | Default | Description |
221
+ |-----------|------|----------|---------|-------------|
222
+ | accountId | string | No* | config.accountId | Unipile account ID |
223
+ | params | object | No | {} | LinkedIn search parameters |
224
+ | cursor | string | No | - | Pagination cursor |
225
+ | limit | number | No | 10 | Results per page |
226
+
227
+ #### `byUrl({ accountId, searchUrl, cursor, limit })`
228
+ Performs a LinkedIn search using a LinkedIn search URL.
229
+
230
+ | Parameter | Type | Required | Default | Description |
231
+ |-----------|------|----------|---------|-------------|
232
+ | accountId | string | No* | config.accountId | Unipile account ID |
233
+ | searchUrl | string | Yes | - | LinkedIn search URL |
234
+ | cursor | string | No | - | Pagination cursor |
235
+ | limit | number | No | 10 | Results per page |
236
+
237
+ #### `retrieveParameters({ accountId, type, keywords, limit })`
238
+ Retrieves LinkedIn search parameter suggestions.
239
+
240
+ | Parameter | Type | Required | Default | Description |
241
+ |-----------|------|----------|---------|-------------|
242
+ | accountId | string | No* | config.accountId | Unipile account ID |
243
+ | type | string | Yes | - | Parameter type (e.g., LOCATION) |
244
+ | keywords | string | No | "" | Search keywords |
245
+ | limit | number | No | 3 | Number of suggestions |
246
+
247
+ *Required if not set in constructor config.
248
+
249
+ ### ProfileService (`linkedin.profile`)
250
+
251
+ #### `retrieve({ accountId, profileId, linkedinSections, notify })`
252
+ Retrieves a LinkedIn user profile.
253
+
254
+ | Parameter | Type | Required | Default | Description |
255
+ |-----------|------|----------|---------|-------------|
256
+ | accountId | string | No* | config.accountId | Unipile account ID |
257
+ | profileId | string | Yes | - | LinkedIn profile ID or URL |
258
+ | linkedinSections | string[] | No | [] | Sections to retrieve |
259
+ | notify | boolean | No | false | Notify profile owner |
260
+
261
+ #### `edit({ accountId, profileData })`
262
+ Edits the LinkedIn profile of the account owner.
263
+
264
+ | Parameter | Type | Required | Default | Description |
265
+ |-----------|------|----------|---------|-------------|
266
+ | accountId | string | No* | config.accountId | Unipile account ID |
267
+ | profileData | object | Yes | - | Profile fields to update |
268
+
269
+ **ProfileData fields:**
270
+ - `headline`: string - Professional headline
271
+ - `summary`: string - Profile bio/summary
272
+ - `location`: { id: string } - Location object
273
+ - `picture`: object - Profile/cover picture settings
274
+ - `experience`: object - Experience data
275
+ - `education`: object - Education entries
276
+
277
+ #### `addExperience({ accountId, experience })`
278
+ Adds a work experience position to the profile.
279
+
280
+ | Parameter | Type | Required | Default | Description |
281
+ |-----------|------|----------|---------|-------------|
282
+ | accountId | string | No* | config.accountId | Unipile account ID |
283
+ | experience | ExperienceData | Yes | - | Experience details |
284
+
285
+ *Required if not set in constructor config.
286
+
287
+ **ExperienceData fields:**
288
+
289
+ | Field | Type | Required | Description |
290
+ |-------|------|----------|-------------|
291
+ | role | string | Yes | Job title |
292
+ | company | string | Yes | Company name |
293
+ | company_id | string | No | LinkedIn company ID |
294
+ | description | string | No | Role description |
295
+ | location | string | No | Job location |
296
+ | start_month | number | No | Start month (1-12) |
297
+ | start_year | number | No | Start year |
298
+ | end_month | number | No | End month (1-12) |
299
+ | end_year | number | No | End year |
300
+ | skills | string[] | No | Associated skills |
301
+ | notify_network | boolean | No | Notify connections |
302
+
303
+ ### CompanyService (`linkedin.company`)
304
+
305
+ #### `retrieve({ accountId, companyId, companyUrl })`
306
+ Retrieves LinkedIn company information.
307
+
308
+ | Parameter | Type | Required | Default | Description |
309
+ |-----------|------|----------|---------|-------------|
310
+ | accountId | string | No** | config.accountId | Unipile account ID |
311
+ | companyId | string | No* | - | LinkedIn company ID |
312
+ | companyUrl | string | No* | - | LinkedIn company URL |
313
+
314
+ *Either `companyId` or `companyUrl` must be provided.
315
+
316
+ **Required if not set in constructor config.
317
+
318
+ ## Error Handling
319
+
320
+ The wrapper throws `ValidationError` for invalid inputs:
321
+
322
+ ```typescript
323
+ import { ValidationError } from '@entergreat/unipile-wrapper';
324
+
325
+ try {
326
+ await linkedin.profile.retrieve({ accountId: '', profileId: 'test' });
327
+ } catch (error) {
328
+ if (error instanceof ValidationError) {
329
+ console.error('Validation failed:', error.message);
330
+ }
331
+ }
332
+ ```
333
+
334
+ ## Dependencies
335
+
336
+ - `axios` - HTTP client
337
+ - `form-data` - Multipart form handling
338
+
339
+ ## Contributing
340
+
213
341
  Contributions are welcome! Feel free to submit issues and pull requests.
214
342
 
215
- ## License 📄
216
- MIT License - see LICENSE file for details
343
+ ## License
344
+
345
+ MIT License - see LICENSE file for details
@@ -0,0 +1,14 @@
1
+ import FormData from "form-data";
2
+ import { ServiceConfig } from "../types/index.js";
3
+ export declare class HttpClient {
4
+ private client;
5
+ private apiKey;
6
+ constructor(config: ServiceConfig);
7
+ private setupInterceptors;
8
+ get baseURL(): string;
9
+ get<T>(url: string): Promise<T>;
10
+ post<T>(url: string, body?: Record<string, unknown>): Promise<T>;
11
+ patch<T>(url: string, body?: Record<string, unknown>): Promise<T>;
12
+ patchFormData<T>(url: string, formData: FormData): Promise<T>;
13
+ }
14
+ //# sourceMappingURL=httpClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpClient.d.ts","sourceRoot":"","sources":["../../src/client/httpClient.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,aAAa;IAejC,OAAO,CAAC,iBAAiB;IAOzB,IAAI,OAAO,IAAI,MAAM,CAEpB;IAEK,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/B,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAKpE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAKrE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;CAWpE"}
@@ -0,0 +1,50 @@
1
+ import axios from "axios";
2
+ export class HttpClient {
3
+ client;
4
+ apiKey;
5
+ constructor(config) {
6
+ const baseURL = `https://${config.subdomain}.unipile.com:${config.port}/api/v1`;
7
+ this.apiKey = config.unipileToken;
8
+ this.client = axios.create({
9
+ baseURL,
10
+ headers: {
11
+ accept: "application/json",
12
+ "content-type": "application/json",
13
+ },
14
+ });
15
+ this.setupInterceptors();
16
+ }
17
+ setupInterceptors() {
18
+ this.client.interceptors.request.use((config) => {
19
+ config.headers["X-API-KEY"] = this.apiKey;
20
+ return config;
21
+ });
22
+ }
23
+ get baseURL() {
24
+ return this.client.defaults.baseURL || "";
25
+ }
26
+ async get(url) {
27
+ const response = await this.client.get(url);
28
+ return response.data;
29
+ }
30
+ async post(url, body = {}) {
31
+ const response = await this.client.post(url, body);
32
+ return response.data;
33
+ }
34
+ async patch(url, body = {}) {
35
+ const response = await this.client.patch(url, body);
36
+ return response.data;
37
+ }
38
+ async patchFormData(url, formData) {
39
+ const config = {
40
+ headers: {
41
+ ...formData.getHeaders(),
42
+ "X-API-KEY": this.apiKey,
43
+ accept: "application/json",
44
+ },
45
+ };
46
+ const response = await this.client.patch(url, formData, config);
47
+ return response.data;
48
+ }
49
+ }
50
+ //# sourceMappingURL=httpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../src/client/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAIjE,MAAM,OAAO,UAAU;IACb,MAAM,CAAgB;IACtB,MAAM,CAAS;IAEvB,YAAY,MAAqB;QAC/B,MAAM,OAAO,GAAG,WAAW,MAAM,CAAC,SAAS,gBAAgB,MAAM,CAAC,IAAI,SAAS,CAAC;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;QAElC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACzB,OAAO;YACP,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC9C,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1C,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAI,GAAG,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,IAAI,CAAI,GAAW,EAAE,OAAgC,EAAE;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAI,GAAG,EAAE,IAAI,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,KAAK,CAAI,GAAW,EAAE,OAAgC,EAAE;QAC5D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAI,GAAG,EAAE,IAAI,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,aAAa,CAAI,GAAW,EAAE,QAAkB;QACpD,MAAM,MAAM,GAAuB;YACjC,OAAO,EAAE;gBACP,GAAG,QAAQ,CAAC,UAAU,EAAE;gBACxB,WAAW,EAAE,IAAI,CAAC,MAAM;gBACxB,MAAM,EAAE,kBAAkB;aAC3B;SACF,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAI,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnE,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from "./httpClient.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./httpClient.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { AccountService, SearchService, ProfileService, CompanyService } from "./services/index.js";
2
+ import { ServiceConfig } from "./types/index.js";
3
+ export declare class LinkedinService {
4
+ account: AccountService;
5
+ search: SearchService;
6
+ profile: ProfileService;
7
+ company: CompanyService;
8
+ constructor(config: ServiceConfig);
9
+ }
10
+ export * from "./types/index.js";
11
+ export { ValidationError } from "./utils/validators.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qBAAa,eAAe;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;gBAEnB,MAAM,EAAE,aAAa;CASlC;AAGD,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { HttpClient } from "./client/index.js";
2
+ import { AccountService, SearchService, ProfileService, CompanyService, } from "./services/index.js";
3
+ export class LinkedinService {
4
+ account;
5
+ search;
6
+ profile;
7
+ company;
8
+ constructor(config) {
9
+ const client = new HttpClient(config);
10
+ const { accountId } = config;
11
+ this.account = new AccountService(client, accountId);
12
+ this.search = new SearchService(client, accountId);
13
+ this.profile = new ProfileService(client, accountId);
14
+ this.company = new CompanyService(client, accountId);
15
+ }
16
+ }
17
+ // Re-export types for consumers
18
+ export * from "./types/index.js";
19
+ // Re-export utilities that might be useful
20
+ export { ValidationError } from "./utils/validators.js";
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,MAAM,OAAO,eAAe;IACnB,OAAO,CAAiB;IACxB,MAAM,CAAgB;IACtB,OAAO,CAAiB;IACxB,OAAO,CAAiB;IAE/B,YAAY,MAAqB;QAC/B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAE7B,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAED,gCAAgC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,2CAA2C;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { HttpClient } from "../client/index.js";
2
+ import { BaseService } from "./baseService.js";
3
+ import { ConnectParams, ConnectResponse } from "../types/index.js";
4
+ export declare class AccountService extends BaseService {
5
+ constructor(client: HttpClient, defaultAccountId?: string);
6
+ /**
7
+ * Connect a LinkedIn account to Unipile using a li_at cookie
8
+ */
9
+ connect({ loginCookie }: ConnectParams): Promise<ConnectResponse>;
10
+ }
11
+ //# sourceMappingURL=accountService.d.ts.map