linkedin-secret-sauce 0.3.20 → 0.3.21

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/dist/types.d.ts CHANGED
@@ -207,12 +207,24 @@ export type Geo = {
207
207
  export type SalesSearchFilters = {
208
208
  company?: {
209
209
  current?: {
210
- include?: string[];
211
- exclude?: string[];
210
+ include?: (string | {
211
+ id?: string | number;
212
+ text?: string;
213
+ })[];
214
+ exclude?: (string | {
215
+ id?: string | number;
216
+ text?: string;
217
+ })[];
212
218
  };
213
219
  past?: {
214
- include?: string[];
215
- exclude?: string[];
220
+ include?: (string | {
221
+ id?: string | number;
222
+ text?: string;
223
+ })[];
224
+ exclude?: (string | {
225
+ id?: string | number;
226
+ text?: string;
227
+ })[];
216
228
  };
217
229
  headcount?: {
218
230
  include?: ("1-10" | "11-50" | "51-200" | "201-500" | "501-1000" | "1001-5000" | "5001-10000" | "10000+")[];
@@ -117,22 +117,52 @@ function buildLeadSearchQuery(keywords, filters) {
117
117
  });
118
118
  pushFilter(f, 'COMPANY_HEADCOUNT', values);
119
119
  }
120
- // CURRENT_COMPANY — accept org URN (urn:li:organization:ID), numeric ID, or text
121
- if (filters?.company?.current?.include?.length) {
122
- const values = filters.company.current.include.map((c) => {
123
- const s = String(c);
120
+ // CURRENT_COMPANY — accept org URN (urn:li:organization:ID), numeric ID, text, or object with {id, text}
121
+ function encodeCompanies(arr) {
122
+ if (!arr || !arr.length)
123
+ return [];
124
+ return arr.map((c) => {
124
125
  const parts = [];
125
- if (/^urn:li:organization:\d+$/i.test(s) || /^\d+$/.test(s)) {
126
- parts.push(`id:${s}`);
126
+ if (typeof c === 'object' && c !== null) {
127
+ // Handle object format: { id: 'urn:...', text: 'Company Name' }
128
+ if (c.id != null) {
129
+ const idStr = String(c.id);
130
+ // If numeric, convert to URN
131
+ if (/^\d+$/.test(idStr)) {
132
+ parts.push(`id:urn:li:organization:${idStr}`);
133
+ }
134
+ else {
135
+ parts.push(`id:${idStr}`);
136
+ }
137
+ }
138
+ if (c.text) {
139
+ parts.push(`text:${encText(c.text)}`);
140
+ }
127
141
  }
128
142
  else {
129
- parts.push(`text:${encText(s)}`);
143
+ // Handle string format (legacy)
144
+ const s = String(c);
145
+ if (/^urn:li:organization:\d+$/i.test(s)) {
146
+ parts.push(`id:${s}`);
147
+ }
148
+ else if (/^\d+$/.test(s)) {
149
+ parts.push(`id:urn:li:organization:${s}`);
150
+ }
151
+ else {
152
+ parts.push(`text:${encText(s)}`);
153
+ }
130
154
  }
131
155
  parts.push('selectionType:INCLUDED');
132
156
  return valObj(parts);
133
157
  });
134
- pushFilter(f, 'CURRENT_COMPANY', values);
135
158
  }
159
+ const curCompanies = encodeCompanies(filters?.company?.current?.include);
160
+ if (curCompanies.length)
161
+ pushFilter(f, 'CURRENT_COMPANY', curCompanies);
162
+ // PAST_COMPANY — same logic as current
163
+ const pastCompanies = encodeCompanies(filters?.company?.past?.include);
164
+ if (pastCompanies.length)
165
+ pushFilter(f, 'PAST_COMPANY', pastCompanies);
136
166
  // COMPANY_TYPE — map to C,P,N,D,G when known; allow raw codes
137
167
  const COMPANY_TYPE = {
138
168
  PUBLIC: 'C',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkedin-secret-sauce",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "Private LinkedIn Sales Navigator client with automatic cookie management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",