@curviate/cli 0.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.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/account-YOW2MCZS.js +639 -0
- package/dist/chunk-2NCPJJPC.js +140 -0
- package/dist/chunk-6JNCLLNY.js +195 -0
- package/dist/chunk-BNUTM6KD.js +33 -0
- package/dist/chunk-Q43HZUN3.js +29 -0
- package/dist/chunk-R3VLWLVV.js +23 -0
- package/dist/chunk-SND3NHCT.js +46 -0
- package/dist/chunk-UWO2D4HW.js +34 -0
- package/dist/cli.js +159 -0
- package/dist/company-IKVDW7MX.js +82 -0
- package/dist/config-4JOXBFYX.js +262 -0
- package/dist/connect-HLDHFBGX.js +348 -0
- package/dist/exit-codes-NFIR57ZA.js +57 -0
- package/dist/inbox-JBLYJMV2.js +294 -0
- package/dist/login-VWJEBBFU.js +122 -0
- package/dist/message-IK7VGB63.js +566 -0
- package/dist/post-EAAGVR5D.js +496 -0
- package/dist/profile-WXA3NC7D.js +352 -0
- package/dist/recruiter-TGCV36EH.js +984 -0
- package/dist/sales-nav-XGFO5I6F.js +488 -0
- package/dist/search-LHPTHPWH.js +354 -0
- package/dist/webhook-QM5LGAUF.js +445 -0
- package/package.json +54 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
buildPreviewOutput
|
|
4
|
+
} from "./chunk-R3VLWLVV.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveIdentifier
|
|
7
|
+
} from "./chunk-BNUTM6KD.js";
|
|
8
|
+
import {
|
|
9
|
+
streamAll
|
|
10
|
+
} from "./chunk-SND3NHCT.js";
|
|
11
|
+
import {
|
|
12
|
+
createClient,
|
|
13
|
+
renderError,
|
|
14
|
+
renderSuccess,
|
|
15
|
+
renderUnexpectedError,
|
|
16
|
+
resolveEffectiveConfig
|
|
17
|
+
} from "./chunk-2NCPJJPC.js";
|
|
18
|
+
import {
|
|
19
|
+
GLOBAL_FLAGS
|
|
20
|
+
} from "./chunk-6JNCLLNY.js";
|
|
21
|
+
|
|
22
|
+
// src/commands/profile.ts
|
|
23
|
+
import { defineCommand } from "citty";
|
|
24
|
+
function requireAccount(account, out) {
|
|
25
|
+
if (!account) {
|
|
26
|
+
out.stderr.write("error: --account is required for this command. Set it via --account, CURVIATE_ACCOUNT, or `curviate config set-account`.\n");
|
|
27
|
+
process.exit(2);
|
|
28
|
+
}
|
|
29
|
+
return account;
|
|
30
|
+
}
|
|
31
|
+
function rejectPreviewOnRead(preview, out) {
|
|
32
|
+
if (preview) {
|
|
33
|
+
out.stderr.write("error: --preview is only valid on write commands (mutations). Reads just run.\n");
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function rejectAllOnNonPaginated(all, out) {
|
|
38
|
+
if (all) {
|
|
39
|
+
out.stderr.write("error: --all is not supported on non-paginated commands.\n");
|
|
40
|
+
process.exit(2);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function buildOutputStreams() {
|
|
44
|
+
return {
|
|
45
|
+
stdout: { write: (s) => process.stdout.write(s) },
|
|
46
|
+
stderr: { write: (s) => process.stderr.write(s) }
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function resolveOutputOpts(flags) {
|
|
50
|
+
return {
|
|
51
|
+
json: (flags.json ?? false) || !process.stdout.isTTY,
|
|
52
|
+
isTTY: process.stdout.isTTY ?? false,
|
|
53
|
+
fields: flags.fields
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function runProfileMe(client, flags, out) {
|
|
57
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
58
|
+
rejectAllOnNonPaginated(flags.all, out);
|
|
59
|
+
const accountId = requireAccount(flags.account, out);
|
|
60
|
+
const ns = client.account(accountId);
|
|
61
|
+
try {
|
|
62
|
+
const result = await ns.profiles.getMe();
|
|
63
|
+
const opts = resolveOutputOpts(flags);
|
|
64
|
+
renderSuccess(result, opts, out);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
67
|
+
if (err instanceof CurviateError) {
|
|
68
|
+
const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
|
|
69
|
+
renderError(err, resolveOutputOpts(flags), out);
|
|
70
|
+
process.exit(getExitCode(err.code));
|
|
71
|
+
}
|
|
72
|
+
renderUnexpectedError(err, out);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function runProfileGet(client, flags, out) {
|
|
77
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
78
|
+
const accountId = requireAccount(flags.account, out);
|
|
79
|
+
const rawId = flags.id ?? "";
|
|
80
|
+
const resolvedId = resolveIdentifier(rawId);
|
|
81
|
+
const ns = client.account(accountId);
|
|
82
|
+
const outOpts = resolveOutputOpts(flags);
|
|
83
|
+
const all = flags.all ?? false;
|
|
84
|
+
const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
|
|
85
|
+
const limit = flags.limit ? parseInt(flags.limit, 10) : void 0;
|
|
86
|
+
const cursor = flags.cursor;
|
|
87
|
+
try {
|
|
88
|
+
if (flags.posts) {
|
|
89
|
+
const params = {};
|
|
90
|
+
if (flags["is-company"]) params["is_company"] = true;
|
|
91
|
+
if (limit !== void 0) params["limit"] = limit;
|
|
92
|
+
if (cursor) params["cursor"] = cursor;
|
|
93
|
+
if (all) {
|
|
94
|
+
const fn = (p) => ns.profiles.listPosts(resolvedId, p);
|
|
95
|
+
for await (const item of streamAll(fn, params, {
|
|
96
|
+
maxPages,
|
|
97
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
98
|
+
})) {
|
|
99
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
const result = await ns.profiles.listPosts(resolvedId, params);
|
|
103
|
+
renderSuccess(result, outOpts, out);
|
|
104
|
+
}
|
|
105
|
+
} else if (flags.comments) {
|
|
106
|
+
const params = {};
|
|
107
|
+
if (limit !== void 0) params["limit"] = limit;
|
|
108
|
+
if (cursor) params["cursor"] = cursor;
|
|
109
|
+
if (all) {
|
|
110
|
+
const fn = (p) => ns.profiles.listComments(resolvedId, p);
|
|
111
|
+
for await (const item of streamAll(fn, params, {
|
|
112
|
+
maxPages,
|
|
113
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
114
|
+
})) {
|
|
115
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
const result = await ns.profiles.listComments(resolvedId, params);
|
|
119
|
+
renderSuccess(result, outOpts, out);
|
|
120
|
+
}
|
|
121
|
+
} else if (flags.reactions) {
|
|
122
|
+
const params = {};
|
|
123
|
+
if (limit !== void 0) params["limit"] = limit;
|
|
124
|
+
if (cursor) params["cursor"] = cursor;
|
|
125
|
+
if (all) {
|
|
126
|
+
const fn = (p) => ns.profiles.listReactions(resolvedId, p);
|
|
127
|
+
for await (const item of streamAll(fn, params, {
|
|
128
|
+
maxPages,
|
|
129
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
130
|
+
})) {
|
|
131
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
const result = await ns.profiles.listReactions(resolvedId, params);
|
|
135
|
+
renderSuccess(result, outOpts, out);
|
|
136
|
+
}
|
|
137
|
+
} else if (flags.followers) {
|
|
138
|
+
const params = {};
|
|
139
|
+
if (limit !== void 0) params["limit"] = limit;
|
|
140
|
+
if (cursor) params["cursor"] = cursor;
|
|
141
|
+
if (all) {
|
|
142
|
+
const fn = (p) => ns.profiles.listFollowers(resolvedId, p);
|
|
143
|
+
for await (const item of streamAll(fn, params, {
|
|
144
|
+
maxPages,
|
|
145
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
146
|
+
})) {
|
|
147
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
const result = await ns.profiles.listFollowers(resolvedId, params);
|
|
151
|
+
renderSuccess(result, outOpts, out);
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
rejectAllOnNonPaginated(flags.all, out);
|
|
155
|
+
const params = {};
|
|
156
|
+
if (flags.notify) params["notify"] = true;
|
|
157
|
+
const result = await ns.profiles.get(resolvedId, params);
|
|
158
|
+
renderSuccess(result, outOpts, out);
|
|
159
|
+
}
|
|
160
|
+
} catch (err) {
|
|
161
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
162
|
+
if (err instanceof CurviateError) {
|
|
163
|
+
const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
|
|
164
|
+
renderError(err, outOpts, out);
|
|
165
|
+
process.exit(getExitCode(err.code));
|
|
166
|
+
}
|
|
167
|
+
renderUnexpectedError(err, out);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function runProfileConnections(client, flags, out) {
|
|
172
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
173
|
+
const accountId = requireAccount(flags.account, out);
|
|
174
|
+
const ns = client.account(accountId);
|
|
175
|
+
const outOpts = resolveOutputOpts(flags);
|
|
176
|
+
const all = flags.all ?? false;
|
|
177
|
+
const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
|
|
178
|
+
const limit = flags.limit ? parseInt(flags.limit, 10) : void 0;
|
|
179
|
+
const cursor = flags.cursor;
|
|
180
|
+
const params = {};
|
|
181
|
+
if (limit !== void 0) params["limit"] = limit;
|
|
182
|
+
if (cursor) params["cursor"] = cursor;
|
|
183
|
+
try {
|
|
184
|
+
if (all) {
|
|
185
|
+
const fn = (p) => ns.profiles.listConnections(p);
|
|
186
|
+
for await (const item of streamAll(fn, params, {
|
|
187
|
+
maxPages,
|
|
188
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
189
|
+
})) {
|
|
190
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
const result = await ns.profiles.listConnections(params);
|
|
194
|
+
renderSuccess(result, outOpts, out);
|
|
195
|
+
}
|
|
196
|
+
} catch (err) {
|
|
197
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
198
|
+
if (err instanceof CurviateError) {
|
|
199
|
+
const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
|
|
200
|
+
renderError(err, outOpts, out);
|
|
201
|
+
process.exit(getExitCode(err.code));
|
|
202
|
+
}
|
|
203
|
+
renderUnexpectedError(err, out);
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async function runProfileEndorse(client, flags, out) {
|
|
208
|
+
const accountId = requireAccount(flags.account, out);
|
|
209
|
+
const rawId = flags.id ?? "";
|
|
210
|
+
const resolvedId = resolveIdentifier(rawId);
|
|
211
|
+
const skillId = flags.skill ?? "";
|
|
212
|
+
const outOpts = resolveOutputOpts(flags);
|
|
213
|
+
if (flags.preview) {
|
|
214
|
+
const preview = buildPreviewOutput({
|
|
215
|
+
method: "profiles.endorse",
|
|
216
|
+
args: { id: resolvedId },
|
|
217
|
+
body: { skill_endorsement_id: skillId },
|
|
218
|
+
account: accountId
|
|
219
|
+
});
|
|
220
|
+
out.stdout.write(JSON.stringify(preview) + "\n");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const ns = client.account(accountId);
|
|
224
|
+
try {
|
|
225
|
+
const result = await ns.profiles.endorse(resolvedId, { skill_endorsement_id: skillId });
|
|
226
|
+
renderSuccess(result, outOpts, out);
|
|
227
|
+
} catch (err) {
|
|
228
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
229
|
+
if (err instanceof CurviateError) {
|
|
230
|
+
const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
|
|
231
|
+
renderError(err, outOpts, out);
|
|
232
|
+
process.exit(getExitCode(err.code));
|
|
233
|
+
}
|
|
234
|
+
renderUnexpectedError(err, out);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
var profileMeCommand = defineCommand({
|
|
239
|
+
meta: { name: "me", description: "Get your own LinkedIn profile." },
|
|
240
|
+
args: { ...GLOBAL_FLAGS },
|
|
241
|
+
async run({ args }) {
|
|
242
|
+
const flags = args;
|
|
243
|
+
const cfg = await resolveEffectiveConfig({
|
|
244
|
+
apiKey: flags["api-key"],
|
|
245
|
+
baseUrl: flags["base-url"],
|
|
246
|
+
timeout: flags.timeout,
|
|
247
|
+
account: flags.account,
|
|
248
|
+
profile: flags.profile
|
|
249
|
+
});
|
|
250
|
+
if (!cfg.apiKey) {
|
|
251
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
252
|
+
process.exit(3);
|
|
253
|
+
}
|
|
254
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
255
|
+
const out = buildOutputStreams();
|
|
256
|
+
await runProfileMe(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
var profileConnectionsCommand = defineCommand({
|
|
260
|
+
meta: { name: "connections", description: "List your 1st-degree connections." },
|
|
261
|
+
args: { ...GLOBAL_FLAGS },
|
|
262
|
+
async run({ args }) {
|
|
263
|
+
const flags = args;
|
|
264
|
+
const cfg = await resolveEffectiveConfig({
|
|
265
|
+
apiKey: flags["api-key"],
|
|
266
|
+
baseUrl: flags["base-url"],
|
|
267
|
+
timeout: flags.timeout,
|
|
268
|
+
account: flags.account,
|
|
269
|
+
profile: flags.profile
|
|
270
|
+
});
|
|
271
|
+
if (!cfg.apiKey) {
|
|
272
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
273
|
+
process.exit(3);
|
|
274
|
+
}
|
|
275
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
276
|
+
const out = buildOutputStreams();
|
|
277
|
+
await runProfileConnections(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
var profileEndorseCommand = defineCommand({
|
|
281
|
+
meta: { name: "endorse", description: "Endorse a skill on a member's profile." },
|
|
282
|
+
args: {
|
|
283
|
+
...GLOBAL_FLAGS,
|
|
284
|
+
id: { type: "positional", description: "Member identifier (URL, slug, or URN)." },
|
|
285
|
+
skill: { type: "string", description: "Skill endorsement ID to endorse.", required: true }
|
|
286
|
+
},
|
|
287
|
+
async run({ args }) {
|
|
288
|
+
const flags = args;
|
|
289
|
+
const cfg = await resolveEffectiveConfig({
|
|
290
|
+
apiKey: args["api-key"],
|
|
291
|
+
baseUrl: args["base-url"],
|
|
292
|
+
timeout: args.timeout,
|
|
293
|
+
account: flags.account,
|
|
294
|
+
profile: args.profile
|
|
295
|
+
});
|
|
296
|
+
if (!cfg.apiKey) {
|
|
297
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
298
|
+
process.exit(3);
|
|
299
|
+
}
|
|
300
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
301
|
+
const out = buildOutputStreams();
|
|
302
|
+
await runProfileEndorse(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
var profileCommand = defineCommand({
|
|
306
|
+
meta: { name: "profile", description: "LinkedIn profile operations." },
|
|
307
|
+
args: {
|
|
308
|
+
...GLOBAL_FLAGS,
|
|
309
|
+
id: { type: "positional", description: "Member identifier (URL, slug, or URN). Optional for subcommands.", required: false },
|
|
310
|
+
posts: { type: "boolean", description: "List the profile's posts.", default: false },
|
|
311
|
+
comments: { type: "boolean", description: "List the profile's comments.", default: false },
|
|
312
|
+
reactions: { type: "boolean", description: "List the profile's reactions.", default: false },
|
|
313
|
+
followers: { type: "boolean", description: "List the profile's followers.", default: false },
|
|
314
|
+
"is-company": { type: "boolean", description: "When listing posts, treat the profile as a company page.", default: false },
|
|
315
|
+
notify: { type: "boolean", description: "Signal a profile view when fetching.", default: false }
|
|
316
|
+
},
|
|
317
|
+
subCommands: {
|
|
318
|
+
me: profileMeCommand,
|
|
319
|
+
connections: profileConnectionsCommand,
|
|
320
|
+
endorse: profileEndorseCommand
|
|
321
|
+
},
|
|
322
|
+
async run({ args }) {
|
|
323
|
+
const flags = args;
|
|
324
|
+
if (!flags.id) {
|
|
325
|
+
process.stderr.write(
|
|
326
|
+
"Usage: curviate profile <id> [--posts|--comments|--reactions|--followers]\n curviate profile me\n curviate profile connections\n curviate profile endorse <id> --skill <sid>\n"
|
|
327
|
+
);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const cfg = await resolveEffectiveConfig({
|
|
331
|
+
apiKey: flags["api-key"],
|
|
332
|
+
baseUrl: flags["base-url"],
|
|
333
|
+
timeout: flags.timeout,
|
|
334
|
+
account: flags.account,
|
|
335
|
+
profile: flags.profile
|
|
336
|
+
});
|
|
337
|
+
if (!cfg.apiKey) {
|
|
338
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
339
|
+
process.exit(3);
|
|
340
|
+
}
|
|
341
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
342
|
+
const out = buildOutputStreams();
|
|
343
|
+
await runProfileGet(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
export {
|
|
347
|
+
profileCommand,
|
|
348
|
+
runProfileConnections,
|
|
349
|
+
runProfileEndorse,
|
|
350
|
+
runProfileGet,
|
|
351
|
+
runProfileMe
|
|
352
|
+
};
|